Layout changes, fix bugs in new entry page
This commit is contained in:
@@ -443,53 +443,59 @@ class _ValueBlockMenu extends StatelessWidget {
|
||||
return _ValueBlockView(block: block);
|
||||
}
|
||||
|
||||
Future<void> showContextMenuAt(Offset globalPosition) async {
|
||||
final overlay = Overlay.of(context);
|
||||
final renderBox = overlay?.context.findRenderObject() as RenderBox?;
|
||||
if (renderBox == null) return;
|
||||
final position = RelativeRect.fromRect(
|
||||
Rect.fromLTWH(
|
||||
globalPosition.dx,
|
||||
globalPosition.dy,
|
||||
1,
|
||||
1,
|
||||
),
|
||||
Offset.zero & renderBox.size,
|
||||
);
|
||||
|
||||
final action = await showMenu<_TimelineBlockAction>(
|
||||
context: context,
|
||||
position: position,
|
||||
items: [
|
||||
if (onEditEntry != null)
|
||||
const PopupMenuItem(
|
||||
value: _TimelineBlockAction.edit,
|
||||
child: Text('Edit'),
|
||||
),
|
||||
if (onDeleteEntry != null)
|
||||
const PopupMenuItem(
|
||||
value: _TimelineBlockAction.delete,
|
||||
child: Text('Delete'),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
final entry = block.entry;
|
||||
if (action == null || entry == null) return;
|
||||
switch (action) {
|
||||
case _TimelineBlockAction.edit:
|
||||
onEditEntry?.call(entry);
|
||||
break;
|
||||
case _TimelineBlockAction.delete:
|
||||
onDeleteEntry?.call(entry);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onLongPressStart: (details) async {
|
||||
final overlay = Overlay.of(context);
|
||||
final renderBox = overlay.context.findRenderObject() as RenderBox?;
|
||||
if (renderBox == null) return;
|
||||
if (defaultTargetPlatform == TargetPlatform.android) {
|
||||
HapticFeedback.lightImpact();
|
||||
}
|
||||
final anchor = details.globalPosition + const Offset(0, -8);
|
||||
final position = RelativeRect.fromRect(
|
||||
Rect.fromLTWH(
|
||||
anchor.dx,
|
||||
anchor.dy,
|
||||
1,
|
||||
1,
|
||||
),
|
||||
Offset.zero & renderBox.size,
|
||||
);
|
||||
|
||||
final action = await showMenu<_TimelineBlockAction>(
|
||||
context: context,
|
||||
position: position,
|
||||
items: [
|
||||
if (onEditEntry != null)
|
||||
const PopupMenuItem(
|
||||
value: _TimelineBlockAction.edit,
|
||||
child: Text('Edit'),
|
||||
),
|
||||
if (onDeleteEntry != null)
|
||||
const PopupMenuItem(
|
||||
value: _TimelineBlockAction.delete,
|
||||
child: Text('Delete'),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
final entry = block.entry;
|
||||
if (action == null || entry == null) return;
|
||||
switch (action) {
|
||||
case _TimelineBlockAction.edit:
|
||||
onEditEntry?.call(entry);
|
||||
break;
|
||||
case _TimelineBlockAction.delete:
|
||||
onDeleteEntry?.call(entry);
|
||||
break;
|
||||
}
|
||||
await showContextMenuAt(details.globalPosition);
|
||||
},
|
||||
onSecondaryTapDown: (details) async {
|
||||
await showContextMenuAt(details.globalPosition);
|
||||
},
|
||||
child: _ValueBlockView(block: block),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user