From ace7f3e5a5a3e66fb42bfa0757a81a8f8392008c Mon Sep 17 00:00:00 2001 From: Ryan ZHAO <> Date: Thu, 25 Jan 2024 10:42:06 +1100 Subject: [PATCH] add dismiss button on start new conversation screen --- Session/Home/HomeVC.swift | 8 ++++-- .../StartConversationScreen.swift | 2 +- .../Shared/SessionHostingViewController.swift | 28 +++++++++++++++++-- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Session/Home/HomeVC.swift b/Session/Home/HomeVC.swift index e7f5d552d..bc0de2395 100644 --- a/Session/Home/HomeVC.swift +++ b/Session/Home/HomeVC.swift @@ -868,10 +868,14 @@ final class HomeVC: BaseVC, SessionUtilRespondingViewController, UITableViewData } @objc func createNewConversation() { - let viewController = SessionHostingViewController(rootView: StartConversationScreen()) + let viewController = SessionHostingViewController( + rootView: StartConversationScreen(), + customizedNavigationBackground: .backgroundSecondary + ) viewController.setNavBarTitle("start_conversation_screen_title".localized()) + viewController.setUpDismissingButton(on: .right) + let navigationController = StyledNavigationController(rootViewController: viewController) - navigationController.view.backgroundColor = .blue if UIDevice.current.isIPad { navigationController.modalPresentationStyle = .fullScreen } diff --git a/Session/Home/New Conversation/StartConversationScreen.swift b/Session/Home/New Conversation/StartConversationScreen.swift index e889693a5..34f458d92 100644 --- a/Session/Home/New Conversation/StartConversationScreen.swift +++ b/Session/Home/New Conversation/StartConversationScreen.swift @@ -76,7 +76,7 @@ struct StartConversationScreen: View { .aspectRatio(1, contentMode: .fit) .padding(.vertical, Values.smallSpacing) } - .padding(.all, Values.largeSpacing) + .padding(.horizontal, Values.largeSpacing) } } .backgroundColor(themeColor: .backgroundSecondary) diff --git a/Session/Shared/SessionHostingViewController.swift b/Session/Shared/SessionHostingViewController.swift index 148cc0a1a..b8e24740d 100644 --- a/Session/Shared/SessionHostingViewController.swift +++ b/Session/Shared/SessionHostingViewController.swift @@ -7,10 +7,18 @@ public class HostWrapper: ObservableObject { public weak var controller: UIViewController? } -public class SessionHostingViewController: UIHostingController>> where Content : View { +public enum NavigationItemPosition { + case left + case right +} + +public class SessionHostingViewController: UIHostingController>>, ThemedNavigation where Content : View { public override var preferredStatusBarStyle: UIStatusBarStyle { return ThemeManager.currentTheme.statusBarStyle } + + public var navigationBackground: ThemeValue { customizedNavigationBackground ?? .backgroundPrimary } + private let customizedNavigationBackground: ThemeValue? lazy var navBarTitleLabel: UILabel = { let result = UILabel() @@ -32,7 +40,8 @@ public class SessionHostingViewController: UIHostingController> super.init(rootView: modified) @@ -94,4 +103,19 @@ public class SessionHostingViewController: UIHostingController