Remove dependencies used by AlarmModule

This commit is contained in:
Brandon Presley 2022-07-04 16:17:29 +12:00
parent 5a1257a859
commit 8d4c075677
7 changed files with 11 additions and 91 deletions

View File

@ -1,7 +1,7 @@
import {NativeStackScreenProps} from '@react-navigation/native-stack';
import React, {useEffect, useState} from 'react';
import {FlatList, StyleSheet, View} from 'react-native';
import {List, TextInput} from 'react-native-paper';
import {List, Searchbar, TextInput} from 'react-native-paper';
import {RootStackParamList} from './App';
import {getDb} from './db';
import Exercise from './exercise';
@ -43,7 +43,7 @@ export default function Exercises({
return (
<View style={styles.container}>
<TextInput label="Search" value={search} onChangeText={setSearch} />
<Searchbar placeholder="Search" value={search} onChangeText={setSearch} />
<FlatList
onRefresh={refresh}
refreshing={refreshing}

View File

@ -1,16 +1,13 @@
import AsyncStorage from '@react-native-async-storage/async-storage';
import {useNavigation} from '@react-navigation/native';
import React, {useEffect, useState} from 'react';
import {
FlatList,
NativeModules,
SafeAreaView,
StyleSheet,
Vibration,
View,
} from 'react-native';
import {List, TextInput} from 'react-native-paper';
import Sound from 'react-native-sound';
import {List, Searchbar, TextInput} from 'react-native-paper';
import Alarm from './Alarm';
import {getDb} from './db';
import EditSet from './EditSet';
@ -26,7 +23,6 @@ export default function Home() {
const [refreshing, setRefreshing] = useState(false);
const [showEdit, setShowEdit] = useState(false);
const [search, setSearch] = useState('');
const navigation = useNavigation();
const refresh = async () => {
setRefreshing(true);
@ -41,21 +37,10 @@ export default function Home() {
setOffset(0);
};
const alarm = new Sound('argon.mp3', Sound.MAIN_BUNDLE, error => {
if (error) throw new Error(error);
});
const focus = async () => {
alarm.stop();
Vibration.cancel();
};
useEffect(() => {
refresh();
}, [search]);
useEffect(() => navigation.addListener('focus', focus), [navigation]);
const renderItem = ({item}: {item: Set}) => (
<List.Item
onPress={() => {
@ -98,7 +83,7 @@ export default function Home() {
return (
<SafeAreaView style={styles.container}>
<TextInput label="Search" value={search} onChangeText={setSearch} />
<Searchbar placeholder="Search" value={search} onChangeText={setSearch} />
<FlatList
style={{height: '100%'}}
data={sets}

View File

@ -40,6 +40,7 @@ export default function Settings({
keyboardType="numeric"
placeholder="3"
onChangeText={setMinutes}
style={styles.text}
/>
<TextInput
label="Rest seconds"
@ -47,10 +48,11 @@ export default function Settings({
keyboardType="numeric"
placeholder="30"
onChangeText={setSeconds}
style={styles.text}
/>
<Text style={{marginTop: 10, marginBottom: 10}}>Alarm enabled?</Text>
<Text style={styles.text}>Alarm enabled?</Text>
<Switch
style={{alignSelf: 'flex-start'}}
style={[styles.text, {alignSelf: 'flex-start'}]}
value={alarmEnabled}
onValueChange={setAlarmEnabled}
/>
@ -65,4 +67,7 @@ const styles = StyleSheet.create({
container: {
padding: 10,
},
text: {
marginBottom: 10,
},
});

View File

@ -1,13 +0,0 @@
import PushNotification, {Importance} from 'react-native-push-notification';
export const ALARM = 'alarm';
PushNotification.createChannel(
{
channelId: ALARM,
channelName: 'Alarms',
channelDescription: 'Notifications of when alarms are triggered.',
importance: Importance.HIGH,
vibrate: false,
},
created => console.log(`Created channel ${created}`),
);

View File

@ -4,7 +4,6 @@ import React from 'react';
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
import PushNotification from 'react-native-push-notification';
import {Provider as PaperProvider, DarkTheme} from 'react-native-paper';
import Ionicon from 'react-native-vector-icons/Ionicons';
@ -19,21 +18,3 @@ export default function Main() {
}
AppRegistry.registerComponent(appName, () => Main);
PushNotification.configure({
onNotification: function (notification) {
console.log('NOTIFICATION:', notification);
},
onAction: function (notification) {
console.log('ACTION:', notification.action);
console.log('NOTIFICATION:', notification);
},
onRegistrationError: function (err) {
console.error(err.message, err);
},
popInitialNotification: true,
requestPermissions: false,
});

View File

@ -12,27 +12,21 @@
"dependencies": {
"@babel/preset-env": "^7.1.6",
"@react-native-async-storage/async-storage": "^1.17.7",
"@react-native-community/push-notification-ios": "^1.10.1",
"@react-navigation/bottom-tabs": "^6.3.1",
"@react-navigation/material-top-tabs": "^6.2.1",
"@react-navigation/native": "^6.0.10",
"@react-navigation/native-stack": "^6.6.2",
"@types/react-native-background-timer": "^2.0.0",
"@types/react-native-push-notification": "^8.1.1",
"@types/react-native-sqlite-storage": "^5.0.2",
"@types/react-native-vector-icons": "^6.4.11",
"react": "18.0.0",
"react-devtools": "^4.24.7",
"react-native": "0.69.1",
"react-native-background-timer": "^2.4.1",
"react-native-gesture-handler": "^2.5.0",
"react-native-pager-view": "^5.4.24",
"react-native-paper": "^4.12.2",
"react-native-push-notification": "^8.1.1",
"react-native-reanimated": "^2.9.0",
"react-native-safe-area-context": "^4.3.1",
"react-native-screens": "^3.14.0",
"react-native-sound": "^0.11.2",
"react-native-sqlite-storage": "^6.0.1",
"react-native-tab-view": "^3.1.1",
"react-native-vector-icons": "^9.2.0"

View File

@ -1603,13 +1603,6 @@
resolved "https://registry.yarnpkg.com/@react-native-community/eslint-plugin/-/eslint-plugin-1.2.0.tgz#7d6d789ae8edf73dc9bed1246cd48277edea8066"
integrity sha512-o6aam+0Ug1xGK3ABYmBm0B1YuEKfM/5kaoZO0eHbZwSpw9UzDX4G5y4Nx/K20FHqUmJHkZmLvOUFYwN4N+HqKA==
"@react-native-community/push-notification-ios@^1.10.1":
version "1.10.1"
resolved "https://registry.yarnpkg.com/@react-native-community/push-notification-ios/-/push-notification-ios-1.10.1.tgz#d52a6d69ac1112df0f79e1d17978077629b76784"
integrity sha512-k6bZWUKLif4GjenyTD3aQLwA2VT3bNmt22INO/34lexnpmqkPDZF7nreqbckTHG0Zso9wDTe4N/AZJUC/d8iRg==
dependencies:
invariant "^2.2.4"
"@react-native/assets@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@react-native/assets/-/assets-1.0.0.tgz#c6f9bf63d274bafc8e970628de24986b30a55c8e"
@ -1843,16 +1836,6 @@
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.5.tgz#5f19d2b85a98e9558036f6a3cacc8819420f05cf"
integrity sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==
"@types/react-native-background-timer@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@types/react-native-background-timer/-/react-native-background-timer-2.0.0.tgz#c44c57f8fbca9d9d5521fdd72a8f55232b79381e"
integrity sha512-y5VW82dL/ESOLg+5QQHyBdsFVA4ZklENxmOyxv8o06T+3HBG2JOSuz/CIPz1vKdB7dmWDGPZNuPosdtnp+xv2A==
"@types/react-native-push-notification@^8.1.1":
version "8.1.1"
resolved "https://registry.yarnpkg.com/@types/react-native-push-notification/-/react-native-push-notification-8.1.1.tgz#0c9a181d7823cfad215d040bc5596c2d83e1a3cd"
integrity sha512-ZN4UbU4EM3C7XGt4zI6RqHEZS2+35EwOz9DPAD1lTTY3IpWMHAKYjryykvP35hFkSwrGMpT8nYuMFPEJRwDEJA==
"@types/react-native-sqlite-storage@^5.0.2":
version "5.0.2"
resolved "https://registry.yarnpkg.com/@types/react-native-sqlite-storage/-/react-native-sqlite-storage-5.0.2.tgz#eefcc9ea6ff73043bb2945023fa8ee721683b61b"
@ -6648,11 +6631,6 @@ react-is@^16.13.0, react-is@^16.13.1, react-is@^16.7.0:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
react-native-background-timer@^2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/react-native-background-timer/-/react-native-background-timer-2.4.1.tgz#a3bc1cafa8c1e3aeefd0611de120298b67978a0f"
integrity sha512-TE4Kiy7jUyv+hugxDxitzu38sW1NqjCk4uE5IgU2WevLv7sZacaBc6PZKOShNRPGirLl1NWkaG3LDEkdb9Um5g==
react-native-codegen@^0.69.1:
version "0.69.1"
resolved "https://registry.yarnpkg.com/react-native-codegen/-/react-native-codegen-0.69.1.tgz#3632be2f24464e6fad8dd11a25d1b6f3bc2c7d0b"
@ -6698,11 +6676,6 @@ react-native-paper@^4.12.2:
color "^3.1.2"
react-native-iphone-x-helper "^1.3.1"
react-native-push-notification@^8.1.1:
version "8.1.1"
resolved "https://registry.yarnpkg.com/react-native-push-notification/-/react-native-push-notification-8.1.1.tgz#a41d20c70ea5a7709417e96261b225461f8dc73a"
integrity sha512-XpBtG/w+a6WXTxu6l1dNYyTiHnbgnvjoc3KxPTxYkaIABRmvuJZkFxqruyGvfCw7ELAlZEAJO+dthdTabCe1XA==
react-native-reanimated@^2.9.0:
version "2.9.0"
resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-2.9.0.tgz#b8236c4e58461a66bdb7202d98a00e9d0db6c706"
@ -6730,11 +6703,6 @@ react-native-screens@^3.14.0:
react-freeze "^1.0.0"
warn-once "^0.1.0"
react-native-sound@^0.11.2:
version "0.11.2"
resolved "https://registry.yarnpkg.com/react-native-sound/-/react-native-sound-0.11.2.tgz#e542dc5b9e16ab4b3ac7e6eaddb1fc8d98da9038"
integrity sha512-LmGc8lgOK3qecYMVQpyHvww/C+wgT6sWeMpVbOe4NCRGC2yKd4fo4U0KBUo9PO7AqKESO3I/2GZg1/C0+bwiiA==
react-native-sqlite-storage@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/react-native-sqlite-storage/-/react-native-sqlite-storage-6.0.1.tgz#ce6a6b852f07abbea68658d5363818c8bef45dfb"