Localization and platform availability fixes

This commit is contained in:
Arkadiusz Fal 2022-11-19 00:38:32 +01:00
parent 780b7ab130
commit 99769380fc
7 changed files with 64 additions and 46 deletions

View File

@ -3,8 +3,11 @@ import SwiftUI
extension Backport where Content: View { extension Backport where Content: View {
@ViewBuilder func listRowSeparator(_ visible: Bool) -> some View { @ViewBuilder func listRowSeparator(_ visible: Bool) -> some View {
if #available(iOS 15, macOS 12, tvOS 15, *) { if #available(iOS 15, macOS 13, *) {
content.listRowSeparator(visible ? .visible : .hidden) content
#if !os(tvOS)
.listRowSeparator(visible ? .visible : .hidden)
#endif
} else { } else {
content content
} }

View File

@ -47,6 +47,7 @@ struct HomeView: View {
OpenVideosButton(text: "Settings", imageSystemName: "gear") { OpenVideosButton(text: "Settings", imageSystemName: "gear") {
NavigationModel.shared.presentingSettings = true NavigationModel.shared.presentingSettings = true
} }
.frame(maxWidth: 600)
} }
#else #else
@ -93,28 +94,30 @@ struct HomeView: View {
#endif #endif
} }
if homeRecentDocumentsItems > 0 { #if os(iOS)
VStack { if homeRecentDocumentsItems > 0 {
HStack { VStack {
sectionLabel("Recent Documents") HStack {
sectionLabel("Recent Documents")
Spacer() Spacer()
Button { Button {
recentDocumentsID = UUID() recentDocumentsID = UUID()
} label: { } label: {
Label("Refresh", systemImage: "arrow.clockwise") Label("Refresh", systemImage: "arrow.clockwise")
.font(.headline) .font(.headline)
.labelStyle(.iconOnly) .labelStyle(.iconOnly)
.foregroundColor(.secondary) .foregroundColor(.secondary)
}
} }
}
RecentDocumentsView(limit: homeRecentDocumentsItems) RecentDocumentsView(limit: homeRecentDocumentsItems)
.id(recentDocumentsID) .id(recentDocumentsID)
}
.frame(maxWidth: .infinity, alignment: .leading)
} }
.frame(maxWidth: .infinity, alignment: .leading) #endif
}
if homeHistoryItems > 0 { if homeHistoryItems > 0 {
VStack { VStack {
@ -140,8 +143,10 @@ struct HomeView: View {
.foregroundColor(.secondary) .foregroundColor(.secondary)
} }
} }
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
#if os(tvOS)
.padding(.trailing, 40)
#endif
HistoryView(limit: homeHistoryItems) HistoryView(limit: homeHistoryItems)
.id(historyID) .id(historyID)

View File

@ -6,8 +6,10 @@ struct Sidebar: View {
@EnvironmentObject<NavigationModel> private var navigation @EnvironmentObject<NavigationModel> private var navigation
@Default(.showHome) private var showHome @Default(.showHome) private var showHome
@Default(.showDocuments) private var showDocuments
@Default(.visibleSections) private var visibleSections @Default(.visibleSections) private var visibleSections
#if os(iOS)
@Default(.showDocuments) private var showDocuments
#endif
var body: some View { var body: some View {
ScrollViewReader { scrollView in ScrollViewReader { scrollView in

View File

@ -10,12 +10,12 @@ struct BrowsingSettings: View {
#if os(iOS) #if os(iOS)
@Default(.homeRecentDocumentsItems) private var homeRecentDocumentsItems @Default(.homeRecentDocumentsItems) private var homeRecentDocumentsItems
@Default(.lockPortraitWhenBrowsing) private var lockPortraitWhenBrowsing @Default(.lockPortraitWhenBrowsing) private var lockPortraitWhenBrowsing
@Default(.showDocuments) private var showDocuments
#endif #endif
@Default(.thumbnailsQuality) private var thumbnailsQuality @Default(.thumbnailsQuality) private var thumbnailsQuality
@Default(.channelOnThumbnail) private var channelOnThumbnail @Default(.channelOnThumbnail) private var channelOnThumbnail
@Default(.timeOnThumbnail) private var timeOnThumbnail @Default(.timeOnThumbnail) private var timeOnThumbnail
@Default(.showHome) private var showHome @Default(.showHome) private var showHome
@Default(.showDocuments) private var showDocuments
@Default(.showFavoritesInHome) private var showFavoritesInHome @Default(.showFavoritesInHome) private var showFavoritesInHome
@Default(.showOpenActionsInHome) private var showOpenActionsInHome @Default(.showOpenActionsInHome) private var showOpenActionsInHome
@Default(.showOpenActionsToolbarItem) private var showOpenActionsToolbarItem @Default(.showOpenActionsToolbarItem) private var showOpenActionsToolbarItem
@ -59,7 +59,14 @@ struct BrowsingSettings: View {
private var sections: some View { private var sections: some View {
Group { Group {
homeSettings homeSettings
interfaceSettings let interface = interfaceSettings
#if os(tvOS)
if !accounts.isEmpty {
interface
}
#else
interface
#endif
if !accounts.isEmpty { if !accounts.isEmpty {
thumbnailsSettings thumbnailsSettings
visibleSectionsSettings visibleSectionsSettings
@ -91,21 +98,23 @@ struct BrowsingSettings: View {
} }
.multilineTextAlignment(.trailing) .multilineTextAlignment(.trailing)
HStack { #if os(iOS)
Text("Recent Documents") HStack {
TextField("Recent Documents", text: $homeRecentDocumentsItemsText) Text("Recent Documents")
.labelsHidden() TextField("Recent Documents", text: $homeRecentDocumentsItemsText)
#if !os(macOS) .labelsHidden()
.keyboardType(.numberPad) #if !os(macOS)
#endif .keyboardType(.numberPad)
.onAppear { #endif
homeRecentDocumentsItemsText = String(homeRecentDocumentsItems) .onAppear {
} homeRecentDocumentsItemsText = String(homeRecentDocumentsItems)
.onChange(of: homeRecentDocumentsItemsText) { newValue in }
homeRecentDocumentsItems = Int(newValue) ?? 3 .onChange(of: homeRecentDocumentsItemsText) { newValue in
} homeRecentDocumentsItems = Int(newValue) ?? 3
} }
.multilineTextAlignment(.trailing) }
.multilineTextAlignment(.trailing)
#endif
if !accounts.isEmpty { if !accounts.isEmpty {
Toggle("Show Favorites", isOn: $showFavoritesInHome) Toggle("Show Favorites", isOn: $showFavoritesInHome)
@ -115,7 +124,7 @@ struct BrowsingSettings: View {
Button { Button {
presentingEditFavoritesSheet = true presentingEditFavoritesSheet = true
} label: { } label: {
Text("Edit Favorites...") Text("Edit Favorites")
} }
.sheet(isPresented: $presentingEditFavoritesSheet) { .sheet(isPresented: $presentingEditFavoritesSheet) {
VStack(alignment: .leading) { VStack(alignment: .leading) {

View File

@ -104,18 +104,16 @@ struct EditFavorites: View {
func label(_ item: FavoriteItem) -> String { func label(_ item: FavoriteItem) -> String {
if case let .playlist(id) = item.section { 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 { struct EditFavorites_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
// NavigationView {
EditFavorites() EditFavorites()
// }
.injectFixtureEnvironmentObjects() .injectFixtureEnvironmentObjects()
} }
} }

View File

@ -124,8 +124,9 @@ struct PlayerSettings: View {
#if !os(tvOS) #if !os(tvOS)
Section(header: SettingsHeader(text: "Video Details").padding(.bottom, videoDetailsHeaderPadding)) { Section(header: SettingsHeader(text: "Video Details").padding(.bottom, videoDetailsHeaderPadding)) {
SettingsHeader(text: "Buttons labels".localized(), secondary: true) SettingsHeader(text: "Actions buttons".localized(), secondary: true)
playerActionsButtonLabelStylePicker playerActionsButtonLabelStylePicker
SettingsHeader(text: "Pages buttons".localized(), secondary: true)
detailsButtonLabelStylePicker detailsButtonLabelStylePicker
SettingsHeader(text: "Show Inspector".localized(), secondary: true) SettingsHeader(text: "Show Inspector".localized(), secondary: true)

View File

@ -223,7 +223,7 @@ struct SettingsView: View {
case .browsing: case .browsing:
return 580 return 580
case .player: case .player:
return 850 return 900
case .quality: case .quality:
return 420 return 420
case .history: case .history:
@ -235,7 +235,7 @@ struct SettingsView: View {
case .advanced: case .advanced:
return 250 return 250
case .help: case .help:
return 580 return 650
} }
} }
#endif #endif