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