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

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 {
@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
}

View File

@ -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)

View File

@ -6,8 +6,10 @@ struct Sidebar: View {
@EnvironmentObject<NavigationModel> 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

View File

@ -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) {

View File

@ -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()
}
}

View File

@ -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)

View File

@ -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