feat: hide proxy names

This commit is contained in:
mrFq1
2023-05-16 15:24:56 +08:00
parent adcfb183f9
commit 8e9bf8c6cc
4 changed files with 37 additions and 4 deletions
+17
View File
@@ -6,11 +6,18 @@
import SwiftUI
class HideProxyNames: ObservableObject, Identifiable {
let id = UUID().uuidString
@Published var hide = false
}
struct ContentView: View {
private let runningState = NotificationCenter.default.publisher(for: .init("ClashRunningStateChanged"))
@State private var isRunning = false
@StateObject private var hideProxyNames = HideProxyNames()
var body: some View {
Group {
if !isRunning {
@@ -24,6 +31,7 @@ struct ContentView: View {
}
}
}
.environmentObject(hideProxyNames)
.toolbar {
ToolbarItem(placement: .navigation) {
Button {
@@ -34,6 +42,15 @@ struct ContentView: View {
.help("Toggle Sidebar")
.disabled(!isRunning)
}
ToolbarItem {
Button {
hideProxyNames.hide = !hideProxyNames.hide
} label: {
Image(systemName: hideProxyNames.hide ? "eyeglasses" : "wand.and.stars")
}
.disabled(!isRunning)
}
}
.onReceive(runningState) { _ in
isRunning = ConfigManager.shared.isRunning