diff --git a/BatteryDialog.tsx b/BatteryDialog.tsx
deleted file mode 100644
index 3972446..0000000
--- a/BatteryDialog.tsx
+++ /dev/null
@@ -1,36 +0,0 @@
-import React from 'react';
-import {NativeModules, Text} from 'react-native';
-import {Button, Dialog, Portal} from 'react-native-paper';
-
-export default function BatteryDialog({
- show,
- setShow,
-}: {
- show: boolean;
- setShow: (show: boolean) => void;
-}) {
- const ok = () => {
- NativeModules.AlarmModule.openBatteryOptimizations();
- setShow(false);
- };
-
- return (
-
-
-
- );
-}
diff --git a/ConfirmDialog.tsx b/ConfirmDialog.tsx
new file mode 100644
index 0000000..a8ccb59
--- /dev/null
+++ b/ConfirmDialog.tsx
@@ -0,0 +1,32 @@
+import React from 'react';
+import {Text} from 'react-native';
+import {Button, Dialog, Portal} from 'react-native-paper';
+
+export default function ConfirmDialog({
+ title,
+ children,
+ onOk,
+ show,
+ setShow,
+}: {
+ title: string;
+ children: string;
+ onOk: () => void;
+ show: boolean;
+ setShow: (show: boolean) => void;
+}) {
+ return (
+
+
+
+ );
+}
diff --git a/HomePage.tsx b/HomePage.tsx
index d738037..4abadbb 100644
--- a/HomePage.tsx
+++ b/HomePage.tsx
@@ -6,7 +6,7 @@ import {IconButton} from 'react-native-paper';
import {DrawerParamList} from './App';
import EditSet from './EditSet';
import Set from './set';
-import SetsPage from './SetsPage';
+import SetList from './SetList';
const Stack = createStackNavigator();
export type StackParams = {
@@ -22,7 +22,7 @@ export default function HomePage() {
return (
-
+
();
const [offset, setOffset] = useState(0);
const [search, setSearch] = useState('');
@@ -33,7 +33,7 @@ export default function SetsPage() {
const refresh = useCallback(async () => {
const [result] = await db.executeSql(selectSets, [`%${search}%`, limit, 0]);
if (!result) return setSets([]);
- console.log(`${SetsPage.name}.refresh:`, {search, limit});
+ console.log(`${SetList.name}.refresh:`, {search, limit});
setSets(result.rows.raw());
setOffset(0);
setEnd(false);
@@ -66,7 +66,7 @@ export default function SetsPage() {
if (end) return;
setRefreshing(true);
const newOffset = offset + limit;
- console.log(`${SetsPage.name}.next:`, {
+ console.log(`${SetList.name}.next:`, {
offset,
limit,
newOffset,
diff --git a/SettingsPage.tsx b/SettingsPage.tsx
index a5dfd4f..963854c 100644
--- a/SettingsPage.tsx
+++ b/SettingsPage.tsx
@@ -13,6 +13,7 @@ import {DatabaseContext} from './App';
import BatteryDialog from './BatteryDialog';
import Set from './set';
import DocumentPicker from 'react-native-document-picker';
+import ConfirmDialog from './ConfirmDialog';
const {getItem, setItem} = AsyncStorage;
@@ -24,6 +25,7 @@ export default function SettingsPage() {
const [predictiveSets, setPredictiveSets] = useState(false);
const [snackbar, setSnackbar] = useState('');
const [showBattery, setShowBattery] = useState(false);
+ const [showDelete, setShowDelete] = useState(false);
const [ignoring, setIgnoring] = useState(false);
const [timeoutId, setTimeoutId] = useState(0);
const db = useContext(DatabaseContext);
@@ -51,6 +53,7 @@ export default function SettingsPage() {
);
const clear = useCallback(async () => {
+ setShowDelete(false);
await db.executeSql(`DELETE FROM sets`);
toast('All data has been deleted!');
}, [db, toast]);
@@ -165,6 +168,17 @@ export default function SettingsPage() {
onValueChange={changeAlarmEnabled}
/>
+ {
+ NativeModules.AlarmModule.openBatteryOptimizations();
+ setShowBattery(false);
+ }}>
+ Disable battery optimizations for Massive to use rest timers.
+
+
Predictive sets
-
+
+ This irreversibly deletes all data from the app. Are you sure?
+