mirror of
https://github.com/yJason/ClashX-Dashboard.git
synced 2026-02-04 10:02:26 +08:00
58 lines
1.2 KiB
Swift
58 lines
1.2 KiB
Swift
//
|
|
// ProxiesView.swift
|
|
// ClashX Dashboard
|
|
//
|
|
//
|
|
|
|
import SwiftUI
|
|
import Introspect
|
|
|
|
class ProxiesSearchString: ObservableObject, Identifiable {
|
|
let id = UUID().uuidString
|
|
@Published var string: String = ""
|
|
}
|
|
|
|
struct ProxiesView: View {
|
|
|
|
@ObservedObject var proxyStorage = DBProxyStorage()
|
|
|
|
@State private var searchString = ProxiesSearchString()
|
|
@State private var isGlobalMode = false
|
|
|
|
var body: some View {
|
|
NavigationView {
|
|
List(proxyStorage.groups, id: \.id) { group in
|
|
ProxyGroupRowView(proxyGroup: group)
|
|
}
|
|
.introspectTableView {
|
|
$0.refusesFirstResponder = true
|
|
$0.doubleAction = nil
|
|
}
|
|
.listStyle(.plain)
|
|
EmptyView()
|
|
}
|
|
.searchable(text: $searchString.string)
|
|
.environmentObject(searchString)
|
|
.onAppear {
|
|
loadProxies()
|
|
}
|
|
}
|
|
|
|
|
|
func loadProxies() {
|
|
// self.isGlobalMode = ConfigManager.shared.currentConfig?.mode == .global
|
|
ApiRequest.getMergedProxyData {
|
|
guard let resp = $0 else { return }
|
|
proxyStorage.groups = DBProxyStorage(resp).groups.filter {
|
|
isGlobalMode ? true : $0.name != "GLOBAL"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//struct ProxiesView_Previews: PreviewProvider {
|
|
// static var previews: some View {
|
|
// ProxiesView()
|
|
// }
|
|
//}
|