Change alignment of TextFields from trailing to leading

This commit is contained in:
Kenta Kubo 2023-04-25 02:37:12 +09:00
parent d61e4c7a1b
commit 7be92ee8af
4 changed files with 46 additions and 94 deletions

View file

@ -35,12 +35,8 @@ extension DetailView: View {
Section {
Toggle("Use This Server", isOn: self.$isOn)
}
Section {
HStack {
Text("Name")
TextField("Name", text: self.$server.name)
.multilineTextAlignment(.trailing)
}
Section("Name") {
TextField("Name", text: self.$server.name)
}
self.serverConfigurationSections
Section {
@ -76,12 +72,8 @@ extension DetailView: View {
Section {
Toggle("Use This Server", isOn: self.$isOn)
}
Section {
HStack {
Text("Name")
TextField("Name", text: self.$server.name)
.multilineTextAlignment(.trailing)
}
Section("Name") {
TextField("Name", text: self.$server.name)
}
self.serverConfigurationSections
Section {

View file

@ -15,20 +15,11 @@ extension DoHSections: View {
var body: some View {
Section {
ForEach(0..<self.configuration.servers.count, id: \.self) { i in
TextField(
"IP address",
text: .init(
get: { self.configuration.servers[i] },
set: {
self.configuration.servers[i] = $0
.trimmingCharacters(in: .whitespacesAndNewlines)
}
)
)
.textContentType(.URL)
.keyboardType(.numbersAndPunctuation)
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
TextField("IP address", text: self.$configuration.servers[i])
.textContentType(.URL)
.keyboardType(.numbersAndPunctuation)
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
}
.onDelete { self.configuration.servers.remove(atOffsets: $0) }
.onMove { self.configuration.servers.move(fromOffsets: $0, toOffset: $1) }
@ -45,29 +36,19 @@ extension DoHSections: View {
Text("The DNS server IP addresses.")
}
Section {
HStack {
Text("Server URL")
TextField(
"Server URL",
text: .init(
get: {
self.configuration.serverURL?.absoluteString ?? ""
},
set: {
self.configuration.serverURL = URL(
string: $0.trimmingCharacters(in: .whitespacesAndNewlines)
)
}
)
TextField(
"Server URL",
text: .init(
get: { self.configuration.serverURL?.absoluteString ?? "" },
set: { self.configuration.serverURL = URL(string: $0) }
)
.multilineTextAlignment(.trailing)
.textContentType(.URL)
.keyboardType(.URL)
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
}
)
.textContentType(.URL)
.keyboardType(.URL)
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
} header: {
Text("DNS-over-HTTPS Settings")
Text("Server URL")
} footer: {
Text("The URL of a DNS-over-HTTPS server.")
}

View file

@ -15,20 +15,11 @@ extension DoTSections: View {
var body: some View {
Section {
ForEach(0..<self.configuration.servers.count, id: \.self) { i in
TextField(
"IP address",
text: .init(
get: { self.configuration.servers[i] },
set: {
self.configuration.servers[i] = $0
.trimmingCharacters(in: .whitespacesAndNewlines)
}
)
)
.textContentType(.URL)
.keyboardType(.numbersAndPunctuation)
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
TextField("IP address", text: self.$configuration.servers[i])
.textContentType(.URL)
.keyboardType(.numbersAndPunctuation)
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
}
.onDelete { self.configuration.servers.remove(atOffsets: $0) }
.onMove { self.configuration.servers.move(fromOffsets: $0, toOffset: $1) }
@ -45,26 +36,19 @@ extension DoTSections: View {
Text("The DNS server IP addresses.")
}
Section {
HStack {
Text("Server Name")
TextField(
"Server Name",
text: .init(
get: { self.configuration.serverName ?? "" },
set: {
self.configuration.serverName = $0
.trimmingCharacters(in: .whitespacesAndNewlines)
}
)
TextField(
"Server Name",
text: .init(
get: { self.configuration.serverName ?? "" },
set: { self.configuration.serverName = $0 }
)
.multilineTextAlignment(.trailing)
.textContentType(.URL)
.keyboardType(.URL)
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
}
)
.textContentType(.URL)
.keyboardType(.URL)
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
} header: {
Text("DNS-over-TLS Settings")
Text("Server Name")
} footer: {
Text("The TLS name of a DNS-over-TLS server.")
}

View file

@ -15,12 +15,11 @@ struct RuleView {
extension RuleView: View {
var body: some View {
Form {
Section("Name") {
TextField("Name", text: self.$rule.name)
}
Section {
HStack {
Text("Name")
TextField("Name", text: self.$rule.name)
.multilineTextAlignment(.trailing)
}
Picker("Action", selection: self.$rule.action) {
ForEach(NEOnDemandRuleAction.allCases, id: \.self) {
Text($0.description)
@ -123,17 +122,13 @@ extension RuleView: View {
}
Section {
HStack {
Text("Probe URL")
TextField(
"URL",
text: .init(
get: { self.rule.probeURL?.absoluteString ?? "" },
set: { self.rule.probeURL = URL(string: $0) }
)
TextField(
"Probe URL",
text: .init(
get: { self.rule.probeURL?.absoluteString ?? "" },
set: { self.rule.probeURL = URL(string: $0) }
)
.multilineTextAlignment(.trailing)
}
)
} header: {
Text("Probe URL Match")
} footer: {