Widget Features: - Add inline voting to timeline widget when no entry exists for today - Show random prompt from notification strings in voting mode - Update vote widget to use simple icon style for selection - Make stats bar full width in voted state view - Add Localizable.strings to widget extension target Bug Fixes: - Fix inverted date calculation in InsightsViewModel streak logic - Replace force unwraps with safe optional handling in widgets - Replace fatalError calls with graceful error handling - Fix CSV import safety in SettingsView Warning Fixes: - Add @retroactive to Color and Date extension conformances - Update deprecated onChange(of:perform:) to new syntax - Replace deprecated applicationIconBadgeNumber with setBadgeCount - Replace deprecated UIApplication.shared.windows API - Add @preconcurrency for Swift 6 protocol conformances - Add missing widget family cases to switch statement - Remove unused variables and #warning directives 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
94 lines
3.3 KiB
Swift
94 lines
3.3 KiB
Swift
//
|
|
// MainTabView.swift
|
|
// Feels (iOS)
|
|
//
|
|
// Created by Trey Tartt on 2/18/22.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct MainTabView: View {
|
|
@AppStorage(UserDefaultsStore.Keys.needsOnboarding.rawValue, store: GroupUserDefaults.groupDefaults) private var needsOnboarding = true
|
|
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
|
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
|
|
@AppStorage(UserDefaultsStore.Keys.textColor.rawValue, store: GroupUserDefaults.groupDefaults) private var textColor: Color = DefaultTextColor.textColor
|
|
|
|
|
|
let onboardingData = OnboardingDataDataManager.shared.savedOnboardingData
|
|
|
|
let dayView: DayView
|
|
let monthView: MonthView
|
|
let yearView: YearView
|
|
let insightsView: InsightsView
|
|
let customizeView: CustomizeView
|
|
|
|
var body: some View {
|
|
return TabView {
|
|
dayView
|
|
.tabItem {
|
|
Label(String(localized: "content_view_tab_main"), systemImage: "list.dash")
|
|
}
|
|
|
|
monthView
|
|
.tabItem {
|
|
Label(String(localized: "content_view_tab_month"), systemImage: "calendar")
|
|
}
|
|
|
|
yearView
|
|
.tabItem {
|
|
Label(String(localized: "content_view_tab_filter"), systemImage: "line.3.horizontal.decrease.circle")
|
|
}
|
|
|
|
insightsView
|
|
.tabItem {
|
|
Label(String(localized: "content_view_tab_insights"), systemImage: "lightbulb.fill")
|
|
}
|
|
|
|
customizeView
|
|
.tabItem {
|
|
Label(String(localized: "content_view_tab_customize"), systemImage: "pencil")
|
|
}
|
|
}
|
|
.accentColor(textColor)
|
|
.sheet(isPresented: $needsOnboarding, onDismiss: { }, content: {
|
|
OnboardingMain(onboardingData: onboardingData,
|
|
updateBoardingDataClosure: { onboardingData in
|
|
needsOnboarding = false
|
|
OnboardingDataDataManager.shared.updateOnboardingData(onboardingData: onboardingData)
|
|
})
|
|
})
|
|
.onAppear(perform: {
|
|
applyTheme(theme)
|
|
})
|
|
.onChange(of: theme) { _, newTheme in
|
|
applyTheme(newTheme)
|
|
}
|
|
}
|
|
|
|
private func applyTheme(_ theme: Theme) {
|
|
let style: UIUserInterfaceStyle
|
|
switch theme {
|
|
case .system, .iFeel:
|
|
style = .unspecified
|
|
case .dark:
|
|
style = .dark
|
|
case .light:
|
|
style = .light
|
|
}
|
|
|
|
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
|
let window = windowScene.windows.first else { return }
|
|
window.overrideUserInterfaceStyle = style
|
|
}
|
|
}
|
|
|
|
struct MainTabView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
MainTabView(dayView: DayView(viewModel: DayViewViewModel(addMonthStartWeekdayPadding: false)),
|
|
monthView: MonthView(viewModel: DayViewViewModel(addMonthStartWeekdayPadding: true)),
|
|
yearView: YearView(viewModel: YearViewModel()),
|
|
insightsView: InsightsView(),
|
|
customizeView: CustomizeView())
|
|
}
|
|
}
|