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 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix#7792: Add cookie consent notice popup (#7890)
- Loading branch information
Showing
14 changed files
with
230 additions
and
3 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
6 changes: 6 additions & 0 deletions
6
Sources/Onboarding/Assets/Images.xcassets/CookieConsent/Contents.json
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,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+18 KB
...s.xcassets/CookieConsent/cookie-consent-background.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16.8 KB
...ges.xcassets/CookieConsent/cookie-consent-background.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+29.2 KB
...s.xcassets/CookieConsent/cookie-consent-background.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+26.4 KB
...ges.xcassets/CookieConsent/cookie-consent-background.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions
57
...ing/Assets/Images.xcassets/CookieConsent/cookie-consent-background.imageset/Contents.json
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,57 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "dark" | ||
} | ||
], | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "dark" | ||
} | ||
], | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "dark" | ||
} | ||
], | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "original" | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...nboarding/Assets/Images.xcassets/CookieConsent/cookie-consent-icon.imageset/Contents.json
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,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "cookie.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+252 KB
...s/Onboarding/Assets/Images.xcassets/CookieConsent/cookie-consent-icon.imageset/cookie.pdf
Binary file not shown.
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
91 changes: 91 additions & 0 deletions
91
Sources/Onboarding/ProductNotifications/CookieNotificationBlockingConsentView.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,91 @@ | ||
// Copyright 2023 The Brave Authors. All rights reserved. | ||
// 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 https://mozilla.org/MPL/2.0/. | ||
|
||
import SwiftUI | ||
import Strings | ||
import DesignSystem | ||
import BraveShared | ||
import Growth | ||
import BraveUI | ||
|
||
public struct CookieNotificationBlockingConsentView: View { | ||
public static let contentHeight = 400.0 | ||
public static let contentWidth = 344.0 | ||
private static let textPadding = 24.0 | ||
@Environment(\.presentationMode) @Binding private var presentationMode | ||
|
||
public var body: some View { | ||
ScrollView { | ||
VStack(alignment: .center, spacing: 48) { | ||
VStack(alignment: .center, spacing: Self.textPadding) { | ||
Image("cookie-consent-icon", bundle: .module) | ||
.resizable() | ||
.frame(width: 48, height: 48) | ||
|
||
Text(Strings.blockCookieConsentNoticesPopupTitle).font(.title) | ||
Text(Strings.blockCookieConsentNoticesPopupDescription).font(.body) | ||
} | ||
.padding(Self.textPadding) | ||
.foregroundColor(Color(UIColor.braveLabel)) | ||
.multilineTextAlignment(.center) | ||
.fixedSize(horizontal: false, vertical: true) | ||
|
||
Button(Strings.blockCookieConsentNoticesDismissButtonTitle, | ||
action: { | ||
presentationMode.dismiss() | ||
} | ||
) | ||
.buttonStyle(BraveFilledButtonStyle(size: .large)) | ||
.multilineTextAlignment(.center) | ||
} | ||
} | ||
.frame(width: Self.contentWidth, height: Self.contentHeight) | ||
.background( | ||
Image("cookie-consent-background", bundle: .module), | ||
alignment: .bottomLeading | ||
) | ||
.background(Color(UIColor.braveBackground)) | ||
.onAppear { | ||
recordCookieListPromptP3A(answer: .seen) | ||
} | ||
} | ||
|
||
private enum P3AAnswer: Int, CaseIterable { | ||
case seen = 1 | ||
} | ||
|
||
private func recordCookieListPromptP3A(answer: P3AAnswer) { | ||
// Q68 If you have viewed the cookie consent block prompt, how did you react? | ||
UmaHistogramEnumeration("Brave.Shields.CookieListPrompt", sample: answer) | ||
} | ||
} | ||
|
||
#if DEBUG | ||
struct CookieNotificationBlockingConsentView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
CookieNotificationBlockingConsentView() | ||
} | ||
} | ||
#endif | ||
|
||
public class CookieNotificationBlockingConsentViewController: UIHostingController<CookieNotificationBlockingConsentView>, PopoverContentComponent { | ||
public init() { | ||
super.init(rootView: CookieNotificationBlockingConsentView()) | ||
|
||
self.preferredContentSize = CGSize( | ||
width: CookieNotificationBlockingConsentView.contentWidth, | ||
height: CookieNotificationBlockingConsentView.contentHeight | ||
) | ||
} | ||
|
||
required init?(coder aDecoder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
public override func viewDidLoad() { | ||
super.viewDidLoad() | ||
view.backgroundColor = UIColor.braveBackground | ||
} | ||
} |
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