Add Welcome screen

This commit is contained in:
Arkadiusz Fal
2021-10-18 01:06:00 +02:00
parent 0d1eaaca5c
commit ec395ff2e0
16 changed files with 187 additions and 42 deletions

View File

@@ -3,7 +3,6 @@ import SwiftUI
struct AccountsMenuView: View {
@EnvironmentObject<AccountsModel> private var model
@EnvironmentObject<InstancesModel> private var instancesModel
@Default(.instances) private var instances

View File

@@ -37,7 +37,12 @@ struct AppSidebarNavigation: View {
.toolbar { toolbarContent }
.frame(minWidth: sidebarMinWidth)
Text("Select section")
VStack {
Image(systemName: "play.tv")
.renderingMode(.original)
.font(.system(size: 60))
.foregroundColor(.accentColor)
}
}
.environment(\.navigationStyle, .sidebar)
}

View File

@@ -39,6 +39,11 @@ struct ContentView: View {
.environmentObject(recents)
.environmentObject(search)
.environmentObject(subscriptions)
.sheet(isPresented: $navigation.presentingWelcomeScreen) {
WelcomeScreen()
.environmentObject(accounts)
.environmentObject(navigation)
}
#if os(iOS)
.fullScreenCover(isPresented: $player.presentingPlayer) {
VideoPlayerView()
@@ -68,8 +73,9 @@ struct ContentView: View {
PlaylistFormView(playlist: $navigation.editedPlaylist)
.environmentObject(playlists)
}
.sheet(isPresented: $navigation.presentingSettings) {
.sheet(isPresented: $navigation.presentingSettings, onDismiss: openWelcomeScreenIfAccountEmpty) {
SettingsView()
.environmentObject(accounts)
.environmentObject(instances)
}
#endif
@@ -78,17 +84,29 @@ struct ContentView: View {
func configure() {
SiestaLog.Category.enabled = .common
// TODO: Remove when piped supports videos information
if let account = instances.defaultAccount ??
// TODO: Remove when piped supports videos information
accounts.all.first(where: { $0.instance.app == .invidious })
{
accounts.setAccount(account)
}
if accounts.account.isNil {
navigation.presentingWelcomeScreen = true
}
player.accounts = accounts
playlists.accounts = accounts
search.accounts = accounts
subscriptions.accounts = accounts
}
func openWelcomeScreenIfAccountEmpty() {
guard accounts.isEmpty else {
return
}
navigation.presentingWelcomeScreen = true
}
}
struct ContentView_Previews: PreviewProvider {

View File

@@ -7,14 +7,16 @@ struct Sidebar: View {
var body: some View {
ScrollViewReader { scrollView in
List {
mainNavigationLinks
if !accounts.isEmpty {
mainNavigationLinks
AppSidebarRecents()
.id("recentlyOpened")
AppSidebarRecents()
.id("recentlyOpened")
if accounts.signedIn {
AppSidebarSubscriptions()
AppSidebarPlaylists()
if accounts.signedIn {
AppSidebarSubscriptions()
AppSidebarPlaylists()
}
}
}
.onChange(of: navigation.sidebarSectionChanged) { _ in