Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FXIOS-6706 [v116] Screen Time implementation #15111

Merged
merged 2 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions Client/Frontend/Browser/WebView/WebviewViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import Foundation
import Shared
import WebKit
import ScreenTime

class WebviewViewController: UIViewController, ContentContainable, ScreenshotableView {
private var webView: WKWebView
private let screenTimeController = STWebpageController()
var contentType: ContentType = .webview

init(webView: WKWebView) {
Expand All @@ -21,10 +23,11 @@ class WebviewViewController: UIViewController, ContentContainable, Screenshotabl

override func viewDidLoad() {
super.viewDidLoad()
setupLayout()
setupWebView()
setupScreenTimeController()
}

private func setupLayout() {
private func setupWebView() {
view.addSubview(webView)
webView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
Expand All @@ -35,9 +38,18 @@ class WebviewViewController: UIViewController, ContentContainable, Screenshotabl
])
}

private func setupScreenTimeController() {
addChild(screenTimeController)
screenTimeController.view.frame = webView.frame
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use constraints here as well instead of setting a frame to avoid problems with rotation or other screen size changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok perfect i'm changing it

view.addSubview(screenTimeController.view)
screenTimeController.didMove(toParent: self)
screenTimeController.url = webView.url
}

func update(webView: WKWebView) {
self.webView = webView
setupLayout()
setupWebView()
setupScreenTimeController()
}

// MARK: - ScreenshotableView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class AppSettingsTableViewController: SettingsTableViewController, AppSettingsSc
ThemeSetting(settings: self),
SiriPageSetting(settings: self),
blockpopUpSetting,
NoImageModeSetting(settings: self)
NoImageModeSetting(settings: self),
]

if isSearchBarLocationFeatureEnabled {
Expand Down