mirror of
https://github.com/yJason/ClashX-Dashboard.git
synced 2026-02-04 10:02:26 +08:00
misc: SidebarLabel
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
//
|
||||||
|
// SwiftUIView.swift
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct SidebarLabel: View {
|
||||||
|
@State var item: SidebarItem
|
||||||
|
@State var iconName: String
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
HStack {
|
||||||
|
Image(systemName: iconName)
|
||||||
|
.foregroundColor(.accentColor)
|
||||||
|
Text(item.rawValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct SidebarLabel_Previews: PreviewProvider {
|
||||||
|
static var previews: some View {
|
||||||
|
SidebarLabel(item: .overview, iconName: "chart.bar.xaxis")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,47 +19,49 @@ struct SidebarListView: View {
|
|||||||
NavigationLink(destination: OverviewView(),
|
NavigationLink(destination: OverviewView(),
|
||||||
tag: SidebarItem.overview,
|
tag: SidebarItem.overview,
|
||||||
selection: $selectionName) {
|
selection: $selectionName) {
|
||||||
Label(SidebarItem.overview.rawValue, systemImage: "chart.bar.xaxis")
|
SidebarLabel(item: .overview, iconName: "chart.bar.xaxis")
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationLink(destination: ProxiesView(),
|
NavigationLink(destination: ProxiesView(),
|
||||||
tag: SidebarItem.proxies,
|
tag: SidebarItem.proxies,
|
||||||
selection: $selectionName) {
|
selection: $selectionName) {
|
||||||
Label(SidebarItem.proxies.rawValue, systemImage: "globe.asia.australia")
|
SidebarLabel(item: .proxies, iconName: "globe.asia.australia")
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationLink(destination: ProvidersView(),
|
NavigationLink(destination: ProvidersView(),
|
||||||
tag: SidebarItem.providers,
|
tag: SidebarItem.providers,
|
||||||
selection: $selectionName) {
|
selection: $selectionName) {
|
||||||
Label(SidebarItem.providers.rawValue, systemImage: "link.icloud")
|
SidebarLabel(item: .providers, iconName: "link.icloud")
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationLink(destination: RulesView(),
|
NavigationLink(destination: RulesView(),
|
||||||
tag: SidebarItem.rules,
|
tag: SidebarItem.rules,
|
||||||
selection: $selectionName) {
|
selection: $selectionName) {
|
||||||
Label(SidebarItem.rules.rawValue, systemImage: "waveform.and.magnifyingglass")
|
SidebarLabel(item: .rules, iconName: "waveform.and.magnifyingglass")
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationLink(destination: ConnectionsView(),
|
NavigationLink(destination: ConnectionsView(),
|
||||||
tag: SidebarItem.conns,
|
tag: SidebarItem.conns,
|
||||||
selection: $selectionName) {
|
selection: $selectionName) {
|
||||||
Label(SidebarItem.conns.rawValue, systemImage: "app.connected.to.app.below.fill")
|
SidebarLabel(item: .conns, iconName: "app.connected.to.app.below.fill")
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationLink(destination: ConfigView(),
|
NavigationLink(destination: ConfigView(),
|
||||||
tag: SidebarItem.config,
|
tag: SidebarItem.config,
|
||||||
selection: $selectionName) {
|
selection: $selectionName) {
|
||||||
Label(SidebarItem.config.rawValue, systemImage: "slider.horizontal.3")
|
SidebarLabel(item: .config, iconName: "slider.horizontal.3")
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationLink(destination: LogsView(),
|
NavigationLink(destination: LogsView(),
|
||||||
tag: SidebarItem.logs,
|
tag: SidebarItem.logs,
|
||||||
selection: $selectionName) {
|
selection: $selectionName) {
|
||||||
Label(SidebarItem.logs.rawValue, systemImage: "wand.and.stars.inverse")
|
SidebarLabel(item: .logs, iconName: "wand.and.stars.inverse")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
.introspectTableView {
|
.introspectTableView {
|
||||||
|
$0.refusesFirstResponder = true
|
||||||
|
|
||||||
if selectionName == nil {
|
if selectionName == nil {
|
||||||
selectionName = SidebarItem.overview
|
selectionName = SidebarItem.overview
|
||||||
$0.allowsEmptySelection = false
|
$0.allowsEmptySelection = false
|
||||||
|
|||||||
Reference in New Issue
Block a user