NCDisplayView.swift 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //
  2. // NCDisplayView.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 30/05/24.
  6. // Copyright © 2024 Marino Faggiana. All rights reserved.
  7. //
  8. import SwiftUI
  9. struct NCDisplayView: View {
  10. @ObservedObject var model: NCDisplayModel
  11. @Environment(\.colorScheme) var colorScheme
  12. var body: some View {
  13. Form {
  14. Section(header: Text(NSLocalizedString("_appearance_", comment: ""))) {
  15. VStack {
  16. HStack {
  17. Spacer()
  18. VStack {
  19. Image(systemName: "sun.max")
  20. .resizable()
  21. .scaledToFit()
  22. .font(Font.system(.body).weight(.light))
  23. .frame(width: 50, height: 100)
  24. .foregroundColor(Color(NCBrandColor.shared.iconImageColor))
  25. Text(NSLocalizedString("_light_", comment: ""))
  26. Image(systemName: colorScheme == .light ? "checkmark.circle.fill" : "circle")
  27. .foregroundColor(Color(NCBrandColor.shared.getElement(account: model.session.account)))
  28. .imageScale(.large)
  29. .font(Font.system(.body).weight(.light))
  30. .frame(width: 50, height: 50)
  31. }
  32. .onTapGesture {
  33. model.userInterfaceStyle(.light)
  34. }
  35. Spacer()
  36. VStack {
  37. Image(systemName: "moon.fill")
  38. .resizable()
  39. .scaledToFit()
  40. .font(Font.system(.body).weight(.light))
  41. .frame(width: 50, height: 100)
  42. .foregroundColor(Color(NCBrandColor.shared.iconImageColor))
  43. Text(NSLocalizedString("_dark_", comment: ""))
  44. Image(systemName: colorScheme == .dark ? "checkmark.circle.fill" : "circle")
  45. .foregroundColor(Color(NCBrandColor.shared.getElement(account: model.session.account)))
  46. .imageScale(.large)
  47. .font(Font.system(.body).weight(.light))
  48. .frame(width: 50, height: 50)
  49. }
  50. .onTapGesture {
  51. model.userInterfaceStyle(.dark)
  52. }
  53. Spacer()
  54. }
  55. Divider()
  56. .padding(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: -50))
  57. Toggle(NSLocalizedString("_use_system_style_", comment: ""), isOn: $model.appearanceAutomatic)
  58. .tint(Color(NCBrandColor.shared.getElement(account: model.session.account)))
  59. .onChange(of: model.appearanceAutomatic) { _ in
  60. model.updateAppearanceAutomatic()
  61. }
  62. }
  63. }
  64. .font(.system(size: 16))
  65. Section(header: Text(NSLocalizedString("_additional_options_", comment: ""))) {
  66. Picker(NSLocalizedString("_keep_screen_awake_", comment: ""),
  67. selection: $model.screenAwakeState) {
  68. Text(NSLocalizedString("_off_", comment: "")).tag(AwakeMode.off)
  69. Text(NSLocalizedString("_on_", comment: "")).tag(AwakeMode.on)
  70. Text(NSLocalizedString("_while_charging_", comment: "")).tag(AwakeMode.whileCharging)
  71. }
  72. .frame(height: 50)
  73. }
  74. .pickerStyle(.menu)
  75. }
  76. .navigationBarTitle(NSLocalizedString("_display_", comment: ""))
  77. .defaultViewModifier(model)
  78. .padding(.top, 0)
  79. }
  80. }
  81. #Preview {
  82. NCDisplayView(model: NCDisplayModel(controller: nil))
  83. }