Share prefix for validating theme methods
This commit is contained in:
parent
5c0e053e7d
commit
58cf401883
|
@ -397,44 +397,44 @@ extension View {
|
|||
// MARK: Validation
|
||||
|
||||
extension View {
|
||||
func themeProfileName() -> some View {
|
||||
func themeValidProfileName() -> some View {
|
||||
autocapitalization(.none)
|
||||
.disableAutocorrection(true)
|
||||
}
|
||||
|
||||
func themeURL(_ urlString: String?) -> some View {
|
||||
func themeValidURL(_ urlString: String?) -> some View {
|
||||
themeValidating(urlString, validator: Validators.url)
|
||||
.keyboardType(.asciiCapable)
|
||||
.autocapitalization(.none)
|
||||
.disableAutocorrection(true)
|
||||
}
|
||||
|
||||
func themeIPAddress(_ ipAddress: String?) -> some View {
|
||||
func themeValidIPAddress(_ ipAddress: String?) -> some View {
|
||||
themeValidating(ipAddress, validator: Validators.ipAddress)
|
||||
.keyboardType(.numbersAndPunctuation)
|
||||
.autocapitalization(.none)
|
||||
.disableAutocorrection(true)
|
||||
}
|
||||
|
||||
func themeSocketPort() -> some View {
|
||||
func themeValidSocketPort() -> some View {
|
||||
keyboardType(.numberPad)
|
||||
}
|
||||
|
||||
func themeDomainName(_ domainName: String?) -> some View {
|
||||
func themeValidDomainName(_ domainName: String?) -> some View {
|
||||
themeValidating(domainName, validator: Validators.domainName)
|
||||
.keyboardType(.asciiCapable)
|
||||
.autocapitalization(.none)
|
||||
.disableAutocorrection(true)
|
||||
}
|
||||
|
||||
func themeDNSOverTLSServerName(_ string: String?) -> some View {
|
||||
func themeValidDNSOverTLSServerName(_ string: String?) -> some View {
|
||||
themeValidating(string, validator: Validators.dnsOverTLSServerName)
|
||||
.keyboardType(.asciiCapable)
|
||||
.autocapitalization(.none)
|
||||
.disableAutocorrection(true)
|
||||
}
|
||||
|
||||
func themeSSID(_ text: String?) -> some View {
|
||||
func themeValidSSID(_ text: String?) -> some View {
|
||||
themeValidating(text, validator: Validators.notEmpty)
|
||||
.keyboardType(.asciiCapable)
|
||||
.autocapitalization(.none)
|
||||
|
|
|
@ -44,7 +44,7 @@ enum AddProfileView {
|
|||
footer: themeErrorMessage(errorMessage)
|
||||
) {
|
||||
TextField(L10n.Global.Placeholders.profileName, text: $profileName, onCommit: onCommit)
|
||||
.themeProfileName()
|
||||
.themeValidProfileName()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,12 +152,12 @@ extension NetworkSettingsView {
|
|||
|
||||
private var dnsManualHTTPSRow: some View {
|
||||
TextField(Unlocalized.Placeholders.dohURL, text: $settings.dns.dnsHTTPSURL.toString())
|
||||
.themeURL(settings.dns.dnsHTTPSURL?.absoluteString)
|
||||
.themeValidURL(settings.dns.dnsHTTPSURL?.absoluteString)
|
||||
}
|
||||
|
||||
private var dnsManualTLSRow: some View {
|
||||
TextField(Unlocalized.Placeholders.dotServerName, text: $settings.dns.dnsTLSServerName ?? "")
|
||||
.themeDNSOverTLSServerName(settings.dns.dnsTLSServerName)
|
||||
.themeValidDNSOverTLSServerName(settings.dns.dnsTLSServerName)
|
||||
}
|
||||
|
||||
private var dnsManualServers: some View {
|
||||
|
@ -172,7 +172,7 @@ extension NetworkSettingsView {
|
|||
text: $0.text,
|
||||
onEditingChanged: $0.onEditingChanged,
|
||||
onCommit: $0.onCommit
|
||||
).themeIPAddress($0.text.wrappedValue)
|
||||
).themeValidIPAddress($0.text.wrappedValue)
|
||||
} addLabel: {
|
||||
Text(L10n.NetworkSettings.Items.AddDnsServer.caption)
|
||||
} commitLabel: {
|
||||
|
@ -193,7 +193,7 @@ extension NetworkSettingsView {
|
|||
text: $0.text,
|
||||
onEditingChanged: $0.onEditingChanged,
|
||||
onCommit: $0.onCommit
|
||||
).themeDomainName($0.text.wrappedValue)
|
||||
).themeValidDomainName($0.text.wrappedValue)
|
||||
} addLabel: {
|
||||
Text(L10n.NetworkSettings.Items.AddDnsDomain.caption)
|
||||
} commitLabel: {
|
||||
|
@ -225,16 +225,16 @@ extension NetworkSettingsView {
|
|||
switch settings.proxy.configurationType {
|
||||
case .manual:
|
||||
TextField(Unlocalized.Placeholders.address, text: $settings.proxy.proxyAddress ?? "")
|
||||
.themeIPAddress(settings.proxy.proxyAddress)
|
||||
.themeValidIPAddress(settings.proxy.proxyAddress)
|
||||
.withLeadingText(L10n.Global.Strings.address)
|
||||
|
||||
TextField(Unlocalized.Placeholders.port, text: $settings.proxy.proxyPort.toString())
|
||||
.themeSocketPort()
|
||||
.themeValidSocketPort()
|
||||
.withLeadingText(L10n.Global.Strings.port)
|
||||
|
||||
case .pac:
|
||||
TextField(Unlocalized.Placeholders.pacURL, text: $settings.proxy.proxyAutoConfigurationURL.toString())
|
||||
.themeURL(settings.proxy.proxyAutoConfigurationURL?.absoluteString)
|
||||
.themeValidURL(settings.proxy.proxyAutoConfigurationURL?.absoluteString)
|
||||
|
||||
case .disabled:
|
||||
EmptyView()
|
||||
|
@ -258,7 +258,7 @@ extension NetworkSettingsView {
|
|||
text: $0.text,
|
||||
onEditingChanged: $0.onEditingChanged,
|
||||
onCommit: $0.onCommit
|
||||
).themeDomainName($0.text.wrappedValue)
|
||||
).themeValidDomainName($0.text.wrappedValue)
|
||||
} addLabel: {
|
||||
Text(L10n.NetworkSettings.Items.AddProxyBypass.caption)
|
||||
} commitLabel: {
|
||||
|
|
|
@ -72,7 +72,7 @@ extension OnDemandView {
|
|||
text: callback.text,
|
||||
onEditingChanged: callback.onEditingChanged,
|
||||
onCommit: callback.onCommit
|
||||
).themeSSID(callback.text.wrappedValue)
|
||||
).themeValidSSID(callback.text.wrappedValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ extension ProfileView {
|
|||
header: Text(L10n.Profile.Alerts.Rename.title)
|
||||
) {
|
||||
TextField(L10n.Global.Placeholders.profileName, text: $newName, onCommit: commitRenaming)
|
||||
.themeProfileName()
|
||||
.themeValidProfileName()
|
||||
.onAppear(perform: loadCurrentName)
|
||||
}
|
||||
}.themeSecondaryView()
|
||||
|
|
Loading…
Reference in New Issue