mirror of
https://github.com/yJason/ClashX-Dashboard.git
synced 2026-02-04 10:02:26 +08:00
misc: ProxyItemView select color
This commit is contained in:
@@ -18,6 +18,8 @@ struct ProxyGroupView: View {
|
|||||||
@State private var selectable = false
|
@State private var selectable = false
|
||||||
@State private var isTesting = false
|
@State private var isTesting = false
|
||||||
|
|
||||||
|
@State private var groupSelected: String?
|
||||||
|
|
||||||
var proxies: [DBProxy] {
|
var proxies: [DBProxy] {
|
||||||
if searchString.string.isEmpty {
|
if searchString.string.isEmpty {
|
||||||
return proxyGroup.proxies
|
return proxyGroup.proxies
|
||||||
@@ -52,6 +54,7 @@ struct ProxyGroupView: View {
|
|||||||
}
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
self.selectable = [.select, .fallback].contains(proxyGroup.type)
|
self.selectable = [.select, .fallback].contains(proxyGroup.type)
|
||||||
|
self.groupSelected = proxyGroup.now
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,9 +101,9 @@ struct ProxyGroupView: View {
|
|||||||
ForEach(proxies, id: \.id) { proxy in
|
ForEach(proxies, id: \.id) { proxy in
|
||||||
ProxyItemView(
|
ProxyItemView(
|
||||||
proxy: proxy,
|
proxy: proxy,
|
||||||
selectable: [.select, .fallback].contains(proxyGroup.type)
|
selectable: [.select, .fallback].contains(proxyGroup.type),
|
||||||
|
now: $groupSelected
|
||||||
)
|
)
|
||||||
.background(proxyGroup.now == proxy.name ? Color.pink.opacity(0.3) : Color(nsColor: .textBackgroundColor))
|
|
||||||
.cornerRadius(8)
|
.cornerRadius(8)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
let item = proxy
|
let item = proxy
|
||||||
@@ -138,6 +141,7 @@ struct ProxyGroupView: View {
|
|||||||
isUpdatingSelect = false
|
isUpdatingSelect = false
|
||||||
guard success else { return }
|
guard success else { return }
|
||||||
proxyGroup.now = name
|
proxyGroup.now = name
|
||||||
|
self.groupSelected = name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,13 +10,15 @@ struct ProxyItemView: View {
|
|||||||
|
|
||||||
@ObservedObject var proxy: DBProxy
|
@ObservedObject var proxy: DBProxy
|
||||||
@State var selectable: Bool
|
@State var selectable: Bool
|
||||||
|
@Binding var now: String?
|
||||||
|
|
||||||
@EnvironmentObject var hideProxyNames: HideProxyNames
|
@EnvironmentObject var hideProxyNames: HideProxyNames
|
||||||
|
|
||||||
init(proxy: DBProxy, selectable: Bool) {
|
|
||||||
|
init(proxy: DBProxy, selectable: Bool, now: Binding<String?> = .init(get: {nil}) { _ in }) {
|
||||||
self.proxy = proxy
|
self.proxy = proxy
|
||||||
self.selectable = selectable
|
self.selectable = selectable
|
||||||
|
self._now = now
|
||||||
self.isBuiltInProxy = [.pass, .direct, .reject].contains(proxy.type)
|
self.isBuiltInProxy = [.pass, .direct, .reject].contains(proxy.type)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,6 +70,7 @@ struct ProxyItemView: View {
|
|||||||
.padding(1)
|
.padding(1)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
.background(now == proxy.name ? Color.accentColor.opacity(0.7) : Color(nsColor: .textBackgroundColor))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user