-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d0a23a
commit 7561a58
Showing
7 changed files
with
105 additions
and
2 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,31 @@ | ||
import { useCallback, useRef, useState } from 'react'; | ||
|
||
const useRequireMultiplePresses = ( | ||
onPress: () => void, | ||
requiredPresses = 3, | ||
timeout = 500, | ||
) => { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const [_, setPresses] = useState(0); | ||
const timeoutRef = useRef<NodeJS.Timeout>(); | ||
|
||
return useCallback(() => { | ||
setPresses(prevPresses => { | ||
if (prevPresses === 0) { | ||
timeoutRef.current = setTimeout(() => { | ||
setPresses(0); | ||
}, timeout); | ||
} | ||
|
||
if (prevPresses + 1 === requiredPresses) { | ||
clearTimeout(timeoutRef.current); | ||
onPress(); | ||
return 0; | ||
} | ||
|
||
return prevPresses + 1; | ||
}); | ||
}, [onPress, requiredPresses, timeout]); | ||
}; | ||
|
||
export default useRequireMultiplePresses; |
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,12 @@ | ||
import type { EqualityFn } from 'react-redux'; | ||
|
||
import type { SettingsState } from '@/types/settings'; | ||
|
||
import { useAppSelector } from '@/store'; | ||
|
||
const useSettings = <T>( | ||
selector: (state: SettingsState) => T, | ||
equalityFn?: EqualityFn<T>, | ||
): T => useAppSelector(state => selector(state.settings), equalityFn); | ||
|
||
export default useSettings; |
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,16 @@ | ||
import type { FC } from 'react'; | ||
import { Appbar } from 'react-native-paper'; | ||
|
||
import type { PropsWithNavigation } from '@/views/navigation/NavigationStack'; | ||
|
||
const DebugScreen: FC<PropsWithNavigation> = () => { | ||
return ( | ||
<> | ||
<Appbar.Header> | ||
<Appbar.Content title="Debug" /> | ||
</Appbar.Header> | ||
</> | ||
); | ||
}; | ||
|
||
export default DebugScreen; |
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