From ae862386fd39c81031f1e3d0f9bfa67b5b292e45 Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Thu, 18 Jan 2024 11:06:09 +0000 Subject: [PATCH] tweak page position --- .../xcshareddata/swiftpm/Package.resolved | 2 +- DuckDuckGo/MainView.swift | 19 -------------- DuckDuckGo/MainViewController.swift | 25 ++++++++----------- 3 files changed, 11 insertions(+), 35 deletions(-) diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 67fbd40e2b..64a6614e8d 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -156,7 +156,7 @@ { "identity" : "trackerradarkit", "kind" : "remoteSourceControl", - "location" : "https://github.com/duckduckgo/TrackerRadarKit", + "location" : "https://github.com/duckduckgo/TrackerRadarKit.git", "state" : { "revision" : "a6b7ba151d9dc6684484f3785293875ec01cc1ff", "version" : "1.2.2" diff --git a/DuckDuckGo/MainView.swift b/DuckDuckGo/MainView.swift index e5cb0798c8..4d5171167e 100644 --- a/DuckDuckGo/MainView.swift +++ b/DuckDuckGo/MainView.swift @@ -54,7 +54,6 @@ class MainViewFactory { extension MainViewFactory { private func createViews() { - createWebViewContainer() createLogoBackground() createContentContainer() createSuggestionTrayContainer() @@ -66,12 +65,6 @@ extension MainViewFactory { createToolbar() } - final class WebViewContainerView: UIView { } - private func createWebViewContainer() { - coordinator.webViewContainer = WebViewContainerView() - superview.addSubview(coordinator.webViewContainer) - } - private func createProgressView() { coordinator.progress = ProgressView() superview.addSubview(coordinator.progress) @@ -163,7 +156,6 @@ extension MainViewFactory { extension MainViewFactory { private func constrainViews() { - constrainWebViewContainer() constrainLogoBackground() constrainContentContainer() constrainSuggestionTrayContainer() @@ -174,16 +166,6 @@ extension MainViewFactory { constrainProgress() constrainToolbar() } - - private func constrainWebViewContainer() { - let webViewContainer = coordinator.webViewContainer! - NSLayoutConstraint.activate([ - webViewContainer.constrainView(superview, by: .width), - webViewContainer.constrainView(superview, by: .height), - webViewContainer.constrainView(superview, by: .centerX), - webViewContainer.constrainView(superview, by: .centerY), - ]) - } private func constrainProgress() { let progress = coordinator.progress! @@ -351,7 +333,6 @@ class MainViewCoordinator { var toolbarFireButton: UIBarButtonItem! var toolbarForwardButton: UIBarButtonItem! var toolbarTabSwitcherButton: UIBarButtonItem! - var webViewContainer: UIView! let constraints = Constraints() diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index b5cb5f8083..1d1412813b 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -644,7 +644,7 @@ class MainViewController: UIViewController { guard let tab = tabManager.current(createIfNeeded: true) else { fatalError("Unable to create tab") } - addToWebViewContainer(tab: tab) + attachTab(tab: tab) refreshControls() } else { attachHomeScreen() @@ -853,7 +853,7 @@ class MainViewController: UIViewController { private func addTab(url: URL?, inheritedAttribution: AdClickAttributionLogic.State?) { let tab = tabManager.add(url: url, inheritedAttribution: inheritedAttribution) dismissOmniBar() - addToWebViewContainer(tab: tab) + attachTab(tab: tab) } func select(tabAt index: Int) { @@ -867,7 +867,7 @@ class MainViewController: UIViewController { if tab.link == nil { attachHomeScreen() } else { - addToWebViewContainer(tab: tab) + attachTab(tab: tab) refreshControls() } tabsBarController?.refresh(tabsModel: tabManager.model, scrollToSelected: true) @@ -876,21 +876,15 @@ class MainViewController: UIViewController { } } - private func addToWebViewContainer(tab: TabViewController) { + private func attachTab(tab: TabViewController) { removeHomeScreen() updateFindInPage() currentTab?.progressWorker.progressBar = nil currentTab?.chromeDelegate = nil - currentTab?.webView.scrollView.contentInsetAdjustmentBehavior = .never - - addChild(tab) - viewCoordinator.webViewContainer.subviews.forEach { $0.removeFromSuperview() } - viewCoordinator.webViewContainer.addSubview(tab.view) - tab.view.frame = self.viewCoordinator.webViewContainer.bounds - tab.didMove(toParent: self) - + + addToContentContainer(controller: tab) + viewCoordinator.logoContainer.isHidden = true - viewCoordinator.contentContainer.isHidden = true tab.progressWorker.progressBar = viewCoordinator.progress chromeManager.attach(to: tab.webView.scrollView) @@ -1365,7 +1359,8 @@ extension MainViewController: BrowserChromeDelegate { + keyboardHeight } - webView.scrollView.contentInset = .init(top: top, left: 0, bottom: bottom, right: 0) + // webView.scrollView.contentInset = .init(top: top, left: 0, bottom: bottom, right: 0) + // webView.invalidateIntrinsicContentSize() } func setNavigationBarHidden(_ hidden: Bool) { @@ -1733,7 +1728,7 @@ extension MainViewController: TabDelegate { guard self.tabManager.model.tabs.contains(newTab.tabModel) else { return } self.dismissOmniBar() - self.addToWebViewContainer(tab: newTab) + self.attachTab(tab: newTab) self.refreshOmniBar() }