mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-18 05:51:34 +02:00
Flutter upgrade
This commit is contained in:
@@ -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: (_) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
+49
-46
@@ -1,55 +1,58 @@
|
||||
import 'package:flushbar/flushbar.dart';
|
||||
// import 'package:flushbar/flushbar.dart';
|
||||
import 'package:flutter/cupertino.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}) {
|
||||
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,
|
||||
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, fontSize: 16)),
|
||||
duration: duration,
|
||||
isDismissible: isDismissible,
|
||||
flushbarPosition: FlushbarPosition.TOP,
|
||||
flushbarStyle: FlushbarStyle.FLOATING);
|
||||
String? titleText}) async {
|
||||
// FIX-ME: Unimplemented Flushbar
|
||||
// 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,
|
||||
// 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, fontSize: 16)),
|
||||
// duration: duration,
|
||||
// isDismissible: isDismissible,
|
||||
// flushbarPosition: FlushbarPosition.TOP,
|
||||
// flushbarStyle: FlushbarStyle.FLOATING);
|
||||
|
||||
return bar.show(context);
|
||||
// return bar.show(context);
|
||||
return null;
|
||||
}
|
||||
|
||||
Flushbar<T> createBar<T>(String text,
|
||||
{bool isDark = false, Duration duration = const Duration(seconds: 1), 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);
|
||||
}
|
||||
// FIX-ME: Unimplemented Flushbar
|
||||
// Flushbar<T> createBar<T>(String text,
|
||||
// {bool isDark = false, Duration duration = const Duration(seconds: 1), 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);
|
||||
// }
|
||||
|
||||
@@ -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