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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. });
  21. return (
  22. <View>
  23. <View style={styles.container, {
  24. flexDirection: "column"
  25. }}>
  26. <TitleBar
  27. onChangeDuration={onChangeDuration}
  28. durationMode={durationMode}
  29. dailyExpense={dailyObjective}
  30. onChangeObjective={onChangeObjective}/>
  31. <DepensesList durationMode={durationMode} />
  32. <StatusBar hidden />
  33. </View>
  34. <View>
  35. {/* Overlay for expenses */}
  36. <AddDepense/>
  37. </View>
  38. </View>
  39. );
  40. }
  41. const styles = StyleSheet.create({
  42. container: {
  43. flex: 1,
  44. backgroundColor: '#fff',
  45. alignItems: 'center',
  46. justifyContent: 'center',
  47. }
  48. });