Fix the call URL input field in Developer Options (#3192)

This commit is contained in:
Doug 2024-08-22 17:45:58 +01:00 committed by GitHub
parent 4eb1ed5d09
commit 8c07397548
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 {
@ -51,21 +56,30 @@ struct DeveloperOptionsScreen: View {
}
}
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 {