APNSettingsView.swift 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // LoopFollow
  2. // APNSettingsView.swift
  3. import SwiftUI
  4. struct APNSettingsView: View {
  5. @State private var keyId: String = Storage.shared.lfKeyId.value
  6. @State private var apnsKey: String = Storage.shared.lfApnsKey.value
  7. var body: some View {
  8. Form {
  9. Section(header: Text("LoopFollow APNs Credentials")) {
  10. HStack {
  11. Text("APNS Key ID")
  12. TogglableSecureInput(
  13. placeholder: "Enter APNS Key ID",
  14. text: $keyId,
  15. style: .singleLine
  16. )
  17. }
  18. VStack(alignment: .leading) {
  19. Text("APNS Key")
  20. TogglableSecureInput(
  21. placeholder: "Paste APNS Key",
  22. text: $apnsKey,
  23. style: .multiLine
  24. )
  25. .frame(minHeight: 110)
  26. }
  27. }
  28. }
  29. .onChange(of: keyId) { newValue in
  30. Storage.shared.lfKeyId.value = newValue
  31. }
  32. .onChange(of: apnsKey) { newValue in
  33. let apnsService = LoopAPNSService()
  34. Storage.shared.lfApnsKey.value = apnsService.validateAndFixAPNSKey(newValue)
  35. }
  36. .preferredColorScheme(Storage.shared.appearanceMode.value.colorScheme)
  37. .navigationTitle("APN")
  38. .navigationBarTitleDisplayMode(.inline)
  39. }
  40. }