Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Altering 3PA Controller view
Browse files Browse the repository at this point in the history
  • Loading branch information
soner-yuksel committed Nov 2, 2022
1 parent 2f5817f commit 90b13e0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ extension BrowserViewController {

// let onboardingP3ACalloutController = WelcomeViewController(p3aUtilities: braveCore.p3aUtils)

let onboardingP3ACalloutController = Welcome3PAViewController(p3aUtilities: braveCore.p3aUtils)
let onboardingP3ACalloutController = Welcome3PAViewController().then {
$0.isModalInPresentation = true
$0.modalPresentationStyle = .overFullScreen
}

let state = WelcomeViewCalloutState.p3a(
info: WelcomeViewCalloutState.WelcomeViewDefaultBrowserDetails(
Expand All @@ -66,7 +69,7 @@ extension BrowserViewController {
onboardingP3ACalloutController.setLayoutState(state: state)

if !isOnboardingOrFullScreenCalloutPresented {
present(onboardingP3ACalloutController, animated: true)
present(onboardingP3ACalloutController, animated: false)
}
}

Expand Down
89 changes: 22 additions & 67 deletions Sources/Onboarding/Welcome/Welcome3PAViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,9 @@ import BraveUI
import BraveCore

public class Welcome3PAViewController: UIViewController {

private let backgroundView = UIView()
private let calloutView = WelcomeViewCallout()

private let p3aUtilities: BraveP3AUtils

public init(p3aUtilities: BraveP3AUtils) {
self.p3aUtilities = p3aUtilities
super.init(nibName: nil, bundle: nil)

self.modalPresentationStyle = .fullScreen
self.loadViewIfNeeded()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
private let contentView = WelcomeViewCallout().then {
$0.isBottomArrowHidden = true
}

public override func viewDidLoad() {
Expand All @@ -36,61 +23,29 @@ public class Welcome3PAViewController: UIViewController {
}

view.addSubview(backgroundView)
backgroundView.snp.makeConstraints {
$0.edges.equalToSuperview()
}

view.addSubview(calloutView)
calloutView.snp.makeConstraints {

$0.leading.trailing.equalToSuperview()

$0.centerY.centerX.equalToSuperview()
// $0.bottom.equalTo(view.safeAreaLayoutGuide.snp.bottom).inset(16)
backgroundView.snp.makeConstraints { $0.edges.equalToSuperview() }

view.addSubview(contentView)
contentView.snp.makeConstraints {
if traitCollection.verticalSizeClass == .regular
&& traitCollection.horizontalSizeClass == .compact {
$0.leading.trailing.greaterThanOrEqualTo(view)
} else {
$0.width.lessThanOrEqualTo(BraveUX.baseDimensionValue)
}

$0.centerX.centerY.equalToSuperview()
}

let tapGesture = UITapGestureRecognizer(target: self, action: #selector(backgroundTapped))
backgroundView.addGestureRecognizer(tapGesture)
}


@objc func backgroundTapped() {
dismiss(animated: false)
}

public func setLayoutState(state: WelcomeViewCalloutState) {
calloutView.setState(state: state)
contentView.setState(state: state)
}
}


//// calloutView.do {
//// $0.setContentHuggingPriority(.init(rawValue: 5), for: .vertical)
//// }
//
// let backgroundView = UIView().then {
// $0.backgroundColor = UIColor.black.withAlphaComponent(0.3)
// }
//
// view.addSubview(backgroundView)
// backgroundView.snp.makeConstraints {
// $0.edges.equalToSuperview()
// }
//
// view.addSubview(calloutView)
// calloutView.snp.makeConstraints {
// $0.leading.trailing.equalToSuperview()
// $0.centerX.centerY.equalToSuperview()
// }
//
//// let stack = UIStackView().then {
//// $0.distribution = .equalSpacing
//// $0.axis = .vertical
//// $0.setContentHuggingPriority(.init(rawValue: 5), for: .vertical)
//// }
////
//// view.addSubview(stack)
//// stack.snp.makeConstraints {
//// $0.leading.trailing.top.equalToSuperview()
//// $0.bottom.equalTo(view.safeAreaLayoutGuide.snp.bottom).inset(16)
//// }
////
//// stack.addStackViewItems(
//// .view(UIView.spacer(.vertical, amount: 1)),
//// .view(calloutView),
//// .view(UIView.spacer(.vertical, amount: 1)))
// }
7 changes: 6 additions & 1 deletion Sources/Onboarding/Welcome/WelcomeViewCallout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,13 @@ class WelcomeViewCallout: UIView {
private var verticalLayoutMargin = UX.verticalLayoutMargin
private var horizontalLayoutMargin = UX.horizontalLayoutMargin

// MARK: - State
private(set) var state: WelcomeViewCalloutState?

var isBottomArrowHidden: Bool = false {
didSet {
arrowView.isHidden = isBottomArrowHidden
}
}

init() {
super.init(frame: .zero)
Expand Down

0 comments on commit 90b13e0

Please sign in to comment.