-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Onboarding Contextual Tutorial Rendering (#3063)
- Loading branch information
1 parent
36bea0c
commit 1e453dd
Showing
12 changed files
with
414 additions
and
32 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
44 changes: 44 additions & 0 deletions
44
...kGo/OnboardingExperiment/ContextualDaxDialogs/ContextualOnboardingBackgroundWrapper.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,44 @@ | ||
// | ||
// ContextualOnboardingBackgroundWrapper.swift | ||
// DuckDuckGo | ||
// | ||
// 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 SwiftUI | ||
|
||
struct ContextualOnboardingBackgroundWrapper<Content: View>: View { | ||
private let content: Content | ||
|
||
init(_ content: Content) { | ||
self.content = content | ||
} | ||
|
||
var body: some View { | ||
content | ||
.padding() | ||
.background(OnboardingBackground()) | ||
} | ||
} | ||
|
||
#Preview { | ||
ContextualOnboardingBackgroundWrapper( | ||
ContextualDaxDialog( | ||
message: .init(string: "Hello World!!!"), | ||
cta: "OK!", | ||
action: {} | ||
) | ||
) | ||
} |
49 changes: 49 additions & 0 deletions
49
DuckDuckGo/OnboardingExperiment/ContextualOnboarding/ContextualDaxDialogsFactory.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,49 @@ | ||
// | ||
// ContextualDaxDialogsFactory.swift | ||
// DuckDuckGo | ||
// | ||
// 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 SwiftUI | ||
|
||
protocol ContextualDaxDialogsFactory { | ||
func makeView(for spec: DaxDialogs.BrowsingSpec, onActionTapped: (() -> Void)?) -> UIViewController | ||
} | ||
|
||
extension ContextualDaxDialogsFactory { | ||
func makeView(for spec: DaxDialogs.BrowsingSpec) -> UIViewController { | ||
self.makeView(for: spec, onActionTapped: nil) | ||
} | ||
} | ||
|
||
// TODO: This will be replaced with the factory that returns the Contextual Dax Dialogs for the new contextual flow | ||
final class ExistingLogicContextualDaxDialogsFactory: ContextualDaxDialogsFactory { | ||
|
||
func makeView(for spec: DaxDialogs.BrowsingSpec, onActionTapped: (() -> Void)?) -> UIViewController { | ||
let contextualDialog = ContextualDaxDialog( | ||
message: spec.message.attributedStringFromMarkdown(color: ThemeManager.shared.currentTheme.daxDialogTextColor), | ||
cta: spec.cta, | ||
action: onActionTapped | ||
) | ||
|
||
let hostingController = UIHostingController(rootView: ContextualOnboardingBackgroundWrapper(contextualDialog)) | ||
if #available(iOS 16.0, *) { | ||
hostingController.sizingOptions = [.intrinsicContentSize] | ||
} | ||
|
||
return hostingController | ||
} | ||
} |
Oops, something went wrong.