mirror of
https://github.com/yattee/yattee.git
synced 2025-10-12 02:18:17 +00:00
Import export settings
This commit is contained in:
@@ -7,7 +7,7 @@ struct SettingsView: View {
|
||||
|
||||
#if os(macOS)
|
||||
private enum Tabs: Hashable {
|
||||
case browsing, player, controls, quality, history, sponsorBlock, locations, advanced, help
|
||||
case browsing, player, controls, quality, history, sponsorBlock, locations, advanced, importExport, help
|
||||
}
|
||||
|
||||
@State private var selection: Tabs = .browsing
|
||||
@@ -24,13 +24,22 @@ struct SettingsView: View {
|
||||
|
||||
@Default(.instances) private var instances
|
||||
|
||||
@State private var filesToShare = []
|
||||
|
||||
@ObservedObject private var navigation = NavigationModel.shared
|
||||
@ObservedObject private var settingsModel = SettingsModel.shared
|
||||
|
||||
var body: some View {
|
||||
settings
|
||||
.alert(isPresented: $model.presentingAlert) { model.alert }
|
||||
#if os(iOS)
|
||||
.backport
|
||||
.scrollDismissesKeyboardInteractively()
|
||||
#if !os(tvOS)
|
||||
.modifier(ImportSettingsFileImporterViewModifier(isPresented: $navigation.presentingSettingsFileImporter))
|
||||
.modifier(ImportSettingsSheetViewModifier(isPresented: $settingsModel.presentingSettingsImportSheet, settingsFile: $settingsModel.settingsImportURL))
|
||||
#endif
|
||||
#if os(iOS)
|
||||
.backport
|
||||
.scrollDismissesKeyboardInteractively()
|
||||
#endif
|
||||
.alert(isPresented: $model.presentingAlert) { model.alert }
|
||||
}
|
||||
|
||||
var settings: some View {
|
||||
@@ -101,6 +110,14 @@ struct SettingsView: View {
|
||||
}
|
||||
.tag(Tabs.advanced)
|
||||
|
||||
Group {
|
||||
ExportSettings()
|
||||
}
|
||||
.tabItem {
|
||||
Label("Export", systemImage: "square.and.arrow.up")
|
||||
}
|
||||
.tag(Tabs.importExport)
|
||||
|
||||
Form {
|
||||
Help()
|
||||
}
|
||||
@@ -110,7 +127,7 @@ struct SettingsView: View {
|
||||
.tag(Tabs.help)
|
||||
}
|
||||
.padding(20)
|
||||
.frame(width: 650, height: windowHeight)
|
||||
.frame(width: 700, height: windowHeight)
|
||||
#else
|
||||
NavigationView {
|
||||
settingsList
|
||||
@@ -206,6 +223,8 @@ struct SettingsView: View {
|
||||
.padding(.horizontal, 20)
|
||||
#endif
|
||||
|
||||
importView
|
||||
|
||||
Section(footer: helpFooter) {
|
||||
NavigationLink {
|
||||
Help()
|
||||
@@ -260,6 +279,28 @@ struct SettingsView: View {
|
||||
}
|
||||
#endif
|
||||
|
||||
var importView: some View {
|
||||
Section {
|
||||
Button(action: importSettings) {
|
||||
Label("Import Settings...", systemImage: "square.and.arrow.down")
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
.foregroundColor(.accent)
|
||||
.buttonStyle(.plain)
|
||||
|
||||
NavigationLink(destination: LazyView(ExportSettings())) {
|
||||
Label("Export Settings", systemImage: "square.and.arrow.up")
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func importSettings() {
|
||||
navigation.presentingSettingsFileImporter = true
|
||||
}
|
||||
|
||||
#if os(macOS)
|
||||
private var windowHeight: Double {
|
||||
switch selection {
|
||||
@@ -278,7 +319,9 @@ struct SettingsView: View {
|
||||
case .locations:
|
||||
return 600
|
||||
case .advanced:
|
||||
return 380
|
||||
return 500
|
||||
case .importExport:
|
||||
return 580
|
||||
case .help:
|
||||
return 650
|
||||
}
|
||||
|
Reference in New Issue
Block a user