Merge pull request #110 from cake-tech/CAKE-54-usdterc20-for-changenow

Cake 54 usdterc20 for changenow
This commit is contained in:
M 2020-10-01 18:38:21 +03:00
commit 90d33bc9fa
7 changed files with 135 additions and 70 deletions

BIN
assets/images/usdterc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

View file

@ -38,6 +38,8 @@ class AddressValidator extends TextValidator {
return '[0-9a-zA-Z]'; return '[0-9a-zA-Z]';
case CryptoCurrency.usdt: case CryptoCurrency.usdt:
return '[0-9a-zA-Z]'; return '[0-9a-zA-Z]';
case CryptoCurrency.usdterc20:
return '[0-9a-zA-Z]';
case CryptoCurrency.xlm: case CryptoCurrency.xlm:
return '[0-9a-zA-Z]'; return '[0-9a-zA-Z]';
case CryptoCurrency.xrp: case CryptoCurrency.xrp:
@ -75,6 +77,8 @@ class AddressValidator extends TextValidator {
return [34]; return [34];
case CryptoCurrency.usdt: case CryptoCurrency.usdt:
return [42]; return [42];
case CryptoCurrency.usdterc20:
return [42];
case CryptoCurrency.xlm: case CryptoCurrency.xlm:
return [56]; return [56];
case CryptoCurrency.xrp: case CryptoCurrency.xrp:

View file

@ -22,6 +22,7 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
CryptoCurrency.nano, CryptoCurrency.nano,
CryptoCurrency.trx, CryptoCurrency.trx,
CryptoCurrency.usdt, CryptoCurrency.usdt,
CryptoCurrency.usdterc20,
CryptoCurrency.xlm, CryptoCurrency.xlm,
CryptoCurrency.xrp CryptoCurrency.xrp
]; ];
@ -38,8 +39,9 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
static const nano = CryptoCurrency(title: 'NANO', raw: 10); static const nano = CryptoCurrency(title: 'NANO', raw: 10);
static const trx = CryptoCurrency(title: 'TRX', raw: 11); static const trx = CryptoCurrency(title: 'TRX', raw: 11);
static const usdt = CryptoCurrency(title: 'USDT', raw: 12); static const usdt = CryptoCurrency(title: 'USDT', raw: 12);
static const xlm = CryptoCurrency(title: 'XLM', raw: 13); static const usdterc20 = CryptoCurrency(title: 'USDTERC20', raw: 13);
static const xrp = CryptoCurrency(title: 'XRP', raw: 14); static const xlm = CryptoCurrency(title: 'XLM', raw: 14);
static const xrp = CryptoCurrency(title: 'XRP', raw: 15);
static CryptoCurrency deserialize({int raw}) { static CryptoCurrency deserialize({int raw}) {
switch (raw) { switch (raw) {
@ -70,8 +72,10 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
case 12: case 12:
return CryptoCurrency.usdt; return CryptoCurrency.usdt;
case 13: case 13:
return CryptoCurrency.xlm; return CryptoCurrency.usdterc20;
case 14: case 14:
return CryptoCurrency.xlm;
case 15:
return CryptoCurrency.xrp; return CryptoCurrency.xrp;
default: default:
return null; return null;
@ -106,6 +110,8 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
return CryptoCurrency.trx; return CryptoCurrency.trx;
case 'usdt': case 'usdt':
return CryptoCurrency.usdt; return CryptoCurrency.usdt;
case 'usdterc20':
return CryptoCurrency.usdterc20;
case 'xlm': case 'xlm':
return CryptoCurrency.xlm; return CryptoCurrency.xlm;
case 'xrp': case 'xrp':

View file

@ -220,6 +220,9 @@ class ContactListPage extends BasePage {
case CryptoCurrency.usdt: case CryptoCurrency.usdt:
image = Image.asset('assets/images/usdt.png', height: 24, width: 24); image = Image.asset('assets/images/usdt.png', height: 24, width: 24);
break; break;
case CryptoCurrency.usdterc20:
image = Image.asset('assets/images/usdterc.png', height: 24, width: 24);
break;
case CryptoCurrency.xlm: case CryptoCurrency.xlm:
image = Image.asset('assets/images/xlm.png', height: 24, width: 24); image = Image.asset('assets/images/xlm.png', height: 24, width: 24);
break; break;

View file

@ -5,8 +5,9 @@ import 'package:flutter/material.dart';
import 'package:cake_wallet/entities/crypto_currency.dart'; import 'package:cake_wallet/entities/crypto_currency.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/src/widgets/cake_scrollbar.dart';
class CurrencyPicker extends StatelessWidget { class CurrencyPicker extends StatefulWidget {
CurrencyPicker({ CurrencyPicker({
@required this.selectedAtIndex, @required this.selectedAtIndex,
@required this.items, @required this.items,
@ -18,12 +19,47 @@ class CurrencyPicker extends StatelessWidget {
final List<CryptoCurrency> items; final List<CryptoCurrency> items;
final String title; final String title;
final Function(CryptoCurrency) onItemSelected; final Function(CryptoCurrency) onItemSelected;
@override
CurrencyPickerState createState() => CurrencyPickerState(
selectedAtIndex,
items,
title,
onItemSelected
);
}
class CurrencyPickerState extends State<CurrencyPicker> {
CurrencyPickerState(
this.selectedAtIndex,
this.items,
this.title,
this.onItemSelected): itemsCount = items.length;
final int selectedAtIndex;
final List<CryptoCurrency> items;
final String title;
final Function(CryptoCurrency) onItemSelected;
final closeButton = Image.asset('assets/images/close.png', final closeButton = Image.asset('assets/images/close.png',
color: Palette.darkBlueCraiola, color: Palette.darkBlueCraiola,
); );
final int crossAxisCount = 3;
final int itemsCount;
final double backgroundHeight = 280;
final double thumbHeight = 72;
ScrollController controller = ScrollController();
double fromTop = 0;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
controller.addListener(() {
fromTop = controller.hasClients
? (controller.offset / controller.position.maxScrollExtent * (backgroundHeight - thumbHeight))
: 0;
setState(() {});
});
return AlertBackground( return AlertBackground(
child: Stack( child: Stack(
alignment: Alignment.center, alignment: Alignment.center,
@ -52,54 +88,72 @@ class CurrencyPicker extends StatelessWidget {
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(14)), borderRadius: BorderRadius.all(Radius.circular(14)),
child: Container( child: Container(
height: 400, height: 320,
width: 300, width: 300,
color: Theme.of(context).accentTextTheme.title.backgroundColor, color: Theme.of(context).accentTextTheme.title.backgroundColor,
child: GridView.count( child: Stack(
shrinkWrap: true, alignment: Alignment.center,
crossAxisCount: 3, children: <Widget>[
childAspectRatio: 1.25, GridView.count(
physics: const NeverScrollableScrollPhysics(), controller: controller,
crossAxisSpacing: 1, crossAxisCount: crossAxisCount,
mainAxisSpacing: 1, childAspectRatio: 1.25,
children: List.generate(items.length, (index) { crossAxisSpacing: 1,
mainAxisSpacing: 1,
children: List.generate(
itemsCount
+ getExtraEmptyTilesCount(crossAxisCount, itemsCount),
(index) {
final item = items[index]; if (index >= itemsCount) {
final isItemSelected = index == selectedAtIndex; return Container(
color: Theme.of(context).accentTextTheme.title.color,
);
}
final color = isItemSelected final item = items[index];
? Theme.of(context).textTheme.body2.color final isItemSelected = index == selectedAtIndex;
: Theme.of(context).accentTextTheme.title.color;
final textColor = isItemSelected
? Palette.blueCraiola
: Theme.of(context).primaryTextTheme.title.color;
return GestureDetector( final color = isItemSelected
onTap: () { ? Theme.of(context).textTheme.body2.color
if (onItemSelected == null) { : Theme.of(context).accentTextTheme.title.color;
return; final textColor = isItemSelected
} ? Palette.blueCraiola
Navigator.of(context).pop(); : Theme.of(context).primaryTextTheme.title.color;
onItemSelected(item);
}, return GestureDetector(
child: Container( onTap: () {
color: color, if (onItemSelected == null) {
child: Center( return;
child: Text( }
item.toString(), Navigator.of(context).pop();
style: TextStyle( onItemSelected(item);
fontSize: 18, },
fontFamily: 'Poppins', child: Container(
fontWeight: FontWeight.w600, color: color,
decoration: TextDecoration.none, child: Center(
color: textColor child: Text(
), item.toString(),
), style: TextStyle(
), fontSize: 15,
), fontFamily: 'Poppins',
); fontWeight: FontWeight.w600,
}) decoration: TextDecoration.none,
), color: textColor
),
),
),
),
);
})
),
CakeScrollbar(
backgroundHeight: backgroundHeight,
thumbHeight: thumbHeight,
fromTop: fromTop
)
],
)
), ),
), ),
), ),
@ -111,4 +165,9 @@ class CurrencyPicker extends StatelessWidget {
) )
); );
} }
int getExtraEmptyTilesCount(int crossAxisCount, int itemsCount) {
final int tilesInNewRowCount = itemsCount % crossAxisCount;
return tilesInNewRowCount == 0 ? 0 : crossAxisCount - tilesInNewRowCount;
}
} }

View file

@ -14,8 +14,8 @@ Future<T> showPopUp<T>({
context: context, context: context,
builder: builder, builder: builder,
barrierDismissible: barrierDismissible, barrierDismissible: barrierDismissible,
barrierColor: barrierColor, //barrierColor: barrierColor,
useSafeArea: useSafeArea, //useSafeArea: useSafeArea,
useRootNavigator: useRootNavigator, useRootNavigator: useRootNavigator,
routeSettings: routeSettings, routeSettings: routeSettings,
child: child); child: child);

View file

@ -42,7 +42,7 @@ packages:
name: async name: async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.4.2" version: "2.4.1"
auto_size_text: auto_size_text:
dependency: "direct main" dependency: "direct main"
description: description:
@ -210,7 +210,7 @@ packages:
name: collection name: collection
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.14.13" version: "1.14.12"
connectivity: connectivity:
dependency: "direct main" dependency: "direct main"
description: description:
@ -252,7 +252,7 @@ packages:
name: crypto name: crypto
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.5" version: "2.1.4"
csslib: csslib:
dependency: transitive dependency: transitive
description: description:
@ -330,13 +330,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.2" version: "1.0.2"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
ffi: ffi:
dependency: transitive dependency: transitive
description: description:
@ -512,7 +505,7 @@ packages:
name: image name: image
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.18" version: "2.1.12"
intl: intl:
dependency: "direct main" dependency: "direct main"
description: description:
@ -568,7 +561,7 @@ packages:
name: matcher name: matcher
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.8" version: "0.12.6"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@ -638,7 +631,7 @@ packages:
name: path name: path
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.7.0" version: "1.6.4"
path_drawing: path_drawing:
dependency: transitive dependency: transitive
description: description:
@ -701,7 +694,7 @@ packages:
name: petitparser name: petitparser
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.4" version: "2.4.0"
platform: platform:
dependency: transitive dependency: transitive
description: description:
@ -881,7 +874,7 @@ packages:
name: stack_trace name: stack_trace
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.9.5" version: "1.9.3"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
@ -916,7 +909,7 @@ packages:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.17" version: "0.2.15"
time: time:
dependency: transitive dependency: transitive
description: description:
@ -937,7 +930,7 @@ packages:
name: typed_data name: typed_data
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.1.6"
url_launcher: url_launcher:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1028,7 +1021,7 @@ packages:
name: xml name: xml
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.5.1" version: "3.6.1"
yaml: yaml:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1037,5 +1030,5 @@ packages:
source: hosted source: hosted
version: "2.2.1" version: "2.2.1"
sdks: sdks:
dart: ">=2.9.0-14.0.dev <3.0.0" dart: ">=2.7.0 <3.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0" flutter: ">=1.12.13+hotfix.5 <2.0.0"