dev
dart 58 lines 1.49 KB
Raw
1 import 'dart:ui';
2
3 import 'package:cake_wallet/utils/show_pop_up.dart';
4 import 'package:flutter/material.dart';
5
6 class LongPressPopupBuilder extends StatelessWidget {
7 const LongPressPopupBuilder(
8 {super.key, required this.child, required this.popup, this.spacing = 8});
9
10 final Widget child;
11 final Widget popup;
12 final double spacing;
13
14 @override
15 Widget build(BuildContext context) {
16 return GestureDetector(
17 onLongPress: () {
18 final RenderBox renderBox = context.findRenderObject() as RenderBox;
19 final offset = renderBox.localToGlobal(Offset.zero);
20 final size = renderBox.size;
21
22 showPopUp(
23 context: context,
24 builder: (context) => _buildPopup(context, offset, size),
25 );
26 },
27 child: child,
28 );
29 }
30
31 Widget _buildPopup(BuildContext context, Offset offset, Size size) {
32 return BackdropFilter(
33 filter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0),
34 child: Stack(
35 children: [
36 Positioned(
37 left: offset.dx,
38 top: offset.dy,
39 width: size.width,
40 height: size.height,
41 child: Material(
42 color: Colors.transparent,
43 child: child,
44 ),
45 ),
46 Positioned(
47 left: offset.dx * 2,
48 top: offset.dy + size.height + spacing,
49 child: Material(
50 color: Colors.transparent,
51 child: popup,
52 ),
53 ),
54 ],
55 ),
56 );
57 }
58 }