Filter servers with category/country of selected server (#735)
And use Task for blocking actions in filters.
This commit is contained in:
parent
aeaf0a6eed
commit
9656e5ed29
|
@ -41,7 +41,7 @@
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "git@github.com:passepartoutvpn/passepartoutkit-source",
|
"location" : "git@github.com:passepartoutvpn/passepartoutkit-source",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "c4182832032fab8fef24386d209572a2c288e28e"
|
"revision" : "5c402931e0628f3280c603cce5c8c3d05b1cfa1f"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,7 +28,7 @@ let package = Package(
|
||||||
],
|
],
|
||||||
dependencies: [
|
dependencies: [
|
||||||
// .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", from: "0.9.0"),
|
// .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", from: "0.9.0"),
|
||||||
.package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", revision: "c4182832032fab8fef24386d209572a2c288e28e"),
|
.package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", revision: "5c402931e0628f3280c603cce5c8c3d05b1cfa1f"),
|
||||||
// .package(path: "../../../passepartoutkit-source"),
|
// .package(path: "../../../passepartoutkit-source"),
|
||||||
.package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", from: "0.9.1"),
|
.package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", from: "0.9.1"),
|
||||||
// .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", revision: "031863a1cd683962a7dfe68e20b91fa820a1ecce"),
|
// .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", revision: "031863a1cd683962a7dfe68e20b91fa820a1ecce"),
|
||||||
|
|
|
@ -38,7 +38,7 @@ struct VPNFiltersModifier<Configuration>: ViewModifier where Configuration: Deco
|
||||||
contentView(with: content)
|
contentView(with: content)
|
||||||
.onChange(of: manager.parameters.filters) { _ in
|
.onChange(of: manager.parameters.filters) { _ in
|
||||||
Task {
|
Task {
|
||||||
await manager.applyFilters()
|
manager.applyFilters()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,6 @@ struct VPNFiltersView<Configuration>: View where Configuration: Decodable {
|
||||||
@ObservedObject
|
@ObservedObject
|
||||||
var manager: VPNProviderManager
|
var manager: VPNProviderManager
|
||||||
|
|
||||||
@State
|
|
||||||
private var isRefreshing = false
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Form {
|
Form {
|
||||||
Section {
|
Section {
|
||||||
|
@ -96,7 +93,9 @@ private extension VPNFiltersView {
|
||||||
|
|
||||||
var clearFiltersButton: some View {
|
var clearFiltersButton: some View {
|
||||||
Button("Clear filters", role: .destructive) {
|
Button("Clear filters", role: .destructive) {
|
||||||
manager.resetFilters()
|
Task {
|
||||||
|
manager.resetFilters()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,18 +84,22 @@ private extension VPNProviderContentModifier {
|
||||||
guard let providerId else {
|
guard let providerId else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
let initialEntity = isInitial ? selectedEntity : nil
|
||||||
if !isInitial {
|
if !isInitial {
|
||||||
selectedEntity = nil
|
selectedEntity = nil
|
||||||
}
|
}
|
||||||
vpnProviderManager.view = manager.vpnView(
|
let view = manager.vpnView(
|
||||||
for: providerId,
|
for: providerId,
|
||||||
configurationType: OpenVPN.Configuration.self,
|
configurationType: OpenVPN.Configuration.self,
|
||||||
initialParameters: .init(sorting: [
|
initialParameters: .init(
|
||||||
.localizedCountry,
|
sorting: [
|
||||||
.area,
|
.localizedCountry,
|
||||||
.hostname
|
.area,
|
||||||
])
|
.hostname
|
||||||
|
]
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
vpnProviderManager.setView(view, filteringWith: initialEntity?.server.provider)
|
||||||
}
|
}
|
||||||
|
|
||||||
func onSelectServer(server: VPNServer, preset: VPNPreset<Configuration>) {
|
func onSelectServer(server: VPNServer, preset: VPNPreset<Configuration>) {
|
||||||
|
|
|
@ -31,24 +31,22 @@ import SwiftUI
|
||||||
|
|
||||||
extension VPNFiltersModifier {
|
extension VPNFiltersModifier {
|
||||||
func contentView(with content: Content) -> some View {
|
func contentView(with content: Content) -> some View {
|
||||||
List {
|
content
|
||||||
content
|
.toolbar {
|
||||||
}
|
Button {
|
||||||
.toolbar {
|
isFiltersPresented = true
|
||||||
Button {
|
} label: {
|
||||||
isFiltersPresented = true
|
Image(systemName: "line.3.horizontal.decrease")
|
||||||
} label: {
|
}
|
||||||
Image(systemName: "line.3.horizontal.decrease")
|
.themeModal(isPresented: $isFiltersPresented) {
|
||||||
|
NavigationStack {
|
||||||
|
VPNFiltersView<Configuration>(manager: manager)
|
||||||
|
.navigationTitle("Filters")
|
||||||
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
|
}
|
||||||
|
.presentationDetents([.medium])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
.themeModal(isPresented: $isFiltersPresented) {
|
|
||||||
NavigationStack {
|
|
||||||
VPNFiltersView<Configuration>(manager: manager)
|
|
||||||
.navigationTitle("Filters")
|
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
|
||||||
}
|
|
||||||
.presentationDetents([.medium])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,11 @@ extension VPNProviderServerView {
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
var serversView: some View {
|
var serversView: some View {
|
||||||
ForEach(manager.filteredServers) { server in
|
List {
|
||||||
Button("\(server.hostname ?? server.id) \(server.provider.countryCodes)") {
|
ForEach(manager.filteredServers, id: \.id) { server in
|
||||||
selectServer(server)
|
Button("\(server.hostname ?? server.id) \(server.provider.countryCodes)") {
|
||||||
|
selectServer(server)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue