This repository has been archived by the owner on May 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
7 changed files
with
217 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
Client/Frontend/Browser/Onboarding/OnboardingPrivacyConsentView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
import Foundation | ||
import Shared | ||
import BraveShared | ||
import pop | ||
import SnapKit | ||
|
||
extension OnboardingPrivacyConsentViewController { | ||
|
||
class View: UIView { | ||
|
||
let yesConsentButton = CommonViews.primaryButton(text: Strings.OBPrivacyConsentYesButton).then { | ||
$0.accessibilityIdentifier = "OnboardingPrivacyConsentViewController.YesButton" | ||
$0.titleLabel?.adjustsFontSizeToFitWidth = true | ||
} | ||
|
||
let noConsentButton = CommonViews.secondaryButton(text: Strings.OBPrivacyConsentNoButton).then { | ||
$0.accessibilityIdentifier = "OnboardingPrivacyConsentViewController.NoButton" | ||
$0.titleLabel?.adjustsFontSizeToFitWidth = true | ||
} | ||
|
||
private let mainStackView = UIStackView().then { | ||
$0.axis = .vertical | ||
$0.distribution = .equalSpacing | ||
} | ||
|
||
private let braveLogo = UIImageView(image: #imageLiteral(resourceName: "browser_lock_popup")).then { | ||
$0.contentMode = .scaleAspectFit | ||
} | ||
|
||
private let titleLabel = CommonViews.primaryText(Strings.OBPrivacyConsentTitle).then { | ||
$0.font = .systemFont(ofSize: 20, weight: .semibold) | ||
$0.numberOfLines = 0 | ||
} | ||
|
||
private let refProgramLabel = UILabel().then { | ||
$0.text = Strings.OBPrivacyConsentDetail | ||
$0.font = .systemFont(ofSize: 16, weight: .regular) | ||
$0.numberOfLines = 0 | ||
$0.textAlignment = .left | ||
$0.minimumScaleFactor = 0.7 | ||
} | ||
|
||
init(theme: Theme) { | ||
super.init(frame: .zero) | ||
|
||
mainStackView.tag = OnboardingViewAnimationID.detailsContent.rawValue | ||
braveLogo.tag = OnboardingViewAnimationID.background.rawValue | ||
|
||
applyTheme(theme) | ||
|
||
mainStackView.addStackViewItems( | ||
.view(.spacer(.vertical, amount: 1)), | ||
.view(braveLogo), | ||
.view( | ||
UIStackView(arrangedSubviews: [titleLabel, refProgramLabel]).then { | ||
$0.axis = .vertical | ||
$0.spacing = 24 | ||
}), | ||
.view(UIStackView(arrangedSubviews: [yesConsentButton, noConsentButton]).then { | ||
$0.axis = .vertical | ||
$0.spacing = 8 | ||
}) | ||
) | ||
|
||
addSubview(mainStackView) | ||
|
||
mainStackView.snp.makeConstraints { | ||
$0.top.equalTo(safeArea.top).inset(24) | ||
$0.bottom.equalTo(safeArea.bottom).inset(16) | ||
$0.leading.trailing.equalToSuperview().inset(25) | ||
} | ||
} | ||
|
||
@available(*, unavailable) | ||
required init(coder: NSCoder) { fatalError() } | ||
|
||
func applyTheme(_ theme: Theme) { | ||
backgroundColor = OnboardingViewController.colorForTheme(theme) | ||
titleLabel.appearanceTextColor = theme.colors.tints.home | ||
refProgramLabel.appearanceTextColor = theme.colors.tints.home | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
Client/Frontend/Browser/Onboarding/OnboardingPrivacyConsentViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
import UIKit | ||
import BraveShared | ||
import Shared | ||
|
||
private let log = Logger.browserLogger | ||
|
||
class OnboardingPrivacyConsentViewController: OnboardingViewController { | ||
|
||
private var contentView: View { | ||
return view as! View // swiftlint:disable:this force_cast | ||
} | ||
|
||
override func loadView() { | ||
view = View(theme: theme) | ||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
contentView.yesConsentButton.addTarget(self, action: #selector(yesConsentTapped), for: .touchUpInside) | ||
contentView.noConsentButton.addTarget(self, action: #selector(noConsentTaapped), for: .touchUpInside) | ||
} | ||
|
||
@objc func yesConsentTapped() { | ||
presentNextScreen(withPrivacyConsent: true) | ||
} | ||
|
||
@objc func noConsentTaapped() { | ||
presentNextScreen(withPrivacyConsent: false) | ||
} | ||
|
||
private func presentNextScreen(withPrivacyConsent: Bool) { | ||
Preferences.General.basicOnboardingProgress.value = OnboardingProgress.privacyConsent.rawValue | ||
if let urp = UserReferralProgram.shared { | ||
(UIApplication.shared.delegate as? AppDelegate)? | ||
.handleReferralLookup(urp, checkClipboard: withPrivacyConsent) | ||
} | ||
|
||
delegate?.presentNextScreen(current: self) | ||
} | ||
|
||
override func applyTheme(_ theme: Theme) { | ||
styleChildren(theme: theme) | ||
contentView.applyTheme(theme) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters