Skip to content

Commit

Permalink
tweak page position
Browse files Browse the repository at this point in the history
  • Loading branch information
brindy committed Jan 18, 2024
1 parent e1467ff commit ae86238
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
19 changes: 0 additions & 19 deletions DuckDuckGo/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class MainViewFactory {
extension MainViewFactory {

private func createViews() {
createWebViewContainer()
createLogoBackground()
createContentContainer()
createSuggestionTrayContainer()
Expand All @@ -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)
Expand Down Expand Up @@ -163,7 +156,6 @@ extension MainViewFactory {
extension MainViewFactory {

private func constrainViews() {
constrainWebViewContainer()
constrainLogoBackground()
constrainContentContainer()
constrainSuggestionTrayContainer()
Expand All @@ -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!
Expand Down Expand Up @@ -351,7 +333,6 @@ class MainViewCoordinator {
var toolbarFireButton: UIBarButtonItem!
var toolbarForwardButton: UIBarButtonItem!
var toolbarTabSwitcherButton: UIBarButtonItem!
var webViewContainer: UIView!

let constraints = Constraints()

Expand Down
25 changes: 10 additions & 15 deletions DuckDuckGo/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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()
}

Expand Down

0 comments on commit ae86238

Please sign in to comment.