1
+ import 'dart:ui' ;
2
+
1
3
import 'package:finacash/Helper/Movimentacoes_helper.dart' ;
2
4
import 'package:finacash/Widgets/AnimatedBottomNavBar.dart' ;
3
5
import 'package:finacash/Widgets/CardMovimentacoesItem.dart' ;
@@ -21,12 +23,13 @@ class _HomePageState extends State<HomePage> {
21
23
var width;
22
24
var height;
23
25
bool recDesp = false ;
24
-
26
+ final GlobalKey <ScaffoldState > _scafoldKey = GlobalKey <ScaffoldState >();
27
+ MovimentacoesHelper movHelper = MovimentacoesHelper ();
25
28
TextEditingController _valorController = TextEditingController ();
26
29
CalendarController calendarController;
27
30
MovimentacoesHelper movimentacoesHelper = MovimentacoesHelper ();
28
31
List <Movimentacoes > listmovimentacoes = List ();
29
-
32
+ List < Movimentacoes > ultimaTarefaRemovida = List ();
30
33
31
34
var dataAtual = new DateTime .now ();
32
35
var formatter = new DateFormat ('dd-MM-yyyy' );
@@ -83,7 +86,6 @@ class _HomePageState extends State<HomePage> {
83
86
total =
84
87
listmovimentacoes.map ((item) => item.valor).reduce ((a, b) => a + b);
85
88
saldoAtual = format (total).toString ();
86
-
87
89
} else {
88
90
setState (() {
89
91
listmovimentacoes.clear ();
@@ -113,75 +115,64 @@ class _HomePageState extends State<HomePage> {
113
115
//_allMov();
114
116
}
115
117
116
- _dialogAddRecDesp (){
117
-
118
+ _dialogAddRecDesp () {
118
119
showDialog (
119
- context: context,
120
- builder: (context){
121
- return CustomDialog ();/*AlertDialog(
122
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
123
- title: Text("Adicionar Valores",textAlign: TextAlign.center, style: TextStyle(
124
- fontWeight: FontWeight.bold,
125
- color: Colors.lightBlue
126
- ),
127
- ),
128
- backgroundColor: Colors.white,
129
- content: CustomDialog()
130
- );*/
131
- }
132
- );
120
+ context: context,
121
+ builder: (context) {
122
+ return CustomDialog ();
123
+ });
133
124
}
134
125
135
126
@override
136
127
Widget build (BuildContext context) {
137
128
width = MediaQuery .of (context).size.width;
138
129
height = MediaQuery .of (context).size.height;
139
-
130
+
140
131
_allMovMes (dataFormatada);
141
- return Scaffold (
132
+ return Scaffold (
133
+ key: _scafoldKey,
142
134
body: SingleChildScrollView (
143
135
primary: false ,
144
136
physics: NeverScrollableScrollPhysics (),
145
137
//height: height,
146
138
//width: width,
147
139
child: Column (
148
-
149
140
children: < Widget > [
150
141
Stack (
151
142
children: < Widget > [
152
-
153
143
Container (
154
144
width: double .infinity,
155
- height: height * 0.334 ,//300,
145
+ height: height * 0.334 , //300,
156
146
color: Colors .white,
157
147
),
158
-
159
148
Positioned (
160
149
top: 0 ,
161
150
left: 0 ,
162
151
right: 0 ,
163
152
child: Container (
164
153
width: double .infinity,
165
- height: height * 0.28 , //250,
154
+ height: height * 0.28 , //250,
166
155
decoration: BoxDecoration (
167
- color: Colors .lightBlue[700 ], //Colors.indigo[400],
156
+ color: Colors .lightBlue[700 ], //Colors.indigo[400],
168
157
)),
169
158
),
170
159
Positioned (
171
- top: width * 0.18 ,//70
172
- left: width * 0.07 ,//30,
173
- child: Text ("FinaCash" ,style: TextStyle (
174
- color: Colors .white,
175
- fontSize: width * 0.074 //30
176
- ),),
160
+ top: width * 0.18 , //70
161
+ left: width * 0.07 , //30,
162
+ child: Text (
163
+ "FinaCash" ,
164
+ style: TextStyle (
165
+ color: Colors .white, fontSize: width * 0.074 //30
166
+ ),
167
+ ),
177
168
),
178
169
Positioned (
179
170
bottom: 0 ,
180
- left: width * 0.07 ,// 30,
181
- right: width * 0.07 ,// 30,
171
+ left: width * 0.07 , // 30,
172
+ right: width * 0.07 , // 30,
182
173
child: Container (
183
- height: height * 0.16 , //150,
184
- width: width * 0.1 ,// 70,
174
+ height: height * 0.16 , //150,
175
+ width: width * 0.1 , // 70,
185
176
decoration: BoxDecoration (
186
177
color: Colors .white,
187
178
borderRadius: BorderRadius .circular (20 ),
@@ -197,7 +188,11 @@ class _HomePageState extends State<HomePage> {
197
188
mainAxisSize: MainAxisSize .min,
198
189
children: < Widget > [
199
190
Padding (
200
- padding: EdgeInsets .only (left: width * 0.05 ,top: width * 0.04 ,bottom: width * 0.02 ,),
191
+ padding: EdgeInsets .only (
192
+ left: width * 0.05 ,
193
+ top: width * 0.04 ,
194
+ bottom: width * 0.02 ,
195
+ ),
201
196
child: Text (
202
197
"Total" ,
203
198
style: TextStyle (
@@ -210,13 +205,15 @@ class _HomePageState extends State<HomePage> {
210
205
mainAxisAlignment: MainAxisAlignment .spaceBetween,
211
206
children: < Widget > [
212
207
Padding (
213
- padding: EdgeInsets .only (left: width * 0.05 ),
208
+ padding: EdgeInsets .only (left: width * 0.05 ),
214
209
child: Text (
215
210
saldoAtual,
216
211
style: TextStyle (
217
- color: Colors .lightBlue[700 ], //Colors.indigo[400],
212
+ color: Colors
213
+ .lightBlue[700 ], //Colors.indigo[400],
218
214
fontWeight: FontWeight .bold,
219
- fontSize: width * 0.1 //_saldoTamanho(saldoAtual)
215
+ fontSize:
216
+ width * 0.1 //_saldoTamanho(saldoAtual)
220
217
),
221
218
),
222
219
),
@@ -225,7 +222,7 @@ class _HomePageState extends State<HomePage> {
225
222
child: GestureDetector (
226
223
onTap: () {
227
224
_dialogAddRecDesp ();
228
- /* Navigator.push(
225
+ /* Navigator.push(
229
226
context,
230
227
MaterialPageRoute(
231
228
builder: (context) => AddReceita()));
@@ -235,7 +232,8 @@ class _HomePageState extends State<HomePage> {
235
232
width: width * 0.12 ,
236
233
height: width * 0.12 , //65,
237
234
decoration: BoxDecoration (
238
- color: Colors .lightBlue[700 ], //Colors.indigo[400],
235
+ color: Colors
236
+ .lightBlue[700 ], //Colors.indigo[400],
239
237
borderRadius: BorderRadius .circular (50 ),
240
238
boxShadow: [
241
239
BoxShadow (
@@ -254,7 +252,9 @@ class _HomePageState extends State<HomePage> {
254
252
)
255
253
],
256
254
),
257
- SizedBox (height: height * 0.008 ,)
255
+ SizedBox (
256
+ height: height * 0.008 ,
257
+ )
258
258
],
259
259
),
260
260
),
@@ -288,7 +288,8 @@ class _HomePageState extends State<HomePage> {
288
288
},
289
289
),
290
290
Padding (
291
- padding: EdgeInsets .only (left: width * 0.04 , right: width * 0.04 ),
291
+ padding:
292
+ EdgeInsets .only (left: width * 0.04 , right: width * 0.04 ),
292
293
child: Row (
293
294
mainAxisAlignment: MainAxisAlignment .spaceBetween,
294
295
children: < Widget > [
@@ -308,21 +309,73 @@ class _HomePageState extends State<HomePage> {
308
309
],
309
310
)),
310
311
Padding (
311
- padding: EdgeInsets .only (left: width * 0.04 , right: width * 0.04 , top: 0 ),
312
+ padding: EdgeInsets .only (
313
+ left: width * 0.04 , right: width * 0.04 , top: 0 ),
312
314
child: SizedBox (
313
315
width: width,
314
316
height: height * 0.47 ,
315
317
child: ListView .builder (
316
318
itemCount: listmovimentacoes.length,
317
319
itemBuilder: (context, index) {
318
320
Movimentacoes mov = listmovimentacoes[index];
319
- return CardMovimentacoesItem (
320
- mov: mov,
321
+ Movimentacoes ultMov = listmovimentacoes[index];
322
+ return Dismissible (
323
+ direction: DismissDirection .endToStart,
324
+ onDismissed: (direction) {
325
+ //_dialogConfimacao(context, width, mov,index);
326
+
327
+ setState (() {
328
+ listmovimentacoes.removeAt (index);
329
+ });
330
+ movHelper.deleteMovimentacao (mov);
331
+ final snackBar = SnackBar (
332
+ content: Container (
333
+ padding: EdgeInsets .only (bottom: width * 0.025 ),
334
+ alignment: Alignment .bottomLeft,
335
+ height: height * 0.05 ,
336
+ child: Text (
337
+ "Desfazer Ação" ,
338
+ style: TextStyle (
339
+ color: Colors .white,
340
+ //fontWeight: FontWeight.bold,
341
+ fontSize: width * 0.05 ),
342
+ ),
343
+ ),
344
+ duration: Duration (seconds: 2 ),
345
+ backgroundColor: Colors .orange[800 ],
346
+ shape: RoundedRectangleBorder (
347
+ borderRadius: BorderRadius .only (
348
+ topLeft: Radius .circular (15 ),
349
+ topRight: Radius .circular (15 ))),
350
+ action: SnackBarAction (
351
+ label: "Desfazer" ,
352
+ textColor: Colors .white,
353
+ onPressed: () {
354
+ setState (() {
355
+ listmovimentacoes.insert (index, ultMov);
356
+ });
357
+
358
+ movHelper.saveMovimentacao (ultMov);
359
+ },
360
+ ),
361
+ );
362
+ _scafoldKey.currentState.showSnackBar (snackBar);
363
+ },
364
+ key: ValueKey (mov.id),
365
+ background: Container (
366
+ padding: EdgeInsets .only (right: 10 ),
367
+ alignment: Alignment .centerRight,
368
+ color: Colors .red,
369
+ child: Icon (
370
+ Icons .delete_outline,
371
+ color: Colors .white,
372
+ size: width * 0.07 ,
373
+ ),
374
+ ),
375
+ child: CardMovimentacoesItem (
376
+ mov: mov,
377
+ ),
321
378
);
322
- /*return ListTile(
323
- title: Text(mov.valor.toString()),
324
- subtitle: Text(mov.tipo),
325
- );*/
326
379
},
327
380
),
328
381
),
0 commit comments