| 1 | import 'package:cake_wallet/new-ui/widgets/modal_header.dart'; |
| 2 | import 'package:cake_wallet/new-ui/widgets/receive_page/receive_top_bar.dart'; |
| 3 | import 'package:flutter/material.dart'; |
| 4 | import 'package:modal_bottom_sheet/modal_bottom_sheet.dart'; |
| 5 | |
| 6 | void nothing() {} |
| 7 | |
| 8 | class ModalPageWrapper extends StatelessWidget { |
| 9 | ModalPageWrapper( |
| 10 | {super.key, |
| 11 | required this.content, |
| 12 | required this.topBar, |
| 13 | this.header, |
| 14 | this.bottomContent, |
| 15 | this.horizontalPadding = 18.0, |
| 16 | this.verticalPadding = 72.0}) {} |
| 17 | |
| 18 | final Widget content; |
| 19 | final Widget? bottomContent; |
| 20 | final ModalTopBar topBar; |
| 21 | final ModalHeader? header; |
| 22 | final double horizontalPadding; |
| 23 | final double verticalPadding; |
| 24 | |
| 25 | @override |
| 26 | Widget build(BuildContext context) { |
| 27 | const gradientSize = 84; |
| 28 | |
| 29 | return Container( |
| 30 | color: Theme.of(context).colorScheme.surface, |
| 31 | child: Scaffold( |
| 32 | resizeToAvoidBottomInset: true, |
| 33 | body: Stack( |
| 34 | alignment: Alignment.topCenter, |
| 35 | children: [ |
| 36 | Positioned.fill( |
| 37 | child: Padding( |
| 38 | padding: EdgeInsets.symmetric(horizontal: horizontalPadding), |
| 39 | child: CustomScrollView( |
| 40 | controller: ModalScrollController.of(context), |
| 41 | physics: ClampingScrollPhysics(), |
| 42 | slivers: [ |
| 43 | SliverToBoxAdapter(child: SizedBox(height: verticalPadding)), |
| 44 | if (header != null) ...[ |
| 45 | SliverToBoxAdapter(child: header), |
| 46 | SliverToBoxAdapter(child: SizedBox(height: 20)), |
| 47 | ], |
| 48 | SliverSafeArea(sliver: SliverToBoxAdapter(child: content)), |
| 49 | SliverToBoxAdapter(child: SizedBox(height: verticalPadding)), |
| 50 | ], |
| 51 | ))), |
| 52 | if (bottomContent != null) |
| 53 | Positioned( |
| 54 | bottom: 12, |
| 55 | left: horizontalPadding, |
| 56 | right: horizontalPadding, |
| 57 | child: SafeArea(child: bottomContent!), |
| 58 | ), |
| 59 | Container( |
| 60 | height: (MediaQuery.of(context).padding.top + gradientSize), |
| 61 | decoration: BoxDecoration( |
| 62 | gradient: LinearGradient( |
| 63 | begin: Alignment.bottomCenter, |
| 64 | end: Alignment.topCenter, |
| 65 | colors: <Color>[ |
| 66 | Theme.of(context).colorScheme.surface.withAlpha(5), |
| 67 | Theme.of(context).colorScheme.surface.withAlpha(25), |
| 68 | Theme.of(context).colorScheme.surface.withAlpha(50), |
| 69 | Theme.of(context).colorScheme.surface.withAlpha(100), |
| 70 | Theme.of(context).colorScheme.surface.withAlpha(150), |
| 71 | Theme.of(context).colorScheme.surface.withAlpha(200), |
| 72 | Theme.of(context).colorScheme.surface.withAlpha(235), |
| 73 | Theme.of(context).colorScheme.surface.withAlpha(255), |
| 74 | Theme.of(context).colorScheme.surface.withAlpha(255), |
| 75 | Theme.of(context).colorScheme.surface.withAlpha(255), |
| 76 | ], |
| 77 | ), |
| 78 | ), |
| 79 | ), |
| 80 | topBar, |
| 81 | ], |
| 82 | ), |
| 83 | ), |
| 84 | ); |
| 85 | } |
| 86 | } |