dev
dart 71 lines 2.06 KB
Raw
1 import 'package:cake_wallet/utils/responsive_layout_util.dart';
2 import 'package:flutter/material.dart';
3 import 'package:cake_wallet/src/widgets/alert_background.dart';
4 import 'package:cake_wallet/src/widgets/alert_close_button.dart';
5
6 class PickerWrapperWidget extends StatelessWidget {
7 PickerWrapperWidget({
8 required this.children,
9 this.hasTitle = false,
10 this.onClose,
11 super.key,
12 });
13
14 final List<Widget> children;
15 final bool hasTitle;
16 final Function()? onClose;
17
18 @override
19 Widget build(BuildContext context) {
20 final double padding = 24;
21
22 final mq = MediaQuery.of(context);
23 final bottom = mq.viewInsets.bottom;
24 final height = mq.size.height - bottom;
25 final screenCenter = height / 2;
26
27 double closeButtonBottom = 60;
28 double containerHeight = height * 0.65;
29 if (bottom > 0) {
30 // increase a bit or it gets too squished in the top
31 containerHeight = height * 0.75;
32
33 final containerCenter = containerHeight / 2;
34 final containerBottom = screenCenter - containerCenter;
35
36 // position the close button right below the search container
37 closeButtonBottom =
38 closeButtonBottom - containerBottom + (!hasTitle ? padding : padding / 1.5);
39 }
40
41 return AlertBackground(
42 child: Column(
43 children: [
44 Expanded(
45 flex: 1,
46 child: Stack(
47 alignment: Alignment.center,
48 children: <Widget>[
49 Column(
50 mainAxisSize: MainAxisSize.min,
51 children: children,
52 ),
53 SizedBox(height: ResponsiveLayoutUtilBase.kPopupSpaceHeight),
54 AlertCloseButton(
55 key: ValueKey('picker_wrapper_close_button_key'),
56 bottom: closeButtonBottom,
57 onTap: onClose,
58 ),
59 ],
60 ),
61 ),
62 // gives the extra spacing using MediaQuery.viewInsets.bottom
63 // to simulate a keyboard area
64 SizedBox(
65 height: bottom,
66 )
67 ],
68 ),
69 );
70 }
71 }