| 1 | import 'package:cake_wallet/di.dart'; |
| 2 | import 'package:cake_wallet/generated/i18n.dart'; |
| 3 | import 'package:cake_wallet/new-ui/pages/bridge/bridge_detail_page.dart'; |
| 4 | import 'package:cake_wallet/new-ui/widgets/receive_page/receive_top_bar.dart'; |
| 5 | import 'package:cake_wallet/view_model/bridge/bridge_history_view_model.dart'; |
| 6 | import 'package:cake_wallet/new-ui/widgets/bridge/transfer_history_row.dart'; |
| 7 | import 'package:flutter/material.dart'; |
| 8 | import 'package:flutter_mobx/flutter_mobx.dart'; |
| 9 | |
| 10 | class BridgeHistoryPage extends StatelessWidget { |
| 11 | BridgeHistoryPage(this.viewModel); |
| 12 | |
| 13 | final BridgeHistoryViewModel viewModel; |
| 14 | |
| 15 | @override |
| 16 | Widget build(BuildContext context) { |
| 17 | final theme = Theme.of(context); |
| 18 | |
| 19 | return Container( |
| 20 | decoration: BoxDecoration( |
| 21 | color: theme.colorScheme.surface, |
| 22 | borderRadius: const BorderRadius.vertical(top: Radius.circular(16)), |
| 23 | ), |
| 24 | child: Column( |
| 25 | children: [ |
| 26 | ModalTopBar( |
| 27 | title: "Bridge history", |
| 28 | leadingIcon: const Icon(Icons.arrow_back_ios_new, size: 18), |
| 29 | leadingSemanticLabel: S.of(context).seed_alert_back, |
| 30 | onLeadingPressed: () => Navigator.of(context).pop(), |
| 31 | ), |
| 32 | Expanded( |
| 33 | child: Observer( |
| 34 | builder: (_) { |
| 35 | if (viewModel.isEmpty) { |
| 36 | return Center( |
| 37 | child: Padding( |
| 38 | padding: const EdgeInsets.all(24), |
| 39 | child: Text( |
| 40 | "No bridge transfers yet.", |
| 41 | textAlign: TextAlign.center, |
| 42 | style: Theme.of(context).textTheme.bodyLarge, |
| 43 | ), |
| 44 | ), |
| 45 | ); |
| 46 | } |
| 47 | |
| 48 | final active = viewModel.activeTransfers; |
| 49 | final past = viewModel.pastTransfers; |
| 50 | final items = <Widget>[]; |
| 51 | |
| 52 | if (active.isNotEmpty) { |
| 53 | items.add( |
| 54 | Padding( |
| 55 | padding: const EdgeInsets.only(bottom: 8.0), |
| 56 | child: Text( |
| 57 | "In progress", |
| 58 | style: Theme.of(context).textTheme.titleSmall, |
| 59 | ), |
| 60 | ), |
| 61 | ); |
| 62 | for (final transfer in active) { |
| 63 | items.add( |
| 64 | TransferHistoryRow( |
| 65 | transfer: transfer, |
| 66 | onTap: () { |
| 67 | final page = getIt.get<BridgeDetailPage>(param1: transfer); |
| 68 | showModalBottomSheet( |
| 69 | backgroundColor: Colors.transparent, |
| 70 | isScrollControlled: true, |
| 71 | context: context, |
| 72 | builder: (context) => page, |
| 73 | ); |
| 74 | }, |
| 75 | ), |
| 76 | ); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | if (past.isNotEmpty) { |
| 81 | items.add( |
| 82 | Padding( |
| 83 | padding: const EdgeInsets.only(bottom: 8.0, top: 16), |
| 84 | child: Text( |
| 85 | "Past", |
| 86 | style: Theme.of(context).textTheme.titleSmall, |
| 87 | ), |
| 88 | ), |
| 89 | ); |
| 90 | for (final transfer in past) { |
| 91 | items.add( |
| 92 | TransferHistoryRow( |
| 93 | transfer: transfer, |
| 94 | onTap: () { |
| 95 | final page = getIt.get<BridgeDetailPage>(param1: transfer); |
| 96 | showModalBottomSheet( |
| 97 | backgroundColor: Colors.transparent, |
| 98 | isScrollControlled: true, |
| 99 | context: context, |
| 100 | builder: (context) => page, |
| 101 | ); |
| 102 | }, |
| 103 | ), |
| 104 | ); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | return ListView( |
| 109 | padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 8), |
| 110 | children: items, |
| 111 | ); |
| 112 | }, |
| 113 | ), |
| 114 | ), |
| 115 | ], |
| 116 | ), |
| 117 | ); |
| 118 | } |
| 119 | } |