-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 #35045 from callstack-internal/issues/30123
Add offline search functionality for addresses
- Loading branch information
Showing
13 changed files
with
212 additions
and
56 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
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
4 changes: 4 additions & 0 deletions
4
src/components/AddressSearch/listViewOverflow/index.native.ts
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,4 @@ | ||
// eslint-disable-next-line no-restricted-imports | ||
import {defaultStyles} from '@styles/index'; | ||
|
||
export default defaultStyles.overflowHidden; |
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,4 @@ | ||
// eslint-disable-next-line no-restricted-imports | ||
import {defaultStyles} from '@styles/index'; | ||
|
||
export default defaultStyles.overflowAuto; |
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
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
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
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,33 @@ | ||
import {useState} from 'react'; | ||
import useSafeAreaInsets from './useSafeAreaInsets'; | ||
import useThemeStyles from './useThemeStyles'; | ||
|
||
// Useful when there's a need to hide the submit button from FormProvider, | ||
// to let form content fill the page when virtual keyboard is shown | ||
function useSubmitButtonVisibility() { | ||
const styles = useThemeStyles(); | ||
const [isSubmitButtonVisible, setIsSubmitButtonVisible] = useState(true); | ||
const {bottom} = useSafeAreaInsets(); | ||
|
||
const showSubmitButton = () => { | ||
setIsSubmitButtonVisible(true); | ||
}; | ||
|
||
const hideSubmitButton = () => { | ||
setIsSubmitButtonVisible(false); | ||
}; | ||
|
||
// When the submit button is hidden there's a need to manually | ||
// add its bottom style to the FormProvider style prop, | ||
// otherwise the form content will touch the bottom of the page/screen | ||
const formStyle = !isSubmitButtonVisible && bottom === 0 && styles.mb5; | ||
|
||
return { | ||
isSubmitButtonVisible, | ||
showSubmitButton, | ||
hideSubmitButton, | ||
formStyle, | ||
}; | ||
} | ||
|
||
export default useSubmitButtonVisibility; |
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,58 @@ | ||
import {useEffect, useRef, useState} from 'react'; | ||
import {Dimensions} from 'react-native'; | ||
import useSafeAreaInsets from './useSafeAreaInsets'; | ||
import useThemeStyles from './useThemeStyles'; | ||
import useWindowDimensions from './useWindowDimensions'; | ||
|
||
// Useful when there's a need to hide the submit button from FormProvider, | ||
// to let form content fill the page when virtual keyboard is shown | ||
function useSubmitButtonVisibility() { | ||
const styles = useThemeStyles(); | ||
const {windowHeight, isSmallScreenWidth} = useWindowDimensions(); | ||
const [isSubmitButtonVisible, setIsSubmitButtonVisible] = useState(true); | ||
const initialWindowHeightRef = useRef(windowHeight); | ||
const isSmallScreenWidthRef = useRef(isSmallScreenWidth); | ||
const {bottom} = useSafeAreaInsets(); | ||
|
||
// Web: the submit button is shown when the height of the window is the same or greater, | ||
// otherwise it's hidden | ||
useEffect(() => { | ||
const dimensionsListener = Dimensions.addEventListener('change', ({window}) => { | ||
if (!isSmallScreenWidthRef.current) { | ||
return; | ||
} | ||
|
||
if (window.height < initialWindowHeightRef.current) { | ||
setIsSubmitButtonVisible(false); | ||
return; | ||
} | ||
|
||
setIsSubmitButtonVisible(true); | ||
}); | ||
|
||
return () => dimensionsListener.remove(); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
// Web: the submit button is only shown when the window height is the same or greater, | ||
// so executing this function won't do anything | ||
const showSubmitButton = () => {}; | ||
|
||
// Web: the submit button is only hidden when the window height becomes smaller, | ||
// so executing this function won't do anything | ||
const hideSubmitButton = () => {}; | ||
|
||
// When the submit button is hidden there's a need to manually | ||
// add its bottom style to the FormProvider style prop, | ||
// otherwise the form content will touch the bottom of the page/screen | ||
const formStyle = !isSubmitButtonVisible && bottom === 0 && styles.mb5; | ||
|
||
return { | ||
isSubmitButtonVisible, | ||
showSubmitButton, | ||
hideSubmitButton, | ||
formStyle, | ||
}; | ||
} | ||
|
||
export default useSubmitButtonVisibility; |
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
Oops, something went wrong.