Changes for buy page for bitcoin and litecoin. Added listeners for notifications from resume and launch.

This commit is contained in:
M 2021-06-08 23:06:22 +03:00
parent 6268cf3788
commit 81b34a30e7
5 changed files with 35 additions and 29 deletions

View file

@ -366,7 +366,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 45; CURRENT_PROJECT_VERSION = 46;
DEVELOPMENT_TEAM = 32J6BB6VUS; DEVELOPMENT_TEAM = 32J6BB6VUS;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
EXCLUDED_SOURCE_FILE_NAMES = ""; EXCLUDED_SOURCE_FILE_NAMES = "";
@ -510,7 +510,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 45; CURRENT_PROJECT_VERSION = 46;
DEVELOPMENT_TEAM = 32J6BB6VUS; DEVELOPMENT_TEAM = 32J6BB6VUS;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
EXCLUDED_SOURCE_FILE_NAMES = ""; EXCLUDED_SOURCE_FILE_NAMES = "";
@ -546,7 +546,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 45; CURRENT_PROJECT_VERSION = 46;
DEVELOPMENT_TEAM = 32J6BB6VUS; DEVELOPMENT_TEAM = 32J6BB6VUS;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
EXCLUDED_SOURCE_FILE_NAMES = ""; EXCLUDED_SOURCE_FILE_NAMES = "";

View file

@ -10,17 +10,7 @@ class PushNotificationsService {
static final PushNotificationsService _instance = PushNotificationsService._(); static final PushNotificationsService _instance = PushNotificationsService._();
static Future<dynamic> _onBackgroundMessage(Map<String, dynamic> message) async {} static Future<dynamic> _onBackgroundMessage(Map<String, dynamic> message) async {}
final _firebaseMessaging = FirebaseMessaging(); static Future<void> _showNotification(Map<String, dynamic> message) async {
bool _initialized = false;
Future<void> init() async {
if (_initialized) {
return;
}
_firebaseMessaging.requestNotificationPermissions();
_firebaseMessaging.configure(
onMessage: (message) async {
Map<dynamic, dynamic> alert = <dynamic, dynamic>{}; Map<dynamic, dynamic> alert = <dynamic, dynamic>{};
String msg = ''; String msg = '';
String title = ''; String title = '';
@ -37,7 +27,21 @@ class PushNotificationsService {
} }
await showBar<void>(navigatorKey.currentContext, msg, titleText: title, duration: null); await showBar<void>(navigatorKey.currentContext, msg, titleText: title, duration: null);
}, }
final _firebaseMessaging = FirebaseMessaging();
bool _initialized = false;
Future<void> init() async {
if (_initialized) {
return;
}
_firebaseMessaging.requestNotificationPermissions();
_firebaseMessaging.configure(
onMessage: (message) async => _showNotification(message),
onLaunch: (message) async => _showNotification(message),
onResume: (message) async => _showNotification(message),
onBackgroundMessage: _onBackgroundMessage); onBackgroundMessage: _onBackgroundMessage);
_initialized = true; _initialized = true;

View file

@ -73,9 +73,7 @@ class PreOrderPage extends BasePage {
@override @override
Widget trailing(context) => TrailButton( Widget trailing(context) => TrailButton(
caption: S.of(context).clear, caption: S.of(context).clear,
onPressed: () { onPressed: () => buyViewModel.reset());
buyViewModel.reset();
});
@override @override
Widget body(BuildContext context) { Widget body(BuildContext context) {

View file

@ -180,10 +180,7 @@ class DashboardPage extends BasePage {
final walletType = walletViewModel.type; final walletType = walletViewModel.type;
switch (walletType) { switch (walletType) {
case WalletType.bitcoin: case WalletType.monero:
Navigator.of(context).pushNamed(Routes.preOrder);
break;
default:
await showPopUp<void>( await showPopUp<void>(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
@ -194,6 +191,9 @@ class DashboardPage extends BasePage {
buttonAction: () => Navigator.of(context).pop()); buttonAction: () => Navigator.of(context).pop());
}); });
break; break;
default:
Navigator.of(context).pushNamed(Routes.preOrder);
break;
} }
} }
} }

View file

@ -89,7 +89,11 @@ abstract class BuyViewModelBase with Store {
} }
Future<void> _fetchBuyItems() async { Future<void> _fetchBuyItems() async {
final List<BuyProvider> _providerList = [WyreBuyProvider(wallet: wallet)]; final List<BuyProvider> _providerList = [];
if (wallet.type == WalletType.bitcoin) {
_providerList.add(WyreBuyProvider(wallet: wallet));
}
var isMoonPayEnabled = false; var isMoonPayEnabled = false;
try { try {