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.

add_depense.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import React from 'react';
  2. import { StyleSheet, Text, View, TextInput, Button } from 'react-native';
  3. import { sqlite_exec_parameterised } from '../db/query';
  4. export default function AddDepense(props){
  5. const [addingDepense, onAddDepense] = React.useState(false);
  6. const [depenseValue, onValueEdit] = React.useState(null);
  7. const [descriptionValue, onDescriptionEdit] = React.useState(null);
  8. return (<View style={ add_depenses_styles.overlay }>
  9. <View >
  10. {addingDepense ?
  11. <View style={ add_depenses_styles.form_area }>
  12. <Text> Nouvelle dépense</Text>
  13. <View style={ add_depenses_styles.form_entry }>
  14. <Text> 💸</Text>
  15. <TextInput
  16. keyboardType="numeric"
  17. style={ add_depenses_styles.input }
  18. onChangeText={ (value) => {
  19. onValueEdit(value);
  20. }}
  21. />
  22. </View>
  23. <View style={ add_depenses_styles.form_entry }>
  24. <Text> 📃</Text>
  25. <TextInput style={ add_depenses_styles.input }
  26. onChangeText={ (value) => {
  27. onDescriptionEdit(value);
  28. }}
  29. />
  30. </View>
  31. <Button
  32. onPress={() =>
  33. {
  34. console.log(depenseValue);
  35. if(null != depenseValue)
  36. {
  37. sqlite_exec_parameterised(
  38. "INSERT INTO expense (value, description, date) values (?, ?, ?)",
  39. [depenseValue, descriptionValue, Date.now()], (res) => {
  40. onAddDepense(false);
  41. }
  42. );
  43. }
  44. }}
  45. title="Ajouter"/>
  46. </View>
  47. : <View/>}
  48. </View>
  49. <View style={ add_depenses_styles.button_add_parent }>
  50. <Button
  51. style={add_depenses_styles.button_add}
  52. title={!addingDepense ? "+" : "-"}
  53. onPress={() => onAddDepense(!addingDepense)}></Button>
  54. </View>
  55. </View>
  56. );
  57. }
  58. const add_depenses_styles = StyleSheet.create({
  59. overlay: {
  60. height: "100%",
  61. width: "100%",
  62. position: 'absolute',
  63. },
  64. form_area: {
  65. backgroundColor: '#f2c596',
  66. zIndex: 10,
  67. elevation: 10,
  68. display: 'flex',
  69. flexDirection: 'column'
  70. },
  71. form_entry :{
  72. display: 'flex',
  73. flexDirection: 'row',
  74. },
  75. input :{
  76. width: "50%",
  77. borderWidth: 1
  78. },
  79. button_add: {
  80. },
  81. button_add_parent: {
  82. position: 'absolute',
  83. bottom: 10,
  84. right: 10,
  85. }
  86. });