Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

App.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { StatusBar } from 'expo-status-bar';
  2. import React, { useEffect } from 'react';
  3. import { StyleSheet, Text, View, TextInput } from 'react-native';
  4. import { SafeAreaView } from 'react-native-safe-area-context';
  5. import AddDepense from './components/add_depense';
  6. import DepensesList from './components/depenses_list';
  7. import TitleBar from './components/title_bar';
  8. import {sqlite_exec_parameterised, sqlite_exec_query} from './db/query';
  9. export default function App() {
  10. const [durationMode, onChangeDuration] = React.useState("days");
  11. const [dailyObjective, onChangeObjective] = React.useState(-1);
  12. const [fetchDepenses, onFetchDepenses] = React.useState(true)
  13. if(dailyObjective != -1)
  14. sqlite_exec_parameterised("update objective set value = ?", [dailyObjective], (res) => {});
  15. useEffect( () => {
  16. sqlite_exec_query("create table if not exists objective(value integer)", (res)=>{
  17. sqlite_exec_query("select * from objective", (res) => {
  18. if(res.rows.length == 0)
  19. {
  20. sqlite_exec_parameterised("insert into objective (value) values (?)",[dailyObjective],(res)=>{})
  21. }
  22. else
  23. {
  24. onChangeObjective(res.rows._array[0].value);
  25. }
  26. });
  27. });
  28. });
  29. return (
  30. <SafeAreaView style={styles.home}>
  31. <View style={styles.container, {
  32. flexDirection: "column"
  33. }}>
  34. <TitleBar
  35. onChangeDuration={onChangeDuration}
  36. durationMode={durationMode}
  37. dailyExpense={dailyObjective}
  38. onChangeObjective={onChangeObjective}/>
  39. <DepensesList
  40. depensesFetched={() => onFetchDepenses(false)}
  41. fetchDepenses={fetchDepenses}
  42. dailyObjective={dailyObjective}
  43. durationMode={durationMode} />
  44. <StatusBar hidden />
  45. </View>
  46. {/* Overlay for expenses */}
  47. <AddDepense fetchDepenses={() => onFetchDepenses(true)}/>
  48. </SafeAreaView>
  49. );
  50. }
  51. const styles = StyleSheet.create({
  52. home: {
  53. width: '100%',
  54. height: '100%',
  55. backgroundColor: '#FFFFFF',
  56. },
  57. container: {
  58. flex: 1,
  59. backgroundColor: '#00FF00',
  60. alignItems: 'center',
  61. justifyContent: 'center',
  62. }
  63. });