From 657f60d5c052b0589caf5e1e37d29fe820e42e52 Mon Sep 17 00:00:00 2001 From: Fernando Bunn Date: Mon, 2 Dec 2024 09:50:37 -0300 Subject: [PATCH] WIP: Remove bar background --- .../Public API/AIChatViewController.swift | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/LocalPackages/AIChat/Sources/AIChat/Public API/AIChatViewController.swift b/LocalPackages/AIChat/Sources/AIChat/Public API/AIChatViewController.swift index 1346ef2a91..4733e138dc 100644 --- a/LocalPackages/AIChat/Sources/AIChat/Public API/AIChatViewController.swift +++ b/LocalPackages/AIChat/Sources/AIChat/Public API/AIChatViewController.swift @@ -66,6 +66,7 @@ extension AIChatViewController { public override func viewDidLoad() { super.viewDidLoad() + self.view.backgroundColor = .systemBackground setupNavigationBar() subscribeToCleanupPublisher() } @@ -95,11 +96,26 @@ extension AIChatViewController { extension AIChatViewController { private func setupNavigationBar() { + guard let navigationController = navigationController else { return } + + // Make the navigation bar transparent + let appearance = UINavigationBarAppearance() + appearance.configureWithTransparentBackground() + appearance.backgroundColor = .clear + appearance.shadowImage = UIImage() + appearance.shadowColor = .clear + + navigationController.navigationBar.standardAppearance = appearance + navigationController.navigationBar.scrollEdgeAppearance = appearance + navigationController.navigationBar.compactAppearance = appearance + navigationController.navigationBar.isTranslucent = true + + // Set up the custom title view let imageView = UIImageView(image: UIImage(named: "Logo")) imageView.contentMode = .scaleAspectFit imageView.translatesAutoresizingMaskIntoConstraints = false - let imageSize: CGFloat = 32 + let imageSize: CGFloat = 28 NSLayoutConstraint.activate([ imageView.widthAnchor.constraint(equalToConstant: imageSize), imageView.heightAnchor.constraint(equalToConstant: imageSize) @@ -127,6 +143,7 @@ extension AIChatViewController { navigationItem.rightBarButtonItem = closeButton } + private func addWebViewController() { guard webViewController == nil else { return } @@ -139,7 +156,7 @@ extension AIChatViewController { viewController.view.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ - viewController.view.topAnchor.constraint(equalTo: view.topAnchor), + viewController.view.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor), viewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor), viewController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor), viewController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor)