-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29609 from huzaifa-99/25855-added-location-button…
…-in-address-search Added location button in address search
- Loading branch information
Showing
8 changed files
with
293 additions
and
282 deletions.
There are no files selected for viewing
This file contains 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,52 @@ | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import {Text} from 'react-native'; | ||
import colors from '../../styles/colors'; | ||
import styles from '../../styles/styles'; | ||
import Icon from '../Icon'; | ||
import * as Expensicons from '../Icon/Expensicons'; | ||
import PressableWithFeedback from '../Pressable/PressableWithFeedback'; | ||
import getButtonState from '../../libs/getButtonState'; | ||
import * as StyleUtils from '../../styles/StyleUtils'; | ||
import useLocalize from '../../hooks/useLocalize'; | ||
|
||
const propTypes = { | ||
/** Callback that runs when location button is clicked */ | ||
onPress: PropTypes.func, | ||
|
||
/** Boolean to indicate if the button is clickable */ | ||
isDisabled: PropTypes.bool, | ||
}; | ||
|
||
const defaultProps = { | ||
isDisabled: false, | ||
onPress: () => {}, | ||
}; | ||
|
||
function CurrentLocationButton({onPress, isDisabled}) { | ||
const {translate} = useLocalize(); | ||
|
||
return ( | ||
<PressableWithFeedback | ||
style={[styles.flexRow, styles.pv4, styles.ph3, isDisabled && styles.buttonOpacityDisabled]} | ||
hoverStyle={StyleUtils.getButtonBackgroundColorStyle(getButtonState(true), true)} | ||
onPress={onPress} | ||
accessibilityLabel={translate('location.useCurrent')} | ||
disabled={isDisabled} | ||
onMouseDown={(e) => e.preventDefault()} | ||
onTouchStart={(e) => e.preventDefault()} | ||
> | ||
<Icon | ||
src={Expensicons.Location} | ||
fill={colors.green} | ||
/> | ||
<Text style={[styles.textLabel, styles.mh2, isDisabled && styles.userSelectNone]}>{translate('location.useCurrent')}</Text> | ||
</PressableWithFeedback> | ||
); | ||
} | ||
|
||
CurrentLocationButton.displayName = 'CurrentLocationButton'; | ||
CurrentLocationButton.propTypes = propTypes; | ||
CurrentLocationButton.defaultProps = defaultProps; | ||
|
||
export default CurrentLocationButton; |
Large diffs are not rendered by default.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
src/components/AddressSearch/isCurrentTargetInsideContainer.js
This file contains 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,8 @@ | ||
function isCurrentTargetInsideContainer(event, containerRef) { | ||
// The related target check is required here | ||
// because without it when we select an option, the onBlur will still trigger setting displayListViewBorder to false | ||
// it will make the auto complete component re-render before onPress is called making selecting an option not working. | ||
return containerRef.current && event.target && containerRef.current.contains(event.relatedTarget); | ||
} | ||
|
||
export default isCurrentTargetInsideContainer; |
6 changes: 6 additions & 0 deletions
6
src/components/AddressSearch/isCurrentTargetInsideContainer.native.js
This file contains 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,6 @@ | ||
function isCurrentTargetInsideContainer() { | ||
// The related target check is not required here because in native there is no race condition rendering like on the web | ||
return false; | ||
} | ||
|
||
export default isCurrentTargetInsideContainer; |
11 changes: 0 additions & 11 deletions
11
src/components/AddressSearch/resetDisplayListViewBorderOnBlur.js
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
src/components/AddressSearch/resetDisplayListViewBorderOnBlur.native.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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