feat: toolbar items

This commit is contained in:
mrFq1
2023-05-27 18:14:13 +08:00
parent 33a4eab579
commit 30922826e8
8 changed files with 134 additions and 54 deletions
@@ -15,50 +15,19 @@ struct SidebarView: View {
@State private var sidebarSelectionName: String? = "Overview"
@State private var sidebarItems = [
SidebarItem(name: "Overview",
icon: "chart.bar.xaxis",
view: AnyView(OverviewView())),
SidebarItem(name: "Proxies",
icon: "globe.asia.australia",
view: AnyView(ProxiesView())),
SidebarItem(name: "Providers",
icon: "link.icloud",
view: AnyView(ProvidersView())),
SidebarItem(name: "Rules",
icon: "waveform.and.magnifyingglass",
view: AnyView(RulesView())),
SidebarItem(name: "Conns",
icon: "app.connected.to.app.below.fill",
view: AnyView(ConnectionsView())),
SidebarItem(name: "Config",
icon: "slider.horizontal.3",
view: AnyView(ConfigView())),
SidebarItem(name: "Logs",
icon: "wand.and.stars.inverse",
view: AnyView(LogsView()))
]
var body: some View {
ScrollViewReader { scrollViewProxy in
List(sidebarItems, id: \.id) { item in
SidebarItemView(item: item, selectionName: $sidebarSelectionName)
}
.listStyle(.sidebar)
SidebarListView(selectionName: $sidebarSelectionName)
}
.environmentObject(clashApiDatasStorage.overviewData)
.environmentObject(clashApiDatasStorage.logStorage)
.environmentObject(clashApiDatasStorage.connsStorage)
.onAppear {
ConfigManager.selectLoggingApiLevel = .debug
clashApiDatasStorage.resetStreamApi()
if ConfigManager.selectLoggingApiLevel == .unknow {
ConfigManager.selectLoggingApiLevel = .info
}
clashApiDatasStorage.resetStreamApi()
connsQueue.sync {
clashApiDatasStorage.connsStorage.conns
.removeAll()