Skip to content

Commit c4456f6

Browse files
committed
fix trailing slash, default url protocol, url entry placeholder color
1 parent 58e11aa commit c4456f6

File tree

2 files changed

+27
-18
lines changed

2 files changed

+27
-18
lines changed

Django Files/Views/ContentView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public struct AuthViewContainer: View {
183183
httpsUrl: selectedServer.url,
184184
doReset: authController.url?.absoluteString ?? "" != selectedServer.url || !selectedServer.auth,
185185
session: selectedServer
186-
)
186+
)
187187
.onStartedLoading {
188188
}
189189
.onCancelled {
@@ -234,12 +234,12 @@ public struct AuthViewContainer: View {
234234
.frame(maxWidth: .infinity, maxHeight: .infinity)
235235
.edgesIgnoringSafeArea(.all)
236236
.navigationTitle(Text(""))
237-
.navigationBarBackButtonHidden(true)
237+
.navigationBarHidden(true)
238238
}
239239
else {
240240
Text("Loading...")
241241
.onAppear(){
242-
columnVisibility.wrappedValue = .automatic
242+
columnVisibility.wrappedValue = .all
243243
}
244244
}
245245
}

Django Files/Views/SessionEditor.swift

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,14 @@ struct SessionEditor: View {
5959
@State private var badURL = false
6060
@State private var insecureURL = false
6161

62+
@FocusState private var isURLFieldFocused: Bool
63+
6264

6365
var body: some View {
6466
NavigationStack {
6567
Form {
6668
LabeledContent{
67-
TextField("https://df.myserver.com", text: Binding(
69+
TextField("", text: Binding(
6870
get: {
6971
if url?.scheme == nil || url?.scheme == ""{
7072
return ""
@@ -75,22 +77,24 @@ struct SessionEditor: View {
7577
let temp = URL(string: $0)
7678
if temp?.scheme != nil && temp?.scheme != ""{
7779
url = temp
78-
if (url?.scheme?.lowercased()) == ("http"){
79-
insecureURL = true
80-
} else {
81-
insecureURL = false
82-
}
80+
insecureURL = (url?.scheme?.lowercased()) == ("http")
8381
}
8482
}
85-
))
86-
.disableAutocorrection(true)
87-
.textInputAutocapitalization(.never)
88-
.accessibilityIdentifier("urlTextField")
83+
), prompt: Text(verbatim: "https://df.example.com"))
84+
.focused($isURLFieldFocused)
85+
.onChange(of: isURLFieldFocused) { wasFocused, isFocused in
86+
if isFocused && url == nil {
87+
url = URL(string: "https://")
88+
}
89+
}
90+
.disableAutocorrection(true)
91+
.textInputAutocapitalization(.never)
92+
.accessibilityIdentifier("urlTextField")
8993
} label: {
9094
Text("URL:")
9195
}
9296
if insecureURL {
93-
let warningMessage = "⚠️ We strongly recommend using HTTPS."
97+
let warningMessage = "⚠️ HTTPS strongly recommend."
9498
TextField("", text: Binding(
9599
get: { warningMessage },
96100
set: { _ in } // Prevents user from modifying the text
@@ -105,13 +109,18 @@ struct SessionEditor: View {
105109
}
106110
ToolbarItem(placement: .confirmationAction) {
107111
Button(action:{
108-
if url != nil
109-
{
112+
// Remove trailing slash if present
113+
if var urlString = url?.absoluteString {
114+
if urlString.hasSuffix("/") {
115+
urlString.removeLast()
116+
url = URL(string: urlString)
117+
}
118+
}
119+
if url != nil {
110120
withAnimation {
111121
save()
112122
}
113-
}
114-
else{
123+
} else {
115124
badURL.toggle()
116125
}
117126
})

0 commit comments

Comments
 (0)