1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-14 14:20:32 +05:30

Improve sections visibility

This commit is contained in:
Arkadiusz Fal 2022-11-11 20:34:20 +01:00
parent 4c2d473caa
commit fa0523d3c6
9 changed files with 71 additions and 53 deletions

View File

@ -49,10 +49,6 @@ final class AccountsModel: ObservableObject {
!isEmpty && !current.anonymous && api.signedIn !isEmpty && !current.anonymous && api.signedIn
} }
var isDemo: Bool {
false
}
init() { init() {
cancellables.append( cancellables.append(
invidious.objectWillChange.sink { [weak self] _ in self?.objectWillChange.send() } invidious.objectWillChange.sink { [weak self] _ in self?.objectWillChange.send() }
@ -80,6 +76,7 @@ final class AccountsModel: ObservableObject {
current = account current = account
guard !account.isNil else { guard !account.isNil else {
current = nil
return return
} }

View File

@ -39,8 +39,10 @@ struct AppTabNavigation: View {
playlistsNavigationView playlistsNavigationView
} }
if !accounts.isEmpty {
searchNavigationView searchNavigationView
} }
}
.id(accounts.current?.id ?? "") .id(accounts.current?.id ?? "")
.overlay(playlistView) .overlay(playlistView)
.overlay(channelView) .overlay(channelView)

View File

@ -73,6 +73,7 @@ struct Sidebar: View {
.id("trending") .id("trending")
} }
if !accounts.isEmpty {
NavigationLink(destination: LazyView(SearchView()), tag: TabSelection.search, selection: $navigation.tabSelection) { NavigationLink(destination: LazyView(SearchView()), tag: TabSelection.search, selection: $navigation.tabSelection) {
Label("Search", systemImage: "magnifyingglass") Label("Search", systemImage: "magnifyingglass")
.accessibility(label: Text("Search")) .accessibility(label: Text("Search"))
@ -81,6 +82,7 @@ struct Sidebar: View {
.keyboardShortcut("f") .keyboardShortcut("f")
} }
} }
}
private func scrollScrollViewToItem(scrollView: ScrollViewProxy, for selection: TabSelection) { private func scrollScrollViewToItem(scrollView: ScrollViewProxy, for selection: TabSelection) {
if case .recentlyOpened = selection { if case .recentlyOpened = selection {

View File

@ -46,6 +46,10 @@ struct AdvancedSettings: View {
InstancesManifest.shared.setPublicAccount(newCountry, accounts: accounts, asCurrent: accounts.current?.isPublic ?? true) InstancesManifest.shared.setPublicAccount(newCountry, accounts: accounts, asCurrent: accounts.current?.isPublic ?? true)
} }
.onChange(of: instancesManifest) { _ in .onChange(of: instancesManifest) { _ in
countryOfPublicInstances = nil
if let account = accounts.current, account.isPublic {
accounts.setCurrent(nil)
}
countries.removeAll() countries.removeAll()
} }
.sheet(isPresented: $presentingInstanceForm) { .sheet(isPresented: $presentingInstanceForm) {

View File

@ -62,7 +62,9 @@ struct PlayerSettings: View {
private var sections: some View { private var sections: some View {
Group { Group {
Section(header: SettingsHeader(text: "Playback".localized())) { Section(header: SettingsHeader(text: "Playback".localized())) {
if !accounts.isEmpty {
sourcePicker sourcePicker
}
pauseOnHidingPlayerToggle pauseOnHidingPlayerToggle
#if !os(macOS) #if !os(macOS)
pauseOnEnteringBackgroundToogle pauseOnEnteringBackgroundToogle
@ -97,9 +99,8 @@ struct PlayerSettings: View {
sidebarPicker sidebarPicker
#endif #endif
if !accounts.isEmpty {
keywordsToggle keywordsToggle
if !accounts.isDemo {
returnYouTubeDislikeToggle returnYouTubeDislikeToggle
} }
} }

View File

@ -10,7 +10,7 @@ struct SettingsView: View {
case browsing, player, quality, history, sponsorBlock, advanced, help case browsing, player, quality, history, sponsorBlock, advanced, help
} }
@State private var selection = Tabs.browsing @State private var selection: Tabs?
#endif #endif
@Environment(\.colorScheme) private var colorScheme @Environment(\.colorScheme) private var colorScheme
@ -34,13 +34,15 @@ struct SettingsView: View {
var settings: some View { var settings: some View {
#if os(macOS) #if os(macOS)
TabView(selection: $selection) { TabView(selection: $selection) {
if !accounts.isEmpty {
Form { Form {
BrowsingSettings() BrowsingSettings()
} }
.tabItem { .tabItem {
Label("Browsing", systemImage: "list.and.film") Label("Browsing", systemImage: "list.and.film")
} }
.tag(Tabs.browsing) .tag(Optional(Tabs.browsing))
}
Form { Form {
PlayerSettings() PlayerSettings()
@ -48,7 +50,7 @@ struct SettingsView: View {
.tabItem { .tabItem {
Label("Player", systemImage: "play.rectangle") Label("Player", systemImage: "play.rectangle")
} }
.tag(Tabs.player) .tag(Optional(Tabs.player))
Form { Form {
QualitySettings() QualitySettings()
@ -56,7 +58,7 @@ struct SettingsView: View {
.tabItem { .tabItem {
Label("Quality", systemImage: "4k.tv") Label("Quality", systemImage: "4k.tv")
} }
.tag(Tabs.quality) .tag(Optional(Tabs.quality))
Form { Form {
HistorySettings() HistorySettings()
@ -64,15 +66,17 @@ struct SettingsView: View {
.tabItem { .tabItem {
Label("History", systemImage: "clock.arrow.circlepath") Label("History", systemImage: "clock.arrow.circlepath")
} }
.tag(Tabs.history) .tag(Optional(Tabs.history))
if !accounts.isEmpty {
Form { Form {
SponsorBlockSettings() SponsorBlockSettings()
} }
.tabItem { .tabItem {
Label("SponsorBlock", systemImage: "dollarsign.circle") Label("SponsorBlock", systemImage: "dollarsign.circle")
} }
.tag(Tabs.sponsorBlock) .tag(Optional(Tabs.sponsorBlock))
}
Group { Group {
AdvancedSettings() AdvancedSettings()
@ -80,7 +84,7 @@ struct SettingsView: View {
.tabItem { .tabItem {
Label("Advanced", systemImage: "wrench.and.screwdriver") Label("Advanced", systemImage: "wrench.and.screwdriver")
} }
.tag(Tabs.advanced) .tag(Optional(Tabs.advanced))
Form { Form {
Help() Help()
@ -88,7 +92,7 @@ struct SettingsView: View {
.tabItem { .tabItem {
Label("Help", systemImage: "questionmark.circle") Label("Help", systemImage: "questionmark.circle")
} }
.tag(Tabs.help) .tag(Optional(Tabs.help))
} }
.padding(20) .padding(20)
.frame(width: 600, height: windowHeight) .frame(width: 600, height: windowHeight)
@ -106,8 +110,10 @@ struct SettingsView: View {
var settingsList: some View { var settingsList: some View {
List { List {
#if os(tvOS) #if os(tvOS)
if !accounts.isEmpty {
AccountSelectionView() AccountSelectionView()
Divider() Divider()
}
#endif #endif
Section { Section {
@ -119,11 +125,13 @@ struct SettingsView: View {
} }
#endif #endif
if !accounts.isEmpty {
NavigationLink { NavigationLink {
BrowsingSettings() BrowsingSettings()
} label: { } label: {
Label("Browsing", systemImage: "list.and.film") Label("Browsing", systemImage: "list.and.film")
} }
}
NavigationLink { NavigationLink {
PlayerSettings() PlayerSettings()
@ -143,11 +151,13 @@ struct SettingsView: View {
Label("History", systemImage: "clock.arrow.circlepath") Label("History", systemImage: "clock.arrow.circlepath")
} }
if !accounts.isEmpty {
NavigationLink { NavigationLink {
SponsorBlockSettings() SponsorBlockSettings()
} label: { } label: {
Label("SponsorBlock", systemImage: "dollarsign.circle") Label("SponsorBlock", systemImage: "dollarsign.circle")
} }
}
NavigationLink { NavigationLink {
AdvancedSettings() AdvancedSettings()
@ -210,6 +220,8 @@ struct SettingsView: View {
#if os(macOS) #if os(macOS)
private var windowHeight: Double { private var windowHeight: Double {
switch selection { switch selection {
case nil:
return accounts.isEmpty ? 680 : 400
case .browsing: case .browsing:
return 400 return 400
case .player: case .player:

View File

@ -19,7 +19,7 @@ struct ShareButton: View {
} else { } else {
instanceActions instanceActions
Divider() Divider()
if !accounts.isDemo { if !accounts.isEmpty {
youtubeActions youtubeActions
} }
} }

View File

@ -35,7 +35,7 @@ struct InstancesSettings: View {
Spacer() Spacer()
} }
if !selectedInstance.isNil, selectedInstance.app.supportsAccounts, !accounts.isDemo { if !selectedInstance.isNil, selectedInstance.app.supportsAccounts {
SettingsHeader(text: "Accounts".localized()) SettingsHeader(text: "Accounts".localized())
let list = List(selection: $selectedAccount) { let list = List(selection: $selectedAccount) {
@ -114,13 +114,11 @@ struct InstancesSettings: View {
if selectedInstance != nil { if selectedInstance != nil {
HStack { HStack {
if !accounts.isDemo {
Button("Add Account...") { Button("Add Account...") {
selectedAccount = nil selectedAccount = nil
presentingAccountForm = true presentingAccountForm = true
} }
.disabled(!selectedInstance.app.supportsAccounts) .disabled(!selectedInstance.app.supportsAccounts)
}
Spacer() Spacer()

View File

@ -47,9 +47,11 @@ struct TVNavigationView: View {
.tabItem { Text("Now Playing") } .tabItem { Text("Now Playing") }
.tag(TabSelection.nowPlaying) .tag(TabSelection.nowPlaying)
if !accounts.isEmpty {
LazyView(SearchView()) LazyView(SearchView())
.tabItem { Image(systemName: "magnifyingglass") } .tabItem { Image(systemName: "magnifyingglass") }
.tag(TabSelection.search) .tag(TabSelection.search)
}
LazyView(SettingsView()) LazyView(SettingsView())
.tabItem { Image(systemName: "gear") } .tabItem { Image(systemName: "gear") }