diff --git a/ApplicationLibrary/Views/Dashboard/ActiveDashboardView.swift b/ApplicationLibrary/Views/Dashboard/ActiveDashboardView.swift index 579eab1..2879762 100644 --- a/ApplicationLibrary/Views/Dashboard/ActiveDashboardView.swift +++ b/ApplicationLibrary/Views/Dashboard/ActiveDashboardView.swift @@ -57,7 +57,24 @@ import SwiftUI } @ViewBuilder private var content: some View { - overviewPage + Group { + #if os(iOS) + if useLegacyTabView { + if ApplicationLibrary.inPreview || profile.status.isConnectedStrict { + VStack { + pageSelector + pageContent + } + } else { + overviewPage + } + } else { + overviewPage + } + #else + overviewPage + #endif + } #if os(iOS) || os(tvOS) .toolbar { toolbar @@ -139,10 +156,20 @@ import SwiftUI #if os(iOS) || os(tvOS) .onReceive(environments.commandClient.$groups) { _ in updateButtonVisibility() + #if os(iOS) + if useLegacyTabView, coordinator.selection == .groups, !buttonState.showGroupsButton { + coordinator.selection = .overview + } + #endif }.onReceive(environments.commandClient.$connections) { _ in updateButtonVisibility() }.onReceive(profile.$status) { _ in updateButtonVisibility() + #if os(iOS) + if useLegacyTabView, coordinator.selection == .groups, !buttonState.showGroupsButton { + coordinator.selection = .overview + } + #endif }.onAppear { updateButtonVisibility() } @@ -171,6 +198,44 @@ import SwiftUI } return false } + + private var useLegacyTabView: Bool { + !isTabViewBottomAccessoryAvailable + } + + private var enabledPages: [DashboardPage] { + DashboardPage.enabledCases(hasGroups: buttonState.showGroupsButton) + } + + @ViewBuilder + private var pageSelector: some View { + Picker("Page", selection: $coordinator.selection) { + ForEach(enabledPages) { page in + page.label + } + } + .pickerStyle(.segmented) + .padding([.leading, .trailing]) + .navigationBarTitleDisplayMode(.inline) + } + + @ViewBuilder + private var pageContent: some View { + TabView(selection: $coordinator.selection) { + ForEach(enabledPages) { page in + page.contentView( + $coordinator.profileList, + $coordinator.selectedProfileID, + $coordinator.systemProxyAvailable, + $coordinator.systemProxyEnabled, + externalCardConfigurationVersion ?? cardConfigurationVersion + ) + .tag(page) + } + } + .navigationBarTitleDisplayMode(.inline) + .tabViewStyle(.page(indexDisplayMode: .never)) + } #endif @ToolbarContentBuilder private var toolbar: some ToolbarContent { @@ -223,33 +288,10 @@ import SwiftUI @available(iOS 16.0, *) @ViewBuilder private var cardManagementButton: some View { #if os(iOS) - Menu { - if !isTabViewBottomAccessoryAvailable { - if buttonState.showGroupsButton { - Button { - showGroups = true - } label: { - Label("Groups (\(buttonState.groupsCount))", systemImage: "rectangle.3.group.fill") - } - } - if buttonState.showConnectionsButton { - Button { - showConnections = true - } label: { - Label("Connections (\(buttonState.connectionsCount))", systemImage: "list.bullet.rectangle.portrait.fill") - } - } - if buttonState.showGroupsButton || buttonState.showConnectionsButton { - Divider() - } - } - Button { - showCardManagement = true - } label: { - Label("Dashboard Items", systemImage: "square.grid.2x2") - } + Button { + showCardManagement = true } label: { - Label("Others", systemImage: "line.3.horizontal.circle") + Label("Dashboard Items", systemImage: "square.grid.2x2") } #elseif os(tvOS) Button { diff --git a/ApplicationLibrary/Views/Dashboard/DashboardPage.swift b/ApplicationLibrary/Views/Dashboard/DashboardPage.swift index c3d52f4..87be6a3 100644 --- a/ApplicationLibrary/Views/Dashboard/DashboardPage.swift +++ b/ApplicationLibrary/Views/Dashboard/DashboardPage.swift @@ -18,7 +18,20 @@ public extension DashboardPage { .overview, .groups, ] - #if !tvOS + #if !os(tvOS) + if Variant.isBeta { + cases.append(.connections) + } + #endif + return cases + } + + static func enabledCases(hasGroups: Bool) -> [DashboardPage] { + var cases: [DashboardPage] = [.overview] + if hasGroups { + cases.append(.groups) + } + #if !os(tvOS) if Variant.isBeta { cases.append(.connections) } diff --git a/Localizable.xcstrings b/Localizable.xcstrings index af59df8..8ded7ba 100644 --- a/Localizable.xcstrings +++ b/Localizable.xcstrings @@ -348,6 +348,7 @@ } }, "Connections (%lld)" : { + "extractionState" : "stale", "localizations" : { "zh-Hans" : { "stringUnit" : { @@ -814,6 +815,7 @@ } }, "Groups (%lld)" : { + "extractionState" : "stale", "localizations" : { "zh-Hans" : { "stringUnit" : { @@ -1353,7 +1355,6 @@ } }, "Page" : { - "extractionState" : "stale", "localizations" : { "zh-Hans" : { "stringUnit" : {