Merge pull request #3778 from eviltofu/#3765_Remove_the_gray_line_under_nav_bar_in_all_ERC20,_ERC721,_ERC1155_tokens

Fixed show/hide navigationBarTopSeparatorLine functions, removed gray line under navigation bar of TokensCardViewController, consolidated UINavigationBar appearance code in applyStyle function #3765
pull/3797/head
Jerome Chan 3 years ago committed by GitHub
commit c2bffdb58b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      AlphaWallet/Style/AppStyle.swift
  2. 2
      AlphaWallet/Tokens/Collectibles/ViewControllers/TokensCardCollectionViewController.swift
  3. 2
      AlphaWallet/Tokens/ViewControllers/TokensCardViewController.swift
  4. 20
      AlphaWallet/Wallet/ViewControllers/SeedPhraseBackupIntroductionViewController.swift

@ -9,23 +9,12 @@ func applyStyle() {
UITabBar.appearance().tintColor = Colors.appTint
UITabBar.appearance().shadowImage = UIImage(color: Style.TabBar.Separator.color, size: CGSize(width: 0.25, height: 0.25))
UITabBar.appearance().backgroundImage = UIImage(color: Style.TabBar.Background.color)
UINavigationBar.appearance().barTintColor = R.color.white()!
UINavigationBar.appearance().backIndicatorImage = R.image.backWhite()
UINavigationBar.appearance().backIndicatorTransitionMaskImage = R.image.backWhite()
UINavigationBar.appearance().titleTextAttributes = [
.foregroundColor: Colors.navigationTitleColor,
.font: Fonts.semibold(size: 17) as Any
]
UINavigationBar.appearance().largeTitleTextAttributes = [
.foregroundColor: Colors.navigationTitleColor,
.font: Fonts.bold(size: 36) as Any,
]
UINavigationBar.appearance().shadowImage = UIImage(color: Style.NavigationBar.Separator.color, size: CGSize(width: 0.25, height: 0.25))
// NOTE: Fixes iOS 15 navigation bar black background
if #available(iOS 15.0, *) {
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = R.color.white()!
appearance.shadowColor = Style.NavigationBar.Separator.color
appearance.shadowImage = nil
appearance.setBackIndicatorImage(R.image.backWhite(), transitionMaskImage: R.image.backWhite())
appearance.titleTextAttributes = [
.foregroundColor: R.color.black()!,
@ -35,13 +24,10 @@ func applyStyle() {
.foregroundColor: R.color.black()!,
.font: Fonts.bold(size: 36) as Any,
]
UINavigationBar.appearance().compactAppearance = appearance
UINavigationBar.appearance().standardAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
} else {
// Fallback on earlier versions
}
if #available(iOS 13.0, *) {
//NOTE: Hides back button text
let titleTextAttributes: [NSAttributedString.Key: Any] = [
.foregroundColor: UIColor.clear
@ -49,9 +35,6 @@ func applyStyle() {
UINavigationBar.appearance().standardAppearance.backButtonAppearance.normal.titleTextAttributes = titleTextAttributes
UINavigationBar.appearance().compactAppearance?.backButtonAppearance.normal.titleTextAttributes = titleTextAttributes
UINavigationBar.appearance().scrollEdgeAppearance?.backButtonAppearance.normal.titleTextAttributes = titleTextAttributes
} else {
// Fallback on earlier versions
}
//We could have set the backBarButtonItem with an empty title for every view controller, but we don't have a place to do it for Eureka view controllers. Using appearance here, while a hack is still more convenient though, since we don't have to do it for every view controller instance
UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffset(horizontal: -200, vertical: 0), for: .default)

@ -121,11 +121,13 @@ class TokensCardCollectionViewController: UIViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
keyboardChecker.viewWillAppear()
hideNavigationBarTopSeparatorLine()
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
keyboardChecker.viewWillDisappear()
showNavigationBarTopSeparatorLine()
}
func configure(viewModel value: TokensCardCollectionViewControllerViewModel? = .none) {

@ -107,11 +107,13 @@ class TokensCardViewController: UIViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
keyboardChecker.viewWillAppear()
hideNavigationBarTopSeparatorLine()
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
keyboardChecker.viewWillDisappear()
showNavigationBarTopSeparatorLine()
}
override func viewDidLoad() {

@ -106,14 +106,22 @@ class SeedPhraseBackupIntroductionViewController: UIViewController {
extension UIViewController {
func hideNavigationBarTopSeparatorLine() {
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationController?.navigationBar.shadowImage = UIImage()
navigationController?.navigationBar.layoutIfNeeded()
guard let navigationBar = navigationController?.navigationBar else { return }
let appearance = navigationBar.standardAppearance
appearance.shadowColor = .clear
appearance.shadowImage = nil
navigationBar.scrollEdgeAppearance = appearance
navigationBar.compactAppearance = appearance
navigationBar.standardAppearance = appearance
}
func showNavigationBarTopSeparatorLine() {
navigationController?.navigationBar.setBackgroundImage(nil, for: .default)
navigationController?.navigationBar.shadowImage = nil
navigationController?.navigationBar.layoutIfNeeded()
guard let navigationBar = navigationController?.navigationBar else { return }
let appearance = navigationBar.standardAppearance
appearance.shadowColor = Style.NavigationBar.Separator.color
appearance.shadowImage = nil
navigationBar.scrollEdgeAppearance = appearance
navigationBar.compactAppearance = appearance
navigationBar.standardAppearance = appearance
}
}

Loading…
Cancel
Save