/
bookmark_tile.dart
67 lines (62 loc) · 2.01 KB
/
bookmark_tile.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import '../../../shared/constants.dart';
import '../../../shared/models/feed_item.dart';
import '../../../shared/util/url.dart';
import '../../../shared/widgets/tile.dart';
import '../bookmark_controller.dart';
class BookmarkTile extends StatelessWidget {
final int index;
final FeedItem bookmark;
final GestureTapCallback onTap;
final BookmarkController controller = Modular.get();
BookmarkTile({Key key, this.index, this.bookmark, this.onTap}) : super(key: key);
@override
Widget build(BuildContext context) {
return Slidable(
key: Key(bookmark.id.toString()),
controller: controller.slidableController,
actionExtentRatio: actionExtentRatio,
actionPane: SlidableDrawerActionPane(),
child: Tile(
title: Text(bookmark.title),
type: bookmark.type,
user: bookmark.user,
domain: bookmark.domain,
time: bookmark.time,
onTap: onTap,
),
secondaryActions: <Widget>[
IconSlideAction(
caption: 'Delete',
color: Colors.blueGrey,
icon: MdiIcons.bookmarkRemove,
onTap: () {
Scaffold.of(context).showSnackBar(
SnackBar(
content: Text('Bookmark deleted'),
action: SnackBarAction(
label: 'Undo',
onPressed: () {
controller.undoDelete(index, bookmark);
},
),
),
);
controller.deleteBookmark(bookmark);
},
),
IconSlideAction(
caption: 'Share',
color: Colors.indigo,
icon: MdiIcons.shareVariant,
onTap: () {
UrlUtil().share(title: bookmark.title, url: bookmark.url);
},
),
],
);
}
}