123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import React, { useEffect } from 'react';
- import { StyleSheet, Text, View, TextInput } from 'react-native';
- import { sqlite_exec_query } from '../db/query';
- import DepenseListEntry from './depense_list_entry';
-
-
- function DepensesList(props)
- {
- const [depenses, onGetDepenses] = React.useState([]);
- useEffect( () => {
- sqlite_exec_query(`create table if not exists expense (id integer primary key not null, value real, description text, date integer);`,(res)=>{
- sqlite_exec_query("select * from expense", (res) => {
- onGetDepenses(res.rows._array);
- });
- });
-
- });
- let content = []
-
- depenses
- .sort((a,b) => (a.date > b.date) ? -1 : (b.date > a.date) ? 1 : 0)
- .forEach( function(depense){
- content.push(
- <DepenseListEntry key={"depense_list_depense"+depense.id} depense={depense}/>
-
- )
- });
-
- return(
- <View>
- {content}
- </View>
- )
- }
-
- const depense_list_style = StyleSheet.create({
- depense_list_entry: {
- display: "flex",
- flexDirection: "row",
- justifyContent: "space-between",
- // flex: 1,
- // backgroundColor: '#00FF00',
- // alignItems: 'center',
- // justifyContent: 'center',
- }
- });
-
- export default DepensesList
|