TV not presenting interactive login on "Connect" (#817)

The side panel was not shown when interactive login was triggered by the
active profile on "Connect".
This commit is contained in:
Davide 2024-11-05 16:13:03 +01:00 committed by GitHub
parent 9286ead348
commit 9351ceeb6a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 7 deletions

View File

@ -50,7 +50,7 @@ struct ProfileView: View, TunnelInstallationProviding {
var tunnel: ExtendedTunnel var tunnel: ExtendedTunnel
@State @State
private var isSwitching = false private var showsSidePanel = false
@FocusState @FocusState
private var focusedField: Field? private var focusedField: Field?
@ -73,7 +73,7 @@ struct ProfileView: View, TunnelInstallationProviding {
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.disabled(interactiveManager.isPresented) .disabled(interactiveManager.isPresented)
if isSwitching { if showsSidePanel {
ZStack { ZStack {
listView listView
.padding(.horizontal) .padding(.horizontal)
@ -91,12 +91,12 @@ struct ProfileView: View, TunnelInstallationProviding {
} }
.ignoresSafeArea(edges: .horizontal) .ignoresSafeArea(edges: .horizontal)
.background(theme.primaryColor.gradient) .background(theme.primaryColor.gradient)
.themeAnimation(on: isSwitching, category: .profiles) .themeAnimation(on: showsSidePanel, category: .profiles)
.withErrorHandler(errorHandler) .withErrorHandler(errorHandler)
.defaultFocus($focusedField, .switchProfile) .defaultFocus($focusedField, .switchProfile)
.onChange(of: tunnel.status) { _, new in .onChange(of: tunnel.status) { _, new in
if new == .activating { if new == .activating {
isSwitching = false showsSidePanel = false
focusedField = .connect focusedField = .connect
} }
} }
@ -105,13 +105,18 @@ struct ProfileView: View, TunnelInstallationProviding {
focusedField = .switchProfile focusedField = .switchProfile
} }
} }
.onChange(of: interactiveManager.isPresented) { _, new in
if new {
showsSidePanel = true
}
}
.onChange(of: focusedField) { _, new in .onChange(of: focusedField) { _, new in
switch new { switch new {
case .connect: case .connect:
isSwitching = false showsSidePanel = false
case .switchProfile: case .switchProfile:
isSwitching = true showsSidePanel = true
default: default:
break break
@ -132,7 +137,7 @@ private extension ProfileView {
ActiveProfileView( ActiveProfileView(
profile: currentProfile, profile: currentProfile,
tunnel: tunnel, tunnel: tunnel,
isSwitching: $isSwitching, isSwitching: $showsSidePanel,
focusedField: $focusedField, focusedField: $focusedField,
interactiveManager: interactiveManager, interactiveManager: interactiveManager,
errorHandler: errorHandler errorHandler: errorHandler