2020-09-25 15:32:44 +00:00
|
|
|
import 'package:cake_wallet/utils/show_pop_up.dart';
|
2020-05-18 17:23:33 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/exchange/exchange_provider_description.dart';
|
|
|
|
import 'package:cake_wallet/exchange/exchange_provider.dart';
|
2020-05-18 17:23:33 +00:00
|
|
|
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';
|
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,
|
2020-08-21 20:26:23 +00:00
|
|
|
color: Theme.of(context).textTheme.headline.color)))
|
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-10-02 16:30:13 +00:00
|
|
|
String description;
|
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'));
|
2020-10-02 17:51:07 +00:00
|
|
|
description = S.of(context).picker_description;
|
2020-05-18 17:23:33 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-25 15:32:44 +00:00
|
|
|
showPopUp<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,
|
2020-10-02 16:30:13 +00:00
|
|
|
description: description,
|
2020-05-18 17:23:33 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|