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.

App.js 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 style={styles.home}>
  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. {/* Overlay for expenses */}
  35. <AddDepense/>
  36. </View>
  37. );
  38. }
  39. const styles = StyleSheet.create({
  40. home: {
  41. width: '100%',
  42. height: '100%',
  43. },
  44. container: {
  45. flex: 1,
  46. backgroundColor: '#00FF00',
  47. alignItems: 'center',
  48. justifyContent: 'center',
  49. }
  50. });