Refactor hidden navlinks and send behind in ZStack
This commit is contained in:
parent
2432f0d97a
commit
b37ff03e4b
|
@ -54,6 +54,7 @@ struct AddHostView: View {
|
|||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
hiddenAccountLink
|
||||
List {
|
||||
if viewModel.processedProfile.isPlaceholder {
|
||||
processingView
|
||||
|
@ -61,14 +62,6 @@ struct AddHostView: View {
|
|||
completeView
|
||||
}
|
||||
}.animation(.default, value: viewModel)
|
||||
|
||||
// hidden
|
||||
NavigationLink("", isActive: $isEnteringCredentials) {
|
||||
AddProfileView.AccountWrapperView(
|
||||
profile: $viewModel.processedProfile,
|
||||
bindings: bindings
|
||||
)
|
||||
}
|
||||
}.toolbar {
|
||||
themeCloseItem(isPresented: bindings.$isPresented)
|
||||
ToolbarItem(placement: .primaryAction) {
|
||||
|
@ -133,6 +126,15 @@ struct AddHostView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var hiddenAccountLink: some View {
|
||||
NavigationLink("", isActive: $isEnteringCredentials) {
|
||||
AddProfileView.AccountWrapperView(
|
||||
profile: $viewModel.processedProfile,
|
||||
bindings: bindings
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private var nextString: String {
|
||||
if !viewModel.processedProfile.isPlaceholder {
|
||||
|
|
|
@ -53,6 +53,7 @@ extension AddProviderView {
|
|||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
hiddenAccountLink
|
||||
List {
|
||||
AddProfileView.ProfileNameSection(
|
||||
profileName: $viewModel.profileName,
|
||||
|
@ -70,14 +71,6 @@ extension AddProviderView {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
// hidden
|
||||
NavigationLink("", isActive: $isEnteringCredentials) {
|
||||
AddProfileView.AccountWrapperView(
|
||||
profile: $profile,
|
||||
bindings: bindings
|
||||
)
|
||||
}
|
||||
}.toolbar {
|
||||
Button {
|
||||
saveProfile(replacingExisting: false)
|
||||
|
@ -87,6 +80,15 @@ extension AddProviderView {
|
|||
}.alert(isPresented: $viewModel.isAskingOverwrite, content: alertOverwriteExistingProfile)
|
||||
.navigationTitle(providerMetadata.fullName)
|
||||
}
|
||||
|
||||
private var hiddenAccountLink: some View {
|
||||
NavigationLink("", isActive: $isEnteringCredentials) {
|
||||
AddProfileView.AccountWrapperView(
|
||||
profile: $profile,
|
||||
bindings: bindings
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private func alertOverwriteExistingProfile() -> Alert {
|
||||
return Alert(
|
||||
|
|
|
@ -74,6 +74,7 @@ struct AddProviderView: View {
|
|||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
ForEach(providers, id: \.navigationId, content: hiddenProviderLink)
|
||||
ScrollViewReader { scrollProxy in
|
||||
List {
|
||||
mainSection
|
||||
|
@ -85,9 +86,6 @@ struct AddProviderView: View {
|
|||
}.disabled(viewModel.pendingOperation != nil)
|
||||
.animation(.default, value: providers)
|
||||
}
|
||||
|
||||
// hidden
|
||||
ForEach(providers, id: \.navigationId, content: providerNavigationLink)
|
||||
}.toolbar {
|
||||
themeCloseItem(isPresented: bindings.$isPresented)
|
||||
}.sheet(isPresented: $viewModel.isPaywallPresented) {
|
||||
|
@ -131,7 +129,7 @@ struct AddProviderView: View {
|
|||
}.withTrailingProgress(when: isFetchingProvider(metadata.name))
|
||||
}
|
||||
|
||||
private func providerNavigationLink(_ metadata: ProviderMetadata) -> some View {
|
||||
private func hiddenProviderLink(_ metadata: ProviderMetadata) -> some View {
|
||||
NavigationLink("", tag: metadata, selection: $viewModel.selectedProvider) {
|
||||
NameView(
|
||||
profile: $viewModel.pendingProfile,
|
||||
|
|
|
@ -54,10 +54,7 @@ extension OrganizerView {
|
|||
var body: some View {
|
||||
debugChanges()
|
||||
return ZStack {
|
||||
NavigationLink("", isActive: $isPresentingProfile) {
|
||||
ProfileView()
|
||||
}.onAppear(perform: presentActiveProfile)
|
||||
|
||||
hiddenProfileLink
|
||||
mainView
|
||||
if profileManager.headers.isEmpty {
|
||||
emptyView
|
||||
|
@ -89,7 +86,7 @@ extension OrganizerView {
|
|||
.themeInformativeText()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private func profileButton(forHeader header: Profile.Header) -> some View {
|
||||
Button {
|
||||
presentProfile(withId: header.id)
|
||||
|
@ -100,6 +97,12 @@ extension OrganizerView {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
private var hiddenProfileLink: some View {
|
||||
NavigationLink("", isActive: $isPresentingProfile) {
|
||||
ProfileView()
|
||||
}.onAppear(perform: presentActiveProfile)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ extension ShortcutsView {
|
|||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
hiddenProviderLocationLink
|
||||
List {
|
||||
Section(
|
||||
header: Text(Unlocalized.VPN.vpn)
|
||||
|
@ -68,8 +69,6 @@ extension ShortcutsView {
|
|||
Button(L10n.Shortcuts.Add.Items.UntrustCellular.caption, action: addUntrustCellular)
|
||||
}
|
||||
}
|
||||
|
||||
providerLocationLink
|
||||
}.navigationTitle(L10n.Shortcuts.Add.title)
|
||||
}
|
||||
|
||||
|
@ -84,7 +83,7 @@ extension ShortcutsView {
|
|||
}
|
||||
}
|
||||
|
||||
private var providerLocationLink: some View {
|
||||
private var hiddenProviderLocationLink: some View {
|
||||
NavigationLink("", isActive: $isPresentingProviderLocation) {
|
||||
ProviderLocationView(
|
||||
currentProfile: pendingProfile,
|
||||
|
|
Loading…
Reference in New Issue