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.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { StatusBar } from 'expo-status-bar';
  2. import React, { useEffect } from 'react';
  3. import { StyleSheet, Text, View, TextInput } from 'react-native';
  4. import DepensesList from './components/depenses_list';
  5. import TitleBar from './components/title_bar';
  6. // https://github.com/expo/examples/blob/master/with-sqlite/App.js
  7. import * as SQLite from 'expo-sqlite';
  8. const db = SQLite.openDatabase("datacoucou.db");
  9. export default function App() {
  10. const [durationMode, onChangeDuration] = React.useState("days");
  11. const [dailyObjective, onChangeObjective] = React.useState(15);
  12. useEffect( () => {
  13. db.transaction((tx) => {
  14. tx.executeSql(
  15. `
  16. create table if not exists expense (id integer primary key not null, value real, description text, date integer);
  17. create table if not exists objective(value integer);
  18. `
  19. );
  20. });
  21. }, [])
  22. return (
  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} database={db}/>
  32. <StatusBar hidden />
  33. </View>
  34. );
  35. }
  36. const styles = StyleSheet.create({
  37. container: {
  38. flex: 1,
  39. backgroundColor: '#fff',
  40. alignItems: 'center',
  41. justifyContent: 'center',
  42. }
  43. });