mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-18 05:51:34 +02:00
@@ -1,5 +1,5 @@
|
||||
class BitcoinMnemonicIsIncorrectException implements Exception {
|
||||
@override
|
||||
String toString() =>
|
||||
'Bitcoin mnemonic has incorrect format. Mnemonic should contain 24 words separated by space.';
|
||||
'Bitcoin mnemonic has incorrect format. Mnemonic should contain 12 or 24 words separated by space.';
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ abstract class ElectrumTransactionHistoryBase
|
||||
|
||||
@override
|
||||
void addMany(Map<String, ElectrumTransactionInfo> transactions) =>
|
||||
this.transactions.addAll(transactions);
|
||||
transactions.forEach((_, tx) => _updateOrInsert(tx));
|
||||
|
||||
@override
|
||||
Future<void> save() async {
|
||||
|
||||
+6
-1
@@ -113,6 +113,7 @@ import 'package:cake_wallet/store/templates/exchange_template_store.dart';
|
||||
import 'package:cake_wallet/entities/template.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_template.dart';
|
||||
import 'package:cake_wallet/.secrets.g.dart' as secrets;
|
||||
import 'package:cake_wallet/entities/push_notifications_service.dart';
|
||||
|
||||
final getIt = GetIt.instance;
|
||||
|
||||
@@ -232,6 +233,9 @@ Future setup(
|
||||
settingsStore: getIt.get<SettingsStore>(),
|
||||
fiatConvertationStore: getIt.get<FiatConversionStore>()));
|
||||
|
||||
|
||||
getIt.registerFactory(() => PushNotificationsService());
|
||||
|
||||
getIt.registerFactory(() => DashboardViewModel(
|
||||
balanceViewModel: getIt.get<BalanceViewModel>(),
|
||||
appStore: getIt.get<AppStore>(),
|
||||
@@ -241,7 +245,8 @@ Future setup(
|
||||
settingsStore: settingsStore,
|
||||
ordersSource: _ordersSource,
|
||||
ordersStore: getIt.get<OrdersStore>(),
|
||||
wyreViewModel: getIt.get<WyreViewModel>()));
|
||||
wyreViewModel: getIt.get<WyreViewModel>(),
|
||||
pushNotificationsService: getIt.get<PushNotificationsService>()));
|
||||
|
||||
getIt.registerFactory<AuthService>(() => AuthService(
|
||||
secureStorage: getIt.get<FlutterSecureStorage>(),
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import 'dart:io';
|
||||
import 'package:cake_wallet/main.dart';
|
||||
import 'package:cake_wallet/utils/show_bar.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
|
||||
class PushNotificationsService {
|
||||
PushNotificationsService._();
|
||||
|
||||
factory PushNotificationsService() => _instance;
|
||||
|
||||
static final PushNotificationsService _instance = PushNotificationsService._();
|
||||
static Future<dynamic> _onBackgroundMessage(Map<String, dynamic> message) async {}
|
||||
final _firebaseMessaging = FirebaseMessaging();
|
||||
bool _initialized = false;
|
||||
|
||||
Future<void> init() async {
|
||||
if (_initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
_firebaseMessaging.requestNotificationPermissions();
|
||||
_firebaseMessaging.configure(
|
||||
onMessage: (message) async {
|
||||
Map<dynamic, dynamic> alert = {};
|
||||
String msg = '';
|
||||
String title = '';
|
||||
|
||||
if (Platform.isIOS) {
|
||||
alert = message['aps']['alert'] as Map<dynamic, dynamic> ?? <dynamic, dynamic>{};
|
||||
msg = alert['body'] as String ?? '';
|
||||
title = alert['title'] as String ?? '';
|
||||
}
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
msg = message['notification']['body'] as String ?? '';
|
||||
title = message['notification']['title'] as String ?? '';
|
||||
}
|
||||
|
||||
await showBar<void>(navigatorKey.currentContext, msg, titleText: title, duration: null);
|
||||
},
|
||||
onBackgroundMessage: _onBackgroundMessage);
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ String walletTypeToDisplayName(WalletType type) {
|
||||
case WalletType.bitcoin:
|
||||
return 'Bitcoin (Electrum)';
|
||||
case WalletType.litecoin:
|
||||
return 'Litecoin';
|
||||
return 'Litecoin (Electrum)';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
|
||||
|
||||
+12
-4
@@ -2,8 +2,11 @@ import 'package:flushbar/flushbar.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Future<T> showBar<T>(BuildContext context, String text,
|
||||
{bool isDark = false, Duration duration = const Duration(seconds: 1), bool isDismissible = true}) {
|
||||
Future<T> showBar<T>(BuildContext context, String messageText,
|
||||
{bool isDark = false,
|
||||
Duration duration = const Duration(seconds: 1),
|
||||
bool isDismissible = true,
|
||||
String titleText}) {
|
||||
final bar = Flushbar<T>(
|
||||
boxShadows: [
|
||||
BoxShadow(
|
||||
@@ -14,9 +17,14 @@ Future<T> showBar<T>(BuildContext context, String text,
|
||||
backgroundColor: isDark ? Colors.black : Colors.white,
|
||||
borderRadius: 35,
|
||||
margin: EdgeInsets.all(50),
|
||||
messageText: Text(text,
|
||||
titleText: titleText != null
|
||||
? Text(titleText,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: isDark ? Colors.white : Colors.black, fontWeight: FontWeight.bold, fontSize: 24.0))
|
||||
: null,
|
||||
messageText: Text(messageText,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: isDark ? Colors.white : Colors.black)),
|
||||
style: TextStyle(color: isDark ? Colors.white : Colors.black, fontSize: 16)),
|
||||
duration: duration,
|
||||
isDismissible: isDismissible,
|
||||
flushbarPosition: FlushbarPosition.TOP,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:cake_wallet/core/transaction_history.dart';
|
||||
import 'package:cake_wallet/entities/balance.dart';
|
||||
import 'package:cake_wallet/entities/order.dart';
|
||||
import 'package:cake_wallet/entities/push_notifications_service.dart';
|
||||
import 'package:cake_wallet/monero/account.dart';
|
||||
import 'package:cake_wallet/monero/monero_balance.dart';
|
||||
import 'package:cake_wallet/monero/monero_transaction_info.dart';
|
||||
@@ -44,7 +45,9 @@ abstract class DashboardViewModelBase with Store {
|
||||
this.settingsStore,
|
||||
this.ordersSource,
|
||||
this.ordersStore,
|
||||
this.wyreViewModel}) {
|
||||
this.wyreViewModel,
|
||||
PushNotificationsService pushNotificationsService}) {
|
||||
_pushNotificationsService = pushNotificationsService;
|
||||
filterItems = {
|
||||
S.current.transactions: [
|
||||
FilterItem(
|
||||
@@ -133,6 +136,8 @@ abstract class DashboardViewModelBase with Store {
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
Future.delayed(Duration(seconds: 2), () => _pushNotificationsService.init());
|
||||
}
|
||||
|
||||
@observable
|
||||
@@ -227,18 +232,20 @@ abstract class DashboardViewModelBase with Store {
|
||||
|
||||
bool get isBuyEnabled => settingsStore.isBitcoinBuyEnabled;
|
||||
|
||||
PushNotificationsService _pushNotificationsService;
|
||||
|
||||
ReactionDisposer _onMoneroAccountChangeReaction;
|
||||
|
||||
ReactionDisposer _onMoneroBalanceChangeReaction;
|
||||
|
||||
@observable
|
||||
bool isOutdatedElectrumWallet;
|
||||
|
||||
Future<void> reconnect() async {
|
||||
final node = appStore.settingsStore.getCurrentNode(wallet.type);
|
||||
await wallet.connectToNode(node: node);
|
||||
}
|
||||
|
||||
@observable
|
||||
bool isOutdatedElectrumWallet;
|
||||
|
||||
@action
|
||||
void _onWalletChange(
|
||||
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>,
|
||||
|
||||
Reference in New Issue
Block a user