Improve dashboard
This commit is contained in:
@@ -53,7 +53,7 @@ public struct MacApplication: Scene {
|
||||
MenuBarExtra(isInserted: $showMenuBarExtra) {
|
||||
MenuView(isMenuPresented: $isMenuPresented)
|
||||
} label: {
|
||||
Image(systemName: "network.badge.shield.half.filled")
|
||||
Image("MenuIcon")
|
||||
}
|
||||
.menuBarExtraStyle(.window)
|
||||
.menuBarExtraAccess(isPresented: $isMenuPresented)
|
||||
|
||||
@@ -17,11 +17,7 @@ public struct MainView: View {
|
||||
public init() {}
|
||||
public var body: some View {
|
||||
NavigationSplitView {
|
||||
VStack {
|
||||
SidebarView()
|
||||
}
|
||||
|
||||
.frame(minWidth: 150)
|
||||
SidebarView()
|
||||
} detail: {
|
||||
if profileLoading {
|
||||
ProgressView().onAppear {
|
||||
@@ -32,6 +28,7 @@ public struct MainView: View {
|
||||
}
|
||||
} else {
|
||||
selection.contentView
|
||||
.navigationTitle(selection.title)
|
||||
}
|
||||
}
|
||||
#if !DEBUG
|
||||
|
||||
@@ -149,8 +149,8 @@ public struct MenuView: View {
|
||||
}
|
||||
.onAppear {
|
||||
if observer == nil {
|
||||
observer = NotificationCenter.default.addObserver(forName: ActiveDashboardView.NotificationUpdateSelectedProfile, object: nil, queue: nil, using: { _ in
|
||||
doReload()
|
||||
observer = NotificationCenter.default.addObserver(forName: OverviewView.NotificationUpdateSelectedProfile, object: nil, queue: nil, using: { notification in
|
||||
selectedProfileID = notification.object as! Int64
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -188,7 +188,7 @@ public struct MenuView: View {
|
||||
|
||||
private func switchProfile(_ newProfileID: Int64) {
|
||||
SharedPreferences.selectedProfileID = newProfileID
|
||||
NotificationCenter.default.post(name: ActiveDashboardView.NotificationUpdateSelectedProfile, object: nil)
|
||||
NotificationCenter.default.post(name: OverviewView.NotificationUpdateSelectedProfile, object: newProfileID)
|
||||
if profile.status.isConnected {
|
||||
do {
|
||||
try LibboxNewStandaloneCommandClient()?.serviceReload()
|
||||
|
||||
@@ -8,13 +8,13 @@ public struct SidebarView: View {
|
||||
|
||||
public init() {}
|
||||
public var body: some View {
|
||||
viewBuilder {
|
||||
VStack {
|
||||
if let profile = extensionProfile.wrappedValue {
|
||||
SidebarView0().environmentObject(profile)
|
||||
} else {
|
||||
SidebarView1()
|
||||
}
|
||||
}
|
||||
}.frame(minWidth: 150)
|
||||
}
|
||||
|
||||
struct SidebarView0: View {
|
||||
@@ -22,11 +22,27 @@ public struct SidebarView: View {
|
||||
@EnvironmentObject private var extensionProfile: ExtensionProfile
|
||||
|
||||
var body: some View {
|
||||
List(NavigationPage.allCases.filter { it in
|
||||
it.visible(extensionProfile)
|
||||
}, selection: selection) { it in
|
||||
it.label
|
||||
}.onChangeCompat(of: extensionProfile.status) {
|
||||
VStack {
|
||||
if extensionProfile.status.isConnectedStrict {
|
||||
List(selection: selection) {
|
||||
Section(NavigationPage.dashboard.title) {
|
||||
Label("Overview", systemImage: "text.and.command.macwindow").tag(NavigationPage.dashboard)
|
||||
NavigationPage.groups.label.tag(NavigationPage.groups)
|
||||
}
|
||||
Divider()
|
||||
ForEach(NavigationPage.macosDefaultPages, id: \.self) { it in
|
||||
it.label
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List(NavigationPage.allCases.filter { it in
|
||||
it.visible(extensionProfile)
|
||||
}, selection: selection) { it in
|
||||
it.label
|
||||
}
|
||||
}
|
||||
}
|
||||
.onChangeCompat(of: extensionProfile.status) {
|
||||
if !selection.wrappedValue.visible(extensionProfile) {
|
||||
selection.wrappedValue = NavigationPage.dashboard
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user