Skip to content
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

[MEDIUM][VIP-Travel] Use static .svg for Travel terms & conditions page, not a .lottie file #42625

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
575 changes: 575 additions & 0 deletions assets/images/product-illustrations/emptystate__travel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/components/FeatureList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ type FeatureListProps = {
/** A list of menuItems representing the feature list. */
menuItems: FeatureListItem[];

/** The illustration to display in the header. Can be a JSON object representing a Lottie animation. */
illustration: DotLottieAnimation;
/** The illustration to display in the header. Can be an image or a JSON object representing a Lottie animation. */
illustration: DotLottieAnimation | IconAsset;

/** The style passed to the illustration */
illustrationStyle?: StyleProp<ViewStyle>;
Expand Down
2 changes: 2 additions & 0 deletions src/components/Icon/Illustrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ConciergeBlue from '@assets/images/product-illustrations/concierge--blue.
import ConciergeExclamation from '@assets/images/product-illustrations/concierge--exclamation.svg';
import CreditCardsBlue from '@assets/images/product-illustrations/credit-cards--blue.svg';
import EmptyStateExpenses from '@assets/images/product-illustrations/emptystate__expenses.svg';
import EmptyStateTravel from '@assets/images/product-illustrations/emptystate__travel.svg';
import GpsTrackOrange from '@assets/images/product-illustrations/gps-track--orange.svg';
import Hands from '@assets/images/product-illustrations/home-illustration-hands.svg';
import InvoiceOrange from '@assets/images/product-illustrations/invoice--orange.svg';
Expand Down Expand Up @@ -176,4 +177,5 @@ export {
Tag,
CarIce,
Lightbulb,
EmptyStateTravel,
};
42 changes: 31 additions & 11 deletions src/components/Section/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import type {ReactNode} from 'react';
import React from 'react';
import type {StyleProp, TextStyle, ViewStyle} from 'react-native';
import {View} from 'react-native';
import type {ValueOf} from 'type-fest';
import ImageSVG from '@components/ImageSVG';
import Lottie from '@components/Lottie';
import type DotLottieAnimation from '@components/LottieAnimations/types';
import type {MenuItemWithLink} from '@components/MenuItemList';
Expand Down Expand Up @@ -59,8 +60,8 @@ type SectionProps = ChildrenProps & {
/** Whether the section is in the central pane of the layout */
isCentralPane?: boolean;

/** The illustration to display in the header. Can be a JSON object representing a Lottie animation. */
illustration?: DotLottieAnimation;
/** The illustration to display in the header. Can be an image or a JSON object representing a Lottie animation. */
illustration?: DotLottieAnimation | IconAsset;

/** The background color to apply in the upper half of the screen. */
illustrationBackgroundColor?: string;
Expand All @@ -78,6 +79,14 @@ type SectionProps = ChildrenProps & {
renderSubtitle?: () => ReactNode;
};

function isIllustrationLottieAnimation(illustration: DotLottieAnimation | IconAsset | undefined): illustration is DotLottieAnimation {
if (typeof illustration === 'number' || !illustration) {
return false;
}

return 'file' in illustration && 'w' in illustration && 'h' in illustration;
}

function Section({
children,
childrenStyles,
Expand All @@ -104,7 +113,11 @@ function Section({
const StyleUtils = useStyleUtils();
const {isSmallScreenWidth} = useWindowDimensions();

const illustrationContainerStyle: StyleProp<ViewStyle> = StyleUtils.getBackgroundColorStyle(illustrationBackgroundColor ?? illustration?.backgroundColor ?? theme.appBG);
const isLottie = isIllustrationLottieAnimation(illustration);

const lottieIllustration = isLottie ? illustration : undefined;

const illustrationContainerStyle: StyleProp<ViewStyle> = StyleUtils.getBackgroundColorStyle(illustrationBackgroundColor ?? lottieIllustration?.backgroundColor ?? theme.appBG);

return (
<View style={[styles.pageWrapper, styles.cardSectionContainer, containerStyles, (isCentralPane || !!illustration) && styles.p0]}>
Expand All @@ -117,13 +130,20 @@ function Section({
{!!illustration && (
<View style={[styles.w100, styles.dFlex, styles.alignItemsCenter, styles.justifyContentCenter, illustrationContainerStyle]}>
<View style={[styles.cardSectionIllustration, illustrationStyle]}>
<Lottie
source={illustration}
style={styles.h100}
webStyle={styles.h100}
autoPlay
loop
/>
{isLottie ? (
<Lottie
source={illustration}
style={styles.h100}
webStyle={styles.h100}
autoPlay
loop
/>
) : (
<ImageSVG
src={illustration}
contentFit="contain"
/>
)}
</View>
{overlayContent?.()}
</View>
Expand Down
7 changes: 2 additions & 5 deletions src/pages/Travel/ManageTrips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ import {View} from 'react-native';
import type {FeatureListItem} from '@components/FeatureList';
import FeatureList from '@components/FeatureList';
import * as Illustrations from '@components/Icon/Illustrations';
import LottieAnimations from '@components/LottieAnimations';
import ScrollView from '@components/ScrollView';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import Navigation from '@libs/Navigation/Navigation';
import colors from '@styles/theme/colors';
import ROUTES from '@src/ROUTES';
import getTripIllustrationStyle from './getTripIllustrationStyle';

const tripsFeatures: FeatureListItem[] = [
{
Expand All @@ -28,7 +26,6 @@ function ManageTrips() {
const styles = useThemeStyles();
const {isSmallScreenWidth} = useWindowDimensions();
const {translate} = useLocalize();
const illustrationStyle = getTripIllustrationStyle();

return (
<ScrollView contentContainerStyle={styles.pt3}>
Expand All @@ -42,8 +39,8 @@ function ManageTrips() {
onCtaPress={() => {
Navigation.navigate(ROUTES.TRAVEL_TCS);
}}
illustration={LottieAnimations.Plane}
illustrationStyle={illustrationStyle}
illustration={Illustrations.EmptyStateTravel}
illustrationStyle={[styles.mv4, styles.tripIllustrationSize]}
illustrationBackgroundColor={colors.blue600}
titleStyles={styles.textHeadlineH1}
contentPaddingOnLargeScreens={styles.p5}
Expand Down
8 changes: 0 additions & 8 deletions src/pages/Travel/getTripIllustrationStyle/index.native.ts

This file was deleted.

9 changes: 0 additions & 9 deletions src/pages/Travel/getTripIllustrationStyle/index.ts

This file was deleted.

5 changes: 5 additions & 0 deletions src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4911,6 +4911,11 @@ const styles = (theme: ThemeColors) =>
textLineThrough: {
textDecorationLine: 'line-through',
},

tripIllustrationSize: {
width: 190,
height: 172,
},
} satisfies Styles);

type ThemeStyles = ReturnType<typeof styles>;
Expand Down
Loading