-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.tsx
More file actions
37 lines (31 loc) · 1.27 KB
/
App.tsx
File metadata and controls
37 lines (31 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { useRef, useState } from 'react';
import ToastMessage, { ToastMessageRef } from './components/ToastMessage';
import Button from './components/Button';
import { SafeAreaView } from 'react-native';
export default function App() {
const [toastType, setToastType] = useState<'success' | 'danger' | 'info' | 'warning'>('success');
const toastRef = useRef<ToastMessageRef>(null);
const handleShowToast = () => {
if (toastRef.current) {
toastRef.current.show();
}
};
return (
<SafeAreaView style={{
flex: 1,
backgroundColor:'#1e272e',
justifyContent: 'center',
alignItems: 'center'
}}>
<ToastMessage
type={toastType}
text='Lorem Ipsum Text'
description='Lorem Ipsum Description'
ref={toastRef} />
<Button type='success' text='Success' onPress={() => { setToastType('success'); handleShowToast(); }} />
<Button type='danger' text='Danger' onPress={() => { setToastType('danger'); handleShowToast(); }} />
<Button type='info' text='Info' onPress={() => { setToastType('info'); handleShowToast(); }} />
<Button type='warning' text='Warning' onPress={() => { setToastType('warning'); handleShowToast(); }} />
</SafeAreaView>
);
};