Filter to use Tor only exchange

This commit is contained in:
Godwin Asuquo 2023-03-01 15:50:31 +02:00
parent 2c9f17e728
commit dbfbadffda
2 changed files with 26 additions and 9 deletions

View file

@ -38,7 +38,7 @@ class CheckBoxPickerState extends State<CheckBoxPicker> {
Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
if (widget.title?.isNotEmpty ?? false)
if (widget.title.isNotEmpty)
Container(
padding: EdgeInsets.symmetric(horizontal: 24),
child: Text(
@ -58,7 +58,7 @@ class CheckBoxPickerState extends State<CheckBoxPicker> {
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(30)),
child: Container(
color: Theme.of(context).accentTextTheme!.headline6!.color!,
color: Theme.of(context).accentTextTheme.headline6!.color!,
child: ConstrainedBox(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height * 0.65,
@ -70,7 +70,7 @@ class CheckBoxPickerState extends State<CheckBoxPicker> {
child: Stack(
alignment: Alignment.center,
children: <Widget>[
(items?.length ?? 0) > 3
(items.length) > 3
? Scrollbar(
controller: controller,
child: itemsList(),
@ -95,14 +95,14 @@ class CheckBoxPickerState extends State<CheckBoxPicker> {
Widget itemsList() {
return Container(
color: Theme.of(context).accentTextTheme!.headline6!.backgroundColor!,
color: Theme.of(context).accentTextTheme.headline6!.backgroundColor!,
child: ListView.separated(
padding: EdgeInsets.zero,
controller: controller,
shrinkWrap: true,
separatorBuilder: (context, index) => widget.isSeparated
? Divider(
color: Theme.of(context).accentTextTheme!.headline6!.backgroundColor!,
color: Theme.of(context).accentTextTheme.headline6!.backgroundColor!,
height: 1,
)
: const SizedBox(),
@ -121,13 +121,13 @@ class CheckBoxPickerState extends State<CheckBoxPicker> {
},
child: Container(
height: 55,
color: Theme.of(context).accentTextTheme!.headline6!.color!,
color: Theme.of(context).accentTextTheme.headline6!.color!,
padding: EdgeInsets.only(left: 24, right: 24),
child: CheckboxListTile(
value: item.value,
activeColor: item.value
? Palette.blueCraiola
: Theme.of(context).accentTextTheme!.subtitle1!.decorationColor!,
: Theme.of(context).accentTextTheme.subtitle1!.decorationColor!,
checkColor: Colors.white,
title: widget.displayItem?.call(item) ??
Text(
@ -138,7 +138,7 @@ class CheckBoxPickerState extends State<CheckBoxPicker> {
fontWeight: FontWeight.w600,
color: item.isDisabled
? Colors.grey.withOpacity(0.5)
: Theme.of(context).primaryTextTheme!.headline6!.color!,
: Theme.of(context).primaryTextTheme.headline6!.color!,
decoration: TextDecoration.none,
),
),

View file

@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:collection';
import 'dart:convert';
import 'package:cake_wallet/entities/fiat_api_mode.dart';
import 'package:cake_wallet/entities/preferences_key.dart';
import 'package:cake_wallet/exchange/sideshift/sideshift_exchange_provider.dart';
import 'package:cake_wallet/exchange/sideshift/sideshift_request.dart';
@ -62,8 +63,9 @@ abstract class ExchangeViewModelBase with Store {
limitsState = LimitsInitialState(),
receiveCurrency = wallet.currency,
depositCurrency = wallet.currency,
providerList = [ChangeNowExchangeProvider(), SideShiftExchangeProvider(), SimpleSwapExchangeProvider(), TrocadorExchangeProvider()],
providerList = [],
selectedProviders = ObservableList<ExchangeProvider>() {
_setProviders();
const excludeDepositCurrencies = [CryptoCurrency.btt, CryptoCurrency.nano];
const excludeReceiveCurrencies = [CryptoCurrency.xlm, CryptoCurrency.xrp,
CryptoCurrency.bnb, CryptoCurrency.btt, CryptoCurrency.nano];
@ -126,6 +128,13 @@ abstract class ExchangeViewModelBase with Store {
final TradesStore tradesStore;
final SharedPreferences sharedPreferences;
final _allProviders = [
ChangeNowExchangeProvider(),
SideShiftExchangeProvider(),
SimpleSwapExchangeProvider(),
TrocadorExchangeProvider(),
];
@observable
ExchangeProvider? provider;
@ -683,4 +692,12 @@ abstract class ExchangeViewModelBase with Store {
break;
}
}
void _setProviders(){
if (_settingsStore.exchangeStatus == FiatApiMode.torOnly) {
providerList = _allProviders.where((provider) => provider.shouldUseOnionAddress).toList();
} else {
providerList = _allProviders;
}
}
}