Refactor app passwords to use react-query (#1932)
This commit is contained in:
parent
310a7eaca7
commit
9f7a162a96
6 changed files with 177 additions and 115 deletions
|
@ -7,12 +7,14 @@ import {StyleSheet, Text, View} from 'react-native'
|
|||
import {
|
||||
FontAwesomeIcon,
|
||||
FontAwesomeIconStyle,
|
||||
Props as FontAwesomeProps,
|
||||
} from '@fortawesome/react-native-fontawesome'
|
||||
|
||||
const DURATION = 3500
|
||||
|
||||
interface ActiveToast {
|
||||
text: string
|
||||
icon: FontAwesomeProps['icon']
|
||||
}
|
||||
type GlobalSetActiveToast = (_activeToast: ActiveToast | undefined) => void
|
||||
|
||||
|
@ -36,7 +38,7 @@ export const ToastContainer: React.FC<ToastContainerProps> = ({}) => {
|
|||
{activeToast && (
|
||||
<View style={styles.container}>
|
||||
<FontAwesomeIcon
|
||||
icon="check"
|
||||
icon={activeToast.icon}
|
||||
size={24}
|
||||
style={styles.icon as FontAwesomeIconStyle}
|
||||
/>
|
||||
|
@ -49,11 +51,12 @@ export const ToastContainer: React.FC<ToastContainerProps> = ({}) => {
|
|||
|
||||
// methods
|
||||
// =
|
||||
export function show(text: string) {
|
||||
|
||||
export function show(text: string, icon: FontAwesomeProps['icon'] = 'check') {
|
||||
if (toastTimeout) {
|
||||
clearTimeout(toastTimeout)
|
||||
}
|
||||
globalSetActiveToast?.({text})
|
||||
globalSetActiveToast?.({text, icon})
|
||||
toastTimeout = setTimeout(() => {
|
||||
globalSetActiveToast?.(undefined)
|
||||
}, DURATION)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue