89 lines
3.3 KiB
Swift
89 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
|
|
|
|
let onboardingData = OnboardingDataDataManager.shared.savedOnboardingData
|
|
|
|
var body: some View {
|
|
TabView {
|
|
HomeViewTwo()
|
|
.tabItem {
|
|
Label(String(localized: "content_view_tab_main"), systemImage: "calendar")
|
|
}
|
|
|
|
HomeView()
|
|
.tabItem {
|
|
Label(String(localized: "content_view_tab_main"), systemImage: "list.dash")
|
|
}
|
|
|
|
FilterView()
|
|
.tabItem {
|
|
Label(String(localized: "content_view_tab_filter"), systemImage: "line.3.horizontal.decrease.circle")
|
|
}
|
|
|
|
SharingListView()
|
|
.tabItem {
|
|
Label(String(localized: "content_view_tab_share"), systemImage: "square.and.arrow.up")
|
|
}
|
|
|
|
CustomizeView()
|
|
.tabItem {
|
|
Label(String(localized: "content_view_tab_customize"), systemImage: "pencil")
|
|
}
|
|
}
|
|
.accentColor(moodTint.color(forMood: .average))
|
|
.sheet(isPresented: $needsOnboarding, onDismiss: {
|
|
|
|
}, content: {
|
|
OnboardingMain(onboardingData: onboardingData,
|
|
updateBoardingDataClosure: { onboardingData in
|
|
needsOnboarding = false
|
|
OnboardingDataDataManager.shared.updateOnboardingData(onboardingData: onboardingData)
|
|
})
|
|
})
|
|
.onAppear(perform: {
|
|
switch theme {
|
|
case .system:
|
|
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .unspecified
|
|
case .iFeel:
|
|
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .unspecified
|
|
case .dark:
|
|
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .dark
|
|
case .light:
|
|
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .light
|
|
}
|
|
})
|
|
.onChange(of: theme, perform: { value in
|
|
print("changed to ", value)
|
|
switch theme {
|
|
case .system:
|
|
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .unspecified
|
|
case .iFeel:
|
|
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .unspecified
|
|
case .dark:
|
|
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .dark
|
|
case .light:
|
|
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .light
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
struct MainTabView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
MainTabView()
|
|
}
|
|
}
|