Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

App.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_parameterised, 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. if(dailyObjective != -1)
  12. sqlite_exec_parameterised("update objective set value = ?", [dailyObjective], (res) => {});
  13. useEffect( () => {
  14. sqlite_exec_query("create table if not exists objective(value integer)", (res)=>{
  15. sqlite_exec_query("select * from objective", (res) => {
  16. if(res.rows.length == 0)
  17. {
  18. sqlite_exec_parameterised("insert into objective (value) values (?)",[dailyObjective],(res)=>{})
  19. }
  20. else
  21. {
  22. onChangeObjective(res.rows._array[0].value);
  23. }
  24. });
  25. });
  26. });
  27. return (
  28. <View style={styles.home}>
  29. <View style={styles.container, {
  30. flexDirection: "column"
  31. }}>
  32. <TitleBar
  33. onChangeDuration={onChangeDuration}
  34. durationMode={durationMode}
  35. dailyExpense={dailyObjective}
  36. onChangeObjective={onChangeObjective}/>
  37. <DepensesList durationMode={durationMode} />
  38. <StatusBar hidden />
  39. </View>
  40. {/* Overlay for expenses */}
  41. <AddDepense/>
  42. </View>
  43. );
  44. }
  45. const styles = StyleSheet.create({
  46. home: {
  47. width: '100%',
  48. height: '100%',
  49. },
  50. container: {
  51. flex: 1,
  52. backgroundColor: '#00FF00',
  53. alignItems: 'center',
  54. justifyContent: 'center',
  55. }
  56. });