You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { StatusBar } from 'expo-status-bar';
  2. import React, { useEffect } from 'react';
  3. import { StyleSheet, Text, View, TextInput } from 'react-native';
  4. import AddDepense from './components/add_depense';
  5. import DepensesList from './components/depenses_list';
  6. import TitleBar from './components/title_bar';
  7. import {sqlite_exec_query} from './db/query';
  8. export default function App() {
  9. const [durationMode, onChangeDuration] = React.useState("days");
  10. const [dailyObjective, onChangeObjective] = React.useState(1);
  11. console.log("bah")
  12. useEffect( () => {
  13. sqlite_exec_query("create table if not exists objective(value integer)", (res)=>{
  14. sqlite_exec_query("select * from objective", (res) => {
  15. console.log(res.rows.length);
  16. if(res.rows.length == 0)
  17. onChangeObjective(15);
  18. });
  19. });
  20. sqlite_exec_query(`
  21. create table if not exists expense (id integer primary key not null, value real, description text, date integer);`,(res)=>{});
  22. });
  23. return (
  24. <View style={styles.home}>
  25. <View style={styles.container, {
  26. flexDirection: "column"
  27. }}>
  28. <TitleBar
  29. onChangeDuration={onChangeDuration}
  30. durationMode={durationMode}
  31. dailyExpense={dailyObjective}
  32. onChangeObjective={onChangeObjective}/>
  33. <DepensesList durationMode={durationMode} />
  34. <StatusBar hidden />
  35. </View>
  36. {/* Overlay for expenses */}
  37. <AddDepense/>
  38. </View>
  39. );
  40. }
  41. const styles = StyleSheet.create({
  42. home: {
  43. width: '100%',
  44. height: '100%',
  45. },
  46. container: {
  47. flex: 1,
  48. backgroundColor: '#00FF00',
  49. alignItems: 'center',
  50. justifyContent: 'center',
  51. }
  52. });