-
Notifications
You must be signed in to change notification settings - Fork 11
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
Implement tab bar remote message #3665
Open
jotaemepereira
wants to merge
24
commits into
main
Choose a base branch
from
juan/poc-new-user-feedfack-point-of-action
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
3283e6e
Implement tab bar remote message
jotaemepereira 2a880c0
Change production URL
jotaemepereira 62c8426
Add JSON to be used as debug
jotaemepereira aa916e3
Use raw JSON
jotaemepereira 3f07a6d
Make button as tall as the tab bar
jotaemepereira 2cf6e71
Minor feedback
jotaemepereira 2b74542
More improvements
jotaemepereira ecc4860
Update JSON link
jotaemepereira 3dadbce
Fix JSON
jotaemepereira 0499ff2
Add unit tests
jotaemepereira 472e37e
Revert JSON changes
jotaemepereira 52a86be
Remove URL extension
jotaemepereira 5aca880
Fix deallocation issue
jotaemepereira ba6eadf
Fix filtering on remote message NTP
jotaemepereira 5e8c3b9
Move models to RemoteMessaging folder
jotaemepereira 3fb8ec2
Create TabBarRemoteMessagePresentable
jotaemepereira 4914438
Push JSON
jotaemepereira f8252d1
Add raw JSON for review build
jotaemepereira f3151be
Address button feedback
jotaemepereira cde71c3
Make popover resize automatically
jotaemepereira d68d8a4
Implement new button designs
jotaemepereira 8b91013
Use weak self on closures
jotaemepereira d56ee4d
Create two publishers: one for NTP and another for tab bar
jotaemepereira 7d54df2
Address minor design feedback around margins
jotaemepereira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
DuckDuckGo/Assets.xcassets/Images/dax-response.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" : "Response-DDG-Question-96x96.svg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...Go/Assets.xcassets/Images/dax-response.imageset/Response-DDG-Question-96x96.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
52 changes: 52 additions & 0 deletions
52
DuckDuckGo/RemoteMessaging/TabBarActiveRemoteMessage.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,52 @@ | ||
// | ||
// TabBarActiveRemoteMessage.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 Combine | ||
import RemoteMessaging | ||
|
||
protocol TabBarRemoteMessageProviding { | ||
var remoteMessagePublisher: AnyPublisher<RemoteMessageModel?, Never> { get } | ||
|
||
func markRemoteMessageAsShown() async | ||
func onSurveyOpened() async | ||
func onMessageDismissed() async | ||
} | ||
|
||
final class TabBarActiveRemoteMessage: TabBarRemoteMessageProviding { | ||
private let activeRemoteMessageModel: ActiveRemoteMessageModel | ||
|
||
var remoteMessagePublisher: AnyPublisher<RemoteMessageModel?, Never> { | ||
activeRemoteMessageModel.$tabBarRemoteMessage.eraseToAnyPublisher() | ||
} | ||
|
||
init(activeRemoteMessageModel: ActiveRemoteMessageModel) { | ||
self.activeRemoteMessageModel = activeRemoteMessageModel | ||
} | ||
|
||
func markRemoteMessageAsShown() async { | ||
await activeRemoteMessageModel.markRemoteMessageAsShown() | ||
} | ||
|
||
func onSurveyOpened() async { | ||
await activeRemoteMessageModel.dismissRemoteMessage(with: .primaryAction) | ||
} | ||
|
||
func onMessageDismissed() async { | ||
await activeRemoteMessageModel.dismissRemoteMessage(with: .close) | ||
} | ||
} |
118 changes: 118 additions & 0 deletions
118
DuckDuckGo/RemoteMessaging/TabBarRemoteMessageView.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,118 @@ | ||
// | ||
// TabBarRemoteMessageView.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 SwiftUI | ||
|
||
struct TabBarRemoteMessageView: View { | ||
@State private var wasViewHovered: Bool = false | ||
@State private var wasCloseButtonHovered: Bool = false | ||
|
||
let model: TabBarRemoteMessage | ||
|
||
let onClose: () -> Void | ||
let onTap: (URL) -> Void | ||
let onHover: () -> Void | ||
let onHoverEnd: () -> Void | ||
let onAppear: () -> Void | ||
|
||
var body: some View { | ||
HStack(spacing: 0) { | ||
HStack { | ||
Text(model.buttonTitle) | ||
.font(.system(size: 13)) | ||
.fixedSize(horizontal: true, vertical: false) | ||
.foregroundColor(.white) | ||
} | ||
.padding([.leading, .top, .bottom], 8) | ||
.padding(.trailing, 6) | ||
.cornerRadius(8) | ||
.background(wasViewHovered | ||
? Color("PrimaryButtonHover") | ||
: Color("PrimaryButtonRest")) | ||
.onTapGesture { onTap(model.surveyURL) } | ||
.onHover { hovering in | ||
wasViewHovered = hovering | ||
|
||
if hovering { | ||
onHover() | ||
} else { | ||
onHoverEnd() | ||
} | ||
} | ||
|
||
Divider() | ||
.background(Color.white.opacity(0.3)) | ||
.frame(width: 1) | ||
.padding([.top, .bottom], 3) | ||
|
||
HStack { | ||
Image(.close) | ||
.resizable() | ||
.scaledToFit() | ||
.foregroundColor(.white) | ||
.frame(width: 16, height: 16) | ||
} | ||
.padding([.top, .bottom]) | ||
.padding([.leading, .trailing], 4) | ||
.background(wasCloseButtonHovered | ||
? Color("PrimaryButtonHover") | ||
: Color("PrimaryButtonRest")) | ||
.cornerRadius(8) | ||
.onTapGesture { | ||
onClose() | ||
} | ||
.onHover { hovering in | ||
wasCloseButtonHovered = hovering | ||
} | ||
.frame(maxWidth: .infinity) | ||
} | ||
.background(wasCloseButtonHovered || wasViewHovered | ||
? Color("PrimaryButtonHover") | ||
: Color("PrimaryButtonRest")) | ||
.frame(height: 24) | ||
.cornerRadius(8) | ||
.onAppear(perform: { onAppear() }) | ||
} | ||
} | ||
|
||
struct TabBarRemoteMessagePopoverContent: View { | ||
let model: TabBarRemoteMessage | ||
|
||
var body: some View { | ||
HStack(alignment: .center, spacing: 12) { | ||
Image(.daxResponse) | ||
.resizable() | ||
.scaledToFit() | ||
.frame(width: 72, height: 72) | ||
|
||
VStack(alignment: .leading, spacing: 8) { | ||
Text(model.popupTitle) | ||
.font(.system(size: 13, weight: .bold)) | ||
.padding(.top, 9) | ||
|
||
Text(model.popupSubtitle) | ||
.font(.system(size: 13, weight: .medium)) | ||
.padding(.bottom, 9) | ||
} | ||
} | ||
.frame(width: 360) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ Now, we only fix the width of the popover; if the text is larger, the popover should increase its height. |
||
.padding([.top, .bottom], 10) | ||
.padding(.leading, 12) | ||
.padding(.trailing, 24) | ||
} | ||
} |
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,26 @@ | ||
// | ||
// TabBarRemoteMessage.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. | ||
// | ||
|
||
struct TabBarRemoteMessage { | ||
static let tabBarPermanentSurveyRemoteMessageId = "macos_permanent_survey_tab_bar" | ||
|
||
let buttonTitle: String | ||
let popupTitle: String | ||
let popupSubtitle: String | ||
let surveyURL: URL | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.