-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modal for Duck Player experiment (#3163)
Task/Issue URL: https://app.asana.com/0/1204167627774280/1208057428394427/f **Description**: Implement the onboarding screen for the Duck Player experiment on macOS
- Loading branch information
Showing
31 changed files
with
1,420 additions
and
11 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...DuckGo/Assets.xcassets/Images/DuckPlayer/DuckPlayerOnboardingModal.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" : "DuckPlayerConsentModal.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+4 KB
....xcassets/Images/DuckPlayer/DuckPlayerOnboardingModal.imageset/DuckPlayerConsentModal.pdf
Binary file not shown.
12 changes: 12 additions & 0 deletions
12
...kGo/Assets.xcassets/Images/DuckPlayer/DuckPlayerOnboardingModalDax.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" : "DuckPlayerConsentModalDax.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+16.5 KB
...ets/Images/DuckPlayer/DuckPlayerOnboardingModalDax.imageset/DuckPlayerConsentModalDax.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
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
76 changes: 76 additions & 0 deletions
76
DuckDuckGo/Tab/TabExtensions/DuckPlayerOnboardingTabExtension.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,76 @@ | ||
// | ||
// DuckPlayerOnboardingTabExtension.swift | ||
// | ||
// Copyright © 2024 DuckDuckGo. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Foundation | ||
import Navigation | ||
import Combine | ||
|
||
typealias DuckPlayerOnboardingPublisher = AnyPublisher<OnboardingState?, Never> | ||
|
||
final class DuckPlayerOnboardingTabExtension: TabExtension { | ||
@Published private(set) var onboardingState: OnboardingState? | ||
private let onboardingDecider: DuckPlayerOnboardingDecider | ||
|
||
init(onboardingDecider: DuckPlayerOnboardingDecider) { | ||
self.onboardingDecider = onboardingDecider | ||
} | ||
} | ||
|
||
extension DuckPlayerOnboardingTabExtension: NavigationResponder { | ||
|
||
func navigationDidFinish(_ navigation: Navigation) { | ||
guard onboardingDecider.canDisplayOnboarding else { return } | ||
|
||
let locationValidator = DuckPlayerOnboardingLocationValidator() | ||
|
||
Task { @MainActor in | ||
if let webView = navigation.navigationAction.targetFrame?.webView, | ||
await locationValidator.isValidLocation(webView) { | ||
onboardingState = .init(onboardingDecider: onboardingDecider) | ||
} | ||
} | ||
} | ||
} | ||
|
||
struct OnboardingState { | ||
let onboardingDecider: DuckPlayerOnboardingDecider | ||
} | ||
|
||
protocol DuckPlayerOnboardingProtocol: AnyObject, NavigationResponder { | ||
var duckPlayerOnboardingPublisher: DuckPlayerOnboardingPublisher { get } | ||
} | ||
|
||
extension DuckPlayerOnboardingTabExtension: DuckPlayerOnboardingProtocol { | ||
func getPublicProtocol() -> DuckPlayerOnboardingProtocol { self } | ||
|
||
var duckPlayerOnboardingPublisher: DuckPlayerOnboardingPublisher { | ||
self.$onboardingState.eraseToAnyPublisher() | ||
} | ||
} | ||
|
||
extension TabExtensions { | ||
var duckPlayerOnboarding: DuckPlayerOnboardingProtocol? { | ||
resolve(DuckPlayerOnboardingTabExtension.self) | ||
} | ||
} | ||
|
||
extension Tab { | ||
var duckPlayerOnboardingPublisher: DuckPlayerOnboardingPublisher { | ||
self.duckPlayerOnboarding?.duckPlayerOnboardingPublisher ?? Just(nil).eraseToAnyPublisher() | ||
} | ||
} |
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
Oops, something went wrong.