52 lines
1.3 KiB
Swift
52 lines
1.3 KiB
Swift
//
|
|
// TopOverlayView.swift
|
|
// TheNoiseClock
|
|
//
|
|
// Created by Matt Bruce on 9/7/25.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
/// Component for displaying top overlay with battery and date information
|
|
struct TopOverlayView: View {
|
|
|
|
// MARK: - Properties
|
|
let showBattery: Bool
|
|
let showDate: Bool
|
|
let color: Color
|
|
let opacity: Double
|
|
let dateFormat: String
|
|
|
|
@State private var batteryService = BatteryService.shared
|
|
|
|
// MARK: - Body
|
|
var body: some View {
|
|
HStack {
|
|
if showDate {
|
|
DateOverlayView(color: color, opacity: opacity, dateFormat: dateFormat)
|
|
}
|
|
|
|
Spacer()
|
|
|
|
if showBattery {
|
|
BatteryOverlayView(
|
|
color: color,
|
|
opacity: opacity,
|
|
batteryLevel: batteryService.batteryLevel,
|
|
isCharging: batteryService.isCharging
|
|
)
|
|
}
|
|
}
|
|
.padding(.horizontal, UIConstants.Spacing.medium)
|
|
.padding(.vertical, UIConstants.Spacing.small)
|
|
.cardStyle()
|
|
.transition(.opacity)
|
|
.onAppear {
|
|
batteryService.startMonitoring()
|
|
}
|
|
.onDisappear {
|
|
batteryService.stopMonitoring()
|
|
}
|
|
}
|
|
}
|