-
Notifications
You must be signed in to change notification settings - Fork 0
/
chat_thread.dart
60 lines (57 loc) · 1.6 KB
/
chat_thread.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
import 'package:flutter/material.dart';
class ChatThreadWidget extends StatefulWidget {
final String name;
final VoidCallback onTap;
const ChatThreadWidget({Key? key, required this.name, required this.onTap})
: super(key: key);
@override
State<ChatThreadWidget> createState() => _ChatThreadWidgetState();
}
class _ChatThreadWidgetState extends State<ChatThreadWidget> {
@override
Widget build(BuildContext context) {
return GestureDetector(
onLongPressStart: (details) {
final offset = details.globalPosition;
showMenu(
context: context,
position: RelativeRect.fromLTRB(
offset.dx,
offset.dy,
MediaQuery.of(context).size.width - offset.dx,
MediaQuery.of(context).size.height - offset.dy,
),
items: [
PopupMenuItem(
child: ListTile(
leading: Icon(Icons.edit_outlined),
title: Text('Rename'),
),
value: 'rename',
),
PopupMenuItem(
child: ListTile(
leading: Icon(Icons.delete_outline),
title: Text('Delete'),
),
value: 'delete',
),
],
elevation: 8.0,
).then((value) {
if (value == 'rename') {
// Handle edit option
} else if (value == 'delete') {
// Handle delete option
}
});
},
child: ListTile(
title: Text(widget.name),
onTap: () {
widget.onTap();
},
),
);
}
}