-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add secondary FAB for GPS trip #79495
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 5 commits
9dd7f0c
c0cf5c3
6a006bc
ecb7c21
dfc4aa5
4a960c1
b758285
7276273
8b9009d
d5a8a8d
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,66 @@ | ||
| import React from 'react'; | ||
| import {View} from 'react-native'; | ||
| import Icon from '@components/Icon'; | ||
| import {PressableWithoutFeedback} from '@components/Pressable'; | ||
| import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useOnyx from '@hooks/useOnyx'; | ||
| import useTheme from '@hooks/useTheme'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import {canUseTouchScreen} from '@libs/DeviceCapabilities'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
| import {generateReportID} from '@libs/ReportUtils'; | ||
| import variables from '@styles/variables'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import ROUTES from '@src/ROUTES'; | ||
|
|
||
| function FloatingGpsButton() { | ||
| const [gpsDraftDetails] = useOnyx(ONYXKEYS.GPS_DRAFT_DETAILS, {canBeMissing: true}); | ||
| const {translate} = useLocalize(); | ||
|
|
||
| const icons = useMemoizedLazyExpensifyIcons(['Location'] as const); | ||
| const {textMutedReversed} = useTheme(); | ||
| const styles = useThemeStyles(); | ||
|
|
||
| if (!gpsDraftDetails?.isTracking) { | ||
| return null; | ||
| } | ||
|
|
||
| const navigateToGpsScreen = () => { | ||
| const optimisticReportID = generateReportID(); | ||
|
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. Should we get it from transactionDraft?
Contributor
Author
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. Yeah, makes sense, thanks
Contributor
Author
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. Actually |
||
| Navigation.navigate(ROUTES.DISTANCE_REQUEST_CREATE_TAB_GPS.getRoute(CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.CREATE, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, optimisticReportID)); | ||
|
GCyganek marked this conversation as resolved.
Outdated
|
||
| }; | ||
|
|
||
| return ( | ||
| <PressableWithoutFeedback | ||
| style={[ | ||
| styles.navigationTabBarFABItem, | ||
| styles.ph0, | ||
| // Prevent text selection on touch devices (e.g. on long press) | ||
| canUseTouchScreen() && styles.userSelectNone, | ||
|
GCyganek marked this conversation as resolved.
Outdated
|
||
| styles.floatingGpsButton, | ||
| ]} | ||
| accessibilityLabel={translate('gps.fabGpsTripExplained')} | ||
| onPress={navigateToGpsScreen} | ||
| role={CONST.ROLE.BUTTON} | ||
| testID="floating-gps-button" | ||
| > | ||
| <View | ||
| style={styles.floatingSecondaryActionButton} | ||
| testID="floating-gps-button-container" | ||
| > | ||
| <Icon | ||
| fill={textMutedReversed} | ||
| src={icons.Location} | ||
| width={variables.iconSizeNormal} | ||
| height={variables.iconSizeNormal} | ||
| /> | ||
| </View> | ||
| </PressableWithoutFeedback> | ||
| ); | ||
| } | ||
|
|
||
| FloatingGpsButton.displayName = 'FloatingGpsButton'; | ||
|
|
||
| export default FloatingGpsButton; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| function FloatingGpsButton() { | ||
| return null; | ||
| } | ||
|
|
||
| FloatingGpsButton.displayName = 'FloatingGpsButton'; | ||
|
|
||
| export default FloatingGpsButton; |
Uh oh!
There was an error while loading. Please reload this page.