-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[Home Page] Create DiscoverSection Component #80807
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
Changes from all commits
bbc933d
bdcfe5e
cf2e7e6
3e250e8
16f423c
65773ae
0527ac8
d9f1f5c
1e9c98c
c2a4425
99e3ba7
2beaf2f
9288c3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import type {ReactNode} from 'react'; | ||
| import React from 'react'; | ||
| import {View} from 'react-native'; | ||
| import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
| import useTheme from '@hooks/useTheme'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import variables from '@styles/variables'; | ||
| import type IconAsset from '@src/types/utils/IconAsset'; | ||
| import Icon from './Icon'; | ||
| import Text from './Text'; | ||
|
|
||
| type WidgetContainerProps = { | ||
| /** The icon to display along with the title */ | ||
| icon?: IconAsset; | ||
|
|
||
| /** The text to display in the title of the widget */ | ||
| title?: string; | ||
|
|
||
| /** Custom color for the title text */ | ||
| titleColor?: string; | ||
|
|
||
| /** The width of the icon. */ | ||
| iconWidth?: number; | ||
|
|
||
| /** The height of the icon. */ | ||
| iconHeight?: number; | ||
|
|
||
| /** The content to display inside the widget container */ | ||
| children: ReactNode; | ||
| }; | ||
|
|
||
| function WidgetContainer({children, icon, title, titleColor, iconWidth = variables.iconSizeNormal, iconHeight = variables.iconSizeNormal}: WidgetContainerProps) { | ||
| const styles = useThemeStyles(); | ||
| const theme = useTheme(); | ||
| const {shouldUseNarrowLayout} = useResponsiveLayout(); | ||
|
|
||
| return ( | ||
| <View style={styles.widgetContainer}> | ||
| <View style={[styles.flexRow, styles.alignItemsStart, styles.mb5, shouldUseNarrowLayout ? styles.mh5 : styles.mh8, shouldUseNarrowLayout ? styles.mt5 : styles.mt8]}> | ||
| {!!icon && ( | ||
| <View style={[styles.flexGrow0, styles.flexShrink0]}> | ||
| <Icon | ||
| src={icon} | ||
| width={iconWidth} | ||
| height={iconHeight} | ||
| /> | ||
| </View> | ||
| )} | ||
| <View style={[styles.flexShrink1, styles.flexGrow1, styles.flexRow, styles.alignItemsCenter, styles.gap2]}> | ||
| {!!title && <Text style={styles.getWidgetContainerTitleStyle(titleColor ?? theme.text)}>{title}</Text>} | ||
| </View> | ||
| </View> | ||
| {children} | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| export type {WidgetContainerProps}; | ||
| export default WidgetContainer; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -733,6 +733,16 @@ const translations: TranslationDeepObject<typeof en> = { | |
| description: 'Estamos ajustando algunos detalles de New Expensify para adaptarla a tu configuración específica. Mientras tanto, dirígete a Expensify Classic.', | ||
| }, | ||
| }, | ||
| homePage: { | ||
| forYou: 'Para ti', | ||
| announcements: 'Anuncios', | ||
| discoverSection: { | ||
| title: 'Descubrir', | ||
| menuItemTitleNonAdmin: 'Aprende a crear gastos y enviar informes.', | ||
| menuItemTitleAdmin: 'Aprende a invitar a miembros, editar flujos de aprobación y conciliar tarjetas corporativas.', | ||
| menuItemDescription: 'Descubre lo que Expensify puede hacer en 2 minutos', | ||
| }, | ||
|
Comment on lines
+739
to
+744
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. Lets confirm these @JmillsExpensify |
||
| }, | ||
| allSettingsScreen: { | ||
| subscription: 'Suscripcion', | ||
| domains: 'Dominios', | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import React from 'react'; | ||
| import {Image, Linking, View} from 'react-native'; | ||
| import HomeTestDriveImage from '@assets/images/home-testdrive-image.png'; | ||
| import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; | ||
| import {PressableWithoutFeedback} from '@components/Pressable'; | ||
| import WidgetContainer from '@components/WidgetContainer'; | ||
| import useIsPaidPolicyAdmin from '@hooks/useIsPaidPolicyAdmin'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useOnyx from '@hooks/useOnyx'; | ||
| import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import {getTestDriveURL} from '@libs/TourUtils'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
|
|
||
| const MAX_NUMBER_OF_LINES_TITLE = 4; | ||
|
|
||
| function DiscoverSection() { | ||
| const {translate} = useLocalize(); | ||
| const {shouldUseNarrowLayout} = useResponsiveLayout(); | ||
| const isCurrentUserPolicyAdmin = useIsPaidPolicyAdmin(); | ||
| const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true}); | ||
| const styles = useThemeStyles(); | ||
|
|
||
| const handlePress = () => { | ||
|
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. ❌ CONSISTENCY-5 (docs)The Suggested fix: const handlePress = () => {
const url = getTestDriveURL(shouldUseNarrowLayout, introSelected, isCurrentUserPolicyAdmin);
Linking.openURL(url).catch((error) => {
Log.error('Failed to open test drive URL', error);
// Optionally show user feedback
});
};Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
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. Technically correct but inconsistent with existing patterns. The codebase doesn't do this anywhere else. |
||
| Linking.openURL(getTestDriveURL(shouldUseNarrowLayout, introSelected, isCurrentUserPolicyAdmin)); | ||
| }; | ||
|
|
||
| return ( | ||
| <WidgetContainer title={translate('homePage.discoverSection.title')}> | ||
| <PressableWithoutFeedback | ||
| onPress={handlePress} | ||
| accessibilityRole={CONST.ROLE.BUTTON} | ||
| accessibilityLabel={translate('homePage.discoverSection.title')} | ||
| style={[shouldUseNarrowLayout ? styles.mh5 : styles.mh8, styles.mb5]} | ||
| > | ||
| <View style={[styles.br2, styles.overflowHidden]}> | ||
| <Image | ||
| source={HomeTestDriveImage} | ||
| style={styles.discoverSectionImage} | ||
| /> | ||
| </View> | ||
| </PressableWithoutFeedback> | ||
| <MenuItemWithTopDescription | ||
| shouldShowRightIcon | ||
| title={isCurrentUserPolicyAdmin ? translate('homePage.discoverSection.menuItemTitleAdmin') : translate('homePage.discoverSection.menuItemTitleNonAdmin')} | ||
| description={translate('homePage.discoverSection.menuItemDescription')} | ||
| onPress={handlePress} | ||
| style={shouldUseNarrowLayout ? styles.mb2 : styles.mb5} | ||
| wrapperStyle={shouldUseNarrowLayout ? styles.pl5 : styles.pl8} | ||
| numberOfLinesTitle={MAX_NUMBER_OF_LINES_TITLE} | ||
| /> | ||
| </WidgetContainer> | ||
| ); | ||
| } | ||
|
|
||
| export default DiscoverSection; | ||
Uh oh!
There was an error while loading. Please reload this page.