1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import { StatusBar } from 'expo-status-bar';
- import React, { useEffect } from 'react';
- import { StyleSheet, Text, View, TextInput } from 'react-native';
- import DepensesList from './components/depenses_list';
- import TitleBar from './components/title_bar';
-
- // https://github.com/expo/examples/blob/master/with-sqlite/App.js
- import * as SQLite from 'expo-sqlite';
-
- const db = SQLite.openDatabase("datacoucou.db");
-
-
- export default function App() {
- const [durationMode, onChangeDuration] = React.useState("days");
- const [dailyObjective, onChangeObjective] = React.useState(15);
-
- useEffect( () => {
- db.transaction((tx) => {
- tx.executeSql(
- `
- create table if not exists expense (id integer primary key not null, value real, description text, date integer);
- create table if not exists objective(value integer);
- `
- );
- });
- }, [])
-
- return (
- <View style={styles.container, {
- flexDirection: "column"
- }}>
- <TitleBar
- onChangeDuration={onChangeDuration}
- durationMode={durationMode}
- dailyExpense={dailyObjective}
- onChangeObjective={onChangeObjective}/>
- <DepensesList durationMode={durationMode} database={db}/>
- <StatusBar hidden />
- </View>
- );
- }
-
- const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: '#fff',
- alignItems: 'center',
- justifyContent: 'center',
- }
- });
|