yattee/Shared/Views/WelcomeScreen.swift

66 lines
1.7 KiB
Swift
Raw Normal View History

import Defaults
2021-10-17 23:06:00 +00:00
import SwiftUI
struct WelcomeScreen: View {
@Environment(\.dismiss) private var dismiss
@EnvironmentObject<AccountsModel> private var accounts
@Default(.accounts) private var allAccounts
2021-10-17 23:06:00 +00:00
var body: some View {
VStack {
Spacer()
Text("Welcome")
.font(.largeTitle)
.padding(.bottom, 10)
if allAccounts.isEmpty {
2021-10-17 23:06:00 +00:00
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 {
dismiss()
} label: {
Text("Start")
}
.opacity(accounts.current.isNil ? 0 : 1)
.disabled(accounts.current.isNil)
2021-10-17 23:06:00 +00:00
#else
AccountsMenuView()
.onChange(of: accounts.current) { _ in
2021-10-17 23:06:00 +00:00
dismiss()
}
#if os(macOS)
.frame(maxWidth: 280)
#endif
#endif
}
Spacer()
OpenSettingsButton()
Spacer()
}
.interactiveDismissDisabled()
#if os(macOS)
.frame(minWidth: 400, minHeight: 400)
#endif
}
}
struct WelcomeScreen_Previews: PreviewProvider {
static var previews: some View {
WelcomeScreen()
.injectFixtureEnvironmentObjects()
}
}