-
Notifications
You must be signed in to change notification settings - Fork 120
[Just in Time Messages] Add Modal JITM template support for Tap to Pay campaign #9694
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
19e5f98
Remove unneeded ttl property from JITM
joshheald 17ae3b2
Parse `template` from JITM API response
joshheald 3470b31
9679 Add `template` to JITM display model
joshheald 2e58417
9679 Show modal JITM (temp)
joshheald 8e0733f
Move AnimatedPlaceholder to a file
joshheald 033c98c
9679 Add ModalOverlay presentation style
joshheald 1e34a9d
Improve contrast of overlay modal in dark mode
joshheald 86d115f
Remove Fakes in preview as it broke device builds
joshheald 5fb31d1
Fix opening universal links from modal JITMs
joshheald e7d2e13
9679 Fix webview presentation from modal JITM CTA
joshheald f18623a
9679 Add modal JITMs to 13.6 release notes
joshheald 30d3fa4
9679 Bump modal JITMs to 13.7
joshheald 7523696
9679 Dismiss JITMs when empty response recieved
joshheald 9061b61
9679 Dismiss modal JITMs before showing a webview
joshheald 0db1ec5
Merge branch 'trunk' into issue/9679-modal-JITMs
joshheald ac17696
Prevent multiple re-display of JITM after webview
joshheald 8a13be0
Fix pre-webview dismissal from modal JITMs
joshheald 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
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ import UIKit | |
| import Yosemite | ||
| import Combine | ||
|
|
||
| final class JustInTimeMessageAnnouncementCardViewModel: AnnouncementCardViewModelProtocol { | ||
| final class JustInTimeMessageViewModel { | ||
| private let siteID: Int64 | ||
|
|
||
| private let analytics: Analytics | ||
|
|
@@ -21,6 +21,8 @@ final class JustInTimeMessageAnnouncementCardViewModel: AnnouncementCardViewMode | |
| private let justInTimeMessage: JustInTimeMessage | ||
|
|
||
| // MARK: - Message properties | ||
| let template: JustInTimeMessageTemplate | ||
|
|
||
| let title: String | ||
|
|
||
| let message: String | ||
|
|
@@ -31,6 +33,8 @@ final class JustInTimeMessageAnnouncementCardViewModel: AnnouncementCardViewMode | |
|
|
||
| let imageDarkUrl: URL? | ||
|
|
||
| let badgeType: BadgeView.BadgeType? | ||
|
|
||
| private let url: URL? | ||
|
|
||
| private let messageID: String | ||
|
|
@@ -59,6 +63,7 @@ final class JustInTimeMessageAnnouncementCardViewModel: AnnouncementCardViewMode | |
| self.featureClass = justInTimeMessage.featureClass | ||
| self.justInTimeMessage = justInTimeMessage | ||
| self.screenName = screenName | ||
| self.template = justInTimeMessage.template | ||
| self.title = justInTimeMessage.title | ||
| self.message = justInTimeMessage.detail | ||
| self.buttonTitle = justInTimeMessage.buttonTitle | ||
|
|
@@ -83,42 +88,18 @@ final class JustInTimeMessageAnnouncementCardViewModel: AnnouncementCardViewMode | |
| }.store(in: &cancellables) | ||
| } | ||
|
|
||
| // MARK: - default AnnouncementCardViewModelProtocol conformance | ||
| let showDividers: Bool = false | ||
|
|
||
| let badgeType: BadgeView.BadgeType? | ||
|
|
||
| let image: UIImage = .paymentsFeatureBannerImage | ||
|
|
||
| var showDismissConfirmation: Bool = false | ||
|
|
||
| let dismissAlertTitle: String = "" | ||
|
|
||
| let dismissAlertMessage: String = "" | ||
|
|
||
| // MARK: - AnnouncementCardViewModelProtocol methods | ||
| func onAppear() { | ||
| analytics.track(event: .JustInTimeMessage.messageDisplayed(source: screenName, | ||
| messageID: messageID, | ||
| featureClass: featureClass)) | ||
| } | ||
|
|
||
| // MARK: - Actions | ||
| func ctaTapped() { | ||
| analytics.track(event: .JustInTimeMessage.callToActionTapped(source: screenName, | ||
| messageID: messageID, | ||
| featureClass: featureClass)) | ||
|
|
||
| trackCtaTapped() | ||
| guard let url = url else { | ||
| return | ||
| } | ||
|
|
||
| urlRouter.handle(url: url) | ||
| } | ||
|
|
||
| func dontShowAgainTapped() { | ||
| analytics.track(event: .JustInTimeMessage.dismissTapped(source: screenName, | ||
| messageID: messageID, | ||
| featureClass: featureClass)) | ||
| func dismissTapped() { | ||
| trackDismissTapped() | ||
| let action = JustInTimeMessageAction.dismissMessage(justInTimeMessage, | ||
| siteID: siteID, | ||
| completion: { result in | ||
|
|
@@ -142,7 +123,65 @@ final class JustInTimeMessageAnnouncementCardViewModel: AnnouncementCardViewMode | |
| stores.dispatch(action) | ||
| } | ||
|
|
||
| // MARK: - Analytics | ||
| private func trackMessageDisplayed() { | ||
| analytics.track(event: .JustInTimeMessage.messageDisplayed(source: screenName, | ||
| messageID: messageID, | ||
| featureClass: featureClass)) | ||
| } | ||
|
|
||
| private func trackCtaTapped() { | ||
| analytics.track(event: .JustInTimeMessage.callToActionTapped(source: screenName, | ||
| messageID: messageID, | ||
| featureClass: featureClass)) | ||
| } | ||
|
|
||
| private func trackDismissTapped() { | ||
| analytics.track(event: .JustInTimeMessage.dismissTapped(source: screenName, | ||
| messageID: messageID, | ||
| featureClass: featureClass)) | ||
| } | ||
| } | ||
|
|
||
|
|
||
| extension JustInTimeMessageViewModel: AnnouncementCardViewModelProtocol { | ||
|
Contributor
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. TIL that we cannot make this extension's access control private because is declaring protocol conformances, it makes sense, but I didn't realized until the compiler told me :D |
||
| // MARK: - default AnnouncementCardViewModelProtocol conformance | ||
| var showDividers: Bool { false } | ||
|
|
||
| var image: UIImage { .paymentsFeatureBannerImage } | ||
|
|
||
| var showDismissConfirmation: Bool { false } | ||
|
|
||
| var dismissAlertTitle: String { | ||
| switch template { | ||
| case .modal: | ||
| return Localization.maybeLaterButton | ||
| default: | ||
| return "" | ||
| } | ||
| } | ||
|
|
||
| var dismissAlertMessage: String { "" } | ||
|
|
||
| // MARK: - AnnouncementCardViewModelProtocol methods | ||
| func onAppear() { | ||
| trackMessageDisplayed() | ||
| } | ||
|
|
||
| func dontShowAgainTapped() { | ||
| dismissTapped() | ||
| } | ||
|
|
||
| func remindLaterTapped() { | ||
| // No-op | ||
| } | ||
| } | ||
|
|
||
| private extension JustInTimeMessageViewModel { | ||
| enum Localization { | ||
| static let maybeLaterButton = NSLocalizedString( | ||
| "Maybe Later", | ||
| comment: "Dismiss button title for modally presented Just in Time Messages" | ||
| ) | ||
| } | ||
| } | ||
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.
Much cleaner for tests 💯