MCPcopy Create free account
hub / github.com/douglasjunior/react-native-simple-dialogs / App

Function App

Sample/src/App.tsx:60–191  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

58});
59
60export default function App() {
61 const insets = useSafeAreaInsets();
62
63 const [showDialog, setShowDialog] = useState(false);
64 const [showConfirm, setShowConfirm] = useState(false);
65 const [showProgress, setShowProgress] = useState(false);
66
67 const openDialog = (show: boolean) => {
68 setShowDialog(show);
69 };
70
71 const openConfirm = (show: boolean) => {
72 setShowConfirm(show);
73 };
74
75 const openProgress = () => {
76 setShowProgress(true);
77
78 setTimeout(() => {
79 setShowProgress(false);
80 }, 4000);
81 };
82
83 const optionYes = () => {
84 openConfirm(false);
85
86 // Yes, this is a workaround :(
87 // Why? See this https://github.com/facebook/react-native/issues/10471
88 setTimeout(() => {
89 Alert.alert('The YES Button touched!');
90 }, 300);
91 };
92
93 const optionNo = () => {
94 openConfirm(false);
95
96 // Yes, this is a workaround :(
97 // Why? See this https://github.com/facebook/react-native/issues/10471
98 setTimeout(() => {
99 Alert.alert('The NO Button touched!');
100 }, 300);
101 };
102
103 return (
104 <View style={styles.container}>
105 <Text style={styles.welcomeText}>
106 Welcome to React Native Simple Dialogs!
107 </Text>
108 <Text style={styles.exampleText}>Examples</Text>
109 <Text style={styles.instructionsText}>
110 To get started, touch on the buttons
111 </Text>
112
113 <Button onPress={() => openDialog(true)} title="Custom Dialog" />
114
115 <View style={{height: 40}} />
116
117 <Button onPress={() => openConfirm(true)} title="Confirm Dialog" />

Callers

nothing calls this directly

Calls 2

openDialogFunction · 0.85
openConfirmFunction · 0.85

Tested by

no test coverage detected