diff --git a/Session/Closed Groups/NewClosedGroupVC.swift b/Session/Closed Groups/NewClosedGroupVC.swift index bd51ba8c2..cde0e37f9 100644 --- a/Session/Closed Groups/NewClosedGroupVC.swift +++ b/Session/Closed Groups/NewClosedGroupVC.swift @@ -51,11 +51,6 @@ final class NewClosedGroupVC: BaseVC, UITableViewDataSource, UITableViewDelegate let customTitleFontSize = Values.largeFontSize setNavBarTitle("vc_create_closed_group_title".localized(), customFontSize: customTitleFontSize) - // Set up navigation bar buttons - let closeButton = UIBarButtonItem(image: #imageLiteral(resourceName: "X"), style: .plain, target: self, action: #selector(close)) - closeButton.tintColor = Colors.text - navigationItem.leftBarButtonItem = closeButton - let doneButton = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(createClosedGroup)) doneButton.tintColor = Colors.text navigationItem.rightBarButtonItem = doneButton diff --git a/Session/Home/HomeVC.swift b/Session/Home/HomeVC.swift index 1abee7be2..5b9549a54 100644 --- a/Session/Home/HomeVC.swift +++ b/Session/Home/HomeVC.swift @@ -742,7 +742,7 @@ final class HomeVC: BaseVC, UITableViewDataSource, UITableViewDelegate, SeedRemi } @objc func createNewDM() { - let newDMVC = NewDMVC() + let newDMVC = NewDMVC(shouldShowBackButton: false) let navigationController = OWSNavigationController(rootViewController: newDMVC) if UIDevice.current.isIPad { navigationController.modalPresentationStyle = .fullScreen @@ -753,7 +753,7 @@ final class HomeVC: BaseVC, UITableViewDataSource, UITableViewDelegate, SeedRemi @objc(createNewDMFromDeepLink:) func createNewDMFromDeepLink(sessionID: String) { - let newDMVC = NewDMVC(sessionID: sessionID) + let newDMVC = NewDMVC(sessionID: sessionID, shouldShowBackButton: false) let navigationController = OWSNavigationController(rootViewController: newDMVC) if UIDevice.current.isIPad { navigationController.modalPresentationStyle = .fullScreen diff --git a/Session/Home/New Conversation/NewDMVC.swift b/Session/Home/New Conversation/NewDMVC.swift index 370a32ff3..ffe7b9cff 100644 --- a/Session/Home/New Conversation/NewDMVC.swift +++ b/Session/Home/New Conversation/NewDMVC.swift @@ -7,6 +7,7 @@ import SessionMessagingKit import SessionUtilitiesKit final class NewDMVC : BaseVC, UIPageViewControllerDataSource, UIPageViewControllerDelegate, OWSQRScannerDelegate { + private var shouldShowBackButton: Bool = true private let pageVC = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil) private var pages: [UIViewController] = [] private var targetVCIndex: Int? @@ -44,7 +45,13 @@ final class NewDMVC : BaseVC, UIPageViewControllerDataSource, UIPageViewControll return result }() - init(sessionID: String) { + init(shouldShowBackButton: Bool) { + self.shouldShowBackButton = shouldShowBackButton + super.init(nibName: nil, bundle: nil) + } + + init(sessionID: String, shouldShowBackButton: Bool = true) { + self.shouldShowBackButton = shouldShowBackButton super.init(nibName: nil, bundle: nil) enterPublicKeyVC.setSessionID(to: sessionID) } @@ -65,9 +72,11 @@ final class NewDMVC : BaseVC, UIPageViewControllerDataSource, UIPageViewControll setNavBarTitle(NSLocalizedString("vc_create_private_chat_title", comment: "")) let navigationBar = navigationController!.navigationBar // Set up navigation bar buttons - let closeButton = UIBarButtonItem(image: #imageLiteral(resourceName: "X"), style: .plain, target: self, action: #selector(close)) - closeButton.tintColor = Colors.text - navigationItem.leftBarButtonItem = closeButton + if !shouldShowBackButton { + let closeButton = UIBarButtonItem(image: #imageLiteral(resourceName: "X"), style: .plain, target: self, action: #selector(close)) + closeButton.tintColor = Colors.text + navigationItem.leftBarButtonItem = closeButton + } // Set up page VC let hasCameraAccess = (AVCaptureDevice.authorizationStatus(for: .video) == .authorized) pages = [ enterPublicKeyVC, (hasCameraAccess ? scanQRCodeWrapperVC : scanQRCodePlaceholderVC) ] @@ -77,20 +86,16 @@ final class NewDMVC : BaseVC, UIPageViewControllerDataSource, UIPageViewControll // Set up tab bar view.addSubview(tabBar) tabBar.pin(.leading, to: .leading, of: view) - let tabBarInset: CGFloat = (UIDevice.current.isIPad ? navigationBar.height() + 20 : navigationBar.height()) - tabBar.pin(.top, to: .top, of: view, withInset: tabBarInset) - view.pin(.trailing, to: .trailing, of: tabBar) + tabBar.pin(.top, to: .top, of: view) + tabBar.pin(.trailing, to: .trailing, of: view) // Set up page VC constraints let pageVCView = pageVC.view! view.addSubview(pageVCView) pageVCView.pin(.leading, to: .leading, of: view) pageVCView.pin(.top, to: .bottom, of: tabBar) - view.pin(.trailing, to: .trailing, of: pageVCView) - view.pin(.bottom, to: .bottom, of: pageVCView) - let screen = UIScreen.main.bounds - pageVCView.set(.width, to: screen.width) + pageVCView.pin(.trailing, to: .trailing, of: view) + pageVCView.pin(.bottom, to: .bottom, of: view) let height: CGFloat = (navigationController!.view.bounds.height - navigationBar.height() - TabBar.snHeight) - pageVCView.set(.height, to: height) enterPublicKeyVC.constrainHeight(to: height) scanQRCodePlaceholderVC.constrainHeight(to: height) } diff --git a/Session/Open Groups/JoinOpenGroupVC.swift b/Session/Open Groups/JoinOpenGroupVC.swift index 10de3d156..382575c7e 100644 --- a/Session/Open Groups/JoinOpenGroupVC.swift +++ b/Session/Open Groups/JoinOpenGroupVC.swift @@ -59,12 +59,6 @@ final class JoinOpenGroupVC: BaseVC, UIPageViewControllerDataSource, UIPageViewC setUpNavBarStyle() setNavBarTitle("vc_join_public_chat_title".localized()) - // Navigation bar buttons - let navBarHeight: CGFloat = (navigationController?.navigationBar.frame.size.height ?? 0) - let closeButton = UIBarButtonItem(image: #imageLiteral(resourceName: "X"), style: .plain, target: self, action: #selector(close)) - closeButton.tintColor = Colors.text - navigationItem.leftBarButtonItem = closeButton - // Page VC let hasCameraAccess = (AVCaptureDevice.authorizationStatus(for: .video) == .authorized) pages = [ enterURLVC, (hasCameraAccess ? scanQRCodeWrapperVC : scanQRCodePlaceholderVC) ] @@ -75,26 +69,18 @@ final class JoinOpenGroupVC: BaseVC, UIPageViewControllerDataSource, UIPageViewC // Tab bar view.addSubview(tabBar) tabBar.pin(.leading, to: .leading, of: view) - tabBar.pin( - .top, - to: .top, - of: view, - withInset: (UIDevice.current.isIPad ? navBarHeight + 20 : navBarHeight) - ) - view.pin(.trailing, to: .trailing, of: tabBar) + tabBar.pin(.top, to: .top, of: view) + tabBar.pin(.trailing, to: .trailing, of: view) // Page VC constraints let pageVCView = pageVC.view! view.addSubview(pageVCView) pageVCView.pin(.leading, to: .leading, of: view) pageVCView.pin(.top, to: .bottom, of: tabBar) - view.pin(.trailing, to: .trailing, of: pageVCView) - view.pin(.bottom, to: .bottom, of: pageVCView) - - let screen = UIScreen.main.bounds + pageVCView.pin(.trailing, to: .trailing, of: view) + pageVCView.pin(.bottom, to: .bottom, of: view) + let navBarHeight: CGFloat = (navigationController?.navigationBar.frame.size.height ?? 0) let height: CGFloat = ((navigationController?.view.bounds.height ?? 0) - navBarHeight - TabBar.snHeight) - pageVCView.set(.width, to: screen.width) - pageVCView.set(.height, to: height) enterURLVC.constrainHeight(to: height) scanQRCodePlaceholderVC.constrainHeight(to: height) }