1
1
import 'package:flutter/cupertino.dart' ;
2
2
import 'package:flutter/material.dart' ;
3
+ import 'package:flutter_slidable/flutter_slidable.dart' ;
3
4
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart' ;
4
5
import 'package:givnotes/database/HiveDB.dart' ;
5
6
import 'package:givnotes/packages/unicorndial/speed_dial_controller.dart' ;
@@ -58,6 +59,13 @@ class NotesViewState extends State<NotesView> {
58
59
return AnimationLimiter (
59
60
child: ListView .builder (
60
61
itemCount: _notes.length,
62
+ //TODO maybe remove divider in const_notes_view and use separator
63
+ // separatorBuilder: (context, index) => Divider(
64
+ // height: 0.057 * wm,
65
+ // color: Colors.black,
66
+ // indent: 10,
67
+ // endIndent: 10,
68
+ // ),
61
69
itemBuilder: (context, index) {
62
70
_animateIndex = index;
63
71
index = _notes.length - index - 1 ;
@@ -70,37 +78,43 @@ class NotesViewState extends State<NotesView> {
70
78
child: SlideAnimation (
71
79
verticalOffset: 25.0 ,
72
80
child: FadeInAnimation (
73
- child: Dismissible (
81
+ child: Slidable (
74
82
key: UniqueKey (),
75
- background: Container (
76
- color: Var .isTrash ? Colors .teal[300 ] : Color (0xffEC625C ),
77
- width: double .infinity,
78
- child: Row (
79
- mainAxisAlignment: MainAxisAlignment .end,
80
- children: [
81
- Icon (
82
- Var .isTrash ? Icons .restore : Icons .delete,
83
- size: 10 * wm,
84
- ),
85
- SizedBox (width: 10 * wm)
86
- ],
87
- ),
88
- ),
89
- direction: DismissDirection .endToStart,
90
- onDismissed: (direction) {
91
- if (! Var .isTrash) {
92
- note.trash = ! note.trash;
93
- note.save ();
83
+ actionPane: SlidableBehindActionPane (),
84
+ actionExtentRatio: 1.0 ,
85
+ dismissal: SlidableDismissal (
86
+ child: SlidableDrawerDismissal (),
87
+ onDismissed: (actionType) {
88
+ if (! Var .isTrash) {
89
+ note.trash = ! note.trash;
90
+ note.save ();
91
+ print ('moved to Trash' );
92
+ // Scaffold.of(context).showSnackBar(SnackBar(content: Text('moved to Trash')));
94
93
95
- _multiSelectController.set (_notes.length);
96
- } else {
97
- note.trash = false ;
98
- note.save ();
99
- print ('moved to notes' );
94
+ _multiSelectController.set (_notes.length);
95
+ } else {
96
+ note.trash = false ;
97
+ note.save ();
98
+ print ('moved to Notes' );
99
+ // Scaffold.of(context).showSnackBar(SnackBar(content: Text('moved to Notes')));
100
100
101
- _multiSelectController.set (_notes.length);
102
- }
103
- },
101
+ _multiSelectController.set (_notes.length);
102
+ }
103
+ },
104
+ ),
105
+ secondaryActions: < Widget > [
106
+ ! Var .isTrash
107
+ ? iconSlideAction (
108
+ Colors .red,
109
+ Icons .delete,
110
+ 'Trash' ,
111
+ )
112
+ : iconSlideAction (
113
+ Color (0xff66a9e0 ),
114
+ Icons .restore,
115
+ 'Resotre' ,
116
+ ),
117
+ ],
104
118
child: NotesCard (
105
119
note: note,
106
120
index: index,
@@ -118,6 +132,7 @@ class NotesViewState extends State<NotesView> {
118
132
),
119
133
floatingActionButton: ! _multiSelectController.isSelecting && ! Var .isTrash
120
134
? UnicornDialer (
135
+ parentHeroTag: 'parent' ,
121
136
parentButton: Icon (
122
137
CupertinoIcons .add,
123
138
color: Colors .white,
@@ -172,6 +187,37 @@ class NotesViewState extends State<NotesView> {
172
187
);
173
188
}
174
189
190
+ Widget iconSlideAction (Color color, IconData icon, String caption) {
191
+ return IconSlideAction (
192
+ // caption: 'Trash',
193
+ color: color,
194
+ // icon: Icons.delete,
195
+ iconWidget: Row (
196
+ crossAxisAlignment: CrossAxisAlignment .center,
197
+ mainAxisAlignment: MainAxisAlignment .end,
198
+ children: [
199
+ Padding (
200
+ padding: const EdgeInsets .only (right: 40 ),
201
+ child: Column (
202
+ mainAxisAlignment: MainAxisAlignment .center,
203
+ children: [
204
+ Icon (
205
+ icon,
206
+ color: Colors .white,
207
+ ),
208
+ Text (
209
+ caption,
210
+ style: TextStyle (color: Colors .white),
211
+ ),
212
+ ],
213
+ ),
214
+ )
215
+ ],
216
+ ),
217
+ onTap: () => Scaffold .of (context).showSnackBar (SnackBar (content: Text ('moved to Trash' ))),
218
+ );
219
+ }
220
+
175
221
List <UnicornButton > unicornButton = [
176
222
Var .isTrash
177
223
? UnicornButton (
@@ -291,35 +337,44 @@ class NotesViewState extends State<NotesView> {
291
337
}
292
338
}
293
339
294
- class NotesCardTemp extends StatefulWidget {
295
- NotesCardTemp ({
296
- Key key,
297
- @required this .index,
298
- @required this .note,
299
- @required this .multiSelectController,
300
- this .notesViewUpdate,
301
- }) : super (key: key);
340
+ // Dismissible(
341
+ // key: UniqueKey(),
342
+ // background: Container(
343
+ // color: Var.isTrash ? Colors.teal[300] : Color(0xffEC625C),
344
+ // width: double.infinity,
345
+ // child: Row(
346
+ // mainAxisAlignment: MainAxisAlignment.end,
347
+ // children: [
348
+ // Icon(
349
+ // Var.isTrash ? Icons.restore : Icons.delete,
350
+ // size: 10 * wm,
351
+ // ),
352
+ // SizedBox(width: 10 * wm)
353
+ // ],
354
+ // ),
355
+ // ),
356
+ // direction: DismissDirection.endToStart,
357
+ // onDismissed: (direction) {
358
+ // if (!Var.isTrash) {
359
+ // note.trash = !note.trash;
360
+ // note.save();
302
361
303
- final int index;
304
- final NotesModel note;
305
- final MultiSelectController multiSelectController;
306
- final Function notesViewUpdate;
362
+ // _multiSelectController.set(_notes.length);
363
+ // } else {
364
+ // note.trash = false;
365
+ // note.save();
366
+ // print('moved to notes');
307
367
308
- @override
309
- _NotesCardTempState createState () => _NotesCardTempState ();
310
- }
311
-
312
- class _NotesCardTempState extends State <NotesCardTemp > {
313
- @override
314
- Widget build (BuildContext context) {
315
- return NotesCard (
316
- note: widget.note,
317
- index: widget.index,
318
- multiSelectController: widget.multiSelectController,
319
- notesViewUpdate: widget.notesViewUpdate,
320
- );
321
- }
322
- }
368
+ // _multiSelectController.set(_notes.length);
369
+ // }
370
+ // },
371
+ // child: NotesCard(
372
+ // note: note,
373
+ // index: index,
374
+ // multiSelectController: _multiSelectController,
375
+ // notesViewUpdate: refreshNotesView,
376
+ // ),
377
+ // ),
323
378
324
379
// return multiSelectController.isSelecting == false
325
380
// ? OpenContainer(
0 commit comments