1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-15 23:00:32 +05:30
yattee/Shared/Views/WelcomeScreen.swift

72 lines
1.9 KiB
Swift
Raw Normal View History

import Defaults
2021-10-18 04:36:00 +05:30
import SwiftUI
struct WelcomeScreen: View {
2021-11-28 20:07:55 +05:30
@Environment(\.presentationMode) private var presentationMode
2021-10-18 04:36:00 +05:30
@EnvironmentObject<AccountsModel> private var accounts
@Default(.accounts) private var allAccounts
2021-10-18 04:36:00 +05:30
var body: some View {
2021-11-28 20:07:55 +05:30
let welcomeScreen = VStack {
2021-10-18 04:36:00 +05:30
Spacer()
Text("Welcome")
.font(.largeTitle)
.padding(.bottom, 10)
if allAccounts.isEmpty {
2021-10-18 04:36:00 +05:30
Text("To start, configure your Instances in Settings")
.foregroundColor(.secondary)
} else {
Text("To start, pick one of your accounts:")
.foregroundColor(.secondary)
#if os(tvOS)
AccountSelectionView(showHeader: false)
Button {
2021-11-28 20:07:55 +05:30
presentationMode.wrappedValue.dismiss()
2021-10-18 04:36:00 +05:30
} label: {
Text("Start")
}
.opacity(accounts.current.isNil ? 0 : 1)
.disabled(accounts.current.isNil)
2021-10-18 04:36:00 +05:30
#else
AccountsMenuView()
.onChange(of: accounts.current) { _ in
2021-11-28 20:07:55 +05:30
presentationMode.wrappedValue.dismiss()
2021-10-18 04:36:00 +05:30
}
#if os(macOS)
.frame(maxWidth: 280)
#endif
#endif
}
Spacer()
OpenSettingsButton()
Spacer()
}
#if os(macOS)
2021-11-28 20:07:55 +05:30
.frame(minWidth: 400, minHeight: 400)
2021-10-18 04:36:00 +05:30
#endif
2021-11-28 20:07:55 +05:30
if #available(iOS 15.0, macOS 12.0, tvOS 15.0, *) {
welcomeScreen
.interactiveDismissDisabled()
} else {
welcomeScreen
}
2021-10-18 04:36:00 +05:30
}
}
struct WelcomeScreen_Previews: PreviewProvider {
static var previews: some View {
WelcomeScreen()
.injectFixtureEnvironmentObjects()
}
}