-
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
base: main
Are you sure you want to change the base?
Conversation
269b7a5
to
52a86be
Compare
b3b001b
to
3fb8ec2
Compare
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.
Hey @jotaemepereira! The message works nicely but l've found a bug in HTML NTP and also wanted to suggest some changes in the view to better support localization. Please have a look, thanks!
}) | ||
) | ||
.onAppear(perform: { onAppear() }) | ||
.frame(width: 147) |
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.
How would that behave with translations? Are we fine with truncating the text?
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.
This was fixed. Now, both the button and the popover will resize accordingly.
.buttonStyle(DefaultActionButtonStyle( | ||
enabled: true, | ||
onClose: { onClose() }, | ||
onHoverStart: { | ||
onHover() | ||
}, | ||
onHoverEnd: { | ||
onHoverEnd() | ||
}) | ||
) | ||
.onAppear(perform: { onAppear() }) |
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.
You could simplify this a bit by passing closures directly as arguments:
.buttonStyle(DefaultActionButtonStyle( | |
enabled: true, | |
onClose: { onClose() }, | |
onHoverStart: { | |
onHover() | |
}, | |
onHoverEnd: { | |
onHoverEnd() | |
}) | |
) | |
.onAppear(perform: { onAppear() }) | |
.buttonStyle(DefaultActionButtonStyle(enabled: true, onClose: onClose, onHoverStart: onHover, onHoverEnd: onHoverEnd)) | |
.onAppear(perform: onAppear) |
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.
This button style was removed.
import SwiftUI | ||
|
||
struct TabBarRemoteMessageView: View { | ||
@State private var presentPopup: Bool = false |
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.
This seems unused
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.
I removed it.
enum Constants { | ||
static let height: CGFloat = 92 | ||
static let width: CGFloat = 360 | ||
} |
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.
Again, would be great to test it with long message bodies. Perhaps we'd want a variable height. The icon should probably stay aligned to the top, like in other remote messages.
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.
This was fixed, now we do not have fixed a fixed height for the popover, the popover will increase in height in case it spans more lines.
$remoteMessage.dropFirst().eraseToAnyPublisher() | ||
$remoteMessage | ||
.dropFirst() | ||
.filter { $0?.isForTabBar == false } |
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.
Thanks for updating this check, but here are 2 more things:
- This also needs to allow nil values, so
{ $0?.isForTabBar == false || $0 == nil }
- This is just a publisher.
NewTabPageActiveRemoteMessageProviding
protocol also declaresremoteMessage
accessor which it taken directly fromActiveRemoteMessageModel.remoteMessage
. That one isn't filtered in any way and the tab bar message still appears on HTML NTP.
What we've talked about on MM, i.e. adding 2 more variables to ActiveRemoteMessageModel called e.g. newTabPageRemoteMessage
and tabBarRemoteMessage
that would be updated every time remoteMessage
is updated, by filtering that one appropriately, could help solve the problem here and move the filtering logic to the model.
Note that if you add these additional variables, you should update NewTabPageActiveRemoteMessageProviding
protocol to use newTabPageRemoteMessage
and newTabPageRemoteMessagePublisher
but this should be straightforward.
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.
Done 👍🏼
.padding(.top, 2.5) | ||
.padding(.bottom, 3) | ||
.padding(.horizontal, 7.5) |
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.
Overall I'm not sure if the design wants fraction paddings (or even odd numbers), so perhaps it's worth checking if 2, 4, and 8 would work.
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.
I removed this button style.
onClose: { | ||
self.tabBarRemoteMessageViewModel.onMessageDismissed() | ||
self.removeFeedbackButton() | ||
}, | ||
onTap: { surveyURL in | ||
DispatchQueue.main.async { | ||
WindowControllersManager.shared.showTab(with: .contentFromURL(surveyURL, source: .appOpenUrl)) | ||
} | ||
self.tabBarRemoteMessageViewModel.onSurveyOpened() | ||
self.removeFeedbackButton() | ||
}, | ||
onHover: { | ||
self.startTabBarRemotMessageTimer(message: tabBarRemotMessage) | ||
}, | ||
onHoverEnd: { | ||
self.dismissTabBarRemoteMessagePopover() | ||
}, | ||
onAppear: { | ||
self.tabBarRemoteMessageViewModel.markTabBarRemoteMessageAsShown() |
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.
Passing self in closures to the view that's owned by a controller that's owned by self introduces a reference cycle. It shouldn't be a problem right here but to be on the safe side I'd use weak self.
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.
Done
private func startTabBarRemotMessageTimer(message: TabBarRemoteMessage) { | ||
tabBarRemoteMessagePopoverHoverTimer?.invalidate() | ||
tabBarRemoteMessagePopoverHoverTimer = Timer.scheduledTimer(withTimeInterval: 1.5, repeats: false) { _ in | ||
self.showTabBarRemotePopup(message) |
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.
Same here with weak self
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.
Done
353b532
to
8b91013
Compare
@@ -47,9 +47,9 @@ final class RemoteMessagingClient: RemoteMessagingProcessing { | |||
static let minimumConfigurationRefreshInterval: TimeInterval = 60 * 30 | |||
static let endpoint: URL = { | |||
#if DEBUG | |||
URL(string: "https://raw.githubusercontent.com/duckduckgo/remote-messaging-config/main/samples/ios/sample1.json")! | |||
URL(string: "https://www.jsonblob.com/api/1316017217598578688")! |
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.
.padding(.bottom, 9) | ||
} | ||
} | ||
.frame(width: 360) |
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.
ℹ️ Now, we only fix the width of the popover; if the text is larger, the popover should increase its height.
This PR has been inactive for more than 7 days and will be automatically closed 7 days from now. |
Task/Issue URL: https://app.asana.com/0/1204006570077678/1208970712110808/f
Tech Design URL:
CC:
Description
Adds a new remote message that is shown in the tab bar.
Steps to test this PR:
RemoteMessagingClient
and change the DEBUG endpoint URL tohttps://www.jsonblob.com/api/1316017217598578688
Definition of Done:
—
Internal references:
Pull Request Review Checklist
Software Engineering Expectations
Technical Design Template
Pull Request Documentation