Skip to content

Commit 555ac6c

Browse files
authored
Merge pull request #6 from django-files/less_annoying_dialog
less annoying insecure message
2 parents 70c2770 + 37d9e98 commit 555ac6c

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed
2.15 KB
Binary file not shown.

Django Files/Views/SessionEditor.swift

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ struct SessionEditor: View {
4646
@State private var token: String = ""
4747
@State private var badURL = false
4848
@State private var insecureURL = false
49-
@State private var insecureAlertShown = false
5049

51-
@State private var urlValid: Bool = false
52-
50+
5351
var body: some View {
5452
NavigationStack {
5553
Form {
@@ -65,25 +63,28 @@ struct SessionEditor: View {
6563
let temp = URL(string: $0)
6664
if temp?.scheme != nil && temp?.scheme != ""{
6765
url = temp
68-
if (url?.absoluteString.starts(with: /[a-zA-Z]+:$/))! && !(url?.absoluteString.starts(with: /https:$/))! && !insecureAlertShown{
66+
if (url?.scheme?.lowercased()) == ("http"){
6967
insecureURL = true
68+
} else {
69+
insecureURL = false
7070
}
7171
}
7272
}
7373
))
7474
.disableAutocorrection(true)
7575
.textInputAutocapitalization(.never)
76-
.alert(isPresented: $insecureURL){
77-
Alert(title: Text("Insecure URL"), message: Text("We strongly recommend using HTTPS for security reasons. Press OK to continue."))
78-
}
79-
.onChange(of: insecureURL){
80-
if insecureURL{
81-
insecureAlertShown = true
82-
}
83-
}
8476
} label: {
8577
Text("URL:")
8678
}
79+
if insecureURL {
80+
let warningMessage = "⚠️ We strongly recommend using HTTPS."
81+
TextField("", text: Binding(
82+
get: { warningMessage },
83+
set: { _ in } // Prevents user from modifying the text
84+
))
85+
.disabled(true) // Prevents user input
86+
.foregroundColor(.red)
87+
}
8788
}
8889
.toolbar {
8990
ToolbarItem(placement: .principal) {

0 commit comments

Comments
 (0)