Filter to use Tor only exchange

Godwin Asuquo committed Mar 1, 2023 at 15:50 UTC dbfbadffdaef761abad0b493b27714c51fb22b01
2 files changed +26 -9
lib/src/widgets/check_box_picker.dart
+8 -8
@@ -38,7 +38,7 @@ class CheckBoxPickerState extends State<CheckBoxPicker> {
38 Column(
39 mainAxisSize: MainAxisSize.min,
40 children: <Widget>[
41 - if (widget.title?.isNotEmpty ?? false)
41 + if (widget.title.isNotEmpty)
42 Container(
43 padding: EdgeInsets.symmetric(horizontal: 24),
44 child: Text(
@@ -58,7 +58,7 @@ class CheckBoxPickerState extends State<CheckBoxPicker> {
58 child: ClipRRect(
59 borderRadius: BorderRadius.all(Radius.circular(30)),
60 child: Container(
61 - color: Theme.of(context).accentTextTheme!.headline6!.color!,
61 + color: Theme.of(context).accentTextTheme.headline6!.color!,
62 child: ConstrainedBox(
63 constraints: BoxConstraints(
64 maxHeight: MediaQuery.of(context).size.height * 0.65,
@@ -70,7 +70,7 @@ class CheckBoxPickerState extends State<CheckBoxPicker> {
70 child: Stack(
71 alignment: Alignment.center,
72 children: <Widget>[
73 - (items?.length ?? 0) > 3
73 + (items.length) > 3
74 ? Scrollbar(
75 controller: controller,
76 child: itemsList(),
@@ -95,14 +95,14 @@ class CheckBoxPickerState extends State<CheckBoxPicker> {
95
96 Widget itemsList() {
97 return Container(
98 - color: Theme.of(context).accentTextTheme!.headline6!.backgroundColor!,
98 + color: Theme.of(context).accentTextTheme.headline6!.backgroundColor!,
99 child: ListView.separated(
100 padding: EdgeInsets.zero,
101 controller: controller,
102 shrinkWrap: true,
103 separatorBuilder: (context, index) => widget.isSeparated
104 ? Divider(
105 - color: Theme.of(context).accentTextTheme!.headline6!.backgroundColor!,
105 + color: Theme.of(context).accentTextTheme.headline6!.backgroundColor!,
106 height: 1,
107 )
108 : const SizedBox(),
@@ -121,13 +121,13 @@ class CheckBoxPickerState extends State<CheckBoxPicker> {
121 },
122 child: Container(
123 height: 55,
124 - color: Theme.of(context).accentTextTheme!.headline6!.color!,
124 + color: Theme.of(context).accentTextTheme.headline6!.color!,
125 padding: EdgeInsets.only(left: 24, right: 24),
126 child: CheckboxListTile(
127 value: item.value,
128 activeColor: item.value
129 ? Palette.blueCraiola
130 - : Theme.of(context).accentTextTheme!.subtitle1!.decorationColor!,
130 + : Theme.of(context).accentTextTheme.subtitle1!.decorationColor!,
131 checkColor: Colors.white,
132 title: widget.displayItem?.call(item) ??
133 Text(
@@ -138,7 +138,7 @@ class CheckBoxPickerState extends State<CheckBoxPicker> {
138 fontWeight: FontWeight.w600,
139 color: item.isDisabled
140 ? Colors.grey.withOpacity(0.5)
141 - : Theme.of(context).primaryTextTheme!.headline6!.color!,
141 + : Theme.of(context).primaryTextTheme.headline6!.color!,
142 decoration: TextDecoration.none,
143 ),
144 ),
lib/view_model/exchange/exchange_view_model.dart
+18 -1
@@ -2,6 +2,7 @@ import 'dart:async';
2 import 'dart:collection';
3 import 'dart:convert';
4
5 +import 'package:cake_wallet/entities/fiat_api_mode.dart';
6 import 'package:cake_wallet/entities/preferences_key.dart';
7 import 'package:cake_wallet/exchange/sideshift/sideshift_exchange_provider.dart';
8 import 'package:cake_wallet/exchange/sideshift/sideshift_request.dart';
@@ -62,8 +63,9 @@ abstract class ExchangeViewModelBase with Store {
63 limitsState = LimitsInitialState(),
64 receiveCurrency = wallet.currency,
65 depositCurrency = wallet.currency,
65 - providerList = [ChangeNowExchangeProvider(), SideShiftExchangeProvider(), SimpleSwapExchangeProvider(), TrocadorExchangeProvider()],
66 + providerList = [],
67 selectedProviders = ObservableList<ExchangeProvider>() {
68 + _setProviders();
69 const excludeDepositCurrencies = [CryptoCurrency.btt, CryptoCurrency.nano];
70 const excludeReceiveCurrencies = [CryptoCurrency.xlm, CryptoCurrency.xrp,
71 CryptoCurrency.bnb, CryptoCurrency.btt, CryptoCurrency.nano];
@@ -126,6 +128,13 @@ abstract class ExchangeViewModelBase with Store {
128 final TradesStore tradesStore;
129 final SharedPreferences sharedPreferences;
130
131 + final _allProviders = [
132 + ChangeNowExchangeProvider(),
133 + SideShiftExchangeProvider(),
134 + SimpleSwapExchangeProvider(),
135 + TrocadorExchangeProvider(),
136 + ];
137 +
138 @observable
139 ExchangeProvider? provider;
140
@@ -683,4 +692,12 @@ abstract class ExchangeViewModelBase with Store {
692 break;
693 }
694 }
695 +
696 + void _setProviders(){
697 + if (_settingsStore.exchangeStatus == FiatApiMode.torOnly) {
698 + providerList = _allProviders.where((provider) => provider.shouldUseOnionAddress).toList();
699 + } else {
700 + providerList = _allProviders;
701 + }
702 + }
703 }