-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Introduce free trial countdown pop-up #84049
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
Open
dukenv0307
wants to merge
24
commits into
Expensify:main
Choose a base branch
from
dukenv0307:fix/84022
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
106994b
Introduce free trial countdown pop-up
dukenv0307 f21e45e
add tests
dukenv0307 905d611
update code
dukenv0307 af73253
early return if loading state
dukenv0307 c98fb52
add translations
dukenv0307 ae8600c
update changes
dukenv0307 f3794e2
Merge branch 'main' into fix/84022
dukenv0307 25295e1
Merge branch 'main' into fix/84022
dukenv0307 f44c7f2
update height
dukenv0307 a5aee0d
update style
dukenv0307 9ddf5ba
resolve the conflict
dukenv0307 130e3e2
update nvp key
dukenv0307 ab2b357
Merge branch 'main' into fix/84022
dukenv0307 6d18fcf
add shouldShowProactiveAppReviewModal check in useTrialPaymentReminder
dukenv0307 72790af
Merge branch 'main' into fix/84022
dukenv0307 2771a93
fix issue modal open when create the new workspace
dukenv0307 9b68afb
lint fix
dukenv0307 3f1c0d4
resolve conflict
dukenv0307 646f429
Suppress AppReview modal when another modal is visible
dukenv0307 bfa0e34
Merge branch 'main' into fix/84022
dukenv0307 7713e7f
update shouldShowModal
dukenv0307 192ad78
format
dukenv0307 cbb41d6
move logic to modal manager
dukenv0307 e5aadf3
Merge branch 'main' into fix/84022
dukenv0307 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
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 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 |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| import React from 'react'; | ||
| import {View} from 'react-native'; | ||
| import {useMemoizedLazyIllustrations} from '@hooks/useLazyAsset'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import type {CountdownTime, TrialReminderVariant} from '@hooks/useTrialPaymentReminder'; | ||
| import colors from '@styles/theme/colors'; | ||
| import CONST from '@src/CONST'; | ||
| import Button from './Button'; | ||
| import ImageSVG from './ImageSVG'; | ||
| import Modal from './Modal'; | ||
| import Text from './Text'; | ||
|
|
||
| type TrialPaymentReminderModalProps = { | ||
| /** Whether the modal is visible */ | ||
| isVisible: boolean; | ||
|
|
||
| /** The variant of the modal to display */ | ||
| variant: TrialReminderVariant; | ||
|
|
||
| /** Number of days remaining for 'nearEnd' variant */ | ||
| daysRemaining?: number; | ||
|
|
||
| /** Countdown time for 'countdown' variant */ | ||
| countdownTime?: CountdownTime; | ||
|
|
||
| /** Called when user presses Close */ | ||
| onClose: () => void; | ||
|
|
||
| /** Called when user presses Add payment card */ | ||
| onAddPaymentCard: () => void; | ||
| }; | ||
|
|
||
| function padZero(num: number): string { | ||
| return num.toString().padStart(2, '0'); | ||
| } | ||
|
|
||
| function TrialPaymentReminderModal({isVisible, variant, daysRemaining, countdownTime, onClose, onAddPaymentCard}: TrialPaymentReminderModalProps) { | ||
| const {shouldUseNarrowLayout} = useResponsiveLayout(); | ||
| const styles = useThemeStyles(); | ||
| const illustrations = useMemoizedLazyIllustrations(['ArmWithCardPos']); | ||
| const {translate} = useLocalize(); | ||
|
|
||
| return ( | ||
| <Modal | ||
| onClose={onClose} | ||
| onBackdropPress={() => {}} | ||
| isVisible={isVisible} | ||
| type={shouldUseNarrowLayout ? CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED : CONST.MODAL.MODAL_TYPE.CONFIRM} | ||
| innerContainerStyle={styles.pv0} | ||
| > | ||
| <View style={[styles.alignItemsCenter, styles.wAuto, {backgroundColor: colors.blue800, height: CONST.CONFIRM_CONTENT_SVG_SIZE.HEIGHT}, styles.pb7]}> | ||
| <ImageSVG | ||
| src={illustrations.ArmWithCardPos} | ||
| contentFit="contain" | ||
| /> | ||
| </View> | ||
| <View style={[styles.m5]}> | ||
| {variant === CONST.TRIAL_REMINDER_VARIANT.NEAR_END && daysRemaining !== undefined && ( | ||
| <Text style={[styles.textSuccess, styles.textStrong, styles.mb2]}>{translate('trialPaymentReminder.trialEndsInDays', {days: daysRemaining})}</Text> | ||
| )} | ||
| {variant === CONST.TRIAL_REMINDER_VARIANT.COUNTDOWN && !!countdownTime && ( | ||
| <Text style={[styles.textSuccess, styles.textStrong, styles.mb2]}> | ||
| {translate('trialPaymentReminder.trialEndsCountdown', { | ||
| hours: padZero(countdownTime.hours), | ||
| minutes: padZero(countdownTime.minutes), | ||
| seconds: padZero(countdownTime.seconds), | ||
| })} | ||
| </Text> | ||
| )} | ||
|
|
||
| <Text style={[styles.textHeadlineH1, styles.mb3]}>{translate('trialPaymentReminder.title')}</Text> | ||
| <Text style={[styles.textSupporting]}>{translate('trialPaymentReminder.subtitle')}</Text> | ||
|
|
||
| <Button | ||
| style={[styles.mt5]} | ||
| onPress={onClose} | ||
| text={translate('trialPaymentReminder.closeButton')} | ||
| large | ||
| /> | ||
| <Button | ||
| success | ||
| style={[styles.mt3]} | ||
| onPress={onAddPaymentCard} | ||
| pressOnEnter | ||
| text={translate('trialPaymentReminder.addPaymentCardButton')} | ||
| large | ||
| /> | ||
| </View> | ||
| </Modal> | ||
| ); | ||
| } | ||
|
|
||
| export default TrialPaymentReminderModal; |
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 |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import React, {useCallback, useState} from 'react'; | ||
| import useOnyx from '@hooks/useOnyx'; | ||
| import useTrialPaymentReminder from '@hooks/useTrialPaymentReminder'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import ROUTES from '@src/ROUTES'; | ||
| import TrialPaymentReminderModal from './TrialPaymentReminderModal'; | ||
|
|
||
| function TrialPaymentReminderModalManager() { | ||
| const {isEligibleToShow, currentVariation, countdownTime, dismiss} = useTrialPaymentReminder(); | ||
| const [modal] = useOnyx(ONYXKEYS.MODAL); | ||
| const [isModalOpen, setIsModalOpen] = useState(false); | ||
|
|
||
| const isOtherModalActive = !!modal?.isVisible || !!modal?.willAlertModalBecomeVisible; | ||
|
|
||
| if (isEligibleToShow && !isOtherModalActive && !isModalOpen) { | ||
| setIsModalOpen(true); | ||
| } | ||
| if (!isEligibleToShow && isModalOpen) { | ||
| setIsModalOpen(false); | ||
| } | ||
|
|
||
| const handleClose = useCallback(() => { | ||
| setIsModalOpen(false); | ||
| dismiss(); | ||
| }, [dismiss]); | ||
|
|
||
| const handleAddPaymentCard = useCallback(() => { | ||
| setIsModalOpen(false); | ||
| dismiss(); | ||
| Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION_ADD_PAYMENT_CARD); | ||
| }, [dismiss]); | ||
|
|
||
| if (!currentVariation) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <TrialPaymentReminderModal | ||
| isVisible={isModalOpen} | ||
| variant={currentVariation.variant} | ||
| daysRemaining={currentVariation.daysRemaining} | ||
| countdownTime={countdownTime} | ||
| onClose={handleClose} | ||
| onAddPaymentCard={handleAddPaymentCard} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| export default TrialPaymentReminderModalManager; |
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.
Uh oh!
There was an error while loading. Please reload this page.