diff --git a/Core/FeatureFlag.swift b/Core/FeatureFlag.swift index f14ae54cbf..579eda936d 100644 --- a/Core/FeatureFlag.swift +++ b/Core/FeatureFlag.swift @@ -34,7 +34,6 @@ public enum FeatureFlag: String { case networkProtection case networkProtectionWaitlistAccess case networkProtectionWaitlistActive - case swipeTabs case autoconsentOnByDefault case history } @@ -42,7 +41,7 @@ public enum FeatureFlag: String { extension FeatureFlag: FeatureFlagSourceProviding { public var source: FeatureFlagSource { switch self { - case .debugMenu, .appTrackingProtection, .swipeTabs: + case .debugMenu, .appTrackingProtection: return .internalOnly case .sync: return .remoteReleasable(.subfeature(SyncSubfeature.level0ShowSync)) diff --git a/DuckDuckGo/AppDelegate.swift b/DuckDuckGo/AppDelegate.swift index 42def30fc4..fa5cdf9eea 100644 --- a/DuckDuckGo/AppDelegate.swift +++ b/DuckDuckGo/AppDelegate.swift @@ -642,7 +642,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate { private func showKeyboardOnLaunch() { guard KeyboardSettings().onAppLaunch && showKeyboardIfSettingOn && shouldShowKeyboardOnLaunch() else { return } - self.mainViewController?.enterSearch() + DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { + self.mainViewController?.enterSearch() + } showKeyboardIfSettingOn = false } diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index 92c0277371..3157597a2a 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -304,8 +304,8 @@ class MainViewController: UIViewController { startOnboardingFlowIfNotSeenBefore() tabsBarController?.refresh(tabsModel: tabManager.model) - swipeTabsCoordinator?.refresh(tabsModel: tabManager.model) - + swipeTabsCoordinator?.refresh(tabsModel: tabManager.model, scrollToSelected: true) + _ = AppWidthObserver.shared.willResize(toWidth: view.frame.width) applyWidth() @@ -340,7 +340,7 @@ class MainViewController: UIViewController { } } - func updatePreviewForCurrentTab() { + func updatePreviewForCurrentTab(completion: (() -> Void)? = nil) { assert(Thread.isMainThread) if !viewCoordinator.logoContainer.isHidden, @@ -349,6 +349,7 @@ class MainViewController: UIViewController { // Home screen with logo if let image = viewCoordinator.logoContainer.createImageSnapshot(inBounds: viewCoordinator.contentContainer.frame) { previewsSource.update(preview: image, forTab: tab) + completion?() } } else if let currentTab = self.tabManager.current(), currentTab.link != nil { @@ -357,12 +358,16 @@ class MainViewController: UIViewController { guard let image else { return } self.previewsSource.update(preview: image, forTab: currentTab.tabModel) + completion?() }) } else if let tab = self.tabManager.model.currentTab { // Favorites, etc if let image = viewCoordinator.contentContainer.createImageSnapshot() { previewsSource.update(preview: image, forTab: tab) + completion?() } + } else { + completion?() } } @@ -1157,7 +1162,7 @@ class MainViewController: UIViewController { viewCoordinator.toolbar.isHidden = false viewCoordinator.omniBar.enterPhoneState() - swipeTabsCoordinator?.isEnabled = featureFlagger.isFeatureOn(.swipeTabs) + swipeTabsCoordinator?.isEnabled = true } @discardableResult @@ -1291,7 +1296,7 @@ class MainViewController: UIViewController { } attachHomeScreen() tabsBarController?.refresh(tabsModel: tabManager.model) - swipeTabsCoordinator?.refresh(tabsModel: tabManager.model) + swipeTabsCoordinator?.refresh(tabsModel: tabManager.model, scrollToSelected: true) homeController?.openedAsNewTab(allowingKeyboard: allowingKeyboard) } @@ -2249,16 +2254,11 @@ extension MainViewController: TabSwitcherButtonDelegate { guard let currentTab = currentTab ?? tabManager?.current(createIfNeeded: true) else { fatalError("Unable to get current tab") } - - currentTab.preparePreview(completion: { image in - if let image = image { - self.previewsSource.update(preview: image, - forTab: currentTab.tabModel) - } + updatePreviewForCurrentTab { ViewHighlighter.hideAll() self.segueToTabSwitcher() - }) + } } } diff --git a/DuckDuckGo/SwipeTabsCoordinator.swift b/DuckDuckGo/SwipeTabsCoordinator.swift index 180d9a17a0..d43a5a3ddb 100644 --- a/DuckDuckGo/SwipeTabsCoordinator.swift +++ b/DuckDuckGo/SwipeTabsCoordinator.swift @@ -73,6 +73,8 @@ class SwipeTabsCoordinator: NSObject { collectionView.dataSource = self collectionView.decelerationRate = .fast collectionView.backgroundColor = .clear + collectionView.showsHorizontalScrollIndicator = false + collectionView.showsVerticalScrollIndicator = false updateLayout() } @@ -92,7 +94,6 @@ class SwipeTabsCoordinator: NSObject { private func updateLayout() { let layout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout - layout?.scrollDirection = .horizontal layout?.itemSize = CGSize(width: coordinator.superview.frame.size.width, height: coordinator.omniBar.frame.height) layout?.minimumLineSpacing = 0 layout?.minimumInteritemSpacing = 0 @@ -101,7 +102,6 @@ class SwipeTabsCoordinator: NSObject { private func scrollToCurrent() { guard isEnabled else { return } - let targetOffset = collectionView.frame.width * CGFloat(tabsModel.currentIndex) guard targetOffset != collectionView.contentOffset.x else { @@ -118,12 +118,6 @@ class SwipeTabsCoordinator: NSObject { // MARK: UICollectionViewDelegate extension SwipeTabsCoordinator: UICollectionViewDelegate { - func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { - DispatchQueue.main.async { - self.scrollToCurrent() - } - } - func scrollViewDidScroll(_ scrollView: UIScrollView) { switch state { @@ -217,7 +211,7 @@ extension SwipeTabsCoordinator: UICollectionViewDelegate { switch state { case .idle: state = .starting(scrollView.contentOffset) - + default: break } } @@ -311,7 +305,8 @@ extension SwipeTabsCoordinator: UICollectionViewDataSource { if let url = tabsModel.safeGetTabAt(indexPath.row)?.link?.url { cell.omniBar?.startBrowsing() - cell.omniBar?.refreshText(forUrl: url) + cell.omniBar?.refreshText(forUrl: url, forceFullURL: appSettings.showFullSiteAddress) + cell.omniBar?.resetPrivacyIcon(for: url) } } diff --git a/DuckDuckGo/TabPreviewsSource.swift b/DuckDuckGo/TabPreviewsSource.swift index 2f58c6b468..7c287e14b7 100644 --- a/DuckDuckGo/TabPreviewsSource.swift +++ b/DuckDuckGo/TabPreviewsSource.swift @@ -51,11 +51,7 @@ class TabPreviewsSource { func update(preview: UIImage, forTab tab: Tab) { cache[tab.uid] = preview - - if tabSettings.isGridViewEnabled { - store(preview: preview, forTab: tab) - } - + store(preview: preview, forTab: tab) tab.didUpdatePreview() }