2020-05-18 17:23:33 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
|
|
|
|
import 'package:cake_wallet/src/domain/exchange/exchange_provider.dart';
|
|
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
|
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
2020-05-21 18:01:12 +00:00
|
|
|
import 'package:cake_wallet/src/widgets/picker.dart';
|
2020-07-31 15:29:21 +00:00
|
|
|
import 'package:cake_wallet/view_model/exchange/exchange_view_model.dart';
|
|
|
|
import 'package:cake_wallet/palette.dart';
|
2020-05-18 17:23:33 +00:00
|
|
|
|
|
|
|
class PresentProviderPicker extends StatelessWidget {
|
2020-07-31 15:29:21 +00:00
|
|
|
PresentProviderPicker({@required this.exchangeViewModel});
|
2020-05-18 17:23:33 +00:00
|
|
|
|
2020-07-31 15:29:21 +00:00
|
|
|
final ExchangeViewModel exchangeViewModel;
|
2020-05-18 17:23:33 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-07-31 15:29:21 +00:00
|
|
|
final arrowBottom =
|
2020-05-29 15:10:11 +00:00
|
|
|
Image.asset('assets/images/arrow_bottom_purple_icon.png',
|
2020-07-31 15:29:21 +00:00
|
|
|
color: Colors.white,
|
2020-05-29 15:10:11 +00:00
|
|
|
height: 6);
|
|
|
|
|
2020-05-18 17:23:33 +00:00
|
|
|
return FlatButton(
|
|
|
|
onPressed: () => _presentProviderPicker(context),
|
|
|
|
highlightColor: Colors.transparent,
|
|
|
|
splashColor: Colors.transparent,
|
|
|
|
child: Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
|
|
|
Text(S.of(context).exchange,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 16.0,
|
2020-07-31 15:29:21 +00:00
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
color: Colors.white)),
|
2020-05-18 17:23:33 +00:00
|
|
|
Observer(
|
2020-07-31 15:29:21 +00:00
|
|
|
builder: (_) => Text('${exchangeViewModel.provider.title}',
|
2020-05-18 17:23:33 +00:00
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 10.0,
|
2020-07-31 15:29:21 +00:00
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
color: PaletteDark.lightBlueGrey)))
|
2020-05-18 17:23:33 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
SizedBox(width: 5),
|
|
|
|
Padding(
|
2020-07-31 15:29:21 +00:00
|
|
|
padding: EdgeInsets.only(top: 12),
|
2020-05-18 17:23:33 +00:00
|
|
|
child: arrowBottom,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void _presentProviderPicker(BuildContext context) {
|
2020-07-31 15:29:21 +00:00
|
|
|
final items = exchangeViewModel.providersForCurrentPair();
|
|
|
|
final selectedItem = items.indexOf(exchangeViewModel.provider);
|
|
|
|
final images = <Image>[];
|
2020-05-18 17:23:33 +00:00
|
|
|
|
2020-07-31 15:29:21 +00:00
|
|
|
for (var provider in items) {
|
2020-05-18 17:23:33 +00:00
|
|
|
switch (provider.description) {
|
|
|
|
case ExchangeProviderDescription.xmrto:
|
|
|
|
images.add(Image.asset('assets/images/xmr_btc.png'));
|
|
|
|
break;
|
|
|
|
case ExchangeProviderDescription.changeNow:
|
|
|
|
images.add(Image.asset('assets/images/change_now.png'));
|
|
|
|
break;
|
|
|
|
case ExchangeProviderDescription.morphToken:
|
|
|
|
images.add(Image.asset('assets/images/morph_icon.png'));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
showDialog<void>(
|
2020-05-21 18:01:12 +00:00
|
|
|
builder: (_) => Picker(
|
2020-05-18 17:23:33 +00:00
|
|
|
items: items,
|
|
|
|
images: images,
|
|
|
|
selectedAtIndex: selectedItem,
|
|
|
|
title: S.of(context).change_exchange_provider,
|
|
|
|
onItemSelected: (ExchangeProvider provider) =>
|
2020-07-31 15:29:21 +00:00
|
|
|
exchangeViewModel.changeProvider(provider: provider)),
|
2020-05-18 17:23:33 +00:00
|
|
|
context: context);
|
|
|
|
}
|
|
|
|
}
|