-
Notifications
You must be signed in to change notification settings - Fork 4k
Add offline search functionality for addresses #35045
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
a3de03d
dcb0939
ec559a9
d1f00b6
f4b3233
3927555
254abbd
bffc960
45bcc82
113eff3
46200f8
f84f234
879ee6a
3d2c7ce
09f670c
21c204d
5bf583e
ffbef6c
1badfc0
529a57b
4760494
8e37883
fd79182
13a07cd
fd5978b
cec47a1
3d212a4
b1f668f
0aa04aa
ad6ab06
715d987
e03748c
60e2285
2f02fdd
2421ec8
3d36e3e
af8fae1
463d185
232df83
3ee5a28
01725ca
32882eb
1d2ba32
14d35c9
8749419
3cff20c
4bd2ae6
c135670
aa9e2c5
4e262bc
93f48ae
882d5c7
6fd9754
86398c6
82e5ca0
4e4fe79
d6284d2
8837fe0
7330834
76a7fda
7a05d93
2cf661c
8f1e5a1
1c5c0f7
87c3265
2740a6b
6337b57
3ecc869
af15403
d842db6
3be71e1
4dac414
3003023
8907eef
d4d9883
557cf6d
08c9a5d
4da5ffe
eda219c
b6b5741
a3dbfef
8c21175
baf70a9
0c38e44
7d58b3a
16b8027
c8dce42
3aef2b9
580af72
97642c8
cb4eaeb
1693acd
9b74216
a116369
553cd86
c2de6ef
6fdb7a8
e34aaa2
32eb193
eb3175c
16f5d89
1097761
86905c4
18610b4
7446682
9f70527
ee38c7e
94dda99
3c2d677
3ce2ddf
0301900
8468261
f7195c0
49e9755
ae0ce2d
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,4 @@ | ||
| // eslint-disable-next-line no-restricted-imports | ||
| import {defaultStyles} from '@styles/index'; | ||
|
|
||
| export default defaultStyles.overflowHidden; |
| 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; |
| 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; |
| 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); | ||
|
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. I think I'm missing something, could you elaborate on why we need initial values (why do we use
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. @eVoloshchak |
||
| const {bottom} = useSafeAreaInsets(); | ||
|
|
||
|
neil-marcellini marked this conversation as resolved.
|
||
| // 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; | ||
|
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. This is duplicated in both files, we can move this outside of
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. Good point, but I think it would be better for this style to be usable across components. I could extract this into a separate function that receives isSubmitButtonVisible as an argument and returns the style, what do you think? |
||
|
|
||
| return { | ||
| isSubmitButtonVisible, | ||
| showSubmitButton, | ||
| hideSubmitButton, | ||
| formStyle, | ||
| }; | ||
| } | ||
|
|
||
| export default useSubmitButtonVisibility; | ||
Uh oh!
There was an error while loading. Please reload this page.