diff --git a/assets/translations/de.json b/assets/translations/de.json index 0553c2b1..a7bf2e5f 100644 --- a/assets/translations/de.json +++ b/assets/translations/de.json @@ -353,5 +353,13 @@ "contact_name_exists": "Du hast bereits einen Kontakt mit diesem Namen angelegt. Bitte verwende einen anderen.", "no_contacts": "Du hast noch keine Kontakte angelegt.", "delete_contact_confirm_title": "Kontakt {} löschen?", - "delete_contact_confirm_text": "Sind Sie sich sicher, dass sie den Kontakt {} mit der Adresse {} löschen möchten?" + "delete_contact_confirm_text": "Sind Sie sich sicher, dass sie den Kontakt {} mit der Adresse {} löschen möchten?", + + "edit_action": "Bearbeiten {} (id: {})", + "edit_action_submit": "Bearbeiten", + "max_value": "Max Value", + "textfield_not_empty": "Das Textfeld {} darf nicht leer sein.", + "max_value_multiplier": "Max Value muss ein Multiplikator von 10 sein.", + "input_exceeds_limit": "Max Value muss weniger als 10^8 sein.", + "input_not_a_number": "Max Value muss eine Zahl sein." } \ No newline at end of file diff --git a/assets/translations/en.json b/assets/translations/en.json index 507deeca..cb780aa8 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -394,7 +394,7 @@ "other": "{} objects" }, "reset_objects_cache_plural": "{} cached", - "objects_list_appbar_title": "{} in storage", + "objects_list_appbar_title": "{} on the storage", "no_objects": "No cached objects", "bad_address": "Wrong address format", "delete_snapshots_dialog_title": "Delete snapshots", @@ -410,5 +410,26 @@ "uploaded_object_id": "id: ", "uploaded_object_status": "Status: ", "uploaded_object_owner": "Owner: ", - "uploaded_object_hashes": "Object's hashes: " + "uploaded_object_hashes": "Object's hashes: ", + + "@2.13.0":{ + }, + "rename_object_button_label": "Rename object", + "rename_object_dialog_title": "Rename object", + "rename_object_dialog_action": "Apply", + "scan_one_more_time_button_label": "Scan one more time", + + "edit_action": "Edit {} (id: {})", + "edit_action_submit": "Edit", + "max_value": "Max Value", + "textfield_not_empty": "The text field must not be empty.", + "max_value_multiplier": "Max Value must be a multiplier of 10.", + "input_exceeds_limit": "Max Value must be less than 10^8.", + "input_not_a_number": "Max Value must be a number.", + + "trans_bytes_none": "None", + "trans_bytes_random": "Random", + "trans_bytes_specific": "Specific", + + "trans_bytes_mode_help": "Set rotation bytes mode to None to upload an object" } \ No newline at end of file diff --git a/lib/core/persistence/hive_setup.dart b/lib/core/persistence/hive_setup.dart index 96704864..18dfe5a4 100644 --- a/lib/core/persistence/hive_setup.dart +++ b/lib/core/persistence/hive_setup.dart @@ -23,6 +23,7 @@ Future hiveSetup() async { Hive.registerAdapter(PreviewSettingsAdapter()); Hive.registerAdapter(AppSettingsAdapter()); Hive.registerAdapter(ContactAdapter()); + Hive.registerAdapter(TransBytesModeAdapter()); // poScan objects Hive.registerAdapter(UploadedObjectAdapter()); diff --git a/lib/core/utils/m_app_install_date.dart b/lib/core/utils/m_app_install_date.dart new file mode 100644 index 00000000..cad0b474 --- /dev/null +++ b/lib/core/utils/m_app_install_date.dart @@ -0,0 +1,6 @@ +import 'package:threedpass/setup.dart'; + +class MAppInstallDate { + static const String instanceName = 'app_install_date'; + static DateTime? get() => getIt(instanceName: instanceName); +} diff --git a/lib/core/widgets/buttons/elevated_button.dart b/lib/core/widgets/buttons/elevated_button.dart index d436eb95..6e6d1c31 100644 --- a/lib/core/widgets/buttons/elevated_button.dart +++ b/lib/core/widgets/buttons/elevated_button.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; +import 'package:threedpass/core/theme/d3p_colors.dart'; import 'package:threedpass/core/theme/d3p_special_styles.dart'; import 'package:threedpass/core/theme/d3p_theme.dart'; @@ -74,7 +75,16 @@ class D3pElevatedButton extends StatelessWidget { style: ButtonStyle( foregroundColor: foregroundColor != null ? MaterialStateProperty.all(foregroundColor) - : null, + : MaterialStateProperty.resolveWith( + (final states) { + if (states.contains(MaterialState.disabled)) { + return D3pColors + .disabled; // Theme.of(context).colorScheme.onSurface; + } else { + return Colors.white; + } + }, + ), backgroundColor: backgroundColor != null && onPressed != null ? MaterialStateProperty.all(backgroundColor) : null, diff --git a/lib/core/widgets/buttons/enum_buttons_list.dart b/lib/core/widgets/buttons/enum_buttons_list.dart new file mode 100644 index 00000000..d9e744d9 --- /dev/null +++ b/lib/core/widgets/buttons/enum_buttons_list.dart @@ -0,0 +1,23 @@ +import 'package:flutter/material.dart'; +import 'package:threedpass/core/widgets/buttons/enum_button.dart'; + +class EnumButtonsList extends StatelessWidget { + final int length; + final EnumButton Function(BuildContext, int) itemBuilder; + + const EnumButtonsList({ + required this.length, + required this.itemBuilder, + super.key, + }); + + @override + Widget build(final BuildContext context) { + return ListView.builder( + shrinkWrap: true, + itemCount: length, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: itemBuilder, + ); + } +} diff --git a/lib/core/widgets/screen_lock/d3p_screen_lock_theme.dart b/lib/core/widgets/screen_lock/d3p_screen_lock_theme.dart index f1fa4c93..af698ee8 100644 --- a/lib/core/widgets/screen_lock/d3p_screen_lock_theme.dart +++ b/lib/core/widgets/screen_lock/d3p_screen_lock_theme.dart @@ -30,7 +30,7 @@ class D3pScreenLockTheme { buttonStyle: OutlinedButton.styleFrom( foregroundColor: colors.themeOpposite, backgroundColor: colors.pinButtonBGColor, - shape: RoundedRectangleBorder( + shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all( D3pCardTheme.radius, ), diff --git a/lib/core/widgets/utc_time.dart b/lib/core/widgets/utc_time.dart index 3533cab1..e171f751 100644 --- a/lib/core/widgets/utc_time.dart +++ b/lib/core/widgets/utc_time.dart @@ -2,15 +2,23 @@ import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:threedpass/core/theme/d3p_colors.dart'; import 'package:threedpass/core/theme/d3p_special_styles.dart'; +import 'package:threedpass/core/widgets/text/d3p_body_medium_text.dart'; class UTCTime extends StatelessWidget { const UTCTime({required this.dateTime, required this.formatter, super.key}); - final DateTime dateTime; + final DateTime? dateTime; final DateFormat formatter; @override - Widget build(BuildContext context) { + Widget build(final BuildContext context) { + if (dateTime == null) { + return const D3pBodyMediumText( + 'null', + translate: false, + ); + } + final medium = Theme.of(context).customTextStyles.d3pBodyMedium; final small = Theme.of(context).customTextStyles.d3pBodySmall; @@ -18,7 +26,7 @@ class UTCTime extends StatelessWidget { text: TextSpan( children: [ TextSpan( - text: formatter.format(dateTime), + text: formatter.format(dateTime!), style: medium, ), WidgetSpan( diff --git a/lib/features/app/presentation/global_states_provider.dart b/lib/features/app/presentation/global_states_provider.dart index 2361d402..928ca6ba 100644 --- a/lib/features/app/presentation/global_states_provider.dart +++ b/lib/features/app/presentation/global_states_provider.dart @@ -45,7 +45,7 @@ class GlobalStatesProvider extends StatelessWidget { lazy: false, ), BlocProvider( - create: (_) => di_setup.getIt(), + create: (final _) => di_setup.getIt(), ), ], child: PlatformProvider( diff --git a/lib/features/hashes_list/bloc/hashes_list_bloc.dart b/lib/features/hashes_list/bloc/hashes_list_bloc.dart index 7e27593b..c57c4f9e 100644 --- a/lib/features/hashes_list/bloc/hashes_list_bloc.dart +++ b/lib/features/hashes_list/bloc/hashes_list_bloc.dart @@ -3,6 +3,8 @@ import 'dart:io'; import 'package:bloc/bloc.dart'; import 'package:flutter/material.dart'; import 'package:logger/logger.dart'; +import 'package:super_core/super_core.dart'; +import 'package:threedpass/core/polkawallet/utils/log.dart'; import 'package:threedpass/features/hashes_list/domain/entities/hash_object.dart'; import 'package:threedpass/features/hashes_list/domain/entities/objects_directory.dart'; import 'package:threedpass/features/hashes_list/domain/entities/snapshot.dart'; @@ -24,6 +26,7 @@ class HashesListBloc extends Bloc { on(_replaceSnapshot); on<_LoadHashesList>(_loadList); on(_unmarkNewSnap); + on(_replaceObject); } final HashesRepository hashesRepository; @@ -235,17 +238,37 @@ class HashesListBloc extends Bloc { // replace it with new one if (oldSnapIndex != -1) { obj.snapshots[oldSnapIndex] = event.snap.copyWith(isNew: false); + emit( + HashesListLoaded( + objects: list, + globalKeyMap: buildMap(list), + ), + ); } else { getIt().e( 'Not found a snapshot in object ${obj.name}. Snapshot name=${event.snap.name}', ); } + } + } + + Future _replaceObject( + final ReplaceObject event, + final Emitter emit, + ) async { + if (state is HashesListLoaded) { + final stateLL = state as HashesListLoaded; + final list = stateLL.objects; + list.replace(event.oldObj, event.newObj); emit( HashesListLoaded( objects: list, - globalKeyMap: buildMap(list), + globalKeyMap: stateLL.globalKeyMap, ), ); + } else { + logE('Replace object is called, but state is not HashesListLoaded'); + return; } } } diff --git a/lib/features/hashes_list/bloc/hashes_list_event.dart b/lib/features/hashes_list/bloc/hashes_list_event.dart index 1ac824a8..59eae60a 100644 --- a/lib/features/hashes_list/bloc/hashes_list_event.dart +++ b/lib/features/hashes_list/bloc/hashes_list_event.dart @@ -44,6 +44,16 @@ class ReplaceSnapshot extends HashesListEvent { final HashObject object; } +class ReplaceObject extends HashesListEvent { + const ReplaceObject({ + required this.oldObj, + required this.newObj, + }); + + final HashObject newObj; + final HashObject oldObj; +} + class AddObject extends HashesListEvent { const AddObject({ required this.object, diff --git a/lib/features/hashes_list/domain/entities/snapshot_create_from_file/snapshot_create_from_file.dart b/lib/features/hashes_list/domain/entities/snapshot_create_from_file/snapshot_create_from_file.dart index 72525c03..9e2b2090 100644 --- a/lib/features/hashes_list/domain/entities/snapshot_create_from_file/snapshot_create_from_file.dart +++ b/lib/features/hashes_list/domain/entities/snapshot_create_from_file/snapshot_create_from_file.dart @@ -144,7 +144,7 @@ class SnapshotFileFactory { filePath: filePath, transBytes: transBytes, algorithm: algo, - // updateIsolateListener: scanIsolateCubit.setData, + sendNone: settings.transBytesMode == TransBytesMode.none, ); return calculator.calcHashes( diff --git a/lib/features/hashes_list/domain/entities/snapshot_create_from_file/trans_bytes.dart b/lib/features/hashes_list/domain/entities/snapshot_create_from_file/trans_bytes.dart index 489f715e..81a6c14d 100644 --- a/lib/features/hashes_list/domain/entities/snapshot_create_from_file/trans_bytes.dart +++ b/lib/features/hashes_list/domain/entities/snapshot_create_from_file/trans_bytes.dart @@ -8,13 +8,13 @@ class _TransBytes { }); Future calc() async { - final String userTransBytes = scanSettings.transBytes; - - if (userTransBytes.isNotEmpty) { - return userTransBytes; + switch (scanSettings.transBytesMode) { + case TransBytesMode.none: + return ''; + case TransBytesMode.random: + return RandomHex.generate(8); + case TransBytesMode.specific: + return scanSettings.transBytes; } - - final randomTransBytes = RandomHex.generate(8); - return randomTransBytes; } } diff --git a/lib/features/hashes_list/domain/extentions/find_hashobject_by_snapshot.dart b/lib/features/hashes_list/domain/extentions/find_hashobject_by_snapshot.dart new file mode 100644 index 00000000..9f952052 --- /dev/null +++ b/lib/features/hashes_list/domain/extentions/find_hashobject_by_snapshot.dart @@ -0,0 +1,15 @@ +import 'package:threedpass/features/hashes_list/bloc/hashes_list_bloc.dart'; +import 'package:threedpass/features/hashes_list/domain/entities/hash_object.dart'; +import 'package:threedpass/features/hashes_list/domain/entities/snapshot.dart'; + +extension FindHashObjectBySnapshot on HashesListLoaded { + HashObject? findBySnapshot(final Snapshot snapshot) { + for (final hashObject in this.objects) { + if (hashObject.snapshots.contains(snapshot)) { + return hashObject; + } + } + + return null; + } +} diff --git a/lib/features/poscan_objects_query/bloc/poscan_objects_cubit.dart b/lib/features/poscan_objects_query/bloc/poscan_objects_cubit.dart index 1e6ff83a..f997ddfc 100644 --- a/lib/features/poscan_objects_query/bloc/poscan_objects_cubit.dart +++ b/lib/features/poscan_objects_query/bloc/poscan_objects_cubit.dart @@ -126,6 +126,9 @@ class PoscanObjectsCubit extends Cubit { logE("Could not load objects count from poscan. $e"); }, right: (final objLen) async { + if (objLen != state.objects.length) { + emit(state.copyWith(storageCount: objLen)); + } await load(from: 0, till: objLen); }, ); diff --git a/lib/features/poscan_objects_query/domain/entities/uploaded_object.dart b/lib/features/poscan_objects_query/domain/entities/uploaded_object.dart index d6abf2cd..0933370b 100644 --- a/lib/features/poscan_objects_query/domain/entities/uploaded_object.dart +++ b/lib/features/poscan_objects_query/domain/entities/uploaded_object.dart @@ -1,4 +1,5 @@ import 'package:hive/hive.dart'; +import 'package:threedpass/core/polkawallet/utils/log.dart'; part 'uploaded_object.g.dart'; @@ -22,21 +23,29 @@ class UploadedObject { const UploadedObject({ required this.id, required this.raw, - // required this.owner, - // required this.hashes, - // required this.status, required this.cacheDate, - // required this.statusDateUTC, }); - DateTime get statusDateUTC { - final d1 = - (raw['state'] as Map).values.first.toString().replaceAll(',', ''); - final d2 = int.parse(d1); - final initialDate = DateTime(2022, DateTime.august, 30, 21, 36); - final realStatus = initialDate.add(Duration(minutes: d2)); - - return realStatus; + DateTime? get statusDateUTC { + try { + final dynamic values = + (raw['state'] as Map).values.first; // Can be 685,523 or [793,188, 0] + String rawDate = ''; + if (values is String) { + rawDate = values; + } else if (values is List) { + rawDate = values.first.toString(); + } + final d1 = rawDate.replaceAll(',', ''); + final d2 = int.parse(d1); + final initialDate = DateTime(2022, DateTime.august, 30, 21, 36); + final realStatus = initialDate.add(Duration(minutes: d2)); + + return realStatus; + } on Object catch (e) { + logE('UploadedObject statusDateUTC ' + e.toString() + ' $raw'); + return null; + } } String get owner => raw['owner'] as String; diff --git a/lib/features/poscan_putobject/bloc/poscan_putobject_cubit.dart b/lib/features/poscan_putobject/bloc/poscan_putobject_cubit.dart index 21a26628..950a3bf5 100644 --- a/lib/features/poscan_putobject/bloc/poscan_putobject_cubit.dart +++ b/lib/features/poscan_putobject/bloc/poscan_putobject_cubit.dart @@ -7,6 +7,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:polkawallet_sdk/storage/types/keyPairData.dart'; import 'package:threedpass/core/widgets/default_loading_dialog.dart'; +import 'package:threedpass/features/poscan_putobject/data/default_poscan_properties.dart'; import 'package:threedpass/features/poscan_putobject/domain/entities/poscan_categories.dart'; import 'package:threedpass/features/poscan_putobject/domain/entities/poscan_property.dart'; import 'package:threedpass/features/poscan_putobject/domain/usecases/put_object_usecase.dart'; @@ -18,13 +19,15 @@ part 'poscan_putobject_cubit.g.dart'; class D3PRPCCubitState { final KeyPairData account; final List chosenHashes; - final List properties; + final List defaultProperties; + final List chosenProperties; final MapPoscanCategory chosenCategory; const D3PRPCCubitState({ required this.account, required this.chosenHashes, - required this.properties, + required this.defaultProperties, + required this.chosenProperties, required this.chosenCategory, }); } @@ -41,7 +44,8 @@ class PoscanPutObjectCubit extends Cubit { D3PRPCCubitState( account: initialAccount, chosenHashes: initialHashes, - properties: [], + defaultProperties: defaultProperties, + chosenProperties: [], chosenCategory: PoscanCategories.first, ), ); @@ -80,7 +84,7 @@ class PoscanPutObjectCubit extends Cubit { } void toggleProp(final PoscanProperty prop) { - if (state.properties.contains(prop)) { + if (state.chosenProperties.contains(prop)) { removeProp(prop); } else { addProp(prop); @@ -88,17 +92,34 @@ class PoscanPutObjectCubit extends Cubit { } void addProp(final PoscanProperty prop) { - final newList = List.from(state.properties); + final newList = List.from(state.chosenProperties); newList.add(prop); - emit(state.copyWith(properties: newList)); + emit(state.copyWith(chosenProperties: newList)); } void removeProp(final PoscanProperty prop) { - final newList = List.from(state.properties); + final newList = List.from(state.chosenProperties); newList.remove(prop); - emit(state.copyWith(properties: newList)); + emit(state.copyWith(chosenProperties: newList)); + } + + void editProp(final PoscanProperty prop) { + final newList = List.from(state.defaultProperties); + final chosenList = List.from(state.chosenProperties); + final index = + newList.indexWhere((final existingProp) => existingProp == prop); + newList[index] = prop; + + if (state.chosenProperties.contains(prop)) { + final index = + chosenList.indexWhere((final existingProp) => existingProp == prop); + chosenList[index] = prop; + } + + emit(state.copyWith( + defaultProperties: newList, chosenProperties: chosenList,),); } void changeCategory(final MapPoscanCategory cat) { @@ -122,7 +143,7 @@ class PoscanPutObjectCubit extends Cubit { pathToFile: filePath, categoryFabric: state.chosenCategory, hashes: state.chosenHashes, - propValues: state.properties.map((final e) => e.propValue).toList(), + propValues: state.chosenProperties.map((final e) => e.propValue).toList(), updateStatus: () { fastCheckPassed = true; DefaultLoadingDialog.hide(context); diff --git a/lib/features/poscan_putobject/bloc/poscan_putobject_cubit.g.dart b/lib/features/poscan_putobject/bloc/poscan_putobject_cubit.g.dart index e1f21977..08c754cb 100644 --- a/lib/features/poscan_putobject/bloc/poscan_putobject_cubit.g.dart +++ b/lib/features/poscan_putobject/bloc/poscan_putobject_cubit.g.dart @@ -1,5 +1,3 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - part of 'poscan_putobject_cubit.dart'; // ************************************************************************** @@ -11,7 +9,10 @@ abstract class _$D3PRPCCubitStateCWProxy { D3PRPCCubitState chosenHashes(List chosenHashes); - D3PRPCCubitState properties(List properties); + D3PRPCCubitState chosenProperties(List chosenProperties); + + D3PRPCCubitState defaultProperties( + List defaultProperties); D3PRPCCubitState chosenCategory(MapPoscanCategory chosenCategory); @@ -24,12 +25,12 @@ abstract class _$D3PRPCCubitStateCWProxy { D3PRPCCubitState call({ KeyPairData? account, List? chosenHashes, - List? properties, + List? chosenProperties, + List? defaultProperties, MapPoscanCategory? chosenCategory, }); } -/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfD3PRPCCubitState.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfD3PRPCCubitState.copyWith.fieldName(...)` class _$D3PRPCCubitStateCWProxyImpl implements _$D3PRPCCubitStateCWProxy { const _$D3PRPCCubitStateCWProxyImpl(this._value); @@ -43,46 +44,46 @@ class _$D3PRPCCubitStateCWProxyImpl implements _$D3PRPCCubitStateCWProxy { this(chosenHashes: chosenHashes); @override - D3PRPCCubitState properties(List properties) => - this(properties: properties); + D3PRPCCubitState chosenProperties(List chosenProperties) => + this(chosenProperties: chosenProperties); + + @override + D3PRPCCubitState defaultProperties(List defaultProperties) => + this(defaultProperties: defaultProperties); @override D3PRPCCubitState chosenCategory(MapPoscanCategory chosenCategory) => this(chosenCategory: chosenCategory); @override - - /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `D3PRPCCubitState(...).copyWith.fieldName(...)` to override fields one at a time with nullification support. - /// - /// Usage - /// ```dart - /// D3PRPCCubitState(...).copyWith(id: 12, name: "My name") - /// ```` D3PRPCCubitState call({ Object? account = const $CopyWithPlaceholder(), Object? chosenHashes = const $CopyWithPlaceholder(), - Object? properties = const $CopyWithPlaceholder(), + Object? chosenProperties = const $CopyWithPlaceholder(), + Object? defaultProperties = + const $CopyWithPlaceholder(), Object? chosenCategory = const $CopyWithPlaceholder(), }) { return D3PRPCCubitState( account: account == const $CopyWithPlaceholder() || account == null ? _value.account - // ignore: cast_nullable_to_non_nullable : account as KeyPairData, chosenHashes: - chosenHashes == const $CopyWithPlaceholder() || chosenHashes == null - ? _value.chosenHashes - // ignore: cast_nullable_to_non_nullable - : chosenHashes as List, - properties: - properties == const $CopyWithPlaceholder() || properties == null - ? _value.properties - // ignore: cast_nullable_to_non_nullable - : properties as List, + chosenHashes == const $CopyWithPlaceholder() || chosenHashes == null + ? _value.chosenHashes + : chosenHashes as List, + chosenProperties: + chosenProperties == const $CopyWithPlaceholder() || chosenProperties == null + ? _value.chosenProperties + : chosenProperties as List, + defaultProperties: + defaultProperties == const $CopyWithPlaceholder() || + defaultProperties == null + ? _value.defaultProperties + : defaultProperties as List, chosenCategory: chosenCategory == const $CopyWithPlaceholder() || - chosenCategory == null + chosenCategory == null ? _value.chosenCategory - // ignore: cast_nullable_to_non_nullable : chosenCategory as MapPoscanCategory, ); } @@ -92,4 +93,4 @@ extension $D3PRPCCubitStateCopyWith on D3PRPCCubitState { /// Returns a callable class that can be used as follows: `instanceOfD3PRPCCubitState.copyWith(...)` or like so:`instanceOfD3PRPCCubitState.copyWith.fieldName(...)`. // ignore: library_private_types_in_public_api _$D3PRPCCubitStateCWProxy get copyWith => _$D3PRPCCubitStateCWProxyImpl(this); -} +} \ No newline at end of file diff --git a/lib/features/poscan_putobject/data/default_poscan_properties.dart b/lib/features/poscan_putobject/data/default_poscan_properties.dart new file mode 100644 index 00000000..cb714757 --- /dev/null +++ b/lib/features/poscan_putobject/data/default_poscan_properties.dart @@ -0,0 +1,13 @@ +import 'package:polkawallet_sdk/p3d/prop_value.dart'; +import 'package:threedpass/features/poscan_putobject/domain/entities/poscan_property.dart'; + +final List defaultProperties = [ + PoscanProperty( + name: 'Non-fungible', + propValue: PropValue(maxValue: BigInt.one, propIdx: 0), + ), + PoscanProperty( + name: 'Share', + propValue: PropValue(maxValue: BigInt.from(100000000), propIdx: 1), + ), +]; diff --git a/lib/features/poscan_putobject/domain/entities/poscan_property.dart b/lib/features/poscan_putobject/domain/entities/poscan_property.dart index 3001b3d1..31a04ffa 100644 --- a/lib/features/poscan_putobject/domain/entities/poscan_property.dart +++ b/lib/features/poscan_putobject/domain/entities/poscan_property.dart @@ -8,4 +8,24 @@ class PoscanProperty { required this.name, required this.propValue, }); + + @override + bool operator ==(final Object other) { + if (other is! PoscanProperty) return false; + return other.propValue.propIdx == this.propValue.propIdx; + } + + @override + int get hashCode => propValue.propIdx.hashCode; + + PoscanProperty copyWith({final BigInt? maxValue}) { + final newPropValue = maxValue != null + ? PropValue(maxValue: maxValue, propIdx: this.propValue.propIdx) + : this.propValue; + + return PoscanProperty( + name: this.name, + propValue: newPropValue, + ); + } } diff --git a/lib/features/poscan_putobject/presentation/widgets/choose_properties.dart b/lib/features/poscan_putobject/presentation/widgets/choose_properties.dart index 882f6c76..2512dff9 100644 --- a/lib/features/poscan_putobject/presentation/widgets/choose_properties.dart +++ b/lib/features/poscan_putobject/presentation/widgets/choose_properties.dart @@ -1,64 +1,72 @@ -import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:polkawallet_sdk/p3d/prop_value.dart'; -import 'package:threedpass/core/theme/d3p_special_styles.dart'; -import 'package:threedpass/core/widgets/buttons/enum_button.dart'; +import 'package:threedpass/core/theme/d3p_special_colors.dart'; +import 'package:threedpass/core/widgets/buttons/elevated_button.dart'; +import 'package:threedpass/core/widgets/paddings.dart'; +import 'package:threedpass/core/widgets/text/d3p_body_medium_text.dart'; import 'package:threedpass/features/poscan_putobject/bloc/poscan_putobject_cubit.dart'; import 'package:threedpass/features/poscan_putobject/domain/entities/poscan_property.dart'; -import 'package:threedpass/features/poscan_putobject/presentation/widgets/open_bottom_sheet.dart'; -import 'package:threedpass/features/poscan_putobject/presentation/widgets/property_tile_text.dart'; +import 'package:threedpass/features/poscan_putobject/presentation/widgets/edit_property_dialog.dart'; +import 'package:threedpass/features/poscan_putobject/presentation/widgets/property_tile_content.dart'; class ChooseProperties extends StatelessWidget { const ChooseProperties({super.key}); @override Widget build(final BuildContext context) { - final textStyle = Theme.of(context).customTextStyles; + final colors = Theme.of(context).customColors; + return BlocBuilder( + builder: (final context, final state) { + return Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBoxH16(), + const D3pBodyMediumText("Properties"), + const SizedBoxH4(), + state.defaultProperties.isEmpty + ? const SizedBoxH16() + : ListView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemCount: state.defaultProperties.length, + itemBuilder: (final context, final index) { + final prop = state.defaultProperties.elementAt(index); + return D3pElevatedButton( + padding: const EdgeInsets.only(top: 2), + onPressed: () => + BlocProvider.of(context) + .toggleProp(prop), + backgroundColor: colors.cardBackground, + elevation: 1, + childAlignment: MainAxisAlignment.start, + text: null, + child: PropertyTileContent( + prop: prop, + isChosen: state.chosenProperties.contains(prop), + onPressedEditCallback: onPressedEditCallback, + ), + ); + }, + ), + ], + ); + }, + ); + } - // Non-fungible - 0, Share - 1 - final List properties = [ - PoscanProperty( - name: 'Non-fungible', - propValue: PropValue(maxValue: BigInt.one, propIdx: 0), - ), - PoscanProperty( - name: 'Share', - propValue: PropValue(maxValue: BigInt.from(100000000), propIdx: 1), - ), - ]; - return OpenBottomSheet( - unlocalizedSubtitle: 'poscan_putobject_choose_properties', - bottomSheetPlatform: BlocBuilder( - builder: (final context, final state) => ListView.builder( - shrinkWrap: true, - itemCount: properties.length, - itemBuilder: (final context, final index) { - final prop = properties.elementAt(index); - return EnumButton( - text: null, - isChosen: state.properties.contains(prop), - onPressed: () => BlocProvider.of(context) - .toggleProp(prop), - child: PropertyTileText( - prop: prop, - isChosen: state.properties.contains(prop), - ), - ); - }, - ), - ), - buttonIconData: Icons.add, - buttonTextChild: BlocBuilder( - buildWhen: (final previous, final current) => - previous.properties != current.properties, - builder: (final context, final state) => Text( - 'PROPERTIES_number_plural'.plural( - state.properties.length, - ), - style: textStyle.d3pBodyMedium, - ), - ), + void onPressedEditCallback( + final BuildContext parentContext, + final PoscanProperty prop, + ) { + showDialog( + context: parentContext, + builder: (final BuildContext context) { + return BlocProvider.value( + value: BlocProvider.of(parentContext), + child: EditPropertyDialog(prop: prop), + ); + }, ); } } diff --git a/lib/features/poscan_putobject/presentation/widgets/edit_property_button.dart b/lib/features/poscan_putobject/presentation/widgets/edit_property_button.dart new file mode 100644 index 00000000..9bd19449 --- /dev/null +++ b/lib/features/poscan_putobject/presentation/widgets/edit_property_button.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; +import 'package:threedpass/core/theme/d3p_colors.dart'; +import 'package:threedpass/features/poscan_putobject/domain/entities/poscan_property.dart'; + +class EditPropertyButton extends StatelessWidget { + final PoscanProperty prop; + final void Function(BuildContext, PoscanProperty) onPressedEditCallback; + + const EditPropertyButton({ + required this.prop, + required this.onPressedEditCallback, + super.key, + }); + + @override + Widget build(final BuildContext context) { + if (prop.propValue.propIdx != 0) { + return IconButton( + icon: const Icon( + Icons.edit, + size: 18, + color: D3pColors.disabled, + ), + onPressed: () => onPressedEditCallback(context, prop), + ); + } else { + return Container(); + } + } +} diff --git a/lib/features/poscan_putobject/presentation/widgets/edit_property_dialog.dart b/lib/features/poscan_putobject/presentation/widgets/edit_property_dialog.dart new file mode 100644 index 00000000..cac01ebe --- /dev/null +++ b/lib/features/poscan_putobject/presentation/widgets/edit_property_dialog.dart @@ -0,0 +1,64 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:threedpass/core/widgets/buttons/text_button.dart'; +import 'package:threedpass/core/widgets/dialog/d3p_platform_dialog.dart'; +import 'package:threedpass/features/poscan_putobject/bloc/poscan_putobject_cubit.dart'; +import 'package:threedpass/features/poscan_putobject/domain/entities/poscan_property.dart'; +import 'package:threedpass/features/poscan_putobject/presentation/widgets/property_max_value.dart'; +import 'package:threedpass/features/poscan_putobject/utils/multiple_of_ten_property_validator.dart'; + +class EditPropertyDialog extends StatelessWidget { + final TextEditingController _maxValueController = TextEditingController(); + final GlobalKey _formKey = GlobalKey(); + final PoscanProperty prop; + + EditPropertyDialog({required this.prop, final Key? key}) : super(key: key); + + @override + Widget build(final BuildContext context) { + _maxValueController.text = prop.propValue.maxValue.toString(); + return D3pPlatformDialog( + title: 'edit_action' + .tr(args: [prop.name, prop.propValue.propIdx.toString()]), + content: SingleChildScrollView( + child: ListBody( + children: [ + // Spacing between text fields + Form( + key: _formKey, + child: Container( + height: 70, + child: PropertyMaxValueInputField( + controller: _maxValueController, + validationStrategy: MultipleOfTenPropertyValidator(), + ), + ), + ), + ], + ), + ), + actions: [ + D3pTextButton( + onPressed: () => Navigator.of(context).pop(), + text: 'Cancel'.tr(), + ), + D3pTextButton( + onPressed: () => _editProperty(context), + text: 'edit_action_submit'.tr(), + ), + ], + ); + } + + void _editProperty(final BuildContext context) { + if (!_formKey.currentState!.validate()) { + return; + } + final BigInt maxValue = + BigInt.tryParse(_maxValueController.text) ?? BigInt.zero; + BlocProvider.of(context) + .editProp(prop.copyWith(maxValue: maxValue)); + Navigator.of(context).pop(); + } +} diff --git a/lib/features/poscan_putobject/presentation/widgets/property_max_value.dart b/lib/features/poscan_putobject/presentation/widgets/property_max_value.dart new file mode 100644 index 00000000..c118d540 --- /dev/null +++ b/lib/features/poscan_putobject/presentation/widgets/property_max_value.dart @@ -0,0 +1,41 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:mask_text_input_formatter/mask_text_input_formatter.dart'; +import 'package:threedpass/core/widgets/input/textformfield/textformfield.dart'; +import 'package:threedpass/features/poscan_putobject/utils/max_value_validation_strategy.dart'; + +class PropertyMaxValueInputField extends StatelessWidget { + static final numericInputFormatter = NumericInputFormatter(); + final TextEditingController controller; + final MaxValueValidationStrategy validationStrategy; + + const PropertyMaxValueInputField({ + required this.controller, + required this.validationStrategy, + final Key? key, + }) : super(key: key); + + @override + Widget build(final BuildContext context) { + return SizedBox( + width: 100, + child: D3pTextFormField( + labelText: 'max_value'.tr(), + hintText: 'max_value'.tr(), + keyboardType: const TextInputType.numberWithOptions(decimal: true), + controller: controller, + validator: (final input) => validationStrategy.isValid(input ?? ''), + inputFormatters: [numericInputFormatter], + ), + ); + } +} + +class NumericInputFormatter extends MaskTextInputFormatter { + NumericInputFormatter() + : super( + mask: '', + filter: {"#": RegExp(r'[0-9]')}, + type: MaskAutoCompletionType.lazy, + ); +} diff --git a/lib/features/poscan_putobject/presentation/widgets/property_tile_text.dart b/lib/features/poscan_putobject/presentation/widgets/property_tile_content.dart similarity index 79% rename from lib/features/poscan_putobject/presentation/widgets/property_tile_text.dart rename to lib/features/poscan_putobject/presentation/widgets/property_tile_content.dart index 24ab4521..b47de8cd 100644 --- a/lib/features/poscan_putobject/presentation/widgets/property_tile_text.dart +++ b/lib/features/poscan_putobject/presentation/widgets/property_tile_content.dart @@ -6,17 +6,20 @@ import 'package:threedpass/core/theme/d3p_special_colors.dart'; import 'package:threedpass/core/theme/d3p_special_styles.dart'; import 'package:threedpass/core/theme/d3p_theme.dart'; import 'package:threedpass/features/poscan_putobject/domain/entities/poscan_property.dart'; +import 'package:threedpass/features/poscan_putobject/presentation/widgets/edit_property_button.dart'; -class PropertyTileText extends StatelessWidget { - const PropertyTileText({ +class PropertyTileContent extends StatelessWidget { + final PoscanProperty prop; + final bool isChosen; + final void Function(BuildContext, PoscanProperty) onPressedEditCallback; + + const PropertyTileContent({ required this.prop, required this.isChosen, + required this.onPressedEditCallback, super.key, }); - final PoscanProperty prop; - final bool isChosen; - TextSpan formattedMaxValue( final BigInt maxValue, final TextStyle enabledStyle, @@ -71,18 +74,27 @@ class PropertyTileText extends StatelessWidget { ); final disabledStyle = textStyles.d3pBodyMedium.copyWith(color: D3pColors.disabled); + return Row( mainAxisSize: MainAxisSize.max, children: [ Expanded( - flex: 4, + flex: 1, + child: Checkbox( + value: isChosen, + fillColor: MaterialStatePropertyAll(D3pThemeData.mainColor), + onChanged: null, + ), + ), + Expanded( + flex: 3, child: Text( prop.name, style: enabledStyle, ), ), Expanded( - flex: 1, + flex: 2, child: Text.rich( TextSpan( text: ' id: ', @@ -100,7 +112,7 @@ class PropertyTileText extends StatelessWidget { flex: 4, child: Text.rich( TextSpan( - text: ' max_value: ', + text: ' max value: ', style: disabledStyle, children: [ formattedMaxValue(prop.propValue.maxValue, enabledStyle), @@ -108,8 +120,14 @@ class PropertyTileText extends StatelessWidget { ), ), ), + Expanded( + flex: 1, + child: EditPropertyButton( + prop: prop, + onPressedEditCallback: onPressedEditCallback, + ), + ), ], ); - // return '${fixedName()}${shortAddress()}'; } } diff --git a/lib/features/poscan_putobject/utils/max_value_validation_strategy.dart b/lib/features/poscan_putobject/utils/max_value_validation_strategy.dart new file mode 100644 index 00000000..70787862 --- /dev/null +++ b/lib/features/poscan_putobject/utils/max_value_validation_strategy.dart @@ -0,0 +1,3 @@ +abstract class MaxValueValidationStrategy { + String? isValid(final String input); +} diff --git a/lib/features/poscan_putobject/utils/multiple_of_ten_property_validator.dart b/lib/features/poscan_putobject/utils/multiple_of_ten_property_validator.dart new file mode 100644 index 00000000..556977a2 --- /dev/null +++ b/lib/features/poscan_putobject/utils/multiple_of_ten_property_validator.dart @@ -0,0 +1,22 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:threedpass/features/poscan_putobject/utils/max_value_validation_strategy.dart'; + +class MultipleOfTenPropertyValidator implements MaxValueValidationStrategy { + @override + String? isValid(final String input) { + if (input.isEmpty) { + return 'textfield_not_empty'.tr(); + } + final number = int.tryParse(input); + if (number != null) { + if (number % 10 != 0) { + return 'max_value_multiplier'.tr(); + } else if (number > 100000000) { + return 'input_exceeds_limit'.tr(); + } + return null; + } else { + return 'input_not_a_number'.tr(); + } + } +} diff --git a/lib/features/preview_page/presentation/widgets/appbar/preview_appbar.dart b/lib/features/preview_page/presentation/widgets/appbar/preview_appbar.dart index cbce9cbd..89572472 100644 --- a/lib/features/preview_page/presentation/widgets/appbar/preview_appbar.dart +++ b/lib/features/preview_page/presentation/widgets/appbar/preview_appbar.dart @@ -85,17 +85,17 @@ class _PreviewAppbarTitle extends StatelessWidget { } } -class _PseudoButtonSavedIndicator extends StatelessWidget { - final PreviewSnapshotType psType; +// class _PseudoButtonSavedIndicator extends StatelessWidget { +// final PreviewSnapshotType psType; - const _PseudoButtonSavedIndicator(this.psType); +// const _PseudoButtonSavedIndicator(this.psType); - @override - Widget build(final BuildContext context) { - return D3pIconButton( - iconData: psType == PreviewSnapshotType.existingSnapshot - ? UniconsLine.file_check - : UniconsLine.file_exclamation, - ); - } -} +// @override +// Widget build(final BuildContext context) { +// return D3pIconButton( +// iconData: psType == PreviewSnapshotType.existingSnapshot +// ? UniconsLine.file_check +// : UniconsLine.file_exclamation, +// ); +// } +// } diff --git a/lib/features/preview_page/presentation/widgets/copy_text_card.dart b/lib/features/preview_page/presentation/widgets/copy_text_card.dart index 3a0c96ba..84c23f86 100644 --- a/lib/features/preview_page/presentation/widgets/copy_text_card.dart +++ b/lib/features/preview_page/presentation/widgets/copy_text_card.dart @@ -18,7 +18,7 @@ class CopyTextCard extends StatelessWidget { Widget build(final BuildContext context) { return ClickableCard( // side: BorderSide(color: Colors.grey), - radius: Radius.circular(16), + radius: const Radius.circular(16), onTap: () => copyAndNotify( textToCopy: textToCopy, textToShow: textToShow, diff --git a/lib/features/preview_page/presentation/widgets/dialogs/common_dialog.dart b/lib/features/preview_page/presentation/widgets/dialogs/common_dialog.dart index a9346d77..e652d4c2 100644 --- a/lib/features/preview_page/presentation/widgets/dialogs/common_dialog.dart +++ b/lib/features/preview_page/presentation/widgets/dialogs/common_dialog.dart @@ -30,18 +30,21 @@ class CommonDialog extends StatelessWidget { Widget build(final BuildContext context) { return D3pPlatformDialog( title: title, - content: SingleChildScrollView( - child: Column( - children: [ - D3pTextFormField( - // decoration: const InputDecoration( - // isCollapsed: false, - // ), - controller: controller, - ), - ], - ), + content: D3pTextFormField( + controller: controller, ), + // SingleChildScrollView( + // child: Column( + // children: [ + // D3pTextFormField( + // // decoration: const InputDecoration( + // // isCollapsed: false, + // // ), + // controller: controller, + // ), + // ], + // ), + // ), actions: [ D3pTextButton( text: 'Cancel'.tr(), diff --git a/lib/features/preview_page/presentation/widgets/poscan_result.dart b/lib/features/preview_page/presentation/widgets/poscan_result.dart index e595e39e..38a1bf68 100644 --- a/lib/features/preview_page/presentation/widgets/poscan_result.dart +++ b/lib/features/preview_page/presentation/widgets/poscan_result.dart @@ -6,8 +6,10 @@ import 'package:threedpass/core/polkawallet/app_service.dart'; import 'package:threedpass/core/polkawallet/bloc/app_service_cubit.dart'; import 'package:threedpass/core/widgets/buttons/elevated_button.dart'; import 'package:threedpass/core/widgets/other/padding_16.dart'; +import 'package:threedpass/core/widgets/text/d3p_body_medium_text.dart'; import 'package:threedpass/features/poscan_objects_query/bloc/poscan_objects_cubit.dart'; import 'package:threedpass/features/preview_page/bloc/preview_page_cubit.dart'; +import 'package:threedpass/features/settings_page/domain/entities/scan_settings.dart'; import 'package:threedpass/features/wallet_screen/assets_page/widgets/objects_list/objects_list_item.dart'; import 'package:threedpass/router/router.gr.dart'; @@ -19,6 +21,9 @@ class PoscanResult extends StatelessWidget { final snap = BlocProvider.of(context).state.snapshot; final loadedObject = BlocProvider.of(context) .findObjectByHashes(snap.hashes); + + final isSnapNoneTransBytes = + snap.settingsConfig.transBytesMode == TransBytesMode.none; return Column( children: [ const SizedBox(height: 2), @@ -30,19 +35,46 @@ class PoscanResult extends StatelessWidget { ), ), BlocBuilder( - builder: (final context, final state) => Padding16( - child: D3pElevatedButton( - iconData: Icons.upload, - text: '3d_rpc_button_label'.tr(), - onPressed: state.status == AppServiceInitStatus.connected && - (loadedObject == null || - loadedObject.status.toLowerCase() != 'approved') - ? () => context.router.push(const D3PRPCRouteWrapper()) - : null, - ), - ), + builder: (final context, final state) { + final isNodeConnected = + state.status == AppServiceInitStatus.connected; + final isObjectAlreadyApproved = loadedObject != null && + loadedObject.status.toLowerCase() == 'approved'; + + final allConditions = isNodeConnected && + !isObjectAlreadyApproved && + isSnapNoneTransBytes; + return Padding16( + child: D3pElevatedButton( + iconData: Icons.upload, + text: '3d_rpc_button_label'.tr(), + onPressed: allConditions + ? () => context.router.push(const D3PRPCRouteWrapper()) + : null, + ), + ); + }, ), + _PutObjectHelp(isSnapNoneTransBytes), ], ); } } + +class _PutObjectHelp extends StatelessWidget { + final bool isSnapNoneTransBytes; + + const _PutObjectHelp(this.isSnapNoneTransBytes); + + @override + Widget build(final BuildContext context) { + if (isSnapNoneTransBytes) { + return const SizedBox(); + } else { + return const Padding( + padding: EdgeInsets.only(top: 2), + child: D3pBodyMediumText('trans_bytes_mode_help'), + ); + } + } +} diff --git a/lib/features/preview_page/presentation/widgets/preview_page_body.dart b/lib/features/preview_page/presentation/widgets/preview_page_body.dart index e49e5dd3..3631292c 100644 --- a/lib/features/preview_page/presentation/widgets/preview_page_body.dart +++ b/lib/features/preview_page/presentation/widgets/preview_page_body.dart @@ -9,7 +9,9 @@ import 'package:threedpass/features/preview_page/presentation/widgets/hash_prope import 'package:threedpass/features/preview_page/presentation/widgets/object_preview/object_preview.dart'; import 'package:threedpass/features/preview_page/presentation/widgets/poscan_result.dart'; import 'package:threedpass/features/preview_page/presentation/widgets/preview_save_button.dart'; +import 'package:threedpass/features/preview_page/presentation/widgets/rename_object_button.dart'; import 'package:threedpass/features/preview_page/presentation/widgets/rename_snapshot_button.dart'; +import 'package:threedpass/features/preview_page/presentation/widgets/scan_one_more_time_button.dart'; import 'package:threedpass/features/preview_page/presentation/widgets/section_title.dart'; import 'package:threedpass/features/preview_page/presentation/widgets/snapshot_info.dart'; import 'package:threedpass/features/preview_page/presentation/widgets/stable_hashes_section.dart'; @@ -62,6 +64,10 @@ class PreviewPageBody extends StatelessWidget { RenameSnapshotButton(state: previewPageCubitState), DeleteSnapshotButton(state: previewPageCubitState), const SizedBoxH16(), + const Divider(), + const RenameObjectButton(), + // const ScanOneMoreTimeButton(), + const SizedBoxH16(), ], ); } diff --git a/lib/features/preview_page/presentation/widgets/rename_object_button.dart b/lib/features/preview_page/presentation/widgets/rename_object_button.dart new file mode 100644 index 00000000..5574db67 --- /dev/null +++ b/lib/features/preview_page/presentation/widgets/rename_object_button.dart @@ -0,0 +1,33 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:threedpass/core/theme/d3p_special_colors.dart'; +import 'package:threedpass/core/widgets/d3p_card.dart'; +import 'package:threedpass/features/preview_page/bloc/preview_page_cubit.dart'; +import 'package:threedpass/features/settings_page/presentation/widgets/default_settings_button.dart'; +import 'package:threedpass/router/router.gr.dart'; + +class RenameObjectButton extends StatelessWidget { + const RenameObjectButton({super.key}); + + @override + Widget build(final BuildContext context) { + final state = BlocProvider.of(context).state; + final colors = Theme.of(context).customColors; + return DefaultSettingsButton.openButton( + iconData: Icons.abc_rounded, + iconColor: colors.themeOpposite, + textValue: '', + onPressed: () => context.router.push( + RenameObjectRoute( + snapshot: state.snapshot, + hashObject: state.hashObject!, + ), + ), + text: 'rename_object_button_label', + cardShape: CardShape.top, + isChevronGrey: false, + ); + // throw Exception(''); + } +} diff --git a/lib/features/preview_page/presentation/widgets/rename_object_dialog.dart b/lib/features/preview_page/presentation/widgets/rename_object_dialog.dart new file mode 100644 index 00000000..ee020281 --- /dev/null +++ b/lib/features/preview_page/presentation/widgets/rename_object_dialog.dart @@ -0,0 +1,63 @@ +import 'dart:async'; + +import 'package:auto_route/auto_route.dart'; +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:threedpass/features/hashes_list/bloc/hashes_list_bloc.dart'; +import 'package:threedpass/features/hashes_list/domain/entities/hash_object.dart'; +import 'package:threedpass/features/hashes_list/domain/entities/snapshot.dart'; +import 'package:threedpass/features/preview_page/bloc/outer_context_cubit.dart'; +import 'package:threedpass/features/preview_page/presentation/widgets/dialogs/common_dialog.dart'; +import 'package:threedpass/router/router.gr.dart'; + +@RoutePage() +class RenameObjectDialog extends StatelessWidget { + const RenameObjectDialog({ + required this.snapshot, + required this.hashObject, + final Key? key, + }) : super(key: key); + + final HashObject hashObject; + final Snapshot snapshot; + + Future renameObject( + final String newName, + final BuildContext context, + ) async { + final newObj = hashObject.copyWith(name: newName); + + BlocProvider.of(context).add( + ReplaceObject( + oldObj: hashObject, + newObj: newObj, + ), + ); + + final outerContext = BlocProvider.of(context).state; + // TODO When rename object do bloc_builder instead of re-push + await outerContext.router.pop(); + + unawaited( + outerContext.router.push( + PreviewRouteWrapper( + hashObject: newObj, + snapshot: snapshot, + ), + ), + ); + } + + @override + Widget build(final BuildContext context) { + return CommonDialog( + snapshot: snapshot, + hashObject: hashObject, + initialText: hashObject.name, + title: 'rename_object_dialog_title'.tr(), + actionText: 'rename_object_dialog_action'.tr(), + action: (final value) => renameObject(value, context), + ); + } +} diff --git a/lib/features/preview_page/presentation/widgets/scan_one_more_time_button.dart b/lib/features/preview_page/presentation/widgets/scan_one_more_time_button.dart new file mode 100644 index 00000000..9e09622e --- /dev/null +++ b/lib/features/preview_page/presentation/widgets/scan_one_more_time_button.dart @@ -0,0 +1,15 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:threedpass/core/widgets/buttons/elevated_button.dart'; + +class ScanOneMoreTimeButton extends StatelessWidget { + const ScanOneMoreTimeButton({super.key}); + + @override + Widget build(BuildContext context) { + return D3pElevatedButton( + text: 'scan_one_more_time_button_label'.tr(), + onPressed: () {}, + ); + } +} diff --git a/lib/features/preview_page/router/preview_page_route.dart b/lib/features/preview_page/router/preview_page_route.dart index 65c34ec7..1293c542 100644 --- a/lib/features/preview_page/router/preview_page_route.dart +++ b/lib/features/preview_page/router/preview_page_route.dart @@ -28,6 +28,10 @@ AutoRoute previewPageRoute = AutoRoute( page: DeleteSnapshotRoute.page, customRouteBuilder: dialogBuilder, ), + CustomRoute( + page: RenameObjectRoute.page, + customRouteBuilder: dialogBuilder, + ), AutoRoute( page: D3PRPCRouteWrapper.page, children: [ diff --git a/lib/features/scan_page/bloc/snapshots_has_new_extension.dart b/lib/features/scan_page/bloc/snapshots_has_new_extension.dart index 2cce9b7d..af6c0a6a 100644 --- a/lib/features/scan_page/bloc/snapshots_has_new_extension.dart +++ b/lib/features/scan_page/bloc/snapshots_has_new_extension.dart @@ -12,4 +12,19 @@ extension HasNew on HashesListLoaded { element.snapshots.any((final element) => element.isNew)) .snapshots .firstWhere((final element) => element.isNew); + + List get allSnaps { + final res = []; + objects.forEach((final element) { + res.addAll(element.snapshots); + }); + return res; + } + + Snapshot get latest { + final all = allSnaps; + final times = allSnaps.map((final e) => e.stamp).toList(); + times.sort(); + return all.firstWhere((final element) => element.stamp == times.last); + } } diff --git a/lib/features/scan_page/presentation/pages/scan_page.dart b/lib/features/scan_page/presentation/scan_page.dart similarity index 100% rename from lib/features/scan_page/presentation/pages/scan_page.dart rename to lib/features/scan_page/presentation/scan_page.dart diff --git a/lib/features/scan_page/presentation/pages/scan_page_wrapper.dart b/lib/features/scan_page/presentation/scan_page_wrapper.dart similarity index 100% rename from lib/features/scan_page/presentation/pages/scan_page_wrapper.dart rename to lib/features/scan_page/presentation/scan_page_wrapper.dart diff --git a/lib/features/scan_page/presentation/widgets/floating_action_button/get_object_from_file_button.dart b/lib/features/scan_page/presentation/widgets/floating_action_button/get_object_from_file_button.dart index 4a87bbde..6ea1bcd0 100644 --- a/lib/features/scan_page/presentation/widgets/floating_action_button/get_object_from_file_button.dart +++ b/lib/features/scan_page/presentation/widgets/floating_action_button/get_object_from_file_button.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:logger/logger.dart'; +import 'package:threedpass/core/theme/d3p_theme.dart'; import 'package:threedpass/features/hashes_list/bloc/hashes_list_bloc.dart'; import 'package:threedpass/features/hashes_list/domain/entities/hash_object.dart'; import 'package:threedpass/features/hashes_list/domain/entities/objects_directory.dart'; @@ -82,28 +83,18 @@ class GetObjectFromFileFloatingButton extends StatelessWidget { ], ); hashesListBloc.add(AddObject(object: newObj)); + unawaited(Fluttertoast.showToast( + msg: 'Unique object found', + backgroundColor: D3pThemeData.mainColor, + )); } else { // Add snapshot hashesListBloc.add(SaveSnapshot(hash: pair.right, object: pair.left!)); + unawaited(Fluttertoast.showToast( + msg: 'Object recognized', + backgroundColor: D3pThemeData.mainColor, + )); } - - // BlocProvider.of(context).add( - // AddObject(HashObject.fromSnapshot(pair.right)), - // // SaveSnapshot( - // // object: pair.left, - // // hash: pair.right, - // // ), - // ); - - // unawaited( - // context.router.push( - // PreviewRouteWrapper( - // hashObject: pair.left, - // snapshot: pair.right, - // createNewAnyway: true, - // ), - // ), - // ); } on FilePickerException catch (e) { showToast(e.message, context); getIt().e('Caught FilePickerException: $e'); diff --git a/lib/features/scan_page/presentation/widgets/object_list/hash_card.dart b/lib/features/scan_page/presentation/widgets/object_list/hash_card.dart index 36659669..fbdb1cc0 100644 --- a/lib/features/scan_page/presentation/widgets/object_list/hash_card.dart +++ b/lib/features/scan_page/presentation/widgets/object_list/hash_card.dart @@ -11,7 +11,6 @@ import 'package:threedpass/core/widgets/text/d3p_body_medium_text.dart'; import 'package:threedpass/features/hashes_list/bloc/hashes_list_bloc.dart'; import 'package:threedpass/features/hashes_list/domain/entities/hash_object.dart'; import 'package:threedpass/features/hashes_list/domain/entities/snapshot.dart'; -import 'package:threedpass/features/scan_page/bloc/select_snapshots_cubit.dart'; import 'package:threedpass/features/settings_page/presentation/widgets/settings_text.dart'; import 'package:threedpass/router/router.gr.dart'; @@ -20,12 +19,18 @@ class SnapshotCard extends StatelessWidget { required this.snapshot, required this.hashObject, this.onTap, + this.areSelectable = false, + this.isSelected = false, + this.setGlobalKey = false, final Key? key, }) : super(key: key); final Snapshot snapshot; final HashObject hashObject; final void Function()? onTap; + final bool areSelectable; + final bool isSelected; + final bool setGlobalKey; @override Widget build(final BuildContext context) { @@ -33,79 +38,72 @@ class SnapshotCard extends StatelessWidget { final hashesListBloc = BlocProvider.of(context); final hashesListState = hashesListBloc.state as HashesListLoaded; - return BlocBuilder( - buildWhen: (final previous, final current) => - previous.areSelectable != current.areSelectable || - previous.snaps.contains(snapshot) != current.snaps.contains(snapshot), - builder: (final _, final state) => ClickableCard( - key: hashesListState.globalKeyMap[snapshot], - onTap: state.areSelectable - ? () => - BlocProvider.of(context).toggle(snapshot) - : () async { - await context.router.push( - PreviewRouteWrapper( - hashObject: hashObject, - snapshot: snapshot, - ), - ); - if (snapshot.isNew) { - hashesListBloc.add( - UnmarkNewSnap( - object: hashObject, - snap: snapshot, - ), - ); - } - }, - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( + return ClickableCard( + key: setGlobalKey ? hashesListState.globalKeyMap[snapshot] : null, + onTap: onTap ?? + () async { + await context.router.push( + PreviewRouteWrapper( + hashObject: hashObject, + snapshot: snapshot, + ), + ); + if (snapshot.isNew) { + hashesListBloc.add( + UnmarkNewSnap( + object: hashObject, + snap: snapshot, + ), + ); + } + }, + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Flexible( + child: Text( + snapshot.name, + style: theme.d3pBodyLarge, + ), + ), + if (snapshot.isNew) + Icon( + Icons.fiber_new_outlined, + color: D3pThemeData.mainColor, + ), + ], + ), + const SizedBoxH8(), + Text.rich( + snapshot.settingsConfig.toShort(context), + ), + const SizedBoxH8(), + SizedBox( + height: 24, + child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Flexible( - child: Text( - snapshot.name, - style: theme.d3pBodyLarge, - ), + children: [ + D3pBodyMediumText( + Fmt.basicDateFormat.format(snapshot.stamp), + translate: false, + color: D3pColors.disabled, ), - if (snapshot.isNew) + if (areSelectable) Icon( - Icons.fiber_new_outlined, + isSelected + ? Icons.check_box_rounded + : Icons.check_box_outline_blank_rounded, color: D3pThemeData.mainColor, ), ], ), - const SizedBoxH8(), - Text.rich( - snapshot.settingsConfig.toShort(context), - ), - const SizedBoxH8(), - SizedBox( - height: 24, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - D3pBodyMediumText( - Fmt.basicDateFormat.format(snapshot.stamp), - translate: false, - color: D3pColors.disabled, - ), - if (state.areSelectable) - Icon( - state.snaps.contains(snapshot) - ? Icons.check_box_rounded - : Icons.check_box_outline_blank_rounded, - color: D3pThemeData.mainColor, - ), - ], - ), - ), - ], - ), + ), + ], ), ); } diff --git a/lib/features/scan_page/presentation/widgets/scan_page_content.dart b/lib/features/scan_page/presentation/widgets/scan_page_content.dart index 421f108c..27d95ae7 100644 --- a/lib/features/scan_page/presentation/widgets/scan_page_content.dart +++ b/lib/features/scan_page/presentation/widgets/scan_page_content.dart @@ -30,12 +30,12 @@ class ScanPageContent extends StatelessWidget { // await Future.delayed(Duration(seconds: 5)); // state.objects.forEach((element) {element.snapshots.forEach((element) {element.isNew });}); if (state.hasNew) { - final snap = state.firstNew; + final snap = state.latest; final gKey = state.globalKeyMap[snap]; // final snap = event.object.snapshots.first; Scrollable.ensureVisible( gKey!.currentContext!, - duration: Duration(seconds: 1), + duration: const Duration(seconds: 1), ); debugPrint('SCROLL SCROLL'); } else { diff --git a/lib/features/scan_page/presentation/widgets/select_many_icon_button.dart b/lib/features/scan_page/presentation/widgets/select_many_icon_button.dart index a09f2998..999028af 100644 --- a/lib/features/scan_page/presentation/widgets/select_many_icon_button.dart +++ b/lib/features/scan_page/presentation/widgets/select_many_icon_button.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:threedpass/core/widgets/buttons/icon_button.dart'; import 'package:threedpass/features/scan_page/bloc/select_snapshots_cubit.dart'; diff --git a/lib/features/scan_page/presentation/widgets/selectable_snapshot_card.dart b/lib/features/scan_page/presentation/widgets/selectable_snapshot_card.dart new file mode 100644 index 00000000..1318d732 --- /dev/null +++ b/lib/features/scan_page/presentation/widgets/selectable_snapshot_card.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:threedpass/features/hashes_list/domain/entities/hash_object.dart'; +import 'package:threedpass/features/hashes_list/domain/entities/snapshot.dart'; +import 'package:threedpass/features/scan_page/bloc/select_snapshots_cubit.dart'; +import 'package:threedpass/features/scan_page/presentation/widgets/object_list/hash_card.dart'; + +class SelectableSnapshotCard extends StatelessWidget { + const SelectableSnapshotCard({ + required this.snapshot, + required this.hashObject, + this.onTap, + super.key, + }); + + final Snapshot snapshot; + final HashObject hashObject; + final void Function()? onTap; + + @override + Widget build(final BuildContext context) { + return BlocBuilder( + buildWhen: (final previous, final current) => + previous.areSelectable != current.areSelectable || + previous.snaps.contains(snapshot) != current.snaps.contains(snapshot), + builder: (final _, final state) => SnapshotCard( + snapshot: snapshot, + hashObject: hashObject, + onTap: state.areSelectable + ? () => + BlocProvider.of(context).toggle(snapshot) + : null, + areSelectable: state.areSelectable, + isSelected: state.snaps.contains(snapshot), + setGlobalKey: true, + ), + ); + } +} diff --git a/lib/features/scan_page/presentation/widgets/snapshots_list.dart b/lib/features/scan_page/presentation/widgets/snapshots_list.dart index aa19757e..9f3aab04 100644 --- a/lib/features/scan_page/presentation/widgets/snapshots_list.dart +++ b/lib/features/scan_page/presentation/widgets/snapshots_list.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:threedpass/features/hashes_list/domain/entities/hash_object.dart'; import 'package:threedpass/features/hashes_list/domain/entities/snapshot.dart'; -import 'package:threedpass/features/scan_page/presentation/widgets/object_list/hash_card.dart'; +import 'package:threedpass/features/scan_page/presentation/widgets/selectable_snapshot_card.dart'; class SnapshotsList extends StatelessWidget { const SnapshotsList({ @@ -36,7 +36,7 @@ class SnapshotsList extends StatelessWidget { // BlocProvider.of(context).state.areSelectable; return Padding( padding: const EdgeInsets.symmetric(vertical: 4), - child: SnapshotCard( + child: SelectableSnapshotCard( snapshot: listToShow[index], hashObject: currentObject, ), diff --git a/lib/features/settings_page/domain/entities/algorithm.dart b/lib/features/settings_page/domain/entities/algorithm.dart index c1963248..0232d224 100644 --- a/lib/features/settings_page/domain/entities/algorithm.dart +++ b/lib/features/settings_page/domain/entities/algorithm.dart @@ -1,9 +1,9 @@ class AlgorithmMaster { // Algo names - static const grid2d_0_3_4_v1 = 'Grid2d. P3D 0.3.4'; - static const grid2d_0_3_4_v2 = 'Grid2d_v2. P3D 0.3.4'; - static const grid2d_0_3_4_v3 = 'Grid2d_v3. P3D 0.3.4'; - static const grid2d_0_3_4_v3a = 'Grid2d_v3a. P3D 0.3.4'; + static const grid2d_0_3_4_v1 = 'Grid2d'; + static const grid2d_0_3_4_v2 = 'Grid2dV2'; + static const grid2d_0_3_4_v3 = 'Grid2dV3'; + static const grid2d_0_3_4_v3a = 'Grid2dV3a'; /// Update this list when a new algorithm is added static const list = [ diff --git a/lib/features/settings_page/domain/entities/scan_settings.dart b/lib/features/settings_page/domain/entities/scan_settings.dart index cde39a82..355b2eb4 100644 --- a/lib/features/settings_page/domain/entities/scan_settings.dart +++ b/lib/features/settings_page/domain/entities/scan_settings.dart @@ -18,6 +18,10 @@ class ScanSettings extends Equatable { final String libVersion; @HiveField(4) final String transBytes; + @HiveField(5, defaultValue: TransBytesMode.random) + final TransBytesMode transBytesMode; + + static const String noneTransBytesKey = 'None'; const ScanSettings({ required this.gridSize, @@ -25,6 +29,7 @@ class ScanSettings extends Equatable { required this.algorithm, required this.libVersion, required this.transBytes, + required this.transBytesMode, }); const ScanSettings.defaultValues() @@ -32,6 +37,7 @@ class ScanSettings extends Equatable { algorithm = AlgorithmMaster.defaultAlgo, nSections = 12, libVersion = 'unknown', + transBytesMode = TransBytesMode.random, transBytes = ''; @override @@ -43,10 +49,10 @@ class ScanSettings extends Equatable { ]; ScanSettings selfValidate() { - final String algorithm = this.algorithm; + String algorithm = this.algorithm; if (!AlgorithmMaster.list.contains(algorithm)) { // If algo is deprecated, migrate slowly - return const ScanSettings.defaultValues(); + algorithm = AlgorithmMaster.defaultAlgo; } return this.copyWith( @@ -54,3 +60,15 @@ class ScanSettings extends Equatable { ); } } + +@HiveType(typeId: 10) +enum TransBytesMode { + @HiveField(0) + none, + + @HiveField(1) + random, + + @HiveField(2) + specific, +} diff --git a/lib/features/settings_page/domain/entities/scan_settings.g.dart b/lib/features/settings_page/domain/entities/scan_settings.g.dart index 7308c985..0756144a 100644 --- a/lib/features/settings_page/domain/entities/scan_settings.g.dart +++ b/lib/features/settings_page/domain/entities/scan_settings.g.dart @@ -17,6 +17,8 @@ abstract class _$ScanSettingsCWProxy { ScanSettings transBytes(String transBytes); + ScanSettings transBytesMode(TransBytesMode transBytesMode); + /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `ScanSettings(...).copyWith.fieldName(...)` to override fields one at a time with nullification support. /// /// Usage @@ -29,6 +31,7 @@ abstract class _$ScanSettingsCWProxy { String? algorithm, String? libVersion, String? transBytes, + TransBytesMode? transBytesMode, }); } @@ -53,6 +56,10 @@ class _$ScanSettingsCWProxyImpl implements _$ScanSettingsCWProxy { @override ScanSettings transBytes(String transBytes) => this(transBytes: transBytes); + @override + ScanSettings transBytesMode(TransBytesMode transBytesMode) => + this(transBytesMode: transBytesMode); + @override /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `ScanSettings(...).copyWith.fieldName(...)` to override fields one at a time with nullification support. @@ -67,6 +74,7 @@ class _$ScanSettingsCWProxyImpl implements _$ScanSettingsCWProxy { Object? algorithm = const $CopyWithPlaceholder(), Object? libVersion = const $CopyWithPlaceholder(), Object? transBytes = const $CopyWithPlaceholder(), + Object? transBytesMode = const $CopyWithPlaceholder(), }) { return ScanSettings( gridSize: gridSize == const $CopyWithPlaceholder() || gridSize == null @@ -91,6 +99,11 @@ class _$ScanSettingsCWProxyImpl implements _$ScanSettingsCWProxy { ? _value.transBytes // ignore: cast_nullable_to_non_nullable : transBytes as String, + transBytesMode: transBytesMode == const $CopyWithPlaceholder() || + transBytesMode == null + ? _value.transBytesMode + // ignore: cast_nullable_to_non_nullable + : transBytesMode as TransBytesMode, ); } } @@ -121,13 +134,16 @@ class ScanSettingsAdapter extends TypeAdapter { algorithm: fields[1] as String, libVersion: fields[3] as String, transBytes: fields[4] as String, + transBytesMode: fields[5] == null + ? TransBytesMode.random + : fields[5] as TransBytesMode, ); } @override void write(BinaryWriter writer, ScanSettings obj) { writer - ..writeByte(5) + ..writeByte(6) ..writeByte(0) ..write(obj.gridSize) ..writeByte(1) @@ -137,7 +153,9 @@ class ScanSettingsAdapter extends TypeAdapter { ..writeByte(3) ..write(obj.libVersion) ..writeByte(4) - ..write(obj.transBytes); + ..write(obj.transBytes) + ..writeByte(5) + ..write(obj.transBytesMode); } @override @@ -150,3 +168,47 @@ class ScanSettingsAdapter extends TypeAdapter { runtimeType == other.runtimeType && typeId == other.typeId; } + +class TransBytesModeAdapter extends TypeAdapter { + @override + final int typeId = 10; + + @override + TransBytesMode read(BinaryReader reader) { + switch (reader.readByte()) { + case 0: + return TransBytesMode.none; + case 1: + return TransBytesMode.random; + case 2: + return TransBytesMode.specific; + default: + return TransBytesMode.none; + } + } + + @override + void write(BinaryWriter writer, TransBytesMode obj) { + switch (obj) { + case TransBytesMode.none: + writer.writeByte(0); + break; + case TransBytesMode.random: + writer.writeByte(1); + break; + case TransBytesMode.specific: + writer.writeByte(2); + break; + } + } + + @override + int get hashCode => typeId.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is TransBytesModeAdapter && + runtimeType == other.runtimeType && + typeId == other.typeId; +} diff --git a/lib/features/settings_page/presentation/settings_sub_page/sections_subpage.dart b/lib/features/settings_page/presentation/settings_sub_page/sections_subpage.dart index 5ef7daa1..942ea3ed 100644 --- a/lib/features/settings_page/presentation/settings_sub_page/sections_subpage.dart +++ b/lib/features/settings_page/presentation/settings_sub_page/sections_subpage.dart @@ -8,7 +8,7 @@ import 'package:threedpass/features/settings_page/presentation/settings_sub_page import 'package:threedpass/features/settings_page/presentation/widgets/hash_settings/sections_textfield.dart'; @RoutePage() -class SectionsSubPage extends SettingSubPage { +class SectionsSubPage extends StatelessWidget { SectionsSubPage({ required final GlobalSettings initialState, super.key, @@ -20,24 +20,10 @@ class SectionsSubPage extends SettingSubPage { late final TextEditingController controller; - @override - final String appbarTitle = 'n_sections_label'; - - @override void onSavePressed(final BuildContext context) { _onFieldChanged(context, controller.text); } - @override - Widget bodyBuilder(final BuildContext context) { - return Padding( - padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 16), - child: SectionsTextField( - controller: controller, - ), - ); - } - static Future _onFieldChanged( final BuildContext context, final String? newValue, @@ -50,4 +36,18 @@ class SectionsSubPage extends SettingSubPage { cubit.updateSettings(newState); } } + + @override + Widget build(final BuildContext context) { + return SettingSubPage( + appbarTitle: 'n_sections_label', + onSavePressed: onSavePressed, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 16), + child: SectionsTextField( + controller: controller, + ), + ), + ); + } } diff --git a/lib/features/settings_page/presentation/settings_sub_page/setting_sub_page.dart b/lib/features/settings_page/presentation/settings_sub_page/setting_sub_page.dart index c1e62c49..f6879aed 100644 --- a/lib/features/settings_page/presentation/settings_sub_page/setting_sub_page.dart +++ b/lib/features/settings_page/presentation/settings_sub_page/setting_sub_page.dart @@ -5,15 +5,18 @@ import 'package:threedpass/core/theme/d3p_special_colors.dart'; import 'package:threedpass/core/widgets/appbars/d3p_platfrom_appbar.dart'; import 'package:threedpass/core/widgets/buttons/icon_button.dart'; -abstract class SettingSubPage extends StatelessWidget { +class SettingSubPage extends StatelessWidget { const SettingSubPage({ + required this.appbarTitle, + required this.child, + required this.onSavePressed, super.key, }); - String get appbarTitle; + final String appbarTitle; + final Widget child; - Widget bodyBuilder(final BuildContext context); - void onSavePressed(final BuildContext context); + final void Function(BuildContext context) onSavePressed; void saveAndExit(final BuildContext context) { onSavePressed(context); @@ -40,8 +43,7 @@ abstract class SettingSubPage extends StatelessWidget { ), ], ), - // ignore: avoid-returning-widgets - body: bodyBuilder(context), + body: child, ); } } diff --git a/lib/features/settings_page/presentation/settings_sub_page/stable_hash_subpage.dart b/lib/features/settings_page/presentation/settings_sub_page/stable_hash_subpage.dart index 4f2ca241..9cc32598 100644 --- a/lib/features/settings_page/presentation/settings_sub_page/stable_hash_subpage.dart +++ b/lib/features/settings_page/presentation/settings_sub_page/stable_hash_subpage.dart @@ -8,7 +8,7 @@ import 'package:threedpass/features/settings_page/presentation/settings_sub_page import 'package:threedpass/features/settings_page/presentation/widgets/app_settings/requirements_textfield.dart'; @RoutePage() -class StableHashSubPage extends SettingSubPage { +class StableHashSubPage extends StatelessWidget { StableHashSubPage({ required final GlobalSettings initialState, super.key, @@ -20,24 +20,10 @@ class StableHashSubPage extends SettingSubPage { late final TextEditingController controller; - @override - final String appbarTitle = 'stable_requirement_label'; - - @override void onSavePressed(final BuildContext context) { _onFieldChanged(context, controller.text); } - @override - Widget bodyBuilder(final BuildContext context) { - return Padding( - padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 16), - child: RequirementsTextField( - controller: controller, - ), - ); - } - static Future _onFieldChanged( final BuildContext context, final String? newValue, @@ -61,4 +47,18 @@ class StableHashSubPage extends SettingSubPage { final newState = cubit.state.copyWith(appSettings: newAppConfig); cubit.updateSettings(newState); } + + @override + Widget build(final BuildContext context) { + return SettingSubPage( + appbarTitle: 'stable_requirement_label', + onSavePressed: onSavePressed, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 16), + child: RequirementsTextField( + controller: controller, + ), + ), + ); + } } diff --git a/lib/features/settings_page/presentation/settings_sub_page/trans_bytes_subpage.dart b/lib/features/settings_page/presentation/settings_sub_page/trans_bytes_subpage.dart index dc742eae..51e50b84 100644 --- a/lib/features/settings_page/presentation/settings_sub_page/trans_bytes_subpage.dart +++ b/lib/features/settings_page/presentation/settings_sub_page/trans_bytes_subpage.dart @@ -1,6 +1,9 @@ import 'package:auto_route/auto_route.dart'; +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:threedpass/core/widgets/buttons/enum_button.dart'; +import 'package:threedpass/core/widgets/buttons/enum_buttons_list.dart'; import 'package:threedpass/features/settings_page/bloc/settings_page_cubit.dart'; import 'package:threedpass/features/settings_page/domain/entities/global_settings.dart'; import 'package:threedpass/features/settings_page/domain/entities/scan_settings.dart'; @@ -8,49 +11,115 @@ import 'package:threedpass/features/settings_page/presentation/settings_sub_page import 'package:threedpass/features/settings_page/presentation/widgets/hash_settings/trans_bytes.dart'; @RoutePage() -class TransBytesSubPage extends SettingSubPage { - TransBytesSubPage({ - required final GlobalSettings initialState, +class TransBytesSubPage extends StatefulWidget { + final GlobalSettings initialState; + + const TransBytesSubPage({ + required this.initialState, super.key, - }) { + }); + + @override + State createState() => _TransBytesSubPageState(); +} + +class _TransBytesSubPageState extends State { + _TransBytesSubPageState(); + @override + void initState() { controller = TextEditingController( text: hexInputFormatter.maskText( - initialState.scanSettings.transBytes, + widget.initialState.scanSettings.transBytes, ), ); + chosennTBM = widget.initialState.scanSettings.transBytesMode; + super.initState(); } static final hexInputFormatter = TransBytesMaskTextInputFormatter(); late final TextEditingController controller; + late TransBytesMode chosennTBM; - @override - final String appbarTitle = 'trans_bytes_input_label'; + final _formKey = GlobalKey(); - @override void onSavePressed(final BuildContext context) { - changeSettings(controller.text, context); + if (_formKey.currentState!.validate()) { + changeSettings(controller.text, context); + } + } + + void changeSettings(final String rawInput, final BuildContext context) { + final cubit = BlocProvider.of(context); + + // Set transBytes + String newTransBytes = cubit.state.scanSettings.transBytes; + if (chosennTBM == TransBytesMode.specific) { + final smartInput = TransBytesInput(rawInput); + final realInput = smartInput.unmasked.toLowerCase(); + newTransBytes = realInput; + } + + // Update settings + final newScanConfig = cubit.state.scanSettings + .copyWith(transBytes: newTransBytes, transBytesMode: chosennTBM); + final newState = cubit.state.copyWith(scanSettings: newScanConfig); + cubit.updateSettings(newState); + } + + void onEnumPressed(final TransBytesMode mode) { + setState(() { + chosennTBM = mode; + }); } @override - Widget bodyBuilder(final BuildContext context) { - return Padding( - padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 16), - child: TransBytesInputField( - controller: controller, + Widget build(final BuildContext context) { + return SettingSubPage( + appbarTitle: 'trans_bytes_input_label', + onSavePressed: onSavePressed, + child: Column( + children: [ + EnumButtonsList( + length: TransBytesMode.values.length, + itemBuilder: (final BuildContext context, final int index) { + final mode = TransBytesMode.values[index]; + return EnumButton( + text: mode.localizedName, + isChosen: mode == chosennTBM, + onPressed: () => onEnumPressed(mode), + ); + }, + ), + Form( + key: _formKey, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 16), + child: TransBytesInputField( + controller: controller, + enabled: chosennTBM == TransBytesMode.specific, + validator: (final input) => + chosennTBM == TransBytesMode.specific + ? TransBytesInput(input ?? '').isValid + : null, + ), + ), + ), + ], ), ); } +} - void changeSettings(final String rawInput, final BuildContext context) { - final smartInput = TransBytesInput(rawInput); - if (smartInput.isValid == null) { - final realInput = smartInput.unmasked.toLowerCase(); - final cubit = BlocProvider.of(context); - final newScanConfig = - cubit.state.scanSettings.copyWith(transBytes: realInput); - final newState = cubit.state.copyWith(scanSettings: newScanConfig); - cubit.updateSettings(newState); +extension LocalizedTransBytesMode on TransBytesMode { + String get localizedName { + switch (this) { + case TransBytesMode.none: + return 'trans_bytes_none'.tr(); + case TransBytesMode.random: + return 'trans_bytes_random'.tr(); + case TransBytesMode.specific: + return 'trans_bytes_specific'.tr(); } } } diff --git a/lib/features/settings_page/presentation/settings_sub_page/wallet_node_subpage.dart b/lib/features/settings_page/presentation/settings_sub_page/wallet_node_subpage.dart index 4cbe4cb1..7d2b4e9b 100644 --- a/lib/features/settings_page/presentation/settings_sub_page/wallet_node_subpage.dart +++ b/lib/features/settings_page/presentation/settings_sub_page/wallet_node_subpage.dart @@ -12,7 +12,7 @@ import 'package:threedpass/features/settings_page/presentation/settings_sub_page import 'package:threedpass/features/settings_page/presentation/widgets/wallet_settings/node_url_textfield.dart'; @RoutePage() -class WalletNodeSubPage extends SettingSubPage { +class WalletNodeSubPage extends StatelessWidget { WalletNodeSubPage({ required final GlobalSettings initialState, super.key, @@ -24,10 +24,6 @@ class WalletNodeSubPage extends SettingSubPage { late final TextEditingController controller; - @override - final String appbarTitle = 'node_url_subpage_label'; - - @override void onSavePressed(final BuildContext context) { apply(controller.text, context); } @@ -51,13 +47,18 @@ class WalletNodeSubPage extends SettingSubPage { } @override - Widget bodyBuilder(final BuildContext context) { - return Padding( - padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 16), - child: NodeUrlTextfield( - textEditingController: controller, - settingsConfigCubit: BlocProvider.of(context), - appServiceLoaderCubit: BlocProvider.of(context), + Widget build(final BuildContext context) { + return SettingSubPage( + appbarTitle: 'node_url_subpage_label', + onSavePressed: onSavePressed, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 16), + child: NodeUrlTextfield( + textEditingController: controller, + settingsConfigCubit: BlocProvider.of(context), + appServiceLoaderCubit: + BlocProvider.of(context), + ), ), ); } diff --git a/lib/features/settings_page/presentation/widgets/hash_settings/grid_size_dropdown.dart b/lib/features/settings_page/presentation/widgets/hash_settings/grid_size_dropdown.dart deleted file mode 100644 index 8c33be77..00000000 --- a/lib/features/settings_page/presentation/widgets/hash_settings/grid_size_dropdown.dart +++ /dev/null @@ -1,41 +0,0 @@ -// part of '../../settings_page.dart'; - -// class _GridSizeDropdown extends StatelessWidget { -// const _GridSizeDropdown({final Key? key}) : super(key: key); - -// static const _gridSizes = [6, 7, 8, 9, 10]; - -// Future _onGridChanged( -// final BuildContext context, -// final int? newValue, -// ) async { -// if (newValue != null) { -// final cubit = BlocProvider.of(context); -// final newScanConfig = -// cubit.state.scanSettings.copyWith(gridSize: newValue); -// final newState = cubit.state.copyWith(scanSettings: newScanConfig); -// cubit.updateSettings(newState); -// } -// } - -// @override -// Widget build(final BuildContext context) { -// final settings = -// BlocProvider.of(context).state.scanSettings; - -// return D3pDropdownButtonFormField( -// context: context, -// label: 'grid_size_label', -// value: settings.gridSize, -// onChanged: (final int? newValue) => _onGridChanged(context, newValue), -// items: _gridSizes -// .map( -// (final e) => DropdownMenuItem( -// value: e, -// child: Text('${e}x$e'), -// ), -// ) -// .toList(), -// ); -// } -// } diff --git a/lib/features/settings_page/presentation/widgets/hash_settings/trans_bytes.dart b/lib/features/settings_page/presentation/widgets/hash_settings/trans_bytes.dart index 9b9c1e22..9bae163e 100644 --- a/lib/features/settings_page/presentation/widgets/hash_settings/trans_bytes.dart +++ b/lib/features/settings_page/presentation/widgets/hash_settings/trans_bytes.dart @@ -7,37 +7,37 @@ import 'package:threedpass/core/widgets/input/textformfield/textformfield.dart'; /// Empty input means, that trans bytes should be taken from chain. /// Else user's 8 len input will be used by calc library -class TransBytesInputField extends StatefulWidget { +class TransBytesInputField extends StatelessWidget { const TransBytesInputField({ required this.controller, + required this.enabled, + required this.validator, final Key? key, }) : super(key: key); final TextEditingController controller; + final bool? enabled; + final String? Function(String?) validator; - @override - State createState() => _State(); -} - -class _State extends State { static final hexInputFormatter = TransBytesMaskTextInputFormatter(); void onClearPressed(final BuildContext context) { - widget.controller.clear(); + controller.clear(); // changeSettings('', context); } @override Widget build(final BuildContext context) { return D3pTextFormField( - controller: widget.controller, + controller: controller, labelText: 'trans_bytes_input_label'.tr(), suffixButton: Icons.clear, onSuffixButtonPressed: () => onClearPressed(context), // onChanged: (final value) => changeSettings(value ?? '', context), - validator: (final input) => TransBytesInput(input ?? '').isValid, + validator: validator, inputFormatters: [hexInputFormatter], - autofocus: true, + // autofocus: true, + enabled: enabled, // bottomHelpText: 'trans_help_text'.tr(), ); } @@ -59,12 +59,8 @@ class TransBytesInput { TransBytesInput(this.rawInput); - /// Does field should show an error? String? get isValid { final realInput = hexInputFormatter.unmaskText(rawInput); - if (realInput.isEmpty) { - return null; - } if (int.tryParse(realInput, radix: 16) != null && realInput.length == 8) { print('Valid $realInput'); diff --git a/lib/features/settings_page/presentation/widgets/hash_settings/trans_bytes_button.dart b/lib/features/settings_page/presentation/widgets/hash_settings/trans_bytes_button.dart index b535826b..cb9d6271 100644 --- a/lib/features/settings_page/presentation/widgets/hash_settings/trans_bytes_button.dart +++ b/lib/features/settings_page/presentation/widgets/hash_settings/trans_bytes_button.dart @@ -1,10 +1,11 @@ import 'package:auto_route/auto_route.dart'; -import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:threedpass/core/widgets/d3p_card.dart'; import 'package:threedpass/features/settings_page/bloc/settings_page_cubit.dart'; import 'package:threedpass/features/settings_page/domain/entities/global_settings.dart'; +import 'package:threedpass/features/settings_page/domain/entities/scan_settings.dart'; +import 'package:threedpass/features/settings_page/presentation/settings_sub_page/trans_bytes_subpage.dart'; import 'package:threedpass/features/settings_page/presentation/widgets/default_settings_button.dart'; import 'package:threedpass/router/router.gr.dart'; import 'package:unicons/unicons.dart'; @@ -17,15 +18,25 @@ class TransBytesButton extends StatelessWidget { context.router.push(TransBytesSubRoute(initialState: settingsState)); } + String transBytesSettingsToText(final ScanSettings scanSettings) { + if (scanSettings.transBytesMode == TransBytesMode.specific) { + return '0x${scanSettings.transBytes}'; + } else { + return scanSettings.transBytesMode.localizedName; + } + } + @override Widget build(final BuildContext context) { return BlocBuilder( buildWhen: (final previous, final current) => - previous.scanSettings.transBytes != current.scanSettings.transBytes, + previous.scanSettings.transBytes != current.scanSettings.transBytes || + previous.scanSettings.transBytesMode != + current.scanSettings.transBytesMode, builder: (final context, final state) { - final text = state.scanSettings.transBytes.isNotEmpty - ? state.scanSettings.transBytes - : 'trans_bytes_empty_input'.tr(); + final scanSettings = state.scanSettings; + final text = transBytesSettingsToText(scanSettings); + return DefaultSettingsButton.openButton( text: 'trans_bytes_input_label', iconData: UniconsLine.shuffle, diff --git a/lib/features/settings_page/presentation/widgets/settings_text.dart b/lib/features/settings_page/presentation/widgets/settings_text.dart index 2190850f..45a18ba4 100644 --- a/lib/features/settings_page/presentation/widgets/settings_text.dart +++ b/lib/features/settings_page/presentation/widgets/settings_text.dart @@ -9,13 +9,21 @@ import 'package:threedpass/features/settings_page/domain/entities/scan_settings. const int $nbsp = 0x00A0; // Non-breaking space extension ToText on ScanSettings { + String get prettyTransBytes { + if (transBytesMode == TransBytesMode.none) { + return ScanSettings.noneTransBytesKey; + } else { + return '0x' + transBytes.toLowerCase(); + } + } + List propertiesList() { final res = [ '- ' + 'algorithm_span'.tr() + ': ' + algorithm + '\n', '- ' + 'grid_span'.tr() + ': ${gridSize}x$gridSize\n', '- ' + 'n_sections_span'.tr() + ': $nSections\n', '- ' + 'lib_version_span'.tr() + ': $libVersion\n', - '- ' + 'trans_bytes_span'.tr() + ': ${transBytes.toLowerCase()}', + '- ' + 'trans_bytes_span'.tr() + ': $prettyTransBytes', ]; return res; } @@ -24,39 +32,68 @@ extension ToText on ScanSettings { return 'settings_text_span_title'.tr() + '\n' + propertiesList().join(); } - TextSpan toShort( + TextSpan smartTextSpan( final BuildContext context, + final String tag, + final String text, + final String end, ) { final medium = Theme.of(context).customTextStyles.d3pBodyMedium; + return TextSpan( + text: tag, + style: medium.copyWith(color: D3pColors.disabled), + children: [ + TextSpan( + text: text, + style: medium, + ), + TextSpan( + text: end, + style: medium.copyWith(color: D3pColors.disabled), + ), + ], + ); + } + + TextSpan toShort( + final BuildContext context, + ) { final tags = [ - 'A: ', - 'G: ', - 'N: ', - 'R:' + String.fromCharCode($nbsp) + '0x', + 'A:' + String.fromCharCode($nbsp), + 'G:' + String.fromCharCode($nbsp), + 'N:' + String.fromCharCode($nbsp), ]; final props = [ algorithm, '${gridSize}x$gridSize', nSections.toString(), // libVersion, - transBytes.toLowerCase(), + prettyTransBytes, ]; + // Add some props final children = []; for (var i = 0; i < tags.length; i++) { children.add( - TextSpan( - text: tags[i], - style: medium.copyWith(color: D3pColors.disabled), - children: [ - TextSpan( - text: props[i], - style: medium, - ), - TextSpan( - text: i != tags.length - 1 ? '; ' : '', - style: medium.copyWith(color: D3pColors.disabled), - ), - ], + smartTextSpan(context, tags[i], props[i], '; '), + ); + } + // Add transBytes + if (transBytesMode == TransBytesMode.none) { + children.add( + smartTextSpan( + context, + 'R:' + String.fromCharCode($nbsp), + ScanSettings.noneTransBytesKey, + '', + ), + ); + } else { + children.add( + smartTextSpan( + context, + 'R:' + String.fromCharCode($nbsp) + '0x', + prettyTransBytes, + '', ), ); } diff --git a/lib/features/uploaded_object_page/uploaded_object_page.dart b/lib/features/uploaded_object_page/uploaded_object_page.dart index d7a30c13..567c2140 100644 --- a/lib/features/uploaded_object_page/uploaded_object_page.dart +++ b/lib/features/uploaded_object_page/uploaded_object_page.dart @@ -43,6 +43,7 @@ class UploadedObjectPage extends StatelessWidget { SnapshotConnectedToUploaded( uploadedObject: uploadedObject, topPadding: 16, + isOnlyText: false, ), const SizedBoxH16(), FastRichText( diff --git a/lib/features/uploaded_object_page/widgets/snapshot_connected_to_uploaded.dart b/lib/features/uploaded_object_page/widgets/snapshot_connected_to_uploaded.dart index 96ce5a30..bc909f35 100644 --- a/lib/features/uploaded_object_page/widgets/snapshot_connected_to_uploaded.dart +++ b/lib/features/uploaded_object_page/widgets/snapshot_connected_to_uploaded.dart @@ -4,17 +4,21 @@ import 'package:threedpass/core/theme/d3p_colors.dart'; import 'package:threedpass/core/widgets/text/d3p_body_medium_text.dart'; import 'package:threedpass/features/hashes_list/bloc/hashes_list_bloc.dart'; import 'package:threedpass/features/hashes_list/domain/entities/snapshot.dart'; +import 'package:threedpass/features/hashes_list/domain/extentions/find_hashobject_by_snapshot.dart'; import 'package:threedpass/features/poscan_objects_query/domain/entities/uploaded_object.dart'; +import 'package:threedpass/features/scan_page/presentation/widgets/object_list/hash_card.dart'; class SnapshotConnectedToUploaded extends StatelessWidget { const SnapshotConnectedToUploaded({ required this.uploadedObject, required this.topPadding, + required this.isOnlyText, super.key, }); final UploadedObject uploadedObject; final double topPadding; + final bool isOnlyText; @override Widget build(final BuildContext context) { @@ -58,10 +62,22 @@ class SnapshotConnectedToUploaded extends StatelessWidget { shrinkWrap: true, itemCount: similarSnapshots.length, itemBuilder: (final context, final index) { - return D3pBodyMediumText( - similarSnapshots[index].name, - translate: false, - ); + if (isOnlyText) { + return D3pBodyMediumText( + similarSnapshots[index].name, + translate: false, + ); + } else { + final snap = similarSnapshots[index]; + final hashObject = localObjectsBloc.findBySnapshot(snap)!; + return Padding( + padding: const EdgeInsets.symmetric(vertical: 4), + child: SnapshotCard( + snapshot: snap, + hashObject: hashObject, + ), + ); + } }, ), ], diff --git a/lib/features/wallet_screen/assets_page/widgets/objects_list/objects_list_item.dart b/lib/features/wallet_screen/assets_page/widgets/objects_list/objects_list_item.dart index c99e2086..f1c0ab1e 100644 --- a/lib/features/wallet_screen/assets_page/widgets/objects_list/objects_list_item.dart +++ b/lib/features/wallet_screen/assets_page/widgets/objects_list/objects_list_item.dart @@ -44,6 +44,7 @@ class ObjectsListItem extends StatelessWidget { SnapshotConnectedToUploaded( uploadedObject: uploadedObject, topPadding: 8, + isOnlyText: true, ), ], ), diff --git a/lib/features/wallet_screen/contacts_page/widgets/contacts_list.dart b/lib/features/wallet_screen/contacts_page/widgets/contacts_list.dart index fe34fb71..22aa6920 100644 --- a/lib/features/wallet_screen/contacts_page/widgets/contacts_list.dart +++ b/lib/features/wallet_screen/contacts_page/widgets/contacts_list.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; import 'package:threedpass/core/widgets/buttons/icon_button.dart'; +import 'package:threedpass/core/widgets/d3p_card.dart'; import 'package:threedpass/features/wallet_screen/add_contact_page/domain/entities/contact.dart'; import 'package:threedpass/features/wallet_screen/contacts_page/widgets/contact_address_text.dart'; import 'package:threedpass/features/wallet_screen/contacts_page/widgets/contact_name_text.dart'; @@ -29,19 +30,25 @@ class ContactsList extends StatelessWidget { final currentContact = contacts[objIndex]; return Padding( padding: const EdgeInsets.only(bottom: 16), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - ContactNameText(name: currentContact.name), - const Spacer(), - ContactAddressText(address: currentContact.address), - const SizedBox(width: 8), - D3pIconButton( - onPressed: () => _openConfirmDialog(currentContact, context), - iconData: Icons.delete, - emptyContraints: true, + child: D3pCard( + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + ContactNameText(name: currentContact.name), + const Spacer(), + ContactAddressText(address: currentContact.address), + const SizedBox(width: 8), + D3pIconButton( + onPressed: () => + _openConfirmDialog(currentContact, context), + iconData: Icons.delete, + emptyContraints: true, + ), + ], ), - ], + ), ), ); }, diff --git a/lib/features/wallet_screen/widgets/block_datetime_w.dart b/lib/features/wallet_screen/widgets/block_datetime_w.dart index 601a8f44..34a61d12 100644 --- a/lib/features/wallet_screen/widgets/block_datetime_w.dart +++ b/lib/features/wallet_screen/widgets/block_datetime_w.dart @@ -11,7 +11,7 @@ class BlockDateTimeW extends StatelessWidget { // final dt = DateTime.parse(dateTime.value); if (dateTime != null) { return UTCTime( - dateTime: dateTime!, + dateTime: dateTime, formatter: Fmt.transferDateFormat, ); } else { diff --git a/lib/router/router.gr.dart b/lib/router/router.gr.dart index 8f6fc3dd..2cac188c 100644 --- a/lib/router/router.gr.dart +++ b/lib/router/router.gr.dart @@ -8,43 +8,43 @@ // coverage:ignore-file // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'package:auto_route/auto_route.dart' as _i52; -import 'package:flutter/material.dart' as _i53; -import 'package:flutter/widgets.dart' as _i59; +import 'package:auto_route/auto_route.dart' as _i53; +import 'package:flutter/material.dart' as _i54; +import 'package:flutter/widgets.dart' as _i60; import 'package:threedpass/core/widgets/default_loading_dialog.dart' as _i2; import 'package:threedpass/core/widgets/error_page.dart' as _i1; import 'package:threedpass/features/accounts/presentation/pages/create_account/create_account_credentials.dart' - as _i36; + as _i38; import 'package:threedpass/features/accounts/presentation/pages/create_account/create_account_from_object/create_account_from_object.dart' - as _i31; -import 'package:threedpass/features/accounts/presentation/pages/create_account/create_account_info_page.dart' as _i33; +import 'package:threedpass/features/accounts/presentation/pages/create_account/create_account_info_page.dart' + as _i35; import 'package:threedpass/features/accounts/presentation/pages/create_account/create_account_loader.dart' - as _i38; + as _i40; import 'package:threedpass/features/accounts/presentation/pages/create_account/create_account_mnemonic_backup.dart' - as _i34; + as _i36; import 'package:threedpass/features/accounts/presentation/pages/create_account/create_account_mnemonic_confirm.dart' - as _i35; -import 'package:threedpass/features/accounts/presentation/pages/create_account/create_account_type.dart' as _i37; +import 'package:threedpass/features/accounts/presentation/pages/create_account/create_account_type.dart' + as _i39; import 'package:threedpass/features/accounts/presentation/pages/create_account/create_account_wrapper.dart' - as _i30; -import 'package:threedpass/features/accounts/presentation/pages/create_account/import_mnemonic_form.dart' as _i32; +import 'package:threedpass/features/accounts/presentation/pages/create_account/import_mnemonic_form.dart' + as _i34; import 'package:threedpass/features/accounts/presentation/pages/create_account/import_rawseed_form.dart' - as _i29; + as _i31; import 'package:threedpass/features/accounts/presentation/pages/no_stable_hash_dialog.dart' - as _i39; + as _i41; import 'package:threedpass/features/compare_page/presentation/pages/compare_page_wrapper.dart' as _i3; import 'package:threedpass/features/explorer_page/explorer_page_wrapper.dart' - as _i51; + as _i18; import 'package:threedpass/features/explorer_page/objects_list_page/objects_list_page.dart' - as _i50; + as _i17; import 'package:threedpass/features/hashes_list/domain/entities/hash_object.dart' - as _i55; + as _i56; import 'package:threedpass/features/hashes_list/domain/entities/snapshot.dart' - as _i54; + as _i55; import 'package:threedpass/features/home_page/presentation/home_page.dart' as _i13; import 'package:threedpass/features/home_page/presentation/login_page.dart' @@ -52,7 +52,7 @@ import 'package:threedpass/features/home_page/presentation/login_page.dart' import 'package:threedpass/features/home_page/router/empty_initial_route.dart' as _i14; import 'package:threedpass/features/poscan_objects_query/domain/entities/uploaded_object.dart' - as _i60; + as _i61; import 'package:threedpass/features/poscan_putobject/presentation/d3prpc_page.dart' as _i15; import 'package:threedpass/features/poscan_putobject/presentation/d3rpc_page_wrapper.dart' @@ -63,77 +63,79 @@ import 'package:threedpass/features/preview_page/presentation/preview_page_wrapp as _i4; import 'package:threedpass/features/preview_page/presentation/widgets/delete_snapshot_dialog.dart' as _i8; +import 'package:threedpass/features/preview_page/presentation/widgets/rename_object_dialog.dart' + as _i52; import 'package:threedpass/features/preview_page/presentation/widgets/rename_snapshot_dialog.dart' as _i6; import 'package:threedpass/features/preview_page/presentation/widgets/save_hash_dialog.dart' as _i7; import 'package:threedpass/features/preview_page/presentation/widgets/save_object_dialog/save_object_dialog.dart' as _i9; -import 'package:threedpass/features/scan_page/presentation/pages/scan_page.dart' +import 'package:threedpass/features/scan_page/presentation/scan_page.dart' as _i11; -import 'package:threedpass/features/scan_page/presentation/pages/scan_page_wrapper.dart' +import 'package:threedpass/features/scan_page/presentation/scan_page_wrapper.dart' as _i10; import 'package:threedpass/features/settings_page/domain/entities/global_settings.dart' - as _i61; + as _i62; import 'package:threedpass/features/settings_page/presentation/settings_page.dart' - as _i41; + as _i43; import 'package:threedpass/features/settings_page/presentation/settings_sub_page/choose_algorithm_subpage.dart' - as _i47; + as _i49; import 'package:threedpass/features/settings_page/presentation/settings_sub_page/grid_size_subpage.dart' - as _i44; + as _i46; import 'package:threedpass/features/settings_page/presentation/settings_sub_page/pixel_ratio_subpage.dart' - as _i45; + as _i47; import 'package:threedpass/features/settings_page/presentation/settings_sub_page/sections_subpage.dart' - as _i42; + as _i44; import 'package:threedpass/features/settings_page/presentation/settings_sub_page/stable_hash_subpage.dart' - as _i48; + as _i50; import 'package:threedpass/features/settings_page/presentation/settings_sub_page/trans_bytes_subpage.dart' - as _i43; + as _i45; import 'package:threedpass/features/settings_page/presentation/settings_sub_page/wallet_node_subpage.dart' - as _i46; + as _i48; import 'package:threedpass/features/settings_page/router/empty_settings_route.dart' - as _i49; + as _i51; import 'package:threedpass/features/uploaded_object_page/uploaded_object_page.dart' - as _i40; + as _i42; import 'package:threedpass/features/wallet_screen/add_contact_page/add_contact_page.dart' - as _i22; + as _i24; import 'package:threedpass/features/wallet_screen/add_contact_page/domain/entities/contact.dart' - as _i56; + as _i57; import 'package:threedpass/features/wallet_screen/assets_page/remove_account_dialog.dart' - as _i19; + as _i21; import 'package:threedpass/features/wallet_screen/contacts_page/contacts_page.dart' - as _i17; + as _i19; import 'package:threedpass/features/wallet_screen/contacts_page/widgets/delete_contact_dialog.dart' - as _i18; + as _i20; import 'package:threedpass/features/wallet_screen/non_native_token_screen/domain/entities/get_extrinsics_usecase_params.dart' - as _i58; + as _i59; import 'package:threedpass/features/wallet_screen/non_native_token_screen/presentation/non_native_token_wrapper.dart' - as _i27; + as _i29; import 'package:threedpass/features/wallet_screen/notifications_page/presentation/notifications_page.dart' - as _i21; + as _i23; import 'package:threedpass/features/wallet_screen/recieve_page/recieve_page.dart' - as _i20; + as _i22; import 'package:threedpass/features/wallet_screen/transactions_history/presentation/transactions_history_wrapper.dart' - as _i28; + as _i30; import 'package:threedpass/features/wallet_screen/transfer_page/domain/entities/transfer_meta_dto.dart' - as _i57; + as _i58; import 'package:threedpass/features/wallet_screen/transfer_page/transfer_page.dart' - as _i26; + as _i28; import 'package:threedpass/features/wallet_screen/transfer_page/transfer_page_wrapper.dart' - as _i25; + as _i27; import 'package:threedpass/features/wallet_screen/wallet_page/wallet_page.dart' - as _i23; + as _i25; import 'package:threedpass/features/wallet_screen/wallet_page/wallet_page_wrapper.dart' - as _i24; + as _i26; -abstract class $RootRouter extends _i52.RootStackRouter { +abstract class $RootRouter extends _i53.RootStackRouter { $RootRouter({super.navigatorKey}); @override - final Map pagesMap = { + final Map pagesMap = { ErrorRoute.name: (routeData) { final args = routeData.argsAs(); - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, child: _i1.ErrorPage( error: args.error, @@ -144,7 +146,7 @@ abstract class $RootRouter extends _i52.RootStackRouter { DefaultLoadingRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const DefaultLoadingRouteArgs()); - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, child: _i2.DefaultLoadingDialog( key: args.key, @@ -154,7 +156,7 @@ abstract class $RootRouter extends _i52.RootStackRouter { }, CompareRouteWrapper.name: (routeData) { final args = routeData.argsAs(); - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, child: _i3.ComparePageWrapper( origObj: args.origObj, @@ -165,9 +167,9 @@ abstract class $RootRouter extends _i52.RootStackRouter { }, PreviewRouteWrapper.name: (routeData) { final args = routeData.argsAs(); - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: _i52.WrappedRoute( + child: _i53.WrappedRoute( child: _i4.PreviewPageWrapper( hashObject: args.hashObject, snapshot: args.snapshot, @@ -177,14 +179,14 @@ abstract class $RootRouter extends _i52.RootStackRouter { ); }, PreviewRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, child: const _i5.PreviewPage(), ); }, RenameSnapshotRoute.name: (routeData) { final args = routeData.argsAs(); - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, child: _i6.RenameSnapshotDialog( snapshot: args.snapshot, @@ -195,7 +197,7 @@ abstract class $RootRouter extends _i52.RootStackRouter { }, SaveHashRoute.name: (routeData) { final args = routeData.argsAs(); - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, child: _i7.SaveHashDialog( snapshot: args.snapshot, @@ -205,14 +207,14 @@ abstract class $RootRouter extends _i52.RootStackRouter { ); }, DeleteSnapshotRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, child: const _i8.DeleteSnapshotDialog(), ); }, SaveObjectRoute.name: (routeData) { final args = routeData.argsAs(); - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, child: _i9.SaveObjectDialog( snapshot: args.snapshot, @@ -221,13 +223,13 @@ abstract class $RootRouter extends _i52.RootStackRouter { ); }, ScanRouteWrapper.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: _i52.WrappedRoute(child: const _i10.ScanPageWrapper()), + child: _i53.WrappedRoute(child: const _i10.ScanPageWrapper()), ); }, ScanRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, child: const _i11.ScanPage(), ); @@ -235,7 +237,7 @@ abstract class $RootRouter extends _i52.RootStackRouter { LoginRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const LoginRouteArgs()); - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, child: _i12.LoginPage( key: args.key, @@ -244,89 +246,101 @@ abstract class $RootRouter extends _i52.RootStackRouter { ); }, HomeRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, child: const _i13.HomePage(), ); }, InitialWrapperRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, child: const _i14.EmptyInitialRoute(), ); }, D3PRPCRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, child: const _i15.D3PRPCPage(), ); }, D3PRPCRouteWrapper.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( + routeData: routeData, + child: _i53.WrappedRoute(child: const _i16.D3PRPCPageWrapper()), + ); + }, + ObjectsListRoute.name: (routeData) { + return _i53.AutoRoutePage( + routeData: routeData, + child: const _i17.ObjectsListPage(), + ); + }, + ExplorerRouteWrapper.name: (routeData) { + return _i53.AutoRoutePage( routeData: routeData, - child: _i52.WrappedRoute(child: const _i16.D3PRPCPageWrapper()), + child: _i53.WrappedRoute(child: const _i18.ExplorerPageWrapper()), ); }, ContactsRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: const _i17.ContactsPage(), + child: const _i19.ContactsPage(), ); }, DeleteContactRoute.name: (routeData) { final args = routeData.argsAs(); - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: _i18.DeleteContactDialog( + child: _i20.DeleteContactDialog( contact: args.contact, key: args.key, ), ); }, RemoveAccountRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: const _i19.RemoveAccountDialog(), + child: const _i21.RemoveAccountDialog(), ); }, RecieveRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: const _i20.RecievePage(), + child: const _i22.RecievePage(), ); }, NotificationsRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: const _i21.NotificationsPage(), + child: const _i23.NotificationsPage(), ); }, AddContactRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const AddContactRouteArgs()); - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: _i22.AddContactPage(key: args.key), + child: _i24.AddContactPage(key: args.key), ); }, WalletRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: const _i23.WalletPage(), + child: const _i25.WalletPage(), ); }, WalletRouteWrapper.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: _i52.WrappedRoute(child: const _i24.WalletPageWrapper()), + child: _i53.WrappedRoute(child: const _i26.WalletPageWrapper()), ); }, TransferRouteWrapper.name: (routeData) { final args = routeData.argsAs(); - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: _i52.WrappedRoute( - child: _i25.TransferPageWrapper( + child: _i53.WrappedRoute( + child: _i27.TransferPageWrapper( metadata: args.metadata, key: args.key, )), @@ -335,122 +349,122 @@ abstract class $RootRouter extends _i52.RootStackRouter { TransferRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const TransferRouteArgs()); - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: _i26.TransferPage(key: args.key), + child: _i28.TransferPage(key: args.key), ); }, NonNativeTokenRouteWrapper.name: (routeData) { final args = routeData.argsAs(); - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: _i27.NonNativeTokenPageWrapper( + child: _i29.NonNativeTokenPageWrapper( args.params, key: args.key, ), ); }, TransactionsHistoryRouteWrapper.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: const _i28.TransactionsHistoryPageWrapper(), + child: const _i30.TransactionsHistoryPageWrapper(), ); }, ImportRawseedFormRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const ImportRawseedFormRouteArgs()); - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: _i29.ImportRawseedFormPage(key: args.key), + child: _i31.ImportRawseedFormPage(key: args.key), ); }, CreateAccountRouteWrapper.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: _i52.WrappedRoute(child: const _i30.CreateAccountPageWrapper()), + child: _i53.WrappedRoute(child: const _i32.CreateAccountPageWrapper()), ); }, CreateAccountFromObjectRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: const _i31.CreateAccountFromObjectPage(), + child: const _i33.CreateAccountFromObjectPage(), ); }, ImportMnemonicFormRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const ImportMnemonicFormRouteArgs()); - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: _i32.ImportMnemonicFormPage(key: args.key), + child: _i34.ImportMnemonicFormPage(key: args.key), ); }, CreateAccountInfoRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: const _i33.CreateAccountInfoPage(), + child: const _i35.CreateAccountInfoPage(), ); }, CreateAccountMnemonicBackupRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: const _i34.CreateAccountMnemonicBackupPage(), + child: const _i36.CreateAccountMnemonicBackupPage(), ); }, CreateAccountMnemonicConfirmRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: const _i35.CreateAccountMnemonicConfirmPage(), + child: const _i37.CreateAccountMnemonicConfirmPage(), ); }, CreateAccountCredentialsRoute.name: (routeData) { final args = routeData.argsAs(); - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: _i36.CreateAccountCredentialsPage( + child: _i38.CreateAccountCredentialsPage( appbarText: args.appbarText, key: args.key, ), ); }, CreateAccountTypeRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: const _i37.CreateAccountTypePage(), + child: const _i39.CreateAccountTypePage(), ); }, CreateAccountLoaderRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: const _i38.CreateAccountLoaderPage(), + child: const _i40.CreateAccountLoaderPage(), ); }, NoStableHashRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: const _i39.NoStableHashDialog(), + child: const _i41.NoStableHashDialog(), ); }, UploadedObjectRoute.name: (routeData) { final args = routeData.argsAs(); - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: _i40.UploadedObjectPage( + child: _i42.UploadedObjectPage( uploadedObject: args.uploadedObject, key: args.key, ), ); }, SettingsRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: const _i41.SettingsPage(), + child: const _i43.SettingsPage(), ); }, SectionsSubRoute.name: (routeData) { final args = routeData.argsAs(); - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: _i42.SectionsSubPage( + child: _i44.SectionsSubPage( initialState: args.initialState, key: args.key, ), @@ -458,68 +472,67 @@ abstract class $RootRouter extends _i52.RootStackRouter { }, TransBytesSubRoute.name: (routeData) { final args = routeData.argsAs(); - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: _i43.TransBytesSubPage( + child: _i45.TransBytesSubPage( initialState: args.initialState, key: args.key, ), ); }, GridSizeSubRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: const _i44.GridSizeSubPage(), + child: const _i46.GridSizeSubPage(), ); }, PixelRatioSubRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: const _i45.PixelRatioSubPage(), + child: const _i47.PixelRatioSubPage(), ); }, WalletNodeSubRoute.name: (routeData) { final args = routeData.argsAs(); - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: _i46.WalletNodeSubPage( + child: _i48.WalletNodeSubPage( initialState: args.initialState, key: args.key, ), ); }, ChooseAlgorithmSubRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: const _i47.ChooseAlgorithmSubPage(), + child: const _i49.ChooseAlgorithmSubPage(), ); }, StableHashSubRoute.name: (routeData) { final args = routeData.argsAs(); - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: _i48.StableHashSubPage( + child: _i50.StableHashSubPage( initialState: args.initialState, key: args.key, ), ); }, SettingsWrapperRoute.name: (routeData) { - return _i52.AutoRoutePage( + return _i53.AutoRoutePage( routeData: routeData, - child: const _i49.EmptySettingsRoute(), + child: const _i51.EmptySettingsRoute(), ); }, - ObjectsListRoute.name: (routeData) { - return _i52.AutoRoutePage( - routeData: routeData, - child: const _i50.ObjectsListPage(), - ); - }, - ExplorerRouteWrapper.name: (routeData) { - return _i52.AutoRoutePage( + RenameObjectRoute.name: (routeData) { + final args = routeData.argsAs(); + return _i53.AutoRoutePage( routeData: routeData, - child: _i52.WrappedRoute(child: const _i51.ExplorerPageWrapper()), + child: _i52.RenameObjectDialog( + snapshot: args.snapshot, + hashObject: args.hashObject, + key: args.key, + ), ); }, }; @@ -527,11 +540,11 @@ abstract class $RootRouter extends _i52.RootStackRouter { /// generated route for /// [_i1.ErrorPage] -class ErrorRoute extends _i52.PageRouteInfo { +class ErrorRoute extends _i53.PageRouteInfo { ErrorRoute({ required Object error, - _i53.Key? key, - List<_i52.PageRouteInfo>? children, + _i54.Key? key, + List<_i53.PageRouteInfo>? children, }) : super( ErrorRoute.name, args: ErrorRouteArgs( @@ -543,8 +556,8 @@ class ErrorRoute extends _i52.PageRouteInfo { static const String name = 'ErrorRoute'; - static const _i52.PageInfo page = - _i52.PageInfo(name); + static const _i53.PageInfo page = + _i53.PageInfo(name); } class ErrorRouteArgs { @@ -555,7 +568,7 @@ class ErrorRouteArgs { final Object error; - final _i53.Key? key; + final _i54.Key? key; @override String toString() { @@ -565,11 +578,11 @@ class ErrorRouteArgs { /// generated route for /// [_i2.DefaultLoadingDialog] -class DefaultLoadingRoute extends _i52.PageRouteInfo { +class DefaultLoadingRoute extends _i53.PageRouteInfo { DefaultLoadingRoute({ - _i53.Key? key, + _i54.Key? key, String? text, - List<_i52.PageRouteInfo>? children, + List<_i53.PageRouteInfo>? children, }) : super( DefaultLoadingRoute.name, args: DefaultLoadingRouteArgs( @@ -581,8 +594,8 @@ class DefaultLoadingRoute extends _i52.PageRouteInfo { static const String name = 'DefaultLoadingRoute'; - static const _i52.PageInfo page = - _i52.PageInfo(name); + static const _i53.PageInfo page = + _i53.PageInfo(name); } class DefaultLoadingRouteArgs { @@ -591,7 +604,7 @@ class DefaultLoadingRouteArgs { this.text, }); - final _i53.Key? key; + final _i54.Key? key; final String? text; @@ -603,12 +616,12 @@ class DefaultLoadingRouteArgs { /// generated route for /// [_i3.ComparePageWrapper] -class CompareRouteWrapper extends _i52.PageRouteInfo { +class CompareRouteWrapper extends _i53.PageRouteInfo { CompareRouteWrapper({ - required _i54.Snapshot origObj, - required _i55.HashObject hashObject, - _i53.Key? key, - List<_i52.PageRouteInfo>? children, + required _i55.Snapshot origObj, + required _i56.HashObject hashObject, + _i54.Key? key, + List<_i53.PageRouteInfo>? children, }) : super( CompareRouteWrapper.name, args: CompareRouteWrapperArgs( @@ -621,8 +634,8 @@ class CompareRouteWrapper extends _i52.PageRouteInfo { static const String name = 'CompareRouteWrapper'; - static const _i52.PageInfo page = - _i52.PageInfo(name); + static const _i53.PageInfo page = + _i53.PageInfo(name); } class CompareRouteWrapperArgs { @@ -632,11 +645,11 @@ class CompareRouteWrapperArgs { this.key, }); - final _i54.Snapshot origObj; + final _i55.Snapshot origObj; - final _i55.HashObject hashObject; + final _i56.HashObject hashObject; - final _i53.Key? key; + final _i54.Key? key; @override String toString() { @@ -646,13 +659,13 @@ class CompareRouteWrapperArgs { /// generated route for /// [_i4.PreviewPageWrapper] -class PreviewRouteWrapper extends _i52.PageRouteInfo { +class PreviewRouteWrapper extends _i53.PageRouteInfo { PreviewRouteWrapper({ - required _i55.HashObject? hashObject, - required _i54.Snapshot snapshot, - _i53.Key? key, + required _i56.HashObject? hashObject, + required _i55.Snapshot snapshot, + _i54.Key? key, bool createNewAnyway = false, - List<_i52.PageRouteInfo>? children, + List<_i53.PageRouteInfo>? children, }) : super( PreviewRouteWrapper.name, args: PreviewRouteWrapperArgs( @@ -666,8 +679,8 @@ class PreviewRouteWrapper extends _i52.PageRouteInfo { static const String name = 'PreviewRouteWrapper'; - static const _i52.PageInfo page = - _i52.PageInfo(name); + static const _i53.PageInfo page = + _i53.PageInfo(name); } class PreviewRouteWrapperArgs { @@ -678,11 +691,11 @@ class PreviewRouteWrapperArgs { this.createNewAnyway = false, }); - final _i55.HashObject? hashObject; + final _i56.HashObject? hashObject; - final _i54.Snapshot snapshot; + final _i55.Snapshot snapshot; - final _i53.Key? key; + final _i54.Key? key; final bool createNewAnyway; @@ -694,8 +707,8 @@ class PreviewRouteWrapperArgs { /// generated route for /// [_i5.PreviewPage] -class PreviewRoute extends _i52.PageRouteInfo { - const PreviewRoute({List<_i52.PageRouteInfo>? children}) +class PreviewRoute extends _i53.PageRouteInfo { + const PreviewRoute({List<_i53.PageRouteInfo>? children}) : super( PreviewRoute.name, initialChildren: children, @@ -703,17 +716,17 @@ class PreviewRoute extends _i52.PageRouteInfo { static const String name = 'PreviewRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for /// [_i6.RenameSnapshotDialog] -class RenameSnapshotRoute extends _i52.PageRouteInfo { +class RenameSnapshotRoute extends _i53.PageRouteInfo { RenameSnapshotRoute({ - required _i54.Snapshot snapshot, - required _i55.HashObject hashObject, - _i53.Key? key, - List<_i52.PageRouteInfo>? children, + required _i55.Snapshot snapshot, + required _i56.HashObject hashObject, + _i54.Key? key, + List<_i53.PageRouteInfo>? children, }) : super( RenameSnapshotRoute.name, args: RenameSnapshotRouteArgs( @@ -726,8 +739,8 @@ class RenameSnapshotRoute extends _i52.PageRouteInfo { static const String name = 'RenameSnapshotRoute'; - static const _i52.PageInfo page = - _i52.PageInfo(name); + static const _i53.PageInfo page = + _i53.PageInfo(name); } class RenameSnapshotRouteArgs { @@ -737,11 +750,11 @@ class RenameSnapshotRouteArgs { this.key, }); - final _i54.Snapshot snapshot; + final _i55.Snapshot snapshot; - final _i55.HashObject hashObject; + final _i56.HashObject hashObject; - final _i53.Key? key; + final _i54.Key? key; @override String toString() { @@ -751,12 +764,12 @@ class RenameSnapshotRouteArgs { /// generated route for /// [_i7.SaveHashDialog] -class SaveHashRoute extends _i52.PageRouteInfo { +class SaveHashRoute extends _i53.PageRouteInfo { SaveHashRoute({ - required _i54.Snapshot snapshot, - required _i55.HashObject hashObject, - _i53.Key? key, - List<_i52.PageRouteInfo>? children, + required _i55.Snapshot snapshot, + required _i56.HashObject hashObject, + _i54.Key? key, + List<_i53.PageRouteInfo>? children, }) : super( SaveHashRoute.name, args: SaveHashRouteArgs( @@ -769,8 +782,8 @@ class SaveHashRoute extends _i52.PageRouteInfo { static const String name = 'SaveHashRoute'; - static const _i52.PageInfo page = - _i52.PageInfo(name); + static const _i53.PageInfo page = + _i53.PageInfo(name); } class SaveHashRouteArgs { @@ -780,11 +793,11 @@ class SaveHashRouteArgs { this.key, }); - final _i54.Snapshot snapshot; + final _i55.Snapshot snapshot; - final _i55.HashObject hashObject; + final _i56.HashObject hashObject; - final _i53.Key? key; + final _i54.Key? key; @override String toString() { @@ -794,8 +807,8 @@ class SaveHashRouteArgs { /// generated route for /// [_i8.DeleteSnapshotDialog] -class DeleteSnapshotRoute extends _i52.PageRouteInfo { - const DeleteSnapshotRoute({List<_i52.PageRouteInfo>? children}) +class DeleteSnapshotRoute extends _i53.PageRouteInfo { + const DeleteSnapshotRoute({List<_i53.PageRouteInfo>? children}) : super( DeleteSnapshotRoute.name, initialChildren: children, @@ -803,16 +816,16 @@ class DeleteSnapshotRoute extends _i52.PageRouteInfo { static const String name = 'DeleteSnapshotRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for /// [_i9.SaveObjectDialog] -class SaveObjectRoute extends _i52.PageRouteInfo { +class SaveObjectRoute extends _i53.PageRouteInfo { SaveObjectRoute({ - required _i54.Snapshot snapshot, - _i53.Key? key, - List<_i52.PageRouteInfo>? children, + required _i55.Snapshot snapshot, + _i54.Key? key, + List<_i53.PageRouteInfo>? children, }) : super( SaveObjectRoute.name, args: SaveObjectRouteArgs( @@ -824,8 +837,8 @@ class SaveObjectRoute extends _i52.PageRouteInfo { static const String name = 'SaveObjectRoute'; - static const _i52.PageInfo page = - _i52.PageInfo(name); + static const _i53.PageInfo page = + _i53.PageInfo(name); } class SaveObjectRouteArgs { @@ -834,9 +847,9 @@ class SaveObjectRouteArgs { this.key, }); - final _i54.Snapshot snapshot; + final _i55.Snapshot snapshot; - final _i53.Key? key; + final _i54.Key? key; @override String toString() { @@ -846,8 +859,8 @@ class SaveObjectRouteArgs { /// generated route for /// [_i10.ScanPageWrapper] -class ScanRouteWrapper extends _i52.PageRouteInfo { - const ScanRouteWrapper({List<_i52.PageRouteInfo>? children}) +class ScanRouteWrapper extends _i53.PageRouteInfo { + const ScanRouteWrapper({List<_i53.PageRouteInfo>? children}) : super( ScanRouteWrapper.name, initialChildren: children, @@ -855,13 +868,13 @@ class ScanRouteWrapper extends _i52.PageRouteInfo { static const String name = 'ScanRouteWrapper'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for /// [_i11.ScanPage] -class ScanRoute extends _i52.PageRouteInfo { - const ScanRoute({List<_i52.PageRouteInfo>? children}) +class ScanRoute extends _i53.PageRouteInfo { + const ScanRoute({List<_i53.PageRouteInfo>? children}) : super( ScanRoute.name, initialChildren: children, @@ -869,16 +882,16 @@ class ScanRoute extends _i52.PageRouteInfo { static const String name = 'ScanRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for /// [_i12.LoginPage] -class LoginRoute extends _i52.PageRouteInfo { +class LoginRoute extends _i53.PageRouteInfo { LoginRoute({ - _i53.Key? key, + _i54.Key? key, void Function(bool)? onLoginResult, - List<_i52.PageRouteInfo>? children, + List<_i53.PageRouteInfo>? children, }) : super( LoginRoute.name, args: LoginRouteArgs( @@ -890,8 +903,8 @@ class LoginRoute extends _i52.PageRouteInfo { static const String name = 'LoginRoute'; - static const _i52.PageInfo page = - _i52.PageInfo(name); + static const _i53.PageInfo page = + _i53.PageInfo(name); } class LoginRouteArgs { @@ -900,7 +913,7 @@ class LoginRouteArgs { this.onLoginResult, }); - final _i53.Key? key; + final _i54.Key? key; final void Function(bool)? onLoginResult; @@ -912,8 +925,8 @@ class LoginRouteArgs { /// generated route for /// [_i13.HomePage] -class HomeRoute extends _i52.PageRouteInfo { - const HomeRoute({List<_i52.PageRouteInfo>? children}) +class HomeRoute extends _i53.PageRouteInfo { + const HomeRoute({List<_i53.PageRouteInfo>? children}) : super( HomeRoute.name, initialChildren: children, @@ -921,13 +934,13 @@ class HomeRoute extends _i52.PageRouteInfo { static const String name = 'HomeRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for /// [_i14.EmptyInitialRoute] -class InitialWrapperRoute extends _i52.PageRouteInfo { - const InitialWrapperRoute({List<_i52.PageRouteInfo>? children}) +class InitialWrapperRoute extends _i53.PageRouteInfo { + const InitialWrapperRoute({List<_i53.PageRouteInfo>? children}) : super( InitialWrapperRoute.name, initialChildren: children, @@ -935,13 +948,13 @@ class InitialWrapperRoute extends _i52.PageRouteInfo { static const String name = 'InitialWrapperRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for /// [_i15.D3PRPCPage] -class D3PRPCRoute extends _i52.PageRouteInfo { - const D3PRPCRoute({List<_i52.PageRouteInfo>? children}) +class D3PRPCRoute extends _i53.PageRouteInfo { + const D3PRPCRoute({List<_i53.PageRouteInfo>? children}) : super( D3PRPCRoute.name, initialChildren: children, @@ -949,13 +962,13 @@ class D3PRPCRoute extends _i52.PageRouteInfo { static const String name = 'D3PRPCRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for /// [_i16.D3PRPCPageWrapper] -class D3PRPCRouteWrapper extends _i52.PageRouteInfo { - const D3PRPCRouteWrapper({List<_i52.PageRouteInfo>? children}) +class D3PRPCRouteWrapper extends _i53.PageRouteInfo { + const D3PRPCRouteWrapper({List<_i53.PageRouteInfo>? children}) : super( D3PRPCRouteWrapper.name, initialChildren: children, @@ -963,13 +976,41 @@ class D3PRPCRouteWrapper extends _i52.PageRouteInfo { static const String name = 'D3PRPCRouteWrapper'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); +} + +/// generated route for +/// [_i17.ObjectsListPage] +class ObjectsListRoute extends _i53.PageRouteInfo { + const ObjectsListRoute({List<_i53.PageRouteInfo>? children}) + : super( + ObjectsListRoute.name, + initialChildren: children, + ); + + static const String name = 'ObjectsListRoute'; + + static const _i53.PageInfo page = _i53.PageInfo(name); +} + +/// generated route for +/// [_i18.ExplorerPageWrapper] +class ExplorerRouteWrapper extends _i53.PageRouteInfo { + const ExplorerRouteWrapper({List<_i53.PageRouteInfo>? children}) + : super( + ExplorerRouteWrapper.name, + initialChildren: children, + ); + + static const String name = 'ExplorerRouteWrapper'; + + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for -/// [_i17.ContactsPage] -class ContactsRoute extends _i52.PageRouteInfo { - const ContactsRoute({List<_i52.PageRouteInfo>? children}) +/// [_i19.ContactsPage] +class ContactsRoute extends _i53.PageRouteInfo { + const ContactsRoute({List<_i53.PageRouteInfo>? children}) : super( ContactsRoute.name, initialChildren: children, @@ -977,16 +1018,16 @@ class ContactsRoute extends _i52.PageRouteInfo { static const String name = 'ContactsRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for -/// [_i18.DeleteContactDialog] -class DeleteContactRoute extends _i52.PageRouteInfo { +/// [_i20.DeleteContactDialog] +class DeleteContactRoute extends _i53.PageRouteInfo { DeleteContactRoute({ - required _i56.Contact contact, - _i53.Key? key, - List<_i52.PageRouteInfo>? children, + required _i57.Contact contact, + _i54.Key? key, + List<_i53.PageRouteInfo>? children, }) : super( DeleteContactRoute.name, args: DeleteContactRouteArgs( @@ -998,8 +1039,8 @@ class DeleteContactRoute extends _i52.PageRouteInfo { static const String name = 'DeleteContactRoute'; - static const _i52.PageInfo page = - _i52.PageInfo(name); + static const _i53.PageInfo page = + _i53.PageInfo(name); } class DeleteContactRouteArgs { @@ -1008,9 +1049,9 @@ class DeleteContactRouteArgs { this.key, }); - final _i56.Contact contact; + final _i57.Contact contact; - final _i53.Key? key; + final _i54.Key? key; @override String toString() { @@ -1019,9 +1060,9 @@ class DeleteContactRouteArgs { } /// generated route for -/// [_i19.RemoveAccountDialog] -class RemoveAccountRoute extends _i52.PageRouteInfo { - const RemoveAccountRoute({List<_i52.PageRouteInfo>? children}) +/// [_i21.RemoveAccountDialog] +class RemoveAccountRoute extends _i53.PageRouteInfo { + const RemoveAccountRoute({List<_i53.PageRouteInfo>? children}) : super( RemoveAccountRoute.name, initialChildren: children, @@ -1029,13 +1070,13 @@ class RemoveAccountRoute extends _i52.PageRouteInfo { static const String name = 'RemoveAccountRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for -/// [_i20.RecievePage] -class RecieveRoute extends _i52.PageRouteInfo { - const RecieveRoute({List<_i52.PageRouteInfo>? children}) +/// [_i22.RecievePage] +class RecieveRoute extends _i53.PageRouteInfo { + const RecieveRoute({List<_i53.PageRouteInfo>? children}) : super( RecieveRoute.name, initialChildren: children, @@ -1043,13 +1084,13 @@ class RecieveRoute extends _i52.PageRouteInfo { static const String name = 'RecieveRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for -/// [_i21.NotificationsPage] -class NotificationsRoute extends _i52.PageRouteInfo { - const NotificationsRoute({List<_i52.PageRouteInfo>? children}) +/// [_i23.NotificationsPage] +class NotificationsRoute extends _i53.PageRouteInfo { + const NotificationsRoute({List<_i53.PageRouteInfo>? children}) : super( NotificationsRoute.name, initialChildren: children, @@ -1057,15 +1098,15 @@ class NotificationsRoute extends _i52.PageRouteInfo { static const String name = 'NotificationsRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for -/// [_i22.AddContactPage] -class AddContactRoute extends _i52.PageRouteInfo { +/// [_i24.AddContactPage] +class AddContactRoute extends _i53.PageRouteInfo { AddContactRoute({ - _i53.Key? key, - List<_i52.PageRouteInfo>? children, + _i54.Key? key, + List<_i53.PageRouteInfo>? children, }) : super( AddContactRoute.name, args: AddContactRouteArgs(key: key), @@ -1074,14 +1115,14 @@ class AddContactRoute extends _i52.PageRouteInfo { static const String name = 'AddContactRoute'; - static const _i52.PageInfo page = - _i52.PageInfo(name); + static const _i53.PageInfo page = + _i53.PageInfo(name); } class AddContactRouteArgs { const AddContactRouteArgs({this.key}); - final _i53.Key? key; + final _i54.Key? key; @override String toString() { @@ -1090,9 +1131,9 @@ class AddContactRouteArgs { } /// generated route for -/// [_i23.WalletPage] -class WalletRoute extends _i52.PageRouteInfo { - const WalletRoute({List<_i52.PageRouteInfo>? children}) +/// [_i25.WalletPage] +class WalletRoute extends _i53.PageRouteInfo { + const WalletRoute({List<_i53.PageRouteInfo>? children}) : super( WalletRoute.name, initialChildren: children, @@ -1100,13 +1141,13 @@ class WalletRoute extends _i52.PageRouteInfo { static const String name = 'WalletRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for -/// [_i24.WalletPageWrapper] -class WalletRouteWrapper extends _i52.PageRouteInfo { - const WalletRouteWrapper({List<_i52.PageRouteInfo>? children}) +/// [_i26.WalletPageWrapper] +class WalletRouteWrapper extends _i53.PageRouteInfo { + const WalletRouteWrapper({List<_i53.PageRouteInfo>? children}) : super( WalletRouteWrapper.name, initialChildren: children, @@ -1114,17 +1155,17 @@ class WalletRouteWrapper extends _i52.PageRouteInfo { static const String name = 'WalletRouteWrapper'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for -/// [_i25.TransferPageWrapper] +/// [_i27.TransferPageWrapper] class TransferRouteWrapper - extends _i52.PageRouteInfo { + extends _i53.PageRouteInfo { TransferRouteWrapper({ - required _i57.TransferMetaDTO metadata, - _i53.Key? key, - List<_i52.PageRouteInfo>? children, + required _i58.TransferMetaDTO metadata, + _i54.Key? key, + List<_i53.PageRouteInfo>? children, }) : super( TransferRouteWrapper.name, args: TransferRouteWrapperArgs( @@ -1136,8 +1177,8 @@ class TransferRouteWrapper static const String name = 'TransferRouteWrapper'; - static const _i52.PageInfo page = - _i52.PageInfo(name); + static const _i53.PageInfo page = + _i53.PageInfo(name); } class TransferRouteWrapperArgs { @@ -1146,9 +1187,9 @@ class TransferRouteWrapperArgs { this.key, }); - final _i57.TransferMetaDTO metadata; + final _i58.TransferMetaDTO metadata; - final _i53.Key? key; + final _i54.Key? key; @override String toString() { @@ -1157,11 +1198,11 @@ class TransferRouteWrapperArgs { } /// generated route for -/// [_i26.TransferPage] -class TransferRoute extends _i52.PageRouteInfo { +/// [_i28.TransferPage] +class TransferRoute extends _i53.PageRouteInfo { TransferRoute({ - _i53.Key? key, - List<_i52.PageRouteInfo>? children, + _i54.Key? key, + List<_i53.PageRouteInfo>? children, }) : super( TransferRoute.name, args: TransferRouteArgs(key: key), @@ -1170,14 +1211,14 @@ class TransferRoute extends _i52.PageRouteInfo { static const String name = 'TransferRoute'; - static const _i52.PageInfo page = - _i52.PageInfo(name); + static const _i53.PageInfo page = + _i53.PageInfo(name); } class TransferRouteArgs { const TransferRouteArgs({this.key}); - final _i53.Key? key; + final _i54.Key? key; @override String toString() { @@ -1186,13 +1227,13 @@ class TransferRouteArgs { } /// generated route for -/// [_i27.NonNativeTokenPageWrapper] +/// [_i29.NonNativeTokenPageWrapper] class NonNativeTokenRouteWrapper - extends _i52.PageRouteInfo { + extends _i53.PageRouteInfo { NonNativeTokenRouteWrapper({ - required _i58.GetExtrinsicsUseCaseParams params, - _i59.Key? key, - List<_i52.PageRouteInfo>? children, + required _i59.GetExtrinsicsUseCaseParams params, + _i60.Key? key, + List<_i53.PageRouteInfo>? children, }) : super( NonNativeTokenRouteWrapper.name, args: NonNativeTokenRouteWrapperArgs( @@ -1204,8 +1245,8 @@ class NonNativeTokenRouteWrapper static const String name = 'NonNativeTokenRouteWrapper'; - static const _i52.PageInfo page = - _i52.PageInfo(name); + static const _i53.PageInfo page = + _i53.PageInfo(name); } class NonNativeTokenRouteWrapperArgs { @@ -1214,9 +1255,9 @@ class NonNativeTokenRouteWrapperArgs { this.key, }); - final _i58.GetExtrinsicsUseCaseParams params; + final _i59.GetExtrinsicsUseCaseParams params; - final _i59.Key? key; + final _i60.Key? key; @override String toString() { @@ -1225,9 +1266,9 @@ class NonNativeTokenRouteWrapperArgs { } /// generated route for -/// [_i28.TransactionsHistoryPageWrapper] -class TransactionsHistoryRouteWrapper extends _i52.PageRouteInfo { - const TransactionsHistoryRouteWrapper({List<_i52.PageRouteInfo>? children}) +/// [_i30.TransactionsHistoryPageWrapper] +class TransactionsHistoryRouteWrapper extends _i53.PageRouteInfo { + const TransactionsHistoryRouteWrapper({List<_i53.PageRouteInfo>? children}) : super( TransactionsHistoryRouteWrapper.name, initialChildren: children, @@ -1235,16 +1276,16 @@ class TransactionsHistoryRouteWrapper extends _i52.PageRouteInfo { static const String name = 'TransactionsHistoryRouteWrapper'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for -/// [_i29.ImportRawseedFormPage] +/// [_i31.ImportRawseedFormPage] class ImportRawseedFormRoute - extends _i52.PageRouteInfo { + extends _i53.PageRouteInfo { ImportRawseedFormRoute({ - _i53.Key? key, - List<_i52.PageRouteInfo>? children, + _i54.Key? key, + List<_i53.PageRouteInfo>? children, }) : super( ImportRawseedFormRoute.name, args: ImportRawseedFormRouteArgs(key: key), @@ -1253,14 +1294,14 @@ class ImportRawseedFormRoute static const String name = 'ImportRawseedFormRoute'; - static const _i52.PageInfo page = - _i52.PageInfo(name); + static const _i53.PageInfo page = + _i53.PageInfo(name); } class ImportRawseedFormRouteArgs { const ImportRawseedFormRouteArgs({this.key}); - final _i53.Key? key; + final _i54.Key? key; @override String toString() { @@ -1269,9 +1310,9 @@ class ImportRawseedFormRouteArgs { } /// generated route for -/// [_i30.CreateAccountPageWrapper] -class CreateAccountRouteWrapper extends _i52.PageRouteInfo { - const CreateAccountRouteWrapper({List<_i52.PageRouteInfo>? children}) +/// [_i32.CreateAccountPageWrapper] +class CreateAccountRouteWrapper extends _i53.PageRouteInfo { + const CreateAccountRouteWrapper({List<_i53.PageRouteInfo>? children}) : super( CreateAccountRouteWrapper.name, initialChildren: children, @@ -1279,13 +1320,13 @@ class CreateAccountRouteWrapper extends _i52.PageRouteInfo { static const String name = 'CreateAccountRouteWrapper'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for -/// [_i31.CreateAccountFromObjectPage] -class CreateAccountFromObjectRoute extends _i52.PageRouteInfo { - const CreateAccountFromObjectRoute({List<_i52.PageRouteInfo>? children}) +/// [_i33.CreateAccountFromObjectPage] +class CreateAccountFromObjectRoute extends _i53.PageRouteInfo { + const CreateAccountFromObjectRoute({List<_i53.PageRouteInfo>? children}) : super( CreateAccountFromObjectRoute.name, initialChildren: children, @@ -1293,16 +1334,16 @@ class CreateAccountFromObjectRoute extends _i52.PageRouteInfo { static const String name = 'CreateAccountFromObjectRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for -/// [_i32.ImportMnemonicFormPage] +/// [_i34.ImportMnemonicFormPage] class ImportMnemonicFormRoute - extends _i52.PageRouteInfo { + extends _i53.PageRouteInfo { ImportMnemonicFormRoute({ - _i53.Key? key, - List<_i52.PageRouteInfo>? children, + _i54.Key? key, + List<_i53.PageRouteInfo>? children, }) : super( ImportMnemonicFormRoute.name, args: ImportMnemonicFormRouteArgs(key: key), @@ -1311,14 +1352,14 @@ class ImportMnemonicFormRoute static const String name = 'ImportMnemonicFormRoute'; - static const _i52.PageInfo page = - _i52.PageInfo(name); + static const _i53.PageInfo page = + _i53.PageInfo(name); } class ImportMnemonicFormRouteArgs { const ImportMnemonicFormRouteArgs({this.key}); - final _i53.Key? key; + final _i54.Key? key; @override String toString() { @@ -1327,9 +1368,9 @@ class ImportMnemonicFormRouteArgs { } /// generated route for -/// [_i33.CreateAccountInfoPage] -class CreateAccountInfoRoute extends _i52.PageRouteInfo { - const CreateAccountInfoRoute({List<_i52.PageRouteInfo>? children}) +/// [_i35.CreateAccountInfoPage] +class CreateAccountInfoRoute extends _i53.PageRouteInfo { + const CreateAccountInfoRoute({List<_i53.PageRouteInfo>? children}) : super( CreateAccountInfoRoute.name, initialChildren: children, @@ -1337,13 +1378,13 @@ class CreateAccountInfoRoute extends _i52.PageRouteInfo { static const String name = 'CreateAccountInfoRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for -/// [_i34.CreateAccountMnemonicBackupPage] -class CreateAccountMnemonicBackupRoute extends _i52.PageRouteInfo { - const CreateAccountMnemonicBackupRoute({List<_i52.PageRouteInfo>? children}) +/// [_i36.CreateAccountMnemonicBackupPage] +class CreateAccountMnemonicBackupRoute extends _i53.PageRouteInfo { + const CreateAccountMnemonicBackupRoute({List<_i53.PageRouteInfo>? children}) : super( CreateAccountMnemonicBackupRoute.name, initialChildren: children, @@ -1351,13 +1392,13 @@ class CreateAccountMnemonicBackupRoute extends _i52.PageRouteInfo { static const String name = 'CreateAccountMnemonicBackupRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for -/// [_i35.CreateAccountMnemonicConfirmPage] -class CreateAccountMnemonicConfirmRoute extends _i52.PageRouteInfo { - const CreateAccountMnemonicConfirmRoute({List<_i52.PageRouteInfo>? children}) +/// [_i37.CreateAccountMnemonicConfirmPage] +class CreateAccountMnemonicConfirmRoute extends _i53.PageRouteInfo { + const CreateAccountMnemonicConfirmRoute({List<_i53.PageRouteInfo>? children}) : super( CreateAccountMnemonicConfirmRoute.name, initialChildren: children, @@ -1365,17 +1406,17 @@ class CreateAccountMnemonicConfirmRoute extends _i52.PageRouteInfo { static const String name = 'CreateAccountMnemonicConfirmRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for -/// [_i36.CreateAccountCredentialsPage] +/// [_i38.CreateAccountCredentialsPage] class CreateAccountCredentialsRoute - extends _i52.PageRouteInfo { + extends _i53.PageRouteInfo { CreateAccountCredentialsRoute({ required String appbarText, - _i53.Key? key, - List<_i52.PageRouteInfo>? children, + _i54.Key? key, + List<_i53.PageRouteInfo>? children, }) : super( CreateAccountCredentialsRoute.name, args: CreateAccountCredentialsRouteArgs( @@ -1387,8 +1428,8 @@ class CreateAccountCredentialsRoute static const String name = 'CreateAccountCredentialsRoute'; - static const _i52.PageInfo page = - _i52.PageInfo(name); + static const _i53.PageInfo page = + _i53.PageInfo(name); } class CreateAccountCredentialsRouteArgs { @@ -1399,7 +1440,7 @@ class CreateAccountCredentialsRouteArgs { final String appbarText; - final _i53.Key? key; + final _i54.Key? key; @override String toString() { @@ -1408,9 +1449,9 @@ class CreateAccountCredentialsRouteArgs { } /// generated route for -/// [_i37.CreateAccountTypePage] -class CreateAccountTypeRoute extends _i52.PageRouteInfo { - const CreateAccountTypeRoute({List<_i52.PageRouteInfo>? children}) +/// [_i39.CreateAccountTypePage] +class CreateAccountTypeRoute extends _i53.PageRouteInfo { + const CreateAccountTypeRoute({List<_i53.PageRouteInfo>? children}) : super( CreateAccountTypeRoute.name, initialChildren: children, @@ -1418,13 +1459,13 @@ class CreateAccountTypeRoute extends _i52.PageRouteInfo { static const String name = 'CreateAccountTypeRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for -/// [_i38.CreateAccountLoaderPage] -class CreateAccountLoaderRoute extends _i52.PageRouteInfo { - const CreateAccountLoaderRoute({List<_i52.PageRouteInfo>? children}) +/// [_i40.CreateAccountLoaderPage] +class CreateAccountLoaderRoute extends _i53.PageRouteInfo { + const CreateAccountLoaderRoute({List<_i53.PageRouteInfo>? children}) : super( CreateAccountLoaderRoute.name, initialChildren: children, @@ -1432,13 +1473,13 @@ class CreateAccountLoaderRoute extends _i52.PageRouteInfo { static const String name = 'CreateAccountLoaderRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for -/// [_i39.NoStableHashDialog] -class NoStableHashRoute extends _i52.PageRouteInfo { - const NoStableHashRoute({List<_i52.PageRouteInfo>? children}) +/// [_i41.NoStableHashDialog] +class NoStableHashRoute extends _i53.PageRouteInfo { + const NoStableHashRoute({List<_i53.PageRouteInfo>? children}) : super( NoStableHashRoute.name, initialChildren: children, @@ -1446,16 +1487,16 @@ class NoStableHashRoute extends _i52.PageRouteInfo { static const String name = 'NoStableHashRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for -/// [_i40.UploadedObjectPage] -class UploadedObjectRoute extends _i52.PageRouteInfo { +/// [_i42.UploadedObjectPage] +class UploadedObjectRoute extends _i53.PageRouteInfo { UploadedObjectRoute({ - required _i60.UploadedObject uploadedObject, - _i53.Key? key, - List<_i52.PageRouteInfo>? children, + required _i61.UploadedObject uploadedObject, + _i54.Key? key, + List<_i53.PageRouteInfo>? children, }) : super( UploadedObjectRoute.name, args: UploadedObjectRouteArgs( @@ -1467,8 +1508,8 @@ class UploadedObjectRoute extends _i52.PageRouteInfo { static const String name = 'UploadedObjectRoute'; - static const _i52.PageInfo page = - _i52.PageInfo(name); + static const _i53.PageInfo page = + _i53.PageInfo(name); } class UploadedObjectRouteArgs { @@ -1477,9 +1518,9 @@ class UploadedObjectRouteArgs { this.key, }); - final _i60.UploadedObject uploadedObject; + final _i61.UploadedObject uploadedObject; - final _i53.Key? key; + final _i54.Key? key; @override String toString() { @@ -1488,9 +1529,9 @@ class UploadedObjectRouteArgs { } /// generated route for -/// [_i41.SettingsPage] -class SettingsRoute extends _i52.PageRouteInfo { - const SettingsRoute({List<_i52.PageRouteInfo>? children}) +/// [_i43.SettingsPage] +class SettingsRoute extends _i53.PageRouteInfo { + const SettingsRoute({List<_i53.PageRouteInfo>? children}) : super( SettingsRoute.name, initialChildren: children, @@ -1498,16 +1539,16 @@ class SettingsRoute extends _i52.PageRouteInfo { static const String name = 'SettingsRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for -/// [_i42.SectionsSubPage] -class SectionsSubRoute extends _i52.PageRouteInfo { +/// [_i44.SectionsSubPage] +class SectionsSubRoute extends _i53.PageRouteInfo { SectionsSubRoute({ - required _i61.GlobalSettings initialState, - _i53.Key? key, - List<_i52.PageRouteInfo>? children, + required _i62.GlobalSettings initialState, + _i54.Key? key, + List<_i53.PageRouteInfo>? children, }) : super( SectionsSubRoute.name, args: SectionsSubRouteArgs( @@ -1519,8 +1560,8 @@ class SectionsSubRoute extends _i52.PageRouteInfo { static const String name = 'SectionsSubRoute'; - static const _i52.PageInfo page = - _i52.PageInfo(name); + static const _i53.PageInfo page = + _i53.PageInfo(name); } class SectionsSubRouteArgs { @@ -1529,9 +1570,9 @@ class SectionsSubRouteArgs { this.key, }); - final _i61.GlobalSettings initialState; + final _i62.GlobalSettings initialState; - final _i53.Key? key; + final _i54.Key? key; @override String toString() { @@ -1540,12 +1581,12 @@ class SectionsSubRouteArgs { } /// generated route for -/// [_i43.TransBytesSubPage] -class TransBytesSubRoute extends _i52.PageRouteInfo { +/// [_i45.TransBytesSubPage] +class TransBytesSubRoute extends _i53.PageRouteInfo { TransBytesSubRoute({ - required _i61.GlobalSettings initialState, - _i53.Key? key, - List<_i52.PageRouteInfo>? children, + required _i62.GlobalSettings initialState, + _i54.Key? key, + List<_i53.PageRouteInfo>? children, }) : super( TransBytesSubRoute.name, args: TransBytesSubRouteArgs( @@ -1557,8 +1598,8 @@ class TransBytesSubRoute extends _i52.PageRouteInfo { static const String name = 'TransBytesSubRoute'; - static const _i52.PageInfo page = - _i52.PageInfo(name); + static const _i53.PageInfo page = + _i53.PageInfo(name); } class TransBytesSubRouteArgs { @@ -1567,9 +1608,9 @@ class TransBytesSubRouteArgs { this.key, }); - final _i61.GlobalSettings initialState; + final _i62.GlobalSettings initialState; - final _i53.Key? key; + final _i54.Key? key; @override String toString() { @@ -1578,9 +1619,9 @@ class TransBytesSubRouteArgs { } /// generated route for -/// [_i44.GridSizeSubPage] -class GridSizeSubRoute extends _i52.PageRouteInfo { - const GridSizeSubRoute({List<_i52.PageRouteInfo>? children}) +/// [_i46.GridSizeSubPage] +class GridSizeSubRoute extends _i53.PageRouteInfo { + const GridSizeSubRoute({List<_i53.PageRouteInfo>? children}) : super( GridSizeSubRoute.name, initialChildren: children, @@ -1588,13 +1629,13 @@ class GridSizeSubRoute extends _i52.PageRouteInfo { static const String name = 'GridSizeSubRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for -/// [_i45.PixelRatioSubPage] -class PixelRatioSubRoute extends _i52.PageRouteInfo { - const PixelRatioSubRoute({List<_i52.PageRouteInfo>? children}) +/// [_i47.PixelRatioSubPage] +class PixelRatioSubRoute extends _i53.PageRouteInfo { + const PixelRatioSubRoute({List<_i53.PageRouteInfo>? children}) : super( PixelRatioSubRoute.name, initialChildren: children, @@ -1602,16 +1643,16 @@ class PixelRatioSubRoute extends _i52.PageRouteInfo { static const String name = 'PixelRatioSubRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for -/// [_i46.WalletNodeSubPage] -class WalletNodeSubRoute extends _i52.PageRouteInfo { +/// [_i48.WalletNodeSubPage] +class WalletNodeSubRoute extends _i53.PageRouteInfo { WalletNodeSubRoute({ - required _i61.GlobalSettings initialState, - _i53.Key? key, - List<_i52.PageRouteInfo>? children, + required _i62.GlobalSettings initialState, + _i54.Key? key, + List<_i53.PageRouteInfo>? children, }) : super( WalletNodeSubRoute.name, args: WalletNodeSubRouteArgs( @@ -1623,8 +1664,8 @@ class WalletNodeSubRoute extends _i52.PageRouteInfo { static const String name = 'WalletNodeSubRoute'; - static const _i52.PageInfo page = - _i52.PageInfo(name); + static const _i53.PageInfo page = + _i53.PageInfo(name); } class WalletNodeSubRouteArgs { @@ -1633,9 +1674,9 @@ class WalletNodeSubRouteArgs { this.key, }); - final _i61.GlobalSettings initialState; + final _i62.GlobalSettings initialState; - final _i53.Key? key; + final _i54.Key? key; @override String toString() { @@ -1644,9 +1685,9 @@ class WalletNodeSubRouteArgs { } /// generated route for -/// [_i47.ChooseAlgorithmSubPage] -class ChooseAlgorithmSubRoute extends _i52.PageRouteInfo { - const ChooseAlgorithmSubRoute({List<_i52.PageRouteInfo>? children}) +/// [_i49.ChooseAlgorithmSubPage] +class ChooseAlgorithmSubRoute extends _i53.PageRouteInfo { + const ChooseAlgorithmSubRoute({List<_i53.PageRouteInfo>? children}) : super( ChooseAlgorithmSubRoute.name, initialChildren: children, @@ -1654,16 +1695,16 @@ class ChooseAlgorithmSubRoute extends _i52.PageRouteInfo { static const String name = 'ChooseAlgorithmSubRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for -/// [_i48.StableHashSubPage] -class StableHashSubRoute extends _i52.PageRouteInfo { +/// [_i50.StableHashSubPage] +class StableHashSubRoute extends _i53.PageRouteInfo { StableHashSubRoute({ - required _i61.GlobalSettings initialState, - _i53.Key? key, - List<_i52.PageRouteInfo>? children, + required _i62.GlobalSettings initialState, + _i54.Key? key, + List<_i53.PageRouteInfo>? children, }) : super( StableHashSubRoute.name, args: StableHashSubRouteArgs( @@ -1675,8 +1716,8 @@ class StableHashSubRoute extends _i52.PageRouteInfo { static const String name = 'StableHashSubRoute'; - static const _i52.PageInfo page = - _i52.PageInfo(name); + static const _i53.PageInfo page = + _i53.PageInfo(name); } class StableHashSubRouteArgs { @@ -1685,9 +1726,9 @@ class StableHashSubRouteArgs { this.key, }); - final _i61.GlobalSettings initialState; + final _i62.GlobalSettings initialState; - final _i53.Key? key; + final _i54.Key? key; @override String toString() { @@ -1696,9 +1737,9 @@ class StableHashSubRouteArgs { } /// generated route for -/// [_i49.EmptySettingsRoute] -class SettingsWrapperRoute extends _i52.PageRouteInfo { - const SettingsWrapperRoute({List<_i52.PageRouteInfo>? children}) +/// [_i51.EmptySettingsRoute] +class SettingsWrapperRoute extends _i53.PageRouteInfo { + const SettingsWrapperRoute({List<_i53.PageRouteInfo>? children}) : super( SettingsWrapperRoute.name, initialChildren: children, @@ -1706,33 +1747,48 @@ class SettingsWrapperRoute extends _i52.PageRouteInfo { static const String name = 'SettingsWrapperRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = _i53.PageInfo(name); } /// generated route for -/// [_i50.ObjectsListPage] -class ObjectsListRoute extends _i52.PageRouteInfo { - const ObjectsListRoute({List<_i52.PageRouteInfo>? children}) - : super( - ObjectsListRoute.name, +/// [_i52.RenameObjectDialog] +class RenameObjectRoute extends _i53.PageRouteInfo { + RenameObjectRoute({ + required _i55.Snapshot snapshot, + required _i56.HashObject hashObject, + _i54.Key? key, + List<_i53.PageRouteInfo>? children, + }) : super( + RenameObjectRoute.name, + args: RenameObjectRouteArgs( + snapshot: snapshot, + hashObject: hashObject, + key: key, + ), initialChildren: children, ); - static const String name = 'ObjectsListRoute'; + static const String name = 'RenameObjectRoute'; - static const _i52.PageInfo page = _i52.PageInfo(name); + static const _i53.PageInfo page = + _i53.PageInfo(name); } -/// generated route for -/// [_i51.ExplorerPageWrapper] -class ExplorerRouteWrapper extends _i52.PageRouteInfo { - const ExplorerRouteWrapper({List<_i52.PageRouteInfo>? children}) - : super( - ExplorerRouteWrapper.name, - initialChildren: children, - ); +class RenameObjectRouteArgs { + const RenameObjectRouteArgs({ + required this.snapshot, + required this.hashObject, + this.key, + }); - static const String name = 'ExplorerRouteWrapper'; + final _i55.Snapshot snapshot; + + final _i56.HashObject hashObject; - static const _i52.PageInfo page = _i52.PageInfo(name); + final _i54.Key? key; + + @override + String toString() { + return 'RenameObjectRouteArgs{snapshot: $snapshot, hashObject: $hashObject, key: $key}'; + } } diff --git a/lib/setup.dart b/lib/setup.dart index d68e4142..719b6e42 100644 --- a/lib/setup.dart +++ b/lib/setup.dart @@ -1,3 +1,4 @@ +import 'package:app_install_date/app_install_date.dart'; import 'package:ferry/ferry.dart'; import 'package:get_it/get_it.dart'; import 'package:logger/logger.dart'; @@ -5,26 +6,37 @@ import 'package:package_info_plus/package_info_plus.dart'; import 'package:threedp_graphql/features/transfers_history/data/repositories/transfers_repository.dart'; import 'package:threedp_graphql/threedp_graphql.dart'; import 'package:threedpass/core/polkawallet/bloc/app_service_cubit.dart'; +import 'package:threedpass/core/polkawallet/utils/log.dart'; +import 'package:threedpass/core/utils/m_app_install_date.dart'; import 'package:threedpass/features/hashes_list/di/di_hashes_list.dart'; import 'package:threedpass/features/poscan_objects_query/di_polkadot_query.dart'; import 'package:threedpass/features/poscan_putobject/di_preview_page.dart'; import 'package:threedpass/features/settings_page/bloc/settings_page_cubit.dart'; import 'package:threedpass/features/settings_page/data/repositories/settings_store.dart'; import 'package:threedpass/features/settings_page/domain/repositories/settings_repository.dart'; +import 'package:threedpass/features/wallet_screen/add_contact_page/di/di_contacts.dart'; import 'package:threedpass/features/wallet_screen/di_wallet_page.dart'; import 'package:threedpass/features/wallet_screen/non_native_token_screen/di/di_non_native_token.dart'; import 'package:threedpass/features/wallet_screen/transactions_history/data/repositories/transfers_repository.dart'; import 'package:threedpass/features/wallet_screen/transactions_history/domain/usecases/get_transfers.dart'; import 'package:threedpass/features/wallet_screen/transfer_page/di_transfer_page.dart'; -import 'features/wallet_screen/add_contact_page/di/di_contacts.dart'; - final getIt = GetIt.instance; Future setup() async { final PackageInfo packageInfo = await PackageInfo.fromPlatform(); getIt.registerSingleton(packageInfo); + try { + final DateTime date = await AppInstallDate().installDate; + getIt.registerSingleton( + date, + instanceName: MAppInstallDate.instanceName, + ); + } on Object catch (_) { + logD('Impossible to get app install date'); + } + await DIHashesList().setup(getIt); // Logger diff --git a/packages/calc/android/src/main/jniLibs/arm64-v8a/libcalc.so b/packages/calc/android/src/main/jniLibs/arm64-v8a/libcalc.so index 1f06b79f..afc39a34 100755 Binary files a/packages/calc/android/src/main/jniLibs/arm64-v8a/libcalc.so and b/packages/calc/android/src/main/jniLibs/arm64-v8a/libcalc.so differ diff --git a/packages/calc/android/src/main/jniLibs/armeabi-v7a/libcalc.so b/packages/calc/android/src/main/jniLibs/armeabi-v7a/libcalc.so index b53cdc5a..061c8c9b 100755 Binary files a/packages/calc/android/src/main/jniLibs/armeabi-v7a/libcalc.so and b/packages/calc/android/src/main/jniLibs/armeabi-v7a/libcalc.so differ diff --git a/packages/calc/android/src/main/jniLibs/x86/libcalc.so b/packages/calc/android/src/main/jniLibs/x86/libcalc.so index e96d1ba4..03aecff4 100755 Binary files a/packages/calc/android/src/main/jniLibs/x86/libcalc.so and b/packages/calc/android/src/main/jniLibs/x86/libcalc.so differ diff --git a/packages/calc/android/src/main/jniLibs/x86_64/libcalc.so b/packages/calc/android/src/main/jniLibs/x86_64/libcalc.so index 53937a3b..7924fb38 100755 Binary files a/packages/calc/android/src/main/jniLibs/x86_64/libcalc.so and b/packages/calc/android/src/main/jniLibs/x86_64/libcalc.so differ diff --git a/packages/calc/assets/bindings.h b/packages/calc/assets/bindings.h index fd5f0332..2e1b77b9 100644 --- a/packages/calc/assets/bindings.h +++ b/packages/calc/assets/bindings.h @@ -6,6 +6,8 @@ char *calc(const unsigned char *input, short par2, const unsigned char *trans, const unsigned char *version, - int version_len); + int version_len, + int send_none, + int is_debug); char *versionInterface(void); diff --git a/packages/calc/example/pubspec.lock b/packages/calc/example/pubspec.lock index 004fb699..d99ba0a7 100644 --- a/packages/calc/example/pubspec.lock +++ b/packages/calc/example/pubspec.lock @@ -5,10 +5,10 @@ packages: dependency: transitive description: name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 url: "https://pub.dev" source: hosted - version: "2.11.0" + version: "2.10.0" boolean_selector: dependency: transitive description: @@ -28,10 +28,10 @@ packages: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.2.1" clock: dependency: transitive description: @@ -44,10 +44,10 @@ packages: dependency: transitive description: name: collection - sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 url: "https://pub.dev" source: hosted - version: "1.17.1" + version: "1.17.0" convert: dependency: transitive description: @@ -86,18 +86,18 @@ packages: dependency: transitive description: name: js - sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" url: "https://pub.dev" source: hosted - version: "0.6.7" + version: "0.6.5" matcher: dependency: transitive description: name: matcher - sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" url: "https://pub.dev" source: hosted - version: "0.12.15" + version: "0.12.13" material_color_utilities: dependency: transitive description: @@ -110,18 +110,18 @@ packages: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.8.0" path: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.8.2" sky_engine: dependency: transitive description: flutter @@ -171,10 +171,10 @@ packages: dependency: transitive description: name: test_api - sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb + sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 url: "https://pub.dev" source: hosted - version: "0.5.1" + version: "0.4.16" typed_data: dependency: transitive description: @@ -192,4 +192,4 @@ packages: source: hosted version: "2.1.4" sdks: - dart: ">=3.0.0-0 <4.0.0" + dart: ">=2.18.0 <4.0.0" diff --git a/packages/calc/ios/Classes/CalcPlugin.h b/packages/calc/ios/Classes/CalcPlugin.h index 8f30364c..e1b57054 100644 --- a/packages/calc/ios/Classes/CalcPlugin.h +++ b/packages/calc/ios/Classes/CalcPlugin.h @@ -12,6 +12,8 @@ char *calc(const unsigned char *input, short par2, const unsigned char *trans, const unsigned char *version, - int version_len); + int version_len, + bool send_none, + bool is_debug); -char *versionInterface(); +char *versionInterface(void); diff --git a/packages/calc/ios/Classes/SwiftCalcPlugin.swift b/packages/calc/ios/Classes/SwiftCalcPlugin.swift index b5f13ea8..2ae33a89 100644 --- a/packages/calc/ios/Classes/SwiftCalcPlugin.swift +++ b/packages/calc/ios/Classes/SwiftCalcPlugin.swift @@ -19,7 +19,7 @@ public class SwiftCalcPlugin: NSObject, FlutterPlugin { public static func dummyMethodToEnforceBundling() { print("iOS Call") // dummy calls to prevent tree shaking - calc("", 0, 1, 1, "", "", 0); + calc("", 0, 1, 1, "", "", 0, false, false); print("iOS calc") versionInterface(); print("iOS version") diff --git a/packages/calc/ios/libcalc.a b/packages/calc/ios/libcalc.a index b00a4018..1a6a9797 100644 Binary files a/packages/calc/ios/libcalc.a and b/packages/calc/ios/libcalc.a differ diff --git a/packages/calc/lib/calc.dart b/packages/calc/lib/calc.dart index 8304021b..7a6ffab5 100644 --- a/packages/calc/lib/calc.dart +++ b/packages/calc/lib/calc.dart @@ -17,6 +17,7 @@ class Calc2 { required this.filePath, required this.transBytes, required this.algorithm, + required this.sendNone, // required this.updateIsolateListener, }); @@ -25,6 +26,7 @@ class Calc2 { final String filePath; final String transBytes; final String algorithm; + final bool sendNone; Future calcHashes( void updateIsolateListener(Isolate i, ReceivePort p)) async { @@ -56,6 +58,26 @@ class Calc2 { Isolate.exit(p, result); } + int sendNoneRaw() { + if (sendNone) { + return 1; + } else { + return 0; + } + } + + Pointer transBytesRaw() { + if (sendNone) { + return _byteDataToPointer(Uint8List.fromList([])); + } else { + final bytesIntList = hex.decode(transBytes); // TODO Check if correct + final bytesUint8List = Uint8List.fromList(bytesIntList); + + final trans = _byteDataToPointer(bytesUint8List); + return trans; + } + } + Future _callLib(SendPort p) async { final DynamicLibrary nativeLib = Platform.isAndroid ? DynamicLibrary.open( @@ -63,25 +85,23 @@ class Calc2 { ) // Load the dynamic library on Android : DynamicLibrary.process(); // Load the static library on iOS - final bytesIntList = hex.decode(transBytes); - final bytesUint8List = Uint8List.fromList(bytesIntList); - - final trans = _byteDataToPointer(bytesUint8List); - final File f = File(filePath); final content = f.readAsBytesSync(); final input = _byteDataToPointer(content); final bindings = CalcBindings(nativeLib); + final rawData = bindings.calc( input, content.lengthInBytes, gridSize, nSections, - trans, + transBytesRaw(), _stringToPointer(algorithm), algorithm.length, + sendNoneRaw(), + 0, ); final result = rawData.cast().toDartString(); diff --git a/packages/calc/lib/generated/bindings.dart b/packages/calc/lib/generated/bindings.dart index 74d45f71..5f494599 100644 --- a/packages/calc/lib/generated/bindings.dart +++ b/packages/calc/lib/generated/bindings.dart @@ -27,6 +27,8 @@ class CalcBindings { ffi.Pointer trans, ffi.Pointer version, int version_len, + int send_none, + int is_debug, ) { return _calc( input, @@ -36,6 +38,8 @@ class CalcBindings { trans, version, version_len, + send_none, + is_debug, ); } @@ -48,6 +52,8 @@ class CalcBindings { ffi.Short, ffi.Pointer, ffi.Pointer, + ffi.Int, + ffi.Int, ffi.Int)>>('calc'); late final _calc = _calcPtr.asFunction< ffi.Pointer Function( @@ -57,6 +63,8 @@ class CalcBindings { int, ffi.Pointer, ffi.Pointer, + int, + int, int)>(); ffi.Pointer versionInterface() { diff --git a/packages/calc/pubspec.lock b/packages/calc/pubspec.lock index dd217143..c096153a 100644 --- a/packages/calc/pubspec.lock +++ b/packages/calc/pubspec.lock @@ -13,10 +13,10 @@ packages: dependency: transitive description: name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 url: "https://pub.dev" source: hosted - version: "2.11.0" + version: "2.10.0" boolean_selector: dependency: transitive description: @@ -29,10 +29,10 @@ packages: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.2.1" cli_util: dependency: transitive description: @@ -53,10 +53,10 @@ packages: dependency: transitive description: name: collection - sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 url: "https://pub.dev" source: hosted - version: "1.17.1" + version: "1.17.0" convert: dependency: "direct main" description: @@ -127,10 +127,10 @@ packages: dependency: transitive description: name: js - sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" url: "https://pub.dev" source: hosted - version: "0.6.7" + version: "0.6.5" lints: dependency: transitive description: @@ -151,10 +151,10 @@ packages: dependency: transitive description: name: matcher - sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" url: "https://pub.dev" source: hosted - version: "0.12.15" + version: "0.12.13" material_color_utilities: dependency: transitive description: @@ -167,18 +167,18 @@ packages: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.8.0" path: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.8.2" quiver: dependency: transitive description: @@ -236,10 +236,10 @@ packages: dependency: transitive description: name: test_api - sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb + sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 url: "https://pub.dev" source: hosted - version: "0.5.1" + version: "0.4.16" typed_data: dependency: transitive description: @@ -265,4 +265,4 @@ packages: source: hosted version: "3.1.1" sdks: - dart: ">=3.0.0-0 <4.0.0" + dart: ">=2.18.0 <4.0.0" diff --git a/packages/hash_lib_interface/Cargo.lock b/packages/hash_lib_interface/Cargo.lock index 634eac86..1a643de9 100644 --- a/packages/hash_lib_interface/Cargo.lock +++ b/packages/hash_lib_interface/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "anyhow" -version = "1.0.71" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" +checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" [[package]] name = "approx" @@ -25,15 +25,15 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base16ct" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" [[package]] name = "block-buffer" -version = "0.9.0" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] @@ -64,20 +64,31 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.7" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] [[package]] -name = "digest" -version = "0.9.0" +name = "crypto-common" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", + "typenum", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", ] [[package]] @@ -142,9 +153,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.144" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libm" @@ -154,15 +165,15 @@ checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" [[package]] name = "libm" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "matrixmultiply" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090126dc04f95dc0d1c1c91f61bdd474b3930ca064c1edc8a849da2c6cbe1e77" +checksum = "7574c1cf36da4798ab73da5b215bbf444f50718207754cb522201d78d1cd0ff2" dependencies = [ "autocfg", "rawpointer", @@ -170,9 +181,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.5.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "ndarray" @@ -188,31 +199,30 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" +checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" dependencies = [ "num-traits", ] [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", - "libm 0.2.7", + "libm 0.2.8", ] [[package]] @@ -225,28 +235,22 @@ dependencies = [ "num-traits", ] -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - [[package]] name = "order-stat" version = "0.1.3" source = "git+https://github.com/3Dpass/order-stat?branch=dev#c1c0d34fe4394f63f6e820993575c4b9dbc5464b" dependencies = [ - "libm 0.2.7", + "libm 0.2.8", ] [[package]] name = "p3d" -version = "0.3.4" -source = "git+https://github.com/3Dpass/p3d?rev=914cf44#914cf4405503387e9b2915c531e01d2443be4be9" +version = "0.7.0" +source = "git+https://github.com/3Dpass/p3d?rev=5eed819#5eed819244fa00cf6f75783837e7541f7965484a" dependencies = [ "base16ct", "cgmath", - "libm 0.2.7", + "libm 0.2.8", "ndarray", "obj-rs", "peroxide", @@ -256,7 +260,7 @@ dependencies = [ [[package]] name = "p3d_interface" -version = "0.3.4" +version = "0.7.0" dependencies = [ "p3d", ] @@ -267,7 +271,7 @@ version = "0.30.9" source = "git+https://github.com/3Dpass/Peroxide?branch=devel#3f33fda43b889858fe1e51125f3b79d85a97849b" dependencies = [ "lexical", - "libm 0.2.7", + "libm 0.2.8", "matrixmultiply", "num-traits", "order-stat", @@ -289,9 +293,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.59" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -306,9 +310,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.28" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -346,15 +350,13 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] name = "sha2" -version = "0.9.9" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ - "block-buffer", "cfg-if", "cpufeatures", "digest", - "opaque-debug", ] [[package]] @@ -384,15 +386,15 @@ dependencies = [ [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "version_check" diff --git a/packages/hash_lib_interface/Cargo.toml b/packages/hash_lib_interface/Cargo.toml index 8474c21b..86724844 100644 --- a/packages/hash_lib_interface/Cargo.toml +++ b/packages/hash_lib_interface/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "p3d_interface" -version = "0.3.4" +version = "0.7.0" authors = ["l3odr0id"] edition = "2018" @@ -15,7 +15,9 @@ crate-type = ["staticlib", "cdylib"] [dependencies] -p3d = { version="0.3.4", git="https://github.com/3Dpass/p3d", rev="914cf44" } +p3d = { version="0.7.0", git="https://github.com/3Dpass/p3d", rev="5eed819" } +# regex-syntax = "=0.8.0" +# p3d_0_3_4 = { version="0.3.4", git="https://github.com/3Dpass/p3d", rev="914cf44" } # p3d_0_3_2 = { package = "p3d", rev = "22d9efb4dd6f2cb523b3a24037b866e3369f33cb", git = "https://github.com/3Dpass/p3d" } # p3d_0_3_1 = { package = "p3d", rev = "4a98da181478ac9ba5e27e96a31a8c695d200c61", git = "https://github.com/3Dpass/p3d" } # p3d_0_3_0 = { package = "p3d", rev = "91c72dfe7f7bacf5de088009133c64ca2197aef7", git = "https://github.com/3Dpass/p3d" } diff --git a/packages/hash_lib_interface/README.md b/packages/hash_lib_interface/README.md index d59a5e46..f88b5d2a 100644 --- a/packages/hash_lib_interface/README.md +++ b/packages/hash_lib_interface/README.md @@ -14,6 +14,7 @@ To compile 0.3.1 version: - You might also need LLVM from the SDK manager - Ensure that the env variable `$ANDROID_NDK_HOME` points to the NDK base folder - It may look like `/Users/brickpop/Library/Android/sdk/ndk-bundle` on MacOS + - Or in modern Android Studio versions `/Users/user_name/Library/Android/sdk/ndk/22.0.7026061` - And look like `/home/brickpop/dev/android/ndk-bundle` on Linux - On the `rust` folder: - Run `rustup override set nightly` to allow unstable features diff --git a/packages/hash_lib_interface/src/ffi_interface.rs b/packages/hash_lib_interface/src/ffi_interface.rs index ce9247ca..9332ea9a 100644 --- a/packages/hash_lib_interface/src/ffi_interface.rs +++ b/packages/hash_lib_interface/src/ffi_interface.rs @@ -8,8 +8,17 @@ use p3d::AlgoType; // Interface for the C binding +// @param input - .obj file, +// @param input_len - lenght of bytes array, +// @param par1 - gridSize (for example 8x8), +// @param par2 - nSections (for example 12), +// @param trans - rotation bytes (always 4 bytes hex), +// @param version - algorithm (for example Grid2dV3a), +// @param version_len - length of version string, +// @param send_none - flag to send none as trans bytes +// @param is_debug - return debug string #[no_mangle] -pub extern fn calc(input: *const c_uchar, input_len: c_int, par1: c_short, par2: c_short, trans: *const c_uchar, version: *const c_uchar, version_len: c_int,) -> *mut c_char +pub extern fn calc(input: *const c_uchar, input_len: c_int, par1: c_short, par2: c_short, trans: *const c_uchar, version: *const c_uchar, version_len: c_int, send_none: c_int, is_debug: c_int) -> *mut c_char { // Some memory leaks are possible // let c_str_path = unsafe { CStr::from_ptr(path) }; @@ -32,11 +41,11 @@ pub extern fn calc(input: *const c_uchar, input_len: c_int, par1: c_short, par2 version2 = make_slice(version, version_len as usize); // Length of version string } - println!("Trans: {:?}", trans2); - println!("Version: {:?}", version2); + // println!("Trans: {:?}", trans2); + // println!("Version: {:?}", version2); let u8str = std::str::from_utf8(version2).expect("Invalid UTF-8"); - let algo = match u8str { + let algo = match u8str { "Grid2d" => AlgoType::Grid2d, "Grid2dV2" => AlgoType::Grid2dV2, "Grid2dV3" => AlgoType::Grid2dV3, @@ -44,9 +53,26 @@ pub extern fn calc(input: *const c_uchar, input_len: c_int, par1: c_short, par2 _=>AlgoType::Grid2d, }; - let r: Vec = match p3d_process(input2, algo, par1, par2, trans2) { + let trans = if send_none != 0 { None } else { trans2 }; + + if is_debug != 0 { + let input_let = input_len.to_string(); + let par1_str = par1.to_string(); + let par2_str = par2.to_string(); + let trans_str = match std::str::from_utf8(trans2.unwrap_or_default().as_ref()) { + Ok(v) => v, + Err(e) => panic!("Invalid UTF-8 sequence: {}", e), + }.to_string(); + let version_str = u8str.to_string(); + let version_len_str = version_len.to_string(); + let send_none_str = send_none.to_string(); + let arr = [input_let, par1_str, par2_str, trans_str, version_str, version_len_str, send_none_str]; + return CString::new(arr.join("\n")).unwrap().into_raw(); + } + + let r: Vec = match p3d_process(input2, algo, par1, par2, trans) { Ok(h) => h, - Err(_e) => vec!["Error".to_string()], + Err(_e) => vec!["Error".to_string()], }; // Maybe we should free the CString. This can be a potential memory leak diff --git a/pubspec.lock b/pubspec.lock index 45977fcb..ebc12837 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -33,6 +33,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.1" + app_install_date: + dependency: "direct main" + description: + name: app_install_date + sha256: "18698fcf00e1d7bc3350ac6966d634869246d26ae640c03be9977b8b3166e71e" + url: "https://pub.dev" + source: hosted + version: "0.1.3" archive: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 6da86fbc..e5c5ca90 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,7 +10,7 @@ publish_to: 'none' # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 2.12.0+34 +version: 2.13.0+35 environment: sdk: ">=3.0.6 <3.0.7" @@ -80,6 +80,7 @@ dependencies: flutter_keyboard_visibility: ^5.3.0 mask_text_input_formatter: ^2.4.0 flutter_phoenix: ^1.1.0 + app_install_date: ^0.1.3 # Child packages super_core: diff --git a/test/resources/3dpass-487203.obj b/test/resources/3dpass-487203.obj new file mode 100644 index 00000000..057e442d --- /dev/null +++ b/test/resources/3dpass-487203.obj @@ -0,0 +1,629 @@ +o +v 0.000000 -0.800000 -0.000000 +v 0.191453 -0.776753 -0.000000 +v 0.169523 -0.776753 0.111216 +v 0.108389 -0.774121 0.196285 +v 0.023077 -0.776753 0.237571 +v -0.067890 -0.776753 0.223764 +v -0.143304 -0.776753 0.158696 +v -0.185889 -0.776753 0.057272 +v -0.185889 -0.776753 -0.057272 +v -0.143304 -0.776753 -0.158696 +v -0.067890 -0.776753 -0.223764 +v 0.016195 -0.545121 -0.166726 +v 0.108757 -0.776753 -0.196953 +v 0.169523 -0.776753 -0.111216 +v 0.371779 -0.708365 -0.000000 +v 0.329194 -0.708365 0.215968 +v 0.188542 -0.632387 0.341438 +v 0.044813 -0.708365 0.461335 +v -0.107089 -0.575406 0.352964 +v -0.278280 -0.708365 0.308168 +v -0.360975 -0.708365 0.111216 +v -0.360975 -0.708365 -0.111216 +v -0.278280 -0.708365 -0.308169 +v -0.106150 -0.570359 -0.349869 +v 0.043520 -0.687928 -0.448025 +v 0.211194 -0.708365 -0.382460 +v 0.329194 -0.708365 -0.215968 +v 0.530498 -0.598809 -0.000000 +v 0.469733 -0.598809 0.308168 +v 0.301357 -0.598809 0.545739 +v 0.063944 -0.598809 0.658288 +v -0.188117 -0.598809 0.620030 +v -0.397084 -0.598809 0.439732 +v -0.515083 -0.598809 0.158696 +v -0.515083 -0.598809 -0.158696 +v -0.397083 -0.598809 -0.439732 +v -0.188117 -0.598809 -0.620031 +v 0.063945 -0.598809 -0.658288 +v 0.301357 -0.598809 -0.545739 +v 0.469733 -0.598809 -0.308169 +v 0.658387 -0.454452 -0.000000 +v 0.582973 -0.454452 0.382460 +v 0.315233 -0.383037 0.570867 +v 0.079188 -0.453467 0.815212 +v -0.170708 -0.332290 0.562652 +v -0.492810 -0.454452 0.545739 +v -0.639256 -0.454452 0.196953 +v -0.639256 -0.454452 -0.196953 +v -0.489145 -0.451072 -0.541681 +v -0.233467 -0.454452 -0.769503 +v 0.079360 -0.454452 -0.816983 +v 0.374007 -0.454452 -0.677302 +v 0.517170 -0.403156 -0.339290 +v 0.718680 -0.272559 -0.000000 +v 0.622741 -0.266726 0.408549 +v 0.394685 -0.263499 0.714750 +v 0.090163 -0.283684 0.928199 +v -0.265249 -0.283684 0.874255 +v -0.559896 -0.283684 0.620030 +v -0.726277 -0.283684 0.223764 +v -0.726277 -0.283684 -0.223764 +v -0.559896 -0.283684 -0.620031 +v -0.265249 -0.283684 -0.874255 +v 0.090163 -0.283684 -0.928199 +v 0.424920 -0.283684 -0.769503 +v 0.662333 -0.283684 -0.434524 +v 0.794167 -0.096429 -0.000000 +v 0.567051 -0.077759 0.372014 +v 0.451138 -0.096429 0.816983 +v 0.095726 -0.096429 0.985471 +v -0.270953 -0.092778 0.893055 +v -0.594443 -0.096429 0.658288 +v -0.771090 -0.096429 0.237571 +v -0.771090 -0.096429 -0.237571 +v -0.594443 -0.096429 -0.658288 +v -0.266170 -0.091141 -0.877293 +v 0.095726 -0.096429 -0.985471 +v 0.451138 -0.096429 -0.816983 +v 0.703200 -0.096429 -0.461335 +v 0.794167 0.096429 0.000000 +v 0.703200 0.096429 0.461335 +v 0.451138 0.096429 0.816983 +v 0.095726 0.096429 0.985471 +v -0.249567 0.085456 0.822568 +v -0.589756 0.095669 0.653097 +v -0.771090 0.096429 0.237571 +v -0.771090 0.096429 -0.237571 +v -0.594443 0.096429 -0.658288 +v -0.281615 0.096429 -0.928199 +v 0.095726 0.096429 -0.985471 +v 0.451138 0.096429 -0.816983 +v 0.703200 0.096429 -0.461335 +v 0.684779 0.259702 0.000000 +v 0.662333 0.283684 0.434524 +v 0.424920 0.283684 0.769503 +v 0.090163 0.283684 0.928199 +v -0.265249 0.283684 0.874255 +v -0.559896 0.283684 0.620030 +v -0.726277 0.283684 0.223764 +v -0.726277 0.283684 -0.223764 +v -0.559896 0.283684 -0.620031 +v -0.265249 0.283684 -0.874255 +v 0.076869 0.241856 -0.791340 +v 0.421457 0.281372 -0.763232 +v 0.662333 0.283684 -0.434524 +v 0.658387 0.454452 0.000000 +v 0.474452 0.369856 0.311265 +v 0.374006 0.454452 0.677302 +v 0.079360 0.454452 0.816983 +v -0.233467 0.454452 0.769503 +v -0.492810 0.454452 0.545739 +v -0.639255 0.454452 0.196953 +v -0.639255 0.454452 -0.196953 +v -0.492810 0.454452 -0.545739 +v -0.233467 0.454452 -0.769503 +v 0.079360 0.454452 -0.816983 +v 0.310800 0.377650 -0.562839 +v 0.582973 0.454452 -0.382460 +v 0.530498 0.598809 0.000000 +v 0.469733 0.598809 0.308169 +v 0.301357 0.598809 0.545739 +v 0.063944 0.598809 0.658288 +v -0.153656 0.489112 0.506446 +v -0.397084 0.598809 0.439732 +v -0.515083 0.598809 0.158696 +v -0.419751 0.487981 -0.129324 +v -0.360435 0.543541 -0.399147 +v -0.188117 0.598809 -0.620030 +v 0.063945 0.598809 -0.658288 +v 0.301357 0.598809 -0.545739 +v 0.469733 0.598809 -0.308168 +v 0.371778 0.708365 0.000000 +v 0.329193 0.708365 0.215968 +v 0.211194 0.708365 0.382460 +v 0.044813 0.708365 0.461335 +v -0.131834 0.708365 0.434524 +v -0.270322 0.688108 0.299356 +v -0.360417 0.707269 0.111044 +v -0.360975 0.708365 -0.111216 +v -0.278280 0.708365 -0.308168 +v -0.128725 0.691659 -0.424276 +v 0.036913 0.583493 -0.380010 +v 0.211194 0.708365 -0.382459 +v 0.329193 0.708365 -0.215968 +v 0.191453 0.776753 0.000000 +v 0.169523 0.776753 0.111216 +v 0.108757 0.776753 0.196953 +v 0.023077 0.776753 0.237571 +v -0.064341 0.736151 0.212067 +v -0.143304 0.776753 0.158696 +v -0.185889 0.776753 0.057272 +v -0.185889 0.776753 -0.057272 +v -0.143304 0.776753 -0.158696 +v -0.067890 0.776753 -0.223764 +v 0.023077 0.776753 -0.237571 +v 0.094425 0.674389 -0.170997 +v 0.169523 0.776753 -0.111216 +v -0.000000 0.800000 0.000000 +vn 0.024493 -0.988119 -0.151729 +vn 0.277553 -0.960435 0.022995 +vn 0.200402 -0.937028 0.286039 +vn 0.378506 -0.886234 0.267064 +vn -0.295060 -0.890455 0.346453 +vn -0.007577 -0.827554 0.561335 +vn -0.227864 -0.964890 0.130632 +vn -0.276399 -0.960549 0.030815 +vn -0.262991 -0.961834 -0.075575 +vn -0.054711 -0.897710 -0.437177 +vn 0.496021 -0.792387 -0.355087 +vn 0.030109 -0.961930 -0.271631 +vn -0.484061 -0.733703 -0.476828 +vn 0.259581 -0.962150 -0.082975 +vn 0.481035 -0.876450 0.020984 +vn 0.259327 -0.928903 0.264366 +vn 0.255760 -0.905729 0.337998 +vn -0.067219 -0.958574 0.276799 +vn -0.202269 -0.908641 0.365321 +vn -0.218286 -0.854373 0.471590 +vn -0.473962 -0.877612 0.071816 +vn -0.462370 -0.879475 -0.112858 +vn -0.023207 -0.944757 -0.326949 +vn -0.104951 -0.922320 -0.371902 +vn -0.059085 -0.979376 -0.193216 +vn -0.002841 -0.956864 -0.290522 +vn 0.441269 -0.882740 -0.161408 +vn 0.671240 -0.741028 0.017742 +vn 0.624322 -0.683865 0.377559 +vn 0.470952 -0.699430 0.537589 +vn -0.079114 -0.723077 0.686222 +vn -0.299151 -0.645812 0.702450 +vn -0.404019 -0.848294 0.342295 +vn -0.659284 -0.743556 0.111664 +vn -0.652886 -0.742270 -0.150918 +vn -0.517054 -0.763537 -0.386868 +vn -0.056871 -0.910631 -0.409289 +vn 0.027103 -0.890781 -0.453625 +vn 0.499252 -0.737732 -0.454422 +vn 0.704273 -0.628148 -0.330801 +vn 0.907003 -0.416780 -0.060339 +vn 0.695964 -0.577731 0.426452 +vn 0.565977 -0.524232 0.636279 +vn 0.015895 -0.751845 0.659148 +vn -0.346343 -0.632652 0.692675 +vn -0.568342 -0.456535 0.684517 +vn -0.811515 -0.565781 0.146065 +vn -0.800946 -0.572195 -0.176291 +vn -0.645242 -0.597240 -0.476411 +vn -0.321743 -0.632243 -0.704805 +vn 0.133579 -0.645668 -0.751844 +vn 0.550862 -0.675429 -0.490253 +vn 0.779234 -0.553226 -0.294508 +vn 0.937200 -0.339937 0.078096 +vn 0.932761 -0.101703 0.345852 +vn 0.518731 -0.564632 0.641957 +vn 0.215282 -0.461435 0.860658 +vn -0.407142 -0.681571 0.608027 +vn -0.639250 -0.561987 0.524910 +vn -0.919181 -0.354042 0.172516 +vn -0.915643 -0.354636 -0.189294 +vn -0.744140 -0.353367 -0.566909 +vn -0.417118 -0.332931 -0.845677 +vn 0.148436 -0.422738 -0.894013 +vn 0.608294 -0.395146 -0.688359 +vn 0.811142 -0.519852 -0.267959 +vn 0.944370 -0.307959 0.115442 +vn 0.891344 -0.233785 0.388395 +vn 0.738571 -0.135442 0.660431 +vn 0.093552 -0.145959 0.984857 +vn -0.388572 0.055437 0.919749 +vn -0.798537 -0.091241 0.594990 +vn -0.974513 -0.120552 0.189184 +vn -0.973376 -0.120625 -0.194907 +vn -0.781627 -0.173342 -0.599176 +vn -0.420151 -0.143803 -0.895988 +vn 0.107967 -0.102697 -0.988836 +vn 0.649966 -0.136836 -0.747543 +vn 0.916086 -0.124141 -0.381282 +vn 0.972278 0.232162 -0.027871 +vn 0.884615 -0.163086 0.436874 +vn 0.703411 -0.018937 0.710531 +vn 0.057291 0.051512 0.997028 +vn -0.443503 0.074668 0.893157 +vn -0.747552 0.194573 0.635065 +vn -0.971885 0.126248 0.198747 +vn -0.974513 0.120552 -0.189184 +vn -0.810918 0.129826 -0.570576 +vn -0.357838 0.174046 -0.917420 +vn 0.049443 0.352614 -0.934462 +vn 0.640687 0.149421 -0.753123 +vn 0.912830 0.182769 -0.365154 +vn 0.882197 0.469836 0.031352 +vn 0.759682 0.619734 0.197011 +vn 0.608294 0.395146 0.688359 +vn 0.148436 0.422738 0.894013 +vn -0.452305 0.228810 0.862013 +vn -0.751524 0.290884 0.592114 +vn -0.916956 0.349765 0.191981 +vn -0.919180 0.354042 -0.172516 +vn -0.761130 0.377582 -0.527365 +vn -0.293479 0.312203 -0.903548 +vn 0.173523 0.534329 -0.827274 +vn 0.327774 0.696190 -0.638658 +vn 0.890657 0.314737 -0.328131 +vn 0.924657 0.350028 0.149966 +vn 0.802531 0.524618 0.284113 +vn 0.561673 0.710255 0.424336 +vn 0.059504 0.741755 0.668026 +vn -0.161780 0.801649 0.575488 +vn -0.645242 0.597240 0.476411 +vn -0.736624 0.666621 0.114025 +vn -0.623978 0.778586 -0.066747 +vn -0.626331 0.679919 -0.381339 +vn -0.347914 0.633482 -0.691127 +vn 0.364125 0.324093 -0.873142 +vn 0.487249 0.522608 -0.699620 +vn 0.608136 0.690727 -0.391238 +vn 0.671240 0.741028 -0.017742 +vn 0.752620 0.531866 0.388178 +vn 0.577098 0.676737 0.457148 +vn -0.115032 0.738054 0.664864 +vn -0.239265 0.811774 0.532706 +vn -0.250967 0.880514 0.402133 +vn -0.750404 0.660880 -0.011414 +vn -0.670104 0.714184 -0.202240 +vn -0.508355 0.845420 -0.163827 +vn -0.223617 0.908089 -0.354077 +vn -0.055030 0.903173 -0.425734 +vn 0.580992 0.581273 -0.569710 +vn 0.626143 0.677507 -0.385913 +vn 0.481035 0.876450 -0.020984 +vn 0.441269 0.882740 0.161408 +vn 0.302825 0.900170 0.313035 +vn 0.050755 0.927090 0.371386 +vn -0.383115 0.759773 0.525326 +vn -0.322746 0.834569 0.446464 +vn -0.428518 0.893018 0.137447 +vn -0.690054 0.687636 -0.225791 +vn -0.608319 0.720218 -0.333517 +vn -0.034841 0.847564 -0.529548 +vn 0.070405 0.949992 -0.304233 +vn -0.175939 0.946458 -0.270671 +vn 0.418304 0.886106 -0.199594 +vn 0.277553 0.960435 -0.022995 +vn 0.259581 0.962150 0.082975 +vn 0.182782 0.968161 0.171039 +vn -0.096746 0.967114 0.235225 +vn -0.072490 0.973115 0.218616 +vn -0.110100 0.968845 0.221849 +vn -0.272739 0.955168 0.115183 +vn -0.277936 0.960161 -0.029016 +vn -0.227864 0.964890 -0.130632 +vn -0.113341 0.962316 -0.247190 +vn 0.575897 0.715499 -0.395479 +vn -0.056505 0.909002 -0.412944 +vn -0.094355 0.948953 -0.300974 +vn 0.036142 0.998879 -0.030584 +f 1//1 2//2 3//3 +f 1//1 3//3 4//4 +f 1//1 4//4 5//5 +f 1//1 5//5 6//6 +f 1//1 6//6 7//7 +f 1//1 7//7 8//8 +f 1//1 8//8 9//9 +f 1//1 9//9 10//10 +f 1//1 10//10 11//11 +f 1//1 11//11 12//12 +f 1//1 12//12 13//13 +f 1//1 13//13 14//14 +f 1//1 14//14 2//2 +f 2//2 15//15 16//16 +f 16//16 3//3 2//2 +f 3//3 16//16 17//17 +f 17//17 4//4 3//3 +f 4//4 17//17 18//18 +f 18//18 5//5 4//4 +f 5//5 18//18 19//19 +f 19//19 6//6 5//5 +f 6//6 19//19 20//20 +f 20//20 7//7 6//6 +f 7//7 20//20 21//21 +f 21//21 8//8 7//7 +f 8//8 21//21 22//22 +f 22//22 9//9 8//8 +f 9//9 22//22 23//23 +f 23//23 10//10 9//9 +f 10//10 23//23 24//24 +f 24//24 11//11 10//10 +f 11//11 24//24 25//25 +f 25//25 12//12 11//11 +f 12//12 25//25 26//26 +f 26//26 13//13 12//12 +f 13//13 26//26 27//27 +f 27//27 14//14 13//13 +f 14//14 27//27 15//15 +f 15//15 2//2 14//14 +f 15//15 28//28 29//29 +f 29//29 16//16 15//15 +f 16//16 29//29 30//30 +f 30//30 17//17 16//16 +f 17//17 30//30 31//31 +f 31//31 18//18 17//17 +f 18//18 31//31 32//32 +f 32//32 19//19 18//18 +f 19//19 32//32 33//33 +f 33//33 20//20 19//19 +f 20//20 33//33 34//34 +f 34//34 21//21 20//20 +f 21//21 34//34 35//35 +f 35//35 22//22 21//21 +f 22//22 35//35 36//36 +f 36//36 23//23 22//22 +f 23//23 36//36 37//37 +f 37//37 24//24 23//23 +f 24//24 37//37 38//38 +f 38//38 25//25 24//24 +f 25//25 38//38 39//39 +f 39//39 26//26 25//25 +f 26//26 39//39 40//40 +f 40//40 27//27 26//26 +f 27//27 40//40 28//28 +f 28//28 15//15 27//27 +f 28//28 41//41 42//42 +f 42//42 29//29 28//28 +f 29//29 42//42 43//43 +f 43//43 30//30 29//29 +f 30//30 43//43 44//44 +f 44//44 31//31 30//30 +f 31//31 44//44 45//45 +f 45//45 32//32 31//31 +f 32//32 45//45 46//46 +f 46//46 33//33 32//32 +f 33//33 46//46 47//47 +f 47//47 34//34 33//33 +f 34//34 47//47 48//48 +f 48//48 35//35 34//34 +f 35//35 48//48 49//49 +f 49//49 36//36 35//35 +f 36//36 49//49 50//50 +f 50//50 37//37 36//36 +f 37//37 50//50 51//51 +f 51//51 38//38 37//37 +f 38//38 51//51 52//52 +f 52//52 39//39 38//38 +f 39//39 52//52 53//53 +f 53//53 40//40 39//39 +f 40//40 53//53 41//41 +f 41//41 28//28 40//40 +f 41//41 54//54 55//55 +f 55//55 42//42 41//41 +f 42//42 55//55 56//56 +f 56//56 43//43 42//42 +f 43//43 56//56 57//57 +f 57//57 44//44 43//43 +f 44//44 57//57 58//58 +f 58//58 45//45 44//44 +f 45//45 58//58 59//59 +f 59//59 46//46 45//45 +f 46//46 59//59 60//60 +f 60//60 47//47 46//46 +f 47//47 60//60 61//61 +f 61//61 48//48 47//47 +f 48//48 61//61 62//62 +f 62//62 49//49 48//48 +f 49//49 62//62 63//63 +f 63//63 50//50 49//49 +f 50//50 63//63 64//64 +f 64//64 51//51 50//50 +f 51//51 64//64 65//65 +f 65//65 52//52 51//51 +f 52//52 65//65 66//66 +f 66//66 53//53 52//52 +f 53//53 66//66 54//54 +f 54//54 41//41 53//53 +f 54//54 67//67 68//68 +f 68//68 55//55 54//54 +f 55//55 68//68 69//69 +f 69//69 56//56 55//55 +f 56//56 69//69 70//70 +f 70//70 57//57 56//56 +f 57//57 70//70 71//71 +f 71//71 58//58 57//57 +f 58//58 71//71 72//72 +f 72//72 59//59 58//58 +f 59//59 72//72 73//73 +f 73//73 60//60 59//59 +f 60//60 73//73 74//74 +f 74//74 61//61 60//60 +f 61//61 74//74 75//75 +f 75//75 62//62 61//61 +f 62//62 75//75 76//76 +f 76//76 63//63 62//62 +f 63//63 76//76 77//77 +f 77//77 64//64 63//63 +f 64//64 77//77 78//78 +f 78//78 65//65 64//64 +f 65//65 78//78 79//79 +f 79//79 66//66 65//65 +f 66//66 79//79 67//67 +f 67//67 54//54 66//66 +f 67//67 80//80 81//81 +f 81//81 68//68 67//67 +f 68//68 81//81 82//82 +f 82//82 69//69 68//68 +f 69//69 82//82 83//83 +f 83//83 70//70 69//69 +f 70//70 83//83 84//84 +f 84//84 71//71 70//70 +f 71//71 84//84 85//85 +f 85//85 72//72 71//71 +f 72//72 85//85 86//86 +f 86//86 73//73 72//72 +f 73//73 86//86 87//87 +f 87//87 74//74 73//73 +f 74//74 87//87 88//88 +f 88//88 75//75 74//74 +f 75//75 88//88 89//89 +f 89//89 76//76 75//75 +f 76//76 89//89 90//90 +f 90//90 77//77 76//76 +f 77//77 90//90 91//91 +f 91//91 78//78 77//77 +f 78//78 91//91 92//92 +f 92//92 79//79 78//78 +f 79//79 92//92 80//80 +f 80//80 67//67 79//79 +f 80//80 93//93 94//94 +f 94//94 81//81 80//80 +f 81//81 94//94 95//95 +f 95//95 82//82 81//81 +f 82//82 95//95 96//96 +f 96//96 83//83 82//82 +f 83//83 96//96 97//97 +f 97//97 84//84 83//83 +f 84//84 97//97 98//98 +f 98//98 85//85 84//84 +f 85//85 98//98 99//99 +f 99//99 86//86 85//85 +f 86//86 99//99 100//100 +f 100//100 87//87 86//86 +f 87//87 100//100 101//101 +f 101//101 88//88 87//87 +f 88//88 101//101 102//102 +f 102//102 89//89 88//88 +f 89//89 102//102 103//103 +f 103//103 90//90 89//89 +f 90//90 103//103 104//104 +f 104//104 91//91 90//90 +f 91//91 104//104 105//105 +f 105//105 92//92 91//91 +f 92//92 105//105 93//93 +f 93//93 80//80 92//92 +f 93//93 106//106 107//107 +f 107//107 94//94 93//93 +f 94//94 107//107 108//108 +f 108//108 95//95 94//94 +f 95//95 108//108 109//109 +f 109//109 96//96 95//95 +f 96//96 109//109 110//110 +f 110//110 97//97 96//96 +f 97//97 110//110 111//111 +f 111//111 98//98 97//97 +f 98//98 111//111 112//112 +f 112//112 99//99 98//98 +f 99//99 112//112 113//113 +f 113//113 100//100 99//99 +f 100//100 113//113 114//114 +f 114//114 101//101 100//100 +f 101//101 114//114 115//115 +f 115//115 102//102 101//101 +f 102//102 115//115 116//116 +f 116//116 103//103 102//102 +f 103//103 116//116 117//117 +f 117//117 104//104 103//103 +f 104//104 117//117 118//118 +f 118//118 105//105 104//104 +f 105//105 118//118 106//106 +f 106//106 93//93 105//105 +f 106//106 119//119 120//120 +f 120//120 107//107 106//106 +f 107//107 120//120 121//121 +f 121//121 108//108 107//107 +f 108//108 121//121 122//122 +f 122//122 109//109 108//108 +f 109//109 122//122 123//123 +f 123//123 110//110 109//109 +f 110//110 123//123 124//124 +f 124//124 111//111 110//110 +f 111//111 124//124 125//125 +f 125//125 112//112 111//111 +f 112//112 125//125 126//126 +f 126//126 113//113 112//112 +f 113//113 126//126 127//127 +f 127//127 114//114 113//113 +f 114//114 127//127 128//128 +f 128//128 115//115 114//114 +f 115//115 128//128 129//129 +f 129//129 116//116 115//115 +f 116//116 129//129 130//130 +f 130//130 117//117 116//116 +f 117//117 130//130 131//131 +f 131//131 118//118 117//117 +f 118//118 131//131 119//119 +f 119//119 106//106 118//118 +f 119//119 132//132 133//133 +f 133//133 120//120 119//119 +f 120//120 133//133 134//134 +f 134//134 121//121 120//120 +f 121//121 134//134 135//135 +f 135//135 122//122 121//121 +f 122//122 135//135 136//136 +f 136//136 123//123 122//122 +f 123//123 136//136 137//137 +f 137//137 124//124 123//123 +f 124//124 137//137 138//138 +f 138//138 125//125 124//124 +f 125//125 138//138 139//139 +f 139//139 126//126 125//125 +f 126//126 139//139 140//140 +f 140//140 127//127 126//126 +f 127//127 140//140 141//141 +f 141//141 128//128 127//127 +f 128//128 141//141 142//142 +f 142//142 129//129 128//128 +f 129//129 142//142 143//143 +f 143//143 130//130 129//129 +f 130//130 143//143 144//144 +f 144//144 131//131 130//130 +f 131//131 144//144 132//132 +f 132//132 119//119 131//131 +f 132//132 145//145 146//146 +f 146//146 133//133 132//132 +f 133//133 146//146 147//147 +f 147//147 134//134 133//133 +f 134//134 147//147 148//148 +f 148//148 135//135 134//134 +f 135//135 148//148 149//149 +f 149//149 136//136 135//135 +f 136//136 149//149 150//150 +f 150//150 137//137 136//136 +f 137//137 150//150 151//151 +f 151//151 138//138 137//137 +f 138//138 151//151 152//152 +f 152//152 139//139 138//138 +f 139//139 152//152 153//153 +f 153//153 140//140 139//139 +f 140//140 153//153 154//154 +f 154//154 141//141 140//140 +f 141//141 154//154 155//155 +f 155//155 142//142 141//141 +f 142//142 155//155 156//156 +f 156//156 143//143 142//142 +f 143//143 156//156 157//157 +f 157//157 144//144 143//143 +f 144//144 157//157 145//145 +f 145//145 132//132 144//144 +f 158//158 146//146 145//145 +f 158//158 147//147 146//146 +f 158//158 148//148 147//147 +f 158//158 149//149 148//148 +f 158//158 150//150 149//149 +f 158//158 151//151 150//150 +f 158//158 152//152 151//151 +f 158//158 153//153 152//152 +f 158//158 154//154 153//153 +f 158//158 155//155 154//154 +f 158//158 156//156 155//155 +f 158//158 157//157 156//156 +f 158//158 145//145 157//157 diff --git a/test/test.dart b/test/test.dart index c94c5cc5..20f63d99 100644 --- a/test/test.dart +++ b/test/test.dart @@ -1,39 +1,14 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:threedpass/features/wallet_screen/presentation/assets_page/widgets/balance_card/locked_balance_card.dart'; - import 'test_config.dart'; -// import 'ui/scan_page/scan_page_test.dart' as scan_page; +import 'ui/scan_page/scan_page_test.dart' as scan_page; +import 'utils/assets_formatting.dart' as assets_formating; +import 'utils/tx_logs_handler.dart' as tx_logs_handler; /// Test all void main() { config(); - group('Example test', () { - testWidgets('MyWidget has a title and message', (tester) async { - // Create the widget by telling the tester to build it. - await tester.pumpWidget( - const Directionality( - textDirection: TextDirection.ltr, - child: Column( - children: [ - LockedBalanceCard( - tokenSymbol: 'P3D', - tokenDecimals: 12, - balance: '0x0000000000000000000044364c5baff6', - ), - ], - ), - ), - ); - // TODO check if localization works - final titleFinder = find.text('75 P3D'); - expect(titleFinder, findsOneWidget); - }); - }); - // Prepare to widget-testing - // setUpAll(() async { - // SharedPreferences.setMockInitialValues({}); - // await service_locator.setup(); - // }); + assets_formating.main(); + // tx_logs_handler.main(); + + scan_page.main(); } diff --git a/test/test_app.dart b/test/test_app.dart new file mode 100644 index 00000000..0622738f --- /dev/null +++ b/test/test_app.dart @@ -0,0 +1,18 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/widgets.dart'; +import 'package:threedpass/main.dart'; + +class TestApp { + TestApp._(); + + static final Widget instance = EasyLocalization( + supportedLocales: const [ + Locale('en'), + Locale('es'), + Locale('sr'), + ], + path: 'assets/translations', + fallbackLocale: const Locale('en'), + child: ThreeDApp(), + ); +} diff --git a/test/test_config.dart b/test/test_config.dart index af2cf681..c67c987e 100644 --- a/test/test_config.dart +++ b/test/test_config.dart @@ -5,8 +5,12 @@ import 'package:threedpass/setup.dart' as di_setup; Future config() async { setUpAll(() async { + TestWidgetsFlutterBinding.ensureInitialized(); + await hive_setup.hiveSetup(); await di_setup.setup(); await EasyLocalization.ensureInitialized(); + + print('setUpAll'); }); } diff --git a/test/ui/scan_page/scan_page_test.dart b/test/ui/scan_page/scan_page_test.dart index c3432cca..7879d432 100644 --- a/test/ui/scan_page/scan_page_test.dart +++ b/test/ui/scan_page/scan_page_test.dart @@ -1,15 +1,85 @@ +import 'dart:io'; + +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:threedpass/features/scan_page/presentation/pages/scan_page.dart'; -import 'package:threedpass/main.dart'; +import 'package:threedpass/core/widgets/buttons/elevated_button.dart'; +import 'package:threedpass/features/hashes_list/bloc/hashes_list_bloc.dart'; +import 'package:threedpass/features/hashes_list/domain/entities/snapshot_create_from_file/snapshot_create_from_file.dart'; +import 'package:threedpass/features/scan_page/bloc/scan_isolate_cubit.dart'; +import 'package:threedpass/features/scan_page/presentation/widgets/get_object_from_file_button.dart'; +import 'package:threedpass/features/settings_page/bloc/settings_page_cubit.dart'; +import 'package:threedpass/router/router.gr.dart'; -import '../../test_config.dart'; +import '../../test_app.dart'; void main() { // config(); + final app = TestApp.instance; + group('Example test', () { testWidgets('MyWidget has a title and message', (tester) async { - // Create the widget by telling the tester to build it. - await tester.pumpWidget(ThreeDApp()); + print('aaaaaaa1'); + // Initial pump + await tester.pumpWidget(app); + print('aaaaaaa2'); + + final filePath = '${Directory.current.path}/resources/3dpass-487203.obj'; + // final Uri basedir = (goldenFileComparator. as LocalFileComparator).basedir; + // matchesGoldenFile(key) + // print(basedir.path); + + final file = await rootBundle.load('assets/textures/space.jpeg'); + print(file.lengthInBytes); + final file2 = await rootBundle.load('test/resources/3dpass-487203.obj'); + // print(file2.lengthInBytes); + + // var dir = Directory.current; + // while (!await dir + // .list() + // .any((entity) => entity.path.endsWith('pubspec.yaml'))) { + // dir = dir.parent; + // } + + // print(dir.absolute); + // print(Directory.current.listSync(recursive: true)); + // print(filePath); + // print(File(filePath).existsSync()); + // for (var i in tester.allElements) { + // print(i.widget.runtimeType); + // } + final BuildContext context = tester.element(find.byType(SizedBox)); + + final snapFactory = SnapshotFileFactory( + showLoader: () {}, + hashesListBloc: BlocProvider.of(context), + scanSettings: + BlocProvider.of(context).state.scanSettings, + // objectsDirectory: getIt(), + scanIsolateCubit: BlocProvider.of(context), + // recievePort: recievePort, + ); + + final pair = await snapFactory.createSnapshotFromFile( + pickedFilePath: filePath, + relativePath: filePath, + ); + + await context.router.push( + PreviewRouteWrapper( + hashObject: pair.left, + snapshot: pair.right, + createNewAnyway: true, + ), + ); + + print('aaaaaaa3'); + + await tester.pumpAndSettle(); + + print('aaaaaaa4'); }); }); } diff --git a/test/utils/assets_formatting.dart b/test/utils/assets_formatting.dart new file mode 100644 index 00000000..d6a9eb3d --- /dev/null +++ b/test/utils/assets_formatting.dart @@ -0,0 +1,44 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:threedpass/core/polkawallet/utils/balance_utils.dart'; +import 'package:threedpass/features/wallet_screen/assets_page/widgets/balance_card/locked_balance_card.dart'; + +void main() { + group('Widget tests', () { + testWidgets('Balance widget', (tester) async { + // Create the widget by telling the tester to build it. + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: Column( + children: [ + LockedBalanceCard( + tokenSymbol: 'P3D', + tokenDecimals: 12, + balance: '0x0000000000000000000044364c5baff6', + ), + ], + ), + ), + ); + // TODO check if localization works + final titleFinder = find.text('75 P3D'); + expect(titleFinder, findsOneWidget); + }); + }); + + group('Utility tests', () { + test('BalanceUtils.tokenInt', () { + const decimals = 12; + + final v1 = BalanceUtils.tokenInt('0', decimals); + expect(v1, BigInt.from(0)); + + final v2 = BalanceUtils.tokenInt('0.2', decimals); + expect(v2, BigInt.from(200000000000)); + + final v3 = BalanceUtils.tokenInt('2', decimals); + expect(v3, BigInt.from(2000000000000)); + }); + }); +} diff --git a/test/utils/tx_logs_handler.dart b/test/utils/tx_logs_handler.dart new file mode 100644 index 00000000..66fe4fd0 --- /dev/null +++ b/test/utils/tx_logs_handler.dart @@ -0,0 +1,62 @@ +// import 'package:flutter_test/flutter_test.dart'; +// import 'package:threedpass/core/polkawallet/utils/extrinsic_status.dart'; +// import 'package:threedpass/core/polkawallet/utils/tx_update_event_logs_handler.dart'; + +// void main() { +// group('TxUpdateLogsHandler gets extrinsic message', () { +// final inputStrings = [ +// '{"path":"onStatusChange11","data":"Ready"}', +// '{"path":"onStatusChange11","data":"Broadcast"}', +// '{"path":"txUpdateEvent|msgId=onStatusChange11","data":{"title":"balances.Withdraw","message":"ok"}}', +// '{"path":"txUpdateEvent|msgId=onStatusChange11","data":{"title":"transactionPayment.TransactionFeePaid","message":"ok"}}', +// '{"path":"uid=12;keyring.sendTx","data":{"hash":"0x8fe6ad176e277a03a90ea5db0361635bddc669a14d8d72e74269575836750777","blockHash":"0x99d3a3b6f9df21925e63fdb5988d901d67e3fa9b8f2c2c9ae62b9bd24e01cb6a"}}', +// ]; + +// for (final input in inputStrings) { +// test('false input № ${inputStrings.indexOf(input)}', () { +// bool res = false; + +// TxUpdateEventLogsHandler('onStatusChange11', ({ +// required final String? message, +// required final ExtrinsicStatus status, +// }) { +// res = true; +// }).handle(input); + +// expect(res, false); +// }); +// } + +// test('ExtrinsicSuccess OK', () { +// const input = +// '{"path":"txUpdateEvent|msgId=onStatusChange11","data":{"title":"system.ExtrinsicSuccess","message":"ok"}}'; + +// String res = ''; + +// TxUpdateEventLogsHandler('onStatusChange11', ({ +// required final String? message, +// required final ExtrinsicStatus status, +// }) { +// res = message ?? ''; +// }).handle(input); + +// expect(res, TxUpdateEventLogsHandler.extrinsicSuccess); +// }); + +// test('ExtrinsicFailed + MSG', () { +// const input = +// '{"path":"txUpdateEvent|msgId=onStatusChange23","data":{"title":"system.ExtrinsicFailed","message":"balances.InsufficientBalance"}}'; + +// String res = ''; + +// TxUpdateEventLogsHandler('onStatusChange23', ({ +// required final String? message, +// required final ExtrinsicStatus status, +// }) { +// res = message ?? ''; +// }).handle(input); + +// expect(res, 'balances.InsufficientBalance'); +// }); +// }); +// }