CAKE-306 | fixed MoonPay icon for buy_list_item.dart and order_row.dart

OleksandrSobol committed Jun 2, 2021 at 16:52 UTC 90d53c9f6e1393c827176e4fbaac32f036489b3c
7 files changed +47 -25
assets/images/moonpay-icon.png
Binary files a/assets/images/moonpay-icon.png and b/assets/images/moonpay-icon.png differ
lib/buy/get_buy_provider_icon.dart
+10 -4
@@ -1,18 +1,24 @@
1 import 'package:flutter/material.dart';
2 import 'package:cake_wallet/buy/buy_provider_description.dart';
3
4 -Image getBuyProviderIcon(BuyProviderDescription providerDescription) {
4 +Image getBuyProviderIcon(BuyProviderDescription providerDescription,
5 + {bool isWhiteIconColor = false}) {
6 +
7 final _wyreIcon =
8 Image.asset('assets/images/wyre-icon.png', width: 36, height: 36);
7 - final _moonPayIcon =
8 - Image.asset('assets/images/moonpay-icon.png', width: 36, height: 34);
9 + final _moonPayWhiteIcon =
10 + Image.asset('assets/images/moonpay-icon.png', color: Colors.white,
11 + width: 36, height: 34);
12 + final _moonPayBlackIcon =
13 + Image.asset('assets/images/moonpay-icon.png', color: Colors.black,
14 + width: 36, height: 34);
15
16 if (providerDescription != null) {
17 switch (providerDescription) {
18 case BuyProviderDescription.wyre:
19 return _wyreIcon;
20 case BuyProviderDescription.moonPay:
15 - return _moonPayIcon;
21 + return isWhiteIconColor ? _moonPayWhiteIcon : _moonPayBlackIcon;
22 default:
23 return null;
24 }
lib/di.dart
+9 -3
@@ -155,9 +155,15 @@ Future setup(
155 (secrets.wyreApiKey?.isNotEmpty ?? false) &&
156 (secrets.wyreAccountId?.isNotEmpty ?? false);
157
158 - final locale = await Devicelocale.currentLocale;
159 - final deviceCountryCode = locale.split('_').last;
160 - final isMoonPayEnabled = await MoonPayBuyProvider.onEnabled(deviceCountryCode);
158 + var isMoonPayEnabled = false;
159 + try {
160 + final locale = await Devicelocale.currentLocale;
161 + final deviceCountryCode = locale.split('_').last;
162 + isMoonPayEnabled = await MoonPayBuyProvider.onEnabled(deviceCountryCode);
163 + } catch (e) {
164 + isMoonPayEnabled = false;
165 + print(e.toString());
166 + }
167
168 final settingsStore = await SettingsStoreBase.load(
169 nodeSource: _nodeSource, isBitcoinBuyEnabled: isBitcoinBuyEnabled,
lib/src/screens/buy/pre_order_page.dart
+1 -1
@@ -114,7 +114,7 @@ class PreOrderPage extends BasePage {
114 padding: EdgeInsets.only(top: 100, bottom: 65),
115 child: Center(
116 child: Container(
117 - width: 185,
117 + width: 210,
118 child: BaseTextFormField(
119 focusNode: _amountFocus,
120 controller: _amountController,
lib/src/screens/buy/widgets/buy_list_item.dart
+10 -13
@@ -26,25 +26,22 @@ class BuyListItem extends StatelessWidget {
26
27 @override
28 Widget build(BuildContext context) {
29 - final providerIcon = getBuyProviderIcon(provider.description);
29 + final isSelected = selectedProvider?.description == provider.description;
30
31 - final backgroundColor = selectedProvider != null
32 - ? selectedProvider.description == provider.description
31 + final providerIcon = getBuyProviderIcon(provider.description,
32 + isWhiteIconColor: isSelected);
33 +
34 + final backgroundColor = isSelected
35 ? Palette.greyBlueCraiola
34 - : Palette.shadowWhite
35 - : Palette.shadowWhite;
36 + : Palette.shadowWhite;
37
37 - final primaryTextColor = selectedProvider != null
38 - ? selectedProvider.description == provider.description
38 + final primaryTextColor = isSelected
39 ? Colors.white
40 - : Palette.darkGray
41 - : Palette.darkGray;
40 + : Palette.darkGray;
41
43 - final secondaryTextColor = selectedProvider != null
44 - ? selectedProvider.description == provider.description
42 + final secondaryTextColor = isSelected
43 ? Colors.white
46 - : Palette.darkBlueCraiola
47 - : Palette.darkBlueCraiola;
44 + : Palette.darkBlueCraiola;
45
46 return GestureDetector(
47 onTap: () => onTap?.call(),
lib/src/screens/dashboard/widgets/order_row.dart
+8 -1
@@ -1,6 +1,9 @@
1 import 'package:cake_wallet/buy/buy_provider_description.dart';
2 import 'package:cake_wallet/buy/get_buy_provider_icon.dart';
3 +import 'package:cake_wallet/themes/theme_base.dart';
4 import 'package:flutter/material.dart';
5 +import 'package:cake_wallet/di.dart';
6 +import 'package:cake_wallet/store/settings_store.dart';
7
8 class OrderRow extends StatelessWidget {
9 OrderRow({
@@ -19,7 +22,11 @@ class OrderRow extends StatelessWidget {
22
23 @override
24 Widget build(BuildContext context) {
22 - final providerIcon = getBuyProviderIcon(provider);
25 + final currentTheme = getIt.get<SettingsStore>().currentTheme;
26 + final isWhiteIconColor = currentTheme.type != ThemeType.light;
27 +
28 + final providerIcon = getBuyProviderIcon(provider,
29 + isWhiteIconColor: isWhiteIconColor);
30
31 return InkWell(
32 onTap: onTap,
lib/store/settings_store.dart
+9 -3
@@ -253,9 +253,15 @@ abstract class SettingsStoreBase with Store {
253 (secrets.wyreApiKey?.isNotEmpty ?? false) &&
254 (secrets.wyreAccountId?.isNotEmpty ?? false);
255
256 - final locale = await Devicelocale.currentLocale;
257 - final deviceCountryCode = locale.split('_').last;
258 - final isMoonPayEnabled = await MoonPayBuyProvider.onEnabled(deviceCountryCode);
256 + var isMoonPayEnabled = false;
257 + try {
258 + final locale = await Devicelocale.currentLocale;
259 + final deviceCountryCode = locale.split('_').last;
260 + isMoonPayEnabled = await MoonPayBuyProvider.onEnabled(deviceCountryCode);
261 + } catch (e) {
262 + isMoonPayEnabled = false;
263 + print(e.toString());
264 + }
265
266 final settings = await SettingsStoreBase.load(
267 nodeSource: nodeSource,