| 1 | import 'package:cake_wallet/entities/new_ui_entities/list_item/list_item_toggle.dart'; |
| 2 | import 'package:cake_wallet/generated/i18n.dart'; |
| 3 | import 'package:cake_wallet/new-ui/widgets/modal_header.dart'; |
| 4 | import 'package:cake_wallet/new-ui/widgets/receive_page/receive_top_bar.dart'; |
| 5 | import 'package:cake_wallet/src/widgets/new_list_row/new_list_section.dart'; |
| 6 | import 'package:cake_wallet/view_model/settings/trocador_providers_view_model.dart'; |
| 7 | import 'package:flutter/material.dart'; |
| 8 | import 'package:flutter_mobx/flutter_mobx.dart'; |
| 9 | |
| 10 | class TrocadorProvidersSettings extends StatelessWidget { |
| 11 | const TrocadorProvidersSettings({super.key, required this.trocadorProvidersViewModel}); |
| 12 | |
| 13 | final TrocadorProvidersViewModel trocadorProvidersViewModel; |
| 14 | |
| 15 | @override |
| 16 | Widget build(BuildContext context) { |
| 17 | return Container( |
| 18 | decoration: BoxDecoration( |
| 19 | color: Theme.of(context).colorScheme.surface, |
| 20 | borderRadius: BorderRadius.circular(16), |
| 21 | ), |
| 22 | child: Column( |
| 23 | spacing: 24, |
| 24 | children: [ |
| 25 | ModalTopBar( |
| 26 | title: "Trocador ${S.of(context).providers}", |
| 27 | leadingIcon: Icon(Icons.arrow_back_ios_new), |
| 28 | leadingSemanticLabel: S.of(context).seed_alert_back, |
| 29 | onLeadingPressed: Navigator.of(context).pop, |
| 30 | ), |
| 31 | Expanded( |
| 32 | child: SafeArea( |
| 33 | child: SingleChildScrollView( |
| 34 | child: Padding( |
| 35 | padding: const EdgeInsets.symmetric(horizontal: 18.0), |
| 36 | child: Column( |
| 37 | spacing: 12, |
| 38 | crossAxisAlignment: CrossAxisAlignment.start, |
| 39 | children: [ |
| 40 | ModalHeader( |
| 41 | title: "${S.of(context).about} Trocador", |
| 42 | iconPath: "assets/new-ui/trade_providers/trocador.svg", |
| 43 | message: "Trocador ${S.of(context).trocador_desc}"), |
| 44 | SizedBox(), |
| 45 | Text(S.of(context).providers), |
| 46 | Text( |
| 47 | S.of(context).trocador_desc_kyc, |
| 48 | style: TextStyle( |
| 49 | color: Theme.of(context).colorScheme.onSurfaceVariant, fontSize: 12), |
| 50 | ), |
| 51 | SizedBox(), |
| 52 | Observer( |
| 53 | builder: (_) { |
| 54 | if (trocadorProvidersViewModel.isLoading) { |
| 55 | return Center(child: CircularProgressIndicator()); |
| 56 | } |
| 57 | final providerStates = trocadorProvidersViewModel.providerStates; |
| 58 | final providerRatings = trocadorProvidersViewModel.providerRatings; |
| 59 | if (providerStates.isEmpty) { |
| 60 | return Center(child: Text(S.of(context).no_providers_available)); |
| 61 | } |
| 62 | return NewListSections( |
| 63 | getCheckboxValue: (key) => providerStates[key] ?? false, |
| 64 | updateCheckboxValue: (key, val) {}, |
| 65 | sections: { |
| 66 | "": [ |
| 67 | for (var providerName in providerStates.keys) |
| 68 | ListItemToggle( |
| 69 | keyValue: providerName, |
| 70 | label: providerName, |
| 71 | value: providerStates[providerName] ?? false, |
| 72 | onChanged: (val) { |
| 73 | trocadorProvidersViewModel |
| 74 | .toggleProviderState(providerName); |
| 75 | }, |
| 76 | leadingEndWidget: providerRatings[providerName] == null |
| 77 | ? null |
| 78 | : Container( |
| 79 | width: 18, |
| 80 | height: 18, |
| 81 | decoration: BoxDecoration( |
| 82 | border: Border.all( |
| 83 | color: Theme.of(context) |
| 84 | .colorScheme |
| 85 | .onSurfaceVariant, |
| 86 | width: 1), |
| 87 | borderRadius: BorderRadius.circular(99999)), |
| 88 | child: Center( |
| 89 | child: Text( |
| 90 | providerRatings[providerName] ?? "", |
| 91 | textAlign: TextAlign.center, |
| 92 | style: TextStyle( |
| 93 | color: Theme.of(context) |
| 94 | .colorScheme |
| 95 | .onSurfaceVariant, |
| 96 | height: 1), |
| 97 | ), |
| 98 | ), |
| 99 | )) |
| 100 | ] |
| 101 | }); |
| 102 | }, |
| 103 | ) |
| 104 | ], |
| 105 | ), |
| 106 | ), |
| 107 | ), |
| 108 | ), |
| 109 | ) |
| 110 | ], |
| 111 | ), |
| 112 | ); |
| 113 | } |
| 114 | } |