Refactor app passwords to use react-query (#1932)

This commit is contained in:
Paul Frazee 2023-11-16 11:11:56 -08:00 committed by GitHub
parent 310a7eaca7
commit 9f7a162a96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 177 additions and 115 deletions

View file

@ -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)