| 1 | import 'package:flutter/material.dart'; |
| 2 | import 'package:cake_wallet/src/widgets/picker_wrapper_widget.dart'; |
| 3 | import 'package:cake_wallet/utils/responsive_layout_util.dart'; |
| 4 | |
| 5 | class PickerInnerWrapperWidget extends StatelessWidget { |
| 6 | PickerInnerWrapperWidget({required this.children, this.title, this.itemsHeight}); |
| 7 | |
| 8 | final List<Widget> children; |
| 9 | final String? title; |
| 10 | final double? itemsHeight; |
| 11 | |
| 12 | @override |
| 13 | Widget build(BuildContext context) { |
| 14 | final mq = MediaQuery.of(context); |
| 15 | final bottom = mq.viewInsets.bottom; |
| 16 | final height = mq.size.height - bottom; |
| 17 | |
| 18 | double containerHeight = height * 0.65; |
| 19 | if (bottom > 0) { |
| 20 | // increase a bit or it gets too squished in the top |
| 21 | containerHeight = height * 0.75; |
| 22 | } |
| 23 | |
| 24 | if (title != null) { |
| 25 | return PickerWrapperWidget( |
| 26 | hasTitle: true, |
| 27 | children: <Widget>[ |
| 28 | Container( |
| 29 | padding: EdgeInsets.symmetric(horizontal: 24), |
| 30 | child: Text( |
| 31 | title!, |
| 32 | textAlign: TextAlign.center, |
| 33 | style: Theme.of(context).textTheme.titleMedium?.copyWith( |
| 34 | fontWeight: FontWeight.bold, |
| 35 | fontSize: 18, |
| 36 | decoration: TextDecoration.none, |
| 37 | color: Theme.of(context).colorScheme.onSurface, |
| 38 | ), |
| 39 | ), |
| 40 | ), |
| 41 | SizedBox(height: 8), |
| 42 | Padding( |
| 43 | padding: EdgeInsets.symmetric(horizontal: 24), |
| 44 | child: ClipRRect( |
| 45 | borderRadius: BorderRadius.all(Radius.circular(14)), |
| 46 | child: Container( |
| 47 | color: Theme.of(context).colorScheme.surfaceContainerHighest, |
| 48 | child: ConstrainedBox( |
| 49 | constraints: BoxConstraints( |
| 50 | maxHeight: itemsHeight != null && itemsHeight! <= containerHeight |
| 51 | ? itemsHeight! |
| 52 | : containerHeight, |
| 53 | maxWidth: ResponsiveLayoutUtilBase.kPopupWidth, |
| 54 | ), |
| 55 | child: Column( |
| 56 | children: children, |
| 57 | ), |
| 58 | ), |
| 59 | ), |
| 60 | ), |
| 61 | ) |
| 62 | ], |
| 63 | ); |
| 64 | } |
| 65 | |
| 66 | return PickerWrapperWidget( |
| 67 | hasTitle: false, |
| 68 | children: <Widget>[ |
| 69 | Padding( |
| 70 | padding: EdgeInsets.symmetric(horizontal: 24), |
| 71 | child: ClipRRect( |
| 72 | borderRadius: BorderRadius.all(Radius.circular(14)), |
| 73 | child: Container( |
| 74 | color: Theme.of(context).colorScheme.surfaceContainerHighest, |
| 75 | child: ConstrainedBox( |
| 76 | constraints: BoxConstraints( |
| 77 | maxHeight: containerHeight, |
| 78 | maxWidth: ResponsiveLayoutUtilBase.kPopupWidth, |
| 79 | ), |
| 80 | child: Column( |
| 81 | children: children, |
| 82 | ), |
| 83 | ), |
| 84 | ), |
| 85 | ), |
| 86 | ) |
| 87 | ], |
| 88 | ); |
| 89 | } |
| 90 | } |