From 03eb1db77ec890b41c68084239eee7cc3135e986 Mon Sep 17 00:00:00 2001 From: Bruno Muniz Azevedo Filho <bruno@elixxir.io> Date: Thu, 11 Aug 2022 15:32:02 -0300 Subject: [PATCH] Fixed navigation bar across the app --- .../Controllers/BackupController.swift | 22 ++++++++---------- .../Controllers/GroupChatController.swift | 8 ------- .../Controllers/SingleChatController.swift | 13 +---------- .../Controller/ChatListController.swift | 8 ++++++- .../Controllers/ContactController.swift | 14 +---------- .../Controllers/CreateGroupController.swift | 23 +++++++++---------- Sources/Countries/CountryListController.swift | 15 +++--------- ...nboardingEmailConfirmationController.swift | 14 +---------- ...nboardingPhoneConfirmationController.swift | 14 +---------- .../OnboardingUsernameController.swift | 3 +-- .../RequestPermissionController.swift | 13 +---------- .../Controllers/ProfileCodeController.swift | 14 +---------- .../Controllers/ProfileEmailController.swift | 14 +---------- .../Controllers/ProfilePhoneController.swift | 16 ++----------- .../Controllers/RestoreController.swift | 16 ++++++------- .../Controllers/RestoreListController.swift | 16 +------------ Sources/SFTPFeature/SFTPController.swift | 22 +++++------------- .../SearchContainerController.swift | 23 ++++++------------- .../Controllers/AccountDeleteController.swift | 11 --------- .../SettingsAdvancedController.swift | 15 +++--------- .../TermsConditionsController.swift | 1 + 21 files changed, 66 insertions(+), 229 deletions(-) diff --git a/Sources/BackupFeature/Controllers/BackupController.swift b/Sources/BackupFeature/Controllers/BackupController.swift index a9942d8c..822ebbc7 100644 --- a/Sources/BackupFeature/Controllers/BackupController.swift +++ b/Sources/BackupFeature/Controllers/BackupController.swift @@ -11,6 +11,13 @@ public final class BackupController: UIViewController { private let viewModel = BackupViewModel.live() private var cancellables = Set<AnyCancellable>() + public override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + navigationItem.backButtonTitle = "" + navigationController?.navigationBar + .customize(backgroundColor: Asset.neutralWhite.color) + } + public override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = Asset.neutralWhite.color @@ -21,19 +28,12 @@ public final class BackupController: UIViewController { } private func setupNavigationBar() { - navigationItem.backButtonTitle = "" - let title = UILabel() title.text = Localized.Backup.header title.textColor = Asset.neutralActive.color title.font = Fonts.Mulish.semiBold.font(size: 18.0) - - let back = UIButton.back() - back.addTarget(self, action: #selector(didTapBack), for: .touchUpInside) - - navigationItem.leftBarButtonItem = UIBarButtonItem( - customView: UIStackView(arrangedSubviews: [back, title]) - ) + navigationItem.leftBarButtonItem = UIBarButtonItem(customView: title) + navigationItem.leftItemsSupplementBackButton = true } private func setupBindings() { @@ -70,8 +70,4 @@ public final class BackupController: UIViewController { } } } - - @objc private func didTapBack() { - navigationController?.popViewController(animated: true) - } } diff --git a/Sources/ChatFeature/Controllers/GroupChatController.swift b/Sources/ChatFeature/Controllers/GroupChatController.swift index b168e70c..24117868 100644 --- a/Sources/ChatFeature/Controllers/GroupChatController.swift +++ b/Sources/ChatFeature/Controllers/GroupChatController.swift @@ -122,14 +122,10 @@ public final class GroupChatController: UIViewController { } private func setupNavigationBar() { - let back = UIButton.back() - back.addTarget(self, action: #selector(didTapBack), for: .touchUpInside) - let more = UIButton() more.setImage(Asset.chatMore.image, for: .normal) more.addTarget(self, action: #selector(didTapDots), for: .touchUpInside) - navigationItem.leftBarButtonItem = UIBarButtonItem(customView: back) navigationItem.titleView = header navigationItem.rightBarButtonItem = UIBarButtonItem(customView: more) } @@ -229,10 +225,6 @@ public final class GroupChatController: UIViewController { .store(in: &cancellables) } - @objc private func didTapBack() { - navigationController?.popViewController(animated: true) - } - @objc private func didTapDots() { coordinator.toMembersList(members, from: self) } diff --git a/Sources/ChatFeature/Controllers/SingleChatController.swift b/Sources/ChatFeature/Controllers/SingleChatController.swift index f34be438..d1d7785a 100644 --- a/Sources/ChatFeature/Controllers/SingleChatController.swift +++ b/Sources/ChatFeature/Controllers/SingleChatController.swift @@ -35,7 +35,6 @@ public final class SingleChatController: UIViewController { lazy private var avatarView = AvatarView() lazy private var moreButton = UIButton() - lazy private var backButton = UIButton.back() lazy private var screenView = ChatView() lazy private var sheet = SheetController() @@ -168,8 +167,6 @@ public final class SingleChatController: UIViewController { nameLabel.textColor = Asset.neutralActive.color nameLabel.font = Fonts.Mulish.semiBold.font(size: 18.0) - backButton.addTarget(self, action: #selector(didTapBack), for: .touchUpInside) - moreButton.setImage(Asset.chatMore.image, for: .normal) moreButton.addTarget(self, action: #selector(didTapDots), for: .touchUpInside) @@ -188,12 +185,8 @@ public final class SingleChatController: UIViewController { $0.right.lessThanOrEqualToSuperview() } - let stackView = UIStackView() - stackView.addArrangedSubview(backButton) - stackView.addArrangedSubview(infoView) - navigationItem.rightBarButtonItem = UIBarButtonItem(customView: moreButton) - navigationItem.leftBarButtonItem = UIBarButtonItem(customView: stackView) + navigationItem.leftBarButtonItem = UIBarButtonItem(customView: infoView) } private func setupInputController() { @@ -462,10 +455,6 @@ public final class SingleChatController: UIViewController { @objc private func didTapInfo() { coordinator.toContact(viewModel.contact, from: self) } - - @objc private func didTapBack() { - navigationController?.popViewController(animated: true) - } } extension SingleChatController: UICollectionViewDataSource { diff --git a/Sources/ChatListFeature/Controller/ChatListController.swift b/Sources/ChatListFeature/Controller/ChatListController.swift index bddccd28..57e744a3 100644 --- a/Sources/ChatListFeature/Controller/ChatListController.swift +++ b/Sources/ChatListFeature/Controller/ChatListController.swift @@ -36,6 +36,13 @@ public final class ChatListController: UIViewController { } } + public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { + super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) + navigationItem.backButtonTitle = "" + } + + required init?(coder: NSCoder) { nil } + public override func loadView() { view = screenView } @@ -55,7 +62,6 @@ public final class ChatListController: UIViewController { } private func setupNavigationBar() { - navigationItem.backButtonTitle = "" navigationItem.leftBarButtonItem = UIBarButtonItem(customView: topLeftView) navigationItem.rightBarButtonItem = UIBarButtonItem(customView: topRightView) diff --git a/Sources/ContactFeature/Controllers/ContactController.swift b/Sources/ContactFeature/Controllers/ContactController.swift index 02859bab..c583654e 100644 --- a/Sources/ContactFeature/Controllers/ContactController.swift +++ b/Sources/ContactFeature/Controllers/ContactController.swift @@ -30,6 +30,7 @@ public final class ContactController: UIViewController { public override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + navigationItem.backButtonTitle = "" statusBarController.style.send(.lightContent) navigationController?.navigationBar .customize(backgroundColor: Asset.neutralBody.color) @@ -43,7 +44,6 @@ public final class ContactController: UIViewController { public override func viewDidLoad() { super.viewDidLoad() - setupNavigationBar() setupScrollView() setupBindings() @@ -62,14 +62,6 @@ public final class ContactController: UIViewController { screenView.set(status: viewModel.contact.authStatus) } - private func setupNavigationBar() { - navigationItem.backButtonTitle = "" - - let back = UIButton.back(color: Asset.neutralWhite.color) - back.addTarget(self, action: #selector(didTapBack), for: .touchUpInside) - navigationItem.leftBarButtonItem = UIBarButtonItem(customView: back) - } - private func setupScrollView() { addChild(scrollViewController) view.addSubview(scrollViewController.view) @@ -333,10 +325,6 @@ public final class ContactController: UIViewController { coordinator.toDrawer(drawer, from: self) } - - @objc private func didTapBack() { - navigationController?.popViewController(animated: true) - } } extension ContactController: UIImagePickerControllerDelegate { diff --git a/Sources/ContactListFeature/Controllers/CreateGroupController.swift b/Sources/ContactListFeature/Controllers/CreateGroupController.swift index a9559f5c..e55860fc 100644 --- a/Sources/ContactListFeature/Controllers/CreateGroupController.swift +++ b/Sources/ContactListFeature/Controllers/CreateGroupController.swift @@ -40,22 +40,25 @@ public final class CreateGroupController: UIViewController { view = screenView } + public override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + navigationItem.backButtonTitle = "" + navigationController?.navigationBar + .customize(backgroundColor: Asset.neutralWhite.color) + } + public override func viewDidLoad() { super.viewDidLoad() setupNavigationBar() setupTableAndCollection() setupBindings() + + count = 0 } private func setupNavigationBar() { - navigationItem.backButtonTitle = " " - - let back = UIButton.back() - back.addTarget(self, action: #selector(didTapBack), for: .touchUpInside) - - navigationItem.leftBarButtonItem = UIBarButtonItem( - customView: UIStackView(arrangedSubviews: [back, titleLabel]) - ) + navigationItem.leftBarButtonItem = UIBarButtonItem(customView: titleLabel) + navigationItem.leftItemsSupplementBackButton = true createButton.setTitle(Localized.CreateGroup.create, for: .normal) createButton.setTitleColor(Asset.brandPrimary.color, for: .normal) @@ -166,10 +169,6 @@ public final class CreateGroupController: UIViewController { ) }.store(in: &cancellables) } - - @objc private func didTapBack() { - navigationController?.popViewController(animated: true) - } } extension CreateGroupController: UITableViewDelegate { diff --git a/Sources/Countries/CountryListController.swift b/Sources/Countries/CountryListController.swift index ab7ca357..a11c0e57 100644 --- a/Sources/Countries/CountryListController.swift +++ b/Sources/Countries/CountryListController.swift @@ -24,6 +24,7 @@ public final class CountryListController: UIViewController { public override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + navigationItem.backButtonTitle = "" statusBarController.style.send(.darkContent) navigationController?.navigationBar.customize( @@ -46,19 +47,13 @@ public final class CountryListController: UIViewController { } private func setupNavigationBar() { - navigationItem.backButtonTitle = " " - let title = UILabel() title.text = Localized.Countries.title title.textColor = Asset.neutralActive.color title.font = Fonts.Mulish.semiBold.font(size: 18.0) - let back = UIButton.back() - back.addTarget(self, action: #selector(didTapBack), for: .touchUpInside) - - navigationItem.leftBarButtonItem = UIBarButtonItem( - customView: UIStackView(arrangedSubviews: [back, title]) - ) + navigationItem.leftBarButtonItem = UIBarButtonItem(customView: title) + navigationItem.leftItemsSupplementBackButton = true } private func setupBindings() { @@ -86,10 +81,6 @@ public final class CountryListController: UIViewController { screenView.tableView.delegate = self screenView.tableView.dataSource = dataSource } - - @objc private func didTapBack() { - navigationController?.popViewController(animated: true) - } public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { if let country = dataSource.itemIdentifier(for: indexPath) { diff --git a/Sources/OnboardingFeature/Controllers/OnboardingEmailConfirmationController.swift b/Sources/OnboardingFeature/Controllers/OnboardingEmailConfirmationController.swift index 90c21056..578a27dc 100644 --- a/Sources/OnboardingFeature/Controllers/OnboardingEmailConfirmationController.swift +++ b/Sources/OnboardingFeature/Controllers/OnboardingEmailConfirmationController.swift @@ -34,15 +34,13 @@ public final class OnboardingEmailConfirmationController: UIViewController { public override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + navigationItem.backButtonTitle = "" statusBarController.style.send(.darkContent) navigationController?.navigationBar.customize(translucent: true) } public override func viewDidLoad() { super.viewDidLoad() - navigationItem.backButtonTitle = " " - - setupNavigationBar() setupScrollView() setupBindings() @@ -58,12 +56,6 @@ public final class OnboardingEmailConfirmationController: UIViewController { } } - private func setupNavigationBar() { - let back = UIButton.back() - back.addTarget(self, action: #selector(didTapBack), for: .touchUpInside) - navigationItem.leftBarButtonItem = UIBarButtonItem(customView: back) - } - private func setupScrollView() { addChild(scrollViewController) view.addSubview(scrollViewController.view) @@ -157,8 +149,4 @@ public final class OnboardingEmailConfirmationController: UIViewController { coordinator.toDrawer(drawer, from: self) } - - @objc private func didTapBack() { - navigationController?.popViewController(animated: true) - } } diff --git a/Sources/OnboardingFeature/Controllers/OnboardingPhoneConfirmationController.swift b/Sources/OnboardingFeature/Controllers/OnboardingPhoneConfirmationController.swift index 0017798b..6207a5a7 100644 --- a/Sources/OnboardingFeature/Controllers/OnboardingPhoneConfirmationController.swift +++ b/Sources/OnboardingFeature/Controllers/OnboardingPhoneConfirmationController.swift @@ -34,15 +34,13 @@ public final class OnboardingPhoneConfirmationController: UIViewController { public override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + navigationItem.backButtonTitle = "" statusBarController.style.send(.darkContent) navigationController?.navigationBar.customize(translucent: true) } public override func viewDidLoad() { super.viewDidLoad() - navigationItem.backButtonTitle = " " - - setupNavigationBar() setupScrollView() setupBindings() @@ -58,12 +56,6 @@ public final class OnboardingPhoneConfirmationController: UIViewController { } } - private func setupNavigationBar() { - let back = UIButton.back() - back.addTarget(self, action: #selector(didTapBack), for: .touchUpInside) - navigationItem.leftBarButtonItem = UIBarButtonItem(customView: back) - } - private func setupScrollView() { addChild(scrollViewController) view.addSubview(scrollViewController.view) @@ -157,8 +149,4 @@ public final class OnboardingPhoneConfirmationController: UIViewController { coordinator.toDrawer(drawer, from: self) } - - @objc private func didTapBack() { - navigationController?.popViewController(animated: true) - } } diff --git a/Sources/OnboardingFeature/Controllers/OnboardingUsernameController.swift b/Sources/OnboardingFeature/Controllers/OnboardingUsernameController.swift index 761128f1..d42e1f81 100644 --- a/Sources/OnboardingFeature/Controllers/OnboardingUsernameController.swift +++ b/Sources/OnboardingFeature/Controllers/OnboardingUsernameController.swift @@ -22,8 +22,8 @@ public final class OnboardingUsernameController: UIViewController { public override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - statusBarController.style.send(.darkContent) navigationItem.backButtonTitle = "" + statusBarController.style.send(.darkContent) navigationController?.navigationBar.customize(translucent: true) } @@ -37,7 +37,6 @@ public final class OnboardingUsernameController: UIViewController { public override func viewDidLoad() { super.viewDidLoad() - setupNavigationBar() setupScrollView() setupBindings() diff --git a/Sources/Permissions/RequestPermissionController.swift b/Sources/Permissions/RequestPermissionController.swift index 8c787bed..d892ab60 100644 --- a/Sources/Permissions/RequestPermissionController.swift +++ b/Sources/Permissions/RequestPermissionController.swift @@ -25,13 +25,13 @@ public final class RequestPermissionController: UIViewController { public override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + navigationItem.backButtonTitle = "" statusBarController.style.send(.darkContent) navigationController?.navigationBar.customize(backgroundColor: Asset.neutralWhite.color) } public override func viewDidLoad() { super.viewDidLoad() - setupNavigationBar() setupBindings() } @@ -60,14 +60,6 @@ public final class RequestPermissionController: UIViewController { } } - private func setupNavigationBar() { - navigationItem.backButtonTitle = "" - - let back = UIButton.back() - back.addTarget(self, action: #selector(didTapBack), for: .touchUpInside) - navigationItem.leftBarButtonItem = UIBarButtonItem(customView: back) - } - private func setupBindings() { screenView.notNowButton .publisher(for: .touchUpInside) @@ -105,7 +97,4 @@ public final class RequestPermissionController: UIViewController { }.store(in: &cancellables) } - @objc private func didTapBack() { - navigationController?.popViewController(animated: true) - } } diff --git a/Sources/ProfileFeature/Controllers/ProfileCodeController.swift b/Sources/ProfileFeature/Controllers/ProfileCodeController.swift index c005b0bf..d612b9e9 100644 --- a/Sources/ProfileFeature/Controllers/ProfileCodeController.swift +++ b/Sources/ProfileFeature/Controllers/ProfileCodeController.swift @@ -22,6 +22,7 @@ public final class ProfileCodeController: UIViewController { public override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + navigationItem.backButtonTitle = "" navigationController?.navigationBar .customize(backgroundColor: Asset.neutralWhite.color) } @@ -39,20 +40,11 @@ public final class ProfileCodeController: UIViewController { public override func viewDidLoad() { super.viewDidLoad() - setupNavigationBar() setupScrollView() setupBindings() setupDetail() } - private func setupNavigationBar() { - navigationItem.backButtonTitle = " " - - let back = UIButton.back() - back.addTarget(self, action: #selector(didTapBack), for: .touchUpInside) - navigationItem.leftBarButtonItem = UIBarButtonItem(customView: back) - } - private func setupScrollView() { addChild(scrollViewController) view.addSubview(scrollViewController.view) @@ -128,8 +120,4 @@ public final class ProfileCodeController: UIViewController { screenView.set(content, isEmail: confirmation.isEmail) } - - @objc private func didTapBack() { - navigationController?.popViewController(animated: true) - } } diff --git a/Sources/ProfileFeature/Controllers/ProfileEmailController.swift b/Sources/ProfileFeature/Controllers/ProfileEmailController.swift index 97ced65c..3fb88d2b 100644 --- a/Sources/ProfileFeature/Controllers/ProfileEmailController.swift +++ b/Sources/ProfileFeature/Controllers/ProfileEmailController.swift @@ -19,6 +19,7 @@ public final class ProfileEmailController: UIViewController { public override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + navigationItem.backButtonTitle = "" statusBarController.style.send(.darkContent) navigationController?.navigationBar .customize(backgroundColor: Asset.neutralWhite.color) @@ -26,19 +27,10 @@ public final class ProfileEmailController: UIViewController { public override func viewDidLoad() { super.viewDidLoad() - setupNavigationBar() setupScrollView() setupBindings() } - private func setupNavigationBar() { - navigationItem.backButtonTitle = " " - - let back = UIButton.back() - back.addTarget(self, action: #selector(didTapBack), for: .touchUpInside) - navigationItem.leftBarButtonItem = UIBarButtonItem(customView: back) - } - private func setupScrollView() { addChild(scrollViewController) view.addSubview(scrollViewController.view) @@ -89,8 +81,4 @@ public final class ProfileEmailController: UIViewController { .sink { [unowned self] in viewModel.didTapNext() } .store(in: &cancellables) } - - @objc private func didTapBack() { - navigationController?.popViewController(animated: true) - } } diff --git a/Sources/ProfileFeature/Controllers/ProfilePhoneController.swift b/Sources/ProfileFeature/Controllers/ProfilePhoneController.swift index eb77fd14..01737802 100644 --- a/Sources/ProfileFeature/Controllers/ProfilePhoneController.swift +++ b/Sources/ProfileFeature/Controllers/ProfilePhoneController.swift @@ -21,26 +21,18 @@ public final class ProfilePhoneController: UIViewController { public override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + navigationItem.backButtonTitle = "" statusBarController.style.send(.darkContent) navigationController?.navigationBar - .customize(backgroundColor: Asset.neutralWhite.color) + .customize(backgroundColor: Asset.neutralWhite.color) } public override func viewDidLoad() { super.viewDidLoad() - setupNavigationBar() setupScrollView() setupBindings() } - private func setupNavigationBar() { - navigationItem.backButtonTitle = " " - - let back = UIButton.back() - back.addTarget(self, action: #selector(didTapBack), for: .touchUpInside) - navigationItem.leftBarButtonItem = UIBarButtonItem(customView: back) - } - private func setupScrollView() { addChild(scrollViewController) view.addSubview(scrollViewController.view) @@ -107,8 +99,4 @@ public final class ProfilePhoneController: UIViewController { .sink { [unowned self] in viewModel.didTapNext() } .store(in: &cancellables) } - - @objc private func didTapBack() { - navigationController?.popViewController(animated: true) - } } diff --git a/Sources/RestoreFeature/Controllers/RestoreController.swift b/Sources/RestoreFeature/Controllers/RestoreController.swift index b88932c1..f2081aae 100644 --- a/Sources/RestoreFeature/Controllers/RestoreController.swift +++ b/Sources/RestoreFeature/Controllers/RestoreController.swift @@ -26,6 +26,12 @@ public final class RestoreController: UIViewController { presentWarning() } + public override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + navigationItem.backButtonTitle = "" + navigationController?.navigationBar.customize() + } + public override func viewDidLoad() { super.viewDidLoad() setupNavigationBar() @@ -33,19 +39,13 @@ public final class RestoreController: UIViewController { } private func setupNavigationBar() { - navigationItem.backButtonTitle = "" - let title = UILabel() title.text = Localized.AccountRestore.header title.textColor = Asset.neutralActive.color title.font = Fonts.Mulish.semiBold.font(size: 18.0) - let back = UIButton.back() - back.addTarget(self, action: #selector(didTapBack), for: .touchUpInside) - - navigationItem.leftBarButtonItem = UIBarButtonItem( - customView: UIStackView(arrangedSubviews: [back, title]) - ) + navigationItem.leftBarButtonItem = UIBarButtonItem(customView: title) + navigationItem.leftItemsSupplementBackButton = true } private func setupBindings() { diff --git a/Sources/RestoreFeature/Controllers/RestoreListController.swift b/Sources/RestoreFeature/Controllers/RestoreListController.swift index b396d106..33470e44 100644 --- a/Sources/RestoreFeature/Controllers/RestoreListController.swift +++ b/Sources/RestoreFeature/Controllers/RestoreListController.swift @@ -30,27 +30,13 @@ public final class RestoreListController: UIViewController { public override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + navigationItem.backButtonTitle = "" navigationController?.navigationBar.customize(translucent: true) } public override func viewDidLoad() { super.viewDidLoad() - setupNavigationBar() - setupBindings() - } - - private func setupNavigationBar() { - navigationItem.backButtonTitle = "" - - let back = UIButton.back() - back.addTarget(self, action: #selector(didTapBack), for: .touchUpInside) - - navigationItem.leftBarButtonItem = UIBarButtonItem( - customView: UIStackView(arrangedSubviews: [back]) - ) - } - private func setupBindings() { viewModel.hudPublisher .receive(on: DispatchQueue.main) .sink { [hud] in hud.update(with: $0) } diff --git a/Sources/SFTPFeature/SFTPController.swift b/Sources/SFTPFeature/SFTPController.swift index f80908b9..21bf8ca1 100644 --- a/Sources/SFTPFeature/SFTPController.swift +++ b/Sources/SFTPFeature/SFTPController.swift @@ -21,10 +21,15 @@ public final class SFTPController: UIViewController { required init?(coder: NSCoder) { nil } + public override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + navigationItem.backButtonTitle = "" + navigationController?.navigationBar.customize(translucent: true) + } + public override func viewDidLoad() { super.viewDidLoad() setupScrollView() - setupNavigationBar() setupBindings() } @@ -38,17 +43,6 @@ public final class SFTPController: UIViewController { scrollViewController.contentView = screenView } - private func setupNavigationBar() { - navigationItem.backButtonTitle = "" - - let back = UIButton.back() - back.addTarget(self, action: #selector(didTapBack), for: .touchUpInside) - - navigationItem.leftBarButtonItem = UIBarButtonItem( - customView: UIStackView(arrangedSubviews: [back]) - ) - } - private func setupBindings() { viewModel.hudPublisher .receive(on: DispatchQueue.main) @@ -89,8 +83,4 @@ public final class SFTPController: UIViewController { .sink { [unowned self] in viewModel.didTapLogin() } .store(in: &cancellables) } - - @objc private func didTapBack() { - navigationController?.popViewController(animated: true) - } } diff --git a/Sources/SearchFeature/Controllers/SearchContainerController.swift b/Sources/SearchFeature/Controllers/SearchContainerController.swift index 9cba5303..3a1bf1e4 100644 --- a/Sources/SearchFeature/Controllers/SearchContainerController.swift +++ b/Sources/SearchFeature/Controllers/SearchContainerController.swift @@ -33,6 +33,7 @@ public final class SearchContainerController: UIViewController { public override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + navigationItem.backButtonTitle = "" statusBarController.style.send(.darkContent) navigationController?.navigationBar.customize( backgroundColor: Asset.neutralWhite.color @@ -61,19 +62,13 @@ public final class SearchContainerController: UIViewController { } private func setupNavigationBar() { - navigationItem.backButtonTitle = " " + let title = UILabel() + title.text = Localized.Ud.title + title.textColor = Asset.neutralActive.color + title.font = Fonts.Mulish.semiBold.font(size: 18.0) - let titleLabel = UILabel() - titleLabel.text = Localized.Ud.title - titleLabel.textColor = Asset.neutralActive.color - titleLabel.font = Fonts.Mulish.semiBold.font(size: 18.0) - - let backButton = UIButton.back() - backButton.addTarget(self, action: #selector(didTapBack), for: .touchUpInside) - - navigationItem.leftBarButtonItem = UIBarButtonItem( - customView: UIStackView(arrangedSubviews: [backButton, titleLabel]) - ) + navigationItem.leftBarButtonItem = UIBarButtonItem(customView: title) + navigationItem.leftItemsSupplementBackButton = true } private func setupBindings() { @@ -98,10 +93,6 @@ public final class SearchContainerController: UIViewController { .store(in: &cancellables) } - @objc private func didTapBack() { - navigationController?.popViewController(animated: true) - } - private func embedControllers() { addChild(leftController) addChild(rightController) diff --git a/Sources/SettingsFeature/Controllers/AccountDeleteController.swift b/Sources/SettingsFeature/Controllers/AccountDeleteController.swift index 1dc36e2e..ee5be65a 100644 --- a/Sources/SettingsFeature/Controllers/AccountDeleteController.swift +++ b/Sources/SettingsFeature/Controllers/AccountDeleteController.swift @@ -28,7 +28,6 @@ public final class AccountDeleteController: UIViewController { public override func viewDidLoad() { super.viewDidLoad() - setupNavigationBar() setupScrollView() setupBindings() @@ -42,12 +41,6 @@ public final class AccountDeleteController: UIViewController { } } - private func setupNavigationBar() { - let back = UIButton.back() - back.addTarget(self, action: #selector(didTapBack), for: .touchUpInside) - navigationItem.leftBarButtonItem = UIBarButtonItem(customView: back) - } - private func setupScrollView() { addChild(scrollViewController) view.addSubview(scrollViewController.view) @@ -84,10 +77,6 @@ public final class AccountDeleteController: UIViewController { .store(in: &cancellables) } - @objc private func didTapBack() { - navigationController?.popViewController(animated: true) - } - private func presentInfo(title: String, subtitle: String) { let actionButton = CapsuleButton() actionButton.set( diff --git a/Sources/SettingsFeature/Controllers/SettingsAdvancedController.swift b/Sources/SettingsFeature/Controllers/SettingsAdvancedController.swift index aeb6791e..a7d92763 100644 --- a/Sources/SettingsFeature/Controllers/SettingsAdvancedController.swift +++ b/Sources/SettingsFeature/Controllers/SettingsAdvancedController.swift @@ -17,6 +17,7 @@ public final class SettingsAdvancedController: UIViewController { public override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + navigationItem.backButtonTitle = "" navigationController?.navigationBar .customize(backgroundColor: Asset.neutralWhite.color) } @@ -30,19 +31,13 @@ public final class SettingsAdvancedController: UIViewController { } private func setupNavigationBar() { - navigationItem.backButtonTitle = "" - let title = UILabel() title.text = Localized.Settings.Advanced.title title.textColor = Asset.neutralActive.color title.font = Fonts.Mulish.semiBold.font(size: 18.0) - let back = UIButton.back() - back.addTarget(self, action: #selector(didTapBack), for: .touchUpInside) - - navigationItem.leftBarButtonItem = UIBarButtonItem( - customView: UIStackView(arrangedSubviews: [back, title]) - ) + navigationItem.leftBarButtonItem = UIBarButtonItem(customView: title) + navigationItem.leftItemsSupplementBackButton = true } private func setupBindings() { @@ -79,8 +74,4 @@ public final class SettingsAdvancedController: UIViewController { screenView.showUsernamesSwitcher.switcherView.setOn(state.isShowingUsernames, animated: true) }.store(in: &cancellables) } - - @objc private func didTapBack() { - navigationController?.popViewController(animated: true) - } } diff --git a/Sources/TermsFeature/TermsConditionsController.swift b/Sources/TermsFeature/TermsConditionsController.swift index 0a5b3b5b..27ad6cb7 100644 --- a/Sources/TermsFeature/TermsConditionsController.swift +++ b/Sources/TermsFeature/TermsConditionsController.swift @@ -29,6 +29,7 @@ public final class TermsConditionsController: UIViewController { public override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + navigationItem.backButtonTitle = "" statusBarController.style.send(.darkContent) navigationController?.navigationBar.customize(translucent: true) } -- GitLab