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

[iOS] Tweak new onboarding order & callout (uplift to 1.75.x) #27261

Open
wants to merge 1 commit into
base: 1.75.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,10 @@ extension BrowserViewController {

let defaultBrowserCallout = UIHostingController(
rootView: FocusSystemSettingsView(
namespace: Namespace().wrappedValue,
screenType: .callout,
shouldDismiss: Binding.constant(false)
isCompleted: .constant(false),
shouldDismiss: .constant(false)
)
).then {
$0.isModalInPresentation = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ extension BrowserViewController {
return
}

let frame = view.convert(
topToolbar.locationView.frame,
from: topToolbar.locationView
).insetBy(dx: -1.0, dy: -1.0)

var controller: UIViewController & PopoverContentComponent

if !Locale.current.isNewOnboardingRegion {
Expand Down Expand Up @@ -123,28 +118,55 @@ extension BrowserViewController {
)
}

presentNTPURLBarPopover(
presentFavouriteURLBarPopover(
controller: controller,
onDismiss: { [weak self] in
guard let self = self else { return }
self.triggerPromotedInAppPurchase(savedPayment: self.iapObserver.savedPayment)
},
onClickURLBar: { [weak self] in
guard let self = self else { return }

DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
self.topToolbar.tabLocationViewDidTapLocation(self.topToolbar.locationView)
}
}
)
}
}

func presentFavouriteURLBarPopover(
controller: UIViewController & PopoverContentComponent,
onDismiss: @escaping () -> Void
) {
guard let info = activeNewTabPageViewController?.onboardingYouTubeFavoriteInfo,
let cellSuperview = info.cell.superview
else { return }
let frame = view.convert(info.cell.frame, from: cellSuperview)
presentPopoverContent(
using: controller,
with: frame,
arrowDistance: -10,
lineWidth: 0,
cornerRadius: topToolbar.locationContainer.layer.cornerRadius,
didDismiss: {
Preferences.FullScreenCallout.omniboxCalloutCompleted.value = true
Preferences.AppState.shouldDeferPromotedPurchase.value = false

onDismiss()
},
didClickBorderedArea: { [unowned self] in
Preferences.FullScreenCallout.omniboxCalloutCompleted.value = true
Preferences.AppState.shouldDeferPromotedPurchase.value = false

self.handleFavoriteAction(favorite: info.favorite, action: .opened())
}
)
}

func presentNTPURLBarPopover(
controller: UIViewController & PopoverContentComponent,
onDismiss: @escaping () -> Void,
onClickURLBar: @escaping () -> Void
) {
let frame = view.convert(
topToolbar.locationView.frame,
from: topToolbar.locationView
).insetBy(dx: -1.0, dy: -1.0)

presentPopoverContent(
using: controller,
with: frame,
Expand Down Expand Up @@ -263,6 +285,8 @@ extension BrowserViewController {
private func presentPopoverContent(
using contentController: UIViewController & PopoverContentComponent,
with frame: CGRect,
arrowDistance: CGFloat = 10,
lineWidth: CGFloat = 2,
cornerRadius: CGFloat,
didDismiss: @escaping () -> Void,
didClickBorderedArea: @escaping () -> Void,
Expand All @@ -272,12 +296,13 @@ extension BrowserViewController {
contentController: contentController,
contentSizeBehavior: .autoLayout(.phoneWidth)
)
popover.arrowDistance = 10.0
popover.arrowDistance = arrowDistance

// Create a border / placeholder view
let borderView = NotificationBorderView(
frame: frame,
cornerRadius: cornerRadius,
lineWidth: lineWidth,
colouredBorder: true
)
let placeholderView = UIView(frame: frame).then {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,20 @@ class NewTabPageViewController: UIViewController {
private var videoAdPlayer: NewTabPageVideoAdPlayer?
private var videoButtonsView = NewTabPageVideoAdButtonsView()

var onboardingYouTubeFavoriteInfo: (favorite: Favorite, cell: UIView)? {
// Get the cell for the youtube from the favs section
let frc = Favorite.frc()
frc.fetchRequest.fetchLimit = 5
try? frc.performFetch()
guard let section = sections.firstIndex(where: { $0 is FavoritesSectionProvider }),
let item = frc.fetchedObjects?.firstIndex(where: { $0.url == "https://m.youtube.com" }),
let cell = collectionView.cellForItem(at: .init(item: item, section: section))
else {
return nil
}
return (frc.fetchedObjects![item], cell)
}

/// A gradient to display over background images to ensure visibility of
/// the NTP contents and sponsored logo
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ public class NotificationBorderView: UIView {

public var didClickBorderedArea: (() -> Void)?

public init(frame: CGRect, cornerRadius: CGFloat, colouredBorder: Bool = false) {
public init(
frame: CGRect,
cornerRadius: CGFloat,
lineWidth: CGFloat = 2,
colouredBorder: Bool = false
) {
let borderLayer = CAShapeLayer().then {
let frame = frame.with { $0.origin = .zero }
$0.strokeColor = colouredBorder ? UIColor.braveLighterBlurple.cgColor : UIColor.white.cgColor
$0.fillColor = UIColor.clear.cgColor
$0.lineWidth = 2.0
$0.lineWidth = lineWidth
$0.strokeEnd = 1.0
$0.path = UIBezierPath(roundedRect: frame, cornerRadius: cornerRadius).cgPath
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public struct FocusOnboardingView: View {
@Environment(\.dismiss) private var dismiss

@State private var shouldDismiss = false
@State private var isSystemSettingsComplete = false
@State private var isSplashViewPresented = true

private let attributionManager: AttributionManager?
Expand All @@ -33,12 +34,23 @@ public struct FocusOnboardingView: View {
if isSplashViewPresented {
FocusSplashScreenView(namespace: namespace)
} else {
FocusSystemSettingsView(
namespace: namespace,
screenType: .onboarding,
isCompleted: $isSystemSettingsComplete,
shouldDismiss: $shouldDismiss
)
}
}
.background {
NavigationLink("", isActive: $isSystemSettingsComplete) {
FocusStepsView(
namespace: namespace,
attributionManager: attributionManager,
p3aUtilities: p3aUtilities,
shouldDismiss: $shouldDismiss
)
.toolbar(.hidden, for: .navigationBar)
}
}
.onAppear {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ struct FocusP3AScreenView: View {
@Environment(\.horizontalSizeClass) private var horizontalSizeClass: UserInterfaceSizeClass?

@State private var isP3AHelpPresented = false
@State private var isSystemSettingsViewPresented = false
@State private var isP3AEnabled: Bool = false

@Binding var shouldDismiss: Bool
Expand Down Expand Up @@ -48,28 +47,15 @@ struct FocusP3AScreenView: View {
.frame(maxWidth: 616, maxHeight: 895)
.shadow(color: .black.opacity(0.1), radius: 18, x: 0, y: 8)
.shadow(color: .black.opacity(0.05), radius: 0, x: 0, y: 1)
FocusStepsPagingIndicator(totalPages: 4, activeIndex: .constant(2))
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color(braveSystemName: .pageBackground))
.background {
NavigationLink("", isActive: $isSystemSettingsViewPresented) {
FocusSystemSettingsView(screenType: .onboarding, shouldDismiss: $shouldDismiss)
}
}
.toolbar(.hidden, for: .navigationBar)
} else {
VStack {
consentp3aContentView
FocusStepsPagingIndicator(totalPages: 4, activeIndex: .constant(2))
.padding(.bottom, 20)
}
.background(Color(braveSystemName: .pageBackground))
.background {
NavigationLink("", isActive: $isSystemSettingsViewPresented) {
FocusSystemSettingsView(screenType: .onboarding, shouldDismiss: $shouldDismiss)
}
}
.toolbar(.hidden, for: .navigationBar)
}
}
Expand Down Expand Up @@ -162,11 +148,11 @@ struct FocusP3AScreenView: View {
Button(
action: {
handleAdCampaignLookupAndDAUPing(isP3AEnabled: p3aUtilities?.isP3AEnabled ?? false)

isSystemSettingsViewPresented = true
Preferences.FocusOnboarding.urlBarIndicatorShowBeShown.value = true
shouldDismiss = true
},
label: {
Text(Strings.FocusOnboarding.continueButtonTitle)
Text(Strings.FocusOnboarding.startBrowseActionButtonTitle)
.font(.body.weight(.semibold))
.foregroundColor(Color(braveSystemName: .schemesOnPrimary))
.dynamicTypeSize(dynamicTypeRange)
Expand Down
Loading
Loading