| 1 | import 'package:cake_wallet/entities/new_ui_entities/list_item/list_item_regular_row.dart'; |
| 2 | import 'package:cake_wallet/generated/i18n.dart'; |
| 3 | import 'package:cake_wallet/new-ui/widgets/receive_page/receive_top_bar.dart'; |
| 4 | import 'package:cake_wallet/src/screens/trade_details/track_trade_list_item.dart'; |
| 5 | import 'package:cake_wallet/src/screens/transaction_details/address_list_item.dart'; |
| 6 | import 'package:cake_wallet/src/screens/transaction_details/transaction_details_list_item.dart'; |
| 7 | import 'package:cake_wallet/src/widgets/new_list_row/new_list_section.dart'; |
| 8 | import 'package:cake_wallet/themes/core/custom_theme_colors.dart'; |
| 9 | import 'package:cake_wallet/utils/address_formatter.dart'; |
| 10 | import 'package:cake_wallet/utils/show_bar.dart'; |
| 11 | import 'package:cake_wallet/view_model/bridge/bridge_details_view_model.dart'; |
| 12 | import 'package:cw_core/generate_name.dart'; |
| 13 | import 'package:flutter/material.dart'; |
| 14 | import 'package:flutter/services.dart'; |
| 15 | |
| 16 | class BridgeDetailPage extends StatelessWidget { |
| 17 | BridgeDetailPage({super.key, required this.viewModel}); |
| 18 | |
| 19 | final BridgeDetailsViewModel viewModel; |
| 20 | |
| 21 | @override |
| 22 | Widget build(BuildContext context) { |
| 23 | final theme = Theme.of(context); |
| 24 | |
| 25 | return DraggableScrollableSheet( |
| 26 | expand: false, |
| 27 | initialChildSize: 0.6, |
| 28 | minChildSize: 0.25, |
| 29 | maxChildSize: 0.9, |
| 30 | snap: true, |
| 31 | snapSizes: const [0.9], |
| 32 | builder: (context, controller) { |
| 33 | return SafeArea( |
| 34 | bottom: false, |
| 35 | child: Padding( |
| 36 | padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), |
| 37 | child: GestureDetector( |
| 38 | onTap: () => FocusScope.of(context).unfocus(), |
| 39 | child: Container( |
| 40 | decoration: BoxDecoration( |
| 41 | color: theme.colorScheme.surface, |
| 42 | borderRadius: const BorderRadius.vertical(top: Radius.circular(16)), |
| 43 | ), |
| 44 | child: Column( |
| 45 | children: [ |
| 46 | ModalTopBar( |
| 47 | title: "Bridge Transfer Details", |
| 48 | leadingIcon: const Icon(Icons.arrow_back_ios_new, size: 18), |
| 49 | leadingSemanticLabel: S.of(context).seed_alert_back, |
| 50 | onLeadingPressed: () => Navigator.of(context).pop(), |
| 51 | ), |
| 52 | Expanded( |
| 53 | child: Padding( |
| 54 | padding: const EdgeInsets.all(16), |
| 55 | child: Column( |
| 56 | children: [ |
| 57 | NewListSections( |
| 58 | sections: { |
| 59 | "": viewModel.items |
| 60 | .where((item) => item is! TrackTradeListItem) |
| 61 | .map((item) { |
| 62 | return ListItemRegularRow( |
| 63 | onTap: () { |
| 64 | Clipboard.setData(ClipboardData(text: item.value)); |
| 65 | showBar<void>(context, S.of(context).copied_to_clipboard); |
| 66 | }, |
| 67 | showArrow: false, |
| 68 | keyValue: item.title, |
| 69 | label: item.title, |
| 70 | trailingWidget: _buildTrailingWidget(item, context), |
| 71 | bottomWidget: _buildBottomWidget(item, context), |
| 72 | ); |
| 73 | }).toList(), |
| 74 | }, |
| 75 | ), |
| 76 | SizedBox(height: 16), |
| 77 | NewListSections(sections: { |
| 78 | "": viewModel.items |
| 79 | .where((item) => item is TrackTradeListItem) |
| 80 | .map((item) { |
| 81 | return ListItemRegularRow( |
| 82 | keyValue: "view tx on", |
| 83 | label: item.title, |
| 84 | onTap: () => (item as TrackTradeListItem).onTap(), |
| 85 | foregroundColor: Theme.of(context).colorScheme.primary, |
| 86 | trailingIconPath: "assets/new-ui/link_arrow.svg", |
| 87 | trailingIconSize: 8, |
| 88 | ); |
| 89 | }).toList() |
| 90 | }), |
| 91 | ], |
| 92 | ), |
| 93 | ), |
| 94 | ), |
| 95 | SizedBox(height: MediaQuery.of(context).viewPadding.bottom) |
| 96 | ], |
| 97 | ), |
| 98 | ), |
| 99 | ), |
| 100 | ), |
| 101 | ); |
| 102 | }, |
| 103 | ); |
| 104 | } |
| 105 | |
| 106 | Widget _buildBottomWidget(TransactionDetailsListItem item, BuildContext context) { |
| 107 | if (item is AddressListItem) { |
| 108 | return AddressFormatter.buildSegmentedAddress( |
| 109 | address: item.value, |
| 110 | evenTextStyle: TextStyle( |
| 111 | fontSize: 12, |
| 112 | fontFamily: "IBM Plex Mono", |
| 113 | color: Theme.of(context).colorScheme.onSurface)); |
| 114 | } |
| 115 | |
| 116 | final isCompleted = item.value.contains("Completed"); |
| 117 | final isInitiated = item.value.contains("initiated"); |
| 118 | if (isCompleted || isInitiated) { |
| 119 | return Row( |
| 120 | children: [ |
| 121 | Container( |
| 122 | height: 8, |
| 123 | width: 8, |
| 124 | decoration: BoxDecoration( |
| 125 | color: isCompleted ? CustomThemeColors.syncGreen : CustomThemeColors.syncYellow, |
| 126 | borderRadius: BorderRadius.circular(12), |
| 127 | border: Border.all( |
| 128 | color: Theme.of(context).colorScheme.surface, |
| 129 | width: 1.5, |
| 130 | ), |
| 131 | ), |
| 132 | ), |
| 133 | SizedBox(width: 8), |
| 134 | Text( |
| 135 | item.value, |
| 136 | style: TextStyle(fontSize: 14, color: Theme.of(context).colorScheme.onSurfaceVariant), |
| 137 | ), |
| 138 | ], |
| 139 | ); |
| 140 | } |
| 141 | |
| 142 | return SizedBox.shrink(); |
| 143 | } |
| 144 | |
| 145 | Widget _buildTrailingWidget(TransactionDetailsListItem item, BuildContext context) { |
| 146 | final isCompleted = item.value.contains("Completed"); |
| 147 | final isInitiated = item.value.contains("initiated"); |
| 148 | if (item is AddressListItem || isCompleted || isInitiated) { |
| 149 | return SizedBox.shrink(); |
| 150 | } |
| 151 | |
| 152 | return Text( |
| 153 | item.value.capitalized(), |
| 154 | style: TextStyle( |
| 155 | fontWeight: FontWeight.w400, |
| 156 | fontFamily: 'Wix Madefor Text', |
| 157 | color: Theme.of(context).colorScheme.onSurfaceVariant, |
| 158 | ), |
| 159 | ); |
| 160 | } |
| 161 | } |