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 {
|
NavigationLink {
|
||||||
InterfaceTypeMatchView(rule: self.$rule)
|
InterfaceTypeMatchView(rule: self.$rule)
|
||||||
} label: {
|
} label: {
|
||||||
HStack {
|
self.interfaceTypeMatchLabel
|
||||||
Text("Interface Type Match")
|
|
||||||
Spacer()
|
|
||||||
Text(self.rule.interfaceType.description)
|
|
||||||
.foregroundStyle(.secondary)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.rule.interfaceType.isSSIDUsed {
|
if self.rule.interfaceType.isSSIDUsed {
|
||||||
NavigationLink {
|
NavigationLink {
|
||||||
SSIDMatchView(rule: self.$rule)
|
SSIDMatchView(rule: self.$rule)
|
||||||
} label: {
|
} label: {
|
||||||
HStack {
|
self.ssidMatchLabel
|
||||||
Text("SSID Match")
|
|
||||||
Spacer()
|
|
||||||
Group {
|
|
||||||
if !self.rule.ssidMatch.isEmpty {
|
|
||||||
Text("\(self.rule.ssidMatch.count)")
|
|
||||||
} else {
|
|
||||||
Text("Not Used")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.foregroundStyle(.secondary)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationLink {
|
NavigationLink {
|
||||||
DNSSearchDomainMatchView(rule: self.$rule)
|
DNSSearchDomainMatchView(rule: self.$rule)
|
||||||
} label: {
|
} label: {
|
||||||
HStack {
|
self.dnsSearchDomainMatchLabel
|
||||||
Text("DNS Search Domain Match")
|
|
||||||
Spacer()
|
|
||||||
Group {
|
|
||||||
if !self.rule.dnsSearchDomainMatch.isEmpty {
|
|
||||||
Text("\(self.rule.dnsSearchDomainMatch.count)")
|
|
||||||
} else {
|
|
||||||
Text("Not Used")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.foregroundStyle(.secondary)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationLink {
|
NavigationLink {
|
||||||
DNSServerAddressMatchView(rule: self.$rule)
|
DNSServerAddressMatchView(rule: self.$rule)
|
||||||
} label: {
|
} label: {
|
||||||
HStack {
|
self.dnsServerAddressMatchLabel
|
||||||
Text("DNS Server Address Match")
|
|
||||||
Spacer()
|
|
||||||
Group {
|
|
||||||
if !self.rule.dnsServerAddressMatch.isEmpty {
|
|
||||||
Text("\(self.rule.dnsServerAddressMatch.count)")
|
|
||||||
} else {
|
|
||||||
Text("Not Used")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.foregroundStyle(.secondary)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationLink {
|
NavigationLink {
|
||||||
ProbeURLView(rule: self.$rule)
|
ProbeURLView(rule: self.$rule)
|
||||||
} label: {
|
} label: {
|
||||||
HStack {
|
self.probeURLLabel
|
||||||
Text("Probe URL")
|
|
||||||
Spacer()
|
|
||||||
Group {
|
|
||||||
if let url = self.rule.probeURL?.absoluteString {
|
|
||||||
Text(url)
|
|
||||||
} else {
|
|
||||||
Text("Not Used")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.foregroundStyle(.secondary)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,6 +63,154 @@ extension RuleView: View {
|
||||||
}
|
}
|
||||||
.navigationTitle(self.rule.name)
|
.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, *)
|
@available(iOS 17, *)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue