Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Bitkit/Extensions/UINavigationController+SwipeBack.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import UIKit

/// Shared state for swipe-back gesture. Views can set this via the `.allowSwipeBack(_:)` modifier
/// to disable the gesture on screens that don't show a back button (e.g. SheetHeader without back).
enum SwipeBackState {
/// When false, the interactive pop gesture is disabled. Set by views that hide the back button.
static var allowSwipeBack: Bool = true
}

/// Re-enables the interactive swipe-back gesture when the navigation bar is hidden
/// (e.g. when using a custom NavigationBar with `.navigationBarHidden(true)`).
/// Without this, the system disables the gesture when the bar is hidden.
/// Use `.allowSwipeBack(false)` on views that don't show a back button to disable the gesture there.
extension UINavigationController: @retroactive UIGestureRecognizerDelegate {
override open func viewDidLoad() {
super.viewDidLoad()
interactivePopGestureRecognizer?.delegate = self
}

public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
// Only allow swipe-back when not at root — avoids iOS 17+ freeze when re-pushing after swiping to root
guard viewControllers.count > 1 else { return false }
return SwipeBackState.allowSwipeBack
}
}
21 changes: 21 additions & 0 deletions Bitkit/Extensions/View+AllowSwipeBack.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import SwiftUI

extension View {
/// Controls whether the interactive swipe-back gesture is enabled on this screen.
/// Use `.allowSwipeBack(false)` on screens that use a custom header without a back button
/// (e.g. `SheetHeader` with default `showBackButton: false`) so users can't swipe to dismiss.
/// Default is `true`; only apply this modifier when you want to disable the gesture.
func allowSwipeBack(_ allowed: Bool) -> some View {
modifier(AllowSwipeBackModifier(allowed: allowed))
}
}

private struct AllowSwipeBackModifier: ViewModifier {
let allowed: Bool

func body(content: Content) -> some View {
content
.onAppear { SwipeBackState.allowSwipeBack = allowed }
.onDisappear { SwipeBackState.allowSwipeBack = true }
}
}
1 change: 1 addition & 0 deletions Bitkit/Views/Backup/BackupMnemonic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ struct BackupMnemonicView: View {
.padding(.horizontal, 16)
}
.navigationBarHidden(true)
.allowSwipeBack(false)
.padding(.horizontal, 16)
.sheetBackground()
.frame(maxWidth: .infinity, maxHeight: .infinity)
Expand Down
2 changes: 1 addition & 1 deletion Bitkit/Views/Backup/BackupPassphrase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ struct BackupPassphrase: View {

var body: some View {
VStack(alignment: .leading, spacing: 0) {
SheetHeader(title: t("security__pass_your"))
SheetHeader(title: t("security__pass_your"), showBackButton: true)

VStack(spacing: 0) {
BodyMText(t("security__pass_text"))
Expand Down
1 change: 1 addition & 0 deletions Bitkit/Views/Gift/GiftError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct GiftFailed: View {
}
}
.navigationBarHidden(true)
.allowSwipeBack(false)
.padding(.horizontal, 16)
.sheetBackground()
.accessibilityIdentifier("GiftError")
Expand Down
1 change: 1 addition & 0 deletions Bitkit/Views/Gift/GiftUsed.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct GiftUsed: View {
}
}
.navigationBarHidden(true)
.allowSwipeBack(false)
.padding(.horizontal, 16)
.sheetBackground()
.accessibilityIdentifier("GiftUsed")
Expand Down
1 change: 1 addition & 0 deletions Bitkit/Views/Gift/GiftUsedUp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct GiftUsedUp: View {
}
}
.navigationBarHidden(true)
.allowSwipeBack(false)
.padding(.horizontal, 16)
.sheetBackground()
.accessibilityIdentifier("GiftUsedUp")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ struct SecurityBiometrics: View {
.padding(.horizontal, 16)
}
.navigationBarHidden(true)
.allowSwipeBack(false)
.padding(.horizontal, 16)
.sheetBackground()
.alert(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ struct SecurityPin: View {
}
}
.navigationBarHidden(true)
.allowSwipeBack(false)
.sheetBackground()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ struct SecuritySuccess: View {
.padding(.horizontal, 16)
}
.navigationBarHidden(true)
.allowSwipeBack(false)
.padding(.horizontal, 16)
.sheetBackground()
}
Expand Down
2 changes: 1 addition & 1 deletion Bitkit/Views/Transfer/FundManualSuccessView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct FundManualSuccessView: View {
.accessibilityIdentifier("ExternalSuccess")
}
.navigationBarHidden(true)
.interactiveDismissDisabled()
.allowSwipeBack(false)
.padding(.horizontal, 16)
}
}
Expand Down
4 changes: 2 additions & 2 deletions Bitkit/Views/Transfer/SavingsProgressView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct SavingsProgressContentView: View {

var body: some View {
VStack(alignment: .leading, spacing: 0) {
NavigationBar(title: navTitle)
NavigationBar(title: navTitle, showBackButton: false)
.padding(.bottom, 16)

DisplayText(title, accentColor: .brandAccent)
Expand Down Expand Up @@ -113,9 +113,9 @@ struct SavingsProgressContentView: View {
.accessibilityIdentifierIfPresent(progressState == .success ? "TransferSuccess-button" : nil)
}
.navigationBarHidden(true)
.allowSwipeBack(false)
.padding(.horizontal, 16)
.bottomSafeAreaPadding()
.interactiveDismissDisabled()
}
}

Expand Down
2 changes: 1 addition & 1 deletion Bitkit/Views/Transfer/SettingUpView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ struct SettingUpView: View {
}
}
.navigationBarHidden(true)
.allowSwipeBack(false)
.padding(.horizontal, 16)
.bottomSafeAreaPadding()
.interactiveDismissDisabled()
.onAppear {
Logger.debug("View appeared - TransferViewModel is handling order updates")

Expand Down
1 change: 1 addition & 0 deletions Bitkit/Views/Wallets/Send/SendFailure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct SendFailure: View {
.padding(.horizontal, 16)
}
.navigationBarHidden(true)
.allowSwipeBack(false)
.sheetBackground()
}
}
Expand Down
1 change: 1 addition & 0 deletions Bitkit/Views/Wallets/Send/SendPendingScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct SendPendingScreen: View {
}
}
.navigationBarHidden(true)
.allowSwipeBack(false)
.padding(.horizontal, 16)
.sheetBackground()
.frame(maxWidth: .infinity, maxHeight: .infinity)
Expand Down
1 change: 1 addition & 0 deletions Bitkit/Views/Wallets/Send/SendQuickpay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ struct SendQuickpay: View {
DisplayText(t("wallet__send_quickpay__title"), accentColor: .purpleAccent)
}
.navigationBarHidden(true)
.allowSwipeBack(false)
.padding(.horizontal, 16)
.sheetBackground()
.frame(maxWidth: .infinity, maxHeight: .infinity)
Expand Down
1 change: 1 addition & 0 deletions Bitkit/Views/Wallets/Send/SendSuccess.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ struct SendSuccess: View {
.padding(.horizontal, 16)
}
.navigationBarHidden(true)
.allowSwipeBack(false)
.sheetBackground()
}
.task {
Expand Down
Loading