CAKE-104 | added description parameter to the picker; applied description text in the present provider picker

This commit is contained in:
OleksandrSobol 2020-10-02 19:30:13 +03:00
parent b506f9c953
commit 738d719fec
2 changed files with 25 additions and 0 deletions

View file

@ -58,11 +58,13 @@ class PresentProviderPicker extends StatelessWidget {
final items = exchangeViewModel.providersForCurrentPair();
final selectedItem = items.indexOf(exchangeViewModel.provider);
final images = <Image>[];
String description;
for (var provider in items) {
switch (provider.description) {
case ExchangeProviderDescription.xmrto:
images.add(Image.asset('assets/images/xmr_btc.png'));
description = 'To choose ChangeNOW or MorphToken, please change your trading pair first';
break;
case ExchangeProviderDescription.changeNow:
images.add(Image.asset('assets/images/change_now.png'));
@ -79,6 +81,7 @@ class PresentProviderPicker extends StatelessWidget {
images: images,
selectedAtIndex: selectedItem,
title: S.of(context).change_exchange_provider,
description: description,
onItemSelected: (ExchangeProvider provider) =>
exchangeViewModel.changeProvider(provider: provider)),
context: context);

View file

@ -12,6 +12,7 @@ class Picker<Item extends Object> extends StatefulWidget {
@required this.items,
this.images,
@required this.title,
this.description,
@required this.onItemSelected,
this.mainAxisAlignment = MainAxisAlignment.start,
this.isAlwaysShowScrollThumb = false
@ -21,6 +22,7 @@ class Picker<Item extends Object> extends StatefulWidget {
final List<Item> items;
final List<Image> images;
final String title;
final String description;
final Function(Item) onItemSelected;
final MainAxisAlignment mainAxisAlignment;
final bool isAlwaysShowScrollThumb;
@ -145,6 +147,26 @@ class PickerState<Item> extends State<Picker> {
);
},
),
((widget.description != null)
&&(widget.description.isNotEmpty))
? Positioned(
bottom: 24,
left: 24,
right: 24,
child: Text(
widget.description,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
fontFamily: 'Poppins',
decoration: TextDecoration.none,
color: Theme.of(context).primaryTextTheme
.title.color
),
)
)
: Offstage(),
widget.isAlwaysShowScrollThumb
? CakeScrollbar(
backgroundHeight: backgroundHeight,