Fix Overview flicker on legacy iOS
This commit is contained in:
@@ -8,19 +8,19 @@ import SwiftUI
|
|||||||
@EnvironmentObject private var environments: ExtensionEnvironments
|
@EnvironmentObject private var environments: ExtensionEnvironments
|
||||||
@EnvironmentObject private var profile: ExtensionProfile
|
@EnvironmentObject private var profile: ExtensionProfile
|
||||||
@ObservedObject private var coordinator: DashboardViewModel
|
@ObservedObject private var coordinator: DashboardViewModel
|
||||||
@State private var cardConfigurationVersion = 0
|
@StateObject private var cardConfiguration = DashboardCardConfiguration()
|
||||||
#if os(iOS) || os(tvOS)
|
#if os(iOS) || os(tvOS)
|
||||||
@State private var showCardManagement = false
|
@State private var showCardManagement = false
|
||||||
@State private var showGroups = false
|
@State private var showGroups = false
|
||||||
@State private var showConnections = false
|
@State private var showConnections = false
|
||||||
@State private var buttonState = ButtonVisibilityState()
|
@State private var buttonState = ButtonVisibilityState()
|
||||||
#endif
|
#endif
|
||||||
|
#if os(macOS)
|
||||||
|
@Environment(\.cardConfigurationVersion) private var cardConfigurationVersion
|
||||||
|
#endif
|
||||||
|
|
||||||
private let externalCardConfigurationVersion: Int?
|
public init(coordinator: DashboardViewModel) {
|
||||||
|
|
||||||
public init(coordinator: DashboardViewModel, externalCardConfigurationVersion: Int? = nil) {
|
|
||||||
_coordinator = ObservedObject(wrappedValue: coordinator)
|
_coordinator = ObservedObject(wrappedValue: coordinator)
|
||||||
self.externalCardConfigurationVersion = externalCardConfigurationVersion
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public var body: some View {
|
public var body: some View {
|
||||||
@@ -100,7 +100,7 @@ import SwiftUI
|
|||||||
}
|
}
|
||||||
.navigationDestination(isPresented: $showCardManagement) {
|
.navigationDestination(isPresented: $showCardManagement) {
|
||||||
CardManagementView(onDisappear: {
|
CardManagementView(onDisappear: {
|
||||||
cardConfigurationVersion += 1
|
Task { await cardConfiguration.reload() }
|
||||||
})
|
})
|
||||||
.navigationTitle("Dashboard Items")
|
.navigationTitle("Dashboard Items")
|
||||||
.toolbar {
|
.toolbar {
|
||||||
@@ -115,7 +115,7 @@ import SwiftUI
|
|||||||
}.sheet(isPresented: $showConnections) {
|
}.sheet(isPresented: $showConnections) {
|
||||||
connectionsSheetContent
|
connectionsSheetContent
|
||||||
}.sheet(isPresented: $showCardManagement, onDismiss: {
|
}.sheet(isPresented: $showCardManagement, onDismiss: {
|
||||||
cardConfigurationVersion += 1
|
Task { await cardConfiguration.reload() }
|
||||||
}, content: {
|
}, content: {
|
||||||
if #available(iOS 16.0, *) {
|
if #available(iOS 16.0, *) {
|
||||||
CardManagementSheet().presentationDetents([.large]).presentationDragIndicator(.visible)
|
CardManagementSheet().presentationDetents([.large]).presentationDragIndicator(.visible)
|
||||||
@@ -174,6 +174,11 @@ import SwiftUI
|
|||||||
updateButtonVisibility()
|
updateButtonVisibility()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if os(macOS)
|
||||||
|
.onChangeCompat(of: cardConfigurationVersion) { _ in
|
||||||
|
Task { await cardConfiguration.reload() }
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder private var overviewPage: some View {
|
@ViewBuilder private var overviewPage: some View {
|
||||||
@@ -182,7 +187,7 @@ import SwiftUI
|
|||||||
$coordinator.selectedProfileID,
|
$coordinator.selectedProfileID,
|
||||||
$coordinator.systemProxyAvailable,
|
$coordinator.systemProxyAvailable,
|
||||||
$coordinator.systemProxyEnabled,
|
$coordinator.systemProxyEnabled,
|
||||||
cardConfigurationVersion: externalCardConfigurationVersion ?? cardConfigurationVersion
|
cardConfiguration: cardConfiguration
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,7 +233,7 @@ import SwiftUI
|
|||||||
$coordinator.selectedProfileID,
|
$coordinator.selectedProfileID,
|
||||||
$coordinator.systemProxyAvailable,
|
$coordinator.systemProxyAvailable,
|
||||||
$coordinator.systemProxyEnabled,
|
$coordinator.systemProxyEnabled,
|
||||||
externalCardConfigurationVersion ?? cardConfigurationVersion
|
cardConfiguration
|
||||||
)
|
)
|
||||||
.tag(page)
|
.tag(page)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,11 +64,11 @@ public extension DashboardPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
func contentView(_ profileList: Binding<[ProfilePreview]>, _ selectedProfileID: Binding<Int64>, _ systemProxyAvailable: Binding<Bool>, _ systemProxyEnabled: Binding<Bool>, _ cardConfigurationVersion: Int) -> some View {
|
func contentView(_ profileList: Binding<[ProfilePreview]>, _ selectedProfileID: Binding<Int64>, _ systemProxyAvailable: Binding<Bool>, _ systemProxyEnabled: Binding<Bool>, _ cardConfiguration: DashboardCardConfiguration) -> some View {
|
||||||
Group {
|
Group {
|
||||||
switch self {
|
switch self {
|
||||||
case .overview:
|
case .overview:
|
||||||
OverviewView(profileList, selectedProfileID, systemProxyAvailable, systemProxyEnabled, cardConfigurationVersion: cardConfigurationVersion)
|
OverviewView(profileList, selectedProfileID, systemProxyAvailable, systemProxyEnabled, cardConfiguration: cardConfiguration)
|
||||||
case .groups:
|
case .groups:
|
||||||
GroupListView()
|
GroupListView()
|
||||||
case .connections:
|
case .connections:
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import SwiftUI
|
|||||||
@MainActor
|
@MainActor
|
||||||
public struct DashboardView: View {
|
public struct DashboardView: View {
|
||||||
@Environment(\.openURL) private var openURL
|
@Environment(\.openURL) private var openURL
|
||||||
@Environment(\.cardConfigurationVersion) private var cardConfigurationVersion
|
|
||||||
@Environment(\.importProfile) private var importProfile
|
@Environment(\.importProfile) private var importProfile
|
||||||
@Environment(\.importRemoteProfile) private var importRemoteProfile
|
@Environment(\.importRemoteProfile) private var importRemoteProfile
|
||||||
@EnvironmentObject private var environments: ExtensionEnvironments
|
@EnvironmentObject private var environments: ExtensionEnvironments
|
||||||
@@ -148,10 +147,6 @@ public struct DashboardView: View {
|
|||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private var activeDashboardView: some View {
|
private var activeDashboardView: some View {
|
||||||
#if os(macOS)
|
|
||||||
ActiveDashboardView(coordinator: coordinator, externalCardConfigurationVersion: cardConfigurationVersion)
|
|
||||||
#else
|
|
||||||
ActiveDashboardView(coordinator: coordinator)
|
ActiveDashboardView(coordinator: coordinator)
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,26 +8,25 @@ public struct OverviewView: View {
|
|||||||
@EnvironmentObject private var environments: ExtensionEnvironments
|
@EnvironmentObject private var environments: ExtensionEnvironments
|
||||||
@EnvironmentObject private var profile: ExtensionProfile
|
@EnvironmentObject private var profile: ExtensionProfile
|
||||||
@StateObject private var coordinator = OverviewViewModel()
|
@StateObject private var coordinator = OverviewViewModel()
|
||||||
@StateObject private var configuration = DashboardCardConfiguration()
|
@ObservedObject private var configuration: DashboardCardConfiguration
|
||||||
|
|
||||||
@Binding private var profileList: [ProfilePreview]
|
@Binding private var profileList: [ProfilePreview]
|
||||||
@Binding private var selectedProfileID: Int64
|
@Binding private var selectedProfileID: Int64
|
||||||
@Binding private var systemProxyAvailable: Bool
|
@Binding private var systemProxyAvailable: Bool
|
||||||
@Binding private var systemProxyEnabled: Bool
|
@Binding private var systemProxyEnabled: Bool
|
||||||
private let cardConfigurationVersion: Int
|
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
_ profileList: Binding<[ProfilePreview]>,
|
_ profileList: Binding<[ProfilePreview]>,
|
||||||
_ selectedProfileID: Binding<Int64>,
|
_ selectedProfileID: Binding<Int64>,
|
||||||
_ systemProxyAvailable: Binding<Bool>,
|
_ systemProxyAvailable: Binding<Bool>,
|
||||||
_ systemProxyEnabled: Binding<Bool>,
|
_ systemProxyEnabled: Binding<Bool>,
|
||||||
cardConfigurationVersion: Int
|
cardConfiguration: DashboardCardConfiguration
|
||||||
) {
|
) {
|
||||||
_profileList = profileList
|
_profileList = profileList
|
||||||
_selectedProfileID = selectedProfileID
|
_selectedProfileID = selectedProfileID
|
||||||
_systemProxyAvailable = systemProxyAvailable
|
_systemProxyAvailable = systemProxyAvailable
|
||||||
_systemProxyEnabled = systemProxyEnabled
|
_systemProxyEnabled = systemProxyEnabled
|
||||||
self.cardConfigurationVersion = cardConfigurationVersion
|
_configuration = ObservedObject(wrappedValue: cardConfiguration)
|
||||||
}
|
}
|
||||||
|
|
||||||
public var body: some View {
|
public var body: some View {
|
||||||
@@ -41,9 +40,6 @@ public struct OverviewView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onChangeCompat(of: cardConfigurationVersion) { _ in
|
|
||||||
Task { await configuration.reload() }
|
|
||||||
}
|
|
||||||
.alert($coordinator.alert)
|
.alert($coordinator.alert)
|
||||||
.disabled(!ApplicationLibrary.inPreview && (!profile.status.isSwitchable || coordinator.reasserting))
|
.disabled(!ApplicationLibrary.inPreview && (!profile.status.isSwitchable || coordinator.reasserting))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user