Skip to content

Commit

Permalink
Merge pull request Expensify#53225 from ishpaul777/migrated-user-welc…
Browse files Browse the repository at this point in the history
…ome-modal

Migrated user welcome modal
  • Loading branch information
puneetlath authored Dec 8, 2024
2 parents b595f5d + 4575829 commit 7925c9b
Show file tree
Hide file tree
Showing 27 changed files with 435 additions and 25 deletions.
52 changes: 52 additions & 0 deletions assets/images/simple-illustrations/simple-illustration__flash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ const CONST = {
COMBINED_TRACK_SUBMIT: 'combinedTrackSubmit',
CATEGORY_AND_TAG_APPROVERS: 'categoryAndTagApprovers',
PER_DIEM: 'newDotPerDiem',
PRODUCT_TRAINING: 'productTraining',
},
BUTTON_STATES: {
DEFAULT: 'default',
Expand Down Expand Up @@ -6391,6 +6392,8 @@ const CONST = {
HYBRID_APP: {
REORDERING_REACT_NATIVE_ACTIVITY_TO_FRONT: 'reorderingReactNativeActivityToFront',
},

MIGRATED_USER_WELCOME_MODAL: 'migratedUserWelcomeModal',
} as const;

type Country = keyof typeof CONST.ALL_COUNTRIES;
Expand Down
1 change: 1 addition & 0 deletions src/NAVIGATORS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export default {
FEATURE_TRANING_MODAL_NAVIGATOR: 'FeatureTrainingModalNavigator',
WELCOME_VIDEO_MODAL_NAVIGATOR: 'WelcomeVideoModalNavigator',
EXPLANATION_MODAL_NAVIGATOR: 'ExplanationModalNavigator',
MIGRATED_USER_MODAL_NAVIGATOR: 'MigratedUserModalNavigator',
FULL_SCREEN_NAVIGATOR: 'FullScreenNavigator',
} as const;
4 changes: 4 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ const ONYXKEYS = {
// Stores onboarding last visited path
ONBOARDING_LAST_VISITED_PATH: 'onboardingLastVisitedPath',

// Object containing names/timestamps of dismissed product training elements (Modal, Tooltip, etc.)
NVP_DISMISSED_PRODUCT_TRAINING: 'nvp_dismissedProductTraining',

// Max width supported for HTML <canvas> element
MAX_CANVAS_WIDTH: 'maxCanvasWidth',

Expand Down Expand Up @@ -1027,6 +1030,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.SHOULD_SHOW_SAVED_SEARCH_RENAME_TOOLTIP]: boolean;
[ONYXKEYS.NVP_EXPENSIFY_COMPANY_CARDS_CUSTOM_NAMES]: Record<string, string>;
[ONYXKEYS.CONCIERGE_REPORT_ID]: string;
[ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING]: OnyxTypes.DismissedProductTraining;
};
type OnyxValues = OnyxValuesMapping & OnyxCollectionValuesMapping & OnyxFormValuesMapping & OnyxFormDraftValuesMapping;

Expand Down
1 change: 1 addition & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,7 @@ const ROUTES = {
},
WELCOME_VIDEO_ROOT: 'onboarding/welcome-video',
EXPLANATION_MODAL_ROOT: 'onboarding/explanation',
MIGRATED_USER_WELCOME_MODAL: 'onboarding/migrated-user-welcome',

TRANSACTION_RECEIPT: {
route: 'r/:reportID/transaction/:transactionID/receipt',
Expand Down
4 changes: 4 additions & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,10 @@ const SCREENS = {
ROOT: 'Explanation_Modal_Root',
},

MIGRATED_USER_WELCOME_MODAL: {
ROOT: 'MigratedUserWelcomeModal_Root',
},

I_KNOW_A_TEACHER: 'I_Know_A_Teacher',
INTRO_SCHOOL_PRINCIPAL: 'Intro_School_Principal',
I_AM_A_TEACHER: 'I_Am_A_Teacher',
Expand Down
76 changes: 65 additions & 11 deletions src/components/FeatureTrainingModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type {VideoReadyForDisplayEvent} from 'expo-av';
import React, {useCallback, useEffect, useState} from 'react';
import {View} from 'react-native';
import {InteractionManager, View} from 'react-native';
import type {StyleProp, ViewStyle} from 'react-native';
import {GestureHandlerRootView} from 'react-native-gesture-handler';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
Expand Down Expand Up @@ -39,6 +40,15 @@ type FeatureTrainingModalProps = {
/** Animation to show when video is unavailable. Useful when app is offline */
animation?: DotLottieAnimation;

/** Style for the inner container of the animation */
animationInnerContainerStyle?: StyleProp<ViewStyle>;

/** Style for the outer container of the animation */
animationOuterContainerStyle?: StyleProp<ViewStyle>;

/** Additional styles for the animation */
animationStyle?: StyleProp<ViewStyle>;

/** URL for the video */
videoURL: string;

Expand Down Expand Up @@ -70,10 +80,25 @@ type FeatureTrainingModalProps = {

/** Link to navigate to when user wants to learn more */
onHelp?: () => void;

/** Children to render */
children?: React.ReactNode;

/** Styles for the content container */
contentInnerContainerStyles?: StyleProp<ViewStyle>;

/** Styles for the content outer container */
contentOuterContainerStyles?: StyleProp<ViewStyle>;

/** Styles for the modal inner container */
modalInnerContainerStyle?: ViewStyle;
};

function FeatureTrainingModal({
animation,
animationStyle,
animationInnerContainerStyle,
animationOuterContainerStyle,
videoURL,
videoAspectRatio: videoAspectRatioProp,
title = '',
Expand All @@ -85,18 +110,26 @@ function FeatureTrainingModal({
onClose = () => {},
helpText = '',
onHelp = () => {},
children,
contentInnerContainerStyles,
contentOuterContainerStyles,
modalInnerContainerStyle,
}: FeatureTrainingModalProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const {onboardingIsMediumOrLargerScreenWidth} = useResponsiveLayout();
const [isModalVisible, setIsModalVisible] = useState(true);
const [isModalVisible, setIsModalVisible] = useState(false);
const [willShowAgain, setWillShowAgain] = useState(true);
const [videoStatus, setVideoStatus] = useState<VideoStatus>('video');
const [isVideoStatusLocked, setIsVideoStatusLocked] = useState(false);
const [videoAspectRatio, setVideoAspectRatio] = useState(videoAspectRatioProp ?? VIDEO_ASPECT_RATIO);
const {shouldUseNarrowLayout} = useResponsiveLayout();
const {isOffline} = useNetwork();

useEffect(() => {
InteractionManager.runAfterInteractions(() => setIsModalVisible(true));
}, []);

useEffect(() => {
if (isVideoStatusLocked) {
return;
Expand Down Expand Up @@ -133,10 +166,11 @@ function FeatureTrainingModal({
// for the video until it loads. Also, when
// videoStatus === 'animation' it will
// set the same aspect ratio as the video would.
{aspectRatio},
animationInnerContainerStyle,
!!videoURL && {aspectRatio},
]}
>
{videoStatus === 'video' ? (
{!!videoURL && videoStatus === 'video' ? (
<GestureHandlerRootView>
<VideoPlayer
url={videoURL}
Expand All @@ -149,7 +183,7 @@ function FeatureTrainingModal({
/>
</GestureHandlerRootView>
) : (
<View style={[styles.flex1, styles.alignItemsCenter, {aspectRatio}]}>
<View style={[styles.flex1, styles.alignItemsCenter, styles.justifyContentCenter, !!videoURL && {aspectRatio}, animationStyle]}>
<Lottie
source={animation ?? LottieAnimations.Hands}
style={styles.h100}
Expand All @@ -161,7 +195,21 @@ function FeatureTrainingModal({
)}
</View>
);
}, [animation, videoURL, videoAspectRatio, videoStatus, shouldUseNarrowLayout, styles]);
}, [
videoAspectRatio,
styles.w100,
styles.onboardingVideoPlayer,
styles.flex1,
styles.alignItemsCenter,
styles.justifyContentCenter,
styles.h100,
videoStatus,
videoURL,
animationStyle,
animation,
shouldUseNarrowLayout,
animationInnerContainerStyle,
]);

const toggleWillShowAgain = useCallback(() => setWillShowAgain((prevWillShowAgain) => !prevWillShowAgain), []);

Expand All @@ -170,8 +218,10 @@ function FeatureTrainingModal({
User.dismissTrackTrainingModal();
}
setIsModalVisible(false);
Navigation.goBack();
onClose?.();
InteractionManager.runAfterInteractions(() => {
Navigation.goBack();
onClose?.();
});
}, [onClose, willShowAgain]);

const closeAndConfirmModal = useCallback(() => {
Expand Down Expand Up @@ -199,16 +249,20 @@ function FeatureTrainingModal({
width: 'auto',
}
: {}),
...modalInnerContainerStyle,
}}
>
<View style={[styles.mh100, onboardingIsMediumOrLargerScreenWidth && styles.welcomeVideoNarrowLayout, safeAreaPaddingBottomStyle]}>
<View style={onboardingIsMediumOrLargerScreenWidth ? {padding: MODAL_PADDING} : {paddingHorizontal: MODAL_PADDING}}>{renderIllustration()}</View>
<View style={[styles.mt5, styles.mh5]}>
<View style={[onboardingIsMediumOrLargerScreenWidth ? {padding: MODAL_PADDING} : {paddingHorizontal: MODAL_PADDING}, animationOuterContainerStyle]}>
{renderIllustration()}
</View>
<View style={[styles.mt5, styles.mh5, contentOuterContainerStyles]}>
{!!title && !!description && (
<View style={[onboardingIsMediumOrLargerScreenWidth ? [styles.gap1, styles.mb8] : [styles.mb10]]}>
<View style={[onboardingIsMediumOrLargerScreenWidth ? [styles.gap1, styles.mb8] : [styles.mb10], contentInnerContainerStyles]}>
<Text style={[styles.textHeadlineH1]}>{title}</Text>
<Text style={styles.textSupporting}>{description}</Text>
{secondaryDescription.length > 0 && <Text style={[styles.textSupporting, styles.mt4]}>{secondaryDescription}</Text>}
{children}
</View>
)}
{shouldShowDismissModalOption && (
Expand Down
4 changes: 4 additions & 0 deletions src/components/Icon/Illustrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ import EmailAddress from '@assets/images/simple-illustrations/simple-illustratio
import EmptyState from '@assets/images/simple-illustrations/simple-illustration__empty-state.svg';
import EnvelopeReceipt from '@assets/images/simple-illustrations/simple-illustration__envelopereceipt.svg';
import Filters from '@assets/images/simple-illustrations/simple-illustration__filters.svg';
import Flash from '@assets/images/simple-illustrations/simple-illustration__flash.svg';
import FolderOpen from '@assets/images/simple-illustrations/simple-illustration__folder-open.svg';
import Gears from '@assets/images/simple-illustrations/simple-illustration__gears.svg';
import HandCard from '@assets/images/simple-illustrations/simple-illustration__handcard.svg';
Expand All @@ -105,6 +106,7 @@ import LockOpen from '@assets/images/simple-illustrations/simple-illustration__l
import Luggage from '@assets/images/simple-illustrations/simple-illustration__luggage.svg';
import MagnifyingGlassMoney from '@assets/images/simple-illustrations/simple-illustration__magnifyingglass-money.svg';
import Mailbox from '@assets/images/simple-illustrations/simple-illustration__mailbox.svg';
import ExpensifyMobileApp from '@assets/images/simple-illustrations/simple-illustration__mobileapp.svg';
import MoneyReceipts from '@assets/images/simple-illustrations/simple-illustration__money-receipts.svg';
import MoneyBadge from '@assets/images/simple-illustrations/simple-illustration__moneybadge.svg';
import MoneyIntoWallet from '@assets/images/simple-illustrations/simple-illustration__moneyintowallet.svg';
Expand Down Expand Up @@ -290,4 +292,6 @@ export {
StripeCompanyCardDetailLarge,
VisaCompanyCardDetailLarge,
WellsFargoCompanyCardDetailLarge,
Flash,
ExpensifyMobileApp,
};
Loading

0 comments on commit 7925c9b

Please sign in to comment.