From 99769380fc37c6df675d511605bb9f2e812f4c42 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sat, 19 Nov 2022 00:38:32 +0100 Subject: [PATCH] Localization and platform availability fixes --- Backports/ListRowSeparator+Backport.swift | 7 +++- Shared/Home/HomeView.swift | 41 ++++++++++++--------- Shared/Navigation/Sidebar.swift | 4 +- Shared/Settings/BrowsingSettings.swift | 45 ++++++++++++++--------- Shared/Settings/EditFavorites.swift | 6 +-- Shared/Settings/PlayerSettings.swift | 3 +- Shared/Settings/SettingsView.swift | 4 +- 7 files changed, 64 insertions(+), 46 deletions(-) diff --git a/Backports/ListRowSeparator+Backport.swift b/Backports/ListRowSeparator+Backport.swift index 7c6ff85a..78d17bc3 100644 --- a/Backports/ListRowSeparator+Backport.swift +++ b/Backports/ListRowSeparator+Backport.swift @@ -3,8 +3,11 @@ import SwiftUI extension Backport where Content: View { @ViewBuilder func listRowSeparator(_ visible: Bool) -> some View { - if #available(iOS 15, macOS 12, tvOS 15, *) { - content.listRowSeparator(visible ? .visible : .hidden) + if #available(iOS 15, macOS 13, *) { + content + #if !os(tvOS) + .listRowSeparator(visible ? .visible : .hidden) + #endif } else { content } diff --git a/Shared/Home/HomeView.swift b/Shared/Home/HomeView.swift index fcc8ad7d..b661babc 100644 --- a/Shared/Home/HomeView.swift +++ b/Shared/Home/HomeView.swift @@ -47,6 +47,7 @@ struct HomeView: View { OpenVideosButton(text: "Settings", imageSystemName: "gear") { NavigationModel.shared.presentingSettings = true } + .frame(maxWidth: 600) } #else @@ -93,28 +94,30 @@ struct HomeView: View { #endif } - if homeRecentDocumentsItems > 0 { - VStack { - HStack { - sectionLabel("Recent Documents") + #if os(iOS) + if homeRecentDocumentsItems > 0 { + VStack { + HStack { + sectionLabel("Recent Documents") - Spacer() + Spacer() - Button { - recentDocumentsID = UUID() - } label: { - Label("Refresh", systemImage: "arrow.clockwise") - .font(.headline) - .labelStyle(.iconOnly) - .foregroundColor(.secondary) + Button { + recentDocumentsID = UUID() + } label: { + Label("Refresh", systemImage: "arrow.clockwise") + .font(.headline) + .labelStyle(.iconOnly) + .foregroundColor(.secondary) + } } - } - RecentDocumentsView(limit: homeRecentDocumentsItems) - .id(recentDocumentsID) + RecentDocumentsView(limit: homeRecentDocumentsItems) + .id(recentDocumentsID) + } + .frame(maxWidth: .infinity, alignment: .leading) } - .frame(maxWidth: .infinity, alignment: .leading) - } + #endif if homeHistoryItems > 0 { VStack { @@ -140,8 +143,10 @@ struct HomeView: View { .foregroundColor(.secondary) } } - .frame(maxWidth: .infinity, alignment: .leading) + #if os(tvOS) + .padding(.trailing, 40) + #endif HistoryView(limit: homeHistoryItems) .id(historyID) diff --git a/Shared/Navigation/Sidebar.swift b/Shared/Navigation/Sidebar.swift index 22e602eb..12ec9395 100644 --- a/Shared/Navigation/Sidebar.swift +++ b/Shared/Navigation/Sidebar.swift @@ -6,8 +6,10 @@ struct Sidebar: View { @EnvironmentObject private var navigation @Default(.showHome) private var showHome - @Default(.showDocuments) private var showDocuments @Default(.visibleSections) private var visibleSections + #if os(iOS) + @Default(.showDocuments) private var showDocuments + #endif var body: some View { ScrollViewReader { scrollView in diff --git a/Shared/Settings/BrowsingSettings.swift b/Shared/Settings/BrowsingSettings.swift index 72e9561a..2b1fdcd0 100644 --- a/Shared/Settings/BrowsingSettings.swift +++ b/Shared/Settings/BrowsingSettings.swift @@ -10,12 +10,12 @@ struct BrowsingSettings: View { #if os(iOS) @Default(.homeRecentDocumentsItems) private var homeRecentDocumentsItems @Default(.lockPortraitWhenBrowsing) private var lockPortraitWhenBrowsing + @Default(.showDocuments) private var showDocuments #endif @Default(.thumbnailsQuality) private var thumbnailsQuality @Default(.channelOnThumbnail) private var channelOnThumbnail @Default(.timeOnThumbnail) private var timeOnThumbnail @Default(.showHome) private var showHome - @Default(.showDocuments) private var showDocuments @Default(.showFavoritesInHome) private var showFavoritesInHome @Default(.showOpenActionsInHome) private var showOpenActionsInHome @Default(.showOpenActionsToolbarItem) private var showOpenActionsToolbarItem @@ -59,7 +59,14 @@ struct BrowsingSettings: View { private var sections: some View { Group { homeSettings - interfaceSettings + let interface = interfaceSettings + #if os(tvOS) + if !accounts.isEmpty { + interface + } + #else + interface + #endif if !accounts.isEmpty { thumbnailsSettings visibleSectionsSettings @@ -91,21 +98,23 @@ struct BrowsingSettings: View { } .multilineTextAlignment(.trailing) - HStack { - Text("Recent Documents") - TextField("Recent Documents", text: $homeRecentDocumentsItemsText) - .labelsHidden() - #if !os(macOS) - .keyboardType(.numberPad) - #endif - .onAppear { - homeRecentDocumentsItemsText = String(homeRecentDocumentsItems) - } - .onChange(of: homeRecentDocumentsItemsText) { newValue in - homeRecentDocumentsItems = Int(newValue) ?? 3 - } - } - .multilineTextAlignment(.trailing) + #if os(iOS) + HStack { + Text("Recent Documents") + TextField("Recent Documents", text: $homeRecentDocumentsItemsText) + .labelsHidden() + #if !os(macOS) + .keyboardType(.numberPad) + #endif + .onAppear { + homeRecentDocumentsItemsText = String(homeRecentDocumentsItems) + } + .onChange(of: homeRecentDocumentsItemsText) { newValue in + homeRecentDocumentsItems = Int(newValue) ?? 3 + } + } + .multilineTextAlignment(.trailing) + #endif if !accounts.isEmpty { Toggle("Show Favorites", isOn: $showFavoritesInHome) @@ -115,7 +124,7 @@ struct BrowsingSettings: View { Button { presentingEditFavoritesSheet = true } label: { - Text("Edit Favorites...") + Text("Edit Favorites…") } .sheet(isPresented: $presentingEditFavoritesSheet) { VStack(alignment: .leading) { diff --git a/Shared/Settings/EditFavorites.swift b/Shared/Settings/EditFavorites.swift index fdce3a4d..c316c4dd 100644 --- a/Shared/Settings/EditFavorites.swift +++ b/Shared/Settings/EditFavorites.swift @@ -104,18 +104,16 @@ struct EditFavorites: View { func label(_ item: FavoriteItem) -> String { if case let .playlist(id) = item.section { - return playlistsModel.find(id: id)?.title ?? "Playlist" + return playlistsModel.find(id: id)?.title ?? "Playlist".localized() } - return item.section.label + return item.section.label.localized() } } struct EditFavorites_Previews: PreviewProvider { static var previews: some View { -// NavigationView { EditFavorites() -// } .injectFixtureEnvironmentObjects() } } diff --git a/Shared/Settings/PlayerSettings.swift b/Shared/Settings/PlayerSettings.swift index 5e0bd459..6d4759bc 100644 --- a/Shared/Settings/PlayerSettings.swift +++ b/Shared/Settings/PlayerSettings.swift @@ -124,8 +124,9 @@ struct PlayerSettings: View { #if !os(tvOS) Section(header: SettingsHeader(text: "Video Details").padding(.bottom, videoDetailsHeaderPadding)) { - SettingsHeader(text: "Buttons labels".localized(), secondary: true) + SettingsHeader(text: "Actions buttons".localized(), secondary: true) playerActionsButtonLabelStylePicker + SettingsHeader(text: "Pages buttons".localized(), secondary: true) detailsButtonLabelStylePicker SettingsHeader(text: "Show Inspector".localized(), secondary: true) diff --git a/Shared/Settings/SettingsView.swift b/Shared/Settings/SettingsView.swift index 5c7f2858..f3a43cef 100644 --- a/Shared/Settings/SettingsView.swift +++ b/Shared/Settings/SettingsView.swift @@ -223,7 +223,7 @@ struct SettingsView: View { case .browsing: return 580 case .player: - return 850 + return 900 case .quality: return 420 case .history: @@ -235,7 +235,7 @@ struct SettingsView: View { case .advanced: return 250 case .help: - return 580 + return 650 } } #endif