Skip to content

Commit

Permalink
normalized
Browse files Browse the repository at this point in the history
Signed-off-by: Marino Faggiana <[email protected]>
  • Loading branch information
marinofaggiana committed May 28, 2024
1 parent a00ff45 commit ef8bd3f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 36 deletions.
68 changes: 34 additions & 34 deletions iOSClient/Settings/Advanced/NCSettingsAdvanced.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import SwiftUI
import NextcloudKit

struct NCSettingsAdvanced: View {
@ObservedObject var viewModel = NCSettingsAdvancedModel()
@ObservedObject var model: NCSettingsAdvancedModel
/// State variable for indicating whether the exit alert is shown.
@State var showExitAlert: Bool = false
/// State variable for indicating whether the cache alert is shown.
Expand All @@ -35,25 +35,25 @@ struct NCSettingsAdvanced: View {
Form {
// Show Hidden Files
Section(content: {
Toggle(NSLocalizedString("_show_hidden_files_", comment: ""), isOn: $viewModel.showHiddenFiles)
Toggle(NSLocalizedString("_show_hidden_files_", comment: ""), isOn: $model.showHiddenFiles)
.tint(Color(NCBrandColor.shared.brandElement))
.onChange(of: viewModel.showHiddenFiles) { _ in
viewModel.updateShowHiddenFiles()
.onChange(of: model.showHiddenFiles) { _ in
model.updateShowHiddenFiles()
}
.font(.system(size: 16))
}, footer: { })
// Most Compatible & Enable Live Photo
Section(content: {
Toggle(NSLocalizedString("_format_compatibility_", comment: ""), isOn: $viewModel.mostCompatible)
Toggle(NSLocalizedString("_format_compatibility_", comment: ""), isOn: $model.mostCompatible)
.tint(Color(NCBrandColor.shared.brandElement))
.onChange(of: viewModel.mostCompatible) { _ in
viewModel.updateMostCompatible()
.onChange(of: model.mostCompatible) { _ in
model.updateMostCompatible()
}
.font(.system(size: 16))
Toggle(NSLocalizedString("_upload_mov_livephoto_", comment: ""), isOn: $viewModel.livePhoto)
Toggle(NSLocalizedString("_upload_mov_livephoto_", comment: ""), isOn: $model.livePhoto)
.tint(Color(NCBrandColor.shared.brandElement))
.onChange(of: viewModel.livePhoto) { _ in
viewModel.updateLivePhoto()
.onChange(of: model.livePhoto) { _ in
model.updateLivePhoto()
}
.font(.system(size: 16))
}, footer: {
Expand All @@ -66,10 +66,10 @@ struct NCSettingsAdvanced: View {
})
// Remove from Camera Roll
Section(content: {
Toggle(NSLocalizedString("_remove_photo_CameraRoll_", comment: ""), isOn: $viewModel.removeFromCameraRoll)
Toggle(NSLocalizedString("_remove_photo_CameraRoll_", comment: ""), isOn: $model.removeFromCameraRoll)
.tint(Color(NCBrandColor.shared.brandElement))
.onChange(of: viewModel.removeFromCameraRoll) { _ in
viewModel.updateRemoveFromCameraRoll()
.onChange(of: model.removeFromCameraRoll) { _ in
model.updateRemoveFromCameraRoll()
}
.font(.system(size: 16))
}, footer: {
Expand All @@ -80,10 +80,10 @@ struct NCSettingsAdvanced: View {
// Section : Files App
if !NCBrandOptions.shared.disable_openin_file {
Section(content: {
Toggle(NSLocalizedString("_disable_files_app_", comment: ""), isOn: $viewModel.appIntegration)
Toggle(NSLocalizedString("_disable_files_app_", comment: ""), isOn: $model.appIntegration)
.tint(Color(NCBrandColor.shared.brandElement))
.onChange(of: viewModel.appIntegration) { _ in
viewModel.updateAppIntegration()
.onChange(of: model.appIntegration) { _ in
model.updateAppIntegration()
}
.font(.system(size: 16))
}, footer: {
Expand All @@ -102,17 +102,17 @@ struct NCSettingsAdvanced: View {
.font(Font.system(.body).weight(.light))
.frame(width: 25, height: 25)
.foregroundColor(Color(NCBrandColor.shared.iconImageColor))
Toggle(NSLocalizedString("_crashservice_title_", comment: ""), isOn: $viewModel.crashReporter)
Toggle(NSLocalizedString("_crashservice_title_", comment: ""), isOn: $model.crashReporter)
.tint(Color(NCBrandColor.shared.brandElement))
.onChange(of: viewModel.crashReporter) { _ in
viewModel.updateCrashReporter()
.onChange(of: model.crashReporter) { _ in
model.updateCrashReporter()
showCrashReporter.toggle()
}
}
.font(.system(size: 16))
.alert(NSLocalizedString("_crashservice_title_", comment: ""), isPresented: $showCrashReporter, actions: {
Button(NSLocalizedString("OK", comment: ""), role: .cancel) {
viewModel.exitNextCloud(ext: showCrashReporter)
model.exitNextCloud(ext: showCrashReporter)
}
}, message: {
Text(NSLocalizedString("_crashservice_alert_", comment: ""))
Expand All @@ -130,7 +130,7 @@ struct NCSettingsAdvanced: View {
Section(content: {
// View Log File
Button(action: {
viewModel.viewLogFile()
model.viewLogFile()
}, label: {
HStack {
Image(systemName: "doc.text.magnifyingglass")
Expand All @@ -146,7 +146,7 @@ struct NCSettingsAdvanced: View {
.tint(Color(UIColor.label))
// Clear Log File
Button(action: {
viewModel.clearLogFile()
model.clearLogFile()
}, label: {
HStack {
Image(systemName: "repeat")
Expand All @@ -160,22 +160,22 @@ struct NCSettingsAdvanced: View {
.font(.system(size: 16))
})
.tint(Color(UIColor.label))
.alert(NSLocalizedString("_log_file_clear_alert_", comment: ""), isPresented: $viewModel.logFileCleared) {
.alert(NSLocalizedString("_log_file_clear_alert_", comment: ""), isPresented: $model.logFileCleared) {
Button(NSLocalizedString("OK", comment: ""), role: .cancel) { }
}
}, header: {
Text(NSLocalizedString("_diagnostics_", comment: ""))
}, footer: { })
// Set Log Level() & Capabilities
Section {
Picker(NSLocalizedString("_set_log_level_", comment: ""), selection: $viewModel.selectedLogLevel) {
Picker(NSLocalizedString("_set_log_level_", comment: ""), selection: $model.selectedLogLevel) {
ForEach(LogLevel.allCases) { level in
Text(level.displayText).tag(level)
}
}
.font(.system(size: 16))
.onChange(of: viewModel.selectedLogLevel) { _ in
viewModel.updateSelectedLogLevel()
.onChange(of: model.selectedLogLevel) { _ in
model.updateSelectedLogLevel()
}
NavigationLink(destination: NCCapabilitiesView(capabilitiesStatus: NCCapabilitiesViewOO())) {
HStack {
Expand All @@ -193,15 +193,15 @@ struct NCSettingsAdvanced: View {
}
// Delete in Cache & Clear Cache
Section(content: {
Picker(NSLocalizedString("_auto_delete_cache_files_", comment: ""), selection: $viewModel.selectedInterval) {
Picker(NSLocalizedString("_auto_delete_cache_files_", comment: ""), selection: $model.selectedInterval) {
ForEach(CacheDeletionInterval.allCases) { interval in
Text(interval.displayText).tag(interval)
}
}
.font(.system(size: 16))
.pickerStyle(.automatic)
.onChange(of: viewModel.selectedInterval) { _ in
viewModel.updateSelectedInterval()
.onChange(of: model.selectedInterval) { _ in
model.updateSelectedInterval()
}
Button(action: {
showCacheAlert.toggle()
Expand All @@ -220,14 +220,14 @@ struct NCSettingsAdvanced: View {
.tint(Color(UIColor.label))
.alert(NSLocalizedString("_want_delete_cache_", comment: ""), isPresented: $showCacheAlert) {
Button(NSLocalizedString("_yes_", comment: ""), role: .destructive) {
viewModel.clearAllCacheRequest()
model.clearAllCacheRequest()
}
Button(NSLocalizedString("_cancel_", comment: ""), role: .cancel) { }
}
}, header: {
Text(NSLocalizedString("_delete_files_desc_", comment: ""))
}, footer: {
Text(viewModel.footerTitle)
Text(model.footerTitle)
.font(.system(size: 12))
.multilineTextAlignment(.leading)
})
Expand All @@ -250,7 +250,7 @@ struct NCSettingsAdvanced: View {
.tint(Color(UIColor.label))
.alert(NSLocalizedString("_want_exit_", comment: ""), isPresented: $showExitAlert) {
Button(NSLocalizedString("_ok_", comment: ""), role: .destructive) {
viewModel.resetNextCloud(exit: showExitAlert)
model.resetNextCloud(exit: showExitAlert)
}
Button(NSLocalizedString("_cancel_", comment: ""), role: .cancel) { }
}
Expand All @@ -264,10 +264,10 @@ struct NCSettingsAdvanced: View {
.multilineTextAlignment(.leading)
})
}.navigationBarTitle(NSLocalizedString("_advanced_", comment: ""))
.defaultViewModifier(viewModel)
.defaultViewModifier(model)
}
}

#Preview {
NCSettingsAdvanced(viewModel: NCSettingsAdvancedModel(), showExitAlert: false, showCacheAlert: false)
NCSettingsAdvanced(model: NCSettingsAdvancedModel(controller: nil), showExitAlert: false, showCacheAlert: false)
}
5 changes: 4 additions & 1 deletion iOSClient/Settings/Advanced/NCSettingsAdvancedModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ class NCSettingsAdvancedModel: ObservableObject, ViewOnAppearHandling, AccountUp
@Published var selectedInterval: CacheDeletionInterval = .never
/// State variable for storing the footer title, usually used for cache deletion.
@Published var footerTitle: String = NSLocalizedString("_clear_cache_footer_", comment: "")

@Published var controller: UITabBarController?
/// Initializes the view model with default values.
init() {
init(controller: UITabBarController?) {
self.controller = controller
onViewAppear()
}
/// Updates the account information.
Expand Down
2 changes: 1 addition & 1 deletion iOSClient/Settings/Settings/NCSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ struct NCSettings: View {
}
/// `Advanced` Section
Section {
NavigationLink(destination: NCSettingsAdvanced(viewModel: NCSettingsAdvancedModel(), showExitAlert: false, showCacheAlert: false)) {
NavigationLink(destination: NCSettingsAdvanced(model: NCSettingsAdvancedModel(controller: model.controller), showExitAlert: false, showCacheAlert: false)) {
HStack {
Image(systemName: "gear")
.resizable()
Expand Down

0 comments on commit ef8bd3f

Please sign in to comment.