diff --git a/App.tsx b/App.tsx index 8cb81c6..9b36078 100644 --- a/App.tsx +++ b/App.tsx @@ -1,116 +1,66 @@ -/** - * Sample React Native App - * https://github.com/facebook/react-native - * - * Generated with the TypeScript template - * https://github.com/react-native-community/react-native-template-typescript - * - * @format - */ - -import React from 'react'; +import React, {useState} from 'react'; import { + Button, SafeAreaView, - ScrollView, StatusBar, - StyleSheet, - Text, + TextInput, useColorScheme, + Vibration, View, } from 'react-native'; - -import { - Colors, - DebugInstructions, - Header, - LearnMoreLinks, - ReloadInstructions, -} from 'react-native/Libraries/NewAppScreen'; - -const Section: React.FC<{ - children: React.ReactNode; - title: string; -}> = ({children, title}) => { - const isDarkMode = useColorScheme() === 'dark'; - return ( - - - {title} - - - {children} - - - ); -}; +import BackgroundTimer from 'react-native-background-timer'; +import {Notifications} from 'react-native-notifications'; +import Sound from 'react-native-sound'; const App = () => { - const isDarkMode = useColorScheme() === 'dark'; + const dark = useColorScheme() === 'dark'; + const alarm = new Sound('argon.mp3', Sound.MAIN_BUNDLE, error => { + if (error) throw new Error(error); + }); + const [timer, setTimer] = useState('0'); - const backgroundStyle = { - backgroundColor: isDarkMode ? Colors.darker : Colors.lighter, + Notifications.registerRemoteNotifications(); + Notifications.events().registerNotificationOpened( + (notification, completion) => { + console.log('Notification opened:', notification); + alarm.stop(); + Vibration.cancel(); + completion(); + }, + ); + + const press = () => { + BackgroundTimer.setTimeout(() => { + alarm.play(_onEnd => Vibration.cancel()); + Vibration.vibrate([0, 400, 600], /*repeat=*/ true); + Notifications.postLocalNotification({ + title: 'title', + body: 'body', + badge: 1, + identifier: 'identifier', + payload: {}, + sound: 'sound', + thread: 'thread', + type: 'type', + }); + }, Number(timer)); }; return ( - - - -
- -
- Edit App.tsx to change this - screen and then come back to see your edits. -
-
- -
-
- -
-
- Read the docs to discover what to do next: -
- -
- + + + + + + +