mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-23 06:38:35 +02:00
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into CW-66-open-app-from-qr-code
Conflicts: lib/di.dart lib/src/screens/send/send_page.dart lib/src/screens/send/widgets/send_card.dart lib/utils/payment_request.dart res/values/strings_de.arb res/values/strings_en.arb res/values/strings_es.arb res/values/strings_fr.arb res/values/strings_hi.arb res/values/strings_hr.arb res/values/strings_it.arb res/values/strings_ja.arb res/values/strings_ko.arb res/values/strings_nl.arb res/values/strings_pl.arb res/values/strings_pt.arb res/values/strings_ru.arb res/values/strings_uk.arb res/values/strings_zh.arb
This commit is contained in:
@@ -3,21 +3,21 @@ import 'package:cake_wallet/di.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
|
||||
class DateFormatter {
|
||||
static String currentLocalFormat({bool hasTime = true}) {
|
||||
static String currentLocalFormat({bool hasTime = true, bool reverse = false}) {
|
||||
final isUSA = getIt.get<SettingsStore>().languageCode.toLowerCase() == 'en';
|
||||
final format =
|
||||
isUSA ? usaStyleFormat(hasTime) : regularStyleFormat(hasTime);
|
||||
isUSA ? usaStyleFormat(hasTime, reverse) : regularStyleFormat(hasTime, reverse);
|
||||
|
||||
return format;
|
||||
}
|
||||
|
||||
static DateFormat withCurrentLocal({bool hasTime = true}) => DateFormat(
|
||||
currentLocalFormat(hasTime: hasTime),
|
||||
static DateFormat withCurrentLocal({bool hasTime = true, bool reverse = false}) => DateFormat(
|
||||
currentLocalFormat(hasTime: hasTime, reverse: reverse),
|
||||
getIt.get<SettingsStore>().languageCode);
|
||||
|
||||
static String usaStyleFormat(bool hasTime) =>
|
||||
hasTime ? 'yyyy.MM.dd, HH:mm' : 'yyyy.MM.dd';
|
||||
static String usaStyleFormat(bool hasTime, bool reverse) =>
|
||||
hasTime ? (reverse ? 'HH:mm yyyy.MM.dd' : 'yyyy.MM.dd, HH:mm') : 'yyyy.MM.dd';
|
||||
|
||||
static String regularStyleFormat(bool hasTime) =>
|
||||
hasTime ? 'dd.MM.yyyy, HH:mm' : 'dd.MM.yyyy';
|
||||
static String regularStyleFormat(bool hasTime, bool reverse) =>
|
||||
hasTime ? (reverse ? 'HH:mm dd.MM.yyyy' : 'dd.MM.yyyy, HH:mm') : 'dd.MM.yyyy';
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@ import 'dart:io';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Future<DateTime> getDate({
|
||||
@required BuildContext context,
|
||||
@required DateTime initialDate,
|
||||
@required DateTime firstDate,
|
||||
@required DateTime lastDate}) {
|
||||
Future<DateTime?> getDate({
|
||||
required BuildContext context,
|
||||
required DateTime initialDate,
|
||||
required DateTime firstDate,
|
||||
required DateTime lastDate}) {
|
||||
|
||||
if (Platform.isIOS) {
|
||||
return _buildCupertinoDataPicker(context, initialDate, firstDate, lastDate);
|
||||
@@ -15,7 +15,7 @@ Future<DateTime> getDate({
|
||||
return _buildMaterialDataPicker(context, initialDate, firstDate, lastDate);
|
||||
}
|
||||
|
||||
Future<DateTime> _buildMaterialDataPicker(
|
||||
Future<DateTime?> _buildMaterialDataPicker(
|
||||
BuildContext context,
|
||||
DateTime initialDate,
|
||||
DateTime firstDate,
|
||||
@@ -28,12 +28,12 @@ Future<DateTime> _buildMaterialDataPicker(
|
||||
helpText: '');
|
||||
}
|
||||
|
||||
Future<DateTime> _buildCupertinoDataPicker(
|
||||
Future<DateTime?> _buildCupertinoDataPicker(
|
||||
BuildContext context,
|
||||
DateTime initialDate,
|
||||
DateTime firstDate,
|
||||
DateTime lastDate) async {
|
||||
DateTime date;
|
||||
DateTime? date;
|
||||
await showModalBottomSheet<void>(
|
||||
context: context,
|
||||
builder: (_) {
|
||||
@@ -45,7 +45,6 @@ Future<DateTime> _buildCupertinoDataPicker(
|
||||
initialDateTime: initialDate,
|
||||
minimumDate: firstDate,
|
||||
maximumDate: lastDate,
|
||||
backgroundColor: Colors.white,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ class Debounce {
|
||||
Debounce(this.duration);
|
||||
|
||||
final Duration duration;
|
||||
Timer _timer;
|
||||
Timer? _timer;
|
||||
|
||||
void run(VoidCallback action) {
|
||||
_timer?.cancel();
|
||||
|
||||
@@ -7,7 +7,9 @@ import 'package:cw_core/keyable.dart';
|
||||
// class NodeListViewModel = NodeListViewModelBase with _$NodeListViewModel;
|
||||
|
||||
class ItemCell<Item> with Keyable {
|
||||
ItemCell(this.value, {this.isSelectedBuilder, @required dynamic key}) {
|
||||
ItemCell(this.value, {
|
||||
required this.isSelectedBuilder,
|
||||
required dynamic key}) {
|
||||
keyIndex = key;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class ListSection<Item> {
|
||||
const ListSection({this.items});
|
||||
const ListSection({required this.items});
|
||||
|
||||
final List<Item> items;
|
||||
}
|
||||
+13
-7
@@ -6,9 +6,13 @@ import 'package:cw_core/keyable.dart';
|
||||
void connectMapToListWithTransform<T extends Keyable, Y extends Keyable>(
|
||||
ObservableMap<dynamic, T> source,
|
||||
ObservableList<Y> dest,
|
||||
Y Function(T) transform,
|
||||
{bool Function(T) filter}) {
|
||||
Y Function(T?) transform,
|
||||
{bool Function(T?)? filter}) {
|
||||
source.observe((MapChange<dynamic, T> change) {
|
||||
if (change.type == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (change.type) {
|
||||
case OperationType.add:
|
||||
if (filter?.call(change.newValue) ?? true) {
|
||||
@@ -18,7 +22,7 @@ void connectMapToListWithTransform<T extends Keyable, Y extends Keyable>(
|
||||
case OperationType.remove:
|
||||
// Hive could has equal index and key
|
||||
dest.removeWhere((elem) =>
|
||||
elem.keyIndex == (change.key ?? change.newValue.keyIndex));
|
||||
elem.keyIndex == (change.key ?? change.newValue?.keyIndex));
|
||||
break;
|
||||
case OperationType.update:
|
||||
for (var i = 0; i < dest.length; i++) {
|
||||
@@ -29,6 +33,8 @@ void connectMapToListWithTransform<T extends Keyable, Y extends Keyable>(
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -51,7 +57,7 @@ extension MobxBindable<T extends Keyable> on Box<T> {
|
||||
StreamSubscription<BoxEvent> bindToList(
|
||||
ObservableList<T> dest, {
|
||||
bool initialFire = false,
|
||||
Filter<T> filter,
|
||||
Filter<T>? filter,
|
||||
}) {
|
||||
if (initialFire) {
|
||||
final res = filter != null ? values.where(filter) : values;
|
||||
@@ -71,7 +77,7 @@ extension MobxBindable<T extends Keyable> on Box<T> {
|
||||
ObservableList<Y> dest,
|
||||
Transform<T, Y> transform, {
|
||||
bool initialFire = false,
|
||||
Filter<T> filter,
|
||||
Filter<T>? filter,
|
||||
}) {
|
||||
if (initialFire) {
|
||||
dest.addAll(values.map((value) => transform(value)));
|
||||
@@ -94,7 +100,7 @@ extension HiveBindable<T extends Keyable> on ObservableList<T> {
|
||||
final controller = StreamController<EntityChange<T>>();
|
||||
|
||||
observe((ListChange<T> change) {
|
||||
change.elementChanges.forEach((change) {
|
||||
change.elementChanges?.forEach((change) {
|
||||
ChangeType type;
|
||||
|
||||
switch (change.type) {
|
||||
@@ -121,7 +127,7 @@ extension HiveBindable<T extends Keyable> on ObservableList<T> {
|
||||
StreamSubscription<EntityChange<T>> bindToList(ObservableList<T> dest) =>
|
||||
listen().listen((event) => dest.acceptEntityChange(event));
|
||||
|
||||
void acceptBoxChange(BoxEvent event, {T transformed}) {
|
||||
void acceptBoxChange(BoxEvent event, {T? transformed}) {
|
||||
if (event.deleted) {
|
||||
removeWhere((el) {
|
||||
return el.keyIndex == event.key;
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
class PaymentRequest {
|
||||
PaymentRequest(this.address, this.amount, {this.scheme});
|
||||
PaymentRequest(this.address, this.amount, this.note, {this.scheme});
|
||||
|
||||
factory PaymentRequest.fromUri(Uri uri) {
|
||||
var address = "";
|
||||
var amount = "";
|
||||
var note = "";
|
||||
var scheme = "";
|
||||
|
||||
if (uri != null) {
|
||||
address = uri.path;
|
||||
amount = uri.queryParameters['tx_amount'] ?? uri.queryParameters['amount'] ?? "";
|
||||
note = uri.queryParameters['tx_description']
|
||||
?? uri.queryParameters['message'] ?? "";
|
||||
scheme = uri.scheme;
|
||||
}
|
||||
|
||||
return PaymentRequest(address, amount, scheme: scheme);
|
||||
return PaymentRequest(address, amount, note, scheme: scheme);
|
||||
}
|
||||
|
||||
final String address;
|
||||
final String amount;
|
||||
final String note;
|
||||
final String scheme;
|
||||
}
|
||||
+58
-42
@@ -1,55 +1,71 @@
|
||||
import 'package:flushbar/flushbar.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:another_flushbar/flushbar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Future<T> showBar<T>(BuildContext context, String messageText,
|
||||
Future<T?> showBar<T>(BuildContext context, String messageText,
|
||||
{bool isDark = false,
|
||||
Duration duration = const Duration(seconds: 1),
|
||||
bool isDismissible = true,
|
||||
String titleText}) {
|
||||
Duration? duration = const Duration(seconds: 1), // pass explicitly by null to make the duration indefinite
|
||||
bool isDismissible = true,
|
||||
String? titleText}) async {
|
||||
final bar = Flushbar<T>(
|
||||
boxShadows: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.09),
|
||||
blurRadius: 8,
|
||||
offset: Offset(0, 2))
|
||||
],
|
||||
backgroundColor: isDark ? Colors.black : Colors.white,
|
||||
borderRadius: 35,
|
||||
margin: EdgeInsets.all(50),
|
||||
titleText: titleText != null
|
||||
? Text(titleText,
|
||||
boxShadows: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.09),
|
||||
blurRadius: 8,
|
||||
offset: Offset(0, 2),
|
||||
)
|
||||
],
|
||||
backgroundColor: isDark ? Colors.black : Colors.white,
|
||||
borderRadius: BorderRadius.circular(35),
|
||||
margin: EdgeInsets.all(50),
|
||||
titleText: titleText != null
|
||||
? Text(
|
||||
titleText,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: isDark ? Colors.white : Colors.black, fontWeight: FontWeight.bold, fontSize: 24.0))
|
||||
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, fontSize: 16)),
|
||||
duration: duration,
|
||||
isDismissible: isDismissible,
|
||||
flushbarPosition: FlushbarPosition.TOP,
|
||||
flushbarStyle: FlushbarStyle.FLOATING);
|
||||
messageText: Text(
|
||||
messageText,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: isDark ? Colors.white : Colors.black,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
duration: duration,
|
||||
isDismissible: isDismissible,
|
||||
flushbarPosition: FlushbarPosition.TOP,
|
||||
flushbarStyle: FlushbarStyle.FLOATING,
|
||||
);
|
||||
|
||||
return bar.show(context);
|
||||
}
|
||||
|
||||
Flushbar<T> createBar<T>(String text,
|
||||
{bool isDark = false, Duration duration = const Duration(seconds: 1), bool isDismissible = true}) {
|
||||
{bool isDark = false,
|
||||
Duration? duration = const Duration(seconds: 1), // pass explicitly by null to make the duration indefinite
|
||||
bool isDismissible = true}) {
|
||||
return Flushbar<T>(
|
||||
boxShadows: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.09),
|
||||
blurRadius: 8,
|
||||
offset: Offset(0, 2))
|
||||
],
|
||||
backgroundColor: isDark ? Colors.black : Colors.white,
|
||||
borderRadius: 35,
|
||||
margin: EdgeInsets.all(50),
|
||||
messageText: Text(text,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: isDark ? Colors.white : Colors.black)),
|
||||
duration: duration,
|
||||
isDismissible: isDismissible,
|
||||
flushbarPosition: FlushbarPosition.TOP,
|
||||
flushbarStyle: FlushbarStyle.FLOATING);
|
||||
boxShadows: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.09),
|
||||
blurRadius: 8,
|
||||
offset: Offset(0, 2),
|
||||
)
|
||||
],
|
||||
backgroundColor: isDark ? Colors.black : Colors.white,
|
||||
borderRadius: BorderRadius.circular(35),
|
||||
margin: EdgeInsets.all(50),
|
||||
messageText: Text(text,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: isDark ? Colors.white : Colors.black)),
|
||||
duration: duration,
|
||||
isDismissible: isDismissible,
|
||||
flushbarPosition: FlushbarPosition.TOP,
|
||||
flushbarStyle: FlushbarStyle.FLOATING,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Future<T> showPopUp<T>({
|
||||
@required BuildContext context,
|
||||
WidgetBuilder builder,
|
||||
Future<T?> showPopUp<T>({
|
||||
required BuildContext context,
|
||||
required WidgetBuilder builder,
|
||||
bool barrierDismissible = true,
|
||||
Color barrierColor,
|
||||
Color? barrierColor,
|
||||
bool useSafeArea = false,
|
||||
bool useRootNavigator = true,
|
||||
RouteSettings routeSettings
|
||||
RouteSettings? routeSettings
|
||||
}) {
|
||||
return showDialog<T>(
|
||||
context: context,
|
||||
|
||||
Reference in New Issue
Block a user