mirror of
https://github.com/kkebo/DNSecure.git
synced 2026-03-11 08:54:36 +00:00
refactor: Split ExcludedDomainsView into a separate file
This commit is contained in:
parent
031f9408a0
commit
3d5397fa7e
2 changed files with 45 additions and 36 deletions
45
DNSecure/Views/ExcludedDomainsView.swift
Normal file
45
DNSecure/Views/ExcludedDomainsView.swift
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import SwiftUI
|
||||
|
||||
struct ExcludedDomainsView {
|
||||
@Binding var domains: [String]
|
||||
}
|
||||
|
||||
extension ExcludedDomainsView: View {
|
||||
var body: some View {
|
||||
Form {
|
||||
Section {
|
||||
ForEach(0..<self.domains.count, id: \.self) { i in
|
||||
LazyTextField(
|
||||
"Domain",
|
||||
// self.$rule.excludedDomains[i] causes crash on deletion
|
||||
text: .init(
|
||||
get: { self.domains[i] },
|
||||
set: { self.domains[i] = $0 }
|
||||
)
|
||||
)
|
||||
}
|
||||
.onDelete { self.domains.remove(atOffsets: $0) }
|
||||
.onMove { self.domains.move(fromOffsets: $0, toOffset: $1) }
|
||||
Button("Add Domain") {
|
||||
self.domains.append("")
|
||||
}
|
||||
} footer: {
|
||||
Text(
|
||||
"Each domain is matched against the destination hostname using suffix matching, and each label in the domain must match an entire label in the hostname. For example, the domain `example.com` will match the hostname `www.example.com` but not `www.anotherexample.com`."
|
||||
)
|
||||
}
|
||||
}
|
||||
.navigationTitle("Excluded Domains")
|
||||
.toolbar {
|
||||
EditButton()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 17, *)
|
||||
#Preview {
|
||||
@Previewable @State var domains = ["example.com"]
|
||||
NavigationStack {
|
||||
ExcludedDomainsView(domains: $domains)
|
||||
}
|
||||
}
|
||||
|
|
@ -8,42 +8,6 @@
|
|||
import NetworkExtension
|
||||
import SwiftUI
|
||||
|
||||
struct ExcludedDomainsView {
|
||||
@Binding var domains: [String]
|
||||
}
|
||||
|
||||
extension ExcludedDomainsView: View {
|
||||
var body: some View {
|
||||
Form {
|
||||
Section {
|
||||
ForEach(0..<self.domains.count, id: \.self) { i in
|
||||
LazyTextField(
|
||||
"Domain",
|
||||
// self.$rule.excludedDomains[i] causes crash on deletion
|
||||
text: .init(
|
||||
get: { self.domains[i] },
|
||||
set: { self.domains[i] = $0 }
|
||||
)
|
||||
)
|
||||
}
|
||||
.onDelete { self.domains.remove(atOffsets: $0) }
|
||||
.onMove { self.domains.move(fromOffsets: $0, toOffset: $1) }
|
||||
Button("Add Domain") {
|
||||
self.domains.append("")
|
||||
}
|
||||
} footer: {
|
||||
Text(
|
||||
"Each domain is matched against the destination hostname using suffix matching, and each label in the domain must match an entire label in the hostname. For example, the domain `example.com` will match the hostname `www.example.com` but not `www.anotherexample.com`."
|
||||
)
|
||||
}
|
||||
}
|
||||
.navigationTitle("Excluded Domains")
|
||||
.toolbar {
|
||||
EditButton()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct RuleView {
|
||||
@Binding var rule: OnDemandRule
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue