diff --git a/Sources/BraveWallet/Crypto/CryptoTabsView.swift b/Sources/BraveWallet/Crypto/CryptoTabsView.swift index f0f5b3f643c..986017516ec 100644 --- a/Sources/BraveWallet/Crypto/CryptoTabsView.swift +++ b/Sources/BraveWallet/Crypto/CryptoTabsView.swift @@ -58,33 +58,7 @@ struct CryptoTabsView: View { ) .navigationTitle(Strings.Wallet.wallet) .navigationBarTitleDisplayMode(.inline) - .introspectViewController(customize: { vc in - vc.navigationItem.do { - // no shadow when content is at top. - let noShadowAppearance: UINavigationBarAppearance = { - let appearance = UINavigationBarAppearance() - appearance.configureWithOpaqueBackground() - appearance.titleTextAttributes = [.foregroundColor: UIColor.braveLabel] - appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.braveLabel] - appearance.backgroundColor = UIColor(braveSystemName: .pageBackground) - appearance.shadowColor = .clear - return appearance - }() - $0.scrollEdgeAppearance = noShadowAppearance - $0.compactScrollEdgeAppearance = noShadowAppearance - // shadow when content is scrolled behind navigation bar. - let shadowAppearance: UINavigationBarAppearance = { - let appearance = UINavigationBarAppearance() - appearance.configureWithOpaqueBackground() - appearance.titleTextAttributes = [.foregroundColor: UIColor.braveLabel] - appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.braveLabel] - appearance.backgroundColor = UIColor(braveSystemName: .pageBackground) - return appearance - }() - $0.standardAppearance = shadowAppearance - $0.compactAppearance = shadowAppearance - } - }) + .transparentUnlessScrolledNavigationAppearance() .toolbar { sharedToolbarItems } .background(settingsNavigationLink(for: .portfolio)) } @@ -243,23 +217,3 @@ struct CryptoTabsView: View { .hidden() } } - -private extension View { - func applyRegularNavigationAppearance() -> some View { - introspectViewController(customize: { vc in - vc.navigationItem.do { - let appearance: UINavigationBarAppearance = { - let appearance = UINavigationBarAppearance() - appearance.configureWithOpaqueBackground() - appearance.titleTextAttributes = [.foregroundColor: UIColor.braveLabel] - appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.braveLabel] - appearance.backgroundColor = .braveBackground - return appearance - }() - $0.standardAppearance = appearance - $0.compactAppearance = appearance - $0.scrollEdgeAppearance = appearance - } - }) - } -} diff --git a/Sources/BraveWallet/Crypto/Onboarding/RestoreWalletView.swift b/Sources/BraveWallet/Crypto/Onboarding/RestoreWalletView.swift index fbd12b2d671..dfdd91dd6d6 100644 --- a/Sources/BraveWallet/Crypto/Onboarding/RestoreWalletView.swift +++ b/Sources/BraveWallet/Crypto/Onboarding/RestoreWalletView.swift @@ -19,7 +19,7 @@ struct RestoreWalletContainerView: View { .background(Color(.braveBackground)) } .background(Color(.braveBackground).edgesIgnoringSafeArea(.all)) - .transparentNavigationBar(backButtonTitle: Strings.Wallet.restoreWalletBackButtonTitle, backButtonDisplayMode: .generic) + .transparentUnlessScrolledNavigationAppearance() } } diff --git a/Sources/BraveWallet/Crypto/Portfolio/PortfolioView.swift b/Sources/BraveWallet/Crypto/Portfolio/PortfolioView.swift index 645428a7bf2..55a803fc155 100644 --- a/Sources/BraveWallet/Crypto/Portfolio/PortfolioView.swift +++ b/Sources/BraveWallet/Crypto/Portfolio/PortfolioView.swift @@ -46,7 +46,7 @@ struct PortfolioView: View { VStack(spacing: 0) { Color(braveSystemName: .pageBackground) // top scroll rubberband area Color(braveSystemName: .containerBackground) // bottom drawer scroll rubberband area - }.edgesIgnoringSafeArea(.bottom) + }.edgesIgnoringSafeArea(.all) ) } diff --git a/Sources/BraveWallet/Crypto/UnlockWalletView.swift b/Sources/BraveWallet/Crypto/UnlockWalletView.swift index bce4960bbc2..024c55582ec 100644 --- a/Sources/BraveWallet/Crypto/UnlockWalletView.swift +++ b/Sources/BraveWallet/Crypto/UnlockWalletView.swift @@ -130,6 +130,7 @@ struct UnlockWalletView: View { } .navigationTitle(Strings.Wallet.cryptoTitle) .navigationBarTitleDisplayMode(.inline) + .transparentUnlessScrolledNavigationAppearance() .ignoresSafeArea(.keyboard, edges: .bottom) } diff --git a/Sources/BraveWallet/Extensions/ViewExtensions.swift b/Sources/BraveWallet/Extensions/ViewExtensions.swift index 908a84739d3..d7d48ad4207 100644 --- a/Sources/BraveWallet/Extensions/ViewExtensions.swift +++ b/Sources/BraveWallet/Extensions/ViewExtensions.swift @@ -16,6 +16,7 @@ extension View { self } } + /// This function will use the help from `introspectViewController` to find the /// containing `UIViewController` of the current SwiftUI view and configure its navigation /// bar appearance to be transparent. @@ -31,6 +32,53 @@ extension View { vc.navigationItem.backButtonDisplayMode = backButtonDisplayMode } } + + func applyRegularNavigationAppearance() -> some View { + introspectViewController(customize: { vc in + vc.navigationItem.do { + let appearance: UINavigationBarAppearance = { + let appearance = UINavigationBarAppearance() + appearance.configureWithOpaqueBackground() + appearance.titleTextAttributes = [.foregroundColor: UIColor.braveLabel] + appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.braveLabel] + appearance.backgroundColor = .braveBackground + return appearance + }() + $0.standardAppearance = appearance + $0.compactAppearance = appearance + $0.scrollEdgeAppearance = appearance + } + }) + } + + func transparentUnlessScrolledNavigationAppearance() -> some View { + introspectViewController(customize: { vc in + vc.navigationItem.do { + // no shadow when content is at top. + let noShadowAppearance: UINavigationBarAppearance = { + let appearance = UINavigationBarAppearance() + appearance.configureWithTransparentBackground() + appearance.titleTextAttributes = [.foregroundColor: UIColor.braveLabel] + appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.braveLabel] + appearance.backgroundColor = .clear + appearance.shadowColor = .clear + return appearance + }() + $0.scrollEdgeAppearance = noShadowAppearance + $0.compactScrollEdgeAppearance = noShadowAppearance + // shadow when content is scrolled behind navigation bar. + let shadowAppearance: UINavigationBarAppearance = { + let appearance = UINavigationBarAppearance() + appearance.configureWithOpaqueBackground() + appearance.titleTextAttributes = [.foregroundColor: UIColor.braveLabel] + appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.braveLabel] + return appearance + }() + $0.standardAppearance = shadowAppearance + $0.compactAppearance = shadowAppearance + } + }) + } func addAccount( keyringStore: KeyringStore,