mirror of
https://github.com/kkebo/DNSecure.git
synced 2026-03-11 08:54:36 +00:00
refactor: use LabeledContent on newer OSes
This commit is contained in:
parent
7433d55450
commit
67a8db045d
1 changed files with 153 additions and 54 deletions
|
|
@ -23,82 +23,33 @@ extension RuleView: View {
|
|||
NavigationLink {
|
||||
InterfaceTypeMatchView(rule: self.$rule)
|
||||
} label: {
|
||||
HStack {
|
||||
Text("Interface Type Match")
|
||||
Spacer()
|
||||
Text(self.rule.interfaceType.description)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
self.interfaceTypeMatchLabel
|
||||
}
|
||||
|
||||
if self.rule.interfaceType.isSSIDUsed {
|
||||
NavigationLink {
|
||||
SSIDMatchView(rule: self.$rule)
|
||||
} label: {
|
||||
HStack {
|
||||
Text("SSID Match")
|
||||
Spacer()
|
||||
Group {
|
||||
if !self.rule.ssidMatch.isEmpty {
|
||||
Text("\(self.rule.ssidMatch.count)")
|
||||
} else {
|
||||
Text("Not Used")
|
||||
}
|
||||
}
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
self.ssidMatchLabel
|
||||
}
|
||||
}
|
||||
|
||||
NavigationLink {
|
||||
DNSSearchDomainMatchView(rule: self.$rule)
|
||||
} label: {
|
||||
HStack {
|
||||
Text("DNS Search Domain Match")
|
||||
Spacer()
|
||||
Group {
|
||||
if !self.rule.dnsSearchDomainMatch.isEmpty {
|
||||
Text("\(self.rule.dnsSearchDomainMatch.count)")
|
||||
} else {
|
||||
Text("Not Used")
|
||||
}
|
||||
}
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
self.dnsSearchDomainMatchLabel
|
||||
}
|
||||
|
||||
NavigationLink {
|
||||
DNSServerAddressMatchView(rule: self.$rule)
|
||||
} label: {
|
||||
HStack {
|
||||
Text("DNS Server Address Match")
|
||||
Spacer()
|
||||
Group {
|
||||
if !self.rule.dnsServerAddressMatch.isEmpty {
|
||||
Text("\(self.rule.dnsServerAddressMatch.count)")
|
||||
} else {
|
||||
Text("Not Used")
|
||||
}
|
||||
}
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
self.dnsServerAddressMatchLabel
|
||||
}
|
||||
|
||||
NavigationLink {
|
||||
ProbeURLView(rule: self.$rule)
|
||||
} label: {
|
||||
HStack {
|
||||
Text("Probe URL")
|
||||
Spacer()
|
||||
Group {
|
||||
if let url = self.rule.probeURL?.absoluteString {
|
||||
Text(url)
|
||||
} else {
|
||||
Text("Not Used")
|
||||
}
|
||||
}
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
self.probeURLLabel
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -112,6 +63,154 @@ extension RuleView: View {
|
|||
}
|
||||
.navigationTitle(self.rule.name)
|
||||
}
|
||||
|
||||
private var interfaceTypeMatchLabel: some View {
|
||||
@available(iOS 16, *)
|
||||
var modern: some View {
|
||||
LabeledContent("Interface Type Match", value: self.rule.interfaceType.description)
|
||||
}
|
||||
var legacy: some View {
|
||||
HStack {
|
||||
Text("Interface Type Match")
|
||||
Spacer()
|
||||
Text(self.rule.interfaceType.description)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
if #available(iOS 16, *) {
|
||||
return modern
|
||||
} else {
|
||||
return legacy
|
||||
}
|
||||
}
|
||||
|
||||
private var ssidMatchLabel: some View {
|
||||
@available(iOS 16, *)
|
||||
var modern: some View {
|
||||
LabeledContent("SSID Match") {
|
||||
if !self.rule.ssidMatch.isEmpty {
|
||||
Text("\(self.rule.ssidMatch.count)")
|
||||
} else {
|
||||
Text("Not Used")
|
||||
}
|
||||
}
|
||||
}
|
||||
var legacy: some View {
|
||||
HStack {
|
||||
Text("SSID Match")
|
||||
Spacer()
|
||||
Group {
|
||||
if !self.rule.ssidMatch.isEmpty {
|
||||
Text("\(self.rule.ssidMatch.count)")
|
||||
} else {
|
||||
Text("Not Used")
|
||||
}
|
||||
}
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
if #available(iOS 16, *) {
|
||||
return modern
|
||||
} else {
|
||||
return legacy
|
||||
}
|
||||
}
|
||||
|
||||
private var dnsSearchDomainMatchLabel: some View {
|
||||
@available(iOS 16, *)
|
||||
var modern: some View {
|
||||
LabeledContent("DNS Search Domain Match") {
|
||||
if !self.rule.dnsSearchDomainMatch.isEmpty {
|
||||
Text("\(self.rule.dnsSearchDomainMatch.count)")
|
||||
} else {
|
||||
Text("Not Used")
|
||||
}
|
||||
}
|
||||
}
|
||||
var legacy: some View {
|
||||
HStack {
|
||||
Text("DNS Search Domain Match")
|
||||
Spacer()
|
||||
Group {
|
||||
if !self.rule.dnsSearchDomainMatch.isEmpty {
|
||||
Text("\(self.rule.dnsSearchDomainMatch.count)")
|
||||
} else {
|
||||
Text("Not Used")
|
||||
}
|
||||
}
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
if #available(iOS 16, *) {
|
||||
return modern
|
||||
} else {
|
||||
return legacy
|
||||
}
|
||||
}
|
||||
|
||||
private var dnsServerAddressMatchLabel: some View {
|
||||
@available(iOS 16, *)
|
||||
var modern: some View {
|
||||
LabeledContent("DNS Server Address Match") {
|
||||
if !self.rule.dnsServerAddressMatch.isEmpty {
|
||||
Text("\(self.rule.dnsServerAddressMatch.count)")
|
||||
} else {
|
||||
Text("Not Used")
|
||||
}
|
||||
}
|
||||
}
|
||||
var legacy: some View {
|
||||
HStack {
|
||||
Text("DNS Server Address Match")
|
||||
Spacer()
|
||||
Group {
|
||||
if !self.rule.dnsServerAddressMatch.isEmpty {
|
||||
Text("\(self.rule.dnsServerAddressMatch.count)")
|
||||
} else {
|
||||
Text("Not Used")
|
||||
}
|
||||
}
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
if #available(iOS 16, *) {
|
||||
return modern
|
||||
} else {
|
||||
return legacy
|
||||
}
|
||||
}
|
||||
|
||||
private var probeURLLabel: some View {
|
||||
@available(iOS 16, *)
|
||||
var modern: some View {
|
||||
LabeledContent("Probe URL") {
|
||||
if let url = self.rule.probeURL?.absoluteString {
|
||||
Text(url)
|
||||
} else {
|
||||
Text("Not Used")
|
||||
}
|
||||
}
|
||||
}
|
||||
var legacy: some View {
|
||||
HStack {
|
||||
Text("Probe URL")
|
||||
Spacer()
|
||||
Group {
|
||||
if let url = self.rule.probeURL?.absoluteString {
|
||||
Text(url)
|
||||
} else {
|
||||
Text("Not Used")
|
||||
}
|
||||
}
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
if #available(iOS 16, *) {
|
||||
return modern
|
||||
} else {
|
||||
return legacy
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 17, *)
|
||||
|
|
|
|||
Loading…
Reference in a new issue