settings/test page will be changed

This commit is contained in:
moist-webDev 2023-06-06 00:21:31 -04:00
parent 4777a10404
commit 025c9fbf16
1 changed files with 79 additions and 5 deletions

View File

@ -1,25 +1,61 @@
import { StyleSheet, Text, View} from 'react-native'; import { StyleSheet, Text, View, Modal} from 'react-native';
import Button from '../components/Button'; import Button from '../components/Button';
import { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import DropDownPicker from 'react-native-dropdown-picker'; import DropDownPicker from 'react-native-dropdown-picker';
import AsyncStorage from '@react-native-async-storage/async-storage'; import AsyncStorage from '@react-native-async-storage/async-storage';
import RNExitApp from 'react-native-exit-app';
import db from '../lib/client';
import { light } from '../lib/theme';
export default function Settings({theme, changeTheme, themeMode}:any){ export default function Settings({theme, changeTheme, themeMode, clearAll}:any){
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const [value, setValue] = useState(themeMode); const [value, setValue] = useState(themeMode);
const [items, setItems] = useState([ const [items, setItems] = useState([
{label: 'System', value: 'auto'}, {label: 'System', value: 'auto'},
{label: 'Light', value: 'light'}, {label: 'Light', value: 'light'},
{label: 'Dark', value: 'dark'} {label: 'Dark', value: 'dark'},
{label: 'Solorized Dark', value: 'solorizedDark'},
{label: "OLED", value: 'oled'}
]); ]);
const [deleteAllModal, setDeleteAllModal] = useState(false);
const st = style(theme);
const test = async () => {
//const res = await db.from('test').insert({test: 'test'});
const res2 = await db.from('test').update({row: 'updated again'}).eq({'id': 1});
console.log(res2);
//const data = await AsyncStorage.getItem('test');
const data = await db.from('test').select().eq();
//console.log(data);
}
useEffect(() => {changeTheme(value)}, [value]); useEffect(() => {changeTheme(value)}, [value]);
return ( return (
<View style={style(theme).container}> <View style={style(theme).container}>
<Modal
animationType="slide"
transparent={true}
visible={deleteAllModal}
>
<View style={st.centeredView}>
<View style={st.modalView}>
<View style={st.modalContainer}>
<Text style={{...st.text, margin: 10}}>Are you sure you want to delete all data?</Text>
<View style={st.modalButtons}>
<Button theme={theme} title="No" onPress={() => setDeleteAllModal(false)} style={{width:'28%', padding:30}}/>
<Button theme={theme} title="Yes" onPress={() => {clearAll();setDeleteAllModal(false)}} style={{backgroundColor: theme.danger, width:'28%', padding:30}}/>
</View>
</View>
</View>
</View>
</Modal>
<View style={style(theme).row}> <View style={style(theme).row}>
<Text style={style(theme).text}>Choose Theme: </Text> <Text style={style(theme).droptext}>Choose Theme: </Text>
<DropDownPicker <DropDownPicker
open={open} open={open}
value={value} value={value}
@ -28,8 +64,11 @@ export default function Settings({theme, changeTheme, themeMode}:any){
setValue={setValue} setValue={setValue}
setItems={setItems} setItems={setItems}
style={style(theme).dropdown} style={style(theme).dropdown}
theme={theme.dropDown}
/> />
</View> </View>
<Button title="clear all" theme={theme} onPress={()=>setDeleteAllModal(true)}/>
<Button title="test" theme={theme} onPress={test}/>
</View> </View>
) )
} }
@ -39,19 +78,54 @@ const style = (theme:any) => {
container: { container: {
width: '100%', width: '100%',
}, },
text: { droptext: {
color: theme.text, color: theme.text,
width: '40%', width: '40%',
marginLeft: '20%', marginLeft: '20%',
padding: 10, padding: 10,
}, },
text: {
color: theme.text,
},
dropdown: { dropdown: {
backgroundColor: theme.primary, backgroundColor: theme.primary,
color: theme.text, color: theme.text,
width: '35%', width: '35%',
zIndex: 100,
}, },
row: { row: {
flexDirection: 'row', flexDirection: 'row',
zIndex: 100,
},
centeredView: {
flex: 1,
marginTop: 200,
},
modalView: {
margin: 20,
backgroundColor: theme.background,
borderRadius: 20,
width: '90%',
height: 200,
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.25,
shadowRadius: 4,
elevation: 5,
},
modalContainer: {
width: '100%',
height: '100%',
alignItems: 'center',
justifyContent: 'center',
textAlign: 'center',
},
modalButtons: {
flexDirection: 'row',
justifyContent: 'space-evenly',
width: '100%', width: '100%',
}, },
}); });