From a5c4738bd84bc2b339c8ac391e323d59f3c21659 Mon Sep 17 00:00:00 2001 From: amddg44 Date: Wed, 4 Sep 2024 16:40:24 +0200 Subject: [PATCH] Fix bookmarks toolbar behaviour with Sync Promo on iOS 15 (#3313) Task/Issue URL: https://app.asana.com/0/414709148257752/1208220515829639/f Tech Design URL: CC: Description: Fixes a SwiftUI issue which caused the toolbar to not appear correctly on the bookmarks screen (iOS 15 only) --- DuckDuckGo/BookmarksViewController.swift | 14 ++++++++++---- .../Sync-Downloads-24.imageset/Contents.json | 3 +++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/DuckDuckGo/BookmarksViewController.swift b/DuckDuckGo/BookmarksViewController.swift index 109542d87e..8d5f56f5ea 100644 --- a/DuckDuckGo/BookmarksViewController.swift +++ b/DuckDuckGo/BookmarksViewController.swift @@ -897,9 +897,18 @@ class BookmarksViewController: UIViewController, UITableViewDelegate { } syncPromoViewHostingController.view.translatesAutoresizingMaskIntoConstraints = false - addChild(syncPromoViewHostingController) + + // This is needed to ensure the toolbar displays correctly on iOS 15 + if #available(iOS 16.0, *) { + addChild(syncPromoViewHostingController) + } + headerView.addSubview(syncPromoViewHostingController.view) + if #available(iOS 16.0, *) { + syncPromoViewHostingController.didMove(toParent: self) + } + NSLayoutConstraint.deactivate([ searchBarBottomConstraint ]) @@ -920,9 +929,6 @@ class BookmarksViewController: UIViewController, UITableViewDelegate { headerView.frame = CGRect(x: 0, y: 0, width: tableView.bounds.width, height: totalHeight) tableView.tableHeaderView = headerView - syncPromoViewHostingController.didMove(toParent: self) - - tableView.layoutIfNeeded() } else if !headerView.subviews.contains(searchBar) || headerView.subviews.count != 1 { if syncPromoViewHostingController.view != nil { diff --git a/DuckDuckGo/SyncAssets.xcassets/Sync-Downloads-24.imageset/Contents.json b/DuckDuckGo/SyncAssets.xcassets/Sync-Downloads-24.imageset/Contents.json index 5651383d76..b1836df5f5 100644 --- a/DuckDuckGo/SyncAssets.xcassets/Sync-Downloads-24.imageset/Contents.json +++ b/DuckDuckGo/SyncAssets.xcassets/Sync-Downloads-24.imageset/Contents.json @@ -8,5 +8,8 @@ "info" : { "author" : "xcode", "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" } }