Highlight selected server (#752)

Use provider-aware ID.
This commit is contained in:
Davide 2024-10-23 18:40:09 +02:00 committed by GitHub
parent 48dc31a1f1
commit 12d3bd20f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 4 deletions

View File

@ -57,7 +57,7 @@ struct Issue: Identifiable {
purchasedProducts: Set<AppProduct>,
appLog: Data? = nil,
tunnelLog: Data? = nil,
providerId: ProviderID?
providerId: ProviderID? = nil
) {
id = UUID()
self.appLine = appLine

View File

@ -60,6 +60,7 @@ struct VPNProviderServerView<Configuration>: View where Configuration: ProviderC
debugChanges()
return Subview(
manager: manager,
selectedServer: selectedEntity?.server,
filters: $filters,
onSelect: selectServer
)

View File

@ -34,6 +34,8 @@ extension VPNProviderServerView {
@ObservedObject
var manager: VPNProviderManager<Configuration>
let selectedServer: VPNServer?
@Binding
var filters: VPNFilters
@ -85,7 +87,7 @@ private extension VPNProviderServerView.Subview {
countryServers(for: code)
.map { servers in
DisclosureGroup {
ForEach(servers, id: \.serverId, content: serverView)
ForEach(servers, id: \.id, content: serverView)
} label: {
HStack {
ThemeCountryFlag(code: code)
@ -99,7 +101,12 @@ private extension VPNProviderServerView.Subview {
Button {
onSelect(server)
} label: {
Text(server.hostname ?? server.id)
HStack {
Text(server.hostname ?? server.serverId)
Spacer()
ThemeImage(.marked)
.opacity(server.id == selectedServer?.id ? 1.0 : 0.0)
}
}
}

View File

@ -34,6 +34,8 @@ extension VPNProviderServerView {
@ObservedObject
var manager: VPNProviderManager<Configuration>
let selectedServer: VPNServer?
@Binding
var filters: VPNFilters
@ -50,7 +52,7 @@ extension VPNProviderServerView {
private extension VPNProviderServerView.Subview {
var tableView: some View {
Table(manager.filteredServers) {
Table(manager.filteredServers, selection: .constant(selectedServer?.id)) {
TableColumn(Strings.Global.region) { server in
HStack {
ThemeCountryFlag(code: server.provider.countryCode)