From 8c07397548d583f81746b32083b4329ecefedf82 Mon Sep 17 00:00:00 2001 From: Doug <6060466+pixlwave@users.noreply.github.com> Date: Thu, 22 Aug 2024 17:45:58 +0100 Subject: [PATCH] Fix the call URL input field in Developer Options (#3192) --- .../View/DeveloperOptionsScreen.swift | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift index 1e1224e1b..509560984 100644 --- a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift +++ b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift @@ -19,7 +19,12 @@ import SwiftUI struct DeveloperOptionsScreen: View { @ObservedObject var context: DeveloperOptionsScreenViewModel.Context @State private var showConfetti = false - @State private var elementCallBaseURLString = "" + @State private var elementCallURLOverrideString: String + + init(context: DeveloperOptionsScreenViewModel.Context) { + self.context = context + elementCallURLOverrideString = context.elementCallBaseURLOverride?.absoluteString ?? "" + } var body: some View { Form { @@ -50,22 +55,31 @@ struct DeveloperOptionsScreen: View { Text("Fuzzy searching") } } - - Section("Element Call") { - TextField(context.viewState.elementCallBaseURL.absoluteString, text: $elementCallBaseURLString) - .submitLabel(.done) - .onSubmit { - guard let url = URL(string: elementCallBaseURLString) else { return } - context.elementCallBaseURLOverride = url - } + + Section { + TextField(context.viewState.elementCallBaseURL.absoluteString, text: $elementCallURLOverrideString) .autocorrectionDisabled(true) .autocapitalization(.none) - .foregroundColor(URL(string: elementCallBaseURLString) == nil ? .red : .primary) + .foregroundColor(URL(string: elementCallURLOverrideString) == nil ? .red : .primary) + .submitLabel(.done) + .onSubmit { + if elementCallURLOverrideString.isEmpty { + context.elementCallBaseURLOverride = nil + } else if let url = URL(string: elementCallURLOverrideString) { + context.elementCallBaseURLOverride = url + } + } Toggle(isOn: $context.elementCallPictureInPictureEnabled) { Text("Picture in Picture support") Text("Requires an Element Call deployment with support for signalling PiP availability.") } + } header: { + Text("Element Call") + } footer: { + if context.elementCallBaseURLOverride == nil { + Text("The call URL may be overridden by your homeserver.") + } } Section {