mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-23 19:16:09 +00:00
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into CW-112-cake-phone-screens
This commit is contained in:
commit
c2976cbe05
12 changed files with 349 additions and 360 deletions
|
@ -8,6 +8,9 @@ class FiatCurrency extends EnumerableItem<String> with Serializable<String> {
|
||||||
|
|
||||||
static List<FiatCurrency> get all => _all.values.toList();
|
static List<FiatCurrency> get all => _all.values.toList();
|
||||||
|
|
||||||
|
static List<FiatCurrency> get currenciesAvailableToBuyWith =>
|
||||||
|
[aud, brl, cad, chf, czk, eur, dkk, gbp, hkd, ils, jpy, krw, mxn, myr, nok, nzd, pln, sek, sgd, thb, usd, zar];
|
||||||
|
|
||||||
static const aud = FiatCurrency(symbol: 'AUD', countryCode: "aus", fullName: "Australian Dollar");
|
static const aud = FiatCurrency(symbol: 'AUD', countryCode: "aus", fullName: "Australian Dollar");
|
||||||
static const bgn = FiatCurrency(symbol: 'BGN', countryCode: "bgr", fullName: "Bulgarian Lev");
|
static const bgn = FiatCurrency(symbol: 'BGN', countryCode: "bgr", fullName: "Bulgarian Lev");
|
||||||
static const brl = FiatCurrency(symbol: 'BRL', countryCode: "bra", fullName: "Brazilian Real");
|
static const brl = FiatCurrency(symbol: 'BRL', countryCode: "bra", fullName: "Brazilian Real");
|
||||||
|
|
|
@ -2,6 +2,8 @@ import 'dart:ui';
|
||||||
import 'package:cake_wallet/buy/buy_amount.dart';
|
import 'package:cake_wallet/buy/buy_amount.dart';
|
||||||
import 'package:cake_wallet/buy/buy_provider.dart';
|
import 'package:cake_wallet/buy/buy_provider.dart';
|
||||||
import 'package:cake_wallet/buy/moonpay/moonpay_buy_provider.dart';
|
import 'package:cake_wallet/buy/moonpay/moonpay_buy_provider.dart';
|
||||||
|
import 'package:cake_wallet/entities/fiat_currency.dart';
|
||||||
|
import 'package:cake_wallet/src/widgets/picker.dart';
|
||||||
import 'package:cw_core/wallet_type.dart';
|
import 'package:cw_core/wallet_type.dart';
|
||||||
import 'package:cake_wallet/src/screens/buy/widgets/buy_list_item.dart';
|
import 'package:cake_wallet/src/screens/buy/widgets/buy_list_item.dart';
|
||||||
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
||||||
|
@ -27,7 +29,6 @@ class PreOrderPage extends BasePage {
|
||||||
PreOrderPage({@required this.buyViewModel})
|
PreOrderPage({@required this.buyViewModel})
|
||||||
: _amountFocus = FocusNode(),
|
: _amountFocus = FocusNode(),
|
||||||
_amountController = TextEditingController() {
|
_amountController = TextEditingController() {
|
||||||
|
|
||||||
_amountController.addListener(() {
|
_amountController.addListener(() {
|
||||||
final amount = _amountController.text;
|
final amount = _amountController.text;
|
||||||
|
|
||||||
|
@ -110,52 +111,70 @@ class PreOrderPage extends BasePage {
|
||||||
.decorationColor,
|
.decorationColor,
|
||||||
], begin: Alignment.topLeft, end: Alignment.bottomRight),
|
], begin: Alignment.topLeft, end: Alignment.bottomRight),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.only(top: 100, bottom: 65),
|
padding: EdgeInsets.only(top: 100, bottom: 65),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 210,
|
width: 210,
|
||||||
child: BaseTextFormField(
|
child: BaseTextFormField(
|
||||||
focusNode: _amountFocus,
|
focusNode: _amountFocus,
|
||||||
controller: _amountController,
|
controller: _amountController,
|
||||||
keyboardType:
|
keyboardType: TextInputType.numberWithOptions(signed: false, decimal: true),
|
||||||
TextInputType.numberWithOptions(
|
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(_amountPattern))],
|
||||||
signed: false, decimal: true),
|
prefixIcon: GestureDetector(
|
||||||
inputFormatters: [
|
onTap: () {
|
||||||
FilteringTextInputFormatter
|
showPopUp<void>(
|
||||||
.allow(RegExp(_amountPattern))
|
context: context,
|
||||||
],
|
builder: (_) => Picker(
|
||||||
prefixIcon: Padding(
|
hintText: S.current.search_currency,
|
||||||
padding: EdgeInsets.only(top: 2),
|
items: FiatCurrency.currenciesAvailableToBuyWith,
|
||||||
child:
|
selectedAtIndex:
|
||||||
Text(buyViewModel.fiatCurrency.title + ': ',
|
FiatCurrency.currenciesAvailableToBuyWith.indexOf(buyViewModel.fiatCurrency),
|
||||||
style: TextStyle(
|
onItemSelected: (FiatCurrency selectedCurrency) {
|
||||||
fontSize: 36,
|
buyViewModel.buyAmountViewModel.fiatCurrency = selectedCurrency;
|
||||||
fontWeight: FontWeight.w600,
|
},
|
||||||
color: Colors.white,
|
images: FiatCurrency.currenciesAvailableToBuyWith
|
||||||
)),
|
.map((e) => Image.asset("assets/images/flags/${e.countryCode}.png"))
|
||||||
),
|
.toList(),
|
||||||
hintText: '0.00',
|
isGridView: true,
|
||||||
borderColor: Theme.of(context)
|
matchingCriteria: (FiatCurrency currency, String searchText) {
|
||||||
.primaryTextTheme
|
return currency.title.toLowerCase().contains(searchText) ||
|
||||||
.body2
|
currency.fullName.toLowerCase().contains(searchText);
|
||||||
.decorationColor,
|
},
|
||||||
borderWidth: 0.5,
|
),
|
||||||
textStyle: TextStyle(
|
);
|
||||||
|
},
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.only(top: 2),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.keyboard_arrow_down, color: Colors.white),
|
||||||
|
Text(
|
||||||
|
buyViewModel.fiatCurrency.title + ': ',
|
||||||
|
style: TextStyle(
|
||||||
fontSize: 36,
|
fontSize: 36,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w600,
|
||||||
color: Colors.white),
|
color: Colors.white,
|
||||||
placeholderTextStyle: TextStyle(
|
),
|
||||||
color: Theme.of(context)
|
),
|
||||||
.primaryTextTheme
|
],
|
||||||
.headline
|
),
|
||||||
.decorationColor,
|
),
|
||||||
fontWeight: FontWeight.w500,
|
),
|
||||||
fontSize: 36),
|
hintText: '0.00',
|
||||||
)
|
borderColor: Theme.of(context).primaryTextTheme.body2.decorationColor,
|
||||||
)
|
borderWidth: 0.5,
|
||||||
)
|
textStyle: TextStyle(fontSize: 36, fontWeight: FontWeight.w500, color: Colors.white),
|
||||||
)
|
placeholderTextStyle: TextStyle(
|
||||||
|
color: Theme.of(context).primaryTextTheme.headline.decorationColor,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
fontSize: 36,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
if (buyViewModel.isShowProviderButtons) Padding(
|
if (buyViewModel.isShowProviderButtons) Padding(
|
||||||
padding: EdgeInsets.only(top: 38, bottom: 18),
|
padding: EdgeInsets.only(top: 38, bottom: 18),
|
||||||
|
|
|
@ -150,6 +150,7 @@ class ContactPage extends BasePage {
|
||||||
contactViewModel.currencies.indexOf(contactViewModel.currency),
|
contactViewModel.currencies.indexOf(contactViewModel.currency),
|
||||||
items: contactViewModel.currencies,
|
items: contactViewModel.currencies,
|
||||||
title: S.of(context).please_select,
|
title: S.of(context).please_select,
|
||||||
|
hintText: S.of(context).search_currency,
|
||||||
onItemSelected: (CryptoCurrency item) =>
|
onItemSelected: (CryptoCurrency item) =>
|
||||||
contactViewModel.currency = item),
|
contactViewModel.currency = item),
|
||||||
context: context);
|
context: context);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
import 'package:cake_wallet/generated/i18n.dart';
|
import 'package:cake_wallet/src/screens/exchange/widgets/currency_picker_item_widget.dart';
|
||||||
import 'package:cake_wallet/palette.dart';
|
|
||||||
import 'package:cake_wallet/src/screens/exchange/widgets/currency_utils.dart';
|
import 'package:cake_wallet/src/screens/exchange/widgets/currency_utils.dart';
|
||||||
import 'package:cake_wallet/src/screens/exchange/widgets/picker_item.dart';
|
import 'package:cake_wallet/src/screens/exchange/widgets/picker_item.dart';
|
||||||
|
import 'package:cake_wallet/src/widgets/alert_close_button.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:cw_core/crypto_currency.dart';
|
import 'package:cw_core/crypto_currency.dart';
|
||||||
|
@ -13,8 +13,9 @@ class CurrencyPicker extends StatefulWidget {
|
||||||
CurrencyPicker(
|
CurrencyPicker(
|
||||||
{@required this.selectedAtIndex,
|
{@required this.selectedAtIndex,
|
||||||
@required this.items,
|
@required this.items,
|
||||||
@required this.title,
|
|
||||||
@required this.onItemSelected,
|
@required this.onItemSelected,
|
||||||
|
this.title,
|
||||||
|
this.hintText,
|
||||||
this.isMoneroWallet = false,
|
this.isMoneroWallet = false,
|
||||||
this.isConvertFrom = false});
|
this.isConvertFrom = false});
|
||||||
|
|
||||||
|
@ -24,6 +25,7 @@ class CurrencyPicker extends StatefulWidget {
|
||||||
final Function(CryptoCurrency) onItemSelected;
|
final Function(CryptoCurrency) onItemSelected;
|
||||||
final bool isMoneroWallet;
|
final bool isMoneroWallet;
|
||||||
final bool isConvertFrom;
|
final bool isConvertFrom;
|
||||||
|
final String hintText;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
CurrencyPickerState createState() => CurrencyPickerState(items);
|
CurrencyPickerState createState() => CurrencyPickerState(items);
|
||||||
|
@ -34,11 +36,8 @@ class CurrencyPickerState extends State<CurrencyPicker> {
|
||||||
: isSearchBarActive = false,
|
: isSearchBarActive = false,
|
||||||
textFieldValue = '',
|
textFieldValue = '',
|
||||||
subPickerItemsList = [],
|
subPickerItemsList = [],
|
||||||
appBarTextStyle = TextStyle(
|
appBarTextStyle =
|
||||||
fontSize: 20,
|
TextStyle(fontSize: 20, fontFamily: 'Lato', backgroundColor: Colors.transparent, color: Colors.white);
|
||||||
fontFamily: 'Lato',
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
color: Colors.white);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
@ -61,13 +60,10 @@ class CurrencyPickerState extends State<CurrencyPicker> {
|
||||||
TextStyle appBarTextStyle;
|
TextStyle appBarTextStyle;
|
||||||
|
|
||||||
void cleanSubPickerItemsList() {
|
void cleanSubPickerItemsList() {
|
||||||
subPickerItemsList = pickerItemsList
|
subPickerItemsList = pickerItemsList.where((element) => items.contains(element.original)).toList();
|
||||||
.where((element) => items.contains(element.original))
|
|
||||||
.toList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void currencySearchBySubstring(
|
void currencySearchBySubstring(String subString, List<PickerItem<CryptoCurrency>> list) {
|
||||||
String subString, List<PickerItem<CryptoCurrency>> list) {
|
|
||||||
setState(() {
|
setState(() {
|
||||||
if (subString.isNotEmpty) {
|
if (subString.isNotEmpty) {
|
||||||
subPickerItemsList = subPickerItemsList
|
subPickerItemsList = subPickerItemsList
|
||||||
|
@ -84,118 +80,104 @@ class CurrencyPickerState extends State<CurrencyPicker> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AlertBackground(
|
return AlertBackground(
|
||||||
child: SafeArea(
|
child: Stack(
|
||||||
child: Scaffold(
|
alignment: Alignment.center,
|
||||||
resizeToAvoidBottomInset: false,
|
children: [
|
||||||
backgroundColor: Colors.transparent,
|
Column(
|
||||||
body: Column(
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: <Widget>[
|
||||||
Padding(
|
if (widget.title?.isNotEmpty ?? false)
|
||||||
padding: EdgeInsets.symmetric(horizontal: 26.0, vertical: 0),
|
Container(
|
||||||
child: Row(
|
padding: EdgeInsets.symmetric(horizontal: 24),
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
child: Text(
|
||||||
children: [
|
widget.title,
|
||||||
isSearchBarActive
|
textAlign: TextAlign.center,
|
||||||
? Expanded(
|
style: TextStyle(
|
||||||
child: Row(
|
fontSize: 18,
|
||||||
mainAxisAlignment:
|
fontFamily: 'Lato',
|
||||||
MainAxisAlignment.spaceBetween,
|
fontWeight: FontWeight.bold,
|
||||||
children: [
|
decoration: TextDecoration.none,
|
||||||
InkWell(
|
color: Colors.white,
|
||||||
child: Text(
|
|
||||||
S.of(context).cancel,
|
|
||||||
style: appBarTextStyle,
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
setState(() {
|
|
||||||
isSearchBarActive = false;
|
|
||||||
textFieldValue = '';
|
|
||||||
cleanSubPickerItemsList();
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
Container(
|
|
||||||
width: 100.0,
|
|
||||||
child: CupertinoTextField(
|
|
||||||
autofocus: true,
|
|
||||||
placeholder:
|
|
||||||
S.of(context).search + '...',
|
|
||||||
placeholderStyle: appBarTextStyle,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.transparent),
|
|
||||||
cursorColor: Colors.white,
|
|
||||||
cursorHeight: 23.0,
|
|
||||||
style: appBarTextStyle,
|
|
||||||
onChanged: (value) {
|
|
||||||
this.textFieldValue = value;
|
|
||||||
cleanSubPickerItemsList();
|
|
||||||
currencySearchBySubstring(
|
|
||||||
textFieldValue,
|
|
||||||
subPickerItemsList);
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Text(
|
|
||||||
widget.title,
|
|
||||||
style: appBarTextStyle,
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
splashRadius: 23,
|
|
||||||
icon: Icon(Icons.search, color: Colors.white),
|
|
||||||
onPressed: () {
|
|
||||||
setState(() {
|
|
||||||
isSearchBarActive = true;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 12,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 26.0, vertical: 26.0),
|
|
||||||
child: Container(
|
|
||||||
child: CurrencyPickerWidget(
|
|
||||||
crossAxisCount: 2,
|
|
||||||
selectedAtIndex: widget.selectedAtIndex,
|
|
||||||
itemsCount: subPickerItemsList.length,
|
|
||||||
pickerItemsList: subPickerItemsList,
|
|
||||||
pickListItem: (int index) {
|
|
||||||
setState(() {
|
|
||||||
widget.selectedAtIndex = index;
|
|
||||||
});
|
|
||||||
widget
|
|
||||||
.onItemSelected(subPickerItemsList[index].original);
|
|
||||||
if (widget.isConvertFrom &&
|
|
||||||
!widget.isMoneroWallet &&
|
|
||||||
(subPickerItemsList[index].original ==
|
|
||||||
CryptoCurrency.xmr)) {
|
|
||||||
} else {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
Padding(
|
||||||
Expanded(
|
padding: EdgeInsets.only(left: 24, right: 24, top: 24),
|
||||||
flex: 2,
|
child: ClipRRect(
|
||||||
child: Container(
|
borderRadius: BorderRadius.all(Radius.circular(30)),
|
||||||
width: 42.0,
|
child: Container(
|
||||||
alignment: Alignment.topCenter,
|
color: Theme.of(context).accentTextTheme.title.color,
|
||||||
child: FittedBox(
|
child: ConstrainedBox(
|
||||||
child: FloatingActionButton(
|
constraints: BoxConstraints(
|
||||||
elevation: 0,
|
maxHeight: MediaQuery.of(context).size.height * 0.65,
|
||||||
backgroundColor: Colors.white,
|
),
|
||||||
onPressed: () {
|
child: Column(
|
||||||
Navigator.of(context).pop();
|
mainAxisSize: MainAxisSize.min,
|
||||||
},
|
children: [
|
||||||
child: Icon(
|
if (widget.hintText != null)
|
||||||
Icons.close_outlined,
|
Padding(
|
||||||
color: Palette.darkBlueCraiola,
|
padding: const EdgeInsets.all(16),
|
||||||
size: 30.0,
|
child: TextFormField(
|
||||||
|
style: TextStyle(color: Theme.of(context).primaryTextTheme.title.color),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: widget.hintText,
|
||||||
|
prefixIcon: Image.asset("assets/images/search_icon.png"),
|
||||||
|
filled: true,
|
||||||
|
fillColor: const Color(0xffF2F0FA),
|
||||||
|
alignLabelWithHint: false,
|
||||||
|
contentPadding: const EdgeInsets.symmetric(vertical: 4, horizontal: 16),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
borderSide: const BorderSide(
|
||||||
|
color: Colors.transparent,
|
||||||
|
)),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
borderSide: const BorderSide(
|
||||||
|
color: Colors.transparent,
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
onChanged: (value) {
|
||||||
|
this.textFieldValue = value;
|
||||||
|
cleanSubPickerItemsList();
|
||||||
|
currencySearchBySubstring(textFieldValue, subPickerItemsList);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Divider(
|
||||||
|
color: Theme.of(context).accentTextTheme.title.backgroundColor,
|
||||||
|
height: 1,
|
||||||
|
),
|
||||||
|
if (widget.selectedAtIndex != -1)
|
||||||
|
AspectRatio(
|
||||||
|
aspectRatio: 6,
|
||||||
|
child: PickerItemWidget(
|
||||||
|
title: pickerItemsList[widget.selectedAtIndex].title,
|
||||||
|
iconPath: pickerItemsList[widget.selectedAtIndex].iconPath,
|
||||||
|
isSelected: true,
|
||||||
|
tag: pickerItemsList[widget.selectedAtIndex].tag,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
child: CurrencyPickerWidget(
|
||||||
|
crossAxisCount: 2,
|
||||||
|
selectedAtIndex: widget.selectedAtIndex,
|
||||||
|
pickerItemsList: subPickerItemsList,
|
||||||
|
pickListItem: (int index) {
|
||||||
|
setState(() {
|
||||||
|
widget.selectedAtIndex = index;
|
||||||
|
});
|
||||||
|
widget.onItemSelected(subPickerItemsList[index].original);
|
||||||
|
if (widget.isConvertFrom &&
|
||||||
|
!widget.isMoneroWallet &&
|
||||||
|
(subPickerItemsList[index].original == CryptoCurrency.xmr)) {
|
||||||
|
} else {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -203,7 +185,8 @@ class CurrencyPickerState extends State<CurrencyPicker> {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
AlertCloseButton(),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:cake_wallet/palette.dart';
|
import 'package:cake_wallet/palette.dart';
|
||||||
|
|
||||||
class PickerItemWidget extends StatelessWidget {
|
class PickerItemWidget extends StatelessWidget {
|
||||||
const PickerItemWidget(
|
const PickerItemWidget({this.iconPath, this.title, this.isSelected = false, this.tag, this.onTap});
|
||||||
{this.iconPath, this.title, this.isSelected, this.tag, this.onTap});
|
|
||||||
|
|
||||||
final String iconPath;
|
final String iconPath;
|
||||||
final String title;
|
final String title;
|
||||||
|
@ -16,74 +15,56 @@ class PickerItemWidget extends StatelessWidget {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
child: Container(
|
child: Container(
|
||||||
color: isSelected
|
color: Theme.of(context).accentTextTheme.headline6.color,
|
||||||
? Theme.of(context).textTheme.bodyText1.color
|
child: Padding(
|
||||||
: Theme.of(context).accentTextTheme.headline6.color,
|
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 24),
|
||||||
child: Center(
|
child: Row(
|
||||||
child: Padding(
|
children: [
|
||||||
padding: const EdgeInsets.all(8.0),
|
Container(
|
||||||
child: Row(
|
child: Image.asset(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
iconPath,
|
||||||
children: [
|
height: 20.0,
|
||||||
Expanded(
|
width: 20.0,
|
||||||
child: Container(
|
|
||||||
child: Image.asset(
|
|
||||||
iconPath,
|
|
||||||
height: 32.0,
|
|
||||||
width: 32.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Expanded(
|
),
|
||||||
child: Stack(
|
const SizedBox(width: 6),
|
||||||
clipBehavior: Clip.none,
|
Expanded(
|
||||||
alignment: Alignment.centerLeft,
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
title,
|
title,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: isSelected
|
color: isSelected ? Palette.blueCraiola : Theme.of(context).primaryTextTheme.title.color,
|
||||||
? Palette.blueCraiola
|
fontSize: isSelected ? 16 : 14.0,
|
||||||
: Theme.of(context).primaryTextTheme.title.color,
|
fontFamily: 'Lato',
|
||||||
fontSize: 18.0,
|
fontWeight: FontWeight.w600,
|
||||||
fontFamily: 'Lato',
|
),
|
||||||
|
),
|
||||||
|
if (tag != null)
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.topCenter,
|
||||||
|
child: Container(
|
||||||
|
width: 35.0,
|
||||||
|
height: 18.0,
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
tag,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 7.0, fontFamily: 'Lato', color: Theme.of(context).textTheme.body1.color),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(6.0),
|
||||||
|
//border: Border.all(color: ),
|
||||||
|
color: Theme.of(context).textTheme.body1.decorationColor,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
tag != null
|
],
|
||||||
? Positioned(
|
|
||||||
top: -20.0,
|
|
||||||
right: 7.0,
|
|
||||||
child: Container(
|
|
||||||
width: 35.0,
|
|
||||||
height: 18.0,
|
|
||||||
child: Center(
|
|
||||||
child: Text(
|
|
||||||
tag,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 7.0,
|
|
||||||
fontFamily: 'Lato',
|
|
||||||
color: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.body1
|
|
||||||
.color),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular(6.0),
|
|
||||||
//border: Border.all(color: ),
|
|
||||||
color: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.body1
|
|
||||||
.decorationColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Container(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
if (isSelected) Icon(Icons.check_circle, color: Theme.of(context).accentTextTheme.body2.color)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -4,58 +4,47 @@ import 'picker_item.dart';
|
||||||
import 'currency_picker_item_widget.dart';
|
import 'currency_picker_item_widget.dart';
|
||||||
|
|
||||||
class CurrencyPickerWidget extends StatelessWidget {
|
class CurrencyPickerWidget extends StatelessWidget {
|
||||||
const CurrencyPickerWidget({
|
CurrencyPickerWidget({
|
||||||
@required this.crossAxisCount,
|
@required this.crossAxisCount,
|
||||||
@required this.selectedAtIndex,
|
@required this.selectedAtIndex,
|
||||||
@required this.itemsCount,
|
|
||||||
@required this.pickerItemsList,
|
@required this.pickerItemsList,
|
||||||
@required this.pickListItem,
|
@required this.pickListItem,
|
||||||
});
|
});
|
||||||
|
|
||||||
final int crossAxisCount;
|
final int crossAxisCount;
|
||||||
final int selectedAtIndex;
|
final int selectedAtIndex;
|
||||||
final int itemsCount;
|
|
||||||
final Function pickListItem;
|
final Function pickListItem;
|
||||||
final List<PickerItem<CryptoCurrency>> pickerItemsList;
|
final List<PickerItem<CryptoCurrency>> pickerItemsList;
|
||||||
|
|
||||||
|
final ScrollController _scrollController = ScrollController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return LayoutBuilder(
|
return Container(
|
||||||
builder: (BuildContext context, BoxConstraints constraints) {
|
color: Theme.of(context).accentTextTheme.headline6.backgroundColor,
|
||||||
return Container(
|
child: Scrollbar(
|
||||||
decoration: BoxDecoration(
|
controller: _scrollController,
|
||||||
color: Theme.of(context).accentTextTheme.headline6.backgroundColor,
|
child: GridView.builder(
|
||||||
borderRadius: BorderRadius.circular(14.0),
|
controller: _scrollController,
|
||||||
),
|
padding: EdgeInsets.zero,
|
||||||
child: ClipRRect(
|
shrinkWrap: true,
|
||||||
borderRadius: BorderRadius.circular(14.0),
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
child: Scrollbar(
|
crossAxisCount: crossAxisCount,
|
||||||
showTrackOnHover: true,
|
crossAxisSpacing: 2,
|
||||||
isAlwaysShown: true,
|
childAspectRatio: 3,
|
||||||
thickness: 6.0,
|
|
||||||
radius: Radius.circular(3),
|
|
||||||
child: GridView.builder(
|
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
||||||
crossAxisCount: crossAxisCount,
|
|
||||||
crossAxisSpacing: 1,
|
|
||||||
mainAxisExtent: constraints.maxHeight / 8,
|
|
||||||
mainAxisSpacing: 1),
|
|
||||||
itemCount: pickerItemsList.length,
|
|
||||||
itemBuilder: (BuildContext ctx, index) {
|
|
||||||
return PickerItemWidget(
|
|
||||||
onTap: () {
|
|
||||||
pickListItem(index);
|
|
||||||
},
|
|
||||||
title: pickerItemsList[index].title,
|
|
||||||
iconPath: pickerItemsList[index].iconPath,
|
|
||||||
isSelected: index == selectedAtIndex,
|
|
||||||
tag: pickerItemsList[index].tag,
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
),
|
||||||
),
|
itemCount: pickerItemsList.length,
|
||||||
);
|
itemBuilder: (BuildContext ctx, index) {
|
||||||
},
|
return PickerItemWidget(
|
||||||
|
onTap: () {
|
||||||
|
pickListItem(index);
|
||||||
|
},
|
||||||
|
title: pickerItemsList[index].title,
|
||||||
|
iconPath: pickerItemsList[index].iconPath,
|
||||||
|
tag: pickerItemsList[index].tag,
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -445,7 +445,7 @@ class ExchangeCardState extends State<ExchangeCard> {
|
||||||
builder: (_) => CurrencyPicker(
|
builder: (_) => CurrencyPicker(
|
||||||
selectedAtIndex: widget.currencies.indexOf(_selectedCurrency),
|
selectedAtIndex: widget.currencies.indexOf(_selectedCurrency),
|
||||||
items: widget.currencies,
|
items: widget.currencies,
|
||||||
title: S.of(context).change_currency,
|
hintText: S.of(context).search_currency,
|
||||||
isMoneroWallet: _isMoneroWallet,
|
isMoneroWallet: _isMoneroWallet,
|
||||||
isConvertFrom: widget.hasRefundAddress,
|
isConvertFrom: widget.hasRefundAddress,
|
||||||
onItemSelected: (CryptoCurrency item) =>
|
onItemSelected: (CryptoCurrency item) =>
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
|
import 'package:cake_wallet/palette.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class AlertCloseButton extends StatelessWidget {
|
class AlertCloseButton extends StatelessWidget {
|
||||||
AlertCloseButton({@required this.image});
|
AlertCloseButton({this.image});
|
||||||
|
|
||||||
final Image image;
|
final Image image;
|
||||||
|
|
||||||
|
final closeButton = Image.asset(
|
||||||
|
'assets/images/close.png',
|
||||||
|
color: Palette.darkBlueCraiola,
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Positioned(
|
return Positioned(
|
||||||
|
@ -19,7 +25,7 @@ class AlertCloseButton extends StatelessWidget {
|
||||||
shape: BoxShape.circle
|
shape: BoxShape.circle
|
||||||
),
|
),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: image,
|
child: image ?? closeButton,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,7 +3,6 @@ import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:cake_wallet/src/widgets/alert_background.dart';
|
import 'package:cake_wallet/src/widgets/alert_background.dart';
|
||||||
import 'package:cake_wallet/src/widgets/alert_close_button.dart';
|
import 'package:cake_wallet/src/widgets/alert_close_button.dart';
|
||||||
import 'package:cake_wallet/palette.dart';
|
|
||||||
|
|
||||||
class Picker<Item extends Object> extends StatefulWidget {
|
class Picker<Item extends Object> extends StatefulWidget {
|
||||||
Picker({
|
Picker({
|
||||||
|
@ -49,10 +48,6 @@ class PickerState<Item> extends State<Picker> {
|
||||||
|
|
||||||
final TextEditingController searchController = TextEditingController();
|
final TextEditingController searchController = TextEditingController();
|
||||||
|
|
||||||
final closeButton = Image.asset(
|
|
||||||
'assets/images/close.png',
|
|
||||||
color: Palette.darkBlueCraiola,
|
|
||||||
);
|
|
||||||
ScrollController controller = ScrollController();
|
ScrollController controller = ScrollController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -98,81 +93,78 @@ class PickerState<Item> extends State<Picker> {
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(left: 24, right: 24, top: 24),
|
padding: EdgeInsets.only(left: 24, right: 24, top: 24),
|
||||||
child: GestureDetector(
|
child: ClipRRect(
|
||||||
onTap: () => null,
|
borderRadius: BorderRadius.all(Radius.circular(30)),
|
||||||
child: ClipRRect(
|
child: Container(
|
||||||
borderRadius: BorderRadius.all(Radius.circular(30)),
|
color: Theme.of(context).accentTextTheme.title.color,
|
||||||
child: Container(
|
child: ConstrainedBox(
|
||||||
color: Theme.of(context).accentTextTheme.title.color,
|
constraints: BoxConstraints(
|
||||||
child: ConstrainedBox(
|
maxHeight: MediaQuery.of(context).size.height * 0.65,
|
||||||
constraints: BoxConstraints(
|
),
|
||||||
maxHeight: MediaQuery.of(context).size.height * 0.65,
|
child: Column(
|
||||||
),
|
mainAxisSize: MainAxisSize.min,
|
||||||
child: Column(
|
children: [
|
||||||
mainAxisSize: MainAxisSize.min,
|
if (widget.hintText != null)
|
||||||
children: [
|
Padding(
|
||||||
if (widget.hintText != null)
|
padding: const EdgeInsets.all(16),
|
||||||
Padding(
|
child: TextFormField(
|
||||||
padding: const EdgeInsets.all(16),
|
controller: searchController,
|
||||||
child: TextFormField(
|
style: TextStyle(color: Theme.of(context).primaryTextTheme.title.color),
|
||||||
controller: searchController,
|
decoration: InputDecoration(
|
||||||
style: TextStyle(color: Theme.of(context).primaryTextTheme.title.color),
|
hintText: widget.hintText,
|
||||||
decoration: InputDecoration(
|
prefixIcon: Image.asset("assets/images/search_icon.png"),
|
||||||
hintText: widget.hintText,
|
filled: true,
|
||||||
prefixIcon: Image.asset("assets/images/search_icon.png"),
|
fillColor: Theme.of(context).accentTextTheme.display2.color,
|
||||||
filled: true,
|
alignLabelWithHint: false,
|
||||||
fillColor: Theme.of(context).accentTextTheme.display2.color,
|
contentPadding: const EdgeInsets.symmetric(vertical: 4, horizontal: 16),
|
||||||
alignLabelWithHint: false,
|
enabledBorder: OutlineInputBorder(
|
||||||
contentPadding: const EdgeInsets.symmetric(vertical: 4, horizontal: 16),
|
borderRadius: BorderRadius.circular(14),
|
||||||
enabledBorder: OutlineInputBorder(
|
borderSide: const BorderSide(
|
||||||
borderRadius: BorderRadius.circular(14),
|
color: Colors.transparent,
|
||||||
borderSide: const BorderSide(
|
)),
|
||||||
color: Colors.transparent,
|
focusedBorder: OutlineInputBorder(
|
||||||
)),
|
borderRadius: BorderRadius.circular(14),
|
||||||
focusedBorder: OutlineInputBorder(
|
borderSide: const BorderSide(
|
||||||
borderRadius: BorderRadius.circular(14),
|
color: Colors.transparent,
|
||||||
borderSide: const BorderSide(
|
)),
|
||||||
color: Colors.transparent,
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Divider(
|
|
||||||
color: Theme.of(context).accentTextTheme.title.backgroundColor,
|
|
||||||
height: 1,
|
|
||||||
),
|
),
|
||||||
if (widget.selectedAtIndex != -1) buildSelectedItem(),
|
Divider(
|
||||||
Flexible(
|
color: Theme.of(context).accentTextTheme.title.backgroundColor,
|
||||||
child: Stack(
|
height: 1,
|
||||||
alignment: Alignment.center,
|
),
|
||||||
children: <Widget>[
|
if (widget.selectedAtIndex != -1) buildSelectedItem(),
|
||||||
(items?.length ?? 0) > 3 ? Scrollbar(
|
Flexible(
|
||||||
controller: controller,
|
child: Stack(
|
||||||
child: itemsList(),
|
alignment: Alignment.center,
|
||||||
) : itemsList(),
|
children: <Widget>[
|
||||||
(widget.description?.isNotEmpty ?? false)
|
(items?.length ?? 0) > 3 ? Scrollbar(
|
||||||
? Positioned(
|
controller: controller,
|
||||||
bottom: 24,
|
child: itemsList(),
|
||||||
left: 24,
|
) : itemsList(),
|
||||||
right: 24,
|
(widget.description?.isNotEmpty ?? false)
|
||||||
child: Text(
|
? Positioned(
|
||||||
widget.description,
|
bottom: 24,
|
||||||
textAlign: TextAlign.center,
|
left: 24,
|
||||||
style: TextStyle(
|
right: 24,
|
||||||
fontSize: 12,
|
child: Text(
|
||||||
fontWeight: FontWeight.w500,
|
widget.description,
|
||||||
fontFamily: 'Lato',
|
textAlign: TextAlign.center,
|
||||||
decoration: TextDecoration.none,
|
style: TextStyle(
|
||||||
color: Theme.of(context).primaryTextTheme.title.color,
|
fontSize: 12,
|
||||||
),
|
fontWeight: FontWeight.w500,
|
||||||
|
fontFamily: 'Lato',
|
||||||
|
decoration: TextDecoration.none,
|
||||||
|
color: Theme.of(context).primaryTextTheme.title.color,
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
: Offstage(),
|
)
|
||||||
],
|
: Offstage(),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -180,7 +172,7 @@ class PickerState<Item> extends State<Picker> {
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
AlertCloseButton(image: closeButton)
|
AlertCloseButton(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -193,6 +185,7 @@ class PickerState<Item> extends State<Picker> {
|
||||||
? GridView.builder(
|
? GridView.builder(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
controller: controller,
|
controller: controller,
|
||||||
|
shrinkWrap: true,
|
||||||
itemCount: items == null || items.isEmpty ? 0 : items.length,
|
itemCount: items == null || items.isEmpty ? 0 : items.length,
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: 2,
|
crossAxisCount: 2,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import 'package:cake_wallet/di.dart';
|
||||||
|
import 'package:cake_wallet/store/settings_store.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
import 'package:cake_wallet/entities/fiat_currency.dart';
|
import 'package:cake_wallet/entities/fiat_currency.dart';
|
||||||
|
|
||||||
|
@ -6,12 +8,24 @@ part 'buy_amount_view_model.g.dart';
|
||||||
class BuyAmountViewModel = BuyAmountViewModelBase with _$BuyAmountViewModel;
|
class BuyAmountViewModel = BuyAmountViewModelBase with _$BuyAmountViewModel;
|
||||||
|
|
||||||
abstract class BuyAmountViewModelBase with Store {
|
abstract class BuyAmountViewModelBase with Store {
|
||||||
BuyAmountViewModelBase() : amount = '';
|
BuyAmountViewModelBase() {
|
||||||
|
amount = '';
|
||||||
|
|
||||||
|
int selectedIndex = FiatCurrency.currenciesAvailableToBuyWith
|
||||||
|
.indexOf(getIt.get<SettingsStore>().fiatCurrency);
|
||||||
|
|
||||||
|
if (selectedIndex == -1) {
|
||||||
|
selectedIndex = FiatCurrency.currenciesAvailableToBuyWith
|
||||||
|
.indexOf(FiatCurrency.usd);
|
||||||
|
}
|
||||||
|
fiatCurrency = FiatCurrency.currenciesAvailableToBuyWith[selectedIndex];
|
||||||
|
}
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
String amount;
|
String amount;
|
||||||
|
|
||||||
FiatCurrency get fiatCurrency => FiatCurrency.usd;
|
@observable
|
||||||
|
FiatCurrency fiatCurrency;
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
double get doubleAmount {
|
double get doubleAmount {
|
||||||
|
|
|
@ -54,6 +54,7 @@ abstract class BuyViewModelBase with Store {
|
||||||
|
|
||||||
double get doubleAmount => buyAmountViewModel.doubleAmount;
|
double get doubleAmount => buyAmountViewModel.doubleAmount;
|
||||||
|
|
||||||
|
@computed
|
||||||
FiatCurrency get fiatCurrency => buyAmountViewModel.fiatCurrency;
|
FiatCurrency get fiatCurrency => buyAmountViewModel.fiatCurrency;
|
||||||
|
|
||||||
CryptoCurrency get cryptoCurrency => walletTypeToCryptoCurrency(type);
|
CryptoCurrency get cryptoCurrency => walletTypeToCryptoCurrency(type);
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import 'package:cake_wallet/di.dart';
|
|
||||||
import 'package:cake_wallet/entities/language_service.dart';
|
import 'package:cake_wallet/entities/language_service.dart';
|
||||||
import 'package:cake_wallet/store/yat/yat_store.dart';
|
import 'package:cake_wallet/store/yat/yat_store.dart';
|
||||||
import 'package:cake_wallet/view_model/settings/choices_list_item.dart';
|
import 'package:cake_wallet/view_model/settings/choices_list_item.dart';
|
||||||
|
@ -172,9 +171,9 @@ abstract class SettingsViewModelBase with Store {
|
||||||
displayItem: (dynamic code) {
|
displayItem: (dynamic code) {
|
||||||
return LanguageService.list[code];
|
return LanguageService.list[code];
|
||||||
},
|
},
|
||||||
selectedItem: () => getIt.get<SettingsStore>().languageCode,
|
selectedItem: () => _settingsStore.languageCode,
|
||||||
onItemSelected: (String code) {
|
onItemSelected: (String code) {
|
||||||
getIt.get<SettingsStore>().languageCode = code;
|
_settingsStore.languageCode = code;
|
||||||
},
|
},
|
||||||
images: LanguageService.list.keys.map(
|
images: LanguageService.list.keys.map(
|
||||||
(e) => Image.asset("assets/images/flags/${LanguageService.localeCountryCode[e]}.png"))
|
(e) => Image.asset("assets/images/flags/${LanguageService.localeCountryCode[e]}.png"))
|
||||||
|
|
Loading…
Reference in a new issue