Add toggle for predictive sets
This commit is contained in:
parent
5c65b283d3
commit
29d2421fb1
2
App.tsx
2
App.tsx
|
@ -49,6 +49,8 @@ const App = () => {
|
|||
if (seconds === null) await setItem('seconds', '30');
|
||||
const alarmEnabled = await getItem('alarmEnabled');
|
||||
if (alarmEnabled === null) await setItem('alarmEnabled', 'false');
|
||||
if (!(await getItem('predictiveSets')))
|
||||
await setItem('predictiveSets', 'true');
|
||||
};
|
||||
init();
|
||||
}, []);
|
||||
|
|
|
@ -150,6 +150,7 @@ export default function HomePage() {
|
|||
const created = new Date().toISOString();
|
||||
setNewSet({created});
|
||||
setShowNew(true);
|
||||
if ((await AsyncStorage.getItem('predictiveSets')) === 'false') return;
|
||||
const todaysPlan = await getTodaysPlan();
|
||||
if (todaysPlan.length === 0) return;
|
||||
console.log(`${HomePage.name}.onAdd: todaysPlan =`, todaysPlan);
|
||||
|
|
|
@ -20,6 +20,7 @@ export default function SettingsPage() {
|
|||
const [minutes, setMinutes] = useState<string>('');
|
||||
const [seconds, setSeconds] = useState<string>('');
|
||||
const [alarmEnabled, setAlarmEnabled] = useState<boolean>(false);
|
||||
const [predictiveSets, setPredictiveSets] = useState<boolean>(false);
|
||||
const [snackbar, setSnackbar] = useState('');
|
||||
const [showBattery, setShowBattery] = useState(false);
|
||||
const [ignoring, setIgnoring] = useState(false);
|
||||
|
@ -108,6 +109,14 @@ export default function SettingsPage() {
|
|||
[setShowBattery, ignoring],
|
||||
);
|
||||
|
||||
const changePredictive = useCallback(
|
||||
(enabled: boolean) => {
|
||||
setPredictiveSets(enabled);
|
||||
setItem('predictiveSets', enabled ? 'true' : 'false');
|
||||
},
|
||||
[setPredictiveSets],
|
||||
);
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<TextInput
|
||||
|
@ -121,6 +130,7 @@ export default function SettingsPage() {
|
|||
}}
|
||||
style={styles.text}
|
||||
/>
|
||||
|
||||
<TextInput
|
||||
label="Rest seconds"
|
||||
value={seconds}
|
||||
|
@ -132,24 +142,35 @@ export default function SettingsPage() {
|
|||
}}
|
||||
style={styles.text}
|
||||
/>
|
||||
|
||||
<Text style={styles.text}>Rest timers</Text>
|
||||
<Switch
|
||||
style={[styles.text, {alignSelf: 'flex-start'}]}
|
||||
value={alarmEnabled}
|
||||
onValueChange={changeAlarmEnabled}
|
||||
/>
|
||||
|
||||
<Text style={styles.text}>Predictive sets</Text>
|
||||
<Switch
|
||||
style={[styles.text, {alignSelf: 'flex-start'}]}
|
||||
value={predictiveSets}
|
||||
onValueChange={changePredictive}
|
||||
/>
|
||||
|
||||
<Button
|
||||
style={{alignSelf: 'flex-start'}}
|
||||
icon="arrow-down"
|
||||
onPress={exportSets}>
|
||||
Export
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
style={{alignSelf: 'flex-start'}}
|
||||
icon="arrow-up"
|
||||
onPress={importSets}>
|
||||
Import
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
style={{alignSelf: 'flex-start', marginTop: 'auto'}}
|
||||
icon="trash"
|
||||
|
|
Loading…
Reference in New Issue
Block a user