Add show images setting

This commit is contained in:
Brandon Presley 2022-09-01 13:06:49 +12:00
parent 663d0f7ba4
commit 137ecf4a77
3 changed files with 41 additions and 5 deletions

View File

@ -24,6 +24,7 @@ export default function SettingsPage() {
const [predict, setPredict] = useState(false);
const [sound, setSound] = useState<string>('');
const [notify, setNotify] = useState(false);
const [images, setImages] = useState(false);
const [battery, setBattery] = useState(false);
const [ignoring, setIgnoring] = useState(false);
const [search, setSearch] = useState('');
@ -42,6 +43,7 @@ export default function SettingsPage() {
setVibrate(!!settings.vibrate);
setSound(settings.sound);
setNotify(!!settings.notify);
setImages(!!settings.images);
NativeModules.AlarmModule.ignoringBattery(setIgnoring);
}, [db]);
@ -51,10 +53,31 @@ export default function SettingsPage() {
useEffect(() => {
db.executeSql(
`UPDATE settings SET vibrate=?,minutes=?,sets=?,seconds=?,alarm=?,predict=?,sound=?,notify=?`,
[vibrate, minutes, maxSets, seconds, alarm, predict, sound, notify],
`UPDATE settings SET vibrate=?,minutes=?,sets=?,seconds=?,alarm=?,predict=?,sound=?,notify=?,images=?`,
[
vibrate,
minutes,
maxSets,
seconds,
alarm,
predict,
sound,
notify,
images,
],
);
}, [vibrate, minutes, maxSets, seconds, alarm, predict, sound, notify, db]);
}, [
vibrate,
minutes,
maxSets,
seconds,
alarm,
predict,
sound,
notify,
db,
images,
]);
const changeAlarmEnabled = useCallback(
(enabled: boolean) => {
@ -191,6 +214,19 @@ export default function SettingsPage() {
</>
),
},
{
name: 'Show images',
element: (
<>
<Text style={styles.text}>Show images</Text>
<MassiveSwitch
style={[styles.text, {alignSelf: 'flex-start'}]}
value={images}
onValueChange={setImages}
/>
</>
),
},
{
name: 'Alarm sound',
element: (

3
db.ts
View File

@ -64,8 +64,7 @@ const selectSettings = `
`;
const insertSettings = `
INSERT INTO settings(minutes,seconds,alarm,vibrate,predict,sets)
VALUES(3,30,false,true,true,3);
INSERT INTO settings(minutes) VALUES(3);
`;
export const getDb = async () => {

View File

@ -7,4 +7,5 @@ export default interface Settings {
sets: number;
sound: string;
notify: number;
images: number;
}