diff --git a/AlarmApp/.bundle/config b/AlarmApp/.bundle/config new file mode 100644 index 0000000..848943b --- /dev/null +++ b/AlarmApp/.bundle/config @@ -0,0 +1,2 @@ +BUNDLE_PATH: "vendor/bundle" +BUNDLE_FORCE_RUBY_PLATFORM: 1 diff --git a/AlarmApp/.eslintrc.js b/AlarmApp/.eslintrc.js new file mode 100644 index 0000000..187894b --- /dev/null +++ b/AlarmApp/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + root: true, + extends: '@react-native', +}; diff --git a/AlarmApp/.gitignore b/AlarmApp/.gitignore new file mode 100644 index 0000000..de99955 --- /dev/null +++ b/AlarmApp/.gitignore @@ -0,0 +1,75 @@ +# OSX +# +.DS_Store + +# Xcode +# +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate +**/.xcode.env.local + +# Android/IntelliJ +# +build/ +.idea +.gradle +local.properties +*.iml +*.hprof +.cxx/ +*.keystore +!debug.keystore +.kotlin/ + +# node.js +# +node_modules/ +npm-debug.log +yarn-error.log + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/ + +**/fastlane/report.xml +**/fastlane/Preview.html +**/fastlane/screenshots +**/fastlane/test_output + +# Bundle artifact +*.jsbundle + +# Ruby / CocoaPods +**/Pods/ +/vendor/bundle/ + +# Temporary files created by Metro to check the health of the file watcher +.metro-health-check* + +# testing +/coverage + +# Yarn +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/sdks +!.yarn/versions diff --git a/AlarmApp/.prettierrc.js b/AlarmApp/.prettierrc.js new file mode 100644 index 0000000..06860c8 --- /dev/null +++ b/AlarmApp/.prettierrc.js @@ -0,0 +1,5 @@ +module.exports = { + arrowParens: 'avoid', + singleQuote: true, + trailingComma: 'all', +}; diff --git a/AlarmApp/.watchmanconfig b/AlarmApp/.watchmanconfig new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/AlarmApp/.watchmanconfig @@ -0,0 +1 @@ +{} diff --git a/AlarmApp/App.tsx b/AlarmApp/App.tsx new file mode 100644 index 0000000..f5dbafb --- /dev/null +++ b/AlarmApp/App.tsx @@ -0,0 +1,83 @@ +import React, { useState, useEffect } from 'react'; +import { + View, + Text, + Button, + Alert, + StyleSheet, + } from 'react-native'; + +import DateTimePicker from '@react-native-community/datetimepicker'; + +export default function App() { + const [alarmTime, setAlarmTime] = useState(null); + const [showPicker, setShowPicker] = useState(false); + const [alarmSet, setAlarmSet] = useState(false); + + // check every second + useEffect(() => { + const interval = setInterval(() => { + if (!alarmTime || !alarmSet) return; + + const now = new Date(); + if (now.getHours() === alarmTime?.getHours() && now.getMinutes() === alarmTime.getMinutes() && now.getSeconds() === 0) { + Alert.alert("Wake up!!!"); + setAlarmSet(false); + } + }, 1000); + + return () => clearInterval(interval); + }, [alarmTime, alarmSet]); + + const onChange = (event: any, selectedDate?: Date) => { + setShowPicker(false); + if (selectedDate) { + setAlarmTime(selectedDate); + setAlarmSet(true); + } + }; + + return ( + + + Alarm App + + +