Remove deprecated SwiftUI APIs

This commit is contained in:
Kenta Kubo 2022-05-05 03:53:59 +09:00
parent b3dc04f670
commit 745ed02482
3 changed files with 79 additions and 66 deletions

View file

@ -133,14 +133,18 @@ extension ContentView: View {
List {
NavigationLink(
"Instructions",
destination: HowToActivateView(isSheet: false),
tag: -1,
selection: self.$selection
)
Section(header: Text("Servers")) {
) {
HowToActivateView(isSheet: false)
}
Section {
ForEach(0..<self.servers.count, id: \.self) { i in
NavigationLink(
destination: DetailView(
tag: i,
selection: self.$selection
) {
DetailView(
server: self.$servers[i],
isOn: .init(
get: {
@ -154,10 +158,8 @@ extension ContentView: View {
}
}
)
),
tag: i,
selection: self.$selection
) {
)
} label: {
VStack(alignment: .leading) {
Text(self.servers[i].name)
Text(self.servers[i].configuration.description)
@ -171,9 +173,11 @@ extension ContentView: View {
}
.onDelete(perform: self.removeServers)
.onMove(perform: self.moveServers)
} header: {
Text("Servers")
}
}
.listStyle(SidebarListStyle())
.listStyle(.sidebar)
.navigationTitle(Bundle.main.displayName!)
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {

View file

@ -33,12 +33,7 @@ extension DetailView: View {
}
}
self.serverConfigurationSections
Section(
header: EditButton()
.foregroundColor(.accentColor)
.frame(maxWidth: .infinity, alignment: .trailing)
.overlay(Text("On Demand Rules"), alignment: .leading)
) {
Section {
ForEach(self.server.onDemandRules) { rule in
NavigationLink(
rule.name,
@ -51,6 +46,11 @@ extension DetailView: View {
self.server.onDemandRules
.append(OnDemandRule(name: "New Rule"))
}
} header: {
EditButton()
.foregroundColor(.accentColor)
.frame(maxWidth: .infinity, alignment: .trailing)
.overlay(Text("On Demand Rules"), alignment: .leading)
}
}
.navigationTitle(self.server.name)
@ -70,13 +70,7 @@ extension DetailView: View {
_ configuration: DoTConfiguration
) -> some View {
var configuration = configuration
Section(
header: EditButton()
.foregroundColor(.accentColor)
.frame(maxWidth: .infinity, alignment: .trailing)
.overlay(Text("Servers"), alignment: .leading),
footer: Text("The DNS server IP addresses.")
) {
Section {
ForEach(0..<configuration.servers.count, id: \.self) { i in
TextField(
"IP address",
@ -105,11 +99,15 @@ extension DetailView: View {
configuration.servers.append("")
self.server.configuration = .dnsOverTLS(configuration)
}
} header: {
EditButton()
.foregroundColor(.accentColor)
.frame(maxWidth: .infinity, alignment: .trailing)
.overlay(Text("Servers"), alignment: .leading)
} footer: {
Text("The DNS server IP addresses.")
}
Section(
header: Text("DNS-over-TLS Settings"),
footer: Text("The TLS name of a DNS-over-TLS server.")
) {
Section {
HStack {
Text("Server Name")
Spacer()
@ -133,6 +131,10 @@ extension DetailView: View {
.autocapitalization(.none)
.disableAutocorrection(true)
}
} header: {
Text("DNS-over-TLS Settings")
} footer: {
Text("The TLS name of a DNS-over-TLS server.")
}
}
@ -141,13 +143,7 @@ extension DetailView: View {
_ configuration: DoHConfiguration
) -> some View {
var configuration = configuration
Section(
header: EditButton()
.foregroundColor(.accentColor)
.frame(maxWidth: .infinity, alignment: .trailing)
.overlay(Text("Servers"), alignment: .leading),
footer: Text("The DNS server IP addresses.")
) {
Section {
ForEach(0..<configuration.servers.count, id: \.self) { i in
TextField(
"IP address",
@ -176,11 +172,15 @@ extension DetailView: View {
configuration.servers.append("")
self.server.configuration = .dnsOverHTTPS(configuration)
}
} header: {
EditButton()
.foregroundColor(.accentColor)
.frame(maxWidth: .infinity, alignment: .trailing)
.overlay(Text("Servers"), alignment: .leading)
} footer: {
Text("The DNS server IP addresses.")
}
Section(
header: Text("DNS-over-HTTPS Settings"),
footer: Text("The URL of a DNS-over-HTTPS server.")
) {
Section {
HStack {
Text("Server URL")
Spacer()
@ -204,6 +204,10 @@ extension DetailView: View {
.autocapitalization(.none)
.disableAutocorrection(true)
}
} header: {
Text("DNS-over-HTTPS Settings")
} footer: {
Text("The URL of a DNS-over-HTTPS server.")
}
}
}

View file

@ -28,25 +28,20 @@ extension RuleView: View {
}
}
Section(
header: Text("Interface Type Match"),
footer: Text("If the current primary network interface is of this type and all of the other conditions in the rule match, then the rule matches.")
) {
Section {
Picker("Interface Type", selection: self.$rule.interfaceType) {
ForEach(NEOnDemandRuleInterfaceType.allCases, id: \.self) {
Text($0.description)
}
}
} header: {
Text("Interface Type Match")
} footer: {
Text("If the current primary network interface is of this type and all of the other conditions in the rule match, then the rule matches.")
}
if self.rule.interfaceType.ssidIsUsed {
Section(
header: EditButton()
.foregroundColor(.accentColor)
.frame(maxWidth: .infinity, alignment: .trailing)
.overlay(Text("SSID Match"), alignment: .leading),
footer: Text("If the Service Set Identifier (SSID) of the current primary connected network matches one of the strings in this array and all of the other conditions in the rule match, then the rule matches.")
) {
Section {
ForEach(0..<self.rule.ssidMatch.count, id: \.self) { i in
TextField(
"SSID",
@ -64,16 +59,17 @@ extension RuleView: View {
self.rule.ssidMatch.append(network?.ssid ?? "")
}
}
} header: {
EditButton()
.foregroundColor(.accentColor)
.frame(maxWidth: .infinity, alignment: .trailing)
.overlay(Text("SSID Match"), alignment: .leading)
} footer: {
Text("If the Service Set Identifier (SSID) of the current primary connected network matches one of the strings in this array and all of the other conditions in the rule match, then the rule matches.")
}
}
Section(
header: EditButton()
.foregroundColor(.accentColor)
.frame(maxWidth: .infinity, alignment: .trailing)
.overlay(Text("DNS Search Domain Match"), alignment: .leading),
footer: Text("If the current default search domain is equal to one of the strings in this array and all of the other conditions in the rule match, then the rule matches.")
) {
Section {
ForEach(0..<self.rule.dnsSearchDomainMatch.count, id: \.self) { i in
TextField(
"Search Domain",
@ -89,15 +85,16 @@ extension RuleView: View {
Button("Add DNS Search Domain") {
self.rule.dnsSearchDomainMatch.append("")
}
}
Section(
header: EditButton()
} header: {
EditButton()
.foregroundColor(.accentColor)
.frame(maxWidth: .infinity, alignment: .trailing)
.overlay(Text("DNS Server Address Match"), alignment: .leading),
footer: Text("If each of the current default DNS servers is equal to one of the strings in this array and all of the other conditions in the rule match, then the rule matches.")
) {
.overlay(Text("DNS Search Domain Match"), alignment: .leading)
} footer: {
Text("If the current default search domain is equal to one of the strings in this array and all of the other conditions in the rule match, then the rule matches.")
}
Section {
ForEach(0..<self.rule.dnsServerAddressMatch.count, id: \.self) { i in
TextField(
"IP Address",
@ -113,12 +110,16 @@ extension RuleView: View {
Button("Add DNS Server Address") {
self.rule.dnsServerAddressMatch.append("")
}
} header: {
EditButton()
.foregroundColor(.accentColor)
.frame(maxWidth: .infinity, alignment: .trailing)
.overlay(Text("DNS Server Address Match"), alignment: .leading)
} footer: {
Text("If each of the current default DNS servers is equal to one of the strings in this array and all of the other conditions in the rule match, then the rule matches.")
}
Section(
header: Text("Probe URL Match"),
footer: Text("If a request sent to this URL results in a HTTP 200 OK response and all of the other conditions in the rule match, then the rule matches. If you don't want to use this rule, leave it empty.")
) {
Section {
HStack {
Text("Probe URL")
TextField(
@ -130,6 +131,10 @@ extension RuleView: View {
)
.multilineTextAlignment(.trailing)
}
} header: {
Text("Probe URL Match")
} footer: {
Text("If a request sent to this URL results in a HTTP 200 OK response and all of the other conditions in the rule match, then the rule matches. If you don't want to use this rule, leave it empty.")
}
}
.navigationTitle(self.rule.name)