TheNoiseClock/TheNoiseClock/Features/Clock/Views/Components/Settings/NightModeSection.swift
Matt Bruce a3398f0dd0 refactored with bedrock and organized folders
Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
2026-01-31 10:46:41 -06:00

92 lines
3.2 KiB
Swift

//
// NightModeSection.swift
// TheNoiseClock
//
// Created by Matt Bruce on 9/7/25.
//
import SwiftUI
import Bedrock
struct NightModeSection: View {
@Binding var style: ClockStyle
var body: some View {
VStack(alignment: .leading, spacing: Design.Spacing.small) {
SettingsSectionHeader(
title: "Night Mode",
systemImage: "moon.stars.fill",
accentColor: AppAccent.primary
)
SettingsCard(backgroundColor: AppSurface.card, borderColor: AppBorder.subtle) {
SettingsToggle(
title: "Enable Night Mode",
subtitle: "Use a red clock for low light",
isOn: $style.nightModeEnabled,
accentColor: AppAccent.primary
)
SettingsToggle(
title: "Auto Night Mode",
subtitle: "Trigger based on ambient light",
isOn: $style.autoNightMode,
accentColor: AppAccent.primary
)
if style.autoNightMode {
SettingsSlider(
title: "Light Threshold",
subtitle: "Lower values activate sooner",
value: $style.ambientLightThreshold,
in: 0.1...0.8,
step: 0.01,
format: SliderFormat.percentage,
accentColor: AppAccent.primary
)
}
SettingsToggle(
title: "Scheduled Night Mode",
subtitle: "Enable on a daily schedule",
isOn: $style.scheduledNightMode,
accentColor: AppAccent.primary
)
if style.scheduledNightMode {
HStack {
Text("Start Time")
.font(.subheadline.weight(.medium))
.foregroundStyle(AppTextColors.primary)
Spacer()
TimePickerView(timeString: $style.nightModeStartTime)
}
HStack {
Text("End Time")
.font(.subheadline.weight(.medium))
.foregroundStyle(AppTextColors.primary)
Spacer()
TimePickerView(timeString: $style.nightModeEndTime)
}
}
if style.isNightModeActive {
HStack(spacing: Design.Spacing.xSmall) {
Image(systemName: "moon.fill")
.foregroundStyle(AppStatus.error)
Text("Night Mode Active")
.font(.subheadline.weight(.medium))
.foregroundStyle(AppStatus.error)
Spacer()
}
}
}
Text("Night mode displays the clock in red to reduce eye strain in low light environments.")
.font(.caption)
.foregroundStyle(AppTextColors.tertiary)
}
}
}