Changes for buy page for bitcoin and litecoin. Added listeners for notifications from resume and launch.
M committed
Jun 8, 2021 at 23:06 UTC
81b34a30e77b8b8041d708a435e8a00bfb090fa4
5 files changed
+35
-29
ios/Runner.xcodeproj/project.pbxproj
+3
-3
@@ -366,7 +366,7 @@
366
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
367
CLANG_ENABLE_MODULES = YES;
368
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
369
- CURRENT_PROJECT_VERSION = 45;
369
+ CURRENT_PROJECT_VERSION = 46;
370
DEVELOPMENT_TEAM = 32J6BB6VUS;
371
ENABLE_BITCODE = NO;
372
EXCLUDED_SOURCE_FILE_NAMES = "";
@@ -510,7 +510,7 @@
510
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
511
CLANG_ENABLE_MODULES = YES;
512
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
513
- CURRENT_PROJECT_VERSION = 45;
513
+ CURRENT_PROJECT_VERSION = 46;
514
DEVELOPMENT_TEAM = 32J6BB6VUS;
515
ENABLE_BITCODE = NO;
516
EXCLUDED_SOURCE_FILE_NAMES = "";
@@ -546,7 +546,7 @@
546
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
547
CLANG_ENABLE_MODULES = YES;
548
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
549
- CURRENT_PROJECT_VERSION = 45;
549
+ CURRENT_PROJECT_VERSION = 46;
550
DEVELOPMENT_TEAM = 32J6BB6VUS;
551
ENABLE_BITCODE = NO;
552
EXCLUDED_SOURCE_FILE_NAMES = "";
lib/entities/push_notifications_service.dart
+22
-18
@@ -10,6 +10,25 @@ class PushNotificationsService {
10
11
static final PushNotificationsService _instance = PushNotificationsService._();
12
static Future<dynamic> _onBackgroundMessage(Map<String, dynamic> message) async {}
13
+ static Future<void> _showNotification(Map<String, dynamic> message) async {
14
+ Map<dynamic, dynamic> alert = <dynamic, dynamic>{};
15
+ String msg = '';
16
+ String title = '';
17
+
18
+ if (Platform.isIOS) {
19
+ alert = message['aps']['alert'] as Map<dynamic, dynamic> ?? <dynamic, dynamic>{};
20
+ msg = alert['body'] as String ?? '';
21
+ title = alert['title'] as String ?? '';
22
+ }
23
+
24
+ if (Platform.isAndroid) {
25
+ msg = message['notification']['body'] as String ?? '';
26
+ title = message['notification']['title'] as String ?? '';
27
+ }
28
+
29
+ await showBar<void>(navigatorKey.currentContext, msg, titleText: title, duration: null);
30
+ }
31
+
32
final _firebaseMessaging = FirebaseMessaging();
33
bool _initialized = false;
34
@@ -20,24 +39,9 @@ class PushNotificationsService {
39
40
_firebaseMessaging.requestNotificationPermissions();
41
_firebaseMessaging.configure(
23
- onMessage: (message) async {
24
- Map<dynamic, dynamic> alert = <dynamic, dynamic>{};
25
- String msg = '';
26
- String title = '';
27
-
28
- if (Platform.isIOS) {
29
- alert = message['aps']['alert'] as Map<dynamic, dynamic> ?? <dynamic, dynamic>{};
30
- msg = alert['body'] as String ?? '';
31
- title = alert['title'] as String ?? '';
32
- }
33
-
34
- if (Platform.isAndroid) {
35
- msg = message['notification']['body'] as String ?? '';
36
- title = message['notification']['title'] as String ?? '';
37
- }
38
-
39
- await showBar<void>(navigatorKey.currentContext, msg, titleText: title, duration: null);
40
- },
42
+ onMessage: (message) async => _showNotification(message),
43
+ onLaunch: (message) async => _showNotification(message),
44
+ onResume: (message) async => _showNotification(message),
45
onBackgroundMessage: _onBackgroundMessage);
46
47
_initialized = true;
lib/src/screens/buy/pre_order_page.dart
+1
-3
@@ -73,9 +73,7 @@ class PreOrderPage extends BasePage {
73
@override
74
Widget trailing(context) => TrailButton(
75
caption: S.of(context).clear,
76
- onPressed: () {
77
- buyViewModel.reset();
78
- });
76
+ onPressed: () => buyViewModel.reset());
77
78
@override
79
Widget body(BuildContext context) {
lib/src/screens/dashboard/dashboard_page.dart
+4
-4
@@ -180,10 +180,7 @@ class DashboardPage extends BasePage {
180
final walletType = walletViewModel.type;
181
182
switch (walletType) {
183
- case WalletType.bitcoin:
184
- Navigator.of(context).pushNamed(Routes.preOrder);
185
- break;
186
- default:
183
+ case WalletType.monero:
184
await showPopUp<void>(
185
context: context,
186
builder: (BuildContext context) {
@@ -194,6 +191,9 @@ class DashboardPage extends BasePage {
191
buttonAction: () => Navigator.of(context).pop());
192
});
193
break;
194
+ default:
195
+ Navigator.of(context).pushNamed(Routes.preOrder);
196
+ break;
197
}
198
}
199
}
lib/view_model/buy/buy_view_model.dart
+5
-1
@@ -89,7 +89,11 @@ abstract class BuyViewModelBase with Store {
89
}
90
91
Future<void> _fetchBuyItems() async {
92
- final List<BuyProvider> _providerList = [WyreBuyProvider(wallet: wallet)];
92
+ final List<BuyProvider> _providerList = [];
93
+
94
+ if (wallet.type == WalletType.bitcoin) {
95
+ _providerList.add(WyreBuyProvider(wallet: wallet));
96
+ }
97
98
var isMoonPayEnabled = false;
99
try {