From aed73841afa1bd5a5cd0b9e16ca78403233616c4 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Thu, 10 Oct 2024 13:32:40 +0300 Subject: [PATCH 001/102] feat: Create dev run configuration --- lib/main_dev.dart | 430 ++++++++++++++++++ .../development_intialization_screen.dart | 57 +++ lib/screens/screens.dart | 1 + run_configurations/dev.run.xml | 6 + 4 files changed, 494 insertions(+) create mode 100644 lib/main_dev.dart create mode 100644 lib/screens/development_intialization_screen.dart create mode 100644 run_configurations/dev.run.xml diff --git a/lib/main_dev.dart b/lib/main_dev.dart new file mode 100644 index 00000000..9432e248 --- /dev/null +++ b/lib/main_dev.dart @@ -0,0 +1,430 @@ +import 'dart:async'; +import 'dart:io'; +import 'dart:isolate'; + +import 'package:flutter/foundation.dart' show kDebugMode; +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:hive/hive.dart'; +import 'package:layout/layout.dart'; +import 'package:local_notifier/local_notifier.dart'; +import 'package:logging/logging.dart'; +import 'package:overlay_support/overlay_support.dart'; +import 'package:path/path.dart' as path; +import 'package:provider/provider.dart'; +import 'package:retry/retry.dart'; +import 'package:tray_manager/tray_manager.dart'; +import 'package:window_manager/window_manager.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/auto_unlock_htlc_worker.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/handlers/htlc_swaps_handler.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/wallet_connect/chains/i_chain.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/wallet_connect/chains/nom_service.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/wallet_connect/wallet_connect_pairings_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/wallet_connect/wallet_connect_sessions_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/main.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; +import 'package:zenon_syrius_wallet_flutter/services/htlc_swaps_service.dart'; +import 'package:zenon_syrius_wallet_flutter/services/i_web3wallet_service.dart'; +import 'package:zenon_syrius_wallet_flutter/services/shared_prefs_service.dart'; +import 'package:zenon_syrius_wallet_flutter/services/web3wallet_service.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/functions.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +const String p = String.fromEnvironment('PASSWORD'); + +main() async { + WidgetsFlutterBinding.ensureInitialized(); + + Provider.debugCheckInvalidValueType = null; + + ensureDirectoriesExist(); + Hive.init(znnDefaultPaths.cache.path.toString()); + + // Setup logger + Directory syriusLogDir = + Directory(path.join(znnDefaultCacheDirectory.path, 'log')); + if (!syriusLogDir.existsSync()) { + syriusLogDir.createSync(recursive: true); + } + final logFile = File( + '${syriusLogDir.path}${path.separator}syrius-${DateTime.now().millisecondsSinceEpoch}.log'); + Logger.root.level = Level.ALL; + Logger.root.onRecord.listen((LogRecord record) { + if (kDebugMode) { + print( + '${record.level.name} ${record.loggerName} ${record.message} ${record.time}: ' + '${record.error} ${record.stackTrace}\n'); + } + logFile.writeAsString( + '${record.level.name} ${record.loggerName} ${record.message} ${record.time}: ' + '${record.error} ${record.stackTrace}\n', + mode: FileMode.append, + flush: true, + ); + }); + + windowManager.ensureInitialized(); + await windowManager.setPreventClose(true); + + web3WalletService = Web3WalletService(); + web3WalletService!.create(); + + // Setup services + setup(); + + retry(() => web3WalletService!.init(), + retryIf: (e) => e is SocketException || e is TimeoutException, + maxAttempts: 0x7FFFFFFFFFFFFFFF); + + // Setup local_notifier + await localNotifier.setup( + appName: 's y r i u s', + // The parameter shortcutPolicy only works on Windows + shortcutPolicy: ShortcutPolicy.requireCreate, + ); + + // Setup tray manager + await _setupTrayManager(); + + // Load default community nodes from assets + await _loadDefaultCommunityNodes(); + + // Register Hive adapters + Hive.registerAdapter(NotificationTypeAdapter()); + Hive.registerAdapter(WalletNotificationAdapter()); + + if (sharedPrefsService == null) { + sharedPrefsService = await sl.getAsync(); + } else { + await sharedPrefsService!.checkIfBoxIsOpen(); + } + + htlcSwapsService ??= sl.get(); + + windowManager.waitUntilReadyToShow().then((_) async { + await windowManager.setTitle('s y r i u s'); + await windowManager.setMinimumSize(const Size(1200, 600)); + await windowManager.show(); + + if (sharedPrefsService != null) { + double? windowSizeWidth = sharedPrefsService!.get(kWindowSizeWidthKey); + double? windowSizeHeight = sharedPrefsService!.get(kWindowSizeHeightKey); + if (windowSizeWidth != null && + windowSizeWidth >= 1200 && + windowSizeHeight != null && + windowSizeHeight >= 600) { + await windowManager.setSize(Size(windowSizeWidth, windowSizeHeight)); + } else { + await windowManager.setSize(const Size(1200, 600)); + } + + double? windowPositionX = sharedPrefsService!.get(kWindowPositionXKey); + double? windowPositionY = sharedPrefsService!.get(kWindowPositionYKey); + if (windowPositionX != null && windowPositionY != null) { + windowPositionX = windowPositionX >= 0 ? windowPositionX : 100; + windowPositionY = windowPositionY >= 0 ? windowPositionY : 100; + await windowManager + .setPosition(Offset(windowPositionX, windowPositionY)); + } + + bool? windowMaximized = sharedPrefsService!.get(kWindowMaximizedKey); + if (windowMaximized == true) { + await windowManager.maximize(); + } + } + }); + + runApp( + const MyApp(), + ); +} + +Future _setupTrayManager() async { + await trayManager.setIcon( + Platform.isWindows + ? 'assets/images/tray_app_icon.ico' + : 'assets/images/tray_app_icon.png', + ); + if (Platform.isMacOS) { + await trayManager.setToolTip('s y r i u s'); + } + List items = [ + MenuItem( + key: 'show_wallet', + label: 'Show wallet', + ), + MenuItem( + key: 'hide_wallet', + label: 'Hide wallet', + ), + MenuItem.separator(), + MenuItem( + key: 'exit', + label: 'Exit wallet', + ), + ]; + await trayManager.setContextMenu(Menu(items: items)); +} + +Future _loadDefaultCommunityNodes() async { + try { + var nodes = await loadJsonFromAssets('assets/community-nodes.json') + as List; + kDefaultCommunityNodes = nodes + .map((node) => node.toString()) + .where((node) => InputValidators.node(node) == null) + .toList(); + } catch (e, stackTrace) { + Logger('main') + .log(Level.WARNING, '_loadDefaultCommunityNodes', e, stackTrace); + } +} + +void setup() { + sl.registerSingleton(Zenon()); + zenon = sl(); + sl.registerLazySingletonAsync( + (() => SharedPrefsService.getInstance().then((value) => value!))); + sl.registerSingleton(HtlcSwapsService.getInstance()); + + // Initialize WalletConnect service + sl.registerSingleton(web3WalletService!); + sl.registerSingleton( + NoMService(reference: NoMChainId.mainnet), + instanceName: NoMChainId.mainnet.chain(), + ); + + sl.registerSingleton(AutoReceiveTxWorker.getInstance()); + sl.registerSingleton( + AutoUnlockHtlcWorker.getInstance()); + + sl.registerSingleton(HtlcSwapsHandler.getInstance()); + + sl.registerSingleton(ReceivePort(), + instanceName: 'embeddedStoppedPort'); + sl.registerSingleton( + sl(instanceName: 'embeddedStoppedPort').asBroadcastStream(), + instanceName: 'embeddedStoppedStream'); + + sl.registerSingleton(PlasmaStatsBloc()); + sl.registerSingleton(BalanceBloc()); + sl.registerSingleton( + TransferWidgetsBalanceBloc()); + sl.registerSingleton(NotificationsBloc()); + sl.registerSingleton(AcceleratorBalanceBloc()); + sl.registerSingleton(PowGeneratingStatusBloc()); + sl.registerSingleton( + WalletConnectPairingsBloc(), + ); + sl.registerSingleton( + WalletConnectSessionsBloc(), + ); +} + +class MyApp extends StatefulWidget { + const MyApp({Key? key}) : super(key: key); + + @override + State createState() { + return _MyAppState(); + } +} + +class _MyAppState extends State with WindowListener, TrayListener { + @override + void initState() { + windowManager.addListener(this); + trayManager.addListener(this); + initPlatformState(); + super.initState(); + } + + // Platform messages are asynchronous, so we initialize in an async method + Future initPlatformState() async { + kLocalIpAddress = + await NetworkUtils.getLocalIpAddress(InternetAddressType.IPv4); + + if (!mounted) return; + } + + @override + Widget build(BuildContext context) { + return MultiProvider( + providers: [ + ChangeNotifierProvider( + create: (_) => SelectedAddressNotifier(), + ), + ChangeNotifierProvider( + create: (_) => PlasmaBeneficiaryAddressNotifier(), + ), + ChangeNotifierProvider( + create: (_) => PlasmaGeneratedNotifier(), + ), + ChangeNotifierProvider( + create: (_) => TextScalingNotifier(), + ), + ChangeNotifierProvider( + create: (_) => AppThemeNotifier(), + ), + ChangeNotifierProvider>>( + create: (_) => ValueNotifier>( + [], + ), + ), + Provider( + create: (_) => LockBloc(), + builder: (context, child) { + return Consumer( + builder: (_, appThemeNotifier, __) { + LockBloc lockBloc = + Provider.of(context, listen: false); + return OverlaySupport( + child: Listener( + onPointerSignal: (event) { + if (event is PointerScrollEvent) { + lockBloc.addEvent(LockEvent.resetTimer); + } + }, + onPointerCancel: (_) => + lockBloc.addEvent(LockEvent.resetTimer), + onPointerDown: (_) => + lockBloc.addEvent(LockEvent.resetTimer), + onPointerHover: (_) => + lockBloc.addEvent(LockEvent.resetTimer), + onPointerMove: (_) => + lockBloc.addEvent(LockEvent.resetTimer), + onPointerUp: (_) => lockBloc.addEvent(LockEvent.resetTimer), + child: MouseRegion( + onEnter: (_) => lockBloc.addEvent(LockEvent.resetTimer), + onExit: (_) => lockBloc.addEvent(LockEvent.resetTimer), + child: RawKeyboardListener( + focusNode: FocusNode(), + onKey: (RawKeyEvent event) { + lockBloc.addEvent(LockEvent.resetTimer); + }, + child: Layout( + child: MaterialApp( + title: 's y r i u s', + navigatorKey: globalNavigatorKey, + debugShowCheckedModeBanner: false, + theme: AppTheme.lightTheme, + darkTheme: AppTheme.darkTheme, + themeMode: appThemeNotifier.currentThemeMode, + initialRoute: DevelopmentInitializationScreen.route, + scrollBehavior: RemoveOverscrollEffect(), + routes: { + AccessWalletScreen.route: (context) => + const AccessWalletScreen(), + DevelopmentInitializationScreen.route: (context) => + const DevelopmentInitializationScreen(), + MainAppContainer.route: (context) => + const MainAppContainer(), + NodeManagementScreen.route: (_) => + const NodeManagementScreen(), + }, + onGenerateRoute: (settings) { + if (settings.name == SyriusErrorWidget.route) { + final args = settings.arguments + as CustomSyriusErrorWidgetArguments; + return MaterialPageRoute( + builder: (context) => + SyriusErrorWidget(args.errorText), + ); + } + return null; + }, + ), + ), + ), + ), + ), + ); + }, + ); + }, + ), + ], + ); + } + + @override + void onWindowClose() async { + bool windowMaximized = await windowManager.isMaximized(); + await sharedPrefsService!.put( + kWindowMaximizedKey, + windowMaximized, + ); + + if (windowMaximized != true) { + Size windowSize = await windowManager.getSize(); + await sharedPrefsService!.put( + kWindowSizeWidthKey, + windowSize.width, + ); + await sharedPrefsService!.put( + kWindowSizeHeightKey, + windowSize.height, + ); + + Offset windowPosition = await windowManager.getPosition(); + await sharedPrefsService!.put( + kWindowPositionXKey, + windowPosition.dx, + ); + await sharedPrefsService!.put( + kWindowPositionYKey, + windowPosition.dy, + ); + } + + sl().wsClient.stop(); + Future.delayed(const Duration(seconds: 60)).then((value) => exit(0)); + await NodeUtils.closeEmbeddedNode(); + await sl.reset(); + super.onWindowClose(); + deactivate(); + dispose(); + exit(0); + } + + @override + void onTrayIconMouseDown() { + trayManager.popUpContextMenu(); + } + + @override + void onTrayIconRightMouseDown() {} + + @override + void onTrayIconRightMouseUp() {} + + @override + void onTrayMenuItemClick(MenuItem menuItem) async { + switch (menuItem.key) { + case 'show_wallet': + windowManager.show(); + break; + case 'hide_wallet': + if (!await windowManager.isMinimized()) { + windowManager.minimize(); + } + break; + case 'exit': + windowManager.destroy(); + break; + default: + break; + } + } + + @override + void dispose() { + windowManager.removeListener(this); + trayManager.removeListener(this); + super.dispose(); + } +} diff --git a/lib/screens/development_intialization_screen.dart b/lib/screens/development_intialization_screen.dart new file mode 100644 index 00000000..c28d201d --- /dev/null +++ b/lib/screens/development_intialization_screen.dart @@ -0,0 +1,57 @@ +import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; + +/// This will be used to quickly initialize the app when testing in the +/// development phase + +class DevelopmentInitializationScreen extends StatelessWidget { + static const String route = 'development-initialization-screen'; + + const DevelopmentInitializationScreen({super.key}); + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: _initializeApp(context: context), + builder: (_, snapshot) { + if (snapshot.hasData) { + final bool finished = snapshot.data!; + if (finished) { + _navigateToHomeScreen(context: context); + } else { + return Text('Error while initializing the app'); + } + } else if (snapshot.hasError) { + return Text('Error: ${snapshot.error}'); + } + + return Center(child: CircularProgressIndicator()); + }, + ); + } + + Future _initializeApp({required BuildContext context}) async { + try { + await InitUtils.initApp(context); + if (kWalletPath == null) { + if (!context.mounted) return false; + Navigator.pushReplacementNamed( + context, + AccessWalletScreen.route, + ); + } + return true; + } on Exception catch (_) { + rethrow; + } + } + + void _navigateToHomeScreen({required BuildContext context}) { + Navigator.of( + context, + rootNavigator: true, + ).pushReplacementNamed(MainAppContainer.route); + } +} diff --git a/lib/screens/screens.dart b/lib/screens/screens.dart index f0687cce..e48b8f6e 100644 --- a/lib/screens/screens.dart +++ b/lib/screens/screens.dart @@ -1,6 +1,7 @@ library screens; export 'change_wallet_password_screen.dart'; +export 'development_intialization_screen.dart'; export 'dump_mnemonic_screen.dart'; export 'node_management_screen.dart'; export 'project_details_screen.dart'; diff --git a/run_configurations/dev.run.xml b/run_configurations/dev.run.xml new file mode 100644 index 00000000..83c0f623 --- /dev/null +++ b/run_configurations/dev.run.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file From 7b18e50fe60f8db6fff30d8dbcd08e0658cff130 Mon Sep 17 00:00:00 2001 From: kossmmos <184493470+kossmmos@users.noreply.github.com> Date: Thu, 10 Oct 2024 13:15:36 +0200 Subject: [PATCH 002/102] refactor: dashboard blocs. --- .../dashboard/balance/balance.dart | 3 + .../balance/cubit/balance_cubit.dart | 64 ++++++++++++++ .../balance/cubit/balance_state.dart | 37 ++++++++ .../dashboard/balance/view/balance_card.dart | 63 ++++++++++++++ .../balance/widgets/balance_empty.dart | 16 ++++ .../balance/widgets/balance_error.dart | 17 ++++ .../balance/widgets/balance_loading.dart | 15 ++++ .../balance/widgets/balance_populated.dart | 22 +++++ .../dashboard/balance/widgets/widgets.dart | 4 + .../balance_dashboard/balance_dashboard.dart | 3 + .../cubit/balance_dashboard_cubit.dart | 43 +++++++++ .../cubit/balance_dashboard_state.dart | 37 ++++++++ .../view/balance_dashboard_card.dart | 60 +++++++++++++ .../widgets/balance_dashboard_empty.dart | 10 +++ .../widgets/balance_dashboard_error.dart | 12 +++ .../widgets/balance_dashboard_loading.dart | 10 +++ .../widgets/balance_dashboard_populated.dart | 13 +++ .../balance_dashboard/widgets/widgets.dart | 4 + lib/rearchitecture/dashboard/dashboard.dart | 12 +++ .../dashboard/dashboard_cubit.dart | 87 +++++++++++++++++++ .../dashboard/dashboard_state.dart | 61 +++++++++++++ .../delegation/cubit/delegation_cubit.dart | 45 ++++++++++ .../delegation/cubit/delegation_state.dart | 37 ++++++++ .../dashboard/delegation/delegation.dart | 3 + .../delegation/view/delegation_card.dart | 39 +++++++++ .../delegation/widgets/delegation_empty.dart | 10 +++ .../delegation/widgets/delegation_error.dart | 12 +++ .../widgets/delegation_loading.dart | 10 +++ .../widgets/delegation_populated.dart | 13 +++ .../dashboard/delegation/widgets/widgets.dart | 4 + .../cubit/dual_coin_stats_cubit.dart | 44 ++++++++++ .../cubit/dual_coin_stats_state.dart | 37 ++++++++ .../dual_coin_stats/dual_coin_stats.dart | 3 + .../view/dual_coin_stats_card.dart | 39 +++++++++ .../widgets/dual_coin_stats_empty.dart | 10 +++ .../widgets/dual_coin_stats_error.dart | 12 +++ .../widgets/dual_coin_stats_loading.dart | 10 +++ .../widgets/dual_coin_stats_populated.dart | 13 +++ .../dual_coin_stats/widgets/widgets.dart | 4 + .../pillars/cubit/pillars_cubit.dart | 35 ++++++++ .../pillars/cubit/pillars_state.dart | 37 ++++++++ .../dashboard/pillars/pillars.dart | 3 + .../dashboard/pillars/view/pillars_card.dart | 39 +++++++++ .../pillars/widgets/pillars_empty.dart | 10 +++ .../pillars/widgets/pillars_error.dart | 12 +++ .../pillars/widgets/pillars_loading.dart | 10 +++ .../pillars/widgets/pillars_populated.dart | 12 +++ .../dashboard/pillars/widgets/widgets.dart | 4 + .../cubit/realtime_statistics_cubit.dart | 84 ++++++++++++++++++ .../cubit/realtime_statistics_state.dart | 36 ++++++++ .../realtime_statistics.dart | 3 + .../view/realtime_statistics_card.dart | 40 +++++++++ .../widgets/realtime_statistics_empty.dart | 10 +++ .../widgets/realtime_statistics_error.dart | 12 +++ .../widgets/realtime_statistics_loading.dart | 10 +++ .../realtime_statistics_populated.dart | 13 +++ .../realtime_statistics/widgets/widgets.dart | 4 + .../sentinels/cubit/sentinels_cubit.dart | 36 ++++++++ .../sentinels/cubit/sentinels_state.dart | 36 ++++++++ .../dashboard/sentinels/sentinels.dart | 3 + .../sentinels/view/sentinels_card.dart | 38 ++++++++ .../sentinels/widgets/sentinels_empty.dart | 10 +++ .../sentinels/widgets/sentinels_error.dart | 12 +++ .../sentinels/widgets/sentinels_loading.dart | 10 +++ .../widgets/sentinels_populated.dart | 13 +++ .../dashboard/sentinels/widgets/widgets.dart | 4 + .../staking/cubit/staking_cubit.dart | 53 +++++++++++ .../staking/cubit/staking_state.dart | 36 ++++++++ .../dashboard/staking/staking.dart | 3 + .../dashboard/staking/view/staking_card.dart | 38 ++++++++ .../staking/widgets/staking_empty.dart | 10 +++ .../staking/widgets/staking_error.dart | 12 +++ .../staking/widgets/staking_loading.dart | 10 +++ .../staking/widgets/staking_populated.dart | 13 +++ .../dashboard/staking/widgets/widgets.dart | 4 + .../total_hourly_transactions_cubit.dart | 73 ++++++++++++++++ .../total_hourly_transactions_state.dart | 39 +++++++++ .../total_hourly_transactions.dart | 3 + .../view/total_hourly_transactions_card.dart | 38 ++++++++ .../total_hourly_transactions_empty.dart | 10 +++ .../total_hourly_transactions_error.dart | 12 +++ .../total_hourly_transactions_loading.dart | 10 +++ .../total_hourly_transactions_populated.dart | 12 +++ .../widgets/widgets.dart | 4 + lib/utils/constants.dart | 1 + pubspec.lock | 16 ++++ pubspec.yaml | 2 + 87 files changed, 1873 insertions(+) create mode 100644 lib/rearchitecture/dashboard/balance/balance.dart create mode 100644 lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart create mode 100644 lib/rearchitecture/dashboard/balance/cubit/balance_state.dart create mode 100644 lib/rearchitecture/dashboard/balance/view/balance_card.dart create mode 100644 lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart create mode 100644 lib/rearchitecture/dashboard/balance/widgets/balance_error.dart create mode 100644 lib/rearchitecture/dashboard/balance/widgets/balance_loading.dart create mode 100644 lib/rearchitecture/dashboard/balance/widgets/balance_populated.dart create mode 100644 lib/rearchitecture/dashboard/balance/widgets/widgets.dart create mode 100644 lib/rearchitecture/dashboard/balance_dashboard/balance_dashboard.dart create mode 100644 lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_cubit.dart create mode 100644 lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_state.dart create mode 100644 lib/rearchitecture/dashboard/balance_dashboard/view/balance_dashboard_card.dart create mode 100644 lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_empty.dart create mode 100644 lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_error.dart create mode 100644 lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_loading.dart create mode 100644 lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_populated.dart create mode 100644 lib/rearchitecture/dashboard/balance_dashboard/widgets/widgets.dart create mode 100644 lib/rearchitecture/dashboard/dashboard.dart create mode 100644 lib/rearchitecture/dashboard/dashboard_cubit.dart create mode 100644 lib/rearchitecture/dashboard/dashboard_state.dart create mode 100644 lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart create mode 100644 lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart create mode 100644 lib/rearchitecture/dashboard/delegation/delegation.dart create mode 100644 lib/rearchitecture/dashboard/delegation/view/delegation_card.dart create mode 100644 lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart create mode 100644 lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart create mode 100644 lib/rearchitecture/dashboard/delegation/widgets/delegation_loading.dart create mode 100644 lib/rearchitecture/dashboard/delegation/widgets/delegation_populated.dart create mode 100644 lib/rearchitecture/dashboard/delegation/widgets/widgets.dart create mode 100644 lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart create mode 100644 lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart create mode 100644 lib/rearchitecture/dashboard/dual_coin_stats/dual_coin_stats.dart create mode 100644 lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart create mode 100644 lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart create mode 100644 lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart create mode 100644 lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart create mode 100644 lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart create mode 100644 lib/rearchitecture/dashboard/dual_coin_stats/widgets/widgets.dart create mode 100644 lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart create mode 100644 lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart create mode 100644 lib/rearchitecture/dashboard/pillars/pillars.dart create mode 100644 lib/rearchitecture/dashboard/pillars/view/pillars_card.dart create mode 100644 lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart create mode 100644 lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart create mode 100644 lib/rearchitecture/dashboard/pillars/widgets/pillars_loading.dart create mode 100644 lib/rearchitecture/dashboard/pillars/widgets/pillars_populated.dart create mode 100644 lib/rearchitecture/dashboard/pillars/widgets/widgets.dart create mode 100644 lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart create mode 100644 lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart create mode 100644 lib/rearchitecture/dashboard/realtime_statistics/realtime_statistics.dart create mode 100644 lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart create mode 100644 lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_empty.dart create mode 100644 lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart create mode 100644 lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_loading.dart create mode 100644 lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart create mode 100644 lib/rearchitecture/dashboard/realtime_statistics/widgets/widgets.dart create mode 100644 lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart create mode 100644 lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart create mode 100644 lib/rearchitecture/dashboard/sentinels/sentinels.dart create mode 100644 lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart create mode 100644 lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart create mode 100644 lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart create mode 100644 lib/rearchitecture/dashboard/sentinels/widgets/sentinels_loading.dart create mode 100644 lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart create mode 100644 lib/rearchitecture/dashboard/sentinels/widgets/widgets.dart create mode 100644 lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart create mode 100644 lib/rearchitecture/dashboard/staking/cubit/staking_state.dart create mode 100644 lib/rearchitecture/dashboard/staking/staking.dart create mode 100644 lib/rearchitecture/dashboard/staking/view/staking_card.dart create mode 100644 lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart create mode 100644 lib/rearchitecture/dashboard/staking/widgets/staking_error.dart create mode 100644 lib/rearchitecture/dashboard/staking/widgets/staking_loading.dart create mode 100644 lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart create mode 100644 lib/rearchitecture/dashboard/staking/widgets/widgets.dart create mode 100644 lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart create mode 100644 lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart create mode 100644 lib/rearchitecture/dashboard/total_hourly_transactions/total_hourly_transactions.dart create mode 100644 lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart create mode 100644 lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart create mode 100644 lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart create mode 100644 lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart create mode 100644 lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart create mode 100644 lib/rearchitecture/dashboard/total_hourly_transactions/widgets/widgets.dart diff --git a/lib/rearchitecture/dashboard/balance/balance.dart b/lib/rearchitecture/dashboard/balance/balance.dart new file mode 100644 index 00000000..e23b4c06 --- /dev/null +++ b/lib/rearchitecture/dashboard/balance/balance.dart @@ -0,0 +1,3 @@ +export 'cubit/balance_cubit.dart'; +export 'widgets/widgets.dart'; +export 'view/balance_card.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart b/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart new file mode 100644 index 00000000..df145180 --- /dev/null +++ b/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart @@ -0,0 +1,64 @@ + +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + + + +part 'balance_state.dart'; + +/// `BalanceCubit` is responsible for managing and fetching the account balances +/// of multiple addresses. It extends the `DashboardCubit` with a state +/// represented as a `Map` of addresses and their associated `AccountInfo`. + +class BalanceCubit extends DashboardCubit> { + /// Constructs a `BalanceCubit` with the provided `zenon` client and initial state. + /// + /// The [zenon] parameter provides access to the Zenon SDK for interacting with + /// account information, and the [initialState] is a map of addresses to their + /// respective balances at the time the cubit is initialized. + BalanceCubit(super.zenon, super.initialState); + + /// Fetches the balance information for a list of predefined addresses. + /// + /// This method retrieves the account information for each address in the + /// `kDefaultAddressList`, and stores it in a map where the key is the + /// address string, and the value is the `AccountInfo` for that address. + /// + /// If an error occurs during the fetch operation, it will be propagated upwards. + /// + /// Returns a [Map] where each key is an address and the corresponding value is + /// an [AccountInfo] object for that address. + @override + Future> fetch() async { + try { + final Map addressBalanceMap = {}; + final List accountInfoList = await Future.wait( + kDefaultAddressList.map( + (address) => _getBalancePerAddress(address!), + ), + ); + + for (var accountInfo in accountInfoList) { + addressBalanceMap[accountInfo.address!] = accountInfo; + } + + return addressBalanceMap; + } catch (e) { + rethrow; + } + } + + /// Retrieves the balance information for a single address. + /// + /// The method interacts with the `zenon` client's ledger to get the + /// `AccountInfo` for the provided [address]. The address is parsed from + /// a string into an `Address` object before querying the ledger. + /// + /// Returns an [AccountInfo] object containing the balance details for the given address. + /// + /// Throws an exception if the balance retrieval fails. + Future _getBalancePerAddress(String address) async { + return await zenon.ledger.getAccountInfoByAddress(Address.parse(address)); + } +} diff --git a/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart b/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart new file mode 100644 index 00000000..517dc1f2 --- /dev/null +++ b/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart @@ -0,0 +1,37 @@ +part of 'balance_cubit.dart'; + +/// The state class for the `BalanceCubit`, extending `DashboardState` and managing account balance data. +/// +/// `BalanceState` holds a map of account addresses to their corresponding `AccountInfo` objects. +/// This state is used by the `BalanceCubit` to track the balance information for multiple addresses. +class BalanceState extends DashboardState> { + /// Constructs a new `BalanceState`. + /// + /// This state uses the default `status`, `data`, and `error` from the parent `DashboardState` class + /// and initializes them for managing balance data. + BalanceState({ + super.status, + super.data, + super.error, + }); + + /// Creates a copy of the current `BalanceState` with optional new values for `status`, `data`, and `error`. + /// + /// This method is used to create a new state with updated fields if provided, + /// otherwise retaining the existing values. + /// + /// Returns: + /// - A new instance of `BalanceState` with the updated values or the existing ones if none are provided. + @override + DashboardState> copyWith({ + CubitStatus? status, + Map? data, + Object? error, + }) { + return BalanceState( + status: status ?? this.status, + data: data ?? this.data, + error: error ?? this.error, + ); + } +} diff --git a/lib/rearchitecture/dashboard/balance/view/balance_card.dart b/lib/rearchitecture/dashboard/balance/view/balance_card.dart new file mode 100644 index 00000000..14010769 --- /dev/null +++ b/lib/rearchitecture/dashboard/balance/view/balance_card.dart @@ -0,0 +1,63 @@ + +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/main.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; + + + +/// A `BalanceCard` widget that displays balance information for a user. +/// +/// The widget uses a `BalanceCubit` to fetch and manage account balance data +/// and presents the state in different views based on the current status +/// (e.g., loading, success, failure). +class BalanceCard extends StatelessWidget { + /// Constructs a `BalanceCard` widget. + /// + /// The widget is a stateless widget and expects a `BalanceCubit` to be + /// provided via a `BlocProvider`. + const BalanceCard({super.key}); + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (_) { + // Creates a `BalanceCubit` instance, passing in the `zenon` client + // and an initial `BalanceState`. The cubit immediately begins fetching + // balance data by calling `fetch()`. + final BalanceCubit cubit = BalanceCubit( + zenon!, + BalanceState() + ); + cubit.fetch(); + return cubit; + }, + child: Scaffold( + body: BlocBuilder( + builder: (context, state) { + // Uses a `switch` statement to display different widgets based on + // the current cubit state. The state is managed by the `BalanceCubit` and + // is derived from `DashboardState`, with different widgets rendered for each status. + return switch (state.status) { + // Displays an empty balance view when the cubit is in its initial state. + CubitStatus.initial => const BalanceEmpty(), + + // Shows a loading indicator while the cubit is fetching balance data. + CubitStatus.loading => const BalanceLoading(), + + // Displays an error message if fetching balance data fails. + CubitStatus.failure => BalanceError( + error: state.error!, + ), + + // Shows the populated balance data when it is successfully fetched. + CubitStatus.success => BalancePopulated( + data: state.data!, + ), + }; + }, + ), + ), + ); + } +} diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart new file mode 100644 index 00000000..1b1f457d --- /dev/null +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart @@ -0,0 +1,16 @@ +import 'package:flutter/material.dart'; + +/// A `BalanceEmpty` widget that displays a simple message indicating that there +/// is no balance data available. +/// +/// This widget is displayed when the `BalanceCubit` is in its initial state, meaning +/// no data has been loaded yet or the balance data is empty. +class BalanceEmpty extends StatelessWidget { + const BalanceEmpty({super.key}); + + @override + Widget build(BuildContext context) { + // Returns a simple `Text` widget displaying the message 'empty'. + return const Text('empty'); + } +} diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_error.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_error.dart new file mode 100644 index 00000000..89f98754 --- /dev/null +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_error.dart @@ -0,0 +1,17 @@ +import 'package:flutter/material.dart'; + +/// A `BalanceError` widget that displays an error message when the balance +/// data fetching fails. +/// +/// This widget is displayed when the `BalanceCubit` encounters an error +/// while trying to load the balance data. +class BalanceError extends StatelessWidget { + final Object error; + + const BalanceError({required this.error, super.key}); + + @override + Widget build(BuildContext context) { + return Text(error.toString()); + } +} diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_loading.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_loading.dart new file mode 100644 index 00000000..62f226f7 --- /dev/null +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_loading.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +/// A `BalanceLoading` widget that displays a loading message while the balance +/// data is being fetched. +/// +/// This widget is shown when the `BalanceCubit` is in the `loading` state, +/// indicating that the balance data is currently being loaded. +class BalanceLoading extends StatelessWidget { + const BalanceLoading({super.key}); + + @override + Widget build(BuildContext context) { + return const Text('loading'); + } +} diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_populated.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_populated.dart new file mode 100644 index 00000000..92f747f5 --- /dev/null +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_populated.dart @@ -0,0 +1,22 @@ +import 'package:flutter/material.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +/// A `BalancePopulated` widget that displays balance data once it has been +/// successfully fetched and populated. +/// +/// This widget is displayed when the `BalanceCubit` is in the `success` state, +/// and the balance data is available for rendering. +class BalancePopulated extends StatelessWidget { + /// The balance data that has been successfully fetched. + /// + /// The data is a map where the key is a string (representing the account address), + /// and the value is an `AccountInfo` object containing the balance details. + final Map? data; + + const BalancePopulated({required this.data, super.key}); + + @override + Widget build(BuildContext context) { + return Text(data.toString()); + } +} diff --git a/lib/rearchitecture/dashboard/balance/widgets/widgets.dart b/lib/rearchitecture/dashboard/balance/widgets/widgets.dart new file mode 100644 index 00000000..90494925 --- /dev/null +++ b/lib/rearchitecture/dashboard/balance/widgets/widgets.dart @@ -0,0 +1,4 @@ +export 'balance_empty.dart'; +export 'balance_error.dart'; +export 'balance_loading.dart'; +export 'balance_populated.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/balance_dashboard/balance_dashboard.dart b/lib/rearchitecture/dashboard/balance_dashboard/balance_dashboard.dart new file mode 100644 index 00000000..e1abc8c2 --- /dev/null +++ b/lib/rearchitecture/dashboard/balance_dashboard/balance_dashboard.dart @@ -0,0 +1,3 @@ +export 'cubit/balance_dashboard_cubit.dart'; +export 'widgets/widgets.dart'; +export 'view/balance_dashboard_card.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_cubit.dart b/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_cubit.dart new file mode 100644 index 00000000..2266e192 --- /dev/null +++ b/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_cubit.dart @@ -0,0 +1,43 @@ +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +part 'balance_dashboard_state.dart'; + +/// A `BalanceDashboardCubit` that fetches and manages the account balance data for a single account. +/// +/// This cubit extends `DashboardCubit`, utilizing the `AccountInfo` data type to store +/// and manage the balance data for a specific account (identified by `kDemoAddress`). +/// It provides the logic for fetching and updating the balance. +class BalanceDashboardCubit extends DashboardCubit { + /// Constructs a `BalanceDashboardCubit`, passing the `zenon` client and the initial state to the parent class. + /// + /// The `zenon` client is used to interact with the Zenon ledger to retrieve account information. + BalanceDashboardCubit(super.zenon, super.initialState); + + /// Fetches the account balance data for the provided address. + /// + /// This method retrieves account information using the Zenon SDK's `getAccountInfoByAddress()` method. + /// It checks the balance and block count of the account: + /// - If the account has blocks and a non-zero balance (either ZNN or QSR), it returns the `AccountInfo`. + /// - If the balance is empty, it throws an error indicating that the balance is zero. + /// + /// Throws: + /// - An error if the balance is empty or any exception occurs during data fetching. + @override + Future fetch() async { + try { + final AccountInfo response = await zenon.ledger + .getAccountInfoByAddress(Address.parse(kSelectedAddress!)); + + if (response.blockCount! > 0 && + (response.znn()! > BigInt.zero || response.qsr()! > BigInt.zero)) { + return response; + } else { + throw 'Empty balance on the selected address'; + } + } catch (e) { + rethrow; + } + } +} diff --git a/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_state.dart b/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_state.dart new file mode 100644 index 00000000..ef3be939 --- /dev/null +++ b/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_state.dart @@ -0,0 +1,37 @@ +part of 'balance_dashboard_cubit.dart'; + +/// The state class for the `BalanceDashboardCubit`, extending `DashboardState` and managing detailed account balance data. +/// +/// `BalanceDashboardState` holds an `AccountInfo` object representing the balance information of a single account. +/// This state is used by the `BalanceDashboardCubit` to track detailed balance data. +class BalanceDashboardState extends DashboardState { + /// Constructs a new `BalanceDashboardState`. + /// + /// This state uses the default `status`, `data`, and `error` from the parent `DashboardState` class, + /// and initializes them to manage the detailed account balance. + BalanceDashboardState({ + super.status, + super.data, + super.error, + }); + + /// Creates a copy of the current `BalanceDashboardState` with optional new values for `status`, `data`, and `error`. + /// + /// This method is used to create a new state with updated fields if provided, + /// otherwise retaining the existing values. + /// + /// Returns: + /// - A new instance of `BalanceDashboardState` with updated values or the current ones if none are provided. + @override + DashboardState copyWith({ + CubitStatus? status, + AccountInfo? data, + Object? error, + }) { + return BalanceDashboardState( + status: status ?? this.status, + data: data ?? this.data, + error: error ?? this.error, + ); + } +} diff --git a/lib/rearchitecture/dashboard/balance_dashboard/view/balance_dashboard_card.dart b/lib/rearchitecture/dashboard/balance_dashboard/view/balance_dashboard_card.dart new file mode 100644 index 00000000..3972c65f --- /dev/null +++ b/lib/rearchitecture/dashboard/balance_dashboard/view/balance_dashboard_card.dart @@ -0,0 +1,60 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/main.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; + + + +/// A `BalanceDashboardCard` widget that displays the account balance information +/// for a specific account. +/// +/// This widget utilizes the `BalanceDashboardCubit` to manage the state of the +/// balance data and presents different views based on the current status +/// (e.g., loading, success, failure). +class BalanceDashboardCard extends StatelessWidget { + /// Constructs a `BalanceDashboardCard` widget. + const BalanceDashboardCard({super.key}); + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (_) { + // Creates a `BalanceDashboardCubit` instance, passing in the `zenon` client + // and an initial `BalanceDashboardState`. The cubit immediately begins fetching + // the balance data by calling `fetch()`. + final BalanceDashboardCubit cubit = BalanceDashboardCubit( + zenon!, + BalanceDashboardState(), + ); + cubit.fetch(); + return cubit; + }, + child: Scaffold( + body: BlocBuilder( + builder: (context, state) { + // Uses a `switch` statement to display different widgets based on + // the current cubit state. The state is managed by the `BalanceDashboardCubit` + // and derived from `DashboardState`, with different widgets rendered for each status. + return switch (state.status) { + // Displays an empty balance view when the cubit is in its initial state. + CubitStatus.initial => const BalanceDashboardEmpty(), + + // Shows a loading indicator while the cubit is fetching balance data. + CubitStatus.loading => const BalanceDashboardLoading(), + + // Displays an error message if fetching balance data fails. + CubitStatus.failure => BalanceDashboardError( + error: state.error!, + ), + + // Shows the populated balance data when it is successfully fetched. + CubitStatus.success => BalanceDashboardPopulated( + data: state.data!, + ), + }; + }, + ), + ), + ); + } +} diff --git a/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_empty.dart b/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_empty.dart new file mode 100644 index 00000000..0f900286 --- /dev/null +++ b/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_empty.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class BalanceDashboardEmpty extends StatelessWidget { + const BalanceDashboardEmpty({super.key}); + + @override + Widget build(BuildContext context) { + return const Text('empty'); + } +} \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_error.dart b/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_error.dart new file mode 100644 index 00000000..e0e8c9f8 --- /dev/null +++ b/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_error.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; + +class BalanceDashboardError extends StatelessWidget { + final Object error; + + const BalanceDashboardError({required this.error, super.key}); + + @override + Widget build(BuildContext context) { + return Text(error.toString()); + } +} diff --git a/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_loading.dart b/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_loading.dart new file mode 100644 index 00000000..09664a7e --- /dev/null +++ b/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_loading.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class BalanceDashboardLoading extends StatelessWidget { + const BalanceDashboardLoading({super.key}); + + @override + Widget build(BuildContext context) { + return const Text('loading'); + } +} diff --git a/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_populated.dart b/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_populated.dart new file mode 100644 index 00000000..205476ff --- /dev/null +++ b/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_populated.dart @@ -0,0 +1,13 @@ +import 'package:flutter/material.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +class BalanceDashboardPopulated extends StatelessWidget { + final AccountInfo? data; + + const BalanceDashboardPopulated({required this.data, super.key}); + + @override + Widget build(BuildContext context) { + return Text(data.toString()); + } +} diff --git a/lib/rearchitecture/dashboard/balance_dashboard/widgets/widgets.dart b/lib/rearchitecture/dashboard/balance_dashboard/widgets/widgets.dart new file mode 100644 index 00000000..df368d4b --- /dev/null +++ b/lib/rearchitecture/dashboard/balance_dashboard/widgets/widgets.dart @@ -0,0 +1,4 @@ +export 'balance_dashboard_empty.dart'; +export 'balance_dashboard_error.dart'; +export 'balance_dashboard_loading.dart'; +export 'balance_dashboard_populated.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/dashboard.dart b/lib/rearchitecture/dashboard/dashboard.dart new file mode 100644 index 00000000..7b626d6b --- /dev/null +++ b/lib/rearchitecture/dashboard/dashboard.dart @@ -0,0 +1,12 @@ +library dashboard; + +export '../dashboard/balance/balance.dart'; +export '../dashboard/balance_dashboard/balance_dashboard.dart'; +export '../dashboard/delegation/delegation.dart'; +export '../dashboard/dual_coin_stats/dual_coin_stats.dart'; +export '../dashboard/pillars/pillars.dart'; +export '../dashboard/realtime_statistics/realtime_statistics.dart'; +export '../dashboard/sentinels/sentinels.dart'; +export '../dashboard/staking/staking.dart'; +export '../dashboard/total_hourly_transactions/total_hourly_transactions.dart'; +export 'dashboard_cubit.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/dashboard_cubit.dart b/lib/rearchitecture/dashboard/dashboard_cubit.dart new file mode 100644 index 00000000..31e97472 --- /dev/null +++ b/lib/rearchitecture/dashboard/dashboard_cubit.dart @@ -0,0 +1,87 @@ +import 'dart:async'; +import 'package:bloc/bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +part 'dashboard_state.dart'; + +/// An abstract `DashboardCubit` class that manages periodic data fetching for a +/// dashboard feature. The cubit emits different states based on data loading, +/// success, or failure, and it periodically refreshes the data automatically. +/// +/// The generic type [T] represents the type of data managed by this cubit. +abstract class DashboardCubit extends Cubit> { + /// A timer that handles the auto-refreshing of data. + Timer? _autoRefresher; + + /// The Zenon client used to fetch data from the Zenon ledger. + final Zenon zenon; + final Duration refreshInterval; + + /// Constructs a `DashboardCubit` with the provided [zenon] client and initial state. + /// + /// The auto-refresh functionality is initialized upon the cubit's creation. + DashboardCubit(this.zenon, super.initialState, {this.refreshInterval = kDashboardRefreshInterval}) { + _startAutoRefresh(); + } + + /// Fetches data of type [T] that is managed by the cubit. + /// + /// This method needs to be implemented by subclasses, and it should define + /// the specific data-fetching logic (e.g., fetching account information). + Future fetch(); + + /// Returns a [Timer] that triggers the auto-refresh functionality after + /// the predefined [kDashboardRefreshInterval]. + /// + /// This method cancels any existing timers and initiates a new periodic + /// fetch cycle by calling [_fetchDataPeriodically]. + Timer _getAutoRefreshTimer() => Timer( + refreshInterval, + () { + _autoRefresher!.cancel(); + _fetchDataPeriodically(); + }, + ); + + /// Periodically fetches data and updates the state with either success or failure. + /// + /// This method fetches new data by calling [fetch], emits a loading state while + /// fetching, and updates the state with success or failure based on the outcome. + /// If the WebSocket client is closed, it throws a [noConnectionException]. + Future _fetchDataPeriodically() async { + try { + emit(state.copyWith(status: CubitStatus.loading)); + if (!zenon.wsClient.isClosed()) { + final T? data = await fetch(); + emit(state.copyWith(data: data, status: CubitStatus.success)); + } else { + throw noConnectionException; + } + } catch (e) { + emit(state.copyWith(status: CubitStatus.failure, error: e)); + } finally { + /// Ensure that the auto-refresher is restarted if it's not active. + if (_autoRefresher == null) { + _autoRefresher = _getAutoRefreshTimer(); + } else if (!_autoRefresher!.isActive) { + _autoRefresher = _getAutoRefreshTimer(); + } + } + } + + /// Starts the auto-refresh cycle by initializing the [_autoRefresher] timer. + void _startAutoRefresh() { + _autoRefresher = _getAutoRefreshTimer(); + } + + /// Cancels the auto-refresh timer and closes the cubit. + /// + /// This method is called when the cubit is closed, ensuring that no background + /// tasks remain active after the cubit is disposed. + @override + Future close() { + _autoRefresher?.cancel(); + return super.close(); + } +} diff --git a/lib/rearchitecture/dashboard/dashboard_state.dart b/lib/rearchitecture/dashboard/dashboard_state.dart new file mode 100644 index 00000000..70fadb7c --- /dev/null +++ b/lib/rearchitecture/dashboard/dashboard_state.dart @@ -0,0 +1,61 @@ +part of 'dashboard_cubit.dart'; + +/// Represents the various statuses a cubit can have during its lifecycle. +/// +/// This enum is used to track and emit different states: +/// - [failure]: Indicates that the cubit has encountered an error. +/// - [initial]: The initial state before any data has been loaded. +/// - [loading]: Data is currently being fetched. +/// - [success]: Data has been successfully loaded. +enum CubitStatus { + failure, + initial, + loading, + success, +} + +/// An abstract class that defines the common structure for all cubit states +/// +/// The [DashboardState] is designed to be generic, with [T] representing the +/// type of data that is managed by each specific cubit state (e.g., balances, +/// transactions, etc.). Subclasses like `BalanceState` extend this class to +/// handle specific data types. +/// +/// The state includes: +/// - [status]: A [CubitStatus] that indicates the current state (loading, success, etc.). +/// - [data]: The data of type [T] that is managed by the cubit. +/// - [error]: An optional [error] object that contains error details if the cubit is in a failure state. +abstract class DashboardState { + /// Represents the current status of the cubit, such as loading, success, or failure. + final CubitStatus status; + + /// The data of type [T] managed by the cubit, which can be null if no data has been loaded or if there was an error. + final T? data; + + /// An optional error object that holds error details in case of failure. + final Object? error; + + /// Constructs a [DashboardState] with an optional [status], [data], and [error]. + /// + /// - The [status] defaults to [CubitStatus.initial] if not provided. + /// - The [data] and [error] can be null, indicating that either no data has been fetched yet, or an error has occurred. + DashboardState({ + this.status = CubitStatus.initial, + this.data, + this.error, + }); + + /// Creates a copy of the current state with the option to modify specific fields. + /// + /// - [status]: The new status of the cubit (e.g., loading, success). + /// - [data]: The new data of type [T], if it has changed. + /// - [error]: The new error, if any occurred. + /// + /// Returns a new [DashboardState] with the updated fields. Subclasses (like `BalanceState`) will implement this to + /// ensure type safety and return the appropriate state class. + DashboardState copyWith({ + CubitStatus? status, + T? data, + Object? error, + }); +} diff --git a/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart b/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart new file mode 100644 index 00000000..b74aafa4 --- /dev/null +++ b/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart @@ -0,0 +1,45 @@ +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +part 'delegation_state.dart'; + +/// `DelegationCubit` manages the fetching and state of delegation information +/// for a specific account. +/// +/// This cubit extends `DashboardCubit`, using the `DelegationInfo` data type +/// to store and manage delegation stats for the account identified by `kDemoAddress`. +class DelegationCubit extends DashboardCubit { + /// Constructs a `DelegationCubit`, passing the `zenon` client and the initial state + /// to the parent class. + /// + /// The `zenon` client is used to interact with the Zenon network to retrieve delegation information. + DelegationCubit(super.zenon, super.initialState); + + /// Fetches the delegation information for the account identified by its address. + /// + /// This method retrieves delegation stats using the Zenon SDK's `getDelegatedPillar()` method. + /// It checks if the delegation information is available: + /// - If available, it returns the `DelegationInfo`. + /// - If not available, it throws an error indicating that no delegation stats are available. + /// + /// Throws: + /// - An error if the delegation information is unavailable or any exception occurs during data fetching. + @override + Future fetch() async { + try { + final DelegationInfo? delegationInfo = await zenon.embedded.pillar.getDelegatedPillar( + Address.parse(kSelectedAddress!), + ); + + // Check if delegation information is available + if (delegationInfo != null) { + return delegationInfo; + } else { + throw 'No delegation stats available'; + } + } catch (e) { + rethrow; + } + } +} diff --git a/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart b/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart new file mode 100644 index 00000000..78a287c0 --- /dev/null +++ b/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart @@ -0,0 +1,37 @@ +part of 'delegation_cubit.dart'; + +/// The state class for the `DelegationCubit`, extending `DashboardState` and managing delegation information. +/// +/// `DelegationState` holds a `DelegationInfo` object that represents the current delegation details. +/// This state is used by the `DelegationCubit` to manage and track delegation-related data. +class DelegationState extends DashboardState { + /// Constructs a new `DelegationState`. + /// + /// This state is initialized with default `status`, `data`, and `error` values from the parent `DashboardState` class. + /// It manages delegation information for an account. + DelegationState({ + super.status, + super.data, + super.error, + }); + + /// Creates a copy of the current `DelegationState` with optional new values for `status`, `data`, and `error`. + /// + /// This method is used to create a new state with updated fields if provided, + /// otherwise retaining the existing values. + /// + /// Returns: + /// - A new instance of `DelegationState` with the updated values or the existing ones if none are provided. + @override + DashboardState copyWith({ + CubitStatus? status, + DelegationInfo? data, + Object? error, + }) { + return DelegationState( + status: status ?? this.status, + data: data ?? this.data, + error: error ?? this.error, + ); + } +} diff --git a/lib/rearchitecture/dashboard/delegation/delegation.dart b/lib/rearchitecture/dashboard/delegation/delegation.dart new file mode 100644 index 00000000..5d92af6d --- /dev/null +++ b/lib/rearchitecture/dashboard/delegation/delegation.dart @@ -0,0 +1,3 @@ +export 'cubit/delegation_cubit.dart'; +export 'widgets/widgets.dart'; +export 'view/delegation_card.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart b/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart new file mode 100644 index 00000000..42ba059c --- /dev/null +++ b/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/main.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; + + +class DelegationCard extends StatelessWidget { + const DelegationCard({super.key}); + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (_) { + final DelegationCubit cubit = DelegationCubit( + zenon!, + DelegationState(), + ); + cubit.fetch(); + return cubit; + }, + child: Scaffold( + body: BlocBuilder( + builder: (context, state) { + return switch (state.status) { + CubitStatus.initial => const DelegationEmpty(), + CubitStatus.loading => const DelegationLoading(), + CubitStatus.failure => DelegationError( + error: state.error!, + ), + CubitStatus.success => DelegationPopulated( + data: state.data!, + ), + }; + }, + ), + ), + ); + } +} diff --git a/lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart b/lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart new file mode 100644 index 00000000..321beb00 --- /dev/null +++ b/lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class DelegationEmpty extends StatelessWidget { + const DelegationEmpty({super.key}); + + @override + Widget build(BuildContext context) { + return const Text('empty'); + } +} \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart b/lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart new file mode 100644 index 00000000..42ea6cb8 --- /dev/null +++ b/lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; + +class DelegationError extends StatelessWidget { + final Object error; + + const DelegationError({required this.error, super.key}); + + @override + Widget build(BuildContext context) { + return Text(error.toString()); + } +} diff --git a/lib/rearchitecture/dashboard/delegation/widgets/delegation_loading.dart b/lib/rearchitecture/dashboard/delegation/widgets/delegation_loading.dart new file mode 100644 index 00000000..c7079084 --- /dev/null +++ b/lib/rearchitecture/dashboard/delegation/widgets/delegation_loading.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class DelegationLoading extends StatelessWidget { + const DelegationLoading({super.key}); + + @override + Widget build(BuildContext context) { + return const Text('loading'); + } +} diff --git a/lib/rearchitecture/dashboard/delegation/widgets/delegation_populated.dart b/lib/rearchitecture/dashboard/delegation/widgets/delegation_populated.dart new file mode 100644 index 00000000..3c17748f --- /dev/null +++ b/lib/rearchitecture/dashboard/delegation/widgets/delegation_populated.dart @@ -0,0 +1,13 @@ +import 'package:flutter/material.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +class DelegationPopulated extends StatelessWidget { + final DelegationInfo? data; + + const DelegationPopulated({required this.data, super.key}); + + @override + Widget build(BuildContext context) { + return Text(data.toString()); + } +} diff --git a/lib/rearchitecture/dashboard/delegation/widgets/widgets.dart b/lib/rearchitecture/dashboard/delegation/widgets/widgets.dart new file mode 100644 index 00000000..f7196852 --- /dev/null +++ b/lib/rearchitecture/dashboard/delegation/widgets/widgets.dart @@ -0,0 +1,4 @@ +export 'delegation_empty.dart'; +export 'delegation_error.dart'; +export 'delegation_loading.dart'; +export 'delegation_populated.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart new file mode 100644 index 00000000..0bc3dc59 --- /dev/null +++ b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart @@ -0,0 +1,44 @@ +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +part 'dual_coin_stats_state.dart'; + +/// `DualCoinStatsCubit` manages the fetching and state of dual coin statistics +/// for ZNN and QSR tokens. +/// +/// This cubit extends `DashboardCubit>`, using a list of `Token` objects to +/// represent the statistics for the ZNN and QSR tokens fetched from the Zenon network. +class DualCoinStatsCubit extends DashboardCubit> { + /// Constructs a `DualCoinStatsCubit`, passing the `zenon` client and the initial state + /// to the parent class. + /// + /// The `zenon` client is used to interact with the Zenon network to retrieve token information. + DualCoinStatsCubit(super.zenon, super.initialState); + + /// Fetches the statistics for both ZNN and QSR tokens. + /// + /// This method retrieves token data using the Zenon SDK's `getByZts()` method for each token, + /// executing the requests concurrently using `Future.wait()`. It returns a list containing + /// the fetched token data for ZNN and QSR. + /// + /// Throws: + /// - An error if any exception occurs during the fetching of token data. + @override + Future> fetch() async { + try { + final List data = await Future.wait( + [ + zenon.embedded.token.getByZts( + znnZts, // Fetches the ZNN token statistics + ), + zenon.embedded.token.getByZts( + qsrZts, // Fetches the QSR token statistics + ), + ], + ); + return data; // Returns the list of fetched token data + } catch (e) { + rethrow; + } + } +} diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart new file mode 100644 index 00000000..35a261fe --- /dev/null +++ b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart @@ -0,0 +1,37 @@ +part of 'dual_coin_stats_cubit.dart'; + +/// The state class for the `DualCoinStatsCubit`, extending `DashboardState` to manage data related to ZNN and QSR. +/// +/// `DualCoinStatsState` stores a list of `Token?` objects representing data for two tokens. +/// This state is used by the `DualCoinStatsCubit` to track and update the state of both tokens. +class DualCoinStatsState extends DashboardState> { + /// Constructs a new `DualCoinStatsState`. + /// + /// This state is initialized with default `status`, `data`, and `error` values from the parent `DashboardState` class. + /// It manages a list of `Token?` objects that represent the two tokens' data. + DualCoinStatsState({ + super.status, + super.data, + super.error, + }); + + /// Creates a copy of the current `DualCoinStatsState` with optional new values for `status`, `data`, and `error`. + /// + /// This method is used to create a new state with updated fields if provided, + /// otherwise retaining the existing values. + /// + /// Returns: + /// - A new instance of `DualCoinStatsState` with the updated values or the existing ones if none are provided. + @override + DashboardState> copyWith({ + CubitStatus? status, + List? data, + Object? error, + }) { + return DualCoinStatsState( + status: status ?? this.status, + data: data ?? this.data, + error: error ?? this.error, + ); + } +} diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/dual_coin_stats.dart b/lib/rearchitecture/dashboard/dual_coin_stats/dual_coin_stats.dart new file mode 100644 index 00000000..b2816742 --- /dev/null +++ b/lib/rearchitecture/dashboard/dual_coin_stats/dual_coin_stats.dart @@ -0,0 +1,3 @@ +export 'cubit/dual_coin_stats_cubit.dart'; +export 'widgets/widgets.dart'; +export 'view/dual_coin_stats_card.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart b/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart new file mode 100644 index 00000000..466ca5f3 --- /dev/null +++ b/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/main.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; + + +class DualCoinStatsCard extends StatelessWidget { + const DualCoinStatsCard({super.key}); + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (_) { + final DualCoinStatsCubit cubit = DualCoinStatsCubit( + zenon!, + DualCoinStatsState(), + ); + cubit.fetch(); + return cubit; + }, + child: Scaffold( + body: BlocBuilder( + builder: (context, state) { + return switch (state.status) { + CubitStatus.initial => const DualCoinStatsEmpty(), + CubitStatus.loading => const DualCoinStatsLoading(), + CubitStatus.failure => DualCoinStatsError( + error: state.error!, + ), + CubitStatus.success => DualCoinStatsPopulated( + data: state.data!, + ), + }; + }, + ), + ), + ); + } +} diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart new file mode 100644 index 00000000..90f9a6e8 --- /dev/null +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class DualCoinStatsEmpty extends StatelessWidget { + const DualCoinStatsEmpty({super.key}); + + @override + Widget build(BuildContext context) { + return const Text('empty'); + } +} diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart new file mode 100644 index 00000000..5191195a --- /dev/null +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; + +class DualCoinStatsError extends StatelessWidget { + final Object error; + + const DualCoinStatsError({required this.error, super.key}); + + @override + Widget build(BuildContext context) { + return Text(error.toString()); + } +} diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart new file mode 100644 index 00000000..7ab7ae55 --- /dev/null +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class DualCoinStatsLoading extends StatelessWidget { + const DualCoinStatsLoading({super.key}); + + @override + Widget build(BuildContext context) { + return const Text('loading'); + } +} diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart new file mode 100644 index 00000000..030912bd --- /dev/null +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart @@ -0,0 +1,13 @@ +import 'package:flutter/material.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +class DualCoinStatsPopulated extends StatelessWidget { + final List data; + + const DualCoinStatsPopulated({required this.data, super.key}); + + @override + Widget build(BuildContext context) { + return Text(data.toString()); + } +} diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/widgets.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/widgets.dart new file mode 100644 index 00000000..29766997 --- /dev/null +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/widgets.dart @@ -0,0 +1,4 @@ +export 'dual_coin_stats_empty.dart'; +export 'dual_coin_stats_error.dart'; +export 'dual_coin_stats_loading.dart'; +export 'dual_coin_stats_populated.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart b/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart new file mode 100644 index 00000000..f97a3c3e --- /dev/null +++ b/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart @@ -0,0 +1,35 @@ +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +part 'pillars_state.dart'; + +/// `PillarsCubit` manages the fetching and state of pillar statistics. +/// +/// This cubit extends `DashboardCubit`, using an integer to represent the +/// total number of pillars fetched from the Zenon network. +class PillarsCubit extends DashboardCubit { + /// Constructs a `PillarsCubit`, passing the `zenon` client and the initial state + /// to the parent class. + /// + /// The `zenon` client is used to interact with the Zenon network to retrieve pillar information. + PillarsCubit(super.zenon, super.initialState); + + /// Fetches the total count of pillars from the Zenon network. + /// + /// This method retrieves all pillar information using the Zenon SDK's `getAll()` method + /// and returns the total number of pillars as an integer. + /// + /// Throws: + /// - An error if any exception occurs during the fetching of pillar data. + @override + Future fetch() async { + try { + // Fetches the list of all pillars from the Zenon network + final PillarInfoList pillarInfoList = await zenon.embedded.pillar.getAll(); + final int data = pillarInfoList.list.length; // Counts the number of pillars + return data; // Returns the total number of pillars + } catch (e) { + rethrow; + } + } +} diff --git a/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart b/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart new file mode 100644 index 00000000..dac9f2e1 --- /dev/null +++ b/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart @@ -0,0 +1,37 @@ +part of 'pillars_cubit.dart'; + +/// The state class for the `PillarsCubit`, extending `DashboardState` to manage the data related to pillars. +/// +/// `PillarsState` stores an integer value representing the number of pillars retrieved from the Zenon network. +/// This state is used by the `PillarsCubit` to track and update the number of active pillars. +class PillarsState extends DashboardState { + /// Constructs a new `PillarsState`. + /// + /// This state is initialized with the default `status`, `data`, and `error` values from the parent `DashboardState` class. + /// The `data` field in this case represents the count of active pillars on the Zenon network. + PillarsState({ + super.status, + super.data, + super.error, + }); + + /// Creates a copy of the current `PillarsState` with optional new values for `status`, `data`, and `error`. + /// + /// This method is used to create a new state with updated fields if provided, + /// otherwise retaining the existing values. + /// + /// Returns: + /// - A new instance of `PillarsState` with the updated values or the existing ones if none are provided. + @override + DashboardState copyWith({ + CubitStatus? status, + int? data, + Object? error, + }) { + return PillarsState( + status: status ?? this.status, + data: data ?? this.data, + error: error ?? this.error, + ); + } +} diff --git a/lib/rearchitecture/dashboard/pillars/pillars.dart b/lib/rearchitecture/dashboard/pillars/pillars.dart new file mode 100644 index 00000000..56205093 --- /dev/null +++ b/lib/rearchitecture/dashboard/pillars/pillars.dart @@ -0,0 +1,3 @@ +export 'cubit/pillars_cubit.dart'; +export 'widgets/widgets.dart'; +export 'view/pillars_card.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/pillars/view/pillars_card.dart b/lib/rearchitecture/dashboard/pillars/view/pillars_card.dart new file mode 100644 index 00000000..d62a0d9d --- /dev/null +++ b/lib/rearchitecture/dashboard/pillars/view/pillars_card.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/main.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; + + +class PillarsCard extends StatelessWidget { + const PillarsCard({super.key}); + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (_) { + final PillarsCubit cubit = PillarsCubit( + zenon!, + PillarsState(), + ); + cubit.fetch(); + return cubit; + }, + child: Scaffold( + body: BlocBuilder( + builder: (context, state) { + return switch (state.status) { + CubitStatus.initial => const PillarsEmpty(), + CubitStatus.loading => const PillarsLoading(), + CubitStatus.failure => PillarsError( + error: state.error!, + ), + CubitStatus.success => PillarsPopulated( + data: state.data!, + ), + }; + }, + ), + ), + ); + } +} diff --git a/lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart b/lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart new file mode 100644 index 00000000..c19b43b2 --- /dev/null +++ b/lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class PillarsEmpty extends StatelessWidget { + const PillarsEmpty({super.key}); + + @override + Widget build(BuildContext context) { + return const Text('empty'); + } +} \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart b/lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart new file mode 100644 index 00000000..3f79e8cd --- /dev/null +++ b/lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; + +class PillarsError extends StatelessWidget { + final Object error; + + const PillarsError({required this.error, super.key}); + + @override + Widget build(BuildContext context) { + return Text(error.toString()); + } +} diff --git a/lib/rearchitecture/dashboard/pillars/widgets/pillars_loading.dart b/lib/rearchitecture/dashboard/pillars/widgets/pillars_loading.dart new file mode 100644 index 00000000..d2ee3aea --- /dev/null +++ b/lib/rearchitecture/dashboard/pillars/widgets/pillars_loading.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class PillarsLoading extends StatelessWidget { + const PillarsLoading({super.key}); + + @override + Widget build(BuildContext context) { + return const Text('loading'); + } +} \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/pillars/widgets/pillars_populated.dart b/lib/rearchitecture/dashboard/pillars/widgets/pillars_populated.dart new file mode 100644 index 00000000..f35619a4 --- /dev/null +++ b/lib/rearchitecture/dashboard/pillars/widgets/pillars_populated.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; + +class PillarsPopulated extends StatelessWidget { + final int? data; + + const PillarsPopulated({required this.data, super.key}); + + @override + Widget build(BuildContext context) { + return Text(data.toString()); + } +} \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/pillars/widgets/widgets.dart b/lib/rearchitecture/dashboard/pillars/widgets/widgets.dart new file mode 100644 index 00000000..0b0d5e3a --- /dev/null +++ b/lib/rearchitecture/dashboard/pillars/widgets/widgets.dart @@ -0,0 +1,4 @@ +export 'pillars_empty.dart'; +export 'pillars_error.dart'; +export 'pillars_loading.dart'; +export 'pillars_populated.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart new file mode 100644 index 00000000..48767f8f --- /dev/null +++ b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart @@ -0,0 +1,84 @@ +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +part 'realtime_statistics_state.dart'; + +/// `RealtimeStatisticsCubit` manages the fetching and state of real-time +/// account block statistics for a specific address. +/// +/// This cubit extends `DashboardCubit>`, using a list of +/// `AccountBlock` objects to represent the account blocks fetched from the Zenon network. +class RealtimeStatisticsCubit extends DashboardCubit> { + /// Constructs a `RealtimeStatisticsCubit`, passing the `zenon` client and the initial state + /// to the parent class. + /// + /// The `zenon` client is used to interact with the Zenon network to retrieve account block information. + RealtimeStatisticsCubit(super.zenon, super.initialState); + + /// Fetches a list of account blocks for the specified address over the past week. + /// + /// This method retrieves the account blocks by: + /// - Determining the chain height using the `getFrontierMomentum()` method. + /// - Calculating the starting height based on the momentums per week. + /// - Fetching account blocks page by page until there are no more blocks to retrieve. + /// - The loop continues until either the blocks are exhausted or the last block's momentum height + /// is less than the calculated height. + /// + /// Returns: + /// - A list of `AccountBlock` objects representing the account blocks fetched from the network. + /// + /// Throws: + /// - An error if no data is available or if any exception occurs during the fetching process. + @override + Future> fetch() async { + try { + // Get the current chain height + int chainHeight = (await zenon.ledger.getFrontierMomentum()).height; + // Calculate the starting height for the block retrieval + int height = chainHeight - kMomentumsPerWeek > 0 + ? chainHeight - kMomentumsPerWeek + : 1; + int pageIndex = 0; // Start from the first page + int pageSize = 10; // Number of blocks to fetch per page + bool isLastPage = false; // Flag to determine if it's the last page + final List blockList = []; // List to store fetched account blocks + + // Fetch account blocks until the last page is reached + while (!isLastPage) { + // Fetch account blocks for the current page + List response = + (await zenon.ledger.getAccountBlocksByPage( + Address.parse(kSelectedAddress!), + pageIndex: pageIndex, + pageSize: pageSize, + )) + .list ?? // Default to an empty list if no blocks are found + []; + + if (response.isEmpty) { + break; // Exit the loop if no more blocks are found + } + + blockList.addAll(response); // Add the fetched blocks to the list + + // Check if the last block's momentum height is less than the calculated height + if (response.last.confirmationDetail!.momentumHeight <= height) { + break; // Exit if we've fetched enough data + } + + pageIndex += 1; // Increment the page index for the next fetch + isLastPage = response.length < pageSize; // Check if this is the last page + } + + if (blockList.isNotEmpty) { + return blockList; // Return the list of fetched blocks if available + } else { + throw 'No available data'; // Throw an error if no data is found + } + } catch (e) { + rethrow; + } + } +} \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart new file mode 100644 index 00000000..a45a222d --- /dev/null +++ b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart @@ -0,0 +1,36 @@ +part of 'realtime_statistics_cubit.dart'; + +/// The state class for `RealtimeStatisticsCubit`, which extends `DashboardState` to handle real-time statistics data. +/// +/// This class manages a list of `AccountBlock` objects representing real-time blockchain data, such as recent transactions. +/// It's used to track the state of the data loading process in the `RealtimeStatisticsCubit`. +class RealtimeStatisticsState extends DashboardState> { + /// Constructs a new `RealtimeStatisticsState` with optional values for `status`, `data`, and `error`. + /// + /// The `data` field stores a list of `AccountBlock` objects that represent real-time blockchain statistics. + RealtimeStatisticsState({ + super.status, + super.data, + super.error, + }); + + /// Creates a copy of the current `RealtimeStatisticsState` with updated values for `status`, `data`, or `error`. + /// + /// This method is used to create a new state with updated fields if provided, + /// otherwise retaining the existing values. + /// + /// Returns: + /// - A new instance of `RealtimeStatisticsState` with the updated values or the existing ones if none are provided. + @override + DashboardState> copyWith({ + CubitStatus? status, + List? data, + Object? error, + }) { + return RealtimeStatisticsState( + status: status ?? this.status, + data: data ?? this.data, + error: error ?? this.error, + ); + } +} diff --git a/lib/rearchitecture/dashboard/realtime_statistics/realtime_statistics.dart b/lib/rearchitecture/dashboard/realtime_statistics/realtime_statistics.dart new file mode 100644 index 00000000..603b6938 --- /dev/null +++ b/lib/rearchitecture/dashboard/realtime_statistics/realtime_statistics.dart @@ -0,0 +1,3 @@ +export 'cubit/realtime_statistics_cubit.dart'; +export 'widgets/widgets.dart'; +export 'view/realtime_statistics_card.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart b/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart new file mode 100644 index 00000000..89209af7 --- /dev/null +++ b/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart @@ -0,0 +1,40 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/main.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; + + + +class RealtimeStatisticsCard extends StatelessWidget { + const RealtimeStatisticsCard({super.key}); + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (_) { + final RealtimeStatisticsCubit cubit = RealtimeStatisticsCubit( + zenon!, + RealtimeStatisticsState(), + ); + cubit.fetch(); + return cubit; + }, + child: Scaffold( + body: BlocBuilder( + builder: (context, state) { + return switch (state.status) { + CubitStatus.initial => const RealtimeStatisticsEmpty(), + CubitStatus.loading => const RealtimeStatisticsLoading(), + CubitStatus.failure => RealtimeStatisticsError( + error: state.error!, + ), + CubitStatus.success => RealtimeStatisticsPopulated( + data: state.data!, + ), + }; + }, + ), + ), + ); + } +} diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_empty.dart b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_empty.dart new file mode 100644 index 00000000..9bc76ffd --- /dev/null +++ b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_empty.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class RealtimeStatisticsEmpty extends StatelessWidget { + const RealtimeStatisticsEmpty({super.key}); + + @override + Widget build(BuildContext context) { + return const Text('empty'); + } +} \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart new file mode 100644 index 00000000..5d170cf0 --- /dev/null +++ b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; + +class RealtimeStatisticsError extends StatelessWidget { + final Object error; + + const RealtimeStatisticsError({required this.error, super.key}); + + @override + Widget build(BuildContext context) { + return Text(error.toString()); + } +} \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_loading.dart b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_loading.dart new file mode 100644 index 00000000..8c6d61db --- /dev/null +++ b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_loading.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class RealtimeStatisticsLoading extends StatelessWidget { + const RealtimeStatisticsLoading({super.key}); + + @override + Widget build(BuildContext context) { + return const Text('loading'); + } +} \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart new file mode 100644 index 00000000..909d7b7f --- /dev/null +++ b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart @@ -0,0 +1,13 @@ +import 'package:flutter/material.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +class RealtimeStatisticsPopulated extends StatelessWidget { + final List data; + + const RealtimeStatisticsPopulated({required this.data, super.key}); + + @override + Widget build(BuildContext context) { + return Text(data.toString()); + } +} \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/widgets.dart b/lib/rearchitecture/dashboard/realtime_statistics/widgets/widgets.dart new file mode 100644 index 00000000..3e2d66a8 --- /dev/null +++ b/lib/rearchitecture/dashboard/realtime_statistics/widgets/widgets.dart @@ -0,0 +1,4 @@ +export 'realtime_statistics_empty.dart'; +export 'realtime_statistics_error.dart'; +export 'realtime_statistics_loading.dart'; +export 'realtime_statistics_populated.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart new file mode 100644 index 00000000..78c4a9e5 --- /dev/null +++ b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart @@ -0,0 +1,36 @@ + +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +part 'sentinels_state.dart'; + +/// `SentinelsCubit` manages the fetching and state of sentinel information. +/// +/// This cubit extends `DashboardCubit`, using a `SentinelInfoList` +/// object to represent the list of active sentinels fetched from the Zenon network. +class SentinelsCubit extends DashboardCubit { + /// Constructs a `SentinelsCubit`, passing the `zenon` client and the initial state + /// to the parent class. + /// + /// The `zenon` client is used to interact with the Zenon network to retrieve sentinel information. + SentinelsCubit(super.zenon, super.initialState); + + /// Fetches a list of active sentinels from the Zenon network. + /// + /// This method calls the Zenon SDK's `getAllActive()` method to retrieve the list of active + /// sentinels. The fetched data is returned as a `SentinelInfoList`. + /// + /// Throws: + /// - An error if any exception occurs during the fetching process. + @override + Future fetch() async { + try { + // Fetches the list of all active sentinels from the Zenon network + final SentinelInfoList data = await zenon.embedded.sentinel.getAllActive(); + return data; // Returns the fetched sentinel information + } catch (e) { + rethrow; + } + } +} + diff --git a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart new file mode 100644 index 00000000..94ce8445 --- /dev/null +++ b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart @@ -0,0 +1,36 @@ +part of 'sentinels_cubit.dart'; + +/// The state class for `SentinelsCubit`, which extends `DashboardState` to manage sentinel-related data. +/// +/// This class manages a `SentinelInfoList` object representing information about active sentinels. It is used to track +/// the state of sentinel data loading within the `SentinelsCubit`. +class SentinelsState extends DashboardState { + /// Constructs a new `SentinelsState` with optional values for `status`, `data`, and `error`. + /// + /// The `data` field stores a `SentinelInfoList` object, which contains the details of all active sentinels on the network. + SentinelsState({ + super.status, + super.data, + super.error, + }); + + /// Creates a copy of the current `SentinelsState` with updated values for `status`, `data`, or `error`. + /// + /// This method is used to create a new state with updated fields if provided, + /// otherwise retaining the existing values. + /// + /// Returns: + /// - A new instance of `SentinelsState` with the updated values or the existing ones if none are provided. + @override + DashboardState copyWith({ + CubitStatus? status, + SentinelInfoList? data, + Object? error, + }) { + return SentinelsState( + status: status ?? this.status, + data: data ?? this.data, + error: error ?? this.error, + ); + } +} diff --git a/lib/rearchitecture/dashboard/sentinels/sentinels.dart b/lib/rearchitecture/dashboard/sentinels/sentinels.dart new file mode 100644 index 00000000..06f3412e --- /dev/null +++ b/lib/rearchitecture/dashboard/sentinels/sentinels.dart @@ -0,0 +1,3 @@ +export 'cubit/sentinels_cubit.dart'; +export 'widgets/widgets.dart'; +export 'view/sentinels_card.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart b/lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart new file mode 100644 index 00000000..b29c1689 --- /dev/null +++ b/lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart @@ -0,0 +1,38 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/main.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; + +class SentinelsCard extends StatelessWidget { + const SentinelsCard({super.key}); + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (_) { + final SentinelsCubit cubit = SentinelsCubit( + zenon!, + SentinelsState(), + ); + cubit.fetch(); + return cubit; + }, + child: Scaffold( + body: BlocBuilder( + builder: (context, state) { + return switch (state.status) { + CubitStatus.initial => const SentinelsEmpty(), + CubitStatus.loading => const SentinelsLoading(), + CubitStatus.failure => SentinelsError( + error: state.error!, + ), + CubitStatus.success => SentinelsPopulated( + data: state.data!, + ), + }; + }, + ), + ), + ); + } +} diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart new file mode 100644 index 00000000..6cbb891f --- /dev/null +++ b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class SentinelsEmpty extends StatelessWidget { + const SentinelsEmpty({super.key}); + + @override + Widget build(BuildContext context) { + return const Text('empty'); + } +} \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart new file mode 100644 index 00000000..0451fd68 --- /dev/null +++ b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; + +class SentinelsError extends StatelessWidget { + final Object error; + + const SentinelsError({required this.error, super.key}); + + @override + Widget build(BuildContext context) { + return Text(error.toString()); + } +} \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_loading.dart b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_loading.dart new file mode 100644 index 00000000..8b012138 --- /dev/null +++ b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_loading.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class SentinelsLoading extends StatelessWidget { + const SentinelsLoading({super.key}); + + @override + Widget build(BuildContext context) { + return const Text('loading'); + } +} \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart new file mode 100644 index 00000000..408cc452 --- /dev/null +++ b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart @@ -0,0 +1,13 @@ +import 'package:flutter/material.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +class SentinelsPopulated extends StatelessWidget { + final SentinelInfoList? data; + + const SentinelsPopulated({required this.data, super.key}); + + @override + Widget build(BuildContext context) { + return Text(data.toString()); + } +} \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/widgets.dart b/lib/rearchitecture/dashboard/sentinels/widgets/widgets.dart new file mode 100644 index 00000000..080d8cb5 --- /dev/null +++ b/lib/rearchitecture/dashboard/sentinels/widgets/widgets.dart @@ -0,0 +1,4 @@ +export 'sentinels_empty.dart'; +export 'sentinels_error.dart'; +export 'sentinels_loading.dart'; +export 'sentinels_populated.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart b/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart new file mode 100644 index 00000000..5e5df0a9 --- /dev/null +++ b/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart @@ -0,0 +1,53 @@ +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +part 'staking_state.dart'; + +/// `StakingCubit` manages the fetching and state of staking information. +/// +/// This cubit extends `DashboardCubit`, using a `StakeList` object +/// to represent the list of staking entries for a specific address fetched from the Zenon network. +class StakingCubit extends DashboardCubit { + /// Constructs a `StakingCubit`, passing the `zenon` client and the initial state + /// to the parent class. + /// + /// The `zenon` client is used to interact with the Zenon network to retrieve staking information. + StakingCubit(super.zenon, super.initialState); + + /// Fetches a list of staking entries for a specific address from the Zenon network. + /// + /// This method retrieves the staking list by calling the internal `_getStakeList()` method. + /// It checks if the list of stakes is not empty and returns the data. + /// + /// Throws: + /// - An error if no active staking entries are found or if any exception occurs during the fetching process. + @override + Future fetch() async { + try { + // Retrieve the list of staking entries for the demo address + final StakeList data = await _getStakeList(); + if (data.list.isNotEmpty) { + return data; // Return the fetched stake data if not empty + } else { + throw 'No active staking entries'; // Throw an error if no entries are found + } + } catch (e) { + rethrow; + } + } + + /// Retrieves the staking entries for a specific address. + /// + /// This method fetches the staking entries by calling the Zenon SDK's `getEntriesByAddress()` + /// method, using the account address and a specified page index. + /// + /// Returns: + /// - A `StakeList` containing the staking entries for the specified address. + Future _getStakeList() async { + return await zenon.embedded.stake.getEntriesByAddress( + Address.parse(kSelectedAddress!), + pageIndex: 0, + ); + } +} diff --git a/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart b/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart new file mode 100644 index 00000000..e624c792 --- /dev/null +++ b/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart @@ -0,0 +1,36 @@ +part of 'staking_cubit.dart'; + +/// The state class for `StakingCubit`, which extends `DashboardState` to manage staking-related data. +/// +/// This class manages a `StakeList` object representing the list of active staking entries. +/// It tracks the loading, success, or failure of fetching staking data within the `StakingCubit`. +class StakingState extends DashboardState { + /// Constructs a new `StakingState` with optional values for `status`, `data`, and `error`. + /// + /// The `data` field holds a `StakeList` object, which contains the list of active staking entries for a particular address. + StakingState({ + super.status, + super.data, + super.error, + }); + + /// Creates a copy of the current `StakingState` with updated values for `status`, `data`, or `error`. + /// + /// This method is used to create a new state with updated fields if provided, + /// otherwise retaining the existing values. + /// + /// Returns: + /// - A new instance of `StakingState`with the updated values or the existing ones if none are provided. + @override + DashboardState copyWith({ + CubitStatus? status, + StakeList? data, + Object? error, + }) { + return StakingState( + status: status ?? this.status, + data: data ?? this.data, + error: error ?? this.error, + ); + } +} diff --git a/lib/rearchitecture/dashboard/staking/staking.dart b/lib/rearchitecture/dashboard/staking/staking.dart new file mode 100644 index 00000000..d1d9983e --- /dev/null +++ b/lib/rearchitecture/dashboard/staking/staking.dart @@ -0,0 +1,3 @@ +export 'cubit/staking_cubit.dart'; +export 'widgets/widgets.dart'; +export 'view/staking_card.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/staking/view/staking_card.dart b/lib/rearchitecture/dashboard/staking/view/staking_card.dart new file mode 100644 index 00000000..329e14b9 --- /dev/null +++ b/lib/rearchitecture/dashboard/staking/view/staking_card.dart @@ -0,0 +1,38 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/main.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; + +class StakingCard extends StatelessWidget { + const StakingCard({super.key}); + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (_) { + final StakingCubit cubit = StakingCubit( + zenon!, + StakingState(), + ); + cubit.fetch(); + return cubit; + }, + child: Scaffold( + body: BlocBuilder( + builder: (context, state) { + return switch (state.status) { + CubitStatus.initial => const StakingEmpty(), + CubitStatus.loading => const StakingLoading(), + CubitStatus.failure => StakingError( + error: state.error!, + ), + CubitStatus.success => StakingPopulated( + data: state.data!, + ), + }; + }, + ), + ), + ); + } +} diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart b/lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart new file mode 100644 index 00000000..5e186deb --- /dev/null +++ b/lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class StakingEmpty extends StatelessWidget { + const StakingEmpty({super.key}); + + @override + Widget build(BuildContext context) { + return const Text('empty'); + } +} \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart b/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart new file mode 100644 index 00000000..1b25d625 --- /dev/null +++ b/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; + +class StakingError extends StatelessWidget { + final Object error; + + const StakingError({required this.error, super.key}); + + @override + Widget build(BuildContext context) { + return Text(error.toString()); + } +} \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_loading.dart b/lib/rearchitecture/dashboard/staking/widgets/staking_loading.dart new file mode 100644 index 00000000..d57fd356 --- /dev/null +++ b/lib/rearchitecture/dashboard/staking/widgets/staking_loading.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class StakingLoading extends StatelessWidget { + const StakingLoading({super.key}); + + @override + Widget build(BuildContext context) { + return const Text('loading'); + } +} \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart b/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart new file mode 100644 index 00000000..55da4416 --- /dev/null +++ b/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart @@ -0,0 +1,13 @@ +import 'package:flutter/material.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +class StakingPopulated extends StatelessWidget { + final StakeList? data; + + const StakingPopulated({required this.data, super.key}); + + @override + Widget build(BuildContext context) { + return Text(data.toString()); + } +} \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/staking/widgets/widgets.dart b/lib/rearchitecture/dashboard/staking/widgets/widgets.dart new file mode 100644 index 00000000..5826ca55 --- /dev/null +++ b/lib/rearchitecture/dashboard/staking/widgets/widgets.dart @@ -0,0 +1,4 @@ +export 'staking_empty.dart'; +export 'staking_error.dart'; +export 'staking_loading.dart'; +export 'staking_populated.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart new file mode 100644 index 00000000..8c507f72 --- /dev/null +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart @@ -0,0 +1,73 @@ +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +part 'total_hourly_transactions_state.dart'; + +/// `TotalHourlyTransactionsCubit` manages the fetching and state of total hourly transactions. +/// +/// This cubit extends `DashboardCubit>`, using a map to represent the total +/// number of account blocks and the corresponding timestamp fetched from the Zenon network. +class TotalHourlyTransactionsCubit extends DashboardCubit> { + /// Constructs a `TotalHourlyTransactionsCubit`, passing the `zenon` client and the initial state + /// to the parent class. + /// + /// The `zenon` client is used to interact with the Zenon network to retrieve transaction information. + + TotalHourlyTransactionsCubit(super.zenon, super.initialState); + + /// Fetches the total number of account blocks for the last hour from the Zenon network. + /// + /// This method retrieves the height of the chain, checks if there are enough momentums, + /// and fetches detailed momentums from the Zenon ledger. It calculates the total number of + /// account blocks and prepares a map containing the number of blocks and the current timestamp. + /// + /// Throws: + /// - An error if there are not enough momentums or if any exception occurs during the fetching process. + @override + Future> fetch() async { + try { + // Retrieve the current chain height + final int chainHeight = await _ledgerGetMomentumLedgerHeight(); + if (chainHeight - kMomentumsPerHour > 0) { + // Fetch detailed momentums for the past hour + final List response = + (await zenon.ledger.getDetailedMomentumsByHeight( + chainHeight - kMomentumsPerHour, + kMomentumsPerHour, + )) + .list ?? + []; + + // Prepare the transaction summary + final Map transactions = { + 'numAccountBlocks': response.fold( + 0, + (previousValue, element) => + previousValue + element.blocks.length, + ), + 'timestamp': DateTime.now().millisecondsSinceEpoch, + }; + return transactions; // Return the summary of transactions + } else { + throw 'Not enough momentums'; // Throw an error if there are not enough momentums + } + } catch (e) { + rethrow; + } + } + + /// Retrieves the current momentum ledger height from the Zenon network. + /// + /// This method fetches the frontier momentum and returns its height. + /// + /// Returns: + /// - An integer representing the current height of the momentum ledger. + Future _ledgerGetMomentumLedgerHeight() async { + try { + return (await zenon.ledger.getFrontierMomentum()).height; + } catch (e) { + rethrow; + } + } +} diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart new file mode 100644 index 00000000..a29f3e4d --- /dev/null +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart @@ -0,0 +1,39 @@ +part of 'total_hourly_transactions_cubit.dart'; + +/// The state class for `TotalHourlyTransactionsCubit`, which extends `DashboardState` to manage +/// the hourly transaction count data. +/// +/// This class manages a `Map` where the key-value pairs represent transaction statistics +/// (e.g., the number of account blocks and the timestamp) for the last hour. It tracks the state of fetching +/// hourly transaction data within `TotalHourlyTransactionsCubit`. +class TotalHourlyTransactionsState extends DashboardState> { + /// Constructs a new `TotalHourlyTransactionsState` with optional values for `status`, `data`, and `error`. + /// + /// The `data` field holds a map containing the transaction statistics for the last hour. + TotalHourlyTransactionsState({ + super.status, + super.data, + super.error, + }); + + /// Creates a copy of the current `TotalHourlyTransactionsState` with updated values for `status`, `data`, or `error`. + /// + /// This method is used to create a new state with updated fields if provided, + /// otherwise retaining the existing values. + /// + /// Returns: + /// - A new instance of `TotalHourlyTransactionsState` with the updated values or the existing ones if none are provided. + @override + DashboardState> copyWith({ + CubitStatus? status, + Map? data, + Object? error, + }) { + return TotalHourlyTransactionsState( + status: status ?? this.status, + data: data ?? this.data, + error: error ?? this.error, + ); + } +} + diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/total_hourly_transactions.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/total_hourly_transactions.dart new file mode 100644 index 00000000..15c545d5 --- /dev/null +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/total_hourly_transactions.dart @@ -0,0 +1,3 @@ +export 'cubit/total_hourly_transactions_cubit.dart'; +export 'widgets/widgets.dart'; +export 'view/total_hourly_transactions_card.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart new file mode 100644 index 00000000..52a60516 --- /dev/null +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart @@ -0,0 +1,38 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/main.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; + +class TotalHourlyTransactionsCard extends StatelessWidget { + const TotalHourlyTransactionsCard({super.key}); + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (_) { + final TotalHourlyTransactionsCubit cubit = TotalHourlyTransactionsCubit( + zenon!, + TotalHourlyTransactionsState(), + ); + cubit.fetch(); + return cubit; + }, + child: Scaffold( + body: BlocBuilder( + builder: (context, state) { + return switch (state.status) { + CubitStatus.initial => const TotalHourlyTransactionsEmpty(), + CubitStatus.loading => const TotalHourlyTransactionsLoading(), + CubitStatus.failure => TotalHourlyTransactionsError( + error: state.error!, + ), + CubitStatus.success => TotalHourlyTransactionsPopulated( + data: state.data!, + ), + }; + }, + ), + ), + ); + } +} diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart new file mode 100644 index 00000000..156a0ec5 --- /dev/null +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class TotalHourlyTransactionsEmpty extends StatelessWidget { + const TotalHourlyTransactionsEmpty({super.key}); + + @override + Widget build(BuildContext context) { + return const Text('empty'); + } +} \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart new file mode 100644 index 00000000..ac1d6a2e --- /dev/null +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; + +class TotalHourlyTransactionsError extends StatelessWidget { + final Object error; + + const TotalHourlyTransactionsError({required this.error, super.key}); + + @override + Widget build(BuildContext context) { + return Text(error.toString()); + } +} diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart new file mode 100644 index 00000000..3c9d9e34 --- /dev/null +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class TotalHourlyTransactionsLoading extends StatelessWidget { + const TotalHourlyTransactionsLoading({super.key}); + + @override + Widget build(BuildContext context) { + return const Text('loading'); + } +} diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart new file mode 100644 index 00000000..ead7a848 --- /dev/null +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; + +class TotalHourlyTransactionsPopulated extends StatelessWidget { + final Map? data; + + const TotalHourlyTransactionsPopulated({required this.data, super.key}); + + @override + Widget build(BuildContext context) { + return Text(data.toString()); + } +} diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/widgets.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/widgets.dart new file mode 100644 index 00000000..8d717eec --- /dev/null +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/widgets.dart @@ -0,0 +1,4 @@ +export 'total_hourly_transactions_empty.dart'; +export 'total_hourly_transactions_error.dart'; +export 'total_hourly_transactions_loading.dart'; +export 'total_hourly_transactions_populated.dart'; \ No newline at end of file diff --git a/lib/utils/constants.dart b/lib/utils/constants.dart index 8d4094ac..9c43950a 100644 --- a/lib/utils/constants.dart +++ b/lib/utils/constants.dart @@ -199,6 +199,7 @@ const Duration kDelayAfterAccountBlockCreationCall = Duration( ); const Duration kProjectVotingPeriod = Duration(days: 14); const Duration kEmbeddedConnectionDelay = Duration(seconds: 30); +const Duration kDashboardRefreshInterval = Duration(minutes: 1); // Tabs const List kTabsWithTextTitles = [ diff --git a/pubspec.lock b/pubspec.lock index ebc6c0d8..66dbc464 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -150,6 +150,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.6" + bloc: + dependency: "direct main" + description: + name: bloc + sha256: "106842ad6569f0b60297619e9e0b1885c2fb9bf84812935490e6c5275777804e" + url: "https://pub.dev" + source: hosted + version: "8.1.4" boolean_selector: dependency: transitive description: @@ -539,6 +547,14 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_bloc: + dependency: "direct main" + description: + name: flutter_bloc + sha256: b594505eac31a0518bdcb4b5b79573b8d9117b193cc80cc12e17d639b10aa27a + url: "https://pub.dev" + source: hosted + version: "8.1.6" flutter_flip_card: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 01ca4323..465f2aba 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -73,6 +73,8 @@ dependencies: version: ^3.0.0 mutex: ^3.1.0 retry: ^3.1.2 + flutter_bloc: ^8.1.6 + bloc: ^8.1.4 dev_dependencies: build_runner: ^2.4.6 From f3c2550988f8d503cd8f38271c8d252d8f342556 Mon Sep 17 00:00:00 2001 From: kossmmos <184493470+kossmmos@users.noreply.github.com> Date: Thu, 10 Oct 2024 15:02:48 +0200 Subject: [PATCH 003/102] mods: delegation cubit. tests. --- .../delegation/cubit/delegation_cubit.dart | 6 +- .../delegation/view/delegation_card.dart | 3 + pubspec.lock | 159 +++++++++++++++++- pubspec.yaml | 16 +- .../cubit/delegation_cubit_test.dart | 105 ++++++++++++ 5 files changed, 276 insertions(+), 13 deletions(-) create mode 100644 test/delegation/cubit/delegation_cubit_test.dart diff --git a/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart b/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart index b74aafa4..2f75ab75 100644 --- a/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart +++ b/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart @@ -10,11 +10,13 @@ part 'delegation_state.dart'; /// This cubit extends `DashboardCubit`, using the `DelegationInfo` data type /// to store and manage delegation stats for the account identified by `kDemoAddress`. class DelegationCubit extends DashboardCubit { + + final Address address; /// Constructs a `DelegationCubit`, passing the `zenon` client and the initial state /// to the parent class. /// /// The `zenon` client is used to interact with the Zenon network to retrieve delegation information. - DelegationCubit(super.zenon, super.initialState); + DelegationCubit(this.address, super.zenon, super.initialState); /// Fetches the delegation information for the account identified by its address. /// @@ -29,7 +31,7 @@ class DelegationCubit extends DashboardCubit { Future fetch() async { try { final DelegationInfo? delegationInfo = await zenon.embedded.pillar.getDelegatedPillar( - Address.parse(kSelectedAddress!), + address, ); // Check if delegation information is available diff --git a/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart b/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart index 42ba059c..77e4e4f9 100644 --- a/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart +++ b/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class DelegationCard extends StatelessWidget { @@ -12,6 +14,7 @@ class DelegationCard extends StatelessWidget { return BlocProvider( create: (_) { final DelegationCubit cubit = DelegationCubit( + Address.parse(kSelectedAddress!), zenon!, DelegationState(), ); diff --git a/pubspec.lock b/pubspec.lock index 66dbc464..347691f9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -158,6 +158,14 @@ packages: url: "https://pub.dev" source: hosted version: "8.1.4" + bloc_test: + dependency: "direct dev" + description: + name: bloc_test + sha256: "165a6ec950d9252ebe36dc5335f2e6eb13055f33d56db0eeb7642768849b43d2" + url: "https://pub.dev" + source: hosted + version: "9.1.7" boolean_selector: dependency: transitive description: @@ -310,6 +318,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.1" + coverage: + dependency: transitive + description: + name: coverage + sha256: c1fb2dce3c0085f39dc72668e85f8e0210ec7de05345821ff58530567df345a5 + url: "https://pub.dev" + source: hosted + version: "1.9.2" cross_file: dependency: transitive description: @@ -382,6 +398,14 @@ packages: url: "https://pub.dev" source: hosted version: "7.0.1" + diff_match_patch: + dependency: transitive + description: + name: diff_match_patch + sha256: "2efc9e6e8f449d0abe15be240e2c2a3bcd977c8d126cfd70598aee60af35c0a4" + url: "https://pub.dev" + source: hosted + version: "0.4.1" dotted_border: dependency: "direct main" description: @@ -438,6 +462,14 @@ packages: url: "https://pub.dev" source: hosted version: "5.0.1" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" + source: hosted + version: "1.3.1" ffi: dependency: "direct main" description: @@ -595,6 +627,11 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.10+1" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" flutter_vector_icons: dependency: "direct main" description: @@ -848,6 +885,30 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.5" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + url: "https://pub.dev" + source: hosted + version: "10.0.5" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + url: "https://pub.dev" + source: hosted + version: "3.0.5" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" lints: dependency: transitive description: @@ -952,6 +1013,14 @@ packages: url: "https://pub.dev" source: hosted version: "5.2.3" + mocktail: + dependency: "direct dev" + description: + name: mocktail + sha256: "890df3f9688106f25755f26b1c60589a92b3ab91a22b8b224947ad041bf172d8" + url: "https://pub.dev" + source: hosted + version: "1.0.4" mutex: dependency: "direct main" description: @@ -968,6 +1037,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.0" + node_preamble: + dependency: transitive + description: + name: node_preamble + sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" + url: "https://pub.dev" + source: hosted + version: "2.0.2" number_selector: dependency: "direct main" description: @@ -1344,6 +1421,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.4.1" + shelf_packages_handler: + dependency: transitive + description: + name: shelf_packages_handler + sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + shelf_static: + dependency: transitive + description: + name: shelf_static + sha256: c87c3875f91262785dade62d135760c2c69cb217ac759485334c5857ad89f6e3 + url: "https://pub.dev" + source: hosted + version: "1.1.3" shelf_web_socket: dependency: transitive description: @@ -1397,6 +1490,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.4" + source_map_stack_trace: + dependency: transitive + description: + name: source_map_stack_trace + sha256: c0713a43e323c3302c2abe2a1cc89aa057a387101ebd280371d6a6c9fa68516b + url: "https://pub.dev" + source: hosted + version: "2.1.2" + source_maps: + dependency: transitive + description: + name: source_maps + sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703" + url: "https://pub.dev" + source: hosted + version: "0.10.12" source_span: dependency: transitive description: @@ -1409,10 +1518,10 @@ packages: dependency: transitive description: name: stack_trace - sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377" + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.12.0" + version: "1.11.1" stacked: dependency: "direct main" description: @@ -1449,10 +1558,10 @@ packages: dependency: transitive description: name: string_scanner - sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.2.0" term_glyph: dependency: transitive description: @@ -1461,14 +1570,30 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.1" + test: + dependency: transitive + description: + name: test + sha256: "7ee44229615f8f642b68120165ae4c2a75fe77ae2065b1e55ae4711f6cf0899e" + url: "https://pub.dev" + source: hosted + version: "1.25.7" test_api: dependency: transitive description: name: test_api - sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c" + sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" + url: "https://pub.dev" + source: hosted + version: "0.7.2" + test_core: + dependency: transitive + description: + name: test_core + sha256: "55ea5a652e38a1dfb32943a7973f3681a60f872f8c3a05a14664ad54ef9c6696" url: "https://pub.dev" source: hosted - version: "0.7.3" + version: "0.6.4" timing: dependency: transitive description: @@ -1621,6 +1746,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.2" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" + url: "https://pub.dev" + source: hosted + version: "14.2.5" wakelock_plus: dependency: "direct main" description: @@ -1693,6 +1826,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.4.0" + webkit_inspection_protocol: + dependency: transitive + description: + name: webkit_inspection_protocol + sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" + url: "https://pub.dev" + source: hosted + version: "1.2.1" win32: dependency: transitive description: @@ -1762,9 +1903,9 @@ packages: dependency: "direct main" description: path: "." - ref: "v0.0.7" - resolved-ref: "8511f17a0dfa721e8f0ec2e0b0aae409f509e102" - url: "https://github.com/zenon-network/znn_sdk_dart.git" + ref: refactor + resolved-ref: "4fadee2fcbe2fb5feb2c1f66ba06fc28c6eda7e6" + url: "https://github.com/maznnwell/znn_sdk_dart.git" source: git version: "0.0.7" zxing2: diff --git a/pubspec.yaml b/pubspec.yaml index 465f2aba..60206600 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -43,8 +43,8 @@ dependencies: number_selector: ^1.0.5 znn_sdk_dart: git: - url: https://github.com/zenon-network/znn_sdk_dart.git - ref: v0.0.7 + url: https://github.com/maznnwell/znn_sdk_dart.git + ref: refactor znn_ledger_dart: git: url: https://github.com/zenon-network/znn_ledger_dart.git @@ -76,11 +76,23 @@ dependencies: flutter_bloc: ^8.1.6 bloc: ^8.1.4 + +dependency_overrides: + znn_sdk_dart: + git: + url: https://github.com/maznnwell/znn_sdk_dart.git + ref: refactor + dev_dependencies: build_runner: ^2.4.6 hive_generator: ^2.0.0 flutter_lints: ^5.0.0 dependency_validator: ^4.1.1 + mocktail: ^1.0.4 + bloc_test: ^9.0.0 + flutter_test: + sdk: flutter + flutter: uses-material-design: true diff --git a/test/delegation/cubit/delegation_cubit_test.dart b/test/delegation/cubit/delegation_cubit_test.dart new file mode 100644 index 00000000..448709f7 --- /dev/null +++ b/test/delegation/cubit/delegation_cubit_test.dart @@ -0,0 +1,105 @@ +// ignore_for_file: prefer_const_constructors + +import 'package:flutter_test/flutter_test.dart'; +import 'package:bloc_test/bloc_test.dart'; +import 'package:mocktail/mocktail.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +class MockZenon extends Mock implements Zenon {} + +class MockEmbedded extends Mock implements EmbeddedApi {} + +class MockPillar extends Mock implements PillarApi {} + +class MockDelegationInfo extends Mock implements DelegationInfo {} + +class FakeAddress extends Fake implements Address {} + + +void main() { + + setUpAll(() { + registerFallbackValue(FakeAddress()); + }); + + group('DelegationCubit', () { + late MockZenon mockZenon; + late DelegationCubit delegationCubit; + late MockEmbedded mockEmbedded; + late MockPillar mockPillar; + late MockDelegationInfo delegationInfo; + + setUp(() async { + mockZenon = MockZenon(); + delegationCubit = DelegationCubit(emptyAddress, mockZenon, DelegationState()); + delegationInfo = MockDelegationInfo(); + mockEmbedded = MockEmbedded(); + mockPillar = MockPillar(); + when( + () => mockZenon.embedded + ).thenReturn(mockEmbedded); + + when( + () => mockEmbedded.pillar + ).thenReturn(mockPillar); + when( + () => mockPillar.getDelegatedPillar(any()) + ).thenAnswer((_) async => delegationInfo); + + + }); + + test('initial status is correct', () { + final DelegationCubit delegationCubit = DelegationCubit( + emptyAddress, + mockZenon, + DelegationState(), + ); + expect(delegationCubit.state.status, CubitStatus.initial); + }); + + group('fetch', () { + blocTest( + 'calls getDelegatedPillar once', + build: () => delegationCubit, + act: (cubit) => cubit.fetch(), + verify: (_) { + verify(() => mockZenon.embedded.pillar.getDelegatedPillar( + emptyAddress, + )).called(1); + }, + ); + + blocTest( + 'emits [loading, failure] when getDelegatedPillar throws', + setUp: () { + when( + () => mockZenon.embedded.pillar.getDelegatedPillar(emptyAddress), + ).thenThrow(Exception('No delegation stats available - test')); + }, + build: () => delegationCubit, + act: (cubit) => cubit.fetch(), + expect: () => [ + DelegationState(status: CubitStatus.loading), + DelegationState(status: CubitStatus.failure), + ], + ); + + blocTest( + 'emits [loading, success] when getDelegatedPillar returns (delegationInfo)', + setUp: () { + when( + () => mockZenon.embedded.pillar.getDelegatedPillar(any()), + ).thenReturn(delegationInfo as Future); + }, + build: () => delegationCubit, + act: (cubit) => cubit.fetch, + expect: () => [ + DelegationState(status: CubitStatus.loading), + DelegationState(status: CubitStatus.success), + ] + ); + }); + }); +} From 38853b109c266cc1082728f41dcdcdad0175fa29 Mon Sep 17 00:00:00 2001 From: kossmmos <184493470+kossmmos@users.noreply.github.com> Date: Thu, 10 Oct 2024 15:25:05 +0200 Subject: [PATCH 004/102] mods: delegation cubit - tests. --- .../cubit/delegation_cubit_test.dart | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/test/delegation/cubit/delegation_cubit_test.dart b/test/delegation/cubit/delegation_cubit_test.dart index 448709f7..3d85086b 100644 --- a/test/delegation/cubit/delegation_cubit_test.dart +++ b/test/delegation/cubit/delegation_cubit_test.dart @@ -70,36 +70,6 @@ void main() { )).called(1); }, ); - - blocTest( - 'emits [loading, failure] when getDelegatedPillar throws', - setUp: () { - when( - () => mockZenon.embedded.pillar.getDelegatedPillar(emptyAddress), - ).thenThrow(Exception('No delegation stats available - test')); - }, - build: () => delegationCubit, - act: (cubit) => cubit.fetch(), - expect: () => [ - DelegationState(status: CubitStatus.loading), - DelegationState(status: CubitStatus.failure), - ], - ); - - blocTest( - 'emits [loading, success] when getDelegatedPillar returns (delegationInfo)', - setUp: () { - when( - () => mockZenon.embedded.pillar.getDelegatedPillar(any()), - ).thenReturn(delegationInfo as Future); - }, - build: () => delegationCubit, - act: (cubit) => cubit.fetch, - expect: () => [ - DelegationState(status: CubitStatus.loading), - DelegationState(status: CubitStatus.success), - ] - ); }); }); } From 7eb39c1b5088ee399c500332fb03682384f70711 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Fri, 11 Oct 2024 15:36:23 +0300 Subject: [PATCH 005/102] feat: Improve the DashboardCubit class --- .../dashboard/balance/view/balance_card.dart | 2 +- .../view/balance_dashboard_card.dart | 2 +- .../dashboard/dashboard_cubit.dart | 34 +++++---- .../dashboard/dashboard_state.dart | 7 +- .../delegation/cubit/delegation_cubit.dart | 1 - .../delegation/cubit/delegation_state.dart | 2 +- .../delegation/view/delegation_card.dart | 13 +++- .../view/dual_coin_stats_card.dart | 2 +- .../dashboard/pillars/view/pillars_card.dart | 2 +- .../view/realtime_statistics_card.dart | 2 +- .../sentinels/view/sentinels_card.dart | 2 +- .../dashboard/staking/view/staking_card.dart | 2 +- .../view/total_hourly_transactions_card.dart | 2 +- .../layout_scaffold/layout_scaffold.dart | 1 + pubspec.lock | 2 +- pubspec.yaml | 1 + .../cubit/delegation_cubit_test.dart | 72 +++++++++++++------ 17 files changed, 98 insertions(+), 51 deletions(-) diff --git a/lib/rearchitecture/dashboard/balance/view/balance_card.dart b/lib/rearchitecture/dashboard/balance/view/balance_card.dart index 14010769..f28caf24 100644 --- a/lib/rearchitecture/dashboard/balance/view/balance_card.dart +++ b/lib/rearchitecture/dashboard/balance/view/balance_card.dart @@ -29,7 +29,7 @@ class BalanceCard extends StatelessWidget { zenon!, BalanceState() ); - cubit.fetch(); + cubit.fetchDataPeriodically(); return cubit; }, child: Scaffold( diff --git a/lib/rearchitecture/dashboard/balance_dashboard/view/balance_dashboard_card.dart b/lib/rearchitecture/dashboard/balance_dashboard/view/balance_dashboard_card.dart index 3972c65f..5d76750e 100644 --- a/lib/rearchitecture/dashboard/balance_dashboard/view/balance_dashboard_card.dart +++ b/lib/rearchitecture/dashboard/balance_dashboard/view/balance_dashboard_card.dart @@ -26,7 +26,7 @@ class BalanceDashboardCard extends StatelessWidget { zenon!, BalanceDashboardState(), ); - cubit.fetch(); + cubit.fetchDataPeriodically(); return cubit; }, child: Scaffold( diff --git a/lib/rearchitecture/dashboard/dashboard_cubit.dart b/lib/rearchitecture/dashboard/dashboard_cubit.dart index 31e97472..b2897cc9 100644 --- a/lib/rearchitecture/dashboard/dashboard_cubit.dart +++ b/lib/rearchitecture/dashboard/dashboard_cubit.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -21,35 +22,39 @@ abstract class DashboardCubit extends Cubit> { /// Constructs a `DashboardCubit` with the provided [zenon] client and initial state. /// /// The auto-refresh functionality is initialized upon the cubit's creation. - DashboardCubit(this.zenon, super.initialState, {this.refreshInterval = kDashboardRefreshInterval}) { - _startAutoRefresh(); - } + DashboardCubit( + this.zenon, + super.initialState, { + this.refreshInterval = kDashboardRefreshInterval, + }); /// Fetches data of type [T] that is managed by the cubit. /// /// This method needs to be implemented by subclasses, and it should define /// the specific data-fetching logic (e.g., fetching account information). + /// + /// It shouldn't be used to emit states Future fetch(); /// Returns a [Timer] that triggers the auto-refresh functionality after /// the predefined [kDashboardRefreshInterval]. /// /// This method cancels any existing timers and initiates a new periodic - /// fetch cycle by calling [_fetchDataPeriodically]. + /// fetch cycle by calling [fetchDataPeriodically]. Timer _getAutoRefreshTimer() => Timer( - refreshInterval, + refreshInterval, () { - _autoRefresher!.cancel(); - _fetchDataPeriodically(); - }, - ); + _autoRefresher!.cancel(); + fetchDataPeriodically(); + }, + ); /// Periodically fetches data and updates the state with either success or failure. /// /// This method fetches new data by calling [fetch], emits a loading state while /// fetching, and updates the state with success or failure based on the outcome. /// If the WebSocket client is closed, it throws a [noConnectionException]. - Future _fetchDataPeriodically() async { + Future fetchDataPeriodically() async { try { emit(state.copyWith(status: CubitStatus.loading)); if (!zenon.wsClient.isClosed()) { @@ -62,10 +67,8 @@ abstract class DashboardCubit extends Cubit> { emit(state.copyWith(status: CubitStatus.failure, error: e)); } finally { /// Ensure that the auto-refresher is restarted if it's not active. - if (_autoRefresher == null) { - _autoRefresher = _getAutoRefreshTimer(); - } else if (!_autoRefresher!.isActive) { - _autoRefresher = _getAutoRefreshTimer(); + if (!isTimerActive) { + _startAutoRefresh(); } } } @@ -75,6 +78,9 @@ abstract class DashboardCubit extends Cubit> { _autoRefresher = _getAutoRefreshTimer(); } + /// Checks if a timer was set and if it's active + bool get isTimerActive => _autoRefresher?.isActive ?? false; + /// Cancels the auto-refresh timer and closes the cubit. /// /// This method is called when the cubit is closed, ensuring that no background diff --git a/lib/rearchitecture/dashboard/dashboard_state.dart b/lib/rearchitecture/dashboard/dashboard_state.dart index 70fadb7c..5c3381fb 100644 --- a/lib/rearchitecture/dashboard/dashboard_state.dart +++ b/lib/rearchitecture/dashboard/dashboard_state.dart @@ -25,7 +25,7 @@ enum CubitStatus { /// - [status]: A [CubitStatus] that indicates the current state (loading, success, etc.). /// - [data]: The data of type [T] that is managed by the cubit. /// - [error]: An optional [error] object that contains error details if the cubit is in a failure state. -abstract class DashboardState { +abstract class DashboardState extends Equatable { /// Represents the current status of the cubit, such as loading, success, or failure. final CubitStatus status; @@ -39,7 +39,7 @@ abstract class DashboardState { /// /// - The [status] defaults to [CubitStatus.initial] if not provided. /// - The [data] and [error] can be null, indicating that either no data has been fetched yet, or an error has occurred. - DashboardState({ + const DashboardState({ this.status = CubitStatus.initial, this.data, this.error, @@ -58,4 +58,7 @@ abstract class DashboardState { T? data, Object? error, }); + + @override + List get props => [status, data, error]; } diff --git a/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart b/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart index 2f75ab75..356b2860 100644 --- a/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart +++ b/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart @@ -1,5 +1,4 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'delegation_state.dart'; diff --git a/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart b/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart index 78a287c0..cc353f9e 100644 --- a/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart +++ b/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart @@ -9,7 +9,7 @@ class DelegationState extends DashboardState { /// /// This state is initialized with default `status`, `data`, and `error` values from the parent `DashboardState` class. /// It manages delegation information for an account. - DelegationState({ + const DelegationState({ super.status, super.data, super.error, diff --git a/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart b/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart index 77e4e4f9..98f90e0f 100644 --- a/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart +++ b/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart @@ -3,8 +3,13 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; +const String _kWidgetTitle = 'Delegation Stats'; +final String _kWidgetDescription = 'This card displays the amount of ' + '${kZnnCoin.symbol} and the name of the Pillar that you delegated to'; class DelegationCard extends StatelessWidget { const DelegationCard({super.key}); @@ -18,11 +23,13 @@ class DelegationCard extends StatelessWidget { zenon!, DelegationState(), ); - cubit.fetch(); + cubit.fetchDataPeriodically(); return cubit; }, - child: Scaffold( - body: BlocBuilder( + child: CardScaffoldWithoutListener( + description: _kWidgetDescription, + title: _kWidgetTitle, + child: BlocBuilder( builder: (context, state) { return switch (state.status) { CubitStatus.initial => const DelegationEmpty(), diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart b/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart index 466ca5f3..3e87999b 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart @@ -15,7 +15,7 @@ class DualCoinStatsCard extends StatelessWidget { zenon!, DualCoinStatsState(), ); - cubit.fetch(); + cubit.fetchDataPeriodically(); return cubit; }, child: Scaffold( diff --git a/lib/rearchitecture/dashboard/pillars/view/pillars_card.dart b/lib/rearchitecture/dashboard/pillars/view/pillars_card.dart index d62a0d9d..d6628404 100644 --- a/lib/rearchitecture/dashboard/pillars/view/pillars_card.dart +++ b/lib/rearchitecture/dashboard/pillars/view/pillars_card.dart @@ -15,7 +15,7 @@ class PillarsCard extends StatelessWidget { zenon!, PillarsState(), ); - cubit.fetch(); + cubit.fetchDataPeriodically(); return cubit; }, child: Scaffold( diff --git a/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart b/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart index 89209af7..7bb6396f 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart @@ -16,7 +16,7 @@ class RealtimeStatisticsCard extends StatelessWidget { zenon!, RealtimeStatisticsState(), ); - cubit.fetch(); + cubit.fetchDataPeriodically(); return cubit; }, child: Scaffold( diff --git a/lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart b/lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart index b29c1689..2c3f1824 100644 --- a/lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart +++ b/lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart @@ -14,7 +14,7 @@ class SentinelsCard extends StatelessWidget { zenon!, SentinelsState(), ); - cubit.fetch(); + cubit.fetchDataPeriodically(); return cubit; }, child: Scaffold( diff --git a/lib/rearchitecture/dashboard/staking/view/staking_card.dart b/lib/rearchitecture/dashboard/staking/view/staking_card.dart index 329e14b9..474d091a 100644 --- a/lib/rearchitecture/dashboard/staking/view/staking_card.dart +++ b/lib/rearchitecture/dashboard/staking/view/staking_card.dart @@ -14,7 +14,7 @@ class StakingCard extends StatelessWidget { zenon!, StakingState(), ); - cubit.fetch(); + cubit.fetchDataPeriodically(); return cubit; }, child: Scaffold( diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart index 52a60516..0a76e774 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart @@ -14,7 +14,7 @@ class TotalHourlyTransactionsCard extends StatelessWidget { zenon!, TotalHourlyTransactionsState(), ); - cubit.fetch(); + cubit.fetchDataPeriodically(); return cubit; }, child: Scaffold( diff --git a/lib/widgets/reusable_widgets/layout_scaffold/layout_scaffold.dart b/lib/widgets/reusable_widgets/layout_scaffold/layout_scaffold.dart index a254a06d..a9b503c7 100644 --- a/lib/widgets/reusable_widgets/layout_scaffold/layout_scaffold.dart +++ b/lib/widgets/reusable_widgets/layout_scaffold/layout_scaffold.dart @@ -1,4 +1,5 @@ export 'card_scaffold.dart'; +export 'card_scaffold_without_listener.dart'; export 'overscroll_remover.dart'; export 'standard_fluid_layout.dart'; export 'widget_animator.dart'; diff --git a/pubspec.lock b/pubspec.lock index 347691f9..66869214 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -439,7 +439,7 @@ packages: source: hosted version: "1.0.2" equatable: - dependency: transitive + dependency: "direct main" description: name: equatable sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2 diff --git a/pubspec.yaml b/pubspec.yaml index 60206600..06343af7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -75,6 +75,7 @@ dependencies: retry: ^3.1.2 flutter_bloc: ^8.1.6 bloc: ^8.1.4 + equatable: ^2.0.5 dependency_overrides: diff --git a/test/delegation/cubit/delegation_cubit_test.dart b/test/delegation/cubit/delegation_cubit_test.dart index 3d85086b..533cca69 100644 --- a/test/delegation/cubit/delegation_cubit_test.dart +++ b/test/delegation/cubit/delegation_cubit_test.dart @@ -8,6 +8,8 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class MockZenon extends Mock implements Zenon {} +class MockWsClient extends Mock implements WsClient {} + class MockEmbedded extends Mock implements EmbeddedApi {} class MockPillar extends Mock implements PillarApi {} @@ -16,60 +18,88 @@ class MockDelegationInfo extends Mock implements DelegationInfo {} class FakeAddress extends Fake implements Address {} - void main() { - setUpAll(() { registerFallbackValue(FakeAddress()); }); group('DelegationCubit', () { late MockZenon mockZenon; + late MockWsClient mockWsClient; late DelegationCubit delegationCubit; late MockEmbedded mockEmbedded; late MockPillar mockPillar; late MockDelegationInfo delegationInfo; + late Exception delegationException; setUp(() async { mockZenon = MockZenon(); - delegationCubit = DelegationCubit(emptyAddress, mockZenon, DelegationState()); + mockWsClient = MockWsClient(); delegationInfo = MockDelegationInfo(); mockEmbedded = MockEmbedded(); mockPillar = MockPillar(); - when( - () => mockZenon.embedded - ).thenReturn(mockEmbedded); - - when( - () => mockEmbedded.pillar - ).thenReturn(mockPillar); - when( - () => mockPillar.getDelegatedPillar(any()) - ).thenAnswer((_) async => delegationInfo); - - - }); - - test('initial status is correct', () { - final DelegationCubit delegationCubit = DelegationCubit( + delegationException = Exception('No delegation stats available - test'); + + when(() => mockZenon.wsClient).thenReturn(mockWsClient); + when(() => mockWsClient.isClosed()).thenReturn(false); + when(() => mockZenon.embedded).thenReturn(mockEmbedded); + when(() => mockEmbedded.pillar).thenReturn(mockPillar); + when(() => mockPillar.getDelegatedPillar(any())) + .thenAnswer((_) async => delegationInfo); + delegationCubit = DelegationCubit( emptyAddress, mockZenon, DelegationState(), ); + }); + + test('initial status is correct', () { expect(delegationCubit.state.status, CubitStatus.initial); }); - group('fetch', () { + group('fetchDataPeriodically', () { blocTest( 'calls getDelegatedPillar once', build: () => delegationCubit, - act: (cubit) => cubit.fetch(), + act: (cubit) => cubit.fetchDataPeriodically(), verify: (_) { verify(() => mockZenon.embedded.pillar.getDelegatedPillar( emptyAddress, )).called(1); }, ); + + blocTest( + 'emits [loading, failure] when getDelegatedPillar throws', + setUp: () { + when( + () => mockPillar.getDelegatedPillar( + any(), + ), + ).thenThrow(delegationException); + }, + build: () => delegationCubit, + act: (cubit) => cubit.fetchDataPeriodically(), + expect: () => [ + DelegationState(status: CubitStatus.loading), + DelegationState( + status: CubitStatus.failure, + error: delegationException, + ), + ], + ); + + blocTest( + 'emits [loading, success] when getDelegatedPillar ' + 'returns a DelegationInfo instance', + build: () => delegationCubit, + act: (cubit) => cubit.fetchDataPeriodically(), + expect: () => [ + DelegationState(status: CubitStatus.loading), + isA() + .having((state) => state.status, 'status', CubitStatus.success), + ], + ); }); }); } From 71a96ac1ed7e85f499a6a2674602ed45476eada2 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Fri, 11 Oct 2024 16:55:49 +0300 Subject: [PATCH 006/102] feat: Finish the delegation widgets --- .../delegation/widgets/delegation_empty.dart | 3 +- .../delegation/widgets/delegation_error.dart | 3 +- .../widgets/delegation_loading.dart | 3 +- .../widgets/delegation_populated.dart | 43 +- .../card_scaffold_without_listener.dart | 377 ++++++++++++++++++ .../dashboard_tab_child.dart | 3 +- 6 files changed, 426 insertions(+), 6 deletions(-) create mode 100644 lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart diff --git a/lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart b/lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart index 321beb00..92fea012 100644 --- a/lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart +++ b/lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart @@ -1,10 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; class DelegationEmpty extends StatelessWidget { const DelegationEmpty({super.key}); @override Widget build(BuildContext context) { - return const Text('empty'); + return SyriusErrorWidget('No data available'); } } \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart b/lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart index 42ea6cb8..1cb893c6 100644 --- a/lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart +++ b/lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; class DelegationError extends StatelessWidget { final Object error; @@ -7,6 +8,6 @@ class DelegationError extends StatelessWidget { @override Widget build(BuildContext context) { - return Text(error.toString()); + return SyriusErrorWidget(error); } } diff --git a/lib/rearchitecture/dashboard/delegation/widgets/delegation_loading.dart b/lib/rearchitecture/dashboard/delegation/widgets/delegation_loading.dart index c7079084..c0c23fad 100644 --- a/lib/rearchitecture/dashboard/delegation/widgets/delegation_loading.dart +++ b/lib/rearchitecture/dashboard/delegation/widgets/delegation_loading.dart @@ -1,10 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; class DelegationLoading extends StatelessWidget { const DelegationLoading({super.key}); @override Widget build(BuildContext context) { - return const Text('loading'); + return SyriusLoadingWidget(); } } diff --git a/lib/rearchitecture/dashboard/delegation/widgets/delegation_populated.dart b/lib/rearchitecture/dashboard/delegation/widgets/delegation_populated.dart index 3c17748f..ea9d51c1 100644 --- a/lib/rearchitecture/dashboard/delegation/widgets/delegation_populated.dart +++ b/lib/rearchitecture/dashboard/delegation/widgets/delegation_populated.dart @@ -1,13 +1,52 @@ import 'package:flutter/material.dart'; +import 'package:flutter_vector_icons/flutter_vector_icons.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class DelegationPopulated extends StatelessWidget { - final DelegationInfo? data; + final DelegationInfo data; const DelegationPopulated({required this.data, super.key}); @override Widget build(BuildContext context) { - return Text(data.toString()); + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + padding: const EdgeInsets.all(8.0), + width: 36.0, + height: 36.0, + decoration: BoxDecoration( + shape: BoxShape.circle, + border: Border.all( + color: data.status == 1 + ? AppColors.znnColor + : AppColors.errorColor, + ), + ), + child: Icon( + SimpleLineIcons.trophy, + size: 12.0, + color: Theme.of(context).textTheme.bodyLarge!.color, + ), + ), + Container(width: 16.0), + Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + data.name.toString(), + style: Theme.of(context).textTheme.bodyMedium, + ), + Text( + '${data.weight.addDecimals(coinDecimals)} ${kZnnCoin.symbol}', + style: Theme.of(context).textTheme.titleMedium, + ), + ], + ), + ], + ); } } diff --git a/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart b/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart new file mode 100644 index 00000000..bde9b50f --- /dev/null +++ b/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart @@ -0,0 +1,377 @@ +import 'package:expandable/expandable.dart'; +import 'package:flip_card/flip_card.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_vector_icons/flutter_vector_icons.dart'; +import 'package:lottie/lottie.dart'; +import 'package:stacked/stacked.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/main.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/widget_utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; + +class CardScaffoldWithoutListener extends StatefulWidget { + final Widget child; + final String? title; + final String description; + final VoidCallback? onRefreshPressed; + + const CardScaffoldWithoutListener({ + required this.child, + required this.title, + required this.description, + this.onRefreshPressed, + super.key, + }); + + @override + State createState() => _CardScaffoldWithoutListenerState(); +} + +class _CardScaffoldWithoutListenerState extends State { + GlobalKey cardKey = GlobalKey(); + final GlobalKey _actionButtonKey = GlobalKey(); + + final TextEditingController _passwordController = TextEditingController(); + + bool? _hideWidgetInfo = false; + bool _showPasswordInputField = false; + + String? _messageToUser; + + LoadingButton? _actionButton; + + @override + void initState() { + super.initState(); + _hideWidgetInfo = _getWidgetHiddenInfoValue(widget.title); + } + + @override + Widget build(BuildContext context) { + return FlipCard( + direction: FlipDirection.HORIZONTAL, + speed: 500, + flipOnTouch: false, + key: cardKey, + onFlipDone: (status) {}, + front: ClipRRect( + borderRadius: BorderRadius.circular( + 15.0, + ), + child: Container( + color: Theme.of(context).colorScheme.primary, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + _getWidgetHeader(widget.title!), + const Divider(), + Expanded( + child: Material( + color: Theme.of(context).colorScheme.primary, + child: _getWidgetFrontBody(), + ), + ) + ], + ), + ), + ), + back: ClipRRect( + borderRadius: BorderRadius.circular( + 15.0, + ), + child: Material( + child: Container( + color: Theme.of(context).colorScheme.primary, + child: Column( + children: [ + _getWidgetHeader(widget.title!), + const Divider(), + Expanded( + child: _getHideWidgetInfoViewModel(), + ), + ], + ), + ), + ), + ), + ); + } + + Widget _getBackBody(HideWidgetStatusBloc model) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: ListView( + shrinkWrap: true, + children: [ + ExpandablePanel( + collapsed: Container(), + theme: ExpandableThemeData( + iconColor: Theme.of(context).textTheme.bodyLarge!.color, + headerAlignment: ExpandablePanelHeaderAlignment.center, + iconPlacement: ExpandablePanelIconPlacement.right, + ), + header: Row( + children: [ + const Icon( + Icons.info, + color: AppColors.znnColor, + size: 20.0, + ), + const SizedBox( + width: 5.0, + ), + Expanded( + child: Text( + 'Description', + style: Theme.of(context).textTheme.bodyLarge, + ), + ), + ], + ), + expanded: Padding( + padding: const EdgeInsets.only( + left: 14.0, + top: 5.0, + bottom: 5.0, + ), + child: Text( + widget.description, + style: Theme.of(context).textTheme.titleMedium, + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + const Icon( + Icons.remove_red_eye_rounded, + color: AppColors.znnColor, + size: 20.0, + ), + const SizedBox( + width: 5.0, + ), + Expanded( + child: Text( + 'Discreet mode', + style: Theme.of(context).textTheme.bodyLarge, + ), + ), + const Spacer(), + Switch( + splashRadius: 0.0, + value: _hideWidgetInfo!, + onChanged: (value) { + setState(() { + _hideWidgetInfo = value; + }); + if (value) { + if (_getWidgetHiddenInfoValue(widget.title) != value) { + model.checkPassAndMarkWidgetWithHiddenValue( + widget.title!, + _passwordController.text, + value, + ); + } else { + setState(() { + _showPasswordInputField = false; + }); + } + } else { + setState(() { + _showPasswordInputField = true; + }); + } + }, + ) + ], + ), + Visibility( + visible: _showPasswordInputField, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: _getPasswordInputField(model), + ), + const SizedBox( + width: 10.0, + ), + _actionButton!, + ], + ), + ), + ], + ), + ); + } + + Widget _getWidgetHeader(String title) { + return Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Padding( + padding: const EdgeInsets.all(14.0), + child: Row( + children: [ + Expanded( + child: Text( + title, + style: Theme.of(context).textTheme.titleMedium, + ), + ), + const SizedBox( + width: 5.0, + ), + ], + ), + ), + ), + Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Visibility( + visible: widget.onRefreshPressed != null, + child: Material( + shadowColor: Colors.transparent, + color: Colors.transparent, + child: IconButton( + splashRadius: 15.0, + icon: const Icon(Icons.refresh), + iconSize: 18.0, + color: Theme.of(context).colorScheme.secondary, + onPressed: widget.onRefreshPressed, + ), + ), + ), + Material( + shadowColor: Colors.transparent, + color: Colors.transparent, + child: IconButton( + splashRadius: 15.0, + icon: const Icon(Icons.more_horiz), + iconSize: 18.0, + color: Theme.of(context).textTheme.bodyLarge!.color, + onPressed: () { + cardKey.currentState!.toggleCard(); + }, + ), + ), + ], + ), + ], + ); + } + + Widget _getPasswordInputField(HideWidgetStatusBloc model) { + return PasswordInputField( + onSubmitted: (value) { + _actionButton!.onPressed!(); + }, + controller: _passwordController, + errorText: _messageToUser, + hintText: 'Password', + ); + } + + LoadingButton _getActionButton(HideWidgetStatusBloc model) { + return LoadingButton.icon( + onPressed: () => _onActionButtonPressed(model), + key: _actionButtonKey, + icon: const Icon( + AntDesign.arrowright, + color: AppColors.znnColor, + size: 25.0, + ), + ); + } + + Widget _getHideWidgetInfoViewModel() { + return ViewModelBuilder.reactive( + onViewModelReady: (model) { + _actionButton = _getActionButton(model); + // Stream will tell us if the widget info is hidden or not + model.stream.listen( + (response) { + if (response != null) { + _passwordController.clear(); + if (!response) { + setState(() { + _showPasswordInputField = false; + }); + } + } + }, + onError: (error) { + setState(() { + _messageToUser = error.toString(); + }); + }, + ); + }, + builder: (_, model, __) => StreamBuilder( + stream: model.stream, + builder: (_, snapshot) { + if (snapshot.hasError) { + return _getBackBody(model); + } + if (snapshot.connectionState == ConnectionState.active) { + if (snapshot.hasData) { + return _getBackBody(model); + } + return const Center( + child: SyriusLoadingWidget( + size: 25.0, + ), + ); + } + return _getBackBody(model); + }, + ), + viewModelBuilder: () => HideWidgetStatusBloc(), + ); + } + + Widget? _getWidgetFrontBody() { + return _getWidgetHiddenInfoValue(widget.title) + ? _getHiddenInfoWidget() + : widget.child; + } + + Widget _getHiddenInfoWidget() { + return Lottie.asset('assets/lottie/ic_anim_eye.json'); + } + + bool _getWidgetHiddenInfoValue(String? title) { + return sharedPrefsService!.get( + WidgetUtils.isWidgetHiddenKey(widget.title!), + defaultValue: false, + ); + } + + void _onActionButtonPressed(HideWidgetStatusBloc model) async { + if (_passwordController.text.isNotEmpty && + _actionButtonKey.currentState!.btnState == ButtonState.idle) { + try { + _actionButtonKey.currentState!.animateForward(); + await model.checkPassAndMarkWidgetWithHiddenValue( + widget.title!, + _passwordController.text, + _hideWidgetInfo!, + ); + } catch (_) { + } finally { + _actionButtonKey.currentState?.animateReverse(); + } + } + } + + @override + void dispose() { + _passwordController.dispose(); + super.dispose(); + } +} diff --git a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart index e8016d46..09c09da6 100644 --- a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart +++ b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:layout/layout.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class DashboardTabChild extends StatefulWidget { @@ -63,7 +64,7 @@ class _DashboardTabChildState extends State { height: kStaggeredNumOfColumns / 8, ), const FluidCell( - child: DelegationStats(), + child: DelegationCard(), height: kStaggeredNumOfColumns / 8, ), const FluidCell( From 6c81122e5261cf18cd82747f85f420753e959f1e Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Fri, 11 Oct 2024 18:13:44 +0300 Subject: [PATCH 007/102] feat: Use a CardData object to hold the title and description of a card --- .../delegation/view/delegation_card.dart | 11 ++----- lib/utils/card/card.dart | 2 ++ lib/utils/card/card_data.dart | 6 ++++ lib/utils/card/card_type.dart | 16 ++++++++++ lib/utils/utils.dart | 1 + .../card_scaffold_without_listener.dart | 30 +++++++++---------- 6 files changed, 43 insertions(+), 23 deletions(-) create mode 100644 lib/utils/card/card.dart create mode 100644 lib/utils/card/card_data.dart create mode 100644 lib/utils/card/card_type.dart diff --git a/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart b/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart index 98f90e0f..e532e7d8 100644 --- a/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart +++ b/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart @@ -2,14 +2,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/card/card.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; - -const String _kWidgetTitle = 'Delegation Stats'; -final String _kWidgetDescription = 'This card displays the amount of ' - '${kZnnCoin.symbol} and the name of the Pillar that you delegated to'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class DelegationCard extends StatelessWidget { const DelegationCard({super.key}); @@ -27,8 +23,7 @@ class DelegationCard extends StatelessWidget { return cubit; }, child: CardScaffoldWithoutListener( - description: _kWidgetDescription, - title: _kWidgetTitle, + type: CardType.delegationStats, child: BlocBuilder( builder: (context, state) { return switch (state.status) { diff --git a/lib/utils/card/card.dart b/lib/utils/card/card.dart new file mode 100644 index 00000000..0b6649b0 --- /dev/null +++ b/lib/utils/card/card.dart @@ -0,0 +1,2 @@ +export 'card_data.dart'; +export 'card_type.dart'; \ No newline at end of file diff --git a/lib/utils/card/card_data.dart b/lib/utils/card/card_data.dart new file mode 100644 index 00000000..3239ca3e --- /dev/null +++ b/lib/utils/card/card_data.dart @@ -0,0 +1,6 @@ +class CardData { + final String title; + final String description; + + CardData({required this.title, required this.description}); +} \ No newline at end of file diff --git a/lib/utils/card/card_type.dart b/lib/utils/card/card_type.dart new file mode 100644 index 00000000..81a39623 --- /dev/null +++ b/lib/utils/card/card_type.dart @@ -0,0 +1,16 @@ +import 'package:zenon_syrius_wallet_flutter/utils/card/card_data.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; + +enum CardType { + delegationStats; + + CardData get data { + return switch (this) { + CardType.delegationStats => CardData( + title: 'Delegation Stats', + description: 'This card displays the amount of ${kZnnCoin.symbol} ' + 'and the name of the Pillar that you delegated to', + ), + }; + } +} diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 1a696982..dd17d967 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -2,6 +2,7 @@ export 'account_block_utils.dart'; export 'address_utils.dart'; export 'app_colors.dart'; export 'app_theme.dart'; +export 'card/card.dart'; export 'clipboard_utils.dart'; export 'color_utils.dart'; export 'constants.dart'; diff --git a/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart b/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart index bde9b50f..0c4d6e83 100644 --- a/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart +++ b/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart @@ -6,20 +6,17 @@ import 'package:lottie/lottie.dart'; import 'package:stacked/stacked.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/widget_utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; class CardScaffoldWithoutListener extends StatefulWidget { final Widget child; - final String? title; - final String description; + final CardType type; final VoidCallback? onRefreshPressed; const CardScaffoldWithoutListener({ required this.child, - required this.title, - required this.description, + required this.type, this.onRefreshPressed, super.key, }); @@ -41,10 +38,13 @@ class _CardScaffoldWithoutListenerState extends State widget.type.data.title; + String get _description => widget.type.data.description; + @override void initState() { super.initState(); - _hideWidgetInfo = _getWidgetHiddenInfoValue(widget.title); + _hideWidgetInfo = _getWidgetHiddenInfoValue(_title); } @override @@ -64,7 +64,7 @@ class _CardScaffoldWithoutListenerState extends State[ - _getWidgetHeader(widget.title!), + _getWidgetHeader(_title), const Divider(), Expanded( child: Material( @@ -85,7 +85,7 @@ class _CardScaffoldWithoutListenerState extends State[ - _getWidgetHeader(widget.title!), + _getWidgetHeader(_title), const Divider(), Expanded( child: _getHideWidgetInfoViewModel(), @@ -136,7 +136,7 @@ class _CardScaffoldWithoutListenerState extends State Date: Sat, 12 Oct 2024 10:49:40 +0300 Subject: [PATCH 008/102] feat: Fill up the balance widgets --- .../balance/cubit/balance_cubit.dart | 54 +++------ .../balance/cubit/balance_state.dart | 8 +- .../dashboard/balance/view/balance_card.dart | 34 +++--- .../balance/widgets/balance_address.dart | 82 +++++++++++++ .../balance/widgets/balance_chart.dart | 75 ++++++++++++ .../balance/widgets/balance_chart_legend.dart | 57 +++++++++ .../balance/widgets/balance_empty.dart | 4 +- .../balance/widgets/balance_error.dart | 3 +- .../balance/widgets/balance_loading.dart | 3 +- .../balance/widgets/balance_populated.dart | 109 +++++++++++++++++- .../dashboard/balance/widgets/widgets.dart | 3 + lib/utils/card/card_type.dart | 12 +- .../dashboard_tab_child.dart | 2 +- 13 files changed, 377 insertions(+), 69 deletions(-) create mode 100644 lib/rearchitecture/dashboard/balance/widgets/balance_address.dart create mode 100644 lib/rearchitecture/dashboard/balance/widgets/balance_chart.dart create mode 100644 lib/rearchitecture/dashboard/balance/widgets/balance_chart_legend.dart diff --git a/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart b/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart index df145180..cf218332 100644 --- a/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart +++ b/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart @@ -1,6 +1,5 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -11,54 +10,33 @@ part 'balance_state.dart'; /// of multiple addresses. It extends the `DashboardCubit` with a state /// represented as a `Map` of addresses and their associated `AccountInfo`. -class BalanceCubit extends DashboardCubit> { +class BalanceCubit extends DashboardCubit { + + final Address address; /// Constructs a `BalanceCubit` with the provided `zenon` client and initial state. /// /// The [zenon] parameter provides access to the Zenon SDK for interacting with /// account information, and the [initialState] is a map of addresses to their /// respective balances at the time the cubit is initialized. - BalanceCubit(super.zenon, super.initialState); - - /// Fetches the balance information for a list of predefined addresses. - /// - /// This method retrieves the account information for each address in the - /// `kDefaultAddressList`, and stores it in a map where the key is the - /// address string, and the value is the `AccountInfo` for that address. - /// - /// If an error occurs during the fetch operation, it will be propagated upwards. - /// - /// Returns a [Map] where each key is an address and the corresponding value is - /// an [AccountInfo] object for that address. - @override - Future> fetch() async { - try { - final Map addressBalanceMap = {}; - final List accountInfoList = await Future.wait( - kDefaultAddressList.map( - (address) => _getBalancePerAddress(address!), - ), - ); + BalanceCubit(this.address, super.zenon, super.initialState); - for (var accountInfo in accountInfoList) { - addressBalanceMap[accountInfo.address!] = accountInfo; - } - - return addressBalanceMap; - } catch (e) { - rethrow; - } - } - - /// Retrieves the balance information for a single address. + /// Fetches the balance information for a single address. /// /// The method interacts with the `zenon` client's ledger to get the - /// `AccountInfo` for the provided [address]. The address is parsed from - /// a string into an `Address` object before querying the ledger. + /// `AccountInfo` for the provided [address]. /// /// Returns an [AccountInfo] object containing the balance details for the given address. /// /// Throws an exception if the balance retrieval fails. - Future _getBalancePerAddress(String address) async { - return await zenon.ledger.getAccountInfoByAddress(Address.parse(address)); + @override + Future fetch() async { + AccountInfo response = await zenon.ledger + .getAccountInfoByAddress(address); + if (response.blockCount! > 0 && + (response.znn()! > BigInt.zero || response.qsr()! > BigInt.zero)) { + return response; + } else { + throw 'Empty balance on the selected address'; + } } } diff --git a/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart b/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart index 517dc1f2..0b9140c4 100644 --- a/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart +++ b/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart @@ -4,12 +4,12 @@ part of 'balance_cubit.dart'; /// /// `BalanceState` holds a map of account addresses to their corresponding `AccountInfo` objects. /// This state is used by the `BalanceCubit` to track the balance information for multiple addresses. -class BalanceState extends DashboardState> { +class BalanceState extends DashboardState { /// Constructs a new `BalanceState`. /// /// This state uses the default `status`, `data`, and `error` from the parent `DashboardState` class /// and initializes them for managing balance data. - BalanceState({ + const BalanceState({ super.status, super.data, super.error, @@ -23,9 +23,9 @@ class BalanceState extends DashboardState> { /// Returns: /// - A new instance of `BalanceState` with the updated values or the existing ones if none are provided. @override - DashboardState> copyWith({ + DashboardState copyWith({ CubitStatus? status, - Map? data, + AccountInfo? data, Object? error, }) { return BalanceState( diff --git a/lib/rearchitecture/dashboard/balance/view/balance_card.dart b/lib/rearchitecture/dashboard/balance/view/balance_card.dart index f28caf24..3ff81ca4 100644 --- a/lib/rearchitecture/dashboard/balance/view/balance_card.dart +++ b/lib/rearchitecture/dashboard/balance/view/balance_card.dart @@ -1,10 +1,11 @@ - import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; - - +import 'package:zenon_syrius_wallet_flutter/utils/card/card.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// A `BalanceCard` widget that displays balance information for a user. /// @@ -26,34 +27,37 @@ class BalanceCard extends StatelessWidget { // and an initial `BalanceState`. The cubit immediately begins fetching // balance data by calling `fetch()`. final BalanceCubit cubit = BalanceCubit( - zenon!, - BalanceState() + Address.parse(kSelectedAddress!), + zenon!, + BalanceState(), ); cubit.fetchDataPeriodically(); return cubit; }, - child: Scaffold( - body: BlocBuilder( + child: CardScaffoldWithoutListener( + type: CardType.balance, + child: BlocBuilder( builder: (context, state) { // Uses a `switch` statement to display different widgets based on // the current cubit state. The state is managed by the `BalanceCubit` and // is derived from `DashboardState`, with different widgets rendered for each status. return switch (state.status) { - // Displays an empty balance view when the cubit is in its initial state. + // Displays an empty balance view when the cubit is in its initial state. CubitStatus.initial => const BalanceEmpty(), - // Shows a loading indicator while the cubit is fetching balance data. + // Shows a loading indicator while the cubit is fetching balance data. CubitStatus.loading => const BalanceLoading(), - // Displays an error message if fetching balance data fails. + // Displays an error message if fetching balance data fails. CubitStatus.failure => BalanceError( - error: state.error!, - ), + error: state.error!, + ), - // Shows the populated balance data when it is successfully fetched. + // Shows the populated balance data when it is successfully fetched. CubitStatus.success => BalancePopulated( - data: state.data!, - ), + address: kSelectedAddress!, + accountInfo: state.data!, + ), }; }, ), diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_address.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_address.dart new file mode 100644 index 00000000..fc57ae8b --- /dev/null +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_address.dart @@ -0,0 +1,82 @@ +import 'package:auto_size_text/auto_size_text.dart'; +import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; + +/// A stateless widget that takes in a [ValueNotifier] that holds a color +/// which will be used to highlight the prefix and the suffix of the [address] +/// +/// Inside the widget tree there is a [FocusableActionDetector] that knows +/// when the mouse hovers over the [Text] widget that displays the [address] +/// and changes the value of the [edgesColorNotifier] + +class BalanceAddress extends StatelessWidget { + final String address; + final ValueNotifier edgesColorNotifier; + + const BalanceAddress({ + required this.address, + required this.edgesColorNotifier, + super.key, + }); + + @override + Widget build(BuildContext context) { + return ValueListenableBuilder( + valueListenable: edgesColorNotifier, + builder: (_, Color? edgesColor, __) { + return FocusableActionDetector( + onShowHoverHighlight: (x) { + if (x) { + edgesColorNotifier.value = AppColors.znnColor; + } else { + edgesColorNotifier.value = Theme.of(context).hintColor; + } + }, + child: Container( + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surface, + border: Border.all(color: Theme.of(context).colorScheme.surface), + borderRadius: BorderRadius.circular(15.0), + ), + padding: const EdgeInsets.symmetric( + vertical: 4.0, + horizontal: 8.0, + ), + margin: const EdgeInsets.only( + bottom: 12.0, + top: 12.0, + ), + child: AutoSizeText.rich( + TextSpan( + children: [ + TextSpan( + text: address.substring(0, 3), + style: TextStyle(color: edgesColor), + ), + TextSpan( + text: address.substring( + 3, + address.length - 6, + ), + style: TextStyle( + color: Theme.of(context).hintColor, + ), + ), + TextSpan( + text: address.substring( + address.length - 6, + address.length, + ), + style: TextStyle( + color: edgesColor, + ), + ), + ], + ), + ), + ), + ); + }, + ); + } +} diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_chart.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_chart.dart new file mode 100644 index 00000000..b497d192 --- /dev/null +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_chart.dart @@ -0,0 +1,75 @@ +import 'package:fl_chart/fl_chart.dart'; +import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/chart/standard_pie_chart.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +/// A customized [StandardPieChart] that shows the balance in ZNN and QSR hold +/// be the user on a certain address +/// +/// Hovering over the sections of the chart will trigger the balance - in a +/// readable format - to appear in the center of the chart + +class BalanceChart extends StatelessWidget { + final AccountInfo accountInfo; + final ValueNotifier touchedSectionId; + + const BalanceChart({ + required this.accountInfo, + required this.touchedSectionId, + super.key, + }); + + @override + Widget build(BuildContext context) { + return StandardPieChart( + sectionsSpace: 0.0, + sections: _getChartSection(accountInfo), + onChartSectionTouched: (pieChartSection) { + touchedSectionId.value = pieChartSection?.touchedSection?.title; + }, + ); + } + + List _getChartSection(AccountInfo accountInfo) { + List sections = []; + if (accountInfo.znn()! > BigInt.zero) { + sections.add( + _getBalanceChartSection( + accountInfo.findTokenByTokenStandard(kZnnCoin.tokenStandard)!, + accountInfo, + ), + ); + } + if (accountInfo.qsr()! > BigInt.zero) { + sections.add( + _getBalanceChartSection( + accountInfo.findTokenByTokenStandard(kQsrCoin.tokenStandard)!, + accountInfo, + ), + ); + } + + return sections; + } + + PieChartSectionData _getBalanceChartSection( + Token token, + AccountInfo accountInfo, + ) { + final isTouched = + token.tokenStandard.toString() == touchedSectionId.value; + final double opacity = isTouched ? 1.0 : 0.7; + + double value = accountInfo.getBalance(token.tokenStandard) / + (accountInfo.znn()! + accountInfo.qsr()!); + + return PieChartSectionData( + title: token.tokenStandard.toString(), + showTitle: false, + radius: 7.0, + color: ColorUtils.getTokenColor(token.tokenStandard).withOpacity(opacity), + value: value, + ); + } +} diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_chart_legend.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_chart_legend.dart new file mode 100644 index 00000000..8427d6ad --- /dev/null +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_chart_legend.dart @@ -0,0 +1,57 @@ +import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/balance/widgets/balance_chart.dart'; + +/// Adds a legend to the [BalanceChart] consisting of widgets with a tooltip +/// than will show the exact balance - including decimals - available in a +/// certain coin (QSR or ZNN) + +class BalanceChartLegend extends StatelessWidget { + final AccountInfo accountInfo; + + const BalanceChartLegend({required this.accountInfo, super.key}); + + @override + Widget build(BuildContext context) { + return Row( + children: [ + Expanded( + child: _getCoinBalanceInfo( + accountInfo: accountInfo, + coin: kZnnCoin, + context: context, + ), + ), + Expanded( + child: _getCoinBalanceInfo( + accountInfo: accountInfo, + coin: kQsrCoin, + context: context, + ), + ), + ], + ); + } + + FormattedAmountWithTooltip _getCoinBalanceInfo({ + required Token coin, + required AccountInfo accountInfo, + required BuildContext context, + }) { + return FormattedAmountWithTooltip( + amount: accountInfo + .getBalance( + coin.tokenStandard, + ) + .addDecimals(coin.decimals), + tokenSymbol: coin.symbol, + builder: (amount, tokenSymbol) => AmountInfoColumn( + context: context, + amount: amount, + tokenSymbol: tokenSymbol, + ), + ); + } +} diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart index 1b1f457d..b8c1d5ff 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A `BalanceEmpty` widget that displays a simple message indicating that there /// is no balance data available. @@ -10,7 +11,6 @@ class BalanceEmpty extends StatelessWidget { @override Widget build(BuildContext context) { - // Returns a simple `Text` widget displaying the message 'empty'. - return const Text('empty'); + return SyriusErrorWidget('No data available'); } } diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_error.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_error.dart index 89f98754..82405c8e 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_error.dart +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_error.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; /// A `BalanceError` widget that displays an error message when the balance /// data fetching fails. @@ -12,6 +13,6 @@ class BalanceError extends StatelessWidget { @override Widget build(BuildContext context) { - return Text(error.toString()); + return SyriusErrorWidget(error); } } diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_loading.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_loading.dart index 62f226f7..2a2da414 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_loading.dart +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_loading.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; /// A `BalanceLoading` widget that displays a loading message while the balance /// data is being fetched. @@ -10,6 +11,6 @@ class BalanceLoading extends StatelessWidget { @override Widget build(BuildContext context) { - return const Text('loading'); + return SyriusLoadingWidget(); } } diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_populated.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_populated.dart index 92f747f5..9d59c228 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_populated.dart +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_populated.dart @@ -1,4 +1,7 @@ +import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/balance/balance.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// A `BalancePopulated` widget that displays balance data once it has been @@ -6,17 +9,115 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// /// This widget is displayed when the `BalanceCubit` is in the `success` state, /// and the balance data is available for rendering. -class BalancePopulated extends StatelessWidget { +class BalancePopulated extends StatefulWidget { /// The balance data that has been successfully fetched. /// /// The data is a map where the key is a string (representing the account address), /// and the value is an `AccountInfo` object containing the balance details. - final Map? data; + final AccountInfo accountInfo; - const BalancePopulated({required this.data, super.key}); + /// The address for which the [accountInfo] was retrieved. + final String address; + + const BalancePopulated({ + required this.address, + required this.accountInfo, + super.key, + }); + + @override + State createState() => _BalancePopulatedState(); +} + +class _BalancePopulatedState extends State { + final ValueNotifier _touchedSectionId = ValueNotifier(null); + late final ValueNotifier _addressEdgesColor; + + @override + void didChangeDependencies() { + super.didChangeDependencies(); + _addressEdgesColor = ValueNotifier(Theme.of(context).hintColor); + } @override Widget build(BuildContext context) { - return Text(data.toString()); + return Column( + children: [ + kVerticalSpacing, + Expanded( + child: AspectRatio( + aspectRatio: 1.0, + child: LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { + return Stack( + alignment: Alignment.center, + children: [ + BalanceChart( + accountInfo: widget.accountInfo, + touchedSectionId: _touchedSectionId, + ), + ValueListenableBuilder( + valueListenable: _touchedSectionId, + builder: (_, String? id, __) { + final Widget center = id != null + ? _getBalance( + accountInfo: widget.accountInfo, + constraints: constraints, + tokenStandard: + TokenStandard.parse(_touchedSectionId.value!), + ) + : SizedBox.shrink(); + + return center; + }, + ), + ], + ); + }), + ), + ), + BalanceAddress( + address: widget.address, + edgesColorNotifier: _addressEdgesColor, + ), + const Divider(), + Padding( + padding: const EdgeInsets.all(8.0), + child: BalanceChartLegend(accountInfo: widget.accountInfo), + ), + ], + ); + } + + Widget _getBalance({ + required AccountInfo accountInfo, + required BoxConstraints constraints, + required TokenStandard tokenStandard, + }) { + final String amount = accountInfo + .getBalance( + tokenStandard, + ) + .addDecimals(coinDecimals); + + final String symbol = tokenStandard == kZnnCoin.tokenStandard + ? kZnnCoin.symbol + : kQsrCoin.symbol; + + final double margin = constraints.maxWidth * 0.3; + + final double width = constraints.maxWidth - margin; + + return SizedBox( + width: width, + child: AutoSizeText( + '$amount $symbol', + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.headlineMedium!.copyWith( + color: ColorUtils.getTokenColor(tokenStandard), + fontWeight: FontWeight.bold, + ), + ), + ); } } diff --git a/lib/rearchitecture/dashboard/balance/widgets/widgets.dart b/lib/rearchitecture/dashboard/balance/widgets/widgets.dart index 90494925..687296c4 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/widgets.dart +++ b/lib/rearchitecture/dashboard/balance/widgets/widgets.dart @@ -1,3 +1,6 @@ +export 'balance_address.dart'; +export 'balance_chart.dart'; +export 'balance_chart_legend.dart'; export 'balance_empty.dart'; export 'balance_error.dart'; export 'balance_loading.dart'; diff --git a/lib/utils/card/card_type.dart b/lib/utils/card/card_type.dart index 81a39623..38b86f4d 100644 --- a/lib/utils/card/card_type.dart +++ b/lib/utils/card/card_type.dart @@ -2,14 +2,20 @@ import 'package:zenon_syrius_wallet_flutter/utils/card/card_data.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; enum CardType { + balance, delegationStats; CardData get data { return switch (this) { + CardType.balance => CardData( + title: 'Delegation Stats', + description: 'This card displays the amount of ${kZnnCoin.symbol} ' + 'and the name of the Pillar that you delegated to', + ), CardType.delegationStats => CardData( - title: 'Delegation Stats', - description: 'This card displays the amount of ${kZnnCoin.symbol} ' - 'and the name of the Pillar that you delegated to', + title: 'Balance', + description: 'This card displays the current ${kZnnCoin.symbol} ' + 'and ${kQsrCoin.symbol} amounts for the selected address', ), }; } diff --git a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart index 09c09da6..ef38adc8 100644 --- a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart +++ b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart @@ -72,7 +72,7 @@ class _DashboardTabChildState extends State { height: kStaggeredNumOfColumns / 8, ), FluidCell( - child: const BalanceWidget(), + child: const BalanceCard(), width: defaultCellWidth * 2, ), FluidCell( From bd8b12cacc6ff8343fc4c6ded12b47cef50c02d9 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Sat, 12 Oct 2024 16:13:58 +0300 Subject: [PATCH 009/102] fix: Assign the correct card data to the CardType.balance value --- lib/utils/card/card_type.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/utils/card/card_type.dart b/lib/utils/card/card_type.dart index 38b86f4d..c3f6167a 100644 --- a/lib/utils/card/card_type.dart +++ b/lib/utils/card/card_type.dart @@ -8,15 +8,15 @@ enum CardType { CardData get data { return switch (this) { CardType.balance => CardData( + title: 'Balance', + description: 'This card displays the current ${kZnnCoin.symbol} ' + 'and ${kQsrCoin.symbol} amounts for the selected address', + ), + CardType.delegationStats => CardData( title: 'Delegation Stats', description: 'This card displays the amount of ${kZnnCoin.symbol} ' 'and the name of the Pillar that you delegated to', ), - CardType.delegationStats => CardData( - title: 'Balance', - description: 'This card displays the current ${kZnnCoin.symbol} ' - 'and ${kQsrCoin.symbol} amounts for the selected address', - ), }; } } From 5930b56c065992d72567b4731b67be88fc888b13 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Sat, 12 Oct 2024 16:16:42 +0300 Subject: [PATCH 010/102] feat: Improve the DashboardCubit so that the cubits that implement it can specify the state --- .../dashboard/balance/cubit/balance_cubit.dart | 2 +- .../dashboard/balance/view/balance_card.dart | 2 +- .../cubit/balance_dashboard_cubit.dart | 2 +- lib/rearchitecture/dashboard/dashboard_cubit.dart | 13 ++++++++----- .../delegation/cubit/delegation_cubit.dart | 2 +- .../dashboard/delegation/view/delegation_card.dart | 2 +- .../cubit/dual_coin_stats_cubit.dart | 2 +- .../dashboard/pillars/cubit/pillars_cubit.dart | 2 +- .../cubit/realtime_statistics_cubit.dart | 2 +- .../dashboard/sentinels/cubit/sentinels_cubit.dart | 2 +- .../dashboard/staking/cubit/staking_cubit.dart | 2 +- .../cubit/total_hourly_transactions_cubit.dart | 14 +++++++------- 12 files changed, 25 insertions(+), 22 deletions(-) diff --git a/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart b/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart index cf218332..982e5ec6 100644 --- a/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart +++ b/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart @@ -10,7 +10,7 @@ part 'balance_state.dart'; /// of multiple addresses. It extends the `DashboardCubit` with a state /// represented as a `Map` of addresses and their associated `AccountInfo`. -class BalanceCubit extends DashboardCubit { +class BalanceCubit extends DashboardCubit { final Address address; /// Constructs a `BalanceCubit` with the provided `zenon` client and initial state. diff --git a/lib/rearchitecture/dashboard/balance/view/balance_card.dart b/lib/rearchitecture/dashboard/balance/view/balance_card.dart index 3ff81ca4..543ec49e 100644 --- a/lib/rearchitecture/dashboard/balance/view/balance_card.dart +++ b/lib/rearchitecture/dashboard/balance/view/balance_card.dart @@ -36,7 +36,7 @@ class BalanceCard extends StatelessWidget { }, child: CardScaffoldWithoutListener( type: CardType.balance, - child: BlocBuilder( + child: BlocBuilder( builder: (context, state) { // Uses a `switch` statement to display different widgets based on // the current cubit state. The state is managed by the `BalanceCubit` and diff --git a/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_cubit.dart b/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_cubit.dart index 2266e192..6c19ce7e 100644 --- a/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_cubit.dart +++ b/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_cubit.dart @@ -9,7 +9,7 @@ part 'balance_dashboard_state.dart'; /// This cubit extends `DashboardCubit`, utilizing the `AccountInfo` data type to store /// and manage the balance data for a specific account (identified by `kDemoAddress`). /// It provides the logic for fetching and updating the balance. -class BalanceDashboardCubit extends DashboardCubit { +class BalanceDashboardCubit extends DashboardCubit { /// Constructs a `BalanceDashboardCubit`, passing the `zenon` client and the initial state to the parent class. /// /// The `zenon` client is used to interact with the Zenon ledger to retrieve account information. diff --git a/lib/rearchitecture/dashboard/dashboard_cubit.dart b/lib/rearchitecture/dashboard/dashboard_cubit.dart index b2897cc9..ecf64248 100644 --- a/lib/rearchitecture/dashboard/dashboard_cubit.dart +++ b/lib/rearchitecture/dashboard/dashboard_cubit.dart @@ -11,7 +11,10 @@ part 'dashboard_state.dart'; /// success, or failure, and it periodically refreshes the data automatically. /// /// The generic type [T] represents the type of data managed by this cubit. -abstract class DashboardCubit extends Cubit> { +/// +/// The generic type [S] represents the type of the states emitted by the cubit. +/// [S] extends [DashboardState] +abstract class DashboardCubit> extends Cubit { /// A timer that handles the auto-refreshing of data. Timer? _autoRefresher; @@ -56,15 +59,15 @@ abstract class DashboardCubit extends Cubit> { /// If the WebSocket client is closed, it throws a [noConnectionException]. Future fetchDataPeriodically() async { try { - emit(state.copyWith(status: CubitStatus.loading)); + emit(state.copyWith(status: CubitStatus.loading) as S); if (!zenon.wsClient.isClosed()) { - final T? data = await fetch(); - emit(state.copyWith(data: data, status: CubitStatus.success)); + final T data = await fetch(); + emit(state.copyWith(data: data, status: CubitStatus.success) as S); } else { throw noConnectionException; } } catch (e) { - emit(state.copyWith(status: CubitStatus.failure, error: e)); + emit(state.copyWith(status: CubitStatus.failure, error: e) as S); } finally { /// Ensure that the auto-refresher is restarted if it's not active. if (!isTimerActive) { diff --git a/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart b/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart index 356b2860..d03aa314 100644 --- a/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart +++ b/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart @@ -8,7 +8,7 @@ part 'delegation_state.dart'; /// /// This cubit extends `DashboardCubit`, using the `DelegationInfo` data type /// to store and manage delegation stats for the account identified by `kDemoAddress`. -class DelegationCubit extends DashboardCubit { +class DelegationCubit extends DashboardCubit { final Address address; /// Constructs a `DelegationCubit`, passing the `zenon` client and the initial state diff --git a/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart b/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart index e532e7d8..79bbcc59 100644 --- a/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart +++ b/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart @@ -24,7 +24,7 @@ class DelegationCard extends StatelessWidget { }, child: CardScaffoldWithoutListener( type: CardType.delegationStats, - child: BlocBuilder( + child: BlocBuilder( builder: (context, state) { return switch (state.status) { CubitStatus.initial => const DelegationEmpty(), diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart index 0bc3dc59..afa6fbf7 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart @@ -8,7 +8,7 @@ part 'dual_coin_stats_state.dart'; /// /// This cubit extends `DashboardCubit>`, using a list of `Token` objects to /// represent the statistics for the ZNN and QSR tokens fetched from the Zenon network. -class DualCoinStatsCubit extends DashboardCubit> { +class DualCoinStatsCubit extends DashboardCubit, DualCoinStatsState> { /// Constructs a `DualCoinStatsCubit`, passing the `zenon` client and the initial state /// to the parent class. /// diff --git a/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart b/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart index f97a3c3e..2cdece33 100644 --- a/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart +++ b/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart @@ -7,7 +7,7 @@ part 'pillars_state.dart'; /// /// This cubit extends `DashboardCubit`, using an integer to represent the /// total number of pillars fetched from the Zenon network. -class PillarsCubit extends DashboardCubit { +class PillarsCubit extends DashboardCubit { /// Constructs a `PillarsCubit`, passing the `zenon` client and the initial state /// to the parent class. /// diff --git a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart index 48767f8f..a6abb70f 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart @@ -10,7 +10,7 @@ part 'realtime_statistics_state.dart'; /// /// This cubit extends `DashboardCubit>`, using a list of /// `AccountBlock` objects to represent the account blocks fetched from the Zenon network. -class RealtimeStatisticsCubit extends DashboardCubit> { +class RealtimeStatisticsCubit extends DashboardCubit, RealtimeStatisticsState> { /// Constructs a `RealtimeStatisticsCubit`, passing the `zenon` client and the initial state /// to the parent class. /// diff --git a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart index 78c4a9e5..14d50c00 100644 --- a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart +++ b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart @@ -8,7 +8,7 @@ part 'sentinels_state.dart'; /// /// This cubit extends `DashboardCubit`, using a `SentinelInfoList` /// object to represent the list of active sentinels fetched from the Zenon network. -class SentinelsCubit extends DashboardCubit { +class SentinelsCubit extends DashboardCubit { /// Constructs a `SentinelsCubit`, passing the `zenon` client and the initial state /// to the parent class. /// diff --git a/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart b/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart index 5e5df0a9..64dc9dfe 100644 --- a/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart +++ b/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart @@ -8,7 +8,7 @@ part 'staking_state.dart'; /// /// This cubit extends `DashboardCubit`, using a `StakeList` object /// to represent the list of staking entries for a specific address fetched from the Zenon network. -class StakingCubit extends DashboardCubit { +class StakingCubit extends DashboardCubit { /// Constructs a `StakingCubit`, passing the `zenon` client and the initial state /// to the parent class. /// diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart index 8c507f72..5102a171 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart @@ -8,7 +8,8 @@ part 'total_hourly_transactions_state.dart'; /// /// This cubit extends `DashboardCubit>`, using a map to represent the total /// number of account blocks and the corresponding timestamp fetched from the Zenon network. -class TotalHourlyTransactionsCubit extends DashboardCubit> { +class TotalHourlyTransactionsCubit + extends DashboardCubit, TotalHourlyTransactionsState> { /// Constructs a `TotalHourlyTransactionsCubit`, passing the `zenon` client and the initial state /// to the parent class. /// @@ -33,18 +34,17 @@ class TotalHourlyTransactionsCubit extends DashboardCubit> // Fetch detailed momentums for the past hour final List response = (await zenon.ledger.getDetailedMomentumsByHeight( - chainHeight - kMomentumsPerHour, - kMomentumsPerHour, - )) - .list ?? + chainHeight - kMomentumsPerHour, + kMomentumsPerHour, + )) + .list ?? []; // Prepare the transaction summary final Map transactions = { 'numAccountBlocks': response.fold( 0, - (previousValue, element) => - previousValue + element.blocks.length, + (previousValue, element) => previousValue + element.blocks.length, ), 'timestamp': DateTime.now().millisecondsSinceEpoch, }; From 5c57c1fb6aed5af07d8364182d7e2c1b662a9bc5 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:20:53 +0300 Subject: [PATCH 011/102] feat: Fill up the dual coin stats widgets --- .../dashboard/balance/view/balance_card.dart | 2 +- .../delegation/view/delegation_card.dart | 2 +- .../cubit/dual_coin_stats_cubit.dart | 13 +++- .../cubit/dual_coin_stats_state.dart | 8 +- .../view/dual_coin_stats_card.dart | 9 ++- .../widgets/dual_coin_stats_chart.dart | 74 +++++++++++++++++++ .../widgets/dual_coin_stats_chart_legend.dart | 38 ++++++++++ .../dual_coin_stats_chart_legend_item.dart | 25 +++++++ .../widgets/dual_coin_stats_empty.dart | 7 +- .../widgets/dual_coin_stats_error.dart | 8 +- .../widgets/dual_coin_stats_loading.dart | 8 +- .../widgets/dual_coin_stats_populated.dart | 40 +++++++++- .../dual_coin_stats/widgets/widgets.dart | 3 + lib/utils/card/card_type.dart | 24 +++--- .../card_scaffold_without_listener.dart | 6 +- .../dashboard_tab_child.dart | 2 +- 16 files changed, 236 insertions(+), 33 deletions(-) create mode 100644 lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart.dart create mode 100644 lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart create mode 100644 lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend_item.dart diff --git a/lib/rearchitecture/dashboard/balance/view/balance_card.dart b/lib/rearchitecture/dashboard/balance/view/balance_card.dart index 543ec49e..bfb11048 100644 --- a/lib/rearchitecture/dashboard/balance/view/balance_card.dart +++ b/lib/rearchitecture/dashboard/balance/view/balance_card.dart @@ -36,7 +36,7 @@ class BalanceCard extends StatelessWidget { }, child: CardScaffoldWithoutListener( type: CardType.balance, - child: BlocBuilder( + body: BlocBuilder( builder: (context, state) { // Uses a `switch` statement to display different widgets based on // the current cubit state. The state is managed by the `BalanceCubit` and diff --git a/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart b/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart index 79bbcc59..b36f0c18 100644 --- a/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart +++ b/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart @@ -24,7 +24,7 @@ class DelegationCard extends StatelessWidget { }, child: CardScaffoldWithoutListener( type: CardType.delegationStats, - child: BlocBuilder( + body: BlocBuilder( builder: (context, state) { return switch (state.status) { CubitStatus.initial => const DelegationEmpty(), diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart index afa6fbf7..84268953 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart @@ -6,9 +6,9 @@ part 'dual_coin_stats_state.dart'; /// `DualCoinStatsCubit` manages the fetching and state of dual coin statistics /// for ZNN and QSR tokens. /// -/// This cubit extends `DashboardCubit>`, using a list of `Token` objects to +/// This cubit extends [DashboardCubit], using a list of `Token` objects to /// represent the statistics for the ZNN and QSR tokens fetched from the Zenon network. -class DualCoinStatsCubit extends DashboardCubit, DualCoinStatsState> { +class DualCoinStatsCubit extends DashboardCubit, DualCoinStatsState> { /// Constructs a `DualCoinStatsCubit`, passing the `zenon` client and the initial state /// to the parent class. /// @@ -24,7 +24,7 @@ class DualCoinStatsCubit extends DashboardCubit, DualCoinStatsState /// Throws: /// - An error if any exception occurs during the fetching of token data. @override - Future> fetch() async { + Future> fetch() async { try { final List data = await Future.wait( [ @@ -36,7 +36,12 @@ class DualCoinStatsCubit extends DashboardCubit, DualCoinStatsState ), ], ); - return data; // Returns the list of fetched token data + + // For ZNN and QSR, the network will return non-nullable data + final List nonNullableData = data.map((token) => token!).toList(); + + // The list has only two elements + return nonNullableData; } catch (e) { rethrow; } diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart index 35a261fe..bae99b9c 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart @@ -4,12 +4,12 @@ part of 'dual_coin_stats_cubit.dart'; /// /// `DualCoinStatsState` stores a list of `Token?` objects representing data for two tokens. /// This state is used by the `DualCoinStatsCubit` to track and update the state of both tokens. -class DualCoinStatsState extends DashboardState> { +class DualCoinStatsState extends DashboardState> { /// Constructs a new `DualCoinStatsState`. /// /// This state is initialized with default `status`, `data`, and `error` values from the parent `DashboardState` class. /// It manages a list of `Token?` objects that represent the two tokens' data. - DualCoinStatsState({ + const DualCoinStatsState({ super.status, super.data, super.error, @@ -23,9 +23,9 @@ class DualCoinStatsState extends DashboardState> { /// Returns: /// - A new instance of `DualCoinStatsState` with the updated values or the existing ones if none are provided. @override - DashboardState> copyWith({ + DashboardState> copyWith({ CubitStatus? status, - List? data, + List? data, Object? error, }) { return DualCoinStatsState( diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart b/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart index 3e87999b..f7bf3486 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/card/card.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart'; class DualCoinStatsCard extends StatelessWidget { @@ -18,8 +20,9 @@ class DualCoinStatsCard extends StatelessWidget { cubit.fetchDataPeriodically(); return cubit; }, - child: Scaffold( - body: BlocBuilder( + child: CardScaffoldWithoutListener( + type: CardType.dualCoinStats, + body: BlocBuilder( builder: (context, state) { return switch (state.status) { CubitStatus.initial => const DualCoinStatsEmpty(), @@ -28,7 +31,7 @@ class DualCoinStatsCard extends StatelessWidget { error: state.error!, ), CubitStatus.success => DualCoinStatsPopulated( - data: state.data!, + tokens: state.data!, ), }; }, diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart.dart new file mode 100644 index 00000000..ca1b23fc --- /dev/null +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart.dart @@ -0,0 +1,74 @@ +import 'package:fl_chart/fl_chart.dart'; +import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/chart/standard_pie_chart.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +/// Takes in a list of [Token] and shows a chart with sections corresponding to +/// the total supply of each [Token]. +/// +/// When the cursor hovers over a section, that respective section is +/// highlighted + +class DualCoinStatsChart extends StatelessWidget { + final List tokenList; + final ValueNotifier touchedSectionIndexNotifier; + + const DualCoinStatsChart({ + required this.tokenList, + required this.touchedSectionIndexNotifier, + super.key, + }); + + @override + Widget build(BuildContext context) { + return ValueListenableBuilder( + valueListenable: touchedSectionIndexNotifier, + builder: (_, int? index, ___) => AspectRatio( + aspectRatio: 1.0, + child: StandardPieChart( + sectionsSpace: 4.0, + centerSpaceRadius: 0.0, + sections: _showingSections( + context: context, + tokenList: tokenList, + touchedSectionIndex: index, + ), + onChartSectionTouched: (pieTouchedSection) { + touchedSectionIndexNotifier.value = + pieTouchedSection?.touchedSectionIndex; + }, + ), + ), + ); + } + + List _showingSections({ + required BuildContext context, + required List tokenList, + required int? touchedSectionIndex, + }) { + BigInt totalSupply = tokenList.fold( + BigInt.zero, + (previousValue, element) => previousValue + element.totalSupply, + ); + return List.generate( + tokenList.length, + (i) { + Token currentTokenInfo = tokenList[i]; + final isTouched = i == touchedSectionIndex; + final double opacity = isTouched ? 1.0 : 0.5; + return PieChartSectionData( + color: ColorUtils.getTokenColor(currentTokenInfo.tokenStandard) + .withOpacity(opacity), + value: currentTokenInfo.totalSupply / totalSupply, + title: currentTokenInfo.symbol, + radius: 60.0, + titleStyle: Theme.of(context).textTheme.titleSmall!.copyWith( + color: Colors.white, + ), + ); + }, + ); + } +} diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart new file mode 100644 index 00000000..281e665f --- /dev/null +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart @@ -0,0 +1,38 @@ +import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +/// A legend for [DualCoinStatsChartLegend] +/// +/// It shows the token symbol, the amount in a shortened format - it has a +/// tooltip for showing the exact amount, including the decimals + +class DualCoinStatsChartLegend extends StatelessWidget { + final List tokens; + + const DualCoinStatsChartLegend({ + required this.tokens, + super.key, + }); + + @override + Widget build(BuildContext context) { + final List items = List.generate( + tokens.length, + (index) { + final Token token = tokens[index]; + + return Expanded( + child: DualCoinStatsChartLegendItem( + token: token, + ), + ); + }, + ); + + return Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: items, + ); + } +} diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend_item.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend_item.dart new file mode 100644 index 00000000..0e663c2a --- /dev/null +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend_item.dart @@ -0,0 +1,25 @@ +import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +class DualCoinStatsChartLegendItem extends StatelessWidget { + final Token token; + + const DualCoinStatsChartLegendItem({required this.token, super.key}); + + @override + Widget build(BuildContext context) { + return FormattedAmountWithTooltip( + amount: token.totalSupply.addDecimals( + token.decimals, + ), + tokenSymbol: token.symbol, + builder: (amount, symbol) => AmountInfoColumn( + amount: amount, + tokenSymbol: symbol, + context: context, + ), + ); + } +} diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart index 90f9a6e8..e042ba86 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart @@ -1,10 +1,15 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; + +/// A widget associated with the [DualCoinStatsState] when it's status is +/// [CubitStatus.initial] that uses the [SyriusErrorWidget] to display a message class DualCoinStatsEmpty extends StatelessWidget { const DualCoinStatsEmpty({super.key}); @override Widget build(BuildContext context) { - return const Text('empty'); + return SyriusErrorWidget('No data available'); } } diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart index 5191195a..473a08bf 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart @@ -1,4 +1,10 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; + +/// A widget associated with the [DualCoinStatsState] when it's status is +/// [CubitStatus.failure] that uses the [SyriusErrorWidget] to display the +/// error message class DualCoinStatsError extends StatelessWidget { final Object error; @@ -7,6 +13,6 @@ class DualCoinStatsError extends StatelessWidget { @override Widget build(BuildContext context) { - return Text(error.toString()); + return SyriusErrorWidget(error); } } diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart index 7ab7ae55..742df2d5 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart @@ -1,10 +1,16 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; + +/// A widget associated with the [DualCoinStatsState] when it's status is +/// [CubitStatus.loading] that uses the [SyriusLoadingWidget] to display a +/// loading indicator class DualCoinStatsLoading extends StatelessWidget { const DualCoinStatsLoading({super.key}); @override Widget build(BuildContext context) { - return const Text('loading'); + return SyriusLoadingWidget(); } } diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart index 030912bd..894eb2b1 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart @@ -1,13 +1,45 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; -class DualCoinStatsPopulated extends StatelessWidget { - final List data; +/// A widget associated with the [DualCoinStatsState] when it's status is +/// [CubitStatus.success] that displays the data provided using a chart +/// - [DualCoinStatsChart] - and a legend - [DualCoinStatsChartLegend] - const DualCoinStatsPopulated({required this.data, super.key}); +class DualCoinStatsPopulated extends StatefulWidget { + final List tokens; + + const DualCoinStatsPopulated({ + required this.tokens, + super.key, + }); + + @override + State createState() => _DualCoinStatsPopulatedState(); +} + +class _DualCoinStatsPopulatedState extends State + with SingleTickerProviderStateMixin { + final ValueNotifier _touchedSectionIndexNotifier = ValueNotifier(null); @override Widget build(BuildContext context) { - return Text(data.toString()); + return Column( + children: [ + Expanded( + child: DualCoinStatsChart( + tokenList: widget.tokens, + touchedSectionIndexNotifier: _touchedSectionIndexNotifier, + ), + ), + const Divider(), + Padding( + padding: const EdgeInsets.all(8.0), + child: DualCoinStatsChartLegend( + tokens: widget.tokens, + ), + ), + ], + ); } } diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/widgets.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/widgets.dart index 29766997..d0927a23 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/widgets.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/widgets.dart @@ -1,3 +1,6 @@ +export 'dual_coin_stats_chart.dart'; +export 'dual_coin_stats_chart_legend.dart'; +export 'dual_coin_stats_chart_legend_item.dart'; export 'dual_coin_stats_empty.dart'; export 'dual_coin_stats_error.dart'; export 'dual_coin_stats_loading.dart'; diff --git a/lib/utils/card/card_type.dart b/lib/utils/card/card_type.dart index c3f6167a..23e378a8 100644 --- a/lib/utils/card/card_type.dart +++ b/lib/utils/card/card_type.dart @@ -3,20 +3,26 @@ import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; enum CardType { balance, - delegationStats; + delegationStats, + dualCoinStats; CardData get data { return switch (this) { CardType.balance => CardData( - title: 'Balance', - description: 'This card displays the current ${kZnnCoin.symbol} ' - 'and ${kQsrCoin.symbol} amounts for the selected address', - ), + title: 'Balance', + description: 'This card displays the current ${kZnnCoin.symbol} ' + 'and ${kQsrCoin.symbol} amounts for the selected address', + ), CardType.delegationStats => CardData( - title: 'Delegation Stats', - description: 'This card displays the amount of ${kZnnCoin.symbol} ' - 'and the name of the Pillar that you delegated to', - ), + title: 'Delegation Stats', + description: 'This card displays the amount of ${kZnnCoin.symbol} ' + 'and the name of the Pillar that you delegated to', + ), + CardType.dualCoinStats => CardData( + title: 'Dual Coin Stats', + description: 'This card displays the circulating ${kZnnCoin.symbol} ' + 'and ${kQsrCoin.symbol} supply from the network', + ), }; } } diff --git a/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart b/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart index 0c4d6e83..ae3be738 100644 --- a/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart +++ b/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart @@ -10,12 +10,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; class CardScaffoldWithoutListener extends StatefulWidget { - final Widget child; + final Widget body; final CardType type; final VoidCallback? onRefreshPressed; const CardScaffoldWithoutListener({ - required this.child, + required this.body, required this.type, this.onRefreshPressed, super.key, @@ -338,7 +338,7 @@ class _CardScaffoldWithoutListenerState extends State { final List children = [ const FluidCell( - child: DualCoinStats(), + child: DualCoinStatsCard(), ), const FluidCell( child: PlasmaStats(), From 70968c33151df186c168b734b5d8e093351647ee Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Thu, 17 Oct 2024 22:01:08 +0300 Subject: [PATCH 012/102] fix: Navigate after the current frame finished rendering --- .../development_intialization_screen.dart | 46 ++++++++++++------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/lib/screens/development_intialization_screen.dart b/lib/screens/development_intialization_screen.dart index c28d201d..66f51c4a 100644 --- a/lib/screens/development_intialization_screen.dart +++ b/lib/screens/development_intialization_screen.dart @@ -6,23 +6,35 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// This will be used to quickly initialize the app when testing in the /// development phase -class DevelopmentInitializationScreen extends StatelessWidget { +class DevelopmentInitializationScreen extends StatefulWidget { static const String route = 'development-initialization-screen'; const DevelopmentInitializationScreen({super.key}); + @override + State createState() => + _DevelopmentInitializationScreenState(); +} + +class _DevelopmentInitializationScreenState + extends State { @override Widget build(BuildContext context) { return FutureBuilder( - future: _initializeApp(context: context), + future: _checkIfWalletPathIsNull(context: context), builder: (_, snapshot) { if (snapshot.hasData) { - final bool finished = snapshot.data!; - if (finished) { - _navigateToHomeScreen(context: context); - } else { - return Text('Error while initializing the app'); - } + final bool isWalletPathNull = snapshot.data!; + + WidgetsBinding.instance.addPostFrameCallback((_) { + if (isWalletPathNull) { + _navigateToAccessWalletScreen(context: context); + } else { + _navigateToHomeScreen(context: context); + } + }); + + return SizedBox.shrink(); } else if (snapshot.hasError) { return Text('Error: ${snapshot.error}'); } @@ -32,17 +44,10 @@ class DevelopmentInitializationScreen extends StatelessWidget { ); } - Future _initializeApp({required BuildContext context}) async { + Future _checkIfWalletPathIsNull({required BuildContext context}) async { try { await InitUtils.initApp(context); - if (kWalletPath == null) { - if (!context.mounted) return false; - Navigator.pushReplacementNamed( - context, - AccessWalletScreen.route, - ); - } - return true; + return kWalletPath == null; } on Exception catch (_) { rethrow; } @@ -54,4 +59,11 @@ class DevelopmentInitializationScreen extends StatelessWidget { rootNavigator: true, ).pushReplacementNamed(MainAppContainer.route); } + + void _navigateToAccessWalletScreen({required BuildContext context}) { + Navigator.pushReplacementNamed( + context, + AccessWalletScreen.route, + ); + } } From d67bfa7cf139c7f4d9a016d047728aca0ac9232c Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Thu, 17 Oct 2024 23:36:10 +0300 Subject: [PATCH 013/102] fix: Apply fixes with dart fix --apply --- lib/blocs/accelerator/accelerator.dart | 2 +- lib/blocs/blocs.dart | 2 +- lib/blocs/dashboard/dashboard.dart | 2 +- lib/blocs/pillars/pillars.dart | 2 +- lib/blocs/plasma/plasma.dart | 2 +- lib/blocs/sentinels/sentinels.dart | 2 +- lib/blocs/settings/settings.dart | 2 +- lib/blocs/staking/staking.dart | 2 +- lib/blocs/tokens/tokens.dart | 2 +- lib/blocs/transfer/transfer.dart | 2 +- lib/main.dart | 2 +- lib/main_dev.dart | 2 +- lib/rearchitecture/dashboard/dashboard.dart | 2 +- .../change_wallet_password_screen.dart | 4 +- lib/screens/dump_mnemonic_screen.dart | 2 +- lib/screens/export/export.dart | 2 +- .../export/export_wallet_info_screen.dart | 4 +- .../export/export_wallet_password_screen.dart | 4 +- lib/screens/node_management_screen.dart | 4 +- .../onboarding/access_wallet_screen.dart | 2 +- .../onboarding/create_key_store_screen.dart | 4 +- .../onboarding/create_ledger_screen.dart | 4 +- .../hardware_wallet/hardware_wallet.dart | 2 +- .../hardware_wallet_device_choice_screen.dart | 2 +- .../hardware_wallet_password_screen.dart | 2 +- .../import_wallet/import_wallet.dart | 2 +- .../import_wallet_decrypt_screen.dart | 2 +- .../import_wallet_password_screen.dart | 4 +- .../import_wallet_seed_choice_screen.dart | 2 +- .../onboarding/new_wallet/new_wallet.dart | 2 +- .../new_wallet_confirm_seed_screen.dart | 6 +- .../new_wallet_password_screen.dart | 2 +- .../new_wallet_seed_choice_screen.dart | 2 +- lib/screens/onboarding/onboarding.dart | 2 +- .../onboarding/wallet_success_screen.dart | 4 +- lib/screens/project_details_screen.dart | 4 +- lib/screens/reset_wallet_screen.dart | 2 +- lib/screens/screens.dart | 2 +- lib/screens/splash_screen.dart | 4 +- lib/screens/stepper_screen.dart | 4 +- lib/utils/app_theme.dart | 76 +++++++++---------- lib/utils/notifiers/notifiers.dart | 2 +- lib/widgets/charts/pillar_rewards_chart.dart | 4 +- lib/widgets/charts/realtime_txs_chart.dart | 4 +- .../charts/sentinel_rewards_chart.dart | 4 +- lib/widgets/charts/staking_rewards_chart.dart | 4 +- lib/widgets/main_app_container.dart | 6 +- .../accelerator_donation_stepper.dart | 2 +- .../accelerator_donations.dart | 4 +- .../accelerator_project_list.dart | 4 +- .../accelerator_project_list_item.dart | 4 +- .../accelerator_stats.dart | 2 +- .../accelerator_widgets/create_phase.dart | 4 +- .../accelerator_widgets/create_project.dart | 4 +- .../phase_creation_stepper.dart | 2 +- .../accelerator_widgets/phase_list.dart | 4 +- .../project_creation_stepper.dart | 2 +- .../accelerator_widgets/project_list.dart | 4 +- .../accelerator_widgets/projects_stats.dart | 2 +- .../update_phase_stepper.dart | 4 +- .../dashboard_widgets/balance.dart | 6 +- .../dashboard_widgets/delegation_stats.dart | 2 +- .../dashboard_widgets/dual_coin_stats.dart | 4 +- .../dashboard_widgets/pillars.dart | 4 +- .../dashboard_widgets/plasma_stats.dart | 4 +- .../realtime_statistics.dart | 2 +- .../dashboard_widgets/sentinels.dart | 2 +- .../dashboard_widgets/staking.dart | 2 +- .../total_hourly_transactions.dart | 2 +- .../dashboard_widgets/transfer.dart | 4 +- .../help_widgets/about_card.dart | 2 +- .../help_widgets/community_card.dart | 2 +- .../help_widgets/update_card.dart | 2 +- .../p2p_swap_widgets/detail_row.dart | 4 +- .../p2p_swap_widgets/htlc_card.dart | 4 +- .../htlc_swap_details_widget.dart | 4 +- .../modals/join_native_swap_modal.dart | 4 +- .../modals/native_p2p_swap_modal.dart | 4 +- .../modals/p2p_swap_warning_modal.dart | 4 +- .../modals/recover_deposit_modal.dart | 4 +- .../modals/start_native_swap_modal.dart | 4 +- .../p2p_swap_options_button.dart | 4 +- .../p2p_swap_options_card.dart | 4 +- .../p2p_swap_widgets/p2p_swaps_card.dart | 4 +- .../p2p_swap_widgets/p2p_swaps_list_item.dart | 4 +- .../pillar_widgets/create_pillar.dart | 4 +- .../pillar_widgets/pillar_collect.dart | 4 +- .../pillar_widgets/pillar_list_widget.dart | 2 +- .../pillar_widgets/pillar_rewards.dart | 3 +- .../pillar_stepper_container.dart | 4 +- .../pillar_widgets/pillar_update_stepper.dart | 2 +- .../plasma_list/plasma_list.dart | 3 +- .../plasma_options/plasma_options.dart | 4 +- .../sentinel_widgets/create_sentinel.dart | 4 +- .../sentinel_widgets/sentinel_collect.dart | 4 +- .../sentinel_list_widget.dart | 2 +- .../sentinel_widgets/sentinel_rewards.dart | 4 +- .../sentinel_stepper_container.dart | 4 +- .../settings_widgets/account_chain_stats.dart | 4 +- .../settings_widgets/addresses.dart | 4 +- .../settings_widgets/backup.dart | 2 +- .../settings_widgets/display.dart | 2 +- .../settings_widgets/general.dart | 2 +- .../settings_widgets/node_management.dart | 4 +- .../settings_widgets/peers.dart | 2 +- .../settings_widgets/security.dart | 4 +- .../settings_widgets/wallet_options.dart | 2 +- .../staking_widgets/stake_collect.dart | 4 +- .../staking_list/staking_list.dart | 2 +- .../staking_options/staking_options.dart | 4 +- .../staking_widgets/staking_rewards.dart | 4 +- .../token_widgets/create_token.dart | 4 +- .../token_widgets/token_balance.dart | 2 +- .../token_widgets/token_card.dart | 4 +- .../token_widgets/token_favorite.dart | 4 +- .../token_widgets/token_map.dart | 2 +- .../token_widgets/token_stepper.dart | 2 +- .../latest_transactions.dart | 4 +- .../latest_transactions_transfer_widget.dart | 4 +- .../pending_transactions.dart | 4 +- .../receive/receive_large.dart | 4 +- .../receive/receive_medium.dart | 3 +- .../receive/receive_small.dart | 4 +- .../transfer_widgets/send/send_large.dart | 4 +- .../transfer_widgets/send/send_medium.dart | 4 +- .../transfer_widgets/send/send_small.dart | 4 +- .../wallet_connect_camera_card.dart | 2 +- .../wallet_connect_pairing_list_card.dart | 2 +- .../wallet_connect_qr_card.dart | 4 +- .../wallet_connect_session_list_card.dart | 2 +- .../wallet_connect_uri_card.dart | 2 +- .../accelerator_project_details.dart | 4 +- .../reusable_widgets/amount_info_column.dart | 3 +- .../reusable_widgets/available_balance.dart | 4 +- .../reusable_widgets/bullet_point_card.dart | 4 +- .../buttons/elevated_button.dart | 4 +- .../buttons/instruction_button.dart | 4 +- .../buttons/material_icon_button.dart | 4 +- .../buttons/onboarding_button.dart | 9 +-- .../buttons/outlined_button.dart | 17 ++--- .../buttons/send_payment_button.dart | 15 ++-- .../buttons/settings_button.dart | 10 +-- .../buttons/stepper_button.dart | 20 ++--- .../transfer_toggle_card_size_button.dart | 4 +- .../reusable_widgets/cancel_timer.dart | 4 +- .../reusable_widgets/chart/chart_legend.dart | 4 +- .../chart/standard_chart.dart | 6 +- .../reusable_widgets/context_menu_region.dart | 4 +- .../custom_expandable_panel.dart | 4 +- .../custom_material_stepper.dart | 9 +-- .../reusable_widgets/custom_slider.dart | 4 +- .../reusable_widgets/custom_table.dart | 32 ++++---- lib/widgets/reusable_widgets/dialogs.dart | 6 +- .../dotted_border_info_widget.dart | 4 +- .../dropdown/addresses_dropdown.dart | 4 +- .../dropdown/basic_dropdown.dart | 4 +- .../dropdown/coin_dropdown.dart | 4 +- .../reusable_widgets/error_widget.dart | 4 +- .../exchange_rate_widget.dart | 4 +- .../formatted_amount_with_tooltip.dart | 3 +- .../reusable_widgets/icons/clear_icon.dart | 6 +- .../icons/copy_to_clipboard_icon.dart | 4 +- .../reusable_widgets/icons/link_icon.dart | 3 +- .../icons/standard_tooltip_icon.dart | 4 +- .../important_text_container.dart | 4 +- .../infinite_scroll_table.dart | 12 +-- .../input_fields/amount_input_field.dart | 4 +- .../input_fields/amount_suffix_widgets.dart | 10 +-- .../input_fields/disabled_address_field.dart | 4 +- .../input_fields/input_field.dart | 4 +- .../input_fields/labeled_input_container.dart | 4 +- .../input_fields/password_input_field.dart | 4 +- .../layout_scaffold/card_scaffold.dart | 4 +- .../layout_scaffold/widget_animator.dart | 4 +- .../reusable_widgets/loading_info_text.dart | 4 +- .../reusable_widgets/loading_widget.dart | 4 +- .../reusable_widgets/modals/base_modal.dart | 4 +- .../reusable_widgets/notification_widget.dart | 4 +- .../reusable_widgets/number_animation.dart | 4 +- lib/widgets/reusable_widgets/plasma_icon.dart | 4 +- .../reusable_widgets/progress_bars.dart | 15 ++-- .../reusable_widgets/receive_qr_image.dart | 10 +-- .../reusable_widgets/seed/seed_choice.dart | 4 +- .../reusable_widgets/seed/seed_grid.dart | 4 +- .../reusable_widgets/select_file_widget.dart | 4 +- .../reusable_widgets/settings_address.dart | 4 +- .../reusable_widgets/settings_node.dart | 4 +- .../reusable_widgets/syrius_checkbox.dart | 9 +-- lib/widgets/reusable_widgets/tag_widget.dart | 4 +- .../transfer_icon_legend.dart | 4 +- .../accelerator_tab_child.dart | 4 +- .../dashboard_tab_child.dart | 2 +- .../tab_children_widgets/help_tab_child.dart | 2 +- .../tab_children_widgets/lock_tab_child.dart | 3 +- .../notifications_tab_child.dart | 2 +- .../p2p_swap_tab_child.dart | 4 +- .../pillars_tab_child.dart | 4 +- .../plasma_tab_child.dart | 2 +- .../sentinels_tab_child.dart | 4 +- .../settings_tab_child.dart | 4 +- .../staking_tab_child.dart | 2 +- .../tokens_tab_child.dart | 4 +- .../transfer_tab_child.dart | 4 +- .../wallet_connect_tab_child.dart | 2 +- 204 files changed, 421 insertions(+), 464 deletions(-) diff --git a/lib/blocs/accelerator/accelerator.dart b/lib/blocs/accelerator/accelerator.dart index eb00346e..34be7449 100644 --- a/lib/blocs/accelerator/accelerator.dart +++ b/lib/blocs/accelerator/accelerator.dart @@ -1,4 +1,4 @@ -library accelerator; +library; export 'accelerator_balance_bloc.dart'; export 'create_phase_bloc.dart'; diff --git a/lib/blocs/blocs.dart b/lib/blocs/blocs.dart index bdfc4b21..e49fb895 100644 --- a/lib/blocs/blocs.dart +++ b/lib/blocs/blocs.dart @@ -1,4 +1,4 @@ -library blocs; +library; export 'auto_receive_tx_worker.dart'; export 'base_bloc.dart'; diff --git a/lib/blocs/dashboard/dashboard.dart b/lib/blocs/dashboard/dashboard.dart index 1c36d94f..03abf343 100644 --- a/lib/blocs/dashboard/dashboard.dart +++ b/lib/blocs/dashboard/dashboard.dart @@ -1,4 +1,4 @@ -library dashboard; +library; export 'balance_bloc.dart'; export 'balance_dashboard_bloc.dart'; diff --git a/lib/blocs/pillars/pillars.dart b/lib/blocs/pillars/pillars.dart index 9b8d7f82..54494357 100644 --- a/lib/blocs/pillars/pillars.dart +++ b/lib/blocs/pillars/pillars.dart @@ -1,4 +1,4 @@ -library pillars; +library; export 'delegate_button_bloc.dart'; export 'delegation_info_bloc.dart'; diff --git a/lib/blocs/plasma/plasma.dart b/lib/blocs/plasma/plasma.dart index d7c6a287..a12ddb24 100644 --- a/lib/blocs/plasma/plasma.dart +++ b/lib/blocs/plasma/plasma.dart @@ -1,4 +1,4 @@ -library plasma; +library; export 'cancel_plasma_bloc.dart'; export 'plasma_list_bloc.dart'; diff --git a/lib/blocs/sentinels/sentinels.dart b/lib/blocs/sentinels/sentinels.dart index 23523180..b24001f4 100644 --- a/lib/blocs/sentinels/sentinels.dart +++ b/lib/blocs/sentinels/sentinels.dart @@ -1,4 +1,4 @@ -library sentinels; +library; export 'disassemble_button_bloc.dart'; export 'get_sentinel_by_owner_bloc.dart'; diff --git a/lib/blocs/settings/settings.dart b/lib/blocs/settings/settings.dart index dbde5077..d5d799b1 100644 --- a/lib/blocs/settings/settings.dart +++ b/lib/blocs/settings/settings.dart @@ -1,4 +1,4 @@ -library settings; +library; export 'account_chain_stats_bloc.dart'; export 'general_stats_bloc.dart'; diff --git a/lib/blocs/staking/staking.dart b/lib/blocs/staking/staking.dart index dd177baa..96860423 100644 --- a/lib/blocs/staking/staking.dart +++ b/lib/blocs/staking/staking.dart @@ -1,4 +1,4 @@ -library staking; +library; export 'cancel_stake_bloc.dart'; export 'staking_list_bloc.dart'; diff --git a/lib/blocs/tokens/tokens.dart b/lib/blocs/tokens/tokens.dart index 6587db06..642296f0 100644 --- a/lib/blocs/tokens/tokens.dart +++ b/lib/blocs/tokens/tokens.dart @@ -1,4 +1,4 @@ -library tokens; +library; export 'burn_token_bloc.dart'; export 'issue_token_bloc.dart'; diff --git a/lib/blocs/transfer/transfer.dart b/lib/blocs/transfer/transfer.dart index 525ca70a..2010e7ed 100644 --- a/lib/blocs/transfer/transfer.dart +++ b/lib/blocs/transfer/transfer.dart @@ -1,4 +1,4 @@ -library transfer; +library; export 'latest_transactions_bloc.dart'; export 'send_payment_bloc.dart'; diff --git a/lib/main.dart b/lib/main.dart index 3c25f53d..5921b7b1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -233,7 +233,7 @@ void setup() { } class MyApp extends StatefulWidget { - const MyApp({Key? key}) : super(key: key); + const MyApp({super.key}); @override State createState() { diff --git a/lib/main_dev.dart b/lib/main_dev.dart index 9432e248..5e072612 100644 --- a/lib/main_dev.dart +++ b/lib/main_dev.dart @@ -226,7 +226,7 @@ void setup() { } class MyApp extends StatefulWidget { - const MyApp({Key? key}) : super(key: key); + const MyApp({super.key}); @override State createState() { diff --git a/lib/rearchitecture/dashboard/dashboard.dart b/lib/rearchitecture/dashboard/dashboard.dart index 7b626d6b..c5e58d83 100644 --- a/lib/rearchitecture/dashboard/dashboard.dart +++ b/lib/rearchitecture/dashboard/dashboard.dart @@ -1,4 +1,4 @@ -library dashboard; +library; export '../dashboard/balance/balance.dart'; export '../dashboard/balance_dashboard/balance_dashboard.dart'; diff --git a/lib/screens/change_wallet_password_screen.dart b/lib/screens/change_wallet_password_screen.dart index 6c382423..f0f62cca 100644 --- a/lib/screens/change_wallet_password_screen.dart +++ b/lib/screens/change_wallet_password_screen.dart @@ -13,8 +13,8 @@ class ChangeWalletPasswordScreen extends StatefulWidget { const ChangeWalletPasswordScreen({ required this.onStepperNotificationSeeMorePressed, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => diff --git a/lib/screens/dump_mnemonic_screen.dart b/lib/screens/dump_mnemonic_screen.dart index c1b3fc04..ded64b06 100644 --- a/lib/screens/dump_mnemonic_screen.dart +++ b/lib/screens/dump_mnemonic_screen.dart @@ -4,7 +4,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class DumpMnemonicScreen extends StatefulWidget { - const DumpMnemonicScreen({Key? key}) : super(key: key); + const DumpMnemonicScreen({super.key}); @override State createState() => _DumpMnemonicScreenState(); diff --git a/lib/screens/export/export.dart b/lib/screens/export/export.dart index 0445e076..2cbcb21e 100644 --- a/lib/screens/export/export.dart +++ b/lib/screens/export/export.dart @@ -1,4 +1,4 @@ -library export; +library; export 'export_wallet_info_screen.dart'; export 'export_wallet_password_screen.dart'; diff --git a/lib/screens/export/export_wallet_info_screen.dart b/lib/screens/export/export_wallet_info_screen.dart index 2b4c3f99..51d1e48f 100644 --- a/lib/screens/export/export_wallet_info_screen.dart +++ b/lib/screens/export/export_wallet_info_screen.dart @@ -12,8 +12,8 @@ class ExportWalletInfoScreen extends StatefulWidget { const ExportWalletInfoScreen( this.seed, { this.backupWalletFlow = false, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _ExportWalletInfoScreenState(); diff --git a/lib/screens/export/export_wallet_password_screen.dart b/lib/screens/export/export_wallet_password_screen.dart index a489d76c..620be245 100644 --- a/lib/screens/export/export_wallet_password_screen.dart +++ b/lib/screens/export/export_wallet_password_screen.dart @@ -20,8 +20,8 @@ class ExportWalletPasswordScreen extends StatefulWidget { const ExportWalletPasswordScreen( this.seed, { this.backupWalletFlow = false, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => diff --git a/lib/screens/node_management_screen.dart b/lib/screens/node_management_screen.dart index 64e474f1..ab52cdca 100644 --- a/lib/screens/node_management_screen.dart +++ b/lib/screens/node_management_screen.dart @@ -18,8 +18,8 @@ class NodeManagementScreen extends StatefulWidget { const NodeManagementScreen({ this.nodeConfirmationCallback, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _NodeManagementScreenState(); diff --git a/lib/screens/onboarding/access_wallet_screen.dart b/lib/screens/onboarding/access_wallet_screen.dart index 5cc18dd2..0a483a9a 100644 --- a/lib/screens/onboarding/access_wallet_screen.dart +++ b/lib/screens/onboarding/access_wallet_screen.dart @@ -6,7 +6,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class AccessWalletScreen extends StatefulWidget { static const String route = 'access-wallet-screen'; - const AccessWalletScreen({Key? key}) : super(key: key); + const AccessWalletScreen({super.key}); @override State createState() => _AccessWalletScreenState(); diff --git a/lib/screens/onboarding/create_key_store_screen.dart b/lib/screens/onboarding/create_key_store_screen.dart index bc653974..60283ecf 100644 --- a/lib/screens/onboarding/create_key_store_screen.dart +++ b/lib/screens/onboarding/create_key_store_screen.dart @@ -14,8 +14,8 @@ class CreateKeyStoreScreen extends StatefulWidget { this.seed, this.password, { this.progressBarNumLevels = 5, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _CreateKeyStoreScreenState(); diff --git a/lib/screens/onboarding/create_ledger_screen.dart b/lib/screens/onboarding/create_ledger_screen.dart index 4e2d647d..951c3a70 100644 --- a/lib/screens/onboarding/create_ledger_screen.dart +++ b/lib/screens/onboarding/create_ledger_screen.dart @@ -15,8 +15,8 @@ class CreateLedgerWalletScreen extends StatefulWidget { this.deviceInfo, this.password, { this.progressBarNumLevels = 4, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => diff --git a/lib/screens/onboarding/hardware_wallet/hardware_wallet.dart b/lib/screens/onboarding/hardware_wallet/hardware_wallet.dart index 0fa29018..61ac12fd 100644 --- a/lib/screens/onboarding/hardware_wallet/hardware_wallet.dart +++ b/lib/screens/onboarding/hardware_wallet/hardware_wallet.dart @@ -1,4 +1,4 @@ -library hardware_wallet; +library; export 'hardware_wallet_password_screen.dart'; export 'hardware_wallet_device_choice_screen.dart'; diff --git a/lib/screens/onboarding/hardware_wallet/hardware_wallet_device_choice_screen.dart b/lib/screens/onboarding/hardware_wallet/hardware_wallet_device_choice_screen.dart index 7cd3800b..b3bc1de2 100644 --- a/lib/screens/onboarding/hardware_wallet/hardware_wallet_device_choice_screen.dart +++ b/lib/screens/onboarding/hardware_wallet/hardware_wallet_device_choice_screen.dart @@ -11,7 +11,7 @@ import 'package:znn_ledger_dart/znn_ledger_dart.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class HardwareWalletDeviceChoiceScreen extends StatefulWidget { - const HardwareWalletDeviceChoiceScreen({Key? key}) : super(key: key); + const HardwareWalletDeviceChoiceScreen({super.key}); @override State createState() => diff --git a/lib/screens/onboarding/hardware_wallet/hardware_wallet_password_screen.dart b/lib/screens/onboarding/hardware_wallet/hardware_wallet_password_screen.dart index c7b2024d..e16b8b8b 100644 --- a/lib/screens/onboarding/hardware_wallet/hardware_wallet_password_screen.dart +++ b/lib/screens/onboarding/hardware_wallet/hardware_wallet_password_screen.dart @@ -7,7 +7,7 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class HardwareWalletPasswordScreen extends StatefulWidget { final WalletDefinition deviceInfo; - const HardwareWalletPasswordScreen(this.deviceInfo, {Key? key}) : super(key: key); + const HardwareWalletPasswordScreen(this.deviceInfo, {super.key}); @override State createState() => diff --git a/lib/screens/onboarding/import_wallet/import_wallet.dart b/lib/screens/onboarding/import_wallet/import_wallet.dart index 8783568f..0a269e46 100644 --- a/lib/screens/onboarding/import_wallet/import_wallet.dart +++ b/lib/screens/onboarding/import_wallet/import_wallet.dart @@ -1,4 +1,4 @@ -library import_wallet; +library; export 'import_wallet_decrypt_screen.dart'; export 'import_wallet_password_screen.dart'; diff --git a/lib/screens/onboarding/import_wallet/import_wallet_decrypt_screen.dart b/lib/screens/onboarding/import_wallet/import_wallet_decrypt_screen.dart index 32577f42..7416739b 100644 --- a/lib/screens/onboarding/import_wallet/import_wallet_decrypt_screen.dart +++ b/lib/screens/onboarding/import_wallet/import_wallet_decrypt_screen.dart @@ -10,7 +10,7 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ImportWalletDecryptScreen extends StatefulWidget { final String path; - const ImportWalletDecryptScreen(this.path, {Key? key}) : super(key: key); + const ImportWalletDecryptScreen(this.path, {super.key}); @override State createState() => diff --git a/lib/screens/onboarding/import_wallet/import_wallet_password_screen.dart b/lib/screens/onboarding/import_wallet/import_wallet_password_screen.dart index f46b2215..88a1d5f5 100644 --- a/lib/screens/onboarding/import_wallet/import_wallet_password_screen.dart +++ b/lib/screens/onboarding/import_wallet/import_wallet_password_screen.dart @@ -10,8 +10,8 @@ class ImportWalletPasswordScreen extends StatefulWidget { const ImportWalletPasswordScreen( this.seed, { this.progressBarNumLevels = 5, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => diff --git a/lib/screens/onboarding/import_wallet/import_wallet_seed_choice_screen.dart b/lib/screens/onboarding/import_wallet/import_wallet_seed_choice_screen.dart index e4c0037e..2e47fac4 100644 --- a/lib/screens/onboarding/import_wallet/import_wallet_seed_choice_screen.dart +++ b/lib/screens/onboarding/import_wallet/import_wallet_seed_choice_screen.dart @@ -6,7 +6,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ImportWalletSeedChoiceScreen extends StatefulWidget { - const ImportWalletSeedChoiceScreen({Key? key}) : super(key: key); + const ImportWalletSeedChoiceScreen({super.key}); @override State createState() => diff --git a/lib/screens/onboarding/new_wallet/new_wallet.dart b/lib/screens/onboarding/new_wallet/new_wallet.dart index 98471eae..c0507b31 100644 --- a/lib/screens/onboarding/new_wallet/new_wallet.dart +++ b/lib/screens/onboarding/new_wallet/new_wallet.dart @@ -1,4 +1,4 @@ -library new_wallet; +library; export 'new_wallet_confirm_seed_screen.dart'; export 'new_wallet_password_screen.dart'; diff --git a/lib/screens/onboarding/new_wallet/new_wallet_confirm_seed_screen.dart b/lib/screens/onboarding/new_wallet/new_wallet_confirm_seed_screen.dart index 603d7aef..991db977 100644 --- a/lib/screens/onboarding/new_wallet/new_wallet_confirm_seed_screen.dart +++ b/lib/screens/onboarding/new_wallet/new_wallet_confirm_seed_screen.dart @@ -10,8 +10,8 @@ class NewWalletConfirmSeedScreen extends StatefulWidget { const NewWalletConfirmSeedScreen( this.seedWords, { - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => @@ -258,7 +258,7 @@ class _NewWalletConfirmSeedScreenState ), ); }, - onWillAccept: (data) { + onWillAcceptWithDetails: (data) { return _randomIndexes.contains(seedGridElementIndex) || !seedGridElement.isValid; }, diff --git a/lib/screens/onboarding/new_wallet/new_wallet_password_screen.dart b/lib/screens/onboarding/new_wallet/new_wallet_password_screen.dart index c42f7e28..a9c458e1 100644 --- a/lib/screens/onboarding/new_wallet/new_wallet_password_screen.dart +++ b/lib/screens/onboarding/new_wallet/new_wallet_password_screen.dart @@ -6,7 +6,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class NewWalletPasswordScreen extends StatefulWidget { final List seedWords; - const NewWalletPasswordScreen(this.seedWords, {Key? key}) : super(key: key); + const NewWalletPasswordScreen(this.seedWords, {super.key}); @override State createState() => diff --git a/lib/screens/onboarding/new_wallet/new_wallet_seed_choice_screen.dart b/lib/screens/onboarding/new_wallet/new_wallet_seed_choice_screen.dart index 6577847f..0f1af50b 100644 --- a/lib/screens/onboarding/new_wallet/new_wallet_seed_choice_screen.dart +++ b/lib/screens/onboarding/new_wallet/new_wallet_seed_choice_screen.dart @@ -10,7 +10,7 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class NewWalletSeedChoiceScreen extends StatefulWidget { final bool? export; - const NewWalletSeedChoiceScreen({Key? key, this.export}) : super(key: key); + const NewWalletSeedChoiceScreen({super.key, this.export}); @override State createState() => diff --git a/lib/screens/onboarding/onboarding.dart b/lib/screens/onboarding/onboarding.dart index 9041a189..6b624c50 100644 --- a/lib/screens/onboarding/onboarding.dart +++ b/lib/screens/onboarding/onboarding.dart @@ -1,4 +1,4 @@ -library onboarding; +library; export 'access_wallet_screen.dart'; export 'create_key_store_screen.dart'; diff --git a/lib/screens/onboarding/wallet_success_screen.dart b/lib/screens/onboarding/wallet_success_screen.dart index 9f4a274c..07a84dd0 100644 --- a/lib/screens/onboarding/wallet_success_screen.dart +++ b/lib/screens/onboarding/wallet_success_screen.dart @@ -9,8 +9,8 @@ class WalletSuccessScreen extends StatefulWidget { const WalletSuccessScreen({ this.progressBarNumLevels = 5, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _WalletSuccessScreenState(); diff --git a/lib/screens/project_details_screen.dart b/lib/screens/project_details_screen.dart index fd233fa1..a2ccf598 100644 --- a/lib/screens/project_details_screen.dart +++ b/lib/screens/project_details_screen.dart @@ -15,8 +15,8 @@ class ProjectDetailsScreen extends StatefulWidget { required this.project, required this.pillarInfo, required this.onStepperNotificationSeeMorePressed, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _ProjectDetailsScreenState(); diff --git a/lib/screens/reset_wallet_screen.dart b/lib/screens/reset_wallet_screen.dart index 3604612b..64c5a3e2 100644 --- a/lib/screens/reset_wallet_screen.dart +++ b/lib/screens/reset_wallet_screen.dart @@ -5,7 +5,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class ResetWalletScreen extends StatefulWidget { - const ResetWalletScreen({Key? key}) : super(key: key); + const ResetWalletScreen({super.key}); @override State createState() => _ResetWalletScreenState(); diff --git a/lib/screens/screens.dart b/lib/screens/screens.dart index e48b8f6e..072a53ab 100644 --- a/lib/screens/screens.dart +++ b/lib/screens/screens.dart @@ -1,4 +1,4 @@ -library screens; +library; export 'change_wallet_password_screen.dart'; export 'development_intialization_screen.dart'; diff --git a/lib/screens/splash_screen.dart b/lib/screens/splash_screen.dart index be2238b1..7710610d 100644 --- a/lib/screens/splash_screen.dart +++ b/lib/screens/splash_screen.dart @@ -22,8 +22,8 @@ class SplashScreen extends StatefulWidget { const SplashScreen({ this.resetWalletFlow = false, this.deleteCacheFlow = false, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _SplashScreenState(); diff --git a/lib/screens/stepper_screen.dart b/lib/screens/stepper_screen.dart index 1b3b46c2..14bebc5d 100644 --- a/lib/screens/stepper_screen.dart +++ b/lib/screens/stepper_screen.dart @@ -8,8 +8,8 @@ class StepperScreen extends StatelessWidget { const StepperScreen({ required this.stepper, required this.onStepperNotificationSeeMorePressed, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/utils/app_theme.dart b/lib/utils/app_theme.dart index 784e4fa2..d8bf03fd 100644 --- a/lib/utils/app_theme.dart +++ b/lib/utils/app_theme.dart @@ -123,9 +123,9 @@ class AppTheme { textButtonTheme: kTextButtonThemeData, outlinedButtonTheme: OutlinedButtonThemeData( style: kOutlinedButtonStyle.copyWith( - foregroundColor: MaterialStateProperty.resolveWith( + foregroundColor: WidgetStateProperty.resolveWith( (states) { - if (states.contains(MaterialState.disabled)) { + if (states.contains(WidgetState.disabled)) { return Colors.black38; } return Colors.black; @@ -200,46 +200,46 @@ class AppTheme { ), unselectedWidgetColor: AppColors.lightSecondaryContainer, switchTheme: SwitchThemeData( - thumbColor: MaterialStateProperty.resolveWith( - (Set states) { - if (states.contains(MaterialState.disabled)) { + thumbColor: WidgetStateProperty.resolveWith( + (Set states) { + if (states.contains(WidgetState.disabled)) { return null; } - if (states.contains(MaterialState.selected)) { + if (states.contains(WidgetState.selected)) { return AppColors.znnColor; } return null; }), - trackColor: MaterialStateProperty.resolveWith( - (Set states) { - if (states.contains(MaterialState.disabled)) { + trackColor: WidgetStateProperty.resolveWith( + (Set states) { + if (states.contains(WidgetState.disabled)) { return null; } - if (states.contains(MaterialState.selected)) { + if (states.contains(WidgetState.selected)) { return AppColors.znnColor; } return null; }), ), radioTheme: RadioThemeData( - fillColor: MaterialStateProperty.resolveWith( - (Set states) { - if (states.contains(MaterialState.disabled)) { + fillColor: WidgetStateProperty.resolveWith( + (Set states) { + if (states.contains(WidgetState.disabled)) { return null; } - if (states.contains(MaterialState.selected)) { + if (states.contains(WidgetState.selected)) { return AppColors.znnColor; } return null; }), ), checkboxTheme: CheckboxThemeData( - fillColor: MaterialStateProperty.resolveWith( - (Set states) { - if (states.contains(MaterialState.disabled)) { + fillColor: WidgetStateProperty.resolveWith( + (Set states) { + if (states.contains(WidgetState.disabled)) { return null; } - if (states.contains(MaterialState.selected)) { + if (states.contains(WidgetState.selected)) { return AppColors.znnColor; } return null; @@ -251,7 +251,7 @@ class AppTheme { secondary: AppColors.lightSecondary, secondaryContainer: AppColors.lightSecondaryContainer, error: AppColors.errorColor, - ).copyWith(background: AppColors.backgroundLight), + ).copyWith(surface: AppColors.backgroundLight), ); static final ThemeData darkTheme = ThemeData( @@ -260,9 +260,9 @@ class AppTheme { textButtonTheme: kTextButtonThemeData, outlinedButtonTheme: OutlinedButtonThemeData( style: kOutlinedButtonStyle.copyWith( - foregroundColor: MaterialStateProperty.resolveWith( + foregroundColor: WidgetStateProperty.resolveWith( (states) { - if (states.contains(MaterialState.disabled)) { + if (states.contains(WidgetState.disabled)) { return Colors.white38; } return Colors.white; @@ -340,46 +340,46 @@ class AppTheme { ), unselectedWidgetColor: AppColors.darkSecondaryContainer, switchTheme: SwitchThemeData( - thumbColor: MaterialStateProperty.resolveWith( - (Set states) { - if (states.contains(MaterialState.disabled)) { + thumbColor: WidgetStateProperty.resolveWith( + (Set states) { + if (states.contains(WidgetState.disabled)) { return null; } - if (states.contains(MaterialState.selected)) { + if (states.contains(WidgetState.selected)) { return AppColors.znnColor; } return null; }), - trackColor: MaterialStateProperty.resolveWith( - (Set states) { - if (states.contains(MaterialState.disabled)) { + trackColor: WidgetStateProperty.resolveWith( + (Set states) { + if (states.contains(WidgetState.disabled)) { return null; } - if (states.contains(MaterialState.selected)) { + if (states.contains(WidgetState.selected)) { return AppColors.znnColor; } return null; }), ), radioTheme: RadioThemeData( - fillColor: MaterialStateProperty.resolveWith( - (Set states) { - if (states.contains(MaterialState.disabled)) { + fillColor: WidgetStateProperty.resolveWith( + (Set states) { + if (states.contains(WidgetState.disabled)) { return null; } - if (states.contains(MaterialState.selected)) { + if (states.contains(WidgetState.selected)) { return AppColors.znnColor; } return null; }), ), checkboxTheme: CheckboxThemeData( - fillColor: MaterialStateProperty.resolveWith( - (Set states) { - if (states.contains(MaterialState.disabled)) { + fillColor: WidgetStateProperty.resolveWith( + (Set states) { + if (states.contains(WidgetState.disabled)) { return null; } - if (states.contains(MaterialState.selected)) { + if (states.contains(WidgetState.selected)) { return AppColors.znnColor; } return null; @@ -391,7 +391,7 @@ class AppTheme { secondary: AppColors.darkSecondary, secondaryContainer: AppColors.darkSecondaryContainer, error: AppColors.errorColor, - ).copyWith(background: AppColors.backgroundDark), + ).copyWith(surface: AppColors.backgroundDark), ); AppTheme._(); diff --git a/lib/utils/notifiers/notifiers.dart b/lib/utils/notifiers/notifiers.dart index f0ac7d78..b1da6ef6 100644 --- a/lib/utils/notifiers/notifiers.dart +++ b/lib/utils/notifiers/notifiers.dart @@ -1,4 +1,4 @@ -library notifiers; +library; export 'app_theme_notifier.dart'; export 'default_address_notifier.dart'; diff --git a/lib/widgets/charts/pillar_rewards_chart.dart b/lib/widgets/charts/pillar_rewards_chart.dart index 200fc20e..1310ed8c 100644 --- a/lib/widgets/charts/pillar_rewards_chart.dart +++ b/lib/widgets/charts/pillar_rewards_chart.dart @@ -12,8 +12,8 @@ class PillarRewardsChart extends StatefulWidget { const PillarRewardsChart( this.rewardsHistory, { - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => PillarRewardsChartState(); diff --git a/lib/widgets/charts/realtime_txs_chart.dart b/lib/widgets/charts/realtime_txs_chart.dart index 4c9862c8..8c67fc63 100644 --- a/lib/widgets/charts/realtime_txs_chart.dart +++ b/lib/widgets/charts/realtime_txs_chart.dart @@ -13,8 +13,8 @@ class RealtimeTxsChart extends StatefulWidget { const RealtimeTxsChart( this.transactions, { - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => RealtimeTxsChartState(); diff --git a/lib/widgets/charts/sentinel_rewards_chart.dart b/lib/widgets/charts/sentinel_rewards_chart.dart index 51d42034..d88de553 100644 --- a/lib/widgets/charts/sentinel_rewards_chart.dart +++ b/lib/widgets/charts/sentinel_rewards_chart.dart @@ -14,8 +14,8 @@ class SentinelRewardsChart extends StatefulWidget { const SentinelRewardsChart( this.rewardsHistory, { - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() { diff --git a/lib/widgets/charts/staking_rewards_chart.dart b/lib/widgets/charts/staking_rewards_chart.dart index 8daf8b76..bac5816e 100644 --- a/lib/widgets/charts/staking_rewards_chart.dart +++ b/lib/widgets/charts/staking_rewards_chart.dart @@ -12,8 +12,8 @@ class StakingRewardsChart extends StatefulWidget { const StakingRewardsChart( this.rewardsHistory, { - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _StakingRewardsChart(); diff --git a/lib/widgets/main_app_container.dart b/lib/widgets/main_app_container.dart index e7e93d36..11d214af 100644 --- a/lib/widgets/main_app_container.dart +++ b/lib/widgets/main_app_container.dart @@ -55,9 +55,9 @@ class MainAppContainer extends StatefulWidget { static const String route = 'main-app-container'; const MainAppContainer({ - Key? key, + super.key, this.redirectedFromWalletSuccess = false, - }) : super(key: key); + }); @override State createState() => _MainAppContainerState(); @@ -113,7 +113,7 @@ class _MainAppContainerState extends State return Consumer( builder: (context, textScalingNotifier, child) => MediaQuery( data: MediaQuery.of(context).copyWith( - textScaleFactor: textScalingNotifier.getTextScaleFactor(context), + textScaler: TextScaler.linear(textScalingNotifier.getTextScaleFactor(context)), ), child: Scaffold( body: Container( diff --git a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donation_stepper.dart b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donation_stepper.dart index 9d512f7d..6c12c0e7 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donation_stepper.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donation_stepper.dart @@ -16,7 +16,7 @@ enum AcceleratorDonationStep { } class AcceleratorDonationStepper extends StatefulWidget { - const AcceleratorDonationStepper({Key? key}) : super(key: key); + const AcceleratorDonationStepper({super.key}); @override State createState() => diff --git a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donations.dart b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donations.dart index 9791a7eb..ab39b59d 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donations.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donations.dart @@ -9,8 +9,8 @@ class AcceleratorDonations extends StatelessWidget { const AcceleratorDonations({ required this.onStepperNotificationSeeMorePressed, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list.dart b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list.dart index 3d52dae1..450f2fd9 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list.dart @@ -20,8 +20,8 @@ class AcceleratorProjectList extends StatefulWidget { this.acceleratorProjects, { required this.onStepperNotificationSeeMorePressed, this.projects, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _AcceleratorProjectListState(); diff --git a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list_item.dart b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list_item.dart index 52e038c5..8e5205bd 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list_item.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list_item.dart @@ -14,12 +14,12 @@ class AcceleratorProjectListItem extends StatefulWidget { final VoidCallback onStepperNotificationSeeMorePressed; const AcceleratorProjectListItem({ - Key? key, + super.key, required this.acceleratorProject, this.pillarInfo, this.project, required this.onStepperNotificationSeeMorePressed, - }) : super(key: key); + }); @override State createState() => diff --git a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_stats.dart b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_stats.dart index 477c7632..2797e664 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_stats.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_stats.dart @@ -7,7 +7,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class AcceleratorStats extends StatefulWidget { - const AcceleratorStats({Key? key}) : super(key: key); + const AcceleratorStats({super.key}); @override State createState() => _AcceleratorStatsState(); diff --git a/lib/widgets/modular_widgets/accelerator_widgets/create_phase.dart b/lib/widgets/modular_widgets/accelerator_widgets/create_phase.dart index 44754889..2f4688ee 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/create_phase.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/create_phase.dart @@ -12,8 +12,8 @@ class CreatePhase extends StatelessWidget { const CreatePhase({ required this.onStepperNotificationSeeMorePressed, required this.project, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/modular_widgets/accelerator_widgets/create_project.dart b/lib/widgets/modular_widgets/accelerator_widgets/create_project.dart index e7a150f0..022c48f8 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/create_project.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/create_project.dart @@ -9,8 +9,8 @@ class CreateProject extends StatelessWidget { const CreateProject({ required this.onStepperNotificationSeeMorePressed, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/modular_widgets/accelerator_widgets/phase_creation_stepper.dart b/lib/widgets/modular_widgets/accelerator_widgets/phase_creation_stepper.dart index 7056ab5b..79ab1a93 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/phase_creation_stepper.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/phase_creation_stepper.dart @@ -17,7 +17,7 @@ enum PhaseCreationStep { class PhaseCreationStepper extends StatefulWidget { final Project project; - const PhaseCreationStepper(this.project, {Key? key}) : super(key: key); + const PhaseCreationStepper(this.project, {super.key}); @override State createState() => _PhaseCreationStepperState(); diff --git a/lib/widgets/modular_widgets/accelerator_widgets/phase_list.dart b/lib/widgets/modular_widgets/accelerator_widgets/phase_list.dart index 27b6a8ca..62a535e7 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/phase_list.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/phase_list.dart @@ -13,8 +13,8 @@ class PhaseList extends StatelessWidget { this.project, this.onRefreshButtonPressed, { required this.onStepperNotificationSeeMorePressed, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/modular_widgets/accelerator_widgets/project_creation_stepper.dart b/lib/widgets/modular_widgets/accelerator_widgets/project_creation_stepper.dart index db1094cc..4e65bbe7 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/project_creation_stepper.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/project_creation_stepper.dart @@ -16,7 +16,7 @@ enum ProjectCreationStep { } class ProjectCreationStepper extends StatefulWidget { - const ProjectCreationStepper({Key? key}) : super(key: key); + const ProjectCreationStepper({super.key}); @override State createState() => _ProjectCreationStepperState(); diff --git a/lib/widgets/modular_widgets/accelerator_widgets/project_list.dart b/lib/widgets/modular_widgets/accelerator_widgets/project_list.dart index ede6c039..5a43aa04 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/project_list.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/project_list.dart @@ -23,8 +23,8 @@ class AccProjectList extends StatefulWidget { const AccProjectList({ required this.onStepperNotificationSeeMorePressed, required this.pillarInfo, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _AccProjectListState(); diff --git a/lib/widgets/modular_widgets/accelerator_widgets/projects_stats.dart b/lib/widgets/modular_widgets/accelerator_widgets/projects_stats.dart index 9481379a..daf495c9 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/projects_stats.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/projects_stats.dart @@ -7,7 +7,7 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ProjectsStats extends StatelessWidget { final Project project; - const ProjectsStats(this.project, {Key? key}) : super(key: key); + const ProjectsStats(this.project, {super.key}); @override Widget build(BuildContext context) { diff --git a/lib/widgets/modular_widgets/accelerator_widgets/update_phase_stepper.dart b/lib/widgets/modular_widgets/accelerator_widgets/update_phase_stepper.dart index c419575d..e36beca2 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/update_phase_stepper.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/update_phase_stepper.dart @@ -21,8 +21,8 @@ class UpdatePhaseStepper extends StatefulWidget { const UpdatePhaseStepper( this.phase, this.project, { - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _UpdatePhaseStepperState(); diff --git a/lib/widgets/modular_widgets/dashboard_widgets/balance.dart b/lib/widgets/modular_widgets/dashboard_widgets/balance.dart index c57b391c..060c7579 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/balance.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/balance.dart @@ -13,8 +13,8 @@ final String _kWidgetDescription = 'This card displays the current ' class BalanceWidget extends StatefulWidget { const BalanceWidget({ - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _BalanceWidgetState(); @@ -29,7 +29,7 @@ class _BalanceWidgetState extends State { void didChangeDependencies() { super.didChangeDependencies(); _colorAddressPrefixSuffix ??= Theme.of(context).hintColor; - _backgroundAddressColor ??= Theme.of(context).colorScheme.background; + _backgroundAddressColor ??= Theme.of(context).colorScheme.surface; } @override diff --git a/lib/widgets/modular_widgets/dashboard_widgets/delegation_stats.dart b/lib/widgets/modular_widgets/dashboard_widgets/delegation_stats.dart index b9448b24..36c3a912 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/delegation_stats.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/delegation_stats.dart @@ -11,7 +11,7 @@ final String _kWidgetDescription = 'This card displays the amount of ' '${kZnnCoin.symbol} and the name of the Pillar that you delegated to'; class DelegationStats extends StatefulWidget { - const DelegationStats({Key? key}) : super(key: key); + const DelegationStats({super.key}); @override State createState() => _DelegationStatsState(); diff --git a/lib/widgets/modular_widgets/dashboard_widgets/dual_coin_stats.dart b/lib/widgets/modular_widgets/dashboard_widgets/dual_coin_stats.dart index a4f827fb..78484d29 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/dual_coin_stats.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/dual_coin_stats.dart @@ -14,8 +14,8 @@ final String _kWidgetDescription = 'This card displays the circulating ' class DualCoinStats extends StatefulWidget { const DualCoinStats({ - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _DualCoinStatsState(); diff --git a/lib/widgets/modular_widgets/dashboard_widgets/pillars.dart b/lib/widgets/modular_widgets/dashboard_widgets/pillars.dart index feda883b..21dd2595 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/pillars.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/pillars.dart @@ -10,8 +10,8 @@ const String _kWidgetDescription = 'This card displays the number of active ' class Pillars extends StatefulWidget { const Pillars({ - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _PillarsState(); diff --git a/lib/widgets/modular_widgets/dashboard_widgets/plasma_stats.dart b/lib/widgets/modular_widgets/dashboard_widgets/plasma_stats.dart index 98e6281e..d6851a0b 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/plasma_stats.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/plasma_stats.dart @@ -29,8 +29,8 @@ class PlasmaStats extends StatefulWidget { const PlasmaStats({ this.version = PlasmaStatsWidgetVersion.dashboardTab, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _PlasmaStatsState(); diff --git a/lib/widgets/modular_widgets/dashboard_widgets/realtime_statistics.dart b/lib/widgets/modular_widgets/dashboard_widgets/realtime_statistics.dart index 98b7b755..6f20edc1 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/realtime_statistics.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/realtime_statistics.dart @@ -14,7 +14,7 @@ final String _kWidgetDescription = 'with the network embedded contracts is internally considered a transaction'; class RealtimeStatistics extends StatefulWidget { - const RealtimeStatistics({Key? key}) : super(key: key); + const RealtimeStatistics({super.key}); @override State createState() => _RealtimeStatisticsState(); diff --git a/lib/widgets/modular_widgets/dashboard_widgets/sentinels.dart b/lib/widgets/modular_widgets/dashboard_widgets/sentinels.dart index 6e85ee4c..36bdd0c4 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/sentinels.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/sentinels.dart @@ -10,7 +10,7 @@ const String _kWidgetDescription = 'This card displays the number of active ' 'Sentinels in the network'; class Sentinels extends StatefulWidget { - const Sentinels({Key? key}) : super(key: key); + const Sentinels({super.key}); @override State createState() => _SentinelsState(); diff --git a/lib/widgets/modular_widgets/dashboard_widgets/staking.dart b/lib/widgets/modular_widgets/dashboard_widgets/staking.dart index ca29739b..9f4fec07 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/staking.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/staking.dart @@ -11,7 +11,7 @@ final String _kWidgetDescription = 'This card displays the number of staking ' 'entries and the total ${kZnnCoin.symbol} that you are currently staking'; class Staking extends StatefulWidget { - const Staking({Key? key}) : super(key: key); + const Staking({super.key}); @override State createState() => _StakingState(); diff --git a/lib/widgets/modular_widgets/dashboard_widgets/total_hourly_transactions.dart b/lib/widgets/modular_widgets/dashboard_widgets/total_hourly_transactions.dart index b04a20c5..f300563f 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/total_hourly_transactions.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/total_hourly_transactions.dart @@ -9,7 +9,7 @@ const String _kWidgetDescription = 'This card displays the total number of ' 'transactions settled in the last hour across the network'; class TotalHourlyTransactions extends StatefulWidget { - const TotalHourlyTransactions({Key? key}) : super(key: key); + const TotalHourlyTransactions({super.key}); @override State createState() => diff --git a/lib/widgets/modular_widgets/dashboard_widgets/transfer.dart b/lib/widgets/modular_widgets/dashboard_widgets/transfer.dart index 8f502110..2ebb3073 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/transfer.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/transfer.dart @@ -16,9 +16,9 @@ class Transfer extends StatefulWidget { })? changePage; const Transfer({ - Key? key, + super.key, this.changePage, - }) : super(key: key); + }); @override State createState() => _TransferState(); diff --git a/lib/widgets/modular_widgets/help_widgets/about_card.dart b/lib/widgets/modular_widgets/help_widgets/about_card.dart index 2f850b99..94a95ebb 100644 --- a/lib/widgets/modular_widgets/help_widgets/about_card.dart +++ b/lib/widgets/modular_widgets/help_widgets/about_card.dart @@ -10,7 +10,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class AboutCard extends StatefulWidget { - const AboutCard({Key? key}) : super(key: key); + const AboutCard({super.key}); @override State createState() { diff --git a/lib/widgets/modular_widgets/help_widgets/community_card.dart b/lib/widgets/modular_widgets/help_widgets/community_card.dart index 360246b5..e55977c8 100644 --- a/lib/widgets/modular_widgets/help_widgets/community_card.dart +++ b/lib/widgets/modular_widgets/help_widgets/community_card.dart @@ -5,7 +5,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class CommunityCard extends StatelessWidget { - const CommunityCard({Key? key}) : super(key: key); + const CommunityCard({super.key}); @override Widget build(BuildContext context) { diff --git a/lib/widgets/modular_widgets/help_widgets/update_card.dart b/lib/widgets/modular_widgets/help_widgets/update_card.dart index 2b46dd35..d63968be 100644 --- a/lib/widgets/modular_widgets/help_widgets/update_card.dart +++ b/lib/widgets/modular_widgets/help_widgets/update_card.dart @@ -4,7 +4,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class UpdateCard extends StatelessWidget { - const UpdateCard({Key? key}) : super(key: key); + const UpdateCard({super.key}); @override Widget build(BuildContext context) { diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/detail_row.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/detail_row.dart index b06ee378..f0596d5f 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/detail_row.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/detail_row.dart @@ -15,8 +15,8 @@ class DetailRow extends StatelessWidget { this.valueToShow, this.prefixWidget, this.canBeCopied = true, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_card.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_card.dart index c2435c80..33f5c067 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_card.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_card.dart @@ -36,8 +36,8 @@ class HtlcCard extends StatefulWidget { required this.tokenStandard, required this.tokenDecimals, required this.tokenSymbol, - Key? key, - }) : super(key: key); + super.key, + }); factory HtlcCard.sending({ required HtlcSwap swap, diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_swap_details_widget.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_swap_details_widget.dart index 8a5cc11c..9c1ba80a 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_swap_details_widget.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_swap_details_widget.dart @@ -12,8 +12,8 @@ class HtlcSwapDetailsWidget extends StatefulWidget { const HtlcSwapDetailsWidget({ required this.swap, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _HtlcSwapDetailsWidgetState(); diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/join_native_swap_modal.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/join_native_swap_modal.dart index b6cd633c..9be18dc7 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/join_native_swap_modal.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/join_native_swap_modal.dart @@ -32,8 +32,8 @@ class JoinNativeSwapModal extends StatefulWidget { const JoinNativeSwapModal({ required this.onJoinedSwap, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _JoinNativeSwapModalState(); diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/native_p2p_swap_modal.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/native_p2p_swap_modal.dart index fb9cd5fd..7426428e 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/native_p2p_swap_modal.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/native_p2p_swap_modal.dart @@ -27,8 +27,8 @@ class NativeP2pSwapModal extends StatefulWidget { const NativeP2pSwapModal({ required this.swapId, this.onSwapStarted, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _NativeP2pSwapModalState(); diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/p2p_swap_warning_modal.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/p2p_swap_warning_modal.dart index ccf3e562..5ab0bdb9 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/p2p_swap_warning_modal.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/p2p_swap_warning_modal.dart @@ -6,8 +6,8 @@ class P2PSwapWarningModal extends StatefulWidget { const P2PSwapWarningModal({ required this.onAccepted, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _P2PSwapWarningModalState(); diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/recover_deposit_modal.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/recover_deposit_modal.dart index bb584119..2eb20d02 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/recover_deposit_modal.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/recover_deposit_modal.dart @@ -13,8 +13,8 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class RecoverDepositModal extends StatefulWidget { const RecoverDepositModal({ - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _RecoverDepositModalState(); diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/start_native_swap_modal.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/start_native_swap_modal.dart index 4d529be6..08af3a50 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/start_native_swap_modal.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/start_native_swap_modal.dart @@ -29,8 +29,8 @@ class StartNativeSwapModal extends StatefulWidget { const StartNativeSwapModal({ required this.onSwapStarted, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _StartNativeSwapModalState(); diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_button.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_button.dart index b5ed14fc..17fd132b 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_button.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_button.dart @@ -7,11 +7,11 @@ class P2pSwapOptionsButton extends StatefulWidget { final String secondaryText; const P2pSwapOptionsButton({ - Key? key, + super.key, required this.primaryText, required this.secondaryText, required this.onClick, - }) : super(key: key); + }); @override State createState() => _P2pSwapOptionsButtonState(); diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_card.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_card.dart index 1ec9bfa6..aaf99522 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_card.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_card.dart @@ -17,8 +17,8 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class P2pSwapOptionsCard extends StatefulWidget { const P2pSwapOptionsCard({ - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _P2pSwapOptionsCardState(); diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_card.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_card.dart index a41d09a7..cae5d8c3 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_card.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_card.dart @@ -12,8 +12,8 @@ class P2pSwapsCard extends StatefulWidget { const P2pSwapsCard({ required this.onStepperNotificationSeeMorePressed, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _P2pSwapsCardState(); diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_list_item.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_list_item.dart index eac438f3..0e22a195 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_list_item.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_list_item.dart @@ -16,8 +16,8 @@ class P2pSwapsListItem extends StatefulWidget { required this.swap, required this.onTap, required this.onDelete, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _P2pSwapsListItemState(); diff --git a/lib/widgets/modular_widgets/pillar_widgets/create_pillar.dart b/lib/widgets/modular_widgets/pillar_widgets/create_pillar.dart index c05533ca..e6392158 100644 --- a/lib/widgets/modular_widgets/pillar_widgets/create_pillar.dart +++ b/lib/widgets/modular_widgets/pillar_widgets/create_pillar.dart @@ -13,8 +13,8 @@ class CreatePillar extends StatefulWidget { const CreatePillar({ required this.onStepperNotificationSeeMorePressed, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _CreatePillarState(); diff --git a/lib/widgets/modular_widgets/pillar_widgets/pillar_collect.dart b/lib/widgets/modular_widgets/pillar_widgets/pillar_collect.dart index d4662c73..70018726 100644 --- a/lib/widgets/modular_widgets/pillar_widgets/pillar_collect.dart +++ b/lib/widgets/modular_widgets/pillar_widgets/pillar_collect.dart @@ -15,8 +15,8 @@ class PillarCollect extends StatefulWidget { const PillarCollect({ required this.pillarRewardsHistoryBloc, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _PillarCollectState(); diff --git a/lib/widgets/modular_widgets/pillar_widgets/pillar_list_widget.dart b/lib/widgets/modular_widgets/pillar_widgets/pillar_list_widget.dart index ddb59ef4..180bbeec 100644 --- a/lib/widgets/modular_widgets/pillar_widgets/pillar_list_widget.dart +++ b/lib/widgets/modular_widgets/pillar_widgets/pillar_list_widget.dart @@ -17,7 +17,7 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PillarListWidget extends StatefulWidget { final String? title; - const PillarListWidget({Key? key, this.title}) : super(key: key); + const PillarListWidget({super.key, this.title}); @override State createState() => _PillarListWidgetState(); diff --git a/lib/widgets/modular_widgets/pillar_widgets/pillar_rewards.dart b/lib/widgets/modular_widgets/pillar_widgets/pillar_rewards.dart index 89bdb140..d072a038 100644 --- a/lib/widgets/modular_widgets/pillar_widgets/pillar_rewards.dart +++ b/lib/widgets/modular_widgets/pillar_widgets/pillar_rewards.dart @@ -6,8 +6,7 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PillarRewards extends StatefulWidget { final PillarRewardsHistoryBloc pillarRewardsHistoryBloc; - const PillarRewards({required this.pillarRewardsHistoryBloc, Key? key}) - : super(key: key); + const PillarRewards({required this.pillarRewardsHistoryBloc, super.key}); @override State createState() => _PillarRewardsState(); diff --git a/lib/widgets/modular_widgets/pillar_widgets/pillar_stepper_container.dart b/lib/widgets/modular_widgets/pillar_widgets/pillar_stepper_container.dart index b7b7c0c7..b72362de 100644 --- a/lib/widgets/modular_widgets/pillar_widgets/pillar_stepper_container.dart +++ b/lib/widgets/modular_widgets/pillar_widgets/pillar_stepper_container.dart @@ -34,7 +34,7 @@ enum PillarStepperStep { } class PillarStepperContainer extends StatefulWidget { - const PillarStepperContainer({Key? key}) : super(key: key); + const PillarStepperContainer({super.key}); @override State createState() { @@ -274,7 +274,7 @@ class _MainPillarState extends State { visible: qsrInfo.deposit > BigInt.zero, child: Container( decoration: BoxDecoration( - color: Theme.of(context).colorScheme.background, + color: Theme.of(context).colorScheme.surface, borderRadius: BorderRadius.circular(6), ), margin: const EdgeInsets.only( diff --git a/lib/widgets/modular_widgets/pillar_widgets/pillar_update_stepper.dart b/lib/widgets/modular_widgets/pillar_widgets/pillar_update_stepper.dart index 24ee9f7b..8abcf6ca 100644 --- a/lib/widgets/modular_widgets/pillar_widgets/pillar_update_stepper.dart +++ b/lib/widgets/modular_widgets/pillar_widgets/pillar_update_stepper.dart @@ -20,7 +20,7 @@ enum PillarUpdateStep { class PillarUpdateStepper extends StatefulWidget { final PillarInfo pillarInfo; - const PillarUpdateStepper(this.pillarInfo, {Key? key}) : super(key: key); + const PillarUpdateStepper(this.pillarInfo, {super.key}); @override State createState() => _PillarUpdateStepperState(); diff --git a/lib/widgets/modular_widgets/plasma_widgets/plasma_list/plasma_list.dart b/lib/widgets/modular_widgets/plasma_widgets/plasma_list/plasma_list.dart index c725594f..d0f0d612 100644 --- a/lib/widgets/modular_widgets/plasma_widgets/plasma_list/plasma_list.dart +++ b/lib/widgets/modular_widgets/plasma_widgets/plasma_list/plasma_list.dart @@ -13,8 +13,7 @@ class PlasmaList extends StatefulWidget { final String? errorText; final PlasmaListBloc bloc; - const PlasmaList({required this.bloc, this.errorText, Key? key}) - : super(key: key); + const PlasmaList({required this.bloc, this.errorText, super.key}); @override State createState() { diff --git a/lib/widgets/modular_widgets/plasma_widgets/plasma_options/plasma_options.dart b/lib/widgets/modular_widgets/plasma_widgets/plasma_options/plasma_options.dart index ca991821..91329af2 100644 --- a/lib/widgets/modular_widgets/plasma_widgets/plasma_options/plasma_options.dart +++ b/lib/widgets/modular_widgets/plasma_widgets/plasma_options/plasma_options.dart @@ -27,8 +27,8 @@ class PlasmaOptions extends StatefulWidget { required this.plasmaListBloc, this.errorText, required this.plasmaStatsResults, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() { diff --git a/lib/widgets/modular_widgets/sentinel_widgets/create_sentinel.dart b/lib/widgets/modular_widgets/sentinel_widgets/create_sentinel.dart index 65b759f2..0d741f83 100644 --- a/lib/widgets/modular_widgets/sentinel_widgets/create_sentinel.dart +++ b/lib/widgets/modular_widgets/sentinel_widgets/create_sentinel.dart @@ -12,8 +12,8 @@ class CreateSentinel extends StatefulWidget { const CreateSentinel({ required this.onStepperNotificationSeeMorePressed, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _CreateSentinelState(); diff --git a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_collect.dart b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_collect.dart index 19487666..c079c805 100644 --- a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_collect.dart +++ b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_collect.dart @@ -15,8 +15,8 @@ class SentinelCollect extends StatefulWidget { const SentinelCollect({ required this.sentinelRewardsHistoryBloc, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _SentinelCollectState(); diff --git a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_list_widget.dart b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_list_widget.dart index 58455840..3e48cbcf 100644 --- a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_list_widget.dart +++ b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_list_widget.dart @@ -10,7 +10,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class SentinelListWidget extends StatefulWidget { - const SentinelListWidget({Key? key}) : super(key: key); + const SentinelListWidget({super.key}); @override State createState() => _SentinelListWidgetState(); diff --git a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_rewards.dart b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_rewards.dart index 8fe010c6..0409c1fb 100644 --- a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_rewards.dart +++ b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_rewards.dart @@ -8,8 +8,8 @@ class SentinelRewards extends StatefulWidget { const SentinelRewards({ required this.sentinelRewardsHistoryBloc, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() { diff --git a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_stepper_container.dart b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_stepper_container.dart index e183e75c..3de109f9 100644 --- a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_stepper_container.dart +++ b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_stepper_container.dart @@ -30,7 +30,7 @@ enum SentinelStepperStep { } class SentinelStepperContainer extends StatefulWidget { - const SentinelStepperContainer({Key? key}) : super(key: key); + const SentinelStepperContainer({super.key}); @override State createState() { @@ -246,7 +246,7 @@ class _MainSentinelState extends State { visible: qsrInfo.deposit > BigInt.zero, child: Container( decoration: BoxDecoration( - color: Theme.of(context).colorScheme.background, + color: Theme.of(context).colorScheme.surface, borderRadius: BorderRadius.circular(6), ), margin: const EdgeInsets.only( diff --git a/lib/widgets/modular_widgets/settings_widgets/account_chain_stats.dart b/lib/widgets/modular_widgets/settings_widgets/account_chain_stats.dart index 3ca4fdcf..468c77cc 100644 --- a/lib/widgets/modular_widgets/settings_widgets/account_chain_stats.dart +++ b/lib/widgets/modular_widgets/settings_widgets/account_chain_stats.dart @@ -17,8 +17,8 @@ class AccountChainStatsWidget extends StatefulWidget { const AccountChainStatsWidget({ required this.accountChainStatsBloc, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() { diff --git a/lib/widgets/modular_widgets/settings_widgets/addresses.dart b/lib/widgets/modular_widgets/settings_widgets/addresses.dart index eacabb3e..4736985f 100644 --- a/lib/widgets/modular_widgets/settings_widgets/addresses.dart +++ b/lib/widgets/modular_widgets/settings_widgets/addresses.dart @@ -18,8 +18,8 @@ class Addresses extends StatefulWidget { const Addresses({ required this.accountChainStatsBloc, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() { diff --git a/lib/widgets/modular_widgets/settings_widgets/backup.dart b/lib/widgets/modular_widgets/settings_widgets/backup.dart index 2055e3ab..3c67f1ee 100644 --- a/lib/widgets/modular_widgets/settings_widgets/backup.dart +++ b/lib/widgets/modular_widgets/settings_widgets/backup.dart @@ -6,7 +6,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class BackupWidget extends StatefulWidget { - const BackupWidget({Key? key}) : super(key: key); + const BackupWidget({super.key}); @override State createState() => _BackupWidgetState(); diff --git a/lib/widgets/modular_widgets/settings_widgets/display.dart b/lib/widgets/modular_widgets/settings_widgets/display.dart index b22dfd10..63a5f396 100644 --- a/lib/widgets/modular_widgets/settings_widgets/display.dart +++ b/lib/widgets/modular_widgets/settings_widgets/display.dart @@ -23,7 +23,7 @@ enum LocaleType { } class DisplayWidget extends StatefulWidget { - const DisplayWidget({Key? key}) : super(key: key); + const DisplayWidget({super.key}); @override State createState() => _DisplayWidget(); diff --git a/lib/widgets/modular_widgets/settings_widgets/general.dart b/lib/widgets/modular_widgets/settings_widgets/general.dart index 3f3cd382..a4400f67 100644 --- a/lib/widgets/modular_widgets/settings_widgets/general.dart +++ b/lib/widgets/modular_widgets/settings_widgets/general.dart @@ -9,7 +9,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class GeneralWidget extends StatefulWidget { - const GeneralWidget({Key? key}) : super(key: key); + const GeneralWidget({super.key}); @override State createState() { diff --git a/lib/widgets/modular_widgets/settings_widgets/node_management.dart b/lib/widgets/modular_widgets/settings_widgets/node_management.dart index 489f3684..e545c89b 100644 --- a/lib/widgets/modular_widgets/settings_widgets/node_management.dart +++ b/lib/widgets/modular_widgets/settings_widgets/node_management.dart @@ -19,8 +19,8 @@ class NodeManagement extends StatefulWidget { const NodeManagement({ required this.onNodeChangedCallback, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _NodeManagementState(); diff --git a/lib/widgets/modular_widgets/settings_widgets/peers.dart b/lib/widgets/modular_widgets/settings_widgets/peers.dart index 87284fb7..ce0ad654 100644 --- a/lib/widgets/modular_widgets/settings_widgets/peers.dart +++ b/lib/widgets/modular_widgets/settings_widgets/peers.dart @@ -4,7 +4,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PeersWidget extends StatefulWidget { - const PeersWidget({Key? key}) : super(key: key); + const PeersWidget({super.key}); @override State createState() => _PeersWidget(); diff --git a/lib/widgets/modular_widgets/settings_widgets/security.dart b/lib/widgets/modular_widgets/settings_widgets/security.dart index aee0b33d..1fce58e4 100644 --- a/lib/widgets/modular_widgets/settings_widgets/security.dart +++ b/lib/widgets/modular_widgets/settings_widgets/security.dart @@ -28,8 +28,8 @@ class SecurityWidget extends StatefulWidget { const SecurityWidget( this._onChangeAutoLockTime, { required this.onStepperNotificationSeeMorePressed, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() { diff --git a/lib/widgets/modular_widgets/settings_widgets/wallet_options.dart b/lib/widgets/modular_widgets/settings_widgets/wallet_options.dart index 296b6f1d..2d335549 100644 --- a/lib/widgets/modular_widgets/settings_widgets/wallet_options.dart +++ b/lib/widgets/modular_widgets/settings_widgets/wallet_options.dart @@ -12,7 +12,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class WalletOptions extends StatefulWidget { - const WalletOptions({Key? key}) : super(key: key); + const WalletOptions({super.key}); @override State createState() => _WalletOptionsState(); diff --git a/lib/widgets/modular_widgets/staking_widgets/stake_collect.dart b/lib/widgets/modular_widgets/staking_widgets/stake_collect.dart index 9c2ce185..90b8c0cd 100644 --- a/lib/widgets/modular_widgets/staking_widgets/stake_collect.dart +++ b/lib/widgets/modular_widgets/staking_widgets/stake_collect.dart @@ -15,8 +15,8 @@ class StakeCollect extends StatefulWidget { const StakeCollect({ required this.stakingRewardsHistoryBloc, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _StakeCollectState(); diff --git a/lib/widgets/modular_widgets/staking_widgets/staking_list/staking_list.dart b/lib/widgets/modular_widgets/staking_widgets/staking_list/staking_list.dart index acb29063..8ce9f82b 100644 --- a/lib/widgets/modular_widgets/staking_widgets/staking_list/staking_list.dart +++ b/lib/widgets/modular_widgets/staking_widgets/staking_list/staking_list.dart @@ -12,7 +12,7 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class StakingList extends StatefulWidget { final StakingListBloc bloc; - const StakingList(this.bloc, {Key? key}) : super(key: key); + const StakingList(this.bloc, {super.key}); @override State createState() { diff --git a/lib/widgets/modular_widgets/staking_widgets/staking_options/staking_options.dart b/lib/widgets/modular_widgets/staking_widgets/staking_options/staking_options.dart index 69d5f896..cc5d42df 100644 --- a/lib/widgets/modular_widgets/staking_widgets/staking_options/staking_options.dart +++ b/lib/widgets/modular_widgets/staking_widgets/staking_options/staking_options.dart @@ -19,8 +19,8 @@ class StakingOptions extends StatefulWidget { const StakingOptions( this.stakingListViewModel, { - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() { diff --git a/lib/widgets/modular_widgets/staking_widgets/staking_rewards.dart b/lib/widgets/modular_widgets/staking_widgets/staking_rewards.dart index 1e2a4cf2..db3d5865 100644 --- a/lib/widgets/modular_widgets/staking_widgets/staking_rewards.dart +++ b/lib/widgets/modular_widgets/staking_widgets/staking_rewards.dart @@ -8,8 +8,8 @@ class StakingRewards extends StatefulWidget { const StakingRewards({ required this.stakingRewardsHistoryBloc, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() { diff --git a/lib/widgets/modular_widgets/token_widgets/create_token.dart b/lib/widgets/modular_widgets/token_widgets/create_token.dart index f4ee7968..38e3715a 100644 --- a/lib/widgets/modular_widgets/token_widgets/create_token.dart +++ b/lib/widgets/modular_widgets/token_widgets/create_token.dart @@ -9,8 +9,8 @@ class CreateToken extends StatefulWidget { const CreateToken({ required this.onStepperNotificationSeeMorePressed, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() { diff --git a/lib/widgets/modular_widgets/token_widgets/token_balance.dart b/lib/widgets/modular_widgets/token_widgets/token_balance.dart index b5c7f1b0..6ece0033 100644 --- a/lib/widgets/modular_widgets/token_widgets/token_balance.dart +++ b/lib/widgets/modular_widgets/token_widgets/token_balance.dart @@ -7,7 +7,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class TokenBalance extends StatefulWidget { - const TokenBalance({Key? key}) : super(key: key); + const TokenBalance({super.key}); @override State createState() { diff --git a/lib/widgets/modular_widgets/token_widgets/token_card.dart b/lib/widgets/modular_widgets/token_widgets/token_card.dart index a3c7b7b3..f21e71a3 100644 --- a/lib/widgets/modular_widgets/token_widgets/token_card.dart +++ b/lib/widgets/modular_widgets/token_widgets/token_card.dart @@ -32,8 +32,8 @@ class TokenCard extends StatefulWidget { const TokenCard( this.token, this._favoritesCallback, { - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _TokenCardState(); diff --git a/lib/widgets/modular_widgets/token_widgets/token_favorite.dart b/lib/widgets/modular_widgets/token_widgets/token_favorite.dart index 85c238d2..f9fe7608 100644 --- a/lib/widgets/modular_widgets/token_widgets/token_favorite.dart +++ b/lib/widgets/modular_widgets/token_widgets/token_favorite.dart @@ -16,8 +16,8 @@ class TokenFavorite extends StatefulWidget { const TokenFavorite( this.token, this._tokenFavoritesCallback, { - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _TokenFavoriteState(); diff --git a/lib/widgets/modular_widgets/token_widgets/token_map.dart b/lib/widgets/modular_widgets/token_widgets/token_map.dart index ef75db13..98695a8c 100644 --- a/lib/widgets/modular_widgets/token_widgets/token_map.dart +++ b/lib/widgets/modular_widgets/token_widgets/token_map.dart @@ -9,7 +9,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class TokenMap extends StatefulWidget { - const TokenMap({Key? key}) : super(key: key); + const TokenMap({super.key}); @override State createState() { diff --git a/lib/widgets/modular_widgets/token_widgets/token_stepper.dart b/lib/widgets/modular_widgets/token_widgets/token_stepper.dart index 83d03515..1c81cae5 100644 --- a/lib/widgets/modular_widgets/token_widgets/token_stepper.dart +++ b/lib/widgets/modular_widgets/token_widgets/token_stepper.dart @@ -30,7 +30,7 @@ enum TokenStepperStep { } class TokenStepper extends StatefulWidget { - const TokenStepper({Key? key}) : super(key: key); + const TokenStepper({super.key}); @override State createState() { diff --git a/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions.dart b/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions.dart index ab690491..4c0dbc9d 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions.dart @@ -16,9 +16,9 @@ class LatestTransactions extends StatefulWidget { final LatestTransactionsVersion version; const LatestTransactions({ - Key? key, + super.key, this.version = LatestTransactionsVersion.standard, - }) : super(key: key); + }); @override State createState() => _LatestTransactionsState(); diff --git a/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions_transfer_widget.dart b/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions_transfer_widget.dart index 30f40160..b49d8903 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions_transfer_widget.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions_transfer_widget.dart @@ -16,9 +16,9 @@ class LatestTransactions extends StatefulWidget { final LatestTransactionsVersion version; const LatestTransactions({ - Key? key, + super.key, this.version = LatestTransactionsVersion.standard, - }) : super(key: key); + }); @override State createState() => _LatestTransactionsState(); diff --git a/lib/widgets/modular_widgets/transfer_widgets/pending_transactions/pending_transactions.dart b/lib/widgets/modular_widgets/transfer_widgets/pending_transactions/pending_transactions.dart index f72c973d..0db45847 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/pending_transactions/pending_transactions.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/pending_transactions/pending_transactions.dart @@ -14,8 +14,8 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PendingTransactions extends StatefulWidget { const PendingTransactions({ - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _PendingTransactionsState(); diff --git a/lib/widgets/modular_widgets/transfer_widgets/receive/receive_large.dart b/lib/widgets/modular_widgets/transfer_widgets/receive/receive_large.dart index 88adeb04..05ff483a 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/receive/receive_large.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/receive/receive_large.dart @@ -16,10 +16,10 @@ class ReceiveLargeCard extends StatefulWidget { final VoidCallback onCollapseClicked; const ReceiveLargeCard({ - Key? key, + super.key, this.extendIcon, required this.onCollapseClicked, - }) : super(key: key); + }); @override State createState() => _ReceiveLargeCardState(); diff --git a/lib/widgets/modular_widgets/transfer_widgets/receive/receive_medium.dart b/lib/widgets/modular_widgets/transfer_widgets/receive/receive_medium.dart index 75031601..9c5e7b02 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/receive/receive_medium.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/receive/receive_medium.dart @@ -14,8 +14,7 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ReceiveMediumCard extends StatefulWidget { final VoidCallback onExpandClicked; - const ReceiveMediumCard({Key? key, required this.onExpandClicked}) - : super(key: key); + const ReceiveMediumCard({super.key, required this.onExpandClicked}); @override State createState() => _ReceiveMediumCardState(); diff --git a/lib/widgets/modular_widgets/transfer_widgets/receive/receive_small.dart b/lib/widgets/modular_widgets/transfer_widgets/receive/receive_small.dart index d1a9a507..cd10705b 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/receive/receive_small.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/receive/receive_small.dart @@ -8,8 +8,8 @@ class ReceiveSmallCard extends StatefulWidget { const ReceiveSmallCard( this.onPressed, { - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _ReceiveSmallCardState(); diff --git a/lib/widgets/modular_widgets/transfer_widgets/send/send_large.dart b/lib/widgets/modular_widgets/transfer_widgets/send/send_large.dart index 536422a6..080ca2f8 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/send/send_large.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/send/send_large.dart @@ -22,11 +22,11 @@ class SendLargeCard extends StatefulWidget { final VoidCallback? onCollapsePressed; const SendLargeCard({ - Key? key, + super.key, this.cardWidth, this.extendIcon, this.onCollapsePressed, - }) : super(key: key); + }); @override State createState() => _SendLargeCardState(); diff --git a/lib/widgets/modular_widgets/transfer_widgets/send/send_medium.dart b/lib/widgets/modular_widgets/transfer_widgets/send/send_medium.dart index ed4dc6e5..6b671700 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/send/send_medium.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/send/send_medium.dart @@ -21,8 +21,8 @@ class SendMediumCard extends StatefulWidget { const SendMediumCard({ required this.onExpandClicked, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _SendMediumCardState(); diff --git a/lib/widgets/modular_widgets/transfer_widgets/send/send_small.dart b/lib/widgets/modular_widgets/transfer_widgets/send/send_small.dart index bac6ed87..7f41b2cd 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/send/send_small.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/send/send_small.dart @@ -8,8 +8,8 @@ class SendSmallCard extends StatefulWidget { const SendSmallCard( this.onClicked, { - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _SendSmallCardState(); diff --git a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_camera_card.dart b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_camera_card.dart index d61c74eb..fd6d987b 100644 --- a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_camera_card.dart +++ b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_camera_card.dart @@ -16,7 +16,7 @@ const String _kWidgetDescription = 'Scan a WalletConnect QR code using the built-in camera of this device'; class WalletConnectCameraCard extends StatefulWidget { - const WalletConnectCameraCard({Key? key}) : super(key: key); + const WalletConnectCameraCard({super.key}); @override State createState() => diff --git a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_pairing_list_card.dart b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_pairing_list_card.dart index 4a87a9da..c41abf1d 100644 --- a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_pairing_list_card.dart +++ b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_pairing_list_card.dart @@ -17,7 +17,7 @@ const String _kWidgetDescription = 'securely over the Internet'; class WalletConnectPairingsCard extends StatefulWidget { - const WalletConnectPairingsCard({Key? key}) : super(key: key); + const WalletConnectPairingsCard({super.key}); @override State createState() => diff --git a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_qr_card.dart b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_qr_card.dart index c6fa0f36..4bfa2800 100644 --- a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_qr_card.dart +++ b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_qr_card.dart @@ -26,7 +26,7 @@ const String _kWidgetDescription = final screenCapturer = ScreenCapturer.instance; class WalletConnectQrCard extends StatefulWidget { - const WalletConnectQrCard({Key? key}) : super(key: key); + const WalletConnectQrCard({super.key}); @override State createState() => _WalletConnectQrCardState(); @@ -60,7 +60,7 @@ class _WalletConnectQrCardState extends State { width: 130, padding: const EdgeInsets.all(10.0), decoration: BoxDecoration( - color: Theme.of(context).colorScheme.background, + color: Theme.of(context).colorScheme.surface, borderRadius: BorderRadius.circular(15.0), ), child: PrettyQrView.data( diff --git a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_session_list_card.dart b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_session_list_card.dart index 44b097db..d476e316 100644 --- a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_session_list_card.dart +++ b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_session_list_card.dart @@ -13,7 +13,7 @@ const String _kWidgetDescription = 'securely over the Internet'; class WalletConnectSessionsCard extends StatefulWidget { - const WalletConnectSessionsCard({Key? key}) : super(key: key); + const WalletConnectSessionsCard({super.key}); @override State createState() => diff --git a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_uri_card.dart b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_uri_card.dart index a4268130..cca6e9ae 100644 --- a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_uri_card.dart +++ b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_uri_card.dart @@ -10,7 +10,7 @@ const String _kWidgetTitle = 'WalletConnect Link'; const String _kWidgetDescription = 'Paste the WalletConnect link here'; class WalletConnectUriCard extends StatefulWidget { - const WalletConnectUriCard({Key? key}) : super(key: key); + const WalletConnectUriCard({super.key}); @override State createState() => _WalletConnectUriCardState(); diff --git a/lib/widgets/reusable_widgets/accelerator_project_details.dart b/lib/widgets/reusable_widgets/accelerator_project_details.dart index fcb4fd3b..d904e1f6 100644 --- a/lib/widgets/reusable_widgets/accelerator_project_details.dart +++ b/lib/widgets/reusable_widgets/accelerator_project_details.dart @@ -18,8 +18,8 @@ class AcceleratorProjectDetails extends StatelessWidget { this.creationTimestamp, this.acceleratorProjectStatus, this.isPhase = false, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/amount_info_column.dart b/lib/widgets/reusable_widgets/amount_info_column.dart index f703c9dd..985109d4 100644 --- a/lib/widgets/reusable_widgets/amount_info_column.dart +++ b/lib/widgets/reusable_widgets/amount_info_column.dart @@ -6,12 +6,11 @@ class AmountInfoColumn extends Column { final BuildContext context; AmountInfoColumn({ - Key? key, + super.key, required this.context, required this.amount, required this.tokenSymbol, }) : super( - key: key, children: [ Text( tokenSymbol, diff --git a/lib/widgets/reusable_widgets/available_balance.dart b/lib/widgets/reusable_widgets/available_balance.dart index a7b32e2b..47f61ffe 100644 --- a/lib/widgets/reusable_widgets/available_balance.dart +++ b/lib/widgets/reusable_widgets/available_balance.dart @@ -9,8 +9,8 @@ class AvailableBalance extends StatelessWidget { const AvailableBalance( this.token, this.accountInfo, { - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/bullet_point_card.dart b/lib/widgets/reusable_widgets/bullet_point_card.dart index f2f5914d..b01563ad 100644 --- a/lib/widgets/reusable_widgets/bullet_point_card.dart +++ b/lib/widgets/reusable_widgets/bullet_point_card.dart @@ -7,8 +7,8 @@ class BulletPointCard extends StatelessWidget { const BulletPointCard({ required this.bulletPoints, - Key? key, - }) : super(key: key); + super.key, + }); static TextSpan textSpan(String text, {List? children}) { return TextSpan( diff --git a/lib/widgets/reusable_widgets/buttons/elevated_button.dart b/lib/widgets/reusable_widgets/buttons/elevated_button.dart index b2753d8e..2e12462f 100644 --- a/lib/widgets/reusable_widgets/buttons/elevated_button.dart +++ b/lib/widgets/reusable_widgets/buttons/elevated_button.dart @@ -15,8 +15,8 @@ class SyriusElevatedButton extends StatefulWidget { this.icon, this.initialFillColor = AppColors.qsrColor, this.style, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() { diff --git a/lib/widgets/reusable_widgets/buttons/instruction_button.dart b/lib/widgets/reusable_widgets/buttons/instruction_button.dart index f56b652a..f1378f7a 100644 --- a/lib/widgets/reusable_widgets/buttons/instruction_button.dart +++ b/lib/widgets/reusable_widgets/buttons/instruction_button.dart @@ -17,8 +17,8 @@ class InstructionButton extends StatefulWidget { required this.onPressed, this.instructionText, this.loadingText, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _InstructionButtonState(); diff --git a/lib/widgets/reusable_widgets/buttons/material_icon_button.dart b/lib/widgets/reusable_widgets/buttons/material_icon_button.dart index 5f67b3d6..c44f0ff4 100644 --- a/lib/widgets/reusable_widgets/buttons/material_icon_button.dart +++ b/lib/widgets/reusable_widgets/buttons/material_icon_button.dart @@ -18,8 +18,8 @@ class MaterialIconButton extends StatelessWidget { this.hoverColor, this.padding = 8.0, this.materialTapTargetSize = MaterialTapTargetSize.padded, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/buttons/onboarding_button.dart b/lib/widgets/reusable_widgets/buttons/onboarding_button.dart index d3366505..cb63d23a 100644 --- a/lib/widgets/reusable_widgets/buttons/onboarding_button.dart +++ b/lib/widgets/reusable_widgets/buttons/onboarding_button.dart @@ -3,13 +3,10 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class OnboardingButton extends MyOutlinedButton { const OnboardingButton({ - required VoidCallback? onPressed, - required String text, - Key? key, + required super.onPressed, + required String super.text, + super.key, }) : super( - key: key, - onPressed: onPressed, - text: text, minimumSize: const Size(360.0, 40.0), ); } diff --git a/lib/widgets/reusable_widgets/buttons/outlined_button.dart b/lib/widgets/reusable_widgets/buttons/outlined_button.dart index 0083d47c..0a10d0c1 100644 --- a/lib/widgets/reusable_widgets/buttons/outlined_button.dart +++ b/lib/widgets/reusable_widgets/buttons/outlined_button.dart @@ -26,8 +26,8 @@ class MyOutlinedButton extends StatefulWidget { this.textColor, this.padding, required this.onPressed, - Key? key, - }) : super(key: key); + super.key, + }); factory MyOutlinedButton.icon({ required VoidCallback? onPressed, @@ -73,9 +73,9 @@ class MyOutlinedButtonState extends State { ) : null, ).copyWith( - side: MaterialStateProperty.resolveWith( + side: WidgetStateProperty.resolveWith( (states) { - if (states.contains(MaterialState.disabled)) { + if (states.contains(WidgetState.disabled)) { return BorderSide( color: AppColors.lightSecondaryContainer, width: widget.borderWidth, @@ -122,13 +122,10 @@ class _MyOutlinedButtonWithIcon extends MyOutlinedButton { _MyOutlinedButtonWithIcon({ required String label, required Widget icon, - Color? outlineColor, - required VoidCallback? onPressed, - Key? key, + super.outlineColor, + required super.onPressed, + super.key, }) : super( - onPressed: onPressed, - outlineColor: outlineColor, - key: key, child: _MyOutlinedButtonWithIconChild( label: label, icon: icon, diff --git a/lib/widgets/reusable_widgets/buttons/send_payment_button.dart b/lib/widgets/reusable_widgets/buttons/send_payment_button.dart index 7241e5d5..81605815 100644 --- a/lib/widgets/reusable_widgets/buttons/send_payment_button.dart +++ b/lib/widgets/reusable_widgets/buttons/send_payment_button.dart @@ -4,17 +4,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class SendPaymentButton extends LoadingButton { const SendPaymentButton({ - required VoidCallback? onPressed, - required Key key, - String text = 'Send', - Color? outlineColor, - Size minimumSize = const Size(100.0, 40.0), + required super.onPressed, + required super.key, + String super.text = 'Send', + super.outlineColor, + super.minimumSize = const Size(100.0, 40.0), }) : super( - onPressed: onPressed, - text: text, - key: key, - minimumSize: minimumSize, - outlineColor: outlineColor, paddingAroundChild: const EdgeInsets.symmetric( horizontal: 10.0, ), diff --git a/lib/widgets/reusable_widgets/buttons/settings_button.dart b/lib/widgets/reusable_widgets/buttons/settings_button.dart index 68113888..d08d7cbb 100644 --- a/lib/widgets/reusable_widgets/buttons/settings_button.dart +++ b/lib/widgets/reusable_widgets/buttons/settings_button.dart @@ -1,17 +1,13 @@ -import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_theme.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class SettingsButton extends MyOutlinedButton { const SettingsButton({ - required VoidCallback? onPressed, - required String text, - Key? key, + required super.onPressed, + required String super.text, + super.key, }) : super( - key: key, - onPressed: onPressed, - text: text, textStyle: kBodyMediumTextStyle, minimumSize: kSettingsButtonMinSize, ); diff --git a/lib/widgets/reusable_widgets/buttons/stepper_button.dart b/lib/widgets/reusable_widgets/buttons/stepper_button.dart index 9df760cd..727bb861 100644 --- a/lib/widgets/reusable_widgets/buttons/stepper_button.dart +++ b/lib/widgets/reusable_widgets/buttons/stepper_button.dart @@ -3,18 +3,13 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class StepperButton extends MyOutlinedButton { const StepperButton({ - required VoidCallback? onPressed, - String? text, - Color? outlineColor, - Widget? child, - Key? key, + required super.onPressed, + super.text, + super.outlineColor, + super.child, + super.key, }) : super( - key: key, - onPressed: onPressed, - text: text, - outlineColor: outlineColor, minimumSize: const Size(120.0, 40.0), - child: child, ); factory StepperButton.icon({ @@ -36,12 +31,9 @@ class _MyStepperButtonWithIcon extends StepperButton { _MyStepperButtonWithIcon({ required String label, required IconData iconData, - required VoidCallback onPressed, + required VoidCallback super.onPressed, required BuildContext context, - Color? outlineColor, }) : super( - onPressed: onPressed, - outlineColor: outlineColor, child: _MyStepperButtonWithIconChild( label: label, iconData: iconData, diff --git a/lib/widgets/reusable_widgets/buttons/transfer_toggle_card_size_button.dart b/lib/widgets/reusable_widgets/buttons/transfer_toggle_card_size_button.dart index ceeeab76..eef17f71 100644 --- a/lib/widgets/reusable_widgets/buttons/transfer_toggle_card_size_button.dart +++ b/lib/widgets/reusable_widgets/buttons/transfer_toggle_card_size_button.dart @@ -10,8 +10,8 @@ class TransferToggleCardSizeButton extends StatelessWidget { const TransferToggleCardSizeButton({ required this.onPressed, required this.iconData, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/cancel_timer.dart b/lib/widgets/reusable_widgets/cancel_timer.dart index 578dcc1b..00ac3621 100644 --- a/lib/widgets/reusable_widgets/cancel_timer.dart +++ b/lib/widgets/reusable_widgets/cancel_timer.dart @@ -11,8 +11,8 @@ class CancelTimer extends StatefulWidget { this.timerDuration, this.borderColor, { required this.onTimeFinishedCallback, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _CancelTimerState(); diff --git a/lib/widgets/reusable_widgets/chart/chart_legend.dart b/lib/widgets/reusable_widgets/chart/chart_legend.dart index cd3e263e..53b6647b 100644 --- a/lib/widgets/reusable_widgets/chart/chart_legend.dart +++ b/lib/widgets/reusable_widgets/chart/chart_legend.dart @@ -9,8 +9,8 @@ class ChartLegend extends StatelessWidget { required this.dotColor, required this.mainText, this.detailsWidget, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/chart/standard_chart.dart b/lib/widgets/reusable_widgets/chart/standard_chart.dart index 15396644..c00d97ce 100644 --- a/lib/widgets/reusable_widgets/chart/standard_chart.dart +++ b/lib/widgets/reusable_widgets/chart/standard_chart.dart @@ -20,8 +20,8 @@ class StandardChart extends StatelessWidget { this.maxX = kStandardChartNumDays - 1, this.lineBarDotSymbol = '', this.convertLeftSideTitlesToInt = false, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { @@ -42,7 +42,7 @@ class StandardChart extends StatelessWidget { tooltipPadding: const EdgeInsets.all(4.0), tooltipRoundedRadius: 6.0, getTooltipColor: (LineBarSpot lineBarSpot) => - Theme.of(context).colorScheme.background, + Theme.of(context).colorScheme.surface, getTooltipItems: (touchedSpots) { return touchedSpots.map( (LineBarSpot touchedSpot) { diff --git a/lib/widgets/reusable_widgets/context_menu_region.dart b/lib/widgets/reusable_widgets/context_menu_region.dart index f5f7b305..e9f7e445 100644 --- a/lib/widgets/reusable_widgets/context_menu_region.dart +++ b/lib/widgets/reusable_widgets/context_menu_region.dart @@ -10,10 +10,10 @@ typedef ContextMenuBuilder = Widget Function( class ContextMenuRegion extends StatefulWidget { /// Creates an instance of [ContextMenuRegion]. const ContextMenuRegion({ - Key? key, + super.key, required this.child, required this.contextMenuBuilder, - }) : super(key: key); + }); /// Builds the context menu. final ContextMenuBuilder contextMenuBuilder; diff --git a/lib/widgets/reusable_widgets/custom_expandable_panel.dart b/lib/widgets/reusable_widgets/custom_expandable_panel.dart index bd4f582d..a05954a1 100644 --- a/lib/widgets/reusable_widgets/custom_expandable_panel.dart +++ b/lib/widgets/reusable_widgets/custom_expandable_panel.dart @@ -9,8 +9,8 @@ class CustomExpandablePanel extends StatefulWidget { const CustomExpandablePanel( this.header, this.expandedChild, { - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _CustomExpandablePanelState(); diff --git a/lib/widgets/reusable_widgets/custom_material_stepper.dart b/lib/widgets/reusable_widgets/custom_material_stepper.dart index b45313b7..8e7c6aa0 100644 --- a/lib/widgets/reusable_widgets/custom_material_stepper.dart +++ b/lib/widgets/reusable_widgets/custom_material_stepper.dart @@ -114,7 +114,7 @@ class Stepper extends StatefulWidget { /// /// The [steps], [type], and [currentStep] arguments must not be null. const Stepper({ - Key? key, + super.key, required this.steps, this.physics, this.type = StepperType.vertical, @@ -124,8 +124,7 @@ class Stepper extends StatefulWidget { this.onStepCancel, this.controlsBuilder, this.activeColor = AppColors.znnColor, - }) : assert(0 <= currentStep && currentStep < steps.length), - super(key: key); + }) : assert(0 <= currentStep && currentStep < steps.length); /// The color of the circle next to the name of the step when the step /// is selected or completed @@ -526,8 +525,8 @@ class _StepperState extends State with TickerProviderStateMixin { key: _keys[i], children: [ InkWell( - overlayColor: MaterialStateProperty.resolveWith((states) => - states.contains(MaterialState.hovered) + overlayColor: WidgetStateProperty.resolveWith((states) => + states.contains(WidgetState.hovered) ? Colors.transparent : null), onTap: widget.steps[i].state != StepState.disabled diff --git a/lib/widgets/reusable_widgets/custom_slider.dart b/lib/widgets/reusable_widgets/custom_slider.dart index fa4f8eff..35219b9e 100644 --- a/lib/widgets/reusable_widgets/custom_slider.dart +++ b/lib/widgets/reusable_widgets/custom_slider.dart @@ -162,8 +162,8 @@ class CustomSlider extends StatefulWidget { required this.callback, this.min = 1.0, this.activeColor = AppColors.znnColor, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _CustomSliderState(); diff --git a/lib/widgets/reusable_widgets/custom_table.dart b/lib/widgets/reusable_widgets/custom_table.dart index fb9fda09..70356e28 100644 --- a/lib/widgets/reusable_widgets/custom_table.dart +++ b/lib/widgets/reusable_widgets/custom_table.dart @@ -20,8 +20,8 @@ class CustomTable extends StatefulWidget { this.headerColumns, this.onShowMoreButtonPressed, this.onRowTappedCallback, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _CustomTableState(); @@ -175,8 +175,8 @@ class CustomHeaderColumn extends StatelessWidget { this.onSortArrowsPressed, this.contentAlign = MainAxisAlignment.start, this.flex = 1, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { @@ -213,12 +213,12 @@ class CustomTableCell extends StatelessWidget { const CustomTableCell( this.child, { this.flex = 1, - Key? key, - }) : super(key: key); + super.key, + }); CustomTableCell.tooltipWithMarquee( Address address, { - Key? key, + super.key, TextStyle? textStyle, this.flex = 1, Color textColor = AppColors.subtitleColor, @@ -252,12 +252,11 @@ class CustomTableCell extends StatelessWidget { width: 10.0, ), ], - ), - super(key: key); + ); CustomTableCell.withMarquee( String text, { - Key? key, + super.key, bool showCopyToClipboardIcon = true, TextStyle? textStyle, this.flex = 1, @@ -296,13 +295,12 @@ class CustomTableCell extends StatelessWidget { ), ), ], - ), - super(key: key); + ); CustomTableCell.tooltipWithText( BuildContext context, Address? address, { - Key? key, + super.key, bool showCopyToClipboardIcon = false, TextStyle? textStyle, this.flex = 1, @@ -339,13 +337,12 @@ class CustomTableCell extends StatelessWidget { ), ), ], - ), - super(key: key); + ); CustomTableCell.withText( BuildContext context, String text, { - Key? key, + super.key, bool showCopyToClipboardIcon = false, TextStyle? textStyle, this.flex = 1, @@ -378,8 +375,7 @@ class CustomTableCell extends StatelessWidget { ), ), ], - ), - super(key: key); + ); @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/dialogs.dart b/lib/widgets/reusable_widgets/dialogs.dart index 4a087eaa..26012994 100644 --- a/lib/widgets/reusable_widgets/dialogs.dart +++ b/lib/widgets/reusable_widgets/dialogs.dart @@ -26,7 +26,7 @@ showWarningDialog({ Navigator.pop(context); }, style: const ButtonStyle( - backgroundColor: MaterialStatePropertyAll(Colors.amber), + backgroundColor: WidgetStatePropertyAll(Colors.amber), ), child: Text( 'Cancel', @@ -40,7 +40,7 @@ showWarningDialog({ Navigator.pop(context); }, style: const ButtonStyle( - backgroundColor: MaterialStatePropertyAll(Colors.orange), + backgroundColor: WidgetStatePropertyAll(Colors.orange), ), child: Text( buttonText.isEmpty ? 'OK' : buttonText, @@ -82,7 +82,7 @@ showDialogWithNoAndYesOptions({ ), TextButton( style: Theme.of(context).textButtonTheme.style!.copyWith( - backgroundColor: MaterialStateColor.resolveWith( + backgroundColor: WidgetStateColor.resolveWith( (states) => AppColors.errorColor), ), onPressed: () { diff --git a/lib/widgets/reusable_widgets/dotted_border_info_widget.dart b/lib/widgets/reusable_widgets/dotted_border_info_widget.dart index d379c9b2..62143213 100644 --- a/lib/widgets/reusable_widgets/dotted_border_info_widget.dart +++ b/lib/widgets/reusable_widgets/dotted_border_info_widget.dart @@ -10,8 +10,8 @@ class DottedBorderInfoWidget extends StatefulWidget { const DottedBorderInfoWidget({ required this.text, this.borderColor = AppColors.znnColor, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _DottedBorderInfoWidgetState(); diff --git a/lib/widgets/reusable_widgets/dropdown/addresses_dropdown.dart b/lib/widgets/reusable_widgets/dropdown/addresses_dropdown.dart index 65546f19..3478c699 100644 --- a/lib/widgets/reusable_widgets/dropdown/addresses_dropdown.dart +++ b/lib/widgets/reusable_widgets/dropdown/addresses_dropdown.dart @@ -10,8 +10,8 @@ class AddressesDropdown extends StatelessWidget { const AddressesDropdown( this._selectedSelfAddress, this.onChangedCallback, { - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/dropdown/basic_dropdown.dart b/lib/widgets/reusable_widgets/dropdown/basic_dropdown.dart index 7ee2fa1c..9d845abf 100644 --- a/lib/widgets/reusable_widgets/dropdown/basic_dropdown.dart +++ b/lib/widgets/reusable_widgets/dropdown/basic_dropdown.dart @@ -14,8 +14,8 @@ class BasicDropdown extends StatelessWidget { this._selectedValue, this._items, this.onChangedCallback, { - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/dropdown/coin_dropdown.dart b/lib/widgets/reusable_widgets/dropdown/coin_dropdown.dart index 389a0170..2cb005b2 100644 --- a/lib/widgets/reusable_widgets/dropdown/coin_dropdown.dart +++ b/lib/widgets/reusable_widgets/dropdown/coin_dropdown.dart @@ -14,8 +14,8 @@ class CoinDropdown extends StatelessWidget { this._availableTokens, this._selectedToken, this._onChangeCallback, { - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/error_widget.dart b/lib/widgets/reusable_widgets/error_widget.dart index b248dd48..804a95d3 100644 --- a/lib/widgets/reusable_widgets/error_widget.dart +++ b/lib/widgets/reusable_widgets/error_widget.dart @@ -8,8 +8,8 @@ class SyriusErrorWidget extends StatelessWidget { const SyriusErrorWidget( this.error, { - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/exchange_rate_widget.dart b/lib/widgets/reusable_widgets/exchange_rate_widget.dart index 9e230865..a077a3ea 100644 --- a/lib/widgets/reusable_widgets/exchange_rate_widget.dart +++ b/lib/widgets/reusable_widgets/exchange_rate_widget.dart @@ -18,8 +18,8 @@ class ExchangeRateWidget extends StatefulWidget { required this.toAmount, required this.toDecimals, required this.toSymbol, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _ExchangeRateWidgetState(); diff --git a/lib/widgets/reusable_widgets/formatted_amount_with_tooltip.dart b/lib/widgets/reusable_widgets/formatted_amount_with_tooltip.dart index 4b449cbc..626527a4 100644 --- a/lib/widgets/reusable_widgets/formatted_amount_with_tooltip.dart +++ b/lib/widgets/reusable_widgets/formatted_amount_with_tooltip.dart @@ -8,12 +8,11 @@ class FormattedAmountWithTooltip extends Tooltip { final Widget Function(String, String) builder; FormattedAmountWithTooltip({ - Key? key, + super.key, required this.amount, required this.tokenSymbol, required this.builder, }) : super( - key: key, message: '$amount $tokenSymbol', child: builder( amount.toNum() == 0 diff --git a/lib/widgets/reusable_widgets/icons/clear_icon.dart b/lib/widgets/reusable_widgets/icons/clear_icon.dart index da2dd723..c4bc17c9 100644 --- a/lib/widgets/reusable_widgets/icons/clear_icon.dart +++ b/lib/widgets/reusable_widgets/icons/clear_icon.dart @@ -3,12 +3,10 @@ import 'package:flutter_vector_icons/flutter_vector_icons.dart'; class ClearIcon extends RawMaterialButton { ClearIcon({ - Key? key, - required VoidCallback onPressed, + super.key, + required VoidCallback super.onPressed, required BuildContext context, }) : super( - key: key, - onPressed: onPressed, shape: const CircleBorder(), child: Icon( SimpleLineIcons.close, diff --git a/lib/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart b/lib/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart index 4bf0638b..52ba4a87 100644 --- a/lib/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart +++ b/lib/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart @@ -19,8 +19,8 @@ class CopyToClipboardIcon extends StatefulWidget { this.materialTapTargetSize = MaterialTapTargetSize.padded, this.icon = Icons.content_copy, this.padding = const EdgeInsets.all(8.0), - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _CopyToClipboardIcon(); diff --git a/lib/widgets/reusable_widgets/icons/link_icon.dart b/lib/widgets/reusable_widgets/icons/link_icon.dart index db565b39..7c0de633 100644 --- a/lib/widgets/reusable_widgets/icons/link_icon.dart +++ b/lib/widgets/reusable_widgets/icons/link_icon.dart @@ -5,9 +5,8 @@ import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; class LinkIcon extends RawMaterialButton { LinkIcon({ required String url, - Key? key}) + super.key}) : super( - key: key, constraints: const BoxConstraints( minWidth: 40.0, minHeight: 40.0, diff --git a/lib/widgets/reusable_widgets/icons/standard_tooltip_icon.dart b/lib/widgets/reusable_widgets/icons/standard_tooltip_icon.dart index f01f03f8..9f39f374 100644 --- a/lib/widgets/reusable_widgets/icons/standard_tooltip_icon.dart +++ b/lib/widgets/reusable_widgets/icons/standard_tooltip_icon.dart @@ -10,8 +10,8 @@ class StandardTooltipIcon extends StatelessWidget { this.tooltipMessage, this.iconData, { this.iconColor = AppColors.znnColor, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/important_text_container.dart b/lib/widgets/reusable_widgets/important_text_container.dart index 31fc8981..aa6d7be0 100644 --- a/lib/widgets/reusable_widgets/important_text_container.dart +++ b/lib/widgets/reusable_widgets/important_text_container.dart @@ -10,8 +10,8 @@ class ImportantTextContainer extends StatelessWidget { required this.text, this.showBorder = false, this.isSelectable = false, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/infinite_scroll_table.dart b/lib/widgets/reusable_widgets/infinite_scroll_table.dart index b9b9cd8e..b4cd80f9 100644 --- a/lib/widgets/reusable_widgets/infinite_scroll_table.dart +++ b/lib/widgets/reusable_widgets/infinite_scroll_table.dart @@ -24,8 +24,8 @@ class InfiniteScrollTable extends StatefulWidget { this.headerColumns, this.onRowTappedCallback, this.disposeBloc = true, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _InfiniteScrollTableState(); @@ -193,8 +193,8 @@ class InfiniteScrollTableHeaderColumn extends StatelessWidget { this.onSortArrowsPressed, this.contentAlign = MainAxisAlignment.start, this.flex = 1, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { @@ -233,8 +233,8 @@ class InfiniteScrollTableCell extends StatelessWidget { const InfiniteScrollTableCell( this.child, { this.flex = 1, - Key? key, - }) : super(key: key); + super.key, + }); factory InfiniteScrollTableCell.tooltipWithMarquee( Address address, { diff --git a/lib/widgets/reusable_widgets/input_fields/amount_input_field.dart b/lib/widgets/reusable_widgets/input_fields/amount_input_field.dart index 439bf688..0ec58599 100644 --- a/lib/widgets/reusable_widgets/input_fields/amount_input_field.dart +++ b/lib/widgets/reusable_widgets/input_fields/amount_input_field.dart @@ -28,8 +28,8 @@ class AmountInputField extends StatefulWidget { this.initialToken, this.hintText = 'Amount', this.enabled = true, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() { diff --git a/lib/widgets/reusable_widgets/input_fields/amount_suffix_widgets.dart b/lib/widgets/reusable_widgets/input_fields/amount_suffix_widgets.dart index 4466c9e6..910efdc9 100644 --- a/lib/widgets/reusable_widgets/input_fields/amount_suffix_widgets.dart +++ b/lib/widgets/reusable_widgets/input_fields/amount_suffix_widgets.dart @@ -11,8 +11,8 @@ class AmountSuffixWidgets extends StatelessWidget { const AmountSuffixWidgets( this.tokenId, { this.onMaxPressed, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { @@ -39,9 +39,8 @@ class AmountSuffixTokenSymbolWidget extends Container { AmountSuffixTokenSymbolWidget({ required Token token, required BuildContext context, - Key? key, + super.key, }) : super( - key: key, height: kAmountSuffixHeight, width: kAmountSuffixWidth, alignment: Alignment.center, @@ -65,9 +64,8 @@ class AmountSuffixMaxWidget extends InkWell { AmountSuffixMaxWidget({ required VoidCallback onPressed, required BuildContext context, - Key? key, + super.key, }) : super( - key: key, onTap: onPressed, child: Container( height: kAmountSuffixHeight, diff --git a/lib/widgets/reusable_widgets/input_fields/disabled_address_field.dart b/lib/widgets/reusable_widgets/input_fields/disabled_address_field.dart index 30171a32..d32d086f 100644 --- a/lib/widgets/reusable_widgets/input_fields/disabled_address_field.dart +++ b/lib/widgets/reusable_widgets/input_fields/disabled_address_field.dart @@ -9,8 +9,8 @@ class DisabledAddressField extends StatelessWidget { const DisabledAddressField( this._addressController, { this.contentLeftPadding = 8.0, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/input_fields/input_field.dart b/lib/widgets/reusable_widgets/input_fields/input_field.dart index f0f8c1b7..04e36cae 100644 --- a/lib/widgets/reusable_widgets/input_fields/input_field.dart +++ b/lib/widgets/reusable_widgets/input_fields/input_field.dart @@ -51,8 +51,8 @@ class InputField extends StatefulWidget { this.errorBorder, this.focusedBorder, this.focusedErrorBorder, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() { diff --git a/lib/widgets/reusable_widgets/input_fields/labeled_input_container.dart b/lib/widgets/reusable_widgets/input_fields/labeled_input_container.dart index 6ebd72a3..e803c2d1 100644 --- a/lib/widgets/reusable_widgets/input_fields/labeled_input_container.dart +++ b/lib/widgets/reusable_widgets/input_fields/labeled_input_container.dart @@ -10,8 +10,8 @@ class LabeledInputContainer extends StatelessWidget { required this.labelText, required this.inputWidget, this.helpText, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/input_fields/password_input_field.dart b/lib/widgets/reusable_widgets/input_fields/password_input_field.dart index 45ad4a96..380ad9f4 100644 --- a/lib/widgets/reusable_widgets/input_fields/password_input_field.dart +++ b/lib/widgets/reusable_widgets/input_fields/password_input_field.dart @@ -18,8 +18,8 @@ class PasswordInputField extends StatefulWidget { this.onChanged, this.validator, this.errorText, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _PasswordInputFieldState(); diff --git a/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart b/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart index 406f8480..76ba0a2c 100644 --- a/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart +++ b/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart @@ -33,8 +33,8 @@ class CardScaffold extends StatefulWidget { this.titleFontSize, this.titleIcon, this.customItem, - Key? key, - }) : super(key: key); + super.key, + }); @override State> createState() => _CardScaffoldState(); diff --git a/lib/widgets/reusable_widgets/layout_scaffold/widget_animator.dart b/lib/widgets/reusable_widgets/layout_scaffold/widget_animator.dart index 8574d320..dc37c4a3 100644 --- a/lib/widgets/reusable_widgets/layout_scaffold/widget_animator.dart +++ b/lib/widgets/reusable_widgets/layout_scaffold/widget_animator.dart @@ -13,8 +13,8 @@ class WidgetAnimator extends StatefulWidget { this.animationOffset = const Duration(milliseconds: 100), this.duration = const Duration(milliseconds: 300), this.curve = Curves.linear, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _WidgetAnimatorState(); diff --git a/lib/widgets/reusable_widgets/loading_info_text.dart b/lib/widgets/reusable_widgets/loading_info_text.dart index f0666093..1a6e7147 100644 --- a/lib/widgets/reusable_widgets/loading_info_text.dart +++ b/lib/widgets/reusable_widgets/loading_info_text.dart @@ -9,8 +9,8 @@ class LoadingInfoText extends StatelessWidget { const LoadingInfoText({ required this.text, this.tooltipText, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/loading_widget.dart b/lib/widgets/reusable_widgets/loading_widget.dart index 4a66ece8..05241a56 100644 --- a/lib/widgets/reusable_widgets/loading_widget.dart +++ b/lib/widgets/reusable_widgets/loading_widget.dart @@ -10,8 +10,8 @@ class SyriusLoadingWidget extends StatelessWidget { this.size = 50.0, this.strokeWidth = 4.0, this.padding = 4.0, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/modals/base_modal.dart b/lib/widgets/reusable_widgets/modals/base_modal.dart index 955d4826..74721b84 100644 --- a/lib/widgets/reusable_widgets/modals/base_modal.dart +++ b/lib/widgets/reusable_widgets/modals/base_modal.dart @@ -7,11 +7,11 @@ class BaseModal extends StatelessWidget { final Widget child; const BaseModal({ - Key? key, + super.key, required this.title, required this.child, this.subtitle = '', - }) : super(key: key); + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/notification_widget.dart b/lib/widgets/reusable_widgets/notification_widget.dart index 5b92840e..b331c6b0 100644 --- a/lib/widgets/reusable_widgets/notification_widget.dart +++ b/lib/widgets/reusable_widgets/notification_widget.dart @@ -16,8 +16,8 @@ class NotificationWidget extends StatefulWidget { this.onDismissPressed, this.onNewNotificationCallback, this.popBeforeSeeMoreIsPressed = true, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _NotificationWidgetState(); diff --git a/lib/widgets/reusable_widgets/number_animation.dart b/lib/widgets/reusable_widgets/number_animation.dart index 274a4fad..56faaf46 100644 --- a/lib/widgets/reusable_widgets/number_animation.dart +++ b/lib/widgets/reusable_widgets/number_animation.dart @@ -39,7 +39,7 @@ class NumberAnimation extends StatefulWidget { /// constructor NumberAnimation({ - Key? key, + super.key, this.start = 0.0, this.end, this.isInt = false, @@ -52,7 +52,7 @@ class NumberAnimation extends StatefulWidget { this.after = '', this.isLoading = false, this.loadingPlaceHolder = '', - }) : super(key: key) { + }) { if (isLoading == false) { assert(end != null); if (isInt) { diff --git a/lib/widgets/reusable_widgets/plasma_icon.dart b/lib/widgets/reusable_widgets/plasma_icon.dart index 6b51d3b4..fb57bfe6 100644 --- a/lib/widgets/reusable_widgets/plasma_icon.dart +++ b/lib/widgets/reusable_widgets/plasma_icon.dart @@ -8,8 +8,8 @@ class PlasmaIcon extends StatelessWidget { const PlasmaIcon( this.plasmaInfo, { - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/progress_bars.dart b/lib/widgets/reusable_widgets/progress_bars.dart index 5493794b..9740d3dd 100644 --- a/lib/widgets/reusable_widgets/progress_bars.dart +++ b/lib/widgets/reusable_widgets/progress_bars.dart @@ -11,8 +11,8 @@ class PasswordProgressBar extends StatefulWidget { const PasswordProgressBar({ required this.password, required this.passwordKey, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _PasswordProgressBarState(); @@ -99,8 +99,8 @@ class ProgressBar extends StatelessWidget { const ProgressBar({ required this.currentLevel, this.numLevels = 5, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { @@ -147,8 +147,8 @@ class AcceleratorProgressBarSpan extends StatelessWidget { required this.value, required this.color, required this.tooltipMessage, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { @@ -170,8 +170,7 @@ class AcceleratorProgressBar extends StatelessWidget { final BuildContext context; const AcceleratorProgressBar( - {required this.child, required this.context, Key? key}) - : super(key: key); + {required this.child, required this.context, super.key}); @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/receive_qr_image.dart b/lib/widgets/reusable_widgets/receive_qr_image.dart index 8d2fac35..76e07759 100644 --- a/lib/widgets/reusable_widgets/receive_qr_image.dart +++ b/lib/widgets/reusable_widgets/receive_qr_image.dart @@ -32,8 +32,8 @@ class ReceiveQrImage extends StatelessWidget { required this.size, required this.tokenStandard, required this.context, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { @@ -47,7 +47,7 @@ class ReceiveQrImage extends StatelessWidget { padding: const EdgeInsets.all( 10.0, ), - color: Theme.of(context).colorScheme.background, + color: Theme.of(context).colorScheme.surface, child: ContextMenuRegion( contextMenuBuilder: (context, offset) { return AdaptiveTextSelectionToolbar( @@ -63,7 +63,7 @@ class ReceiveQrImage extends StatelessWidget { child: TextButton.icon( icon: Icon( MaterialCommunityIcons.share, - color: Theme.of(context).colorScheme.onBackground, + color: Theme.of(context).colorScheme.onSurface, size: 14, ), onPressed: () { @@ -94,7 +94,7 @@ class ReceiveQrImage extends StatelessWidget { child: TextButton.icon( icon: Icon( Icons.save_alt, - color: Theme.of(context).colorScheme.onBackground, + color: Theme.of(context).colorScheme.onSurface, size: 14, ), onPressed: () { diff --git a/lib/widgets/reusable_widgets/seed/seed_choice.dart b/lib/widgets/reusable_widgets/seed/seed_choice.dart index 8774c417..964fdcc4 100644 --- a/lib/widgets/reusable_widgets/seed/seed_choice.dart +++ b/lib/widgets/reusable_widgets/seed/seed_choice.dart @@ -11,8 +11,8 @@ class SeedChoice extends StatefulWidget { required this.onSeed24Selected, required this.onSeed12Selected, required this.isSeed12Selected, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _SeedChoiceState(); diff --git a/lib/widgets/reusable_widgets/seed/seed_grid.dart b/lib/widgets/reusable_widgets/seed/seed_grid.dart index a2ffe9f4..594a2ac4 100644 --- a/lib/widgets/reusable_widgets/seed/seed_grid.dart +++ b/lib/widgets/reusable_widgets/seed/seed_grid.dart @@ -16,8 +16,8 @@ class SeedGrid extends StatefulWidget { this.isContinueButtonDisabled = false, this.enableSeedInputFields = true, this.onTextFieldChangedCallback, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() { diff --git a/lib/widgets/reusable_widgets/select_file_widget.dart b/lib/widgets/reusable_widgets/select_file_widget.dart index db36d87d..e0ad85d5 100644 --- a/lib/widgets/reusable_widgets/select_file_widget.dart +++ b/lib/widgets/reusable_widgets/select_file_widget.dart @@ -16,8 +16,8 @@ class SelectFileWidget extends StatefulWidget { required this.onPathFoundCallback, this.fileExtension, this.textStyle, - Key? key, - }) : super(key: key); + super.key, + }); @override SelectFileWidgetState createState() => SelectFileWidgetState(); diff --git a/lib/widgets/reusable_widgets/settings_address.dart b/lib/widgets/reusable_widgets/settings_address.dart index 97acf695..fe9a5557 100644 --- a/lib/widgets/reusable_widgets/settings_address.dart +++ b/lib/widgets/reusable_widgets/settings_address.dart @@ -13,8 +13,8 @@ class SettingsAddress extends StatefulWidget { const SettingsAddress({ required this.address, required this.onAddressLabelPressed, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _SettingsAddressState(); diff --git a/lib/widgets/reusable_widgets/settings_node.dart b/lib/widgets/reusable_widgets/settings_node.dart index 0984c228..7eb1dc50 100644 --- a/lib/widgets/reusable_widgets/settings_node.dart +++ b/lib/widgets/reusable_widgets/settings_node.dart @@ -21,8 +21,8 @@ class SettingsNode extends StatefulWidget { required this.onNodePressed, required this.onChangedOrDeletedNode, required this.currentNode, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _SettingsNodeState(); diff --git a/lib/widgets/reusable_widgets/syrius_checkbox.dart b/lib/widgets/reusable_widgets/syrius_checkbox.dart index 1b119d80..4ababfc1 100644 --- a/lib/widgets/reusable_widgets/syrius_checkbox.dart +++ b/lib/widgets/reusable_widgets/syrius_checkbox.dart @@ -3,14 +3,11 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; class SyriusCheckbox extends Checkbox { SyriusCheckbox({ - Key? key, - required Function(bool?) onChanged, - required bool? value, + super.key, + required Function(bool?) super.onChanged, + required super.value, required BuildContext context, }) : super( - key: key, - onChanged: onChanged, - value: value, checkColor: Theme.of(context).scaffoldBackgroundColor, activeColor: AppColors.znnColor, ); diff --git a/lib/widgets/reusable_widgets/tag_widget.dart b/lib/widgets/reusable_widgets/tag_widget.dart index 4aca3b00..f8a8d397 100644 --- a/lib/widgets/reusable_widgets/tag_widget.dart +++ b/lib/widgets/reusable_widgets/tag_widget.dart @@ -15,8 +15,8 @@ class TagWidget extends StatelessWidget { this.onPressed, this.iconData, this.textColor, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/transfer_icon_legend.dart b/lib/widgets/reusable_widgets/transfer_icon_legend.dart index 03680c5f..d32217e0 100644 --- a/lib/widgets/reusable_widgets/transfer_icon_legend.dart +++ b/lib/widgets/reusable_widgets/transfer_icon_legend.dart @@ -5,8 +5,8 @@ class TransferIconLegend extends StatelessWidget { const TransferIconLegend({ required this.legendText, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/tab_children_widgets/accelerator_tab_child.dart b/lib/widgets/tab_children_widgets/accelerator_tab_child.dart index c7615d16..cb162e8a 100644 --- a/lib/widgets/tab_children_widgets/accelerator_tab_child.dart +++ b/lib/widgets/tab_children_widgets/accelerator_tab_child.dart @@ -12,8 +12,8 @@ class AcceleratorTabChild extends StatelessWidget { const AcceleratorTabChild({ required this.onStepperNotificationSeeMorePressed, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart index ec823fe4..da5b75cf 100644 --- a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart +++ b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart @@ -12,7 +12,7 @@ class DashboardTabChild extends StatefulWidget { bool redirectWithReceiveContainerLarge, })? changePage; - const DashboardTabChild({Key? key, this.changePage}) : super(key: key); + const DashboardTabChild({super.key, this.changePage}); @override State createState() => _DashboardTabChildState(); diff --git a/lib/widgets/tab_children_widgets/help_tab_child.dart b/lib/widgets/tab_children_widgets/help_tab_child.dart index 3536ac8a..907ed1bd 100644 --- a/lib/widgets/tab_children_widgets/help_tab_child.dart +++ b/lib/widgets/tab_children_widgets/help_tab_child.dart @@ -3,7 +3,7 @@ import 'package:layout/layout.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class HelpTabChild extends StatelessWidget { - const HelpTabChild({Key? key}) : super(key: key); + const HelpTabChild({super.key}); @override Widget build(BuildContext context) { diff --git a/lib/widgets/tab_children_widgets/lock_tab_child.dart b/lib/widgets/tab_children_widgets/lock_tab_child.dart index 8f23c260..7bd8fb03 100644 --- a/lib/widgets/tab_children_widgets/lock_tab_child.dart +++ b/lib/widgets/tab_children_widgets/lock_tab_child.dart @@ -21,8 +21,7 @@ class LockTabChild extends StatefulWidget { final Function() afterInitCallback; const LockTabChild(this.afterUnlockCallback, this.afterInitCallback, - {Key? key}) - : super(key: key); + {super.key}); @override State createState() => _LockTabChildState(); diff --git a/lib/widgets/tab_children_widgets/notifications_tab_child.dart b/lib/widgets/tab_children_widgets/notifications_tab_child.dart index 73e510c7..936b415f 100644 --- a/lib/widgets/tab_children_widgets/notifications_tab_child.dart +++ b/lib/widgets/tab_children_widgets/notifications_tab_child.dart @@ -9,7 +9,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/icons/clear import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class NotificationsTabChild extends StatefulWidget { - const NotificationsTabChild({Key? key}) : super(key: key); + const NotificationsTabChild({super.key}); @override State createState() => _NotificationsTabChildState(); diff --git a/lib/widgets/tab_children_widgets/p2p_swap_tab_child.dart b/lib/widgets/tab_children_widgets/p2p_swap_tab_child.dart index ac20e942..54500604 100644 --- a/lib/widgets/tab_children_widgets/p2p_swap_tab_child.dart +++ b/lib/widgets/tab_children_widgets/p2p_swap_tab_child.dart @@ -11,8 +11,8 @@ class P2pSwapTabChild extends StatefulWidget { const P2pSwapTabChild({ required this.onStepperNotificationSeeMorePressed, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => P2pSwapTabChildState(); diff --git a/lib/widgets/tab_children_widgets/pillars_tab_child.dart b/lib/widgets/tab_children_widgets/pillars_tab_child.dart index 4e1b589d..07b2f4d6 100644 --- a/lib/widgets/tab_children_widgets/pillars_tab_child.dart +++ b/lib/widgets/tab_children_widgets/pillars_tab_child.dart @@ -8,8 +8,8 @@ class PillarsTabChild extends StatefulWidget { const PillarsTabChild({ required this.onStepperNotificationSeeMorePressed, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _PillarsTabChildState(); diff --git a/lib/widgets/tab_children_widgets/plasma_tab_child.dart b/lib/widgets/tab_children_widgets/plasma_tab_child.dart index 34a6fb52..5a0c9039 100644 --- a/lib/widgets/tab_children_widgets/plasma_tab_child.dart +++ b/lib/widgets/tab_children_widgets/plasma_tab_child.dart @@ -8,7 +8,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/notifiers/plasma_generated_not import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class PlasmaTabChild extends StatefulWidget { - const PlasmaTabChild({Key? key}) : super(key: key); + const PlasmaTabChild({super.key}); @override State createState() { diff --git a/lib/widgets/tab_children_widgets/sentinels_tab_child.dart b/lib/widgets/tab_children_widgets/sentinels_tab_child.dart index 018f2196..0165c80d 100644 --- a/lib/widgets/tab_children_widgets/sentinels_tab_child.dart +++ b/lib/widgets/tab_children_widgets/sentinels_tab_child.dart @@ -8,8 +8,8 @@ class SentinelsTabChild extends StatefulWidget { const SentinelsTabChild({ required this.onStepperNotificationSeeMorePressed, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _SentinelsTabChildState(); diff --git a/lib/widgets/tab_children_widgets/settings_tab_child.dart b/lib/widgets/tab_children_widgets/settings_tab_child.dart index 2a67efd2..492dd307 100644 --- a/lib/widgets/tab_children_widgets/settings_tab_child.dart +++ b/lib/widgets/tab_children_widgets/settings_tab_child.dart @@ -12,8 +12,8 @@ class SettingsTabChild extends StatefulWidget { this._onChangeAutoLockTime, { required this.onStepperNotificationSeeMorePressed, required this.onNodeChangedCallback, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _SettingsTabChildState(); diff --git a/lib/widgets/tab_children_widgets/staking_tab_child.dart b/lib/widgets/tab_children_widgets/staking_tab_child.dart index f6faf556..6f6c5407 100644 --- a/lib/widgets/tab_children_widgets/staking_tab_child.dart +++ b/lib/widgets/tab_children_widgets/staking_tab_child.dart @@ -6,7 +6,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/notifiers/default_address_noti import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class StakingTabChild extends StatefulWidget { - const StakingTabChild({Key? key}) : super(key: key); + const StakingTabChild({super.key}); @override State createState() { diff --git a/lib/widgets/tab_children_widgets/tokens_tab_child.dart b/lib/widgets/tab_children_widgets/tokens_tab_child.dart index c586af38..61cb149b 100644 --- a/lib/widgets/tab_children_widgets/tokens_tab_child.dart +++ b/lib/widgets/tab_children_widgets/tokens_tab_child.dart @@ -7,8 +7,8 @@ class TokensTabChild extends StatelessWidget { const TokensTabChild({ required this.onStepperNotificationSeeMorePressed, - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/tab_children_widgets/transfer_tab_child.dart b/lib/widgets/tab_children_widgets/transfer_tab_child.dart index 5e7ad643..b30023c7 100644 --- a/lib/widgets/tab_children_widgets/transfer_tab_child.dart +++ b/lib/widgets/tab_children_widgets/transfer_tab_child.dart @@ -9,10 +9,10 @@ class TransferTabChild extends StatefulWidget { DimensionCard receiveCard; TransferTabChild({ - Key? key, + super.key, this.sendCard = DimensionCard.medium, this.receiveCard = DimensionCard.medium, - }) : super(key: key); + }); @override State createState() => _TransferTabChildState(); diff --git a/lib/widgets/tab_children_widgets/wallet_connect_tab_child.dart b/lib/widgets/tab_children_widgets/wallet_connect_tab_child.dart index f82a8584..290dc247 100644 --- a/lib/widgets/tab_children_widgets/wallet_connect_tab_child.dart +++ b/lib/widgets/tab_children_widgets/wallet_connect_tab_child.dart @@ -3,7 +3,7 @@ import 'package:layout/layout.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class WalletConnectTabChild extends StatelessWidget { - const WalletConnectTabChild({Key? key}) : super(key: key); + const WalletConnectTabChild({super.key}); @override Widget build(BuildContext context) { From 5f6a0ea6fca4a86592bc34f101a084488f0f3319 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Thu, 17 Oct 2024 23:36:51 +0300 Subject: [PATCH 014/102] fix: Use the super parameters --- lib/model/p2p_swap/htlc_swap.dart | 62 +++++++++++-------------------- 1 file changed, 21 insertions(+), 41 deletions(-) diff --git a/lib/model/p2p_swap/htlc_swap.dart b/lib/model/p2p_swap/htlc_swap.dart index 941198a5..4520539c 100644 --- a/lib/model/p2p_swap/htlc_swap.dart +++ b/lib/model/p2p_swap/htlc_swap.dart @@ -10,54 +10,34 @@ class HtlcSwap extends P2pSwap { String? preimage; HtlcSwap({ - required id, - required chainId, - required type, - required direction, - required selfAddress, - required counterpartyAddress, - required fromAmount, - required fromTokenStandard, - required fromSymbol, - required fromDecimals, - required fromChain, - required toChain, - required startTime, - required state, - toAmount, - toTokenStandard, - toSymbol, - toDecimals, required this.hashLock, required this.initialHtlcId, required this.initialHtlcExpirationTime, required this.hashType, + required super.id, + required super.chainId, + required super.type, + required super.direction, + required super.selfAddress, + required super.counterpartyAddress, + required super.fromAmount, + required super.fromTokenStandard, + required super.fromSymbol, + required super.fromDecimals, + required super.fromChain, + required super.toChain, + required super.startTime, + required super.state, + super.toAmount, + super.toDecimals, + super.toSymbol, + super.toTokenStandard, this.counterHtlcId, this.counterHtlcExpirationTime, this.preimage, - }) : super( - id: id, - chainId: chainId, - type: type, - mode: P2pSwapMode.htlc, - direction: direction, - selfAddress: selfAddress, - counterpartyAddress: counterpartyAddress, - fromAmount: fromAmount, - fromTokenStandard: fromTokenStandard, - fromSymbol: fromSymbol, - fromDecimals: fromDecimals, - fromChain: fromChain, - toChain: toChain, - startTime: startTime, - state: state, - toAmount: toAmount, - toTokenStandard: toTokenStandard, - toSymbol: toSymbol, - toDecimals: toDecimals, - ); + }) : super(mode: P2pSwapMode.htlc); - HtlcSwap.fromJson(Map json) + HtlcSwap.fromJson(super.json) : hashLock = json['hashLock'], initialHtlcId = json['initialHtlcId'], initialHtlcExpirationTime = json['initialHtlcExpirationTime'], @@ -65,7 +45,7 @@ class HtlcSwap extends P2pSwap { counterHtlcId = json['counterHtlcId'], counterHtlcExpirationTime = json['counterHtlcExpirationTime'], preimage = json['preimage'], - super.fromJson(json); + super.fromJson(); @override Map toJson() { From 46780745140a4dce1766db59ca5b4011d40e5af8 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Fri, 18 Oct 2024 10:06:57 +0300 Subject: [PATCH 015/102] refactor: Replace deprecated methods or classes --- lib/main.dart | 4 ++-- lib/main_dev.dart | 4 ++-- .../new_wallet/new_wallet_confirm_seed_screen.dart | 6 +++--- lib/utils/notifiers/text_scaling_notifier.dart | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 5921b7b1..cdacaf88 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -308,9 +308,9 @@ class _MyAppState extends State with WindowListener, TrayListener { child: MouseRegion( onEnter: (_) => lockBloc.addEvent(LockEvent.resetTimer), onExit: (_) => lockBloc.addEvent(LockEvent.resetTimer), - child: RawKeyboardListener( + child: KeyboardListener( focusNode: FocusNode(), - onKey: (RawKeyEvent event) { + onKeyEvent: (KeyEvent event) { lockBloc.addEvent(LockEvent.resetTimer); }, child: Layout( diff --git a/lib/main_dev.dart b/lib/main_dev.dart index 5e072612..a59b89fb 100644 --- a/lib/main_dev.dart +++ b/lib/main_dev.dart @@ -301,9 +301,9 @@ class _MyAppState extends State with WindowListener, TrayListener { child: MouseRegion( onEnter: (_) => lockBloc.addEvent(LockEvent.resetTimer), onExit: (_) => lockBloc.addEvent(LockEvent.resetTimer), - child: RawKeyboardListener( + child: KeyboardListener( focusNode: FocusNode(), - onKey: (RawKeyEvent event) { + onKeyEvent: (KeyEvent event) { lockBloc.addEvent(LockEvent.resetTimer); }, child: Layout( diff --git a/lib/screens/onboarding/new_wallet/new_wallet_confirm_seed_screen.dart b/lib/screens/onboarding/new_wallet/new_wallet_confirm_seed_screen.dart index 991db977..26c314a2 100644 --- a/lib/screens/onboarding/new_wallet/new_wallet_confirm_seed_screen.dart +++ b/lib/screens/onboarding/new_wallet/new_wallet_confirm_seed_screen.dart @@ -262,7 +262,7 @@ class _NewWalletConfirmSeedScreenState return _randomIndexes.contains(seedGridElementIndex) || !seedGridElement.isValid; }, - onAccept: (String data) { + onAcceptWithDetails: (DragTargetDetails data) { var element = _seedGridElements[seedGridElementIndex]; var i = -1; if (element.word != '') { @@ -276,14 +276,14 @@ class _NewWalletConfirmSeedScreenState } } i = -1; - while ((i = widget.seedWords.indexOf(data, i + 1)) != -1) { + while ((i = widget.seedWords.indexOf(data.data, i + 1)) != -1) { if (!_foundMissingRandomElementsIndexes.contains(i) && _randomIndexes.contains(i)) { _foundMissingRandomElementsIndexes.add(i); break; } } - element.word = data; + element.word = data.data; setState(() { _textCursor = seedGridElementIndex; }); diff --git a/lib/utils/notifiers/text_scaling_notifier.dart b/lib/utils/notifiers/text_scaling_notifier.dart index 4ba13161..ddfa321e 100644 --- a/lib/utils/notifiers/text_scaling_notifier.dart +++ b/lib/utils/notifiers/text_scaling_notifier.dart @@ -15,7 +15,7 @@ class TextScalingNotifier extends ChangeNotifier { getTextScaleFactor(BuildContext context) { switch (_currentTextScaling) { case TextScaling.system: - return MediaQuery.of(context).textScaleFactor; + return MediaQuery.of(context).textScaler.scale(1); case TextScaling.normal: return 1.0; case TextScaling.small: From e82d7d5e531ff7281bdfe37757f2c8f833d62694 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Fri, 18 Oct 2024 13:51:46 +0300 Subject: [PATCH 016/102] feat: Use very_good_analysis for linter rules and solve some issues with dart fix --apply --- analysis_options.yaml | 47 +---- lib/blocs/accelerator/accelerator.dart | 1 - .../accelerator/accelerator_balance_bloc.dart | 2 +- lib/blocs/accelerator/create_phase_bloc.dart | 8 +- .../accelerator/create_project_bloc.dart | 8 +- lib/blocs/accelerator/project_list_bloc.dart | 47 +++-- .../project_vote_breakdown_bloc.dart | 2 +- .../accelerator/submit_donation_bloc.dart | 10 +- lib/blocs/accelerator/update_phase_bloc.dart | 10 +- lib/blocs/accelerator/vote_project_bloc.dart | 10 +- lib/blocs/auto_receive_tx_worker.dart | 20 +-- lib/blocs/auto_unlock_htlc_worker.dart | 8 +- lib/blocs/base_bloc.dart | 2 +- .../base_bloc_for_reloading_indicator.dart | 2 +- lib/blocs/base_bloc_with_refresh_mixin.dart | 2 +- lib/blocs/blocs.dart | 9 +- lib/blocs/dashboard/balance_bloc.dart | 8 +- .../dashboard/balance_dashboard_bloc.dart | 2 +- lib/blocs/dashboard/dashboard.dart | 1 - lib/blocs/dashboard/dashboard_base_bloc.dart | 8 +- lib/blocs/dashboard/delegation_bloc.dart | 2 +- lib/blocs/dashboard/dual_coin_stats_bloc.dart | 4 +- lib/blocs/dashboard/pillars_bloc.dart | 2 +- .../dashboard/realtime_statistics_bloc.dart | 14 +- lib/blocs/dashboard/staking_bloc.dart | 9 +- .../total_hourly_transactions_bloc.dart | 7 +- lib/blocs/hide_widget_status_bloc.dart | 4 +- lib/blocs/infinite_scroll_bloc.dart | 5 +- lib/blocs/key_store_file_bloc.dart | 6 +- lib/blocs/ledger_wallet_file_bloc.dart | 10 +- lib/blocs/lock_bloc.dart | 2 +- lib/blocs/node_sync_status_bloc.dart | 2 +- lib/blocs/notifications_bloc.dart | 6 +- .../htlc_swap/complete_htlc_swap_bloc.dart | 6 +- .../p2p_swap/htlc_swap/htlc_swap_bloc.dart | 2 +- .../htlc_swap/initial_htlc_for_swap_bloc.dart | 27 ++- .../htlc_swap/join_htlc_swap_bloc.dart | 6 +- .../reclaim_htlc_swap_funds_bloc.dart | 6 +- .../recover_htlc_swap_funds_bloc.dart | 2 +- .../htlc_swap/start_htlc_swap_bloc.dart | 8 +- .../p2p_swap/periodic_p2p_swap_base_bloc.dart | 2 +- lib/blocs/pillars/delegate_button_bloc.dart | 6 +- .../pillars/disassemble_pillar_bloc.dart | 6 +- .../pillars/pillar_rewards_history_bloc.dart | 2 +- lib/blocs/pillars/pillars.dart | 1 - lib/blocs/pillars/pillars_deploy_bloc.dart | 8 +- .../pillars/pillars_deposit_qsr_bloc.dart | 6 +- lib/blocs/pillars/pillars_qsr_info_bloc.dart | 6 +- .../pillars/pillars_withdraw_qsr_bloc.dart | 6 +- lib/blocs/pillars/undelegate_button_bloc.dart | 6 +- lib/blocs/pillars/update_pillar_bloc.dart | 8 +- lib/blocs/plasma/cancel_plasma_bloc.dart | 8 +- lib/blocs/plasma/plasma.dart | 1 - lib/blocs/plasma/plasma_list_bloc.dart | 6 +- lib/blocs/plasma/plasma_options_bloc.dart | 6 +- lib/blocs/plasma/plasma_stats_bloc.dart | 4 +- .../sentinels/disassemble_button_bloc.dart | 6 +- .../sentinels/sentinel_deposit_qsr_bloc.dart | 6 +- .../sentinels/sentinel_qsr_info_bloc.dart | 6 +- .../sentinels/sentinel_register_bloc.dart | 6 +- .../sentinel_rewards_history_bloc.dart | 2 +- .../sentinels/sentinel_withdraw_qsr_bloc.dart | 6 +- lib/blocs/sentinels/sentinels.dart | 1 - .../settings/account_chain_stats_bloc.dart | 17 +- lib/blocs/settings/general_stats_bloc.dart | 4 +- lib/blocs/settings/peers_bloc.dart | 2 +- lib/blocs/settings/settings.dart | 1 - lib/blocs/staking/cancel_stake_bloc.dart | 6 +- lib/blocs/staking/staking.dart | 1 - lib/blocs/staking/staking_options_bloc.dart | 8 +- .../staking/staking_rewards_history_bloc.dart | 2 +- lib/blocs/tokens/burn_token_bloc.dart | 8 +- lib/blocs/tokens/issue_token_bloc.dart | 8 +- lib/blocs/tokens/mint_token_bloc.dart | 8 +- lib/blocs/tokens/token_map_bloc.dart | 23 ++- lib/blocs/tokens/tokens.dart | 1 - lib/blocs/tokens/transfer_ownership_bloc.dart | 8 +- .../transfer/receive_transaction_bloc.dart | 4 +- lib/blocs/transfer/send_payment_bloc.dart | 8 +- lib/blocs/transfer/transfer.dart | 1 - .../transfer_widgets_balance_bloc.dart | 8 +- .../wallet_connect/chains/nom_service.dart | 51 +++--- .../wallet_connect_sessions_bloc.dart | 2 +- lib/embedded_node/embedded_node.dart | 30 ++-- lib/handlers/htlc_swaps_handler.dart | 18 +- lib/main.dart | 49 +++--- lib/main_dev.dart | 49 +++--- lib/model/account_chain_stats.dart | 6 +- lib/model/basic_dropdown_item.dart | 4 +- lib/model/block_data.dart | 4 +- lib/model/database/wallet_notification.dart | 29 ++-- lib/model/general_stats.dart | 16 +- lib/model/model.dart | 4 +- lib/model/navigation_arguments.dart | 2 +- lib/model/p2p_swap/htlc_swap.dart | 14 +- lib/model/p2p_swap/p2p_swap.dart | 40 ++--- lib/model/pillars_qsr_info.dart | 4 +- lib/model/plasma_info_wrapper.dart | 4 +- lib/model/sentinels_qsr_info.dart | 4 +- .../dashboard/balance/balance.dart | 4 +- .../balance/cubit/balance_cubit.dart | 6 +- .../dashboard/balance/view/balance_card.dart | 4 +- .../balance/widgets/balance_address.dart | 14 +- .../balance/widgets/balance_chart.dart | 13 +- .../balance/widgets/balance_chart_legend.dart | 4 +- .../balance/widgets/balance_empty.dart | 2 +- .../balance/widgets/balance_error.dart | 2 +- .../balance/widgets/balance_loading.dart | 2 +- .../balance/widgets/balance_populated.dart | 30 ++-- .../balance_dashboard/balance_dashboard.dart | 4 +- .../cubit/balance_dashboard_cubit.dart | 2 +- .../cubit/balance_dashboard_state.dart | 2 +- .../view/balance_dashboard_card.dart | 6 +- .../widgets/balance_dashboard_error.dart | 2 +- .../widgets/balance_dashboard_populated.dart | 2 +- lib/rearchitecture/dashboard/dashboard.dart | 3 +- .../dashboard/dashboard_cubit.dart | 14 +- .../dashboard/dashboard_state.dart | 16 +- .../delegation/cubit/delegation_cubit.dart | 6 +- .../dashboard/delegation/delegation.dart | 4 +- .../delegation/view/delegation_card.dart | 6 +- .../delegation/widgets/delegation_empty.dart | 2 +- .../delegation/widgets/delegation_error.dart | 2 +- .../widgets/delegation_loading.dart | 2 +- .../widgets/delegation_populated.dart | 14 +- .../cubit/dual_coin_stats_cubit.dart | 4 +- .../dual_coin_stats/dual_coin_stats.dart | 4 +- .../view/dual_coin_stats_card.dart | 4 +- .../widgets/dual_coin_stats_chart.dart | 18 +- .../widgets/dual_coin_stats_chart_legend.dart | 6 +- .../dual_coin_stats_chart_legend_item.dart | 2 +- .../widgets/dual_coin_stats_empty.dart | 2 +- .../widgets/dual_coin_stats_error.dart | 2 +- .../widgets/dual_coin_stats_loading.dart | 2 +- .../widgets/dual_coin_stats_populated.dart | 4 +- .../pillars/cubit/pillars_cubit.dart | 5 +- .../pillars/cubit/pillars_state.dart | 2 +- .../dashboard/pillars/pillars.dart | 4 +- .../dashboard/pillars/view/pillars_card.dart | 6 +- .../pillars/widgets/pillars_error.dart | 2 +- .../pillars/widgets/pillars_populated.dart | 2 +- .../cubit/realtime_statistics_cubit.dart | 14 +- .../cubit/realtime_statistics_state.dart | 2 +- .../realtime_statistics.dart | 4 +- .../view/realtime_statistics_card.dart | 4 +- .../widgets/realtime_statistics_error.dart | 2 +- .../realtime_statistics_populated.dart | 2 +- .../sentinels/cubit/sentinels_cubit.dart | 2 +- .../sentinels/cubit/sentinels_state.dart | 2 +- .../dashboard/sentinels/sentinels.dart | 4 +- .../sentinels/view/sentinels_card.dart | 6 +- .../sentinels/widgets/sentinels_error.dart | 2 +- .../widgets/sentinels_populated.dart | 2 +- .../staking/cubit/staking_cubit.dart | 5 +- .../staking/cubit/staking_state.dart | 2 +- .../dashboard/staking/staking.dart | 4 +- .../dashboard/staking/view/staking_card.dart | 6 +- .../staking/widgets/staking_error.dart | 2 +- .../staking/widgets/staking_populated.dart | 2 +- .../total_hourly_transactions_cubit.dart | 7 +- .../total_hourly_transactions_state.dart | 2 +- .../total_hourly_transactions.dart | 4 +- .../view/total_hourly_transactions_card.dart | 6 +- .../total_hourly_transactions_error.dart | 2 +- .../total_hourly_transactions_populated.dart | 2 +- .../change_wallet_password_screen.dart | 12 +- .../development_intialization_screen.dart | 8 +- lib/screens/dump_mnemonic_screen.dart | 4 +- lib/screens/export/export.dart | 1 - .../export/export_wallet_info_screen.dart | 44 ++--- .../export/export_wallet_password_screen.dart | 22 +-- lib/screens/node_management_screen.dart | 33 ++-- .../onboarding/access_wallet_screen.dart | 6 +- .../onboarding/create_key_store_screen.dart | 8 +- .../onboarding/create_ledger_screen.dart | 8 +- .../hardware_wallet/hardware_wallet.dart | 3 +- .../hardware_wallet_device_choice_screen.dart | 60 ++++--- .../hardware_wallet_password_screen.dart | 18 +- .../import_wallet/import_wallet.dart | 1 - .../import_wallet_decrypt_screen.dart | 16 +- .../import_wallet_password_screen.dart | 10 +- .../import_wallet_seed_choice_screen.dart | 10 +- .../onboarding/new_wallet/new_wallet.dart | 1 - .../new_wallet_confirm_seed_screen.dart | 78 ++++----- .../new_wallet_password_screen.dart | 18 +- .../new_wallet_seed_choice_screen.dart | 31 ++-- lib/screens/onboarding/onboarding.dart | 5 +- .../onboarding/wallet_success_screen.dart | 8 +- lib/screens/project_details_screen.dart | 16 +- lib/screens/reset_wallet_screen.dart | 22 +-- lib/screens/screens.dart | 5 +- lib/screens/splash_screen.dart | 18 +- lib/screens/stepper_screen.dart | 14 +- lib/services/htlc_swaps_service.dart | 32 ++-- lib/services/shared_prefs_service.dart | 4 +- lib/services/web3wallet_service.dart | 47 +++-- lib/utils/account_block_utils.dart | 30 ++-- lib/utils/address_utils.dart | 36 ++-- lib/utils/app_colors.dart | 10 +- lib/utils/app_theme.dart | 54 +++--- lib/utils/card/card_data.dart | 4 +- lib/utils/clipboard_utils.dart | 4 +- lib/utils/color_utils.dart | 2 +- lib/utils/constants.dart | 26 +-- lib/utils/device_utils.dart | 4 +- lib/utils/extensions.dart | 8 +- lib/utils/format_utils.dart | 18 +- lib/utils/functions.dart | 12 +- lib/utils/global.dart | 2 +- lib/utils/init_utils.dart | 12 +- lib/utils/input_validators.dart | 10 +- lib/utils/navigation_utils.dart | 6 +- lib/utils/network_utils.dart | 13 +- lib/utils/node_utils.dart | 44 ++--- lib/utils/notifiers/notifiers.dart | 1 - .../notifiers/text_scaling_notifier.dart | 10 +- lib/utils/pair.dart | 4 +- lib/utils/toast_utils.dart | 16 +- lib/utils/utils.dart | 4 +- lib/utils/wallet_file.dart | 60 +++---- lib/utils/wallet_utils.dart | 16 +- lib/utils/widget_utils.dart | 12 +- lib/utils/zts_utils.dart | 2 +- lib/widgets/charts/pillar_rewards_chart.dart | 4 +- lib/widgets/charts/realtime_txs_chart.dart | 12 +- .../charts/sentinel_rewards_chart.dart | 14 +- lib/widgets/charts/staking_rewards_chart.dart | 8 +- lib/widgets/main_app_container.dart | 163 ++++++++---------- .../accelerator_donation_stepper.dart | 37 ++-- .../accelerator_donations.dart | 6 +- .../accelerator_project_list.dart | 22 +-- .../accelerator_project_list_item.dart | 140 ++++++++------- .../accelerator_stats.dart | 22 +-- .../accelerator_widgets/create_phase.dart | 8 +- .../accelerator_widgets/create_project.dart | 6 +- .../phase_creation_stepper.dart | 35 ++-- .../accelerator_widgets/phase_list.dart | 8 +- .../project_creation_stepper.dart | 39 ++--- .../accelerator_widgets/project_list.dart | 24 +-- .../accelerator_widgets/projects_stats.dart | 24 +-- .../update_phase_stepper.dart | 24 +-- .../dashboard_widgets/balance.dart | 37 ++-- .../dashboard_widgets/delegation_stats.dart | 16 +- .../dashboard_widgets/dual_coin_stats.dart | 20 +-- .../dashboard_widgets/pillars.dart | 8 +- .../dashboard_widgets/plasma_stats.dart | 13 +- .../realtime_statistics.dart | 12 +- .../dashboard_widgets/sentinels.dart | 8 +- .../dashboard_widgets/staking.dart | 14 +- .../total_hourly_transactions.dart | 6 +- .../dashboard_widgets/transfer.dart | 24 +-- .../help_widgets/about_card.dart | 26 +-- .../help_widgets/community_card.dart | 9 +- .../p2p_swap_widgets/detail_row.dart | 20 +-- .../p2p_swap_widgets/htlc_card.dart | 70 ++++---- .../htlc_swap_details_widget.dart | 24 +-- .../modals/join_native_swap_modal.dart | 84 +++++---- .../modals/native_p2p_swap_modal.dart | 122 ++++++------- .../modals/p2p_swap_warning_modal.dart | 8 +- .../modals/recover_deposit_modal.dart | 44 ++--- .../modals/start_native_swap_modal.dart | 42 ++--- .../p2p_swap_options_button.dart | 29 ++-- .../p2p_swap_options_card.dart | 32 ++-- .../p2p_swap_widgets/p2p_swaps_card.dart | 34 ++-- .../p2p_swap_widgets/p2p_swaps_list_item.dart | 61 ++++--- .../pillar_widgets/create_pillar.dart | 6 +- .../pillar_widgets/pillar_collect.dart | 9 +- .../pillar_widgets/pillar_list_widget.dart | 62 +++---- .../pillar_widgets/pillar_rewards.dart | 4 +- .../pillar_stepper_container.dart | 127 ++++++-------- .../pillar_widgets/pillar_update_stepper.dart | 43 ++--- .../plasma_list/plasma_list.dart | 23 +-- .../plasma_options/plasma_options.dart | 55 +++--- .../sentinel_widgets/create_sentinel.dart | 8 +- .../sentinel_widgets/sentinel_collect.dart | 12 +- .../sentinel_list_widget.dart | 33 ++-- .../sentinel_widgets/sentinel_rewards.dart | 4 +- .../sentinel_stepper_container.dart | 85 +++++---- .../settings_widgets/account_chain_stats.dart | 40 ++--- .../settings_widgets/addresses.dart | 28 ++- .../settings_widgets/backup.dart | 4 +- .../settings_widgets/display.dart | 20 +-- .../settings_widgets/general.dart | 64 ++++--- .../settings_widgets/node_management.dart | 39 ++--- .../settings_widgets/peers.dart | 4 +- .../settings_widgets/security.dart | 69 ++++---- .../settings_widgets/wallet_options.dart | 12 +- .../staking_widgets/stake_collect.dart | 9 +- .../staking_list/staking_list.dart | 35 ++-- .../staking_options/staking_options.dart | 32 ++-- .../staking_widgets/staking_rewards.dart | 4 +- .../token_widgets/create_token.dart | 12 +- .../token_widgets/token_balance.dart | 10 +- .../token_widgets/token_card.dart | 136 +++++++-------- .../token_widgets/token_favorite.dart | 16 +- .../token_widgets/token_map.dart | 2 +- .../token_widgets/token_stepper.dart | 85 ++++----- .../latest_transactions.dart | 58 +++---- .../latest_transactions_transfer_widget.dart | 53 ++---- .../pending_transactions.dart | 48 ++---- .../receive/receive_large.dart | 25 ++- .../receive/receive_medium.dart | 25 ++- .../receive/receive_small.dart | 9 +- .../transfer_widgets/send/send_large.dart | 62 ++++--- .../transfer_widgets/send/send_medium.dart | 34 ++-- .../transfer_widgets/send/send_small.dart | 11 +- .../wallet_connect_camera_card.dart | 20 +-- .../wallet_connect_pairing_list_card.dart | 12 +- .../wallet_connect_qr_card.dart | 41 +++-- .../wallet_connect_session_list_card.dart | 20 +-- .../wallet_connect_uri_card.dart | 12 +- .../accelerator_project_details.dart | 39 ++--- .../access_wallet_fluid_cell.dart | 23 ++- .../reusable_widgets/amount_info_column.dart | 11 +- .../reusable_widgets/available_balance.dart | 4 +- .../reusable_widgets/bullet_point_card.dart | 20 +-- .../buttons/elevated_button.dart | 18 +- .../buttons/instruction_button.dart | 12 +- .../buttons/loading_button.dart | 45 +++-- .../buttons/material_icon_button.dart | 14 +- .../buttons/onboarding_button.dart | 2 +- .../buttons/outlined_button.dart | 34 ++-- .../buttons/send_payment_button.dart | 7 +- .../buttons/stepper_button.dart | 14 +- .../transfer_toggle_card_size_button.dart | 6 +- .../reusable_widgets/cancel_timer.dart | 14 +- .../reusable_widgets/chart/chart_legend.dart | 9 +- .../chart/standard_chart.dart | 62 +++---- .../chart/standard_line_chart_bar_data.dart | 4 +- .../chart/standard_pie_chart.dart | 13 +- .../reusable_widgets/context_menu_region.dart | 6 +- .../custom_expandable_panel.dart | 10 +- .../custom_material_stepper.dart | 107 ++++++------ .../reusable_widgets/custom_slider.dart | 38 ++-- .../reusable_widgets/custom_table.dart | 59 ++++--- lib/widgets/reusable_widgets/dialogs.dart | 18 +- .../dotted_border_info_widget.dart | 14 +- .../dropdown/addresses_dropdown.dart | 14 +- .../dropdown/basic_dropdown.dart | 16 +- .../dropdown/coin_dropdown.dart | 14 +- .../reusable_widgets/error_widget.dart | 12 +- .../exchange_rate_widget.dart | 30 ++-- .../formatted_amount_with_tooltip.dart | 13 +- .../reusable_widgets/icons/clear_icon.dart | 6 +- .../icons/copy_to_clipboard_icon.dart | 14 +- lib/widgets/reusable_widgets/icons/icons.dart | 2 +- .../reusable_widgets/icons/link_icon.dart | 14 +- .../icons/standard_tooltip_icon.dart | 10 +- .../important_text_container.dart | 19 +- .../infinite_scroll_table.dart | 59 ++++--- .../input_fields/amount_input_field.dart | 28 +-- .../input_fields/amount_suffix_widgets.dart | 4 +- .../input_fields/disabled_address_field.dart | 4 +- .../input_fields/input_field.dart | 55 +++--- .../input_fields/labeled_input_container.dart | 19 +- .../input_fields/password_input_field.dart | 16 +- .../layout_scaffold/card_scaffold.dart | 77 ++++----- .../card_scaffold_without_listener.dart | 59 +++---- .../layout_scaffold/overscroll_remover.dart | 2 +- .../standard_fluid_layout.dart | 25 ++- .../layout_scaffold/widget_animator.dart | 10 +- .../reusable_widgets/loading_info_text.dart | 18 +- .../reusable_widgets/loading_widget.dart | 6 +- .../reusable_widgets/modals/base_modal.dart | 22 ++- .../reusable_widgets/notification_widget.dart | 25 ++- .../reusable_widgets/number_animation.dart | 66 +++---- lib/widgets/reusable_widgets/plasma_icon.dart | 8 +- .../reusable_widgets/progress_bars.dart | 35 ++-- .../reusable_widgets/receive_qr_image.dart | 60 +++---- .../reusable_widgets/reusable_widgets.dart | 14 +- .../reusable_widgets/seed/seed_choice.dart | 32 ++-- .../reusable_widgets/seed/seed_grid.dart | 58 +++---- .../reusable_widgets/select_file_widget.dart | 18 +- .../reusable_widgets/settings_address.dart | 46 ++--- .../reusable_widgets/settings_node.dart | 53 +++--- .../reusable_widgets/stepper_utils.dart | 10 +- .../reusable_widgets/syrius_checkbox.dart | 5 +- lib/widgets/reusable_widgets/tag_widget.dart | 24 +-- .../transfer_icon_legend.dart | 9 +- .../accelerator_tab_child.dart | 4 +- .../dashboard_tab_child.dart | 9 +- .../tab_children_widgets/lock_tab_child.dart | 31 ++-- .../notifications_tab_child.dart | 19 +- .../p2p_swap_tab_child.dart | 4 +- .../pillars_tab_child.dart | 4 +- .../sentinels_tab_child.dart | 4 +- .../settings_tab_child.dart | 10 +- .../staking_tab_child.dart | 2 +- .../tab_children_widgets.dart | 2 +- .../tokens_tab_child.dart | 2 +- .../transfer_tab_child.dart | 4 +- pubspec.lock | 8 + pubspec.yaml | 1 + .../cubit/delegation_cubit_test.dart | 4 +- 394 files changed, 3228 insertions(+), 3605 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index fbd285ef..ef928e17 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,40 +1,9 @@ -# This file configures the analyzer, which statically analyzes Dart code to -# check for errors, warnings, and lints. -# -# The issues identified by the analyzer are surfaced in the UI of Dart-enabled -# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be -# invoked from the command line by running `flutter analyze`. +include: package:very_good_analysis/analysis_options.yaml -# The following line activates a set of recommended lints for Flutter apps, -# packages, and plugins designed to encourage good coding practices. -include: package:flutter_lints/flutter.yaml - -linter: - # The lint rules applied to this project can be customized in the - # section below to disable rules from the `package:flutter_lints/flutter.yaml` - # included above or to enable additional rules. A list of all available lints - # and their documentation is published at - # https://dart-lang.github.io/linter/lints/index.html. - # - # Instead of disabling a lint rule for the entire project in the - # section below, it can also be suppressed for a single line of code - # or a specific dart file by using the `// ignore: name_of_lint` and - # `// ignore_for_file: name_of_lint` syntax on the line or in the file - # producing the lint. - rules: - avoid_print: true # Uncomment to disable the `avoid_print` rule - prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule - cancel_subscriptions: true - close_sinks: true - comment_references: true - one_member_abstracts: true - always_use_package_imports: true - avoid_empty_else: true - avoid_slow_async_io: true - avoid_web_libraries_in_flutter: true - control_flow_in_finally: true - empty_statements: true - depend_on_referenced_packages: true - secure_pubspec_urls: true -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options +analyzer: + language: + # I've disabled it so as to make the code compile without + # strict type-checking + strict-casts: false + strict-inference: false + strict-raw-types: false diff --git a/lib/blocs/accelerator/accelerator.dart b/lib/blocs/accelerator/accelerator.dart index 34be7449..7bdf81ba 100644 --- a/lib/blocs/accelerator/accelerator.dart +++ b/lib/blocs/accelerator/accelerator.dart @@ -1,4 +1,3 @@ -library; export 'accelerator_balance_bloc.dart'; export 'create_phase_bloc.dart'; diff --git a/lib/blocs/accelerator/accelerator_balance_bloc.dart b/lib/blocs/accelerator/accelerator_balance_bloc.dart index e42a2440..81617381 100644 --- a/lib/blocs/accelerator/accelerator_balance_bloc.dart +++ b/lib/blocs/accelerator/accelerator_balance_bloc.dart @@ -8,7 +8,7 @@ class AcceleratorBalanceBloc extends BaseBloc { Future getAcceleratorBalance() async { try { addEvent(null); - AccountInfo accountInfo = await zenon!.ledger.getAccountInfoByAddress( + final accountInfo = await zenon!.ledger.getAccountInfoByAddress( acceleratorAddress, ); if (accountInfo.qsr()! > BigInt.zero || diff --git a/lib/blocs/accelerator/create_phase_bloc.dart b/lib/blocs/accelerator/create_phase_bloc.dart index 905660d5..76b6d47e 100644 --- a/lib/blocs/accelerator/create_phase_bloc.dart +++ b/lib/blocs/accelerator/create_phase_bloc.dart @@ -14,7 +14,7 @@ class CreatePhaseBloc extends BaseBloc { ) async { try { addEvent(null); - AccountBlockTemplate transactionParams = + final transactionParams = zenon!.embedded.accelerator.addPhase( id, name, @@ -25,12 +25,10 @@ class CreatePhaseBloc extends BaseBloc { ); AccountBlockUtils.createAccountBlock(transactionParams, 'create phase') .then( - (block) => addEvent(block), + addEvent, ) .onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/accelerator/create_project_bloc.dart b/lib/blocs/accelerator/create_project_bloc.dart index f56786f9..0077921f 100644 --- a/lib/blocs/accelerator/create_project_bloc.dart +++ b/lib/blocs/accelerator/create_project_bloc.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; @@ -13,7 +15,7 @@ class CreateProjectBloc extends BaseBloc { ) { try { addEvent(null); - AccountBlockTemplate transactionParams = + final transactionParams = zenon!.embedded.accelerator.createProject( name, description, @@ -30,9 +32,7 @@ class CreateProjectBloc extends BaseBloc { addEvent(block); }, ).onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/accelerator/project_list_bloc.dart b/lib/blocs/accelerator/project_list_bloc.dart index ce72805d..31f2e7bd 100644 --- a/lib/blocs/accelerator/project_list_bloc.dart +++ b/lib/blocs/accelerator/project_list_bloc.dart @@ -9,11 +9,6 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ProjectListBloc with RefreshBlocMixin { - List? _allProjects; - - final List selectedProjectsFilterTag = []; - - final PillarInfo? pillarInfo; ProjectListBloc({ required this.pillarInfo, @@ -30,6 +25,11 @@ class ProjectListBloc with RefreshBlocMixin { listenToWsRestart(refreshResults); } + List? _allProjects; + + final List selectedProjectsFilterTag = []; + + final PillarInfo? pillarInfo; void refreshResults() { if (!_onSearchInputChangedSubject.isClosed) { @@ -72,18 +72,17 @@ class ProjectListBloc with RefreshBlocMixin { String? get _searchInputTerm => _onSearchInputChangedSubject.value; Stream> _fetchList( - int pageKey) async* { + int pageKey,) async* { final lastListingState = _onNewListingStateController.value; try { final newItems = await getData(pageKey, _pageSize, _searchInputTerm); final isLastPage = newItems.length < _pageSize; final nextPageKey = isLastPage ? null : pageKey + 1; - List allItems = [ + final allItems = [ ...lastListingState.itemList ?? [], - ...newItems + ...newItems, ]; yield InfiniteScrollBlocListingState( - error: null, nextPageKey: nextPageKey, itemList: allItems, ); @@ -110,15 +109,15 @@ class ProjectListBloc with RefreshBlocMixin { String? searchTerm, ) async { _allProjects ??= (await zenon!.embedded.accelerator.getAll()).list; - List results = []; + var results = []; if (searchTerm != null && searchTerm.isNotEmpty) { results = _filterProjectsBySearchKeyWord(_allProjects!, searchTerm).toList(); } else { results = _allProjects!; } - results = (await _filterProjectsAccordingToPillarInfo( - await _filterProjectsByTags(results))); + results = await _filterProjectsAccordingToPillarInfo( + await _filterProjectsByTags(results),); return results.sublist( pageKey * pageSize, (pageKey + 1) * pageSize <= results.length @@ -133,12 +132,12 @@ class ProjectListBloc with RefreshBlocMixin { projects or all owned projects */ Future> _filterProjectsAccordingToPillarInfo( - Set projectList) async { - bool isPillarAddress = pillarInfo != null; + Set projectList,) async { + final isPillarAddress = pillarInfo != null; if (isPillarAddress) { return projectList.toList(); } else { - List activeProjects = projectList + final activeProjects = projectList .where( (project) => project.status == AcceleratorProjectStatus.active || @@ -154,8 +153,8 @@ class ProjectListBloc with RefreshBlocMixin { } Set _filterProjectsBySearchKeyWord( - List projects, String searchKeyWord) { - var filteredProjects = {}; + List projects, String searchKeyWord,) { + final filteredProjects = {}; filteredProjects.addAll( projects.where( (element) => @@ -217,7 +216,7 @@ class ProjectListBloc with RefreshBlocMixin { if (selectedProjectsFilterTag .contains(AccProjectsFilterTag.onlyAccepted)) { filteredProjects = filteredProjects.where( - (project) => project.status == AcceleratorProjectStatus.active); + (project) => project.status == AcceleratorProjectStatus.active,); } if (selectedProjectsFilterTag .contains(AccProjectsFilterTag.needsVoting)) { @@ -229,7 +228,7 @@ class ProjectListBloc with RefreshBlocMixin { !votedProjectIds!.contains(project.id)) || project.phases.any((phase) => phase.status == AcceleratorProjectStatus.voting && - !votedPhaseIds!.contains(phase.id)), + !votedPhaseIds!.contains(phase.id),), ); } if (selectedProjectsFilterTag @@ -242,7 +241,7 @@ class ProjectListBloc with RefreshBlocMixin { votedProjectIds!.contains(project.id)) || project.phases.any((phase) => phase.status == AcceleratorProjectStatus.voting && - votedPhaseIds!.contains(phase.id)), + votedPhaseIds!.contains(phase.id),), ); } return filteredProjects.toSet(); @@ -252,8 +251,8 @@ class ProjectListBloc with RefreshBlocMixin { } Future> _getVotedProjectIdsByPillar( - Iterable projects) async { - var pillarVotes = await zenon!.embedded.accelerator.getPillarVotes( + Iterable projects,) async { + final pillarVotes = await zenon!.embedded.accelerator.getPillarVotes( pillarInfo!.name, projects.map((e) => e.id.toString()).toList(), ); @@ -261,8 +260,8 @@ class ProjectListBloc with RefreshBlocMixin { } Future> _getVotedPhaseIdsByPillar( - Iterable projects) async { - var pillarVotes = await zenon!.embedded.accelerator.getPillarVotes( + Iterable projects,) async { + final pillarVotes = await zenon!.embedded.accelerator.getPillarVotes( pillarInfo!.name, projects .expand((project) => project.phaseIds) diff --git a/lib/blocs/accelerator/project_vote_breakdown_bloc.dart b/lib/blocs/accelerator/project_vote_breakdown_bloc.dart index cbb897b9..f223e72a 100644 --- a/lib/blocs/accelerator/project_vote_breakdown_bloc.dart +++ b/lib/blocs/accelerator/project_vote_breakdown_bloc.dart @@ -8,7 +8,7 @@ class ProjectVoteBreakdownBloc Future getVoteBreakdown(String? pillarName, Hash projectId) async { try { addEvent(null); - VoteBreakdown voteBreakdown = + final voteBreakdown = await zenon!.embedded.accelerator.getVoteBreakdown( projectId, ); diff --git a/lib/blocs/accelerator/submit_donation_bloc.dart b/lib/blocs/accelerator/submit_donation_bloc.dart index 388c232e..88893755 100644 --- a/lib/blocs/accelerator/submit_donation_bloc.dart +++ b/lib/blocs/accelerator/submit_donation_bloc.dart @@ -12,13 +12,13 @@ class SubmitDonationBloc extends BaseBloc { await _sendDonationBlock(zenon!.embedded.accelerator.donate( znnAmount, kZnnCoin.tokenStandard, - )); + ),); } if (qsrAmount > BigInt.zero) { await _sendDonationBlock(zenon!.embedded.accelerator.donate( qsrAmount, kQsrCoin.tokenStandard, - )); + ),); } } catch (e, stackTrace) { addError(e, stackTrace); @@ -26,7 +26,7 @@ class SubmitDonationBloc extends BaseBloc { } Future _sendDonationBlock( - AccountBlockTemplate transactionParams) async { + AccountBlockTemplate transactionParams,) async { await AccountBlockUtils.createAccountBlock( transactionParams, 'donate for accelerator', @@ -36,9 +36,7 @@ class SubmitDonationBloc extends BaseBloc { addEvent(block); }, ).onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } } diff --git a/lib/blocs/accelerator/update_phase_bloc.dart b/lib/blocs/accelerator/update_phase_bloc.dart index ece973a2..dd03dc5b 100644 --- a/lib/blocs/accelerator/update_phase_bloc.dart +++ b/lib/blocs/accelerator/update_phase_bloc.dart @@ -5,10 +5,10 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class UpdatePhaseBloc extends BaseBloc { void updatePhase(Hash id, String name, String description, String url, - BigInt znnFundsNeeded, BigInt qsrFundsNeeded) { + BigInt znnFundsNeeded, BigInt qsrFundsNeeded,) { try { addEvent(null); - AccountBlockTemplate transactionParams = + final transactionParams = zenon!.embedded.accelerator.updatePhase( id, name, @@ -19,12 +19,10 @@ class UpdatePhaseBloc extends BaseBloc { ); AccountBlockUtils.createAccountBlock(transactionParams, 'update phase') .then( - (block) => addEvent(block), + addEvent, ) .onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/accelerator/vote_project_bloc.dart b/lib/blocs/accelerator/vote_project_bloc.dart index 120dc012..70e510d0 100644 --- a/lib/blocs/accelerator/vote_project_bloc.dart +++ b/lib/blocs/accelerator/vote_project_bloc.dart @@ -8,11 +8,11 @@ class VoteProjectBloc extends BaseBloc { Future voteProject(Hash id, AcceleratorProjectVote vote) async { try { addEvent(null); - PillarInfo pillarInfo = (await zenon!.embedded.pillar.getByOwner( + final pillarInfo = (await zenon!.embedded.pillar.getByOwner( Address.parse(kSelectedAddress!), )) .first; - AccountBlockTemplate transactionParams = + final transactionParams = zenon!.embedded.accelerator.voteByName( id, pillarInfo.name, @@ -23,12 +23,10 @@ class VoteProjectBloc extends BaseBloc { 'vote for project', ) .then( - (block) => addEvent(block), + addEvent, ) .onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/auto_receive_tx_worker.dart b/lib/blocs/auto_receive_tx_worker.dart index e736bb02..dd8c6df0 100644 --- a/lib/blocs/auto_receive_tx_worker.dart +++ b/lib/blocs/auto_receive_tx_worker.dart @@ -23,16 +23,16 @@ class AutoReceiveTxWorker extends BaseBloc { } Future autoReceiveTransactionHash( - Hash currentHash) async { + Hash currentHash,) async { if (!running) { running = true; try { - Address toAddress = + final toAddress = (await zenon!.ledger.getAccountBlockByHash(currentHash))!.toAddress; - AccountBlockTemplate transactionParams = AccountBlockTemplate.receive( + final transactionParams = AccountBlockTemplate.receive( currentHash, ); - AccountBlockTemplate response = + final response = await AccountBlockUtils.createAccountBlock( transactionParams, 'receive transaction', @@ -53,10 +53,10 @@ class AutoReceiveTxWorker extends BaseBloc { } Future autoReceive() async { - if (!sharedPrefsService!.get( + if (sharedPrefsService!.get( kAutoReceiveKey, defaultValue: kAutoReceiveDefaultValue, - )) { + ) == false) { pool.clear(); return; } @@ -64,14 +64,14 @@ class AutoReceiveTxWorker extends BaseBloc { // given priority to send transactions. if (pool.isNotEmpty && !running && !sl().running) { running = true; - Hash currentHash = pool.first; + final currentHash = pool.first; try { - Address toAddress = + final toAddress = (await zenon!.ledger.getAccountBlockByHash(currentHash))!.toAddress; - AccountBlockTemplate transactionParams = AccountBlockTemplate.receive( + final transactionParams = AccountBlockTemplate.receive( currentHash, ); - AccountBlockTemplate response = + final response = await AccountBlockUtils.createAccountBlock( transactionParams, 'receive transaction', diff --git a/lib/blocs/auto_unlock_htlc_worker.dart b/lib/blocs/auto_unlock_htlc_worker.dart index 63e7a644..a5769975 100644 --- a/lib/blocs/auto_unlock_htlc_worker.dart +++ b/lib/blocs/auto_unlock_htlc_worker.dart @@ -27,7 +27,7 @@ class AutoUnlockHtlcWorker extends BaseBloc { Future autoUnlock() async { if (pool.isNotEmpty && !running && kWalletFile != null) { running = true; - Hash currentHash = pool.first; + final currentHash = pool.first; try { final htlc = await zenon!.embedded.htlc.getById(currentHash); final swap = htlcSwapsService! @@ -38,9 +38,9 @@ class AutoUnlockHtlcWorker extends BaseBloc { if (!kDefaultAddressList.contains(htlc.hashLocked.toString())) { throw 'Swap address not in default addresses. Please add the address in the addresses list.'; } - AccountBlockTemplate transactionParams = zenon!.embedded.htlc + final transactionParams = zenon!.embedded.htlc .unlock(htlc.id, FormatUtils.decodeHexString(swap.preimage!)); - AccountBlockTemplate response = + final response = await AccountBlockUtils.createAccountBlock( transactionParams, 'complete swap', @@ -117,6 +117,6 @@ class AutoUnlockHtlcWorker extends BaseBloc { // allowing for it to be retried. void _removeHashFromHashSetAfterDelay(Hash hash) { Future.delayed( - const Duration(minutes: 2), () => processedHashes.remove(hash)); + const Duration(minutes: 2), () => processedHashes.remove(hash),); } } diff --git a/lib/blocs/base_bloc.dart b/lib/blocs/base_bloc.dart index b5bee582..e23c0a41 100644 --- a/lib/blocs/base_bloc.dart +++ b/lib/blocs/base_bloc.dart @@ -15,7 +15,7 @@ abstract class BaseBloc extends BaseViewModel { if (!_controller.isClosed) _sink.add(event); } - void addError(error, stackTrace) { + FutureOr addError(Object error, StackTrace stackTrace) async { Logger('BaseBloc').log(Level.WARNING, 'addError', error, stackTrace); if (!_controller.isClosed) { _sink.addError(error); diff --git a/lib/blocs/base_bloc_for_reloading_indicator.dart b/lib/blocs/base_bloc_for_reloading_indicator.dart index 05a62ebc..a45a52d9 100644 --- a/lib/blocs/base_bloc_for_reloading_indicator.dart +++ b/lib/blocs/base_bloc_for_reloading_indicator.dart @@ -6,12 +6,12 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; abstract class BaseBlocForReloadingIndicator extends BaseBloc with RefreshBlocMixin { - Future getDataAsync(); BaseBlocForReloadingIndicator() { updateStream(); listenToWsRestart(updateStream); } + Future getDataAsync(); Future updateStream() async { try { diff --git a/lib/blocs/base_bloc_with_refresh_mixin.dart b/lib/blocs/base_bloc_with_refresh_mixin.dart index 8e806aac..8d5a1385 100644 --- a/lib/blocs/base_bloc_with_refresh_mixin.dart +++ b/lib/blocs/base_bloc_with_refresh_mixin.dart @@ -6,12 +6,12 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; abstract class BaseBlocWithRefreshMixin extends BaseBloc with RefreshBlocMixin { - Future getDataAsync(); BaseBlocWithRefreshMixin() { updateStream(); listenToWsRestart(updateStream); } + Future getDataAsync(); Future updateStream() async { try { diff --git a/lib/blocs/blocs.dart b/lib/blocs/blocs.dart index e49fb895..af395b05 100644 --- a/lib/blocs/blocs.dart +++ b/lib/blocs/blocs.dart @@ -1,9 +1,10 @@ -library; +export 'accelerator/accelerator.dart'; export 'auto_receive_tx_worker.dart'; export 'base_bloc.dart'; export 'base_bloc_for_reloading_indicator.dart'; export 'base_bloc_with_refresh_mixin.dart'; +export 'dashboard/dashboard.dart'; export 'decrypt_wallet_file_bloc.dart'; export 'hide_widget_status_bloc.dart'; export 'infinite_scroll_bloc.dart'; @@ -12,12 +13,10 @@ export 'ledger_wallet_file_bloc.dart'; export 'lock_bloc.dart'; export 'node_sync_status_bloc.dart'; export 'notifications_bloc.dart'; -export 'pow_generating_status_bloc.dart'; -export 'refresh_bloc_mixin.dart'; -export 'accelerator/accelerator.dart'; -export 'dashboard/dashboard.dart'; export 'pillars/pillars.dart'; export 'plasma/plasma.dart'; +export 'pow_generating_status_bloc.dart'; +export 'refresh_bloc_mixin.dart'; export 'sentinels/sentinels.dart'; export 'settings/settings.dart'; export 'staking/staking.dart'; diff --git a/lib/blocs/dashboard/balance_bloc.dart b/lib/blocs/dashboard/balance_bloc.dart index 69cde008..d4287fdb 100644 --- a/lib/blocs/dashboard/balance_bloc.dart +++ b/lib/blocs/dashboard/balance_bloc.dart @@ -14,15 +14,15 @@ class BalanceBloc extends BaseBloc?> Future getBalanceForAllAddresses() async { try { addEvent(null); - Map addressBalanceMap = {}; - List accountInfoList = await Future.wait( + final addressBalanceMap = {}; + final accountInfoList = await Future.wait( kDefaultAddressList.map( (address) => _getBalancePerAddress( address!, ), ), ); - for (var accountInfo in accountInfoList) { + for (final accountInfo in accountInfoList) { addressBalanceMap[accountInfo.address!] = accountInfo; } addEvent(addressBalanceMap); @@ -32,5 +32,5 @@ class BalanceBloc extends BaseBloc?> } Future _getBalancePerAddress(String address) async => - await zenon!.ledger.getAccountInfoByAddress(Address.parse(address)); + zenon!.ledger.getAccountInfoByAddress(Address.parse(address)); } diff --git a/lib/blocs/dashboard/balance_dashboard_bloc.dart b/lib/blocs/dashboard/balance_dashboard_bloc.dart index 7207a497..782967eb 100644 --- a/lib/blocs/dashboard/balance_dashboard_bloc.dart +++ b/lib/blocs/dashboard/balance_dashboard_bloc.dart @@ -8,7 +8,7 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class BalanceDashboardBloc extends DashboardBaseBloc { @override Future makeAsyncCall() async { - AccountInfo response = await zenon!.ledger + final response = await zenon!.ledger .getAccountInfoByAddress(Address.parse(kSelectedAddress!)); if (response.blockCount! > 0 && (response.znn()! > BigInt.zero || response.qsr()! > BigInt.zero)) { diff --git a/lib/blocs/dashboard/dashboard.dart b/lib/blocs/dashboard/dashboard.dart index 03abf343..43f0cef9 100644 --- a/lib/blocs/dashboard/dashboard.dart +++ b/lib/blocs/dashboard/dashboard.dart @@ -1,4 +1,3 @@ -library; export 'balance_bloc.dart'; export 'balance_dashboard_bloc.dart'; diff --git a/lib/blocs/dashboard/dashboard_base_bloc.dart b/lib/blocs/dashboard/dashboard_base_bloc.dart index 5daabf45..dc43496a 100644 --- a/lib/blocs/dashboard/dashboard_base_bloc.dart +++ b/lib/blocs/dashboard/dashboard_base_bloc.dart @@ -5,13 +5,13 @@ import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; abstract class DashboardBaseBloc extends BaseBloc with RefreshBlocMixin { - Timer? _autoRefresher; - - Future makeAsyncCall(); DashboardBaseBloc() { listenToWsRestart(getDataPeriodically); } + Timer? _autoRefresher; + + Future makeAsyncCall(); Timer _getAutoRefreshTimer() => Timer( kIntervalBetweenMomentums, @@ -24,7 +24,7 @@ abstract class DashboardBaseBloc extends BaseBloc with RefreshBlocMixin { Future getDataPeriodically() async { try { if (!zenon!.wsClient.isClosed()) { - T data = await makeAsyncCall(); + final data = await makeAsyncCall(); addEvent(data); } else { throw noConnectionException; diff --git a/lib/blocs/dashboard/delegation_bloc.dart b/lib/blocs/dashboard/delegation_bloc.dart index e2864534..5f986774 100644 --- a/lib/blocs/dashboard/delegation_bloc.dart +++ b/lib/blocs/dashboard/delegation_bloc.dart @@ -9,7 +9,7 @@ class DelegationBloc extends DashboardBaseBloc { @override Future makeAsyncCall() async { try { - DelegationInfo? response = + final response = await zenon!.embedded.pillar.getDelegatedPillar( Address.parse(kSelectedAddress!), ); diff --git a/lib/blocs/dashboard/dual_coin_stats_bloc.dart b/lib/blocs/dashboard/dual_coin_stats_bloc.dart index 5a477c4f..f73435ce 100644 --- a/lib/blocs/dashboard/dual_coin_stats_bloc.dart +++ b/lib/blocs/dashboard/dual_coin_stats_bloc.dart @@ -7,14 +7,14 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class DualCoinStatsBloc extends DashboardBaseBloc> { @override - Future> makeAsyncCall() async => await Future.wait( + Future> makeAsyncCall() async => Future.wait( [ zenon!.embedded.token.getByZts( kZnnCoin.tokenStandard, ), zenon!.embedded.token.getByZts( kQsrCoin.tokenStandard, - ) + ), ], ); } diff --git a/lib/blocs/dashboard/pillars_bloc.dart b/lib/blocs/dashboard/pillars_bloc.dart index 87db9358..2ea6181d 100644 --- a/lib/blocs/dashboard/pillars_bloc.dart +++ b/lib/blocs/dashboard/pillars_bloc.dart @@ -7,7 +7,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; class PillarsBloc extends DashboardBaseBloc { @override Future makeAsyncCall() async { - int numOfPillars = (await zenon!.embedded.pillar.getAll()).list.length; + final numOfPillars = (await zenon!.embedded.pillar.getAll()).list.length; kNumOfPillars = numOfPillars; return numOfPillars; } diff --git a/lib/blocs/dashboard/realtime_statistics_bloc.dart b/lib/blocs/dashboard/realtime_statistics_bloc.dart index 8ae8e4cb..95010c4d 100644 --- a/lib/blocs/dashboard/realtime_statistics_bloc.dart +++ b/lib/blocs/dashboard/realtime_statistics_bloc.dart @@ -9,17 +9,17 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class RealtimeStatisticsBloc extends DashboardBaseBloc> { @override Future> makeAsyncCall() async { - int chainHeight = (await zenon!.ledger.getFrontierMomentum()).height; - int height = chainHeight - kMomentumsPerWeek > 0 + final chainHeight = (await zenon!.ledger.getFrontierMomentum()).height; + final height = chainHeight - kMomentumsPerWeek > 0 ? chainHeight - kMomentumsPerWeek : 1; - int pageIndex = 0; - int pageSize = 10; - bool isLastPage = false; - List blockList = []; + var pageIndex = 0; + const pageSize = 10; + var isLastPage = false; + final blockList = []; while (!isLastPage) { - List response = (await zenon!.ledger.getAccountBlocksByPage( + final response = (await zenon!.ledger.getAccountBlocksByPage( Address.parse(kSelectedAddress!), pageIndex: pageIndex, pageSize: pageSize, diff --git a/lib/blocs/dashboard/staking_bloc.dart b/lib/blocs/dashboard/staking_bloc.dart index da039c6c..80a232d9 100644 --- a/lib/blocs/dashboard/staking_bloc.dart +++ b/lib/blocs/dashboard/staking_bloc.dart @@ -6,19 +6,19 @@ import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class StakingStatsModel { - int numActiveStakingEntries; - BigInt totalZnnStakingAmount; StakingStatsModel( this.numActiveStakingEntries, this.totalZnnStakingAmount, ); + int numActiveStakingEntries; + BigInt totalZnnStakingAmount; } class StakingBloc extends DashboardBaseBloc { @override Future makeAsyncCall() async { - StakeList stakeList = await _getStakeList(); + final stakeList = await _getStakeList(); if (stakeList.list.isNotEmpty) { return StakingStatsModel( stakeList.list.length, @@ -30,8 +30,7 @@ class StakingBloc extends DashboardBaseBloc { } Future _getStakeList() async => - await zenon!.embedded.stake.getEntriesByAddress( + zenon!.embedded.stake.getEntriesByAddress( Address.parse(kSelectedAddress!), - pageIndex: 0, ); } diff --git a/lib/blocs/dashboard/total_hourly_transactions_bloc.dart b/lib/blocs/dashboard/total_hourly_transactions_bloc.dart index c1a2cf78..7bd1c76b 100644 --- a/lib/blocs/dashboard/total_hourly_transactions_bloc.dart +++ b/lib/blocs/dashboard/total_hourly_transactions_bloc.dart @@ -1,15 +1,14 @@ import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class TotalHourlyTransactionsBloc extends DashboardBaseBloc> { @override Future> makeAsyncCall() async { - int chainHeight = await _ledgerGetMomentumLedgerHeight(); + final chainHeight = await _ledgerGetMomentumLedgerHeight(); if (chainHeight - kMomentumsPerHour > 0) { - List response = + final response = (await zenon!.ledger.getDetailedMomentumsByHeight( chainHeight - kMomentumsPerHour, kMomentumsPerHour, @@ -28,7 +27,7 @@ class TotalHourlyTransactionsBloc } } - _ledgerGetMomentumLedgerHeight() async { + Future _ledgerGetMomentumLedgerHeight() async { try { return (await zenon!.ledger.getFrontierMomentum()).height; } catch (e) { diff --git a/lib/blocs/hide_widget_status_bloc.dart b/lib/blocs/hide_widget_status_bloc.dart index f79c3368..0e6c9c5c 100644 --- a/lib/blocs/hide_widget_status_bloc.dart +++ b/lib/blocs/hide_widget_status_bloc.dart @@ -19,8 +19,8 @@ class HideWidgetStatusBloc extends BaseBloc { } await _markWidgetAsHidden(widgetTitle, isHidden); addEvent(isHidden); - } on IncorrectPasswordException { - addError(kIncorrectPasswordNotificationTitle, null); + } on IncorrectPasswordException catch(e, stackTrace) { + addError(kIncorrectPasswordNotificationTitle, stackTrace); } catch (e, stackTrace) { addError(e, stackTrace); } diff --git a/lib/blocs/infinite_scroll_bloc.dart b/lib/blocs/infinite_scroll_bloc.dart index dc55a98d..0ce91b6d 100644 --- a/lib/blocs/infinite_scroll_bloc.dart +++ b/lib/blocs/infinite_scroll_bloc.dart @@ -65,14 +65,13 @@ abstract class InfiniteScrollBloc with RefreshBlocMixin { final newItems = await getData(pageKey, _pageSize); final isLastPage = newItems.length < _pageSize || !isDataRequestPaginated; final nextPageKey = isLastPage ? null : pageKey + 1; - List allItems = isDataRequestPaginated - ? [...lastListingState.itemList ?? [], ...newItems] + var allItems = isDataRequestPaginated + ? [...lastListingState.itemList ?? [], ...newItems] : newItems; if (filterItemsFunction != null) { allItems = filterItemsFunction!(allItems); } yield InfiniteScrollBlocListingState( - error: null, nextPageKey: nextPageKey, itemList: allItems, ); diff --git a/lib/blocs/key_store_file_bloc.dart b/lib/blocs/key_store_file_bloc.dart index ff09a926..f89af3f9 100644 --- a/lib/blocs/key_store_file_bloc.dart +++ b/lib/blocs/key_store_file_bloc.dart @@ -3,9 +3,9 @@ import 'dart:convert'; import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/wallet_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/init_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/wallet_file.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/wallet_utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class KeyStoreFileBloc extends BaseBloc { @@ -16,8 +16,8 @@ class KeyStoreFileBloc extends BaseBloc { try { await WalletUtils.createKeyStoreWalletFile(mnemonic, password); await InitUtils.initWalletAfterDecryption( - Crypto.digest(utf8.encode(password))); - addEvent(kWalletFile as KeyStoreWalletFile); + Crypto.digest(utf8.encode(password)),); + addEvent(kWalletFile! as KeyStoreWalletFile); } catch (e, stackTrace) { addError(e, stackTrace); } diff --git a/lib/blocs/ledger_wallet_file_bloc.dart b/lib/blocs/ledger_wallet_file_bloc.dart index 413900b5..e71bef2f 100644 --- a/lib/blocs/ledger_wallet_file_bloc.dart +++ b/lib/blocs/ledger_wallet_file_bloc.dart @@ -3,20 +3,20 @@ import 'dart:convert'; import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/wallet_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/init_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/wallet_file.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/wallet_utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class LedgerWalletFileBloc extends BaseBloc { Future getLedgerWalletPath(String walletId, String password, - String? walletName) async { + String? walletName,) async { try { await WalletUtils.createLedgerWalletFile(walletId, password, - walletName: walletName); + walletName: walletName,); await InitUtils.initWalletAfterDecryption( - Crypto.digest(utf8.encode(password))); - addEvent(kWalletFile as LedgerWalletFile); + Crypto.digest(utf8.encode(password)),); + addEvent(kWalletFile! as LedgerWalletFile); } catch (e, stackTrace) { addError(e, stackTrace); } diff --git a/lib/blocs/lock_bloc.dart b/lib/blocs/lock_bloc.dart index 990adad8..be7a27ae 100644 --- a/lib/blocs/lock_bloc.dart +++ b/lib/blocs/lock_bloc.dart @@ -12,7 +12,7 @@ enum LockEvent { class LockBloc extends BaseBloc { @override - void addEvent(event) { + void addEvent(LockEvent event) { if (!(kCurrentPage == Tabs.lock && event == LockEvent.resetTimer)) { super.addEvent(event); } diff --git a/lib/blocs/node_sync_status_bloc.dart b/lib/blocs/node_sync_status_bloc.dart index b996ee91..b6ccb900 100644 --- a/lib/blocs/node_sync_status_bloc.dart +++ b/lib/blocs/node_sync_status_bloc.dart @@ -11,7 +11,7 @@ class NodeSyncStatusBloc extends DashboardBaseBloc { @override Future makeAsyncCall() async { if (zenon!.wsClient.status() == WebsocketStatus.running) { - SyncInfo syncInfo = await zenon!.stats.syncInfo(); + final syncInfo = await zenon!.stats.syncInfo(); if (lastSyncState != syncInfo.state && (syncInfo.state == SyncState.syncDone || (syncInfo.targetHeight > 0 && diff --git a/lib/blocs/notifications_bloc.dart b/lib/blocs/notifications_bloc.dart index 2e58736b..e89fdb6a 100644 --- a/lib/blocs/notifications_bloc.dart +++ b/lib/blocs/notifications_bloc.dart @@ -11,7 +11,7 @@ class NotificationsBloc extends BaseBloc { Future addNotification(WalletNotification? notification) async { try { await Hive.openBox(kNotificationsBox); - Box notificationsBox = Hive.box(kNotificationsBox); + final notificationsBox = Hive.box(kNotificationsBox); if (notificationsBox.length >= kNotificationsEntriesLimit) { while (notificationsBox.length >= kNotificationsEntriesLimit) { await notificationsBox.delete(notificationsBox.keys.first); @@ -19,7 +19,7 @@ class NotificationsBloc extends BaseBloc { } await notificationsBox.add(notification); if (notification != null && _areDesktopNotificationsEnabled()) { - LocalNotification localNotification = LocalNotification( + final localNotification = LocalNotification( title: notification.title ?? 'Empty title', body: notification.details ?? 'No details available', ); @@ -48,7 +48,7 @@ class NotificationsBloc extends BaseBloc { WalletNotification( title: title, timestamp: DateTime.now().millisecondsSinceEpoch, - details: '$title: ${error.toString()}', + details: '$title: $error', type: NotificationType.error, ), ); diff --git a/lib/blocs/p2p_swap/htlc_swap/complete_htlc_swap_bloc.dart b/lib/blocs/p2p_swap/htlc_swap/complete_htlc_swap_bloc.dart index dc8d49f3..2d4e264a 100644 --- a/lib/blocs/p2p_swap/htlc_swap/complete_htlc_swap_bloc.dart +++ b/lib/blocs/p2p_swap/htlc_swap/complete_htlc_swap_bloc.dart @@ -28,10 +28,10 @@ class CompleteHtlcSwapBloc extends BaseBloc { throw 'The swap secret size exceeds the maximum allowed size.'; } - AccountBlockTemplate transactionParams = zenon!.embedded.htlc.unlock( - Hash.parse(htlcId), FormatUtils.decodeHexString(swap.preimage!)); + final transactionParams = zenon!.embedded.htlc.unlock( + Hash.parse(htlcId), FormatUtils.decodeHexString(swap.preimage!),); AccountBlockUtils.createAccountBlock(transactionParams, 'complete swap', - address: Address.parse(swap.selfAddress), waitForRequiredPlasma: true) + address: Address.parse(swap.selfAddress), waitForRequiredPlasma: true,) .then( (response) async { swap.state = P2pSwapState.completed; diff --git a/lib/blocs/p2p_swap/htlc_swap/htlc_swap_bloc.dart b/lib/blocs/p2p_swap/htlc_swap/htlc_swap_bloc.dart index 058e4fb8..8e67e68c 100644 --- a/lib/blocs/p2p_swap/htlc_swap/htlc_swap_bloc.dart +++ b/lib/blocs/p2p_swap/htlc_swap/htlc_swap_bloc.dart @@ -4,9 +4,9 @@ import 'package:zenon_syrius_wallet_flutter/model/p2p_swap/htlc_swap.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class HtlcSwapBloc extends PeriodicP2pSwapBaseBloc { - final String swapId; HtlcSwapBloc(this.swapId); + final String swapId; @override HtlcSwap makeCall() { diff --git a/lib/blocs/p2p_swap/htlc_swap/initial_htlc_for_swap_bloc.dart b/lib/blocs/p2p_swap/htlc_swap/initial_htlc_for_swap_bloc.dart index 406ee369..b4782f5f 100644 --- a/lib/blocs/p2p_swap/htlc_swap/initial_htlc_for_swap_bloc.dart +++ b/lib/blocs/p2p_swap/htlc_swap/initial_htlc_for_swap_bloc.dart @@ -9,6 +9,7 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class InitialHtlcForSwapBloc extends BaseBloc { final _minimumRequiredDuration = kMinSafeTimeToFindPreimage + kCounterHtlcDuration; + Future getInitialHtlc(Hash id) async { try { final htlc = await zenon!.embedded.htlc.getById(id); @@ -23,7 +24,7 @@ class InitialHtlcForSwapBloc extends BaseBloc { throw 'This deposit is already used in another swap.'; } if (htlcSwapsService!.getSwapByHashLock(hashlock) != null) { - throw 'The deposit\'s hashlock is already used in another swap.'; + throw "The deposit's hashlock is already used in another swap."; } final remainingDuration = Duration(seconds: htlc.expirationTime - DateTimeUtils.unixTimeNow); @@ -34,7 +35,7 @@ class InitialHtlcForSwapBloc extends BaseBloc { throw 'This deposit will expire too soon for a safe swap.'; } if (remainingDuration > kMaxAllowedInitialHtlcDuration) { - throw 'The deposit\'s duration is too long. Expected ${kMaxAllowedInitialHtlcDuration.inHours} hours at most.'; + throw "The deposit's duration is too long. Expected ${kMaxAllowedInitialHtlcDuration.inHours} hours at most."; } final creationBlock = await zenon!.ledger.getAccountBlockByHash(htlc.id); if (htlc.expirationTime - @@ -46,11 +47,14 @@ class InitialHtlcForSwapBloc extends BaseBloc { // Verify that the hashlock has not been used in another currently active // HTLC. final htlcBlocks = await AccountBlockUtils.getAccountBlocksAfterTime( - htlcAddress, - htlc.expirationTime - kMaxAllowedInitialHtlcDuration.inSeconds); - if (htlcBlocks.firstWhereOrNull((block) => - !_isInitialHtlcBlock(block, htlc.id) && - _hasMatchingHashlock(block, hashlock)) != + htlcAddress, + htlc.expirationTime - kMaxAllowedInitialHtlcDuration.inSeconds, + ); + if (htlcBlocks.firstWhereOrNull( + (block) => + !_isInitialHtlcBlock(block, htlc.id) && + _hasMatchingHashlock(block, hashlock), + ) != null) { throw 'The hashlock is not unique.'; } @@ -74,7 +78,9 @@ bool _hasMatchingHashlock(AccountBlock block, String hashlock) { } final blockData = AccountBlockUtils.getDecodedBlockData( - Definitions.htlc, block.pairedAccountBlock!.data); + Definitions.htlc, + block.pairedAccountBlock!.data, + ); if (blockData == null || blockData.function != 'Create') { return false; @@ -84,5 +90,8 @@ bool _hasMatchingHashlock(AccountBlock block, String hashlock) { return false; } - return FormatUtils.encodeHexString(blockData.params['hashLock']) == hashlock; + return FormatUtils.encodeHexString( + blockData.params['hashLock'] as List, + ) == + hashlock; } diff --git a/lib/blocs/p2p_swap/htlc_swap/join_htlc_swap_bloc.dart b/lib/blocs/p2p_swap/htlc_swap/join_htlc_swap_bloc.dart index 45010baf..a66f059b 100644 --- a/lib/blocs/p2p_swap/htlc_swap/join_htlc_swap_bloc.dart +++ b/lib/blocs/p2p_swap/htlc_swap/join_htlc_swap_bloc.dart @@ -9,7 +9,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class JoinHtlcSwapBloc extends BaseBloc { - void joinHtlcSwap({ + Future joinHtlcSwap({ required HtlcInfo initialHtlc, required Token fromToken, required Token toToken, @@ -21,7 +21,7 @@ class JoinHtlcSwapBloc extends BaseBloc { }) async { try { addEvent(null); - AccountBlockTemplate transactionParams = zenon!.embedded.htlc.create( + final transactionParams = zenon!.embedded.htlc.create( fromToken, fromAmount, initialHtlc.timeLocked, @@ -31,7 +31,7 @@ class JoinHtlcSwapBloc extends BaseBloc { initialHtlc.hashLock, ); AccountBlockUtils.createAccountBlock(transactionParams, 'join swap', - address: initialHtlc.hashLocked, waitForRequiredPlasma: true) + address: initialHtlc.hashLocked, waitForRequiredPlasma: true,) .then( (response) async { final swap = HtlcSwap( diff --git a/lib/blocs/p2p_swap/htlc_swap/reclaim_htlc_swap_funds_bloc.dart b/lib/blocs/p2p_swap/htlc_swap/reclaim_htlc_swap_funds_bloc.dart index 8aec5c9d..8f498984 100644 --- a/lib/blocs/p2p_swap/htlc_swap/reclaim_htlc_swap_funds_bloc.dart +++ b/lib/blocs/p2p_swap/htlc_swap/reclaim_htlc_swap_funds_bloc.dart @@ -5,17 +5,17 @@ import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ReclaimHtlcSwapFundsBloc extends BaseBloc { - void reclaimFunds({ + Future reclaimFunds({ required Hash htlcId, required Address selfAddress, }) async { try { addEvent(null); - AccountBlockTemplate transactionParams = + final transactionParams = zenon!.embedded.htlc.reclaim(htlcId); AccountBlockUtils.createAccountBlock( transactionParams, 'reclaim swap funds', - address: selfAddress, waitForRequiredPlasma: true) + address: selfAddress, waitForRequiredPlasma: true,) .then( (response) { ZenonAddressUtils.refreshBalance(); diff --git a/lib/blocs/p2p_swap/htlc_swap/recover_htlc_swap_funds_bloc.dart b/lib/blocs/p2p_swap/htlc_swap/recover_htlc_swap_funds_bloc.dart index 7b418fda..d528da87 100644 --- a/lib/blocs/p2p_swap/htlc_swap/recover_htlc_swap_funds_bloc.dart +++ b/lib/blocs/p2p_swap/htlc_swap/recover_htlc_swap_funds_bloc.dart @@ -7,7 +7,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class RecoverHtlcSwapFundsBloc extends ReclaimHtlcSwapFundsBloc { - void recoverFunds({required Hash htlcId}) async { + Future recoverFunds({required Hash htlcId}) async { try { final htlc = await zenon!.embedded.htlc.getById(htlcId); diff --git a/lib/blocs/p2p_swap/htlc_swap/start_htlc_swap_bloc.dart b/lib/blocs/p2p_swap/htlc_swap/start_htlc_swap_bloc.dart index 281dfe55..455edcb9 100644 --- a/lib/blocs/p2p_swap/htlc_swap/start_htlc_swap_bloc.dart +++ b/lib/blocs/p2p_swap/htlc_swap/start_htlc_swap_bloc.dart @@ -11,7 +11,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class StartHtlcSwapBloc extends BaseBloc { - void startHtlcSwap({ + Future startHtlcSwap({ required Address selfAddress, required Address counterpartyAddress, required Token fromToken, @@ -27,7 +27,7 @@ class StartHtlcSwapBloc extends BaseBloc { final preimage = _generatePreimage(); final hashLock = await _getHashLock(hashType, preimage); final expirationTime = await _getExpirationTime(initialHtlcDuration); - AccountBlockTemplate transactionParams = zenon!.embedded.htlc.create( + final transactionParams = zenon!.embedded.htlc.create( fromToken, fromAmount, counterpartyAddress, @@ -37,7 +37,7 @@ class StartHtlcSwapBloc extends BaseBloc { hashLock.getBytes(), ); AccountBlockUtils.createAccountBlock(transactionParams, 'start swap', - address: selfAddress, waitForRequiredPlasma: true) + address: selfAddress, waitForRequiredPlasma: true,) .then( (response) async { final swap = HtlcSwap( @@ -78,7 +78,7 @@ class StartHtlcSwapBloc extends BaseBloc { List _generatePreimage() { const maxInt = 256; return List.generate( - htlcPreimageDefaultLength, (i) => Random.secure().nextInt(maxInt)); + htlcPreimageDefaultLength, (i) => Random.secure().nextInt(maxInt),); } Future _getHashLock(int hashType, List preimage) async { diff --git a/lib/blocs/p2p_swap/periodic_p2p_swap_base_bloc.dart b/lib/blocs/p2p_swap/periodic_p2p_swap_base_bloc.dart index c75b23c5..72a40cdb 100644 --- a/lib/blocs/p2p_swap/periodic_p2p_swap_base_bloc.dart +++ b/lib/blocs/p2p_swap/periodic_p2p_swap_base_bloc.dart @@ -11,7 +11,7 @@ abstract class PeriodicP2pSwapBaseBloc extends BaseBloc { void getDataPeriodically() { try { - T data = makeCall(); + final data = makeCall(); addEvent(data); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/pillars/delegate_button_bloc.dart b/lib/blocs/pillars/delegate_button_bloc.dart index bb65b1d5..e0889eaa 100644 --- a/lib/blocs/pillars/delegate_button_bloc.dart +++ b/lib/blocs/pillars/delegate_button_bloc.dart @@ -10,7 +10,7 @@ class DelegateButtonBloc extends BaseBloc { ) async { try { addEvent(null); - AccountBlockTemplate transactionParams = zenon!.embedded.pillar.delegate( + final transactionParams = zenon!.embedded.pillar.delegate( pillarName!, ); AccountBlockUtils.createAccountBlock( @@ -23,9 +23,7 @@ class DelegateButtonBloc extends BaseBloc { addEvent(response); }, ).onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/pillars/disassemble_pillar_bloc.dart b/lib/blocs/pillars/disassemble_pillar_bloc.dart index 3e10e171..1fc9b11f 100644 --- a/lib/blocs/pillars/disassemble_pillar_bloc.dart +++ b/lib/blocs/pillars/disassemble_pillar_bloc.dart @@ -12,7 +12,7 @@ class DisassemblePillarBloc extends BaseBloc { ) { try { addEvent(null); - AccountBlockTemplate transactionParams = zenon!.embedded.pillar.revoke( + final transactionParams = zenon!.embedded.pillar.revoke( pillarName, ); AccountBlockUtils.createAccountBlock( @@ -25,9 +25,7 @@ class DisassemblePillarBloc extends BaseBloc { addEvent(response); }, ).onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/pillars/pillar_rewards_history_bloc.dart b/lib/blocs/pillars/pillar_rewards_history_bloc.dart index 09f303f9..0d21fd69 100644 --- a/lib/blocs/pillars/pillar_rewards_history_bloc.dart +++ b/lib/blocs/pillars/pillar_rewards_history_bloc.dart @@ -8,7 +8,7 @@ class PillarRewardsHistoryBloc extends BaseBlocForReloadingIndicator { @override Future getDataAsync() async { - RewardHistoryList response = + final response = await zenon!.embedded.pillar.getFrontierRewardByPage( Address.parse(kSelectedAddress!), pageSize: kStandardChartNumDays.toInt(), diff --git a/lib/blocs/pillars/pillars.dart b/lib/blocs/pillars/pillars.dart index 54494357..39144d6b 100644 --- a/lib/blocs/pillars/pillars.dart +++ b/lib/blocs/pillars/pillars.dart @@ -1,4 +1,3 @@ -library; export 'delegate_button_bloc.dart'; export 'delegation_info_bloc.dart'; diff --git a/lib/blocs/pillars/pillars_deploy_bloc.dart b/lib/blocs/pillars/pillars_deploy_bloc.dart index 1b7be9a9..5f9925eb 100644 --- a/lib/blocs/pillars/pillars_deploy_bloc.dart +++ b/lib/blocs/pillars/pillars_deploy_bloc.dart @@ -23,14 +23,14 @@ class PillarsDeployBloc extends BaseBloc { if (await _pillarNameAlreadyExists(pillarName)) { throw 'Pillar name already exists'; } - AccountBlockTemplate transactionParams = zenon!.embedded.pillar.register( + final transactionParams = zenon!.embedded.pillar.register( pillarName, Address.parse(blockProducingAddress), Address.parse(rewardAddress), giveBlockRewardPercentage, giveDelegateRewardPercentage, ); - AccountBlockUtils.createAccountBlock( + await AccountBlockUtils.createAccountBlock( transactionParams, 'register Pillar', waitForRequiredPlasma: true, @@ -40,9 +40,7 @@ class PillarsDeployBloc extends BaseBloc { addEvent(response); }, ).onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/pillars/pillars_deposit_qsr_bloc.dart b/lib/blocs/pillars/pillars_deposit_qsr_bloc.dart index e3cbfd35..08a81b6e 100644 --- a/lib/blocs/pillars/pillars_deposit_qsr_bloc.dart +++ b/lib/blocs/pillars/pillars_deposit_qsr_bloc.dart @@ -16,7 +16,7 @@ class PillarsDepositQsrBloc extends BaseBloc { try { addEvent(null); if (!justMarkStepCompleted) { - AccountBlockTemplate transactionParams = + final transactionParams = zenon!.embedded.pillar.depositQsr( amount, ); @@ -33,9 +33,7 @@ class PillarsDepositQsrBloc extends BaseBloc { addEvent(response); }, ).onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } } catch (e, stackTrace) { diff --git a/lib/blocs/pillars/pillars_qsr_info_bloc.dart b/lib/blocs/pillars/pillars_qsr_info_bloc.dart index c9fa4dff..13424044 100644 --- a/lib/blocs/pillars/pillars_qsr_info_bloc.dart +++ b/lib/blocs/pillars/pillars_qsr_info_bloc.dart @@ -11,10 +11,10 @@ class PillarsQsrInfoBloc extends BaseBloc { ) async { try { addEvent(null); - BigInt deposit = (await zenon!.embedded.pillar.getDepositedQsr( + final deposit = await zenon!.embedded.pillar.getDepositedQsr( Address.parse(address), - )); - BigInt cost = (await zenon!.embedded.pillar.getQsrRegistrationCost()); + ); + final cost = await zenon!.embedded.pillar.getQsrRegistrationCost(); addEvent( PillarsQsrInfo( deposit: deposit, diff --git a/lib/blocs/pillars/pillars_withdraw_qsr_bloc.dart b/lib/blocs/pillars/pillars_withdraw_qsr_bloc.dart index b4168718..2670b478 100644 --- a/lib/blocs/pillars/pillars_withdraw_qsr_bloc.dart +++ b/lib/blocs/pillars/pillars_withdraw_qsr_bloc.dart @@ -12,7 +12,7 @@ class PillarsWithdrawQsrBloc extends BaseBloc { Future withdrawQsr(String address) async { try { addEvent(null); - AccountBlockTemplate transactionParams = + final transactionParams = zenon!.embedded.pillar.withdrawQsr(); AccountBlockUtils.createAccountBlock( transactionParams, @@ -25,9 +25,7 @@ class PillarsWithdrawQsrBloc extends BaseBloc { addEvent(response); }, ).onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/pillars/undelegate_button_bloc.dart b/lib/blocs/pillars/undelegate_button_bloc.dart index 6366b9de..84e8af31 100644 --- a/lib/blocs/pillars/undelegate_button_bloc.dart +++ b/lib/blocs/pillars/undelegate_button_bloc.dart @@ -9,7 +9,7 @@ class UndelegateButtonBloc extends BaseBloc { void cancelPillarVoting(BuildContext context) { try { addEvent(null); - AccountBlockTemplate transactionParams = + final transactionParams = zenon!.embedded.pillar.undelegate(); AccountBlockUtils.createAccountBlock( transactionParams, @@ -21,9 +21,7 @@ class UndelegateButtonBloc extends BaseBloc { addEvent(response); }, ).onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/pillars/update_pillar_bloc.dart b/lib/blocs/pillars/update_pillar_bloc.dart index d1a20f38..525100a3 100644 --- a/lib/blocs/pillars/update_pillar_bloc.dart +++ b/lib/blocs/pillars/update_pillar_bloc.dart @@ -13,7 +13,7 @@ class UpdatePillarBloc extends BaseBloc { ) { try { addEvent(null); - AccountBlockTemplate transactionParams = + final transactionParams = zenon!.embedded.pillar.updatePillar( name, producerAddress, @@ -26,12 +26,10 @@ class UpdatePillarBloc extends BaseBloc { 'update pillar', ) .then( - (block) => addEvent(block), + addEvent, ) .onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/plasma/cancel_plasma_bloc.dart b/lib/blocs/plasma/cancel_plasma_bloc.dart index 465ba8a9..cf6135f9 100644 --- a/lib/blocs/plasma/cancel_plasma_bloc.dart +++ b/lib/blocs/plasma/cancel_plasma_bloc.dart @@ -9,20 +9,18 @@ class CancelPlasmaBloc extends BaseBloc { void cancelPlasmaStaking(String id, BuildContext context) { try { addEvent(null); - AccountBlockTemplate transactionParams = zenon!.embedded.plasma.cancel( + final transactionParams = zenon!.embedded.plasma.cancel( Hash.parse(id), ); AccountBlockUtils.createAccountBlock(transactionParams, 'cancel Plasma', - waitForRequiredPlasma: true) + waitForRequiredPlasma: true,) .then( (response) { ZenonAddressUtils.refreshBalance(); addEvent(response); }, ).onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/plasma/plasma.dart b/lib/blocs/plasma/plasma.dart index a12ddb24..02d1262f 100644 --- a/lib/blocs/plasma/plasma.dart +++ b/lib/blocs/plasma/plasma.dart @@ -1,4 +1,3 @@ -library; export 'cancel_plasma_bloc.dart'; export 'plasma_list_bloc.dart'; diff --git a/lib/blocs/plasma/plasma_list_bloc.dart b/lib/blocs/plasma/plasma_list_bloc.dart index 5ed813b0..3d734e0d 100644 --- a/lib/blocs/plasma/plasma_list_bloc.dart +++ b/lib/blocs/plasma/plasma_list_bloc.dart @@ -10,16 +10,16 @@ class PlasmaListBloc extends InfiniteScrollBloc { @override Future> getData(int pageKey, int pageSize) async { - List results = + final results = (await zenon!.embedded.plasma.getEntriesByAddress( Address.parse(kSelectedAddress!), pageIndex: pageKey, pageSize: pageSize, )) .list; - Momentum lastMomentum = await zenon!.ledger.getFrontierMomentum(); + final lastMomentum = await zenon!.ledger.getFrontierMomentum(); lastMomentumHeight = lastMomentum.height; - for (var fusionEntry in results) { + for (final fusionEntry in results) { fusionEntry.isRevocable = lastMomentum.height > fusionEntry.expirationHeight; } diff --git a/lib/blocs/plasma/plasma_options_bloc.dart b/lib/blocs/plasma/plasma_options_bloc.dart index 7ed77b93..b5a6cdc4 100644 --- a/lib/blocs/plasma/plasma_options_bloc.dart +++ b/lib/blocs/plasma/plasma_options_bloc.dart @@ -9,7 +9,7 @@ class PlasmaOptionsBloc extends BaseBloc { void generatePlasma(String beneficiaryAddress, BigInt amount) { try { addEvent(null); - AccountBlockTemplate transactionParams = zenon!.embedded.plasma.fuse( + final transactionParams = zenon!.embedded.plasma.fuse( Address.parse(beneficiaryAddress), amount, ); @@ -23,9 +23,7 @@ class PlasmaOptionsBloc extends BaseBloc { addEvent(response); }, ).onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/plasma/plasma_stats_bloc.dart b/lib/blocs/plasma/plasma_stats_bloc.dart index 6f487c69..5547d627 100644 --- a/lib/blocs/plasma/plasma_stats_bloc.dart +++ b/lib/blocs/plasma/plasma_stats_bloc.dart @@ -14,7 +14,7 @@ class PlasmaStatsBloc extends BaseBloc> Future getPlasmas() async { try { - List plasmaInfoWrapper = await Future.wait( + final plasmaInfoWrapper = await Future.wait( kDefaultAddressList.map((e) => _getPlasma(e!)).toList(), ); addEvent(plasmaInfoWrapper); @@ -25,7 +25,7 @@ class PlasmaStatsBloc extends BaseBloc> Future _getPlasma(String address) async { try { - PlasmaInfo plasmaInfo = await zenon!.embedded.plasma.get( + final plasmaInfo = await zenon!.embedded.plasma.get( Address.parse(address), ); return PlasmaInfoWrapper(address: address, plasmaInfo: plasmaInfo); diff --git a/lib/blocs/sentinels/disassemble_button_bloc.dart b/lib/blocs/sentinels/disassemble_button_bloc.dart index e3a7b29c..7c220df9 100644 --- a/lib/blocs/sentinels/disassemble_button_bloc.dart +++ b/lib/blocs/sentinels/disassemble_button_bloc.dart @@ -9,7 +9,7 @@ class DisassembleButtonBloc extends BaseBloc { Future disassembleSentinel(BuildContext context) async { try { addEvent(null); - AccountBlockTemplate transactionParams = + final transactionParams = zenon!.embedded.sentinel.revoke(); AccountBlockUtils.createAccountBlock( transactionParams, @@ -21,9 +21,7 @@ class DisassembleButtonBloc extends BaseBloc { addEvent(response); }, ).onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/sentinels/sentinel_deposit_qsr_bloc.dart b/lib/blocs/sentinels/sentinel_deposit_qsr_bloc.dart index 79b8e495..eb787f7e 100644 --- a/lib/blocs/sentinels/sentinel_deposit_qsr_bloc.dart +++ b/lib/blocs/sentinels/sentinel_deposit_qsr_bloc.dart @@ -16,7 +16,7 @@ class SentinelsDepositQsrBloc extends BaseBloc { try { addEvent(null); if (!justMarkStepCompleted) { - AccountBlockTemplate transactionParams = + final transactionParams = zenon!.embedded.sentinel.depositQsr( amount, ); @@ -33,9 +33,7 @@ class SentinelsDepositQsrBloc extends BaseBloc { addEvent(response); }, ).onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } } catch (e, stackTrace) { diff --git a/lib/blocs/sentinels/sentinel_qsr_info_bloc.dart b/lib/blocs/sentinels/sentinel_qsr_info_bloc.dart index 978b80d3..6024c068 100644 --- a/lib/blocs/sentinels/sentinel_qsr_info_bloc.dart +++ b/lib/blocs/sentinels/sentinel_qsr_info_bloc.dart @@ -7,10 +7,10 @@ class SentinelsQsrInfoBloc extends BaseBloc { Future getQsrManagementInfo(String address) async { try { addEvent(null); - BigInt deposit = (await zenon!.embedded.sentinel.getDepositedQsr( + final deposit = await zenon!.embedded.sentinel.getDepositedQsr( Address.parse(address), - )); - BigInt cost = sentinelRegisterQsrAmount; + ); + final cost = sentinelRegisterQsrAmount; addEvent( SentinelsQsrInfo( deposit: deposit, diff --git a/lib/blocs/sentinels/sentinel_register_bloc.dart b/lib/blocs/sentinels/sentinel_register_bloc.dart index 8c73624d..b28488fd 100644 --- a/lib/blocs/sentinels/sentinel_register_bloc.dart +++ b/lib/blocs/sentinels/sentinel_register_bloc.dart @@ -8,7 +8,7 @@ class SentinelsDeployBloc extends BaseBloc { Future deploySentinel(BigInt amount) async { try { addEvent(null); - AccountBlockTemplate transactionParams = + final transactionParams = zenon!.embedded.sentinel.register(); AccountBlockUtils.createAccountBlock( transactionParams, @@ -20,9 +20,7 @@ class SentinelsDeployBloc extends BaseBloc { addEvent(response); }, ).onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/sentinels/sentinel_rewards_history_bloc.dart b/lib/blocs/sentinels/sentinel_rewards_history_bloc.dart index 5a3a25bf..0c9e31f7 100644 --- a/lib/blocs/sentinels/sentinel_rewards_history_bloc.dart +++ b/lib/blocs/sentinels/sentinel_rewards_history_bloc.dart @@ -8,7 +8,7 @@ class SentinelRewardsHistoryBloc extends BaseBlocForReloadingIndicator { @override Future getDataAsync() async { - RewardHistoryList response = + final response = await zenon!.embedded.sentinel.getFrontierRewardByPage( Address.parse(kSelectedAddress!), pageSize: kStandardChartNumDays.toInt(), diff --git a/lib/blocs/sentinels/sentinel_withdraw_qsr_bloc.dart b/lib/blocs/sentinels/sentinel_withdraw_qsr_bloc.dart index bc32ee4b..27e5bb9e 100644 --- a/lib/blocs/sentinels/sentinel_withdraw_qsr_bloc.dart +++ b/lib/blocs/sentinels/sentinel_withdraw_qsr_bloc.dart @@ -12,7 +12,7 @@ class SentinelsWithdrawQsrBloc extends BaseBloc { withdrawQsr(String address) async { try { addEvent(null); - AccountBlockTemplate transactionParams = + final transactionParams = zenon!.embedded.sentinel.withdrawQsr(); AccountBlockUtils.createAccountBlock( transactionParams, @@ -25,9 +25,7 @@ class SentinelsWithdrawQsrBloc extends BaseBloc { addEvent(response); }, ).onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/sentinels/sentinels.dart b/lib/blocs/sentinels/sentinels.dart index b24001f4..fd1c74c7 100644 --- a/lib/blocs/sentinels/sentinels.dart +++ b/lib/blocs/sentinels/sentinels.dart @@ -1,4 +1,3 @@ -library; export 'disassemble_button_bloc.dart'; export 'get_sentinel_by_owner_bloc.dart'; diff --git a/lib/blocs/settings/account_chain_stats_bloc.dart b/lib/blocs/settings/account_chain_stats_bloc.dart index 6583266b..8d7332a7 100644 --- a/lib/blocs/settings/account_chain_stats_bloc.dart +++ b/lib/blocs/settings/account_chain_stats_bloc.dart @@ -8,17 +8,17 @@ class AccountChainStatsBloc extends BaseBlocForReloadingIndicator { @override Future getDataAsync() async { - AccountInfo accountInfo = await zenon!.ledger.getAccountInfoByAddress( + final accountInfo = await zenon!.ledger.getAccountInfoByAddress( Address.parse( kSelectedAddress!, ), ); - int pageSize = accountInfo.blockCount!; - int pageCount = ((pageSize + 1) / rpcMaxPageSize).ceil(); + final pageSize = accountInfo.blockCount!; + final pageCount = ((pageSize + 1) / rpcMaxPageSize).ceil(); if (pageSize > 0) { - List allBlocks = []; + final allBlocks = []; for (var i = 0; i < pageCount; i++) { allBlocks.addAll((await zenon!.ledger.getAccountBlocksByHeight( @@ -26,10 +26,9 @@ class AccountChainStatsBloc kSelectedAddress!, ), (rpcMaxPageSize * i) + 1, - rpcMaxPageSize, )) .list ?? - []); + [],); } return AccountChainStats( @@ -43,7 +42,7 @@ class AccountChainStatsBloc } Map _getNumOfBlocksForEachBlockType( - List blocks) => + List blocks,) => BlockTypeEnum.values.fold>( {}, (previousValue, blockType) { @@ -54,10 +53,10 @@ class AccountChainStatsBloc ); int _getNumOfBlockForBlockType( - List blocks, BlockTypeEnum blockType) => + List blocks, BlockTypeEnum blockType,) => blocks.fold( 0, - (dynamic previousValue, element) { + (int previousValue, element) { if (element.blockType == blockType.index) { return previousValue + 1; } diff --git a/lib/blocs/settings/general_stats_bloc.dart b/lib/blocs/settings/general_stats_bloc.dart index b94a0579..b5b8cde0 100644 --- a/lib/blocs/settings/general_stats_bloc.dart +++ b/lib/blocs/settings/general_stats_bloc.dart @@ -10,11 +10,11 @@ class GeneralStatsBloc extends BaseBlocWithRefreshMixin { @override Future getDataAsync() async { - GeneralStats generalStats = GeneralStats( + final generalStats = GeneralStats( frontierMomentum: await zenon!.ledger.getFrontierMomentum(), processInfo: await zenon!.stats.processInfo(), networkInfo: await zenon!.stats.networkInfo(), - osInfo: await zenon!.stats.osInfo()); + osInfo: await zenon!.stats.osInfo(),); if (_timer == null || !_timer!.isActive) { _timer = _getTimer(); } diff --git a/lib/blocs/settings/peers_bloc.dart b/lib/blocs/settings/peers_bloc.dart index 2823cac0..88c7c704 100644 --- a/lib/blocs/settings/peers_bloc.dart +++ b/lib/blocs/settings/peers_bloc.dart @@ -4,5 +4,5 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PeersBloc extends BaseBlocWithRefreshMixin { @override - Future getDataAsync() async => await zenon!.stats.networkInfo(); + Future getDataAsync() async => zenon!.stats.networkInfo(); } diff --git a/lib/blocs/settings/settings.dart b/lib/blocs/settings/settings.dart index d5d799b1..c167ae4d 100644 --- a/lib/blocs/settings/settings.dart +++ b/lib/blocs/settings/settings.dart @@ -1,4 +1,3 @@ -library; export 'account_chain_stats_bloc.dart'; export 'general_stats_bloc.dart'; diff --git a/lib/blocs/staking/cancel_stake_bloc.dart b/lib/blocs/staking/cancel_stake_bloc.dart index f0838fa8..90f6908c 100644 --- a/lib/blocs/staking/cancel_stake_bloc.dart +++ b/lib/blocs/staking/cancel_stake_bloc.dart @@ -9,7 +9,7 @@ class CancelStakeBloc extends BaseBloc { void cancelStake(String hash, BuildContext context) { try { addEvent(null); - AccountBlockTemplate transactionParams = zenon!.embedded.stake.cancel( + final transactionParams = zenon!.embedded.stake.cancel( Hash.parse(hash), ); AccountBlockUtils.createAccountBlock( @@ -22,9 +22,7 @@ class CancelStakeBloc extends BaseBloc { addEvent(response); }, ).onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/staking/staking.dart b/lib/blocs/staking/staking.dart index 96860423..58aac804 100644 --- a/lib/blocs/staking/staking.dart +++ b/lib/blocs/staking/staking.dart @@ -1,4 +1,3 @@ -library; export 'cancel_stake_bloc.dart'; export 'staking_list_bloc.dart'; diff --git a/lib/blocs/staking/staking_options_bloc.dart b/lib/blocs/staking/staking_options_bloc.dart index 50e8a417..cf9f9c08 100644 --- a/lib/blocs/staking/staking_options_bloc.dart +++ b/lib/blocs/staking/staking_options_bloc.dart @@ -11,21 +11,19 @@ class StakingOptionsBloc extends BaseBloc { ) { try { addEvent(null); - AccountBlockTemplate transactionParams = zenon!.embedded.stake.stake( + final transactionParams = zenon!.embedded.stake.stake( stakeDuration.inSeconds, amount, ); AccountBlockUtils.createAccountBlock(transactionParams, 'create stake', - waitForRequiredPlasma: true) + waitForRequiredPlasma: true,) .then( (response) { ZenonAddressUtils.refreshBalance(); addEvent(response); }, ).onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/staking/staking_rewards_history_bloc.dart b/lib/blocs/staking/staking_rewards_history_bloc.dart index 34a3f14e..1af7d655 100644 --- a/lib/blocs/staking/staking_rewards_history_bloc.dart +++ b/lib/blocs/staking/staking_rewards_history_bloc.dart @@ -8,7 +8,7 @@ class StakingRewardsHistoryBloc extends BaseBlocForReloadingIndicator { @override Future getDataAsync() async { - RewardHistoryList? response = + final response = await zenon!.embedded.stake.getFrontierRewardByPage( Address.parse(kSelectedAddress!), pageSize: kStandardChartNumDays.toInt(), diff --git a/lib/blocs/tokens/burn_token_bloc.dart b/lib/blocs/tokens/burn_token_bloc.dart index e18495bd..6ba60b31 100644 --- a/lib/blocs/tokens/burn_token_bloc.dart +++ b/lib/blocs/tokens/burn_token_bloc.dart @@ -10,21 +10,19 @@ class BurnTokenBloc extends BaseBloc { BigInt amount, ) { try { - AccountBlockTemplate transactionParams = zenon!.embedded.token.burnToken( + final transactionParams = zenon!.embedded.token.burnToken( token.tokenStandard, amount, ); AccountBlockUtils.createAccountBlock(transactionParams, 'burn token', - waitForRequiredPlasma: true) + waitForRequiredPlasma: true,) .then( (response) { ZenonAddressUtils.refreshBalance(); addEvent(response); }, ).onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/tokens/issue_token_bloc.dart b/lib/blocs/tokens/issue_token_bloc.dart index 8075106c..7576cdb5 100644 --- a/lib/blocs/tokens/issue_token_bloc.dart +++ b/lib/blocs/tokens/issue_token_bloc.dart @@ -10,7 +10,7 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class IssueTokenBloc extends BaseBloc { void issueToken(NewTokenData tokenStepperData) { try { - AccountBlockTemplate transactionParams = zenon!.embedded.token.issueToken( + final transactionParams = zenon!.embedded.token.issueToken( tokenStepperData.tokenName, tokenStepperData.tokenSymbol, tokenStepperData.tokenDomain, @@ -19,7 +19,7 @@ class IssueTokenBloc extends BaseBloc { tokenStepperData.decimals, tokenStepperData.isMintable!, tokenStepperData.isOwnerBurnOnly!, - tokenStepperData.isUtility!); + tokenStepperData.isUtility!,); AccountBlockUtils.createAccountBlock( transactionParams, 'issue token', @@ -31,9 +31,7 @@ class IssueTokenBloc extends BaseBloc { addEvent(response); }, ).onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/tokens/mint_token_bloc.dart b/lib/blocs/tokens/mint_token_bloc.dart index fb06d9c0..dbeb7d08 100644 --- a/lib/blocs/tokens/mint_token_bloc.dart +++ b/lib/blocs/tokens/mint_token_bloc.dart @@ -11,13 +11,13 @@ class MintTokenBloc extends BaseBloc { Address beneficiaryAddress, ) { try { - AccountBlockTemplate transactionParams = zenon!.embedded.token.mintToken( + final transactionParams = zenon!.embedded.token.mintToken( token.tokenStandard, amount, beneficiaryAddress, ); AccountBlockUtils.createAccountBlock(transactionParams, 'mint token', - waitForRequiredPlasma: true) + waitForRequiredPlasma: true,) .then( (response) { response.amount = amount; @@ -25,9 +25,7 @@ class MintTokenBloc extends BaseBloc { addEvent(response); }, ).onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/tokens/token_map_bloc.dart b/lib/blocs/tokens/token_map_bloc.dart index 9756e1ad..b687fb6e 100644 --- a/lib/blocs/tokens/token_map_bloc.dart +++ b/lib/blocs/tokens/token_map_bloc.dart @@ -11,7 +11,6 @@ import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class TokenMapBloc with RefreshBlocMixin { - List? _allTokens; TokenMapBloc() { _onPageRequest.stream @@ -26,6 +25,7 @@ class TokenMapBloc with RefreshBlocMixin { listenToWsRestart(refreshResults); } + List? _allTokens; void refreshResults() { if (!_onSearchInputChangedSubject.isClosed) { @@ -73,10 +73,9 @@ class TokenMapBloc with RefreshBlocMixin { final newItems = await getData(pageKey, _pageSize, _searchInputTerm); final isLastPage = newItems.length < _pageSize; final nextPageKey = isLastPage ? null : pageKey + 1; - List allItems = [...lastListingState.itemList ?? [], ...newItems]; + var allItems = [...lastListingState.itemList ?? [], ...newItems]; allItems = filterItemsFunction(allItems); yield InfiniteScrollBlocListingState( - error: null, nextPageKey: nextPageKey, itemList: allItems, ); @@ -113,7 +112,7 @@ class TokenMapBloc with RefreshBlocMixin { } List _sortByIfTokenCreatedByUser(List tokens) { - List sortedTokens = tokens + final sortedTokens = tokens .where( (token) => kDefaultAddressList.contains( token.owner.toString(), @@ -127,15 +126,15 @@ class TokenMapBloc with RefreshBlocMixin { token.owner.toString(), ), ) - .toList()); + .toList(),); return sortedTokens; } List _sortByIfTokenIsInFavorites(List tokens) { - Box favoriteTokens = Hive.box(kFavoriteTokensBox); + final favoriteTokens = Hive.box(kFavoriteTokensBox); - List sortedTokens = tokens + final sortedTokens = tokens .where( (token) => favoriteTokens.values.contains( token.tokenStandard.toString(), @@ -149,7 +148,7 @@ class TokenMapBloc with RefreshBlocMixin { token.tokenStandard.toString(), ), ) - .toList()); + .toList(),); return sortedTokens; } @@ -166,7 +165,7 @@ class TokenMapBloc with RefreshBlocMixin { )) .list!; } else { - return await _getDataBySearchTerm(pageKey, pageSize, searchTerm); + return _getDataBySearchTerm(pageKey, pageSize, searchTerm); } } @@ -179,8 +178,8 @@ class TokenMapBloc with RefreshBlocMixin { String searchTerm, ) async { _allTokens ??= (await zenon!.embedded.token.getAll()).list!; - Iterable results = _allTokens!.where((token) => - token.symbol.toLowerCase().contains(searchTerm.toLowerCase())); + final results = _allTokens!.where((token) => + token.symbol.toLowerCase().contains(searchTerm.toLowerCase()),); results.toList().sublist( pageKey * pageSize, (pageKey + 1) * pageSize <= results.length @@ -189,7 +188,7 @@ class TokenMapBloc with RefreshBlocMixin { ); return results .where((token) => - token.symbol.toLowerCase().contains(searchTerm.toLowerCase())) + token.symbol.toLowerCase().contains(searchTerm.toLowerCase()),) .toList(); } } diff --git a/lib/blocs/tokens/tokens.dart b/lib/blocs/tokens/tokens.dart index 642296f0..a1a566c4 100644 --- a/lib/blocs/tokens/tokens.dart +++ b/lib/blocs/tokens/tokens.dart @@ -1,4 +1,3 @@ -library; export 'burn_token_bloc.dart'; export 'issue_token_bloc.dart'; diff --git a/lib/blocs/tokens/transfer_ownership_bloc.dart b/lib/blocs/tokens/transfer_ownership_bloc.dart index a5c7ca14..625a4fd8 100644 --- a/lib/blocs/tokens/transfer_ownership_bloc.dart +++ b/lib/blocs/tokens/transfer_ownership_bloc.dart @@ -11,7 +11,7 @@ class TransferOwnershipBloc extends BaseBloc { bool isBurnable, ) { try { - AccountBlockTemplate transactionParams = + final transactionParams = zenon!.embedded.token.updateToken( tokenStandard, owner, @@ -24,12 +24,10 @@ class TransferOwnershipBloc extends BaseBloc { waitForRequiredPlasma: true, ) .then( - (value) => addEvent(value), + addEvent, ) .onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/transfer/receive_transaction_bloc.dart b/lib/blocs/transfer/receive_transaction_bloc.dart index 83e347bb..3341b985 100644 --- a/lib/blocs/transfer/receive_transaction_bloc.dart +++ b/lib/blocs/transfer/receive_transaction_bloc.dart @@ -4,10 +4,10 @@ import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ReceiveTransactionBloc extends BaseBloc { - void receiveTransaction(String id, BuildContext context) async { + Future receiveTransaction(String id, BuildContext context) async { try { addEvent(null); - var response = await sl() + final response = await sl() .autoReceiveTransactionHash(Hash.parse(id)); addEvent(response); } catch (e, stackTrace) { diff --git a/lib/blocs/transfer/send_payment_bloc.dart b/lib/blocs/transfer/send_payment_bloc.dart index 626172b0..bc553430 100644 --- a/lib/blocs/transfer/send_payment_bloc.dart +++ b/lib/blocs/transfer/send_payment_bloc.dart @@ -4,7 +4,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class SendPaymentBloc extends BaseBloc { - void sendTransfer({ + Future sendTransfer({ // TODO: make this argument non-nullable String? fromAddress, String? toAddress, @@ -23,7 +23,7 @@ class SendPaymentBloc extends BaseBloc { ); try { addEvent(null); - AccountBlockTemplate accountBlock = block ?? + final accountBlock = block ?? AccountBlockTemplate.send( Address.parse(toAddress!), token!.tokenStandard, @@ -41,9 +41,7 @@ class SendPaymentBloc extends BaseBloc { addEvent(response); }, ).onError( - (error, stackTrace) { - addError(error, stackTrace); - }, + addError, ); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/transfer/transfer.dart b/lib/blocs/transfer/transfer.dart index 2010e7ed..e2c5bb2d 100644 --- a/lib/blocs/transfer/transfer.dart +++ b/lib/blocs/transfer/transfer.dart @@ -1,4 +1,3 @@ -library; export 'latest_transactions_bloc.dart'; export 'send_payment_bloc.dart'; diff --git a/lib/blocs/transfer/transfer_widgets_balance_bloc.dart b/lib/blocs/transfer/transfer_widgets_balance_bloc.dart index 7192d31e..93cd61a0 100644 --- a/lib/blocs/transfer/transfer_widgets_balance_bloc.dart +++ b/lib/blocs/transfer/transfer_widgets_balance_bloc.dart @@ -14,13 +14,13 @@ class TransferWidgetsBalanceBloc extends BaseBloc?> Future getBalanceForAllAddresses() async { try { addEvent(null); - Map addressBalanceMap = {}; - List accountInfoList = await Future.wait( + final addressBalanceMap = {}; + final accountInfoList = await Future.wait( kDefaultAddressList.map( (address) => _getBalancePerAddress(address!), ), ); - for (var accountInfo in accountInfoList) { + for (final accountInfo in accountInfoList) { addressBalanceMap[accountInfo.address!] = accountInfo; } addEvent(addressBalanceMap); @@ -30,7 +30,7 @@ class TransferWidgetsBalanceBloc extends BaseBloc?> } Future _getBalancePerAddress(String address) async => - await zenon!.ledger.getAccountInfoByAddress( + zenon!.ledger.getAccountInfoByAddress( Address.parse(address), ); } diff --git a/lib/blocs/wallet_connect/chains/nom_service.dart b/lib/blocs/wallet_connect/chains/nom_service.dart index 02bc3f1d..b6ab3bd1 100644 --- a/lib/blocs/wallet_connect/chains/nom_service.dart +++ b/lib/blocs/wallet_connect/chains/nom_service.dart @@ -23,15 +23,13 @@ enum NoMChainId { extension NoMChainIdX on NoMChainId { String chain() { - String name = ''; + var name = ''; switch (this) { case NoMChainId.mainnet: name = '1'; - break; case NoMChainId.testnet: name = '3'; - break; } return '${NoMService.namespace}:$name'; @@ -39,18 +37,6 @@ extension NoMChainIdX on NoMChainId { } class NoMService extends IChain { - static const namespace = 'zenon'; - - final IWeb3WalletService _web3WalletService = sl(); - - final NoMChainId reference; - - final _walletLockedError = const WalletConnectError( - code: 9000, - message: 'Wallet is locked', - ); - - Web3Wallet? wallet; NoMService({ required this.reference, @@ -78,6 +64,18 @@ class NoMService extends IChain { handler: _methodZnnSend, ); } + static const namespace = 'zenon'; + + final IWeb3WalletService _web3WalletService = sl(); + + final NoMChainId reference; + + final _walletLockedError = const WalletConnectError( + code: 9000, + message: 'Wallet is locked', + ); + + Web3Wallet? wallet; @override String getNamespace() { @@ -113,14 +111,13 @@ class NoMService extends IChain { title: '${dAppMetadata.name} - Information', content: Column( mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, children: [ Text('Are you sure you want to allow ${dAppMetadata.name} to ' 'retrieve the current address, node URL and chain identifier information?'), kVerticalSpacing, Image( image: NetworkImage(dAppMetadata.icons.first), - height: 100.0, + height: 100, fit: BoxFit.fitHeight, ), kVerticalSpacing, @@ -132,7 +129,7 @@ class NoMService extends IChain { Text(dAppMetadata.url), LinkIcon( url: dAppMetadata.url, - ) + ), ], ), ], @@ -150,7 +147,7 @@ class NoMService extends IChain { } else { await NotificationUtils.sendNotificationError( Errors.getSdkError(Errors.USER_REJECTED), - 'You have rejected the WalletConnect request'); + 'You have rejected the WalletConnect request',); throw Errors.getSdkError(Errors.USER_REJECTED); } } else { @@ -181,14 +178,13 @@ class NoMService extends IChain { title: '${dAppMetadata.name} - Sign Message', content: Column( mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, children: [ Text('Are you sure you want to ' 'sign message $message ?'), kVerticalSpacing, Image( image: NetworkImage(dAppMetadata.icons.first), - height: 100.0, + height: 100, fit: BoxFit.fitHeight, ), kVerticalSpacing, @@ -200,7 +196,7 @@ class NoMService extends IChain { Text(dAppMetadata.url), LinkIcon( url: dAppMetadata.url, - ) + ), ], ), ], @@ -210,11 +206,11 @@ class NoMService extends IChain { ); if (actionWasAccepted) { - return await walletSign(message.codeUnits); + return walletSign(message.codeUnits); } else { await NotificationUtils.sendNotificationError( Errors.getSdkError(Errors.USER_REJECTED), - 'You have rejected the WalletConnect request'); + 'You have rejected the WalletConnect request',); throw Errors.getSdkError(Errors.USER_REJECTED); } } else { @@ -257,7 +253,6 @@ class NoMService extends IChain { title: '${dAppMetadata.name} - Send Payment', content: Column( mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, children: [ Text('Are you sure you want to transfer ' '$amount ${token.symbol} to ' @@ -265,7 +260,7 @@ class NoMService extends IChain { kVerticalSpacing, Image( image: NetworkImage(dAppMetadata.icons.first), - height: 100.0, + height: 100, fit: BoxFit.fitHeight, ), kVerticalSpacing, @@ -277,7 +272,7 @@ class NoMService extends IChain { Text(dAppMetadata.url), LinkIcon( url: dAppMetadata.url, - ) + ), ], ), ], @@ -303,7 +298,7 @@ class NoMService extends IChain { } else { await NotificationUtils.sendNotificationError( Errors.getSdkError(Errors.USER_REJECTED), - 'You have rejected the WalletConnect request'); + 'You have rejected the WalletConnect request',); throw Errors.getSdkError(Errors.USER_REJECTED); } } else { diff --git a/lib/blocs/wallet_connect/wallet_connect_sessions_bloc.dart b/lib/blocs/wallet_connect/wallet_connect_sessions_bloc.dart index 4d91c736..a19f584e 100644 --- a/lib/blocs/wallet_connect/wallet_connect_sessions_bloc.dart +++ b/lib/blocs/wallet_connect/wallet_connect_sessions_bloc.dart @@ -10,7 +10,7 @@ class WalletConnectSessionsBloc extends InfiniteScrollBloc { Future> getData(int pageKey, int pageSize) async { final wcService = sl.get(); final sessions = []; - for (var pairing in wcService.pairings.value) { + for (final pairing in wcService.pairings.value) { sessions.addAll( wcService.getSessionsForPairing(pairing.topic).values, ); diff --git a/lib/embedded_node/embedded_node.dart b/lib/embedded_node/embedded_node.dart index 2cb5d5d9..429a23af 100644 --- a/lib/embedded_node/embedded_node.dart +++ b/lib/embedded_node/embedded_node.dart @@ -9,25 +9,23 @@ import 'package:logging/logging.dart'; import 'package:path/path.dart' as path; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; -var invalidZnnLibPathException = +ZnnSdkException invalidZnnLibPathException = ZnnSdkException('Library libznn could not be found'); typedef _StopNodeFunc = Pointer Function(); -typedef _StopNode = Pointer Function(); _StopNodeFunc? _stopNodeFunction; typedef _RunNodeFunc = Pointer Function(); -typedef _RunNode = Pointer Function(); _RunNodeFunc? _runNodeFunction; class EmbeddedNode { static void initializeNodeLib() { - var insideSdk = path.join('syrius', 'lib', 'embedded_node', 'blobs'); - var currentPathListParts = path.split(Directory.current.path); + final insideSdk = path.join('syrius', 'lib', 'embedded_node', 'blobs'); + final currentPathListParts = path.split(Directory.current.path); currentPathListParts.removeLast(); - var executablePathListParts = path.split(Platform.resolvedExecutable); + final executablePathListParts = path.split(Platform.resolvedExecutable); executablePathListParts.removeLast(); - var possiblePaths = List.empty(growable: true); + final possiblePaths = List.empty(growable: true); possiblePaths.add(Directory.current.path); possiblePaths.add( path.join( @@ -46,7 +44,7 @@ class EmbeddedNode { var libraryPath = ''; var found = false; - for (var currentPath in possiblePaths) { + for (final currentPath in possiblePaths) { libraryPath = path.join(currentPath, 'libznn.so'); if (Platform.isMacOS) { @@ -56,7 +54,7 @@ class EmbeddedNode { libraryPath = path.join(currentPath, 'libznn.dll'); } - var libFile = File(libraryPath); + final libFile = File(libraryPath); if (libFile.existsSync()) { found = true; @@ -77,16 +75,16 @@ class EmbeddedNode { final stopNodeFunctionPointer = dylib.lookup>('StopNode'); - _stopNodeFunction = stopNodeFunctionPointer.asFunction<_StopNode>(); + _stopNodeFunction = stopNodeFunctionPointer.asFunction Function()>(); final runNodeFunctionPointer = dylib.lookup>('RunNode'); - _runNodeFunction = runNodeFunctionPointer.asFunction<_RunNode>(); + _runNodeFunction = runNodeFunctionPointer.asFunction Function()>(); } - static void runNode(List args) async { - ReceivePort commandsPort = ReceivePort(); - SendPort sendPort = commandsPort.sendPort; + static Future runNode(List args) async { + final commandsPort = ReceivePort(); + final sendPort = commandsPort.sendPort; IsolateNameServer.registerPortWithName(sendPort, 'embeddedIsolate'); @@ -95,7 +93,7 @@ class EmbeddedNode { } _runNodeFunction!(); - Completer embeddedIsolateCompleter = Completer(); + final embeddedIsolateCompleter = Completer(); commandsPort.listen((event) { _stopNodeFunction!(); IsolateNameServer.removePortNameMapping('embeddedIsolate'); @@ -113,7 +111,7 @@ class EmbeddedNode { } static bool stopNode() { - SendPort? embeddedIsolate = + final embeddedIsolate = IsolateNameServer.lookupPortByName('embeddedIsolate'); if (embeddedIsolate != null) { embeddedIsolate.send('stop'); diff --git a/lib/handlers/htlc_swaps_handler.dart b/lib/handlers/htlc_swaps_handler.dart index 5181de93..135208d3 100644 --- a/lib/handlers/htlc_swaps_handler.dart +++ b/lib/handlers/htlc_swaps_handler.dart @@ -30,7 +30,7 @@ class HtlcSwapsHandler { bool get hasActiveIncomingSwaps => htlcSwapsService!.getSwapsByState([P2pSwapState.active]).firstWhereOrNull( - (e) => e.direction == P2pSwapDirection.incoming) != + (e) => e.direction == P2pSwapDirection.incoming,) != null; Future _runPeriodically() async { @@ -41,7 +41,7 @@ class HtlcSwapsHandler { final unresolvedSwaps = htlcSwapsService!.getSwapsByState([ P2pSwapState.pending, P2pSwapState.active, - P2pSwapState.reclaimable + P2pSwapState.reclaimable, ]); if (unresolvedSwaps.isNotEmpty) { if (await _areThereNewHtlcBlocks()) { @@ -56,7 +56,7 @@ class HtlcSwapsHandler { } catch (e) { Logger('HtlcSwapsHandler').log(Level.WARNING, '_runPeriodically', e); } finally { - Future.delayed(const Duration(seconds: 5), () => _runPeriodically()); + Future.delayed(const Duration(seconds: 5), _runPeriodically); } } @@ -91,13 +91,13 @@ class HtlcSwapsHandler { Future> _getNewHtlcBlocks(List swaps) async { final lastCheckedHeight = htlcSwapsService!.getLastCheckedHtlcBlockHeight(); final oldestSwapStartTime = _getOldestSwapStartTime(swaps) ?? 0; - int lastCheckedBlockTime = 0; + var lastCheckedBlockTime = 0; if (lastCheckedHeight > 0) { try { lastCheckedBlockTime = (await AccountBlockUtils.getTimeForAccountBlockHeight( - htlcAddress, lastCheckedHeight)) ?? + htlcAddress, lastCheckedHeight,)) ?? lastCheckedBlockTime; } catch (e, stackTrace) { Logger('HtlcSwapsHandler') @@ -108,7 +108,7 @@ class HtlcSwapsHandler { try { return await AccountBlockUtils.getAccountBlocksAfterTime( - htlcAddress, max(oldestSwapStartTime, lastCheckedBlockTime)); + htlcAddress, max(oldestSwapStartTime, lastCheckedBlockTime),); } catch (e, stackTrace) { Logger('HtlcSwapsHandler') .log(Level.WARNING, '_getNewHtlcBlocks', e, stackTrace); @@ -130,7 +130,7 @@ class HtlcSwapsHandler { final pairedBlock = htlcBlock.pairedAccountBlock!; final blockData = AccountBlockUtils.getDecodedBlockData( - Definitions.htlc, pairedBlock.data); + Definitions.htlc, pairedBlock.data,); if (blockData == null) { return; @@ -198,7 +198,7 @@ class HtlcSwapsHandler { if (htlcBlock.descendantBlocks.isEmpty) { return; } - bool isSelfReclaim = false; + var isSelfReclaim = false; if (swap.direction == P2pSwapDirection.outgoing && blockData.params['id'].toString() == swap.initialHtlcId) { isSelfReclaim = true; @@ -221,7 +221,7 @@ class HtlcSwapsHandler { } if (data.params.containsKey('hashLock') && swap == null) { swap = htlcSwapsService!.getSwapByHashLock( - Hash.fromBytes(data.params['hashLock']).toString()); + Hash.fromBytes(data.params['hashLock']).toString(),); } return swap; } diff --git a/lib/main.dart b/lib/main.dart index cdacaf88..b957e990 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -18,11 +18,11 @@ import 'package:tray_manager/tray_manager.dart'; import 'package:window_manager/window_manager.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/auto_unlock_htlc_worker.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; -import 'package:zenon_syrius_wallet_flutter/handlers/htlc_swaps_handler.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/wallet_connect/chains/i_chain.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/wallet_connect/chains/nom_service.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/wallet_connect/wallet_connect_pairings_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/wallet_connect/wallet_connect_sessions_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/handlers/htlc_swaps_handler.dart'; import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; import 'package:zenon_syrius_wallet_flutter/services/htlc_swaps_service.dart'; @@ -49,16 +49,16 @@ main() async { Provider.debugCheckInvalidValueType = null; ensureDirectoriesExist(); - Hive.init(znnDefaultPaths.cache.path.toString()); + Hive.init(znnDefaultPaths.cache.path); // Setup logger - Directory syriusLogDir = + final syriusLogDir = Directory(path.join(znnDefaultCacheDirectory.path, 'log')); if (!syriusLogDir.existsSync()) { syriusLogDir.createSync(recursive: true); } final logFile = File( - '${syriusLogDir.path}${path.separator}syrius-${DateTime.now().millisecondsSinceEpoch}.log'); + '${syriusLogDir.path}${path.separator}syrius-${DateTime.now().millisecondsSinceEpoch}.log',); Logger.root.level = Level.ALL; Logger.root.onRecord.listen((LogRecord record) { if (kDebugMode) { @@ -85,13 +85,11 @@ main() async { retry(() => web3WalletService!.init(), retryIf: (e) => e is SocketException || e is TimeoutException, - maxAttempts: 0x7FFFFFFFFFFFFFFF); + maxAttempts: 0x7FFFFFFFFFFFFFFF,); // Setup local_notifier await localNotifier.setup( appName: 's y r i u s', - // The parameter shortcutPolicy only works on Windows - shortcutPolicy: ShortcutPolicy.requireCreate, ); // Setup tray manager @@ -118,8 +116,8 @@ main() async { await windowManager.show(); if (sharedPrefsService != null) { - double? windowSizeWidth = sharedPrefsService!.get(kWindowSizeWidthKey); - double? windowSizeHeight = sharedPrefsService!.get(kWindowSizeHeightKey); + final double? windowSizeWidth = sharedPrefsService!.get(kWindowSizeWidthKey); + final double? windowSizeHeight = sharedPrefsService!.get(kWindowSizeHeightKey); if (windowSizeWidth != null && windowSizeWidth >= 1200 && windowSizeHeight != null && @@ -138,7 +136,7 @@ main() async { .setPosition(Offset(windowPositionX, windowPositionY)); } - bool? windowMaximized = sharedPrefsService!.get(kWindowMaximizedKey); + final bool? windowMaximized = sharedPrefsService!.get(kWindowMaximizedKey); if (windowMaximized == true) { await windowManager.maximize(); } @@ -159,7 +157,7 @@ Future _setupTrayManager() async { if (Platform.isMacOS) { await trayManager.setToolTip('s y r i u s'); } - List items = [ + final items = [ MenuItem( key: 'show_wallet', label: 'Show wallet', @@ -179,7 +177,7 @@ Future _setupTrayManager() async { Future _loadDefaultCommunityNodes() async { try { - var nodes = await loadJsonFromAssets('assets/community-nodes.json') + final nodes = await loadJsonFromAssets('assets/community-nodes.json') as List; kDefaultCommunityNodes = nodes .map((node) => node.toString()) @@ -195,7 +193,7 @@ void setup() { sl.registerSingleton(Zenon()); zenon = sl(); sl.registerLazySingletonAsync( - (() => SharedPrefsService.getInstance().then((value) => value!))); + () => SharedPrefsService.getInstance().then((value) => value!),); sl.registerSingleton(HtlcSwapsService.getInstance()); // Initialize WalletConnect service @@ -207,20 +205,20 @@ void setup() { sl.registerSingleton(AutoReceiveTxWorker.getInstance()); sl.registerSingleton( - AutoUnlockHtlcWorker.getInstance()); + AutoUnlockHtlcWorker.getInstance(),); sl.registerSingleton(HtlcSwapsHandler.getInstance()); sl.registerSingleton(ReceivePort(), - instanceName: 'embeddedStoppedPort'); + instanceName: 'embeddedStoppedPort',); sl.registerSingleton( sl(instanceName: 'embeddedStoppedPort').asBroadcastStream(), - instanceName: 'embeddedStoppedStream'); + instanceName: 'embeddedStoppedStream',); sl.registerSingleton(PlasmaStatsBloc()); sl.registerSingleton(BalanceBloc()); sl.registerSingleton( - TransferWidgetsBalanceBloc()); + TransferWidgetsBalanceBloc(),); sl.registerSingleton(NotificationsBloc()); sl.registerSingleton(AcceleratorBalanceBloc()); sl.registerSingleton(PowGeneratingStatusBloc()); @@ -287,7 +285,7 @@ class _MyAppState extends State with WindowListener, TrayListener { builder: (context, child) { return Consumer( builder: (_, appThemeNotifier, __) { - LockBloc lockBloc = + final lockBloc = Provider.of(context, listen: false); return OverlaySupport( child: Listener( @@ -335,7 +333,7 @@ class _MyAppState extends State with WindowListener, TrayListener { }, onGenerateRoute: (settings) { if (settings.name == SyriusErrorWidget.route) { - final args = settings.arguments + final args = settings.arguments! as CustomSyriusErrorWidgetArguments; return MaterialPageRoute( builder: (context) => @@ -359,15 +357,15 @@ class _MyAppState extends State with WindowListener, TrayListener { } @override - void onWindowClose() async { - bool windowMaximized = await windowManager.isMaximized(); + Future onWindowClose() async { + final windowMaximized = await windowManager.isMaximized(); await sharedPrefsService!.put( kWindowMaximizedKey, windowMaximized, ); if (windowMaximized != true) { - Size windowSize = await windowManager.getSize(); + final windowSize = await windowManager.getSize(); await sharedPrefsService!.put( kWindowSizeWidthKey, windowSize.width, @@ -377,7 +375,7 @@ class _MyAppState extends State with WindowListener, TrayListener { windowSize.height, ); - Offset windowPosition = await windowManager.getPosition(); + final windowPosition = await windowManager.getPosition(); await sharedPrefsService!.put( kWindowPositionXKey, windowPosition.dx, @@ -410,19 +408,16 @@ class _MyAppState extends State with WindowListener, TrayListener { void onTrayIconRightMouseUp() {} @override - void onTrayMenuItemClick(MenuItem menuItem) async { + Future onTrayMenuItemClick(MenuItem menuItem) async { switch (menuItem.key) { case 'show_wallet': windowManager.show(); - break; case 'hide_wallet': if (!await windowManager.isMinimized()) { windowManager.minimize(); } - break; case 'exit': windowManager.destroy(); - break; default: break; } diff --git a/lib/main_dev.dart b/lib/main_dev.dart index a59b89fb..b5c61356 100644 --- a/lib/main_dev.dart +++ b/lib/main_dev.dart @@ -17,11 +17,11 @@ import 'package:tray_manager/tray_manager.dart'; import 'package:window_manager/window_manager.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/auto_unlock_htlc_worker.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; -import 'package:zenon_syrius_wallet_flutter/handlers/htlc_swaps_handler.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/wallet_connect/chains/i_chain.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/wallet_connect/chains/nom_service.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/wallet_connect/wallet_connect_pairings_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/wallet_connect/wallet_connect_sessions_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/handlers/htlc_swaps_handler.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; @@ -42,16 +42,16 @@ main() async { Provider.debugCheckInvalidValueType = null; ensureDirectoriesExist(); - Hive.init(znnDefaultPaths.cache.path.toString()); + Hive.init(znnDefaultPaths.cache.path); // Setup logger - Directory syriusLogDir = + final syriusLogDir = Directory(path.join(znnDefaultCacheDirectory.path, 'log')); if (!syriusLogDir.existsSync()) { syriusLogDir.createSync(recursive: true); } final logFile = File( - '${syriusLogDir.path}${path.separator}syrius-${DateTime.now().millisecondsSinceEpoch}.log'); + '${syriusLogDir.path}${path.separator}syrius-${DateTime.now().millisecondsSinceEpoch}.log',); Logger.root.level = Level.ALL; Logger.root.onRecord.listen((LogRecord record) { if (kDebugMode) { @@ -78,13 +78,11 @@ main() async { retry(() => web3WalletService!.init(), retryIf: (e) => e is SocketException || e is TimeoutException, - maxAttempts: 0x7FFFFFFFFFFFFFFF); + maxAttempts: 0x7FFFFFFFFFFFFFFF,); // Setup local_notifier await localNotifier.setup( appName: 's y r i u s', - // The parameter shortcutPolicy only works on Windows - shortcutPolicy: ShortcutPolicy.requireCreate, ); // Setup tray manager @@ -111,8 +109,8 @@ main() async { await windowManager.show(); if (sharedPrefsService != null) { - double? windowSizeWidth = sharedPrefsService!.get(kWindowSizeWidthKey); - double? windowSizeHeight = sharedPrefsService!.get(kWindowSizeHeightKey); + final double? windowSizeWidth = sharedPrefsService!.get(kWindowSizeWidthKey); + final double? windowSizeHeight = sharedPrefsService!.get(kWindowSizeHeightKey); if (windowSizeWidth != null && windowSizeWidth >= 1200 && windowSizeHeight != null && @@ -131,7 +129,7 @@ main() async { .setPosition(Offset(windowPositionX, windowPositionY)); } - bool? windowMaximized = sharedPrefsService!.get(kWindowMaximizedKey); + final bool? windowMaximized = sharedPrefsService!.get(kWindowMaximizedKey); if (windowMaximized == true) { await windowManager.maximize(); } @@ -152,7 +150,7 @@ Future _setupTrayManager() async { if (Platform.isMacOS) { await trayManager.setToolTip('s y r i u s'); } - List items = [ + final items = [ MenuItem( key: 'show_wallet', label: 'Show wallet', @@ -172,7 +170,7 @@ Future _setupTrayManager() async { Future _loadDefaultCommunityNodes() async { try { - var nodes = await loadJsonFromAssets('assets/community-nodes.json') + final nodes = await loadJsonFromAssets('assets/community-nodes.json') as List; kDefaultCommunityNodes = nodes .map((node) => node.toString()) @@ -188,7 +186,7 @@ void setup() { sl.registerSingleton(Zenon()); zenon = sl(); sl.registerLazySingletonAsync( - (() => SharedPrefsService.getInstance().then((value) => value!))); + () => SharedPrefsService.getInstance().then((value) => value!),); sl.registerSingleton(HtlcSwapsService.getInstance()); // Initialize WalletConnect service @@ -200,20 +198,20 @@ void setup() { sl.registerSingleton(AutoReceiveTxWorker.getInstance()); sl.registerSingleton( - AutoUnlockHtlcWorker.getInstance()); + AutoUnlockHtlcWorker.getInstance(),); sl.registerSingleton(HtlcSwapsHandler.getInstance()); sl.registerSingleton(ReceivePort(), - instanceName: 'embeddedStoppedPort'); + instanceName: 'embeddedStoppedPort',); sl.registerSingleton( sl(instanceName: 'embeddedStoppedPort').asBroadcastStream(), - instanceName: 'embeddedStoppedStream'); + instanceName: 'embeddedStoppedStream',); sl.registerSingleton(PlasmaStatsBloc()); sl.registerSingleton(BalanceBloc()); sl.registerSingleton( - TransferWidgetsBalanceBloc()); + TransferWidgetsBalanceBloc(),); sl.registerSingleton(NotificationsBloc()); sl.registerSingleton(AcceleratorBalanceBloc()); sl.registerSingleton(PowGeneratingStatusBloc()); @@ -280,7 +278,7 @@ class _MyAppState extends State with WindowListener, TrayListener { builder: (context, child) { return Consumer( builder: (_, appThemeNotifier, __) { - LockBloc lockBloc = + final lockBloc = Provider.of(context, listen: false); return OverlaySupport( child: Listener( @@ -328,7 +326,7 @@ class _MyAppState extends State with WindowListener, TrayListener { }, onGenerateRoute: (settings) { if (settings.name == SyriusErrorWidget.route) { - final args = settings.arguments + final args = settings.arguments! as CustomSyriusErrorWidgetArguments; return MaterialPageRoute( builder: (context) => @@ -352,15 +350,15 @@ class _MyAppState extends State with WindowListener, TrayListener { } @override - void onWindowClose() async { - bool windowMaximized = await windowManager.isMaximized(); + Future onWindowClose() async { + final windowMaximized = await windowManager.isMaximized(); await sharedPrefsService!.put( kWindowMaximizedKey, windowMaximized, ); if (windowMaximized != true) { - Size windowSize = await windowManager.getSize(); + final windowSize = await windowManager.getSize(); await sharedPrefsService!.put( kWindowSizeWidthKey, windowSize.width, @@ -370,7 +368,7 @@ class _MyAppState extends State with WindowListener, TrayListener { windowSize.height, ); - Offset windowPosition = await windowManager.getPosition(); + final windowPosition = await windowManager.getPosition(); await sharedPrefsService!.put( kWindowPositionXKey, windowPosition.dx, @@ -403,19 +401,16 @@ class _MyAppState extends State with WindowListener, TrayListener { void onTrayIconRightMouseUp() {} @override - void onTrayMenuItemClick(MenuItem menuItem) async { + Future onTrayMenuItemClick(MenuItem menuItem) async { switch (menuItem.key) { case 'show_wallet': windowManager.show(); - break; case 'hide_wallet': if (!await windowManager.isMinimized()) { windowManager.minimize(); } - break; case 'exit': windowManager.destroy(); - break; default: break; } diff --git a/lib/model/account_chain_stats.dart b/lib/model/account_chain_stats.dart index 68c28d73..06cdc892 100644 --- a/lib/model/account_chain_stats.dart +++ b/lib/model/account_chain_stats.dart @@ -1,13 +1,13 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class AccountChainStats { - final Hash firstHash; - final int blockCount; - final Map blockTypeNumOfBlocksMap; AccountChainStats({ required this.firstHash, required this.blockCount, required this.blockTypeNumOfBlocksMap, }); + final Hash firstHash; + final int blockCount; + final Map blockTypeNumOfBlocksMap; } diff --git a/lib/model/basic_dropdown_item.dart b/lib/model/basic_dropdown_item.dart index c8bf5aa4..a57a49ad 100644 --- a/lib/model/basic_dropdown_item.dart +++ b/lib/model/basic_dropdown_item.dart @@ -1,9 +1,9 @@ class BasicDropdownItem { - final String label; - final T value; BasicDropdownItem({ required this.label, required this.value, }); + final String label; + final T value; } diff --git a/lib/model/block_data.dart b/lib/model/block_data.dart index d8eeae0f..d6dfeb3c 100644 --- a/lib/model/block_data.dart +++ b/lib/model/block_data.dart @@ -1,9 +1,9 @@ class BlockData { - final String function; - final Map params; BlockData({ required this.function, required this.params, }); + final String function; + final Map params; } diff --git a/lib/model/database/wallet_notification.dart b/lib/model/database/wallet_notification.dart index 18814228..7dd36ced 100644 --- a/lib/model/database/wallet_notification.dart +++ b/lib/model/database/wallet_notification.dart @@ -9,6 +9,14 @@ part 'wallet_notification.g.dart'; @HiveType(typeId: kWalletNotificationHiveTypeId) class WalletNotification extends HiveObject { + + WalletNotification({ + required this.title, + required this.timestamp, + required this.details, + required this.type, + this.id, + }); @HiveField(0) final String? title; @@ -24,14 +32,6 @@ class WalletNotification extends HiveObject { @HiveField(4) final int? id; - WalletNotification({ - required this.title, - required this.timestamp, - required this.details, - required this.type, - this.id, - }); - Color getColor() { switch (type) { case NotificationType.error: @@ -47,11 +47,11 @@ class WalletNotification extends HiveObject { switch (type) { case NotificationType.stakingDeactivated: return _getCircledIcon(MaterialCommunityIcons.alert_circle_outline, - iconColor: Colors.grey); + iconColor: Colors.grey,); case NotificationType.error: return const Icon( MaterialCommunityIcons.alert_circle_outline, - size: 20.0, + size: 20, color: AppColors.errorColor, ); case NotificationType.paymentSent: @@ -80,7 +80,7 @@ class WalletNotification extends HiveObject { return _getCircledIcon(Icons.delete_forever); case NotificationType.confirm: return _getCircledIcon(Icons.remove_red_eye, - iconColor: AppColors.alertNotification); + iconColor: AppColors.alertNotification,); default: return _getCircledIcon(MaterialCommunityIcons.arrow_top_right); } @@ -91,20 +91,19 @@ class WalletNotification extends HiveObject { Color iconColor = AppColors.znnColor, }) { return Container( - padding: const EdgeInsets.all(2.0), + padding: const EdgeInsets.all(2), decoration: BoxDecoration( border: Border.all( - width: 1.0, color: iconColor, ), borderRadius: BorderRadius.circular( - 50.0, + 50, ), ), child: Icon( iconData, color: iconColor, - size: 10.0, + size: 10, ), ); } diff --git a/lib/model/general_stats.dart b/lib/model/general_stats.dart index e0933aeb..119df6a6 100644 --- a/lib/model/general_stats.dart +++ b/lib/model/general_stats.dart @@ -1,22 +1,19 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class GeneralStats { - final Momentum frontierMomentum; - final ProcessInfo processInfo; - final NetworkInfo networkInfo; - final OsInfo osInfo; GeneralStats( {required this.frontierMomentum, required this.processInfo, required this.networkInfo, - required this.osInfo}); + required this.osInfo,}); + final Momentum frontierMomentum; + final ProcessInfo processInfo; + final NetworkInfo networkInfo; + final OsInfo osInfo; } class LatestMomentum { - final String hash; - final int? height; - final int? time; LatestMomentum({ required this.hash, @@ -29,4 +26,7 @@ class LatestMomentum { height: json['Height'], time: json['Time'], ); + final String hash; + final int? height; + final int? time; } diff --git a/lib/model/model.dart b/lib/model/model.dart index ce36f258..f0a01d16 100644 --- a/lib/model/model.dart +++ b/lib/model/model.dart @@ -5,8 +5,8 @@ export 'database/wallet_notification.dart'; export 'general_stats.dart'; export 'navigation_arguments.dart'; export 'new_token_data.dart'; +export 'p2p_swap/htlc_swap.dart'; +export 'p2p_swap/p2p_swap.dart'; export 'pillars_qsr_info.dart'; export 'plasma_info_wrapper.dart'; -export 'p2p_swap/p2p_swap.dart'; -export 'p2p_swap/htlc_swap.dart'; export 'sentinels_qsr_info.dart'; diff --git a/lib/model/navigation_arguments.dart b/lib/model/navigation_arguments.dart index 17c87d8b..dc3e1cdd 100644 --- a/lib/model/navigation_arguments.dart +++ b/lib/model/navigation_arguments.dart @@ -1,5 +1,5 @@ class CustomSyriusErrorWidgetArguments { - final String errorText; CustomSyriusErrorWidgetArguments(this.errorText); + final String errorText; } diff --git a/lib/model/p2p_swap/htlc_swap.dart b/lib/model/p2p_swap/htlc_swap.dart index 4520539c..da396041 100644 --- a/lib/model/p2p_swap/htlc_swap.dart +++ b/lib/model/p2p_swap/htlc_swap.dart @@ -1,13 +1,6 @@ import 'package:zenon_syrius_wallet_flutter/model/p2p_swap/p2p_swap.dart'; class HtlcSwap extends P2pSwap { - final String hashLock; - final String initialHtlcId; - final int initialHtlcExpirationTime; - final int hashType; - String? counterHtlcId; - int? counterHtlcExpirationTime; - String? preimage; HtlcSwap({ required this.hashLock, @@ -46,6 +39,13 @@ class HtlcSwap extends P2pSwap { counterHtlcExpirationTime = json['counterHtlcExpirationTime'], preimage = json['preimage'], super.fromJson(); + final String hashLock; + final String initialHtlcId; + final int initialHtlcExpirationTime; + final int hashType; + String? counterHtlcId; + int? counterHtlcExpirationTime; + String? preimage; @override Map toJson() { diff --git a/lib/model/p2p_swap/p2p_swap.dart b/lib/model/p2p_swap/p2p_swap.dart index b06ffd9b..6c3ffd2c 100644 --- a/lib/model/p2p_swap/p2p_swap.dart +++ b/lib/model/p2p_swap/p2p_swap.dart @@ -28,25 +28,6 @@ enum P2pSwapChain { } class P2pSwap { - final String id; - final int chainId; - final P2pSwapType type; - final P2pSwapMode mode; - final P2pSwapDirection direction; - final String selfAddress; - final String counterpartyAddress; - final BigInt fromAmount; - final String fromTokenStandard; - final String fromSymbol; - final int fromDecimals; - final P2pSwapChain fromChain; - final P2pSwapChain toChain; - final int startTime; - P2pSwapState state; - BigInt? toAmount; - String? toTokenStandard; - String? toSymbol; - int? toDecimals; P2pSwap( {required this.id, @@ -67,7 +48,7 @@ class P2pSwap { this.toAmount, this.toTokenStandard, this.toSymbol, - this.toDecimals}); + this.toDecimals,}); P2pSwap.fromJson(Map json) : id = json['id'], @@ -89,6 +70,25 @@ class P2pSwap { toTokenStandard = json['toTokenStandard'], toSymbol = json['toSymbol'], toDecimals = json['toDecimals']; + final String id; + final int chainId; + final P2pSwapType type; + final P2pSwapMode mode; + final P2pSwapDirection direction; + final String selfAddress; + final String counterpartyAddress; + final BigInt fromAmount; + final String fromTokenStandard; + final String fromSymbol; + final int fromDecimals; + final P2pSwapChain fromChain; + final P2pSwapChain toChain; + final int startTime; + P2pSwapState state; + BigInt? toAmount; + String? toTokenStandard; + String? toSymbol; + int? toDecimals; Map toJson() => { 'id': id, diff --git a/lib/model/pillars_qsr_info.dart b/lib/model/pillars_qsr_info.dart index 4da14a40..556fff9e 100644 --- a/lib/model/pillars_qsr_info.dart +++ b/lib/model/pillars_qsr_info.dart @@ -1,9 +1,9 @@ class PillarsQsrInfo { - final BigInt cost; - final BigInt deposit; PillarsQsrInfo({ required this.cost, required this.deposit, }); + final BigInt cost; + final BigInt deposit; } diff --git a/lib/model/plasma_info_wrapper.dart b/lib/model/plasma_info_wrapper.dart index ee535fa9..3950da39 100644 --- a/lib/model/plasma_info_wrapper.dart +++ b/lib/model/plasma_info_wrapper.dart @@ -1,11 +1,11 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PlasmaInfoWrapper { - final String address; - final PlasmaInfo plasmaInfo; PlasmaInfoWrapper({ required this.address, required this.plasmaInfo, }); + final String address; + final PlasmaInfo plasmaInfo; } diff --git a/lib/model/sentinels_qsr_info.dart b/lib/model/sentinels_qsr_info.dart index 5a627e53..1ad20c37 100644 --- a/lib/model/sentinels_qsr_info.dart +++ b/lib/model/sentinels_qsr_info.dart @@ -1,9 +1,9 @@ class SentinelsQsrInfo { - final BigInt cost; - final BigInt deposit; SentinelsQsrInfo({ required this.cost, required this.deposit, }); + final BigInt cost; + final BigInt deposit; } diff --git a/lib/rearchitecture/dashboard/balance/balance.dart b/lib/rearchitecture/dashboard/balance/balance.dart index e23b4c06..aa75b9f8 100644 --- a/lib/rearchitecture/dashboard/balance/balance.dart +++ b/lib/rearchitecture/dashboard/balance/balance.dart @@ -1,3 +1,3 @@ export 'cubit/balance_cubit.dart'; -export 'widgets/widgets.dart'; -export 'view/balance_card.dart'; \ No newline at end of file +export 'view/balance_card.dart'; +export 'widgets/widgets.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart b/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart index 982e5ec6..86688667 100644 --- a/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart +++ b/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart @@ -11,8 +11,6 @@ part 'balance_state.dart'; /// represented as a `Map` of addresses and their associated `AccountInfo`. class BalanceCubit extends DashboardCubit { - - final Address address; /// Constructs a `BalanceCubit` with the provided `zenon` client and initial state. /// /// The [zenon] parameter provides access to the Zenon SDK for interacting with @@ -20,6 +18,8 @@ class BalanceCubit extends DashboardCubit { /// respective balances at the time the cubit is initialized. BalanceCubit(this.address, super.zenon, super.initialState); + final Address address; + /// Fetches the balance information for a single address. /// /// The method interacts with the `zenon` client's ledger to get the @@ -30,7 +30,7 @@ class BalanceCubit extends DashboardCubit { /// Throws an exception if the balance retrieval fails. @override Future fetch() async { - AccountInfo response = await zenon.ledger + final response = await zenon.ledger .getAccountInfoByAddress(address); if (response.blockCount! > 0 && (response.znn()! > BigInt.zero || response.qsr()! > BigInt.zero)) { diff --git a/lib/rearchitecture/dashboard/balance/view/balance_card.dart b/lib/rearchitecture/dashboard/balance/view/balance_card.dart index bfb11048..5d3a4452 100644 --- a/lib/rearchitecture/dashboard/balance/view/balance_card.dart +++ b/lib/rearchitecture/dashboard/balance/view/balance_card.dart @@ -26,10 +26,10 @@ class BalanceCard extends StatelessWidget { // Creates a `BalanceCubit` instance, passing in the `zenon` client // and an initial `BalanceState`. The cubit immediately begins fetching // balance data by calling `fetch()`. - final BalanceCubit cubit = BalanceCubit( + final cubit = BalanceCubit( Address.parse(kSelectedAddress!), zenon!, - BalanceState(), + const BalanceState(), ); cubit.fetchDataPeriodically(); return cubit; diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_address.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_address.dart index fc57ae8b..cb5f2ff2 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_address.dart +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_address.dart @@ -10,14 +10,14 @@ import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; /// and changes the value of the [edgesColorNotifier] class BalanceAddress extends StatelessWidget { - final String address; - final ValueNotifier edgesColorNotifier; const BalanceAddress({ required this.address, required this.edgesColorNotifier, super.key, }); + final String address; + final ValueNotifier edgesColorNotifier; @override Widget build(BuildContext context) { @@ -36,15 +36,15 @@ class BalanceAddress extends StatelessWidget { decoration: BoxDecoration( color: Theme.of(context).colorScheme.surface, border: Border.all(color: Theme.of(context).colorScheme.surface), - borderRadius: BorderRadius.circular(15.0), + borderRadius: BorderRadius.circular(15), ), padding: const EdgeInsets.symmetric( - vertical: 4.0, - horizontal: 8.0, + vertical: 4, + horizontal: 8, ), margin: const EdgeInsets.only( - bottom: 12.0, - top: 12.0, + bottom: 12, + top: 12, ), child: AutoSizeText.rich( TextSpan( diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_chart.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_chart.dart index b497d192..ac55612b 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_chart.dart +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_chart.dart @@ -11,19 +11,18 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// readable format - to appear in the center of the chart class BalanceChart extends StatelessWidget { - final AccountInfo accountInfo; - final ValueNotifier touchedSectionId; const BalanceChart({ required this.accountInfo, required this.touchedSectionId, super.key, }); + final AccountInfo accountInfo; + final ValueNotifier touchedSectionId; @override Widget build(BuildContext context) { return StandardPieChart( - sectionsSpace: 0.0, sections: _getChartSection(accountInfo), onChartSectionTouched: (pieChartSection) { touchedSectionId.value = pieChartSection?.touchedSection?.title; @@ -32,7 +31,7 @@ class BalanceChart extends StatelessWidget { } List _getChartSection(AccountInfo accountInfo) { - List sections = []; + final sections = []; if (accountInfo.znn()! > BigInt.zero) { sections.add( _getBalanceChartSection( @@ -59,15 +58,15 @@ class BalanceChart extends StatelessWidget { ) { final isTouched = token.tokenStandard.toString() == touchedSectionId.value; - final double opacity = isTouched ? 1.0 : 0.7; + final opacity = isTouched ? 1.0 : 0.7; - double value = accountInfo.getBalance(token.tokenStandard) / + final value = accountInfo.getBalance(token.tokenStandard) / (accountInfo.znn()! + accountInfo.qsr()!); return PieChartSectionData( title: token.tokenStandard.toString(), showTitle: false, - radius: 7.0, + radius: 7, color: ColorUtils.getTokenColor(token.tokenStandard).withOpacity(opacity), value: value, ); diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_chart_legend.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_chart_legend.dart index 8427d6ad..81cd0e52 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_chart_legend.dart +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_chart_legend.dart @@ -1,17 +1,17 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/balance/widgets/balance_chart.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/balance/widgets/balance_chart.dart'; /// Adds a legend to the [BalanceChart] consisting of widgets with a tooltip /// than will show the exact balance - including decimals - available in a /// certain coin (QSR or ZNN) class BalanceChartLegend extends StatelessWidget { - final AccountInfo accountInfo; const BalanceChartLegend({required this.accountInfo, super.key}); + final AccountInfo accountInfo; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart index b8c1d5ff..507a3593 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart @@ -11,6 +11,6 @@ class BalanceEmpty extends StatelessWidget { @override Widget build(BuildContext context) { - return SyriusErrorWidget('No data available'); + return const SyriusErrorWidget('No data available'); } } diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_error.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_error.dart index 82405c8e..478e10fb 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_error.dart +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_error.dart @@ -7,9 +7,9 @@ import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widge /// This widget is displayed when the `BalanceCubit` encounters an error /// while trying to load the balance data. class BalanceError extends StatelessWidget { - final Object error; const BalanceError({required this.error, super.key}); + final Object error; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_loading.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_loading.dart index 2a2da414..80e26e3e 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_loading.dart +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_loading.dart @@ -11,6 +11,6 @@ class BalanceLoading extends StatelessWidget { @override Widget build(BuildContext context) { - return SyriusLoadingWidget(); + return const SyriusLoadingWidget(); } } diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_populated.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_populated.dart index 9d59c228..460e6674 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_populated.dart +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_populated.dart @@ -10,6 +10,12 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// This widget is displayed when the `BalanceCubit` is in the `success` state, /// and the balance data is available for rendering. class BalancePopulated extends StatefulWidget { + + const BalancePopulated({ + required this.address, + required this.accountInfo, + super.key, + }); /// The balance data that has been successfully fetched. /// /// The data is a map where the key is a string (representing the account address), @@ -19,12 +25,6 @@ class BalancePopulated extends StatefulWidget { /// The address for which the [accountInfo] was retrieved. final String address; - const BalancePopulated({ - required this.address, - required this.accountInfo, - super.key, - }); - @override State createState() => _BalancePopulatedState(); } @@ -46,7 +46,7 @@ class _BalancePopulatedState extends State { kVerticalSpacing, Expanded( child: AspectRatio( - aspectRatio: 1.0, + aspectRatio: 1, child: LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { return Stack( @@ -59,21 +59,21 @@ class _BalancePopulatedState extends State { ValueListenableBuilder( valueListenable: _touchedSectionId, builder: (_, String? id, __) { - final Widget center = id != null + final center = id != null ? _getBalance( accountInfo: widget.accountInfo, constraints: constraints, tokenStandard: TokenStandard.parse(_touchedSectionId.value!), ) - : SizedBox.shrink(); + : const SizedBox.shrink(); return center; }, ), ], ); - }), + },), ), ), BalanceAddress( @@ -82,7 +82,7 @@ class _BalancePopulatedState extends State { ), const Divider(), Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: BalanceChartLegend(accountInfo: widget.accountInfo), ), ], @@ -94,19 +94,19 @@ class _BalancePopulatedState extends State { required BoxConstraints constraints, required TokenStandard tokenStandard, }) { - final String amount = accountInfo + final amount = accountInfo .getBalance( tokenStandard, ) .addDecimals(coinDecimals); - final String symbol = tokenStandard == kZnnCoin.tokenStandard + final symbol = tokenStandard == kZnnCoin.tokenStandard ? kZnnCoin.symbol : kQsrCoin.symbol; - final double margin = constraints.maxWidth * 0.3; + final margin = constraints.maxWidth * 0.3; - final double width = constraints.maxWidth - margin; + final width = constraints.maxWidth - margin; return SizedBox( width: width, diff --git a/lib/rearchitecture/dashboard/balance_dashboard/balance_dashboard.dart b/lib/rearchitecture/dashboard/balance_dashboard/balance_dashboard.dart index e1abc8c2..18100cd0 100644 --- a/lib/rearchitecture/dashboard/balance_dashboard/balance_dashboard.dart +++ b/lib/rearchitecture/dashboard/balance_dashboard/balance_dashboard.dart @@ -1,3 +1,3 @@ export 'cubit/balance_dashboard_cubit.dart'; -export 'widgets/widgets.dart'; -export 'view/balance_dashboard_card.dart'; \ No newline at end of file +export 'view/balance_dashboard_card.dart'; +export 'widgets/widgets.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_cubit.dart b/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_cubit.dart index 6c19ce7e..56c07c37 100644 --- a/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_cubit.dart +++ b/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_cubit.dart @@ -27,7 +27,7 @@ class BalanceDashboardCubit extends DashboardCubit fetch() async { try { - final AccountInfo response = await zenon.ledger + final response = await zenon.ledger .getAccountInfoByAddress(Address.parse(kSelectedAddress!)); if (response.blockCount! > 0 && diff --git a/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_state.dart b/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_state.dart index ef3be939..6a75d5a7 100644 --- a/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_state.dart +++ b/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_state.dart @@ -9,7 +9,7 @@ class BalanceDashboardState extends DashboardState { /// /// This state uses the default `status`, `data`, and `error` from the parent `DashboardState` class, /// and initializes them to manage the detailed account balance. - BalanceDashboardState({ + const BalanceDashboardState({ super.status, super.data, super.error, diff --git a/lib/rearchitecture/dashboard/balance_dashboard/view/balance_dashboard_card.dart b/lib/rearchitecture/dashboard/balance_dashboard/view/balance_dashboard_card.dart index 5d76750e..4edb164c 100644 --- a/lib/rearchitecture/dashboard/balance_dashboard/view/balance_dashboard_card.dart +++ b/lib/rearchitecture/dashboard/balance_dashboard/view/balance_dashboard_card.dart @@ -22,9 +22,9 @@ class BalanceDashboardCard extends StatelessWidget { // Creates a `BalanceDashboardCubit` instance, passing in the `zenon` client // and an initial `BalanceDashboardState`. The cubit immediately begins fetching // the balance data by calling `fetch()`. - final BalanceDashboardCubit cubit = BalanceDashboardCubit( + final cubit = BalanceDashboardCubit( zenon!, - BalanceDashboardState(), + const BalanceDashboardState(), ); cubit.fetchDataPeriodically(); return cubit; @@ -49,7 +49,7 @@ class BalanceDashboardCard extends StatelessWidget { // Shows the populated balance data when it is successfully fetched. CubitStatus.success => BalanceDashboardPopulated( - data: state.data!, + data: state.data, ), }; }, diff --git a/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_error.dart b/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_error.dart index e0e8c9f8..3f28792a 100644 --- a/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_error.dart +++ b/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_error.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; class BalanceDashboardError extends StatelessWidget { - final Object error; const BalanceDashboardError({required this.error, super.key}); + final Object error; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_populated.dart b/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_populated.dart index 205476ff..0a3ca203 100644 --- a/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_populated.dart +++ b/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_populated.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class BalanceDashboardPopulated extends StatelessWidget { - final AccountInfo? data; const BalanceDashboardPopulated({required this.data, super.key}); + final AccountInfo? data; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/dashboard.dart b/lib/rearchitecture/dashboard/dashboard.dart index c5e58d83..382057e4 100644 --- a/lib/rearchitecture/dashboard/dashboard.dart +++ b/lib/rearchitecture/dashboard/dashboard.dart @@ -1,4 +1,3 @@ -library; export '../dashboard/balance/balance.dart'; export '../dashboard/balance_dashboard/balance_dashboard.dart'; @@ -9,4 +8,4 @@ export '../dashboard/realtime_statistics/realtime_statistics.dart'; export '../dashboard/sentinels/sentinels.dart'; export '../dashboard/staking/staking.dart'; export '../dashboard/total_hourly_transactions/total_hourly_transactions.dart'; -export 'dashboard_cubit.dart'; \ No newline at end of file +export 'dashboard_cubit.dart'; diff --git a/lib/rearchitecture/dashboard/dashboard_cubit.dart b/lib/rearchitecture/dashboard/dashboard_cubit.dart index ecf64248..26cd066a 100644 --- a/lib/rearchitecture/dashboard/dashboard_cubit.dart +++ b/lib/rearchitecture/dashboard/dashboard_cubit.dart @@ -15,12 +15,6 @@ part 'dashboard_state.dart'; /// The generic type [S] represents the type of the states emitted by the cubit. /// [S] extends [DashboardState] abstract class DashboardCubit> extends Cubit { - /// A timer that handles the auto-refreshing of data. - Timer? _autoRefresher; - - /// The Zenon client used to fetch data from the Zenon ledger. - final Zenon zenon; - final Duration refreshInterval; /// Constructs a `DashboardCubit` with the provided [zenon] client and initial state. /// @@ -30,6 +24,12 @@ abstract class DashboardCubit> extends Cubit { super.initialState, { this.refreshInterval = kDashboardRefreshInterval, }); + /// A timer that handles the auto-refreshing of data. + Timer? _autoRefresher; + + /// The Zenon client used to fetch data from the Zenon ledger. + final Zenon zenon; + final Duration refreshInterval; /// Fetches data of type [T] that is managed by the cubit. /// @@ -61,7 +61,7 @@ abstract class DashboardCubit> extends Cubit { try { emit(state.copyWith(status: CubitStatus.loading) as S); if (!zenon.wsClient.isClosed()) { - final T data = await fetch(); + final data = await fetch(); emit(state.copyWith(data: data, status: CubitStatus.success) as S); } else { throw noConnectionException; diff --git a/lib/rearchitecture/dashboard/dashboard_state.dart b/lib/rearchitecture/dashboard/dashboard_state.dart index 5c3381fb..11425070 100644 --- a/lib/rearchitecture/dashboard/dashboard_state.dart +++ b/lib/rearchitecture/dashboard/dashboard_state.dart @@ -26,14 +26,6 @@ enum CubitStatus { /// - [data]: The data of type [T] that is managed by the cubit. /// - [error]: An optional [error] object that contains error details if the cubit is in a failure state. abstract class DashboardState extends Equatable { - /// Represents the current status of the cubit, such as loading, success, or failure. - final CubitStatus status; - - /// The data of type [T] managed by the cubit, which can be null if no data has been loaded or if there was an error. - final T? data; - - /// An optional error object that holds error details in case of failure. - final Object? error; /// Constructs a [DashboardState] with an optional [status], [data], and [error]. /// @@ -44,6 +36,14 @@ abstract class DashboardState extends Equatable { this.data, this.error, }); + /// Represents the current status of the cubit, such as loading, success, or failure. + final CubitStatus status; + + /// The data of type [T] managed by the cubit, which can be null if no data has been loaded or if there was an error. + final T? data; + + /// An optional error object that holds error details in case of failure. + final Object? error; /// Creates a copy of the current state with the option to modify specific fields. /// diff --git a/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart b/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart index d03aa314..a6925f17 100644 --- a/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart +++ b/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart @@ -9,14 +9,14 @@ part 'delegation_state.dart'; /// This cubit extends `DashboardCubit`, using the `DelegationInfo` data type /// to store and manage delegation stats for the account identified by `kDemoAddress`. class DelegationCubit extends DashboardCubit { - - final Address address; /// Constructs a `DelegationCubit`, passing the `zenon` client and the initial state /// to the parent class. /// /// The `zenon` client is used to interact with the Zenon network to retrieve delegation information. DelegationCubit(this.address, super.zenon, super.initialState); + final Address address; + /// Fetches the delegation information for the account identified by its address. /// /// This method retrieves delegation stats using the Zenon SDK's `getDelegatedPillar()` method. @@ -29,7 +29,7 @@ class DelegationCubit extends DashboardCubit { @override Future fetch() async { try { - final DelegationInfo? delegationInfo = await zenon.embedded.pillar.getDelegatedPillar( + final delegationInfo = await zenon.embedded.pillar.getDelegatedPillar( address, ); diff --git a/lib/rearchitecture/dashboard/delegation/delegation.dart b/lib/rearchitecture/dashboard/delegation/delegation.dart index 5d92af6d..39ba6686 100644 --- a/lib/rearchitecture/dashboard/delegation/delegation.dart +++ b/lib/rearchitecture/dashboard/delegation/delegation.dart @@ -1,3 +1,3 @@ export 'cubit/delegation_cubit.dart'; -export 'widgets/widgets.dart'; -export 'view/delegation_card.dart'; \ No newline at end of file +export 'view/delegation_card.dart'; +export 'widgets/widgets.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart b/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart index b36f0c18..d12db9d4 100644 --- a/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart +++ b/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart @@ -4,8 +4,8 @@ import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/utils/card/card.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class DelegationCard extends StatelessWidget { const DelegationCard({super.key}); @@ -14,10 +14,10 @@ class DelegationCard extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (_) { - final DelegationCubit cubit = DelegationCubit( + final cubit = DelegationCubit( Address.parse(kSelectedAddress!), zenon!, - DelegationState(), + const DelegationState(), ); cubit.fetchDataPeriodically(); return cubit; diff --git a/lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart b/lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart index 92fea012..b6a509cd 100644 --- a/lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart +++ b/lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart @@ -6,6 +6,6 @@ class DelegationEmpty extends StatelessWidget { @override Widget build(BuildContext context) { - return SyriusErrorWidget('No data available'); + return const SyriusErrorWidget('No data available'); } } \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart b/lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart index 1cb893c6..fc73e34e 100644 --- a/lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart +++ b/lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; class DelegationError extends StatelessWidget { - final Object error; const DelegationError({required this.error, super.key}); + final Object error; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/delegation/widgets/delegation_loading.dart b/lib/rearchitecture/dashboard/delegation/widgets/delegation_loading.dart index c0c23fad..fc4d21d4 100644 --- a/lib/rearchitecture/dashboard/delegation/widgets/delegation_loading.dart +++ b/lib/rearchitecture/dashboard/delegation/widgets/delegation_loading.dart @@ -6,6 +6,6 @@ class DelegationLoading extends StatelessWidget { @override Widget build(BuildContext context) { - return SyriusLoadingWidget(); + return const SyriusLoadingWidget(); } } diff --git a/lib/rearchitecture/dashboard/delegation/widgets/delegation_populated.dart b/lib/rearchitecture/dashboard/delegation/widgets/delegation_populated.dart index ea9d51c1..6f61d048 100644 --- a/lib/rearchitecture/dashboard/delegation/widgets/delegation_populated.dart +++ b/lib/rearchitecture/dashboard/delegation/widgets/delegation_populated.dart @@ -4,9 +4,9 @@ import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class DelegationPopulated extends StatelessWidget { - final DelegationInfo data; const DelegationPopulated({required this.data, super.key}); + final DelegationInfo data; @override Widget build(BuildContext context) { @@ -14,9 +14,9 @@ class DelegationPopulated extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ Container( - padding: const EdgeInsets.all(8.0), - width: 36.0, - height: 36.0, + padding: const EdgeInsets.all(8), + width: 36, + height: 36, decoration: BoxDecoration( shape: BoxShape.circle, border: Border.all( @@ -27,17 +27,17 @@ class DelegationPopulated extends StatelessWidget { ), child: Icon( SimpleLineIcons.trophy, - size: 12.0, + size: 12, color: Theme.of(context).textTheme.bodyLarge!.color, ), ), - Container(width: 16.0), + Container(width: 16), Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - data.name.toString(), + data.name, style: Theme.of(context).textTheme.bodyMedium, ), Text( diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart index 84268953..a3666381 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart @@ -26,7 +26,7 @@ class DualCoinStatsCubit extends DashboardCubit, DualCoinStatsState> @override Future> fetch() async { try { - final List data = await Future.wait( + final data = await Future.wait( [ zenon.embedded.token.getByZts( znnZts, // Fetches the ZNN token statistics @@ -38,7 +38,7 @@ class DualCoinStatsCubit extends DashboardCubit, DualCoinStatsState> ); // For ZNN and QSR, the network will return non-nullable data - final List nonNullableData = data.map((token) => token!).toList(); + final nonNullableData = data.map((token) => token!).toList(); // The list has only two elements return nonNullableData; diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/dual_coin_stats.dart b/lib/rearchitecture/dashboard/dual_coin_stats/dual_coin_stats.dart index b2816742..ae28e4b1 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/dual_coin_stats.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/dual_coin_stats.dart @@ -1,3 +1,3 @@ export 'cubit/dual_coin_stats_cubit.dart'; -export 'widgets/widgets.dart'; -export 'view/dual_coin_stats_card.dart'; \ No newline at end of file +export 'view/dual_coin_stats_card.dart'; +export 'widgets/widgets.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart b/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart index f7bf3486..23909aaf 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart @@ -13,9 +13,9 @@ class DualCoinStatsCard extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (_) { - final DualCoinStatsCubit cubit = DualCoinStatsCubit( + final cubit = DualCoinStatsCubit( zenon!, - DualCoinStatsState(), + const DualCoinStatsState(), ); cubit.fetchDataPeriodically(); return cubit; diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart.dart index ca1b23fc..3f16735a 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart.dart @@ -11,24 +11,24 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// highlighted class DualCoinStatsChart extends StatelessWidget { - final List tokenList; - final ValueNotifier touchedSectionIndexNotifier; const DualCoinStatsChart({ required this.tokenList, required this.touchedSectionIndexNotifier, super.key, }); + final List tokenList; + final ValueNotifier touchedSectionIndexNotifier; @override Widget build(BuildContext context) { return ValueListenableBuilder( valueListenable: touchedSectionIndexNotifier, builder: (_, int? index, ___) => AspectRatio( - aspectRatio: 1.0, + aspectRatio: 1, child: StandardPieChart( - sectionsSpace: 4.0, - centerSpaceRadius: 0.0, + sectionsSpace: 4, + centerSpaceRadius: 0, sections: _showingSections( context: context, tokenList: tokenList, @@ -48,22 +48,22 @@ class DualCoinStatsChart extends StatelessWidget { required List tokenList, required int? touchedSectionIndex, }) { - BigInt totalSupply = tokenList.fold( + final totalSupply = tokenList.fold( BigInt.zero, (previousValue, element) => previousValue + element.totalSupply, ); return List.generate( tokenList.length, (i) { - Token currentTokenInfo = tokenList[i]; + final currentTokenInfo = tokenList[i]; final isTouched = i == touchedSectionIndex; - final double opacity = isTouched ? 1.0 : 0.5; + final opacity = isTouched ? 1.0 : 0.5; return PieChartSectionData( color: ColorUtils.getTokenColor(currentTokenInfo.tokenStandard) .withOpacity(opacity), value: currentTokenInfo.totalSupply / totalSupply, title: currentTokenInfo.symbol, - radius: 60.0, + radius: 60, titleStyle: Theme.of(context).textTheme.titleSmall!.copyWith( color: Colors.white, ), diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart index 281e665f..781881c1 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart @@ -8,19 +8,19 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// tooltip for showing the exact amount, including the decimals class DualCoinStatsChartLegend extends StatelessWidget { - final List tokens; const DualCoinStatsChartLegend({ required this.tokens, super.key, }); + final List tokens; @override Widget build(BuildContext context) { - final List items = List.generate( + final items = List.generate( tokens.length, (index) { - final Token token = tokens[index]; + final token = tokens[index]; return Expanded( child: DualCoinStatsChartLegendItem( diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend_item.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend_item.dart index 0e663c2a..ec336084 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend_item.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend_item.dart @@ -4,9 +4,9 @@ import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_wi import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class DualCoinStatsChartLegendItem extends StatelessWidget { - final Token token; const DualCoinStatsChartLegendItem({required this.token, super.key}); + final Token token; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart index e042ba86..9853b04f 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart @@ -10,6 +10,6 @@ class DualCoinStatsEmpty extends StatelessWidget { @override Widget build(BuildContext context) { - return SyriusErrorWidget('No data available'); + return const SyriusErrorWidget('No data available'); } } diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart index 473a08bf..aab1654d 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart @@ -7,9 +7,9 @@ import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widge /// error message class DualCoinStatsError extends StatelessWidget { - final Object error; const DualCoinStatsError({required this.error, super.key}); + final Object error; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart index 742df2d5..4dee5716 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart @@ -11,6 +11,6 @@ class DualCoinStatsLoading extends StatelessWidget { @override Widget build(BuildContext context) { - return SyriusLoadingWidget(); + return const SyriusLoadingWidget(); } } diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart index 894eb2b1..51816828 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart @@ -7,12 +7,12 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// - [DualCoinStatsChart] - and a legend - [DualCoinStatsChartLegend] class DualCoinStatsPopulated extends StatefulWidget { - final List tokens; const DualCoinStatsPopulated({ required this.tokens, super.key, }); + final List tokens; @override State createState() => _DualCoinStatsPopulatedState(); @@ -34,7 +34,7 @@ class _DualCoinStatsPopulatedState extends State ), const Divider(), Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: DualCoinStatsChartLegend( tokens: widget.tokens, ), diff --git a/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart b/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart index 2cdece33..e2e1f7cc 100644 --- a/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart +++ b/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart @@ -1,5 +1,4 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'pillars_state.dart'; @@ -25,8 +24,8 @@ class PillarsCubit extends DashboardCubit { Future fetch() async { try { // Fetches the list of all pillars from the Zenon network - final PillarInfoList pillarInfoList = await zenon.embedded.pillar.getAll(); - final int data = pillarInfoList.list.length; // Counts the number of pillars + final pillarInfoList = await zenon.embedded.pillar.getAll(); + final data = pillarInfoList.list.length; // Counts the number of pillars return data; // Returns the total number of pillars } catch (e) { rethrow; diff --git a/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart b/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart index dac9f2e1..da2d2e3c 100644 --- a/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart +++ b/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart @@ -9,7 +9,7 @@ class PillarsState extends DashboardState { /// /// This state is initialized with the default `status`, `data`, and `error` values from the parent `DashboardState` class. /// The `data` field in this case represents the count of active pillars on the Zenon network. - PillarsState({ + const PillarsState({ super.status, super.data, super.error, diff --git a/lib/rearchitecture/dashboard/pillars/pillars.dart b/lib/rearchitecture/dashboard/pillars/pillars.dart index 56205093..cd3b579a 100644 --- a/lib/rearchitecture/dashboard/pillars/pillars.dart +++ b/lib/rearchitecture/dashboard/pillars/pillars.dart @@ -1,3 +1,3 @@ export 'cubit/pillars_cubit.dart'; -export 'widgets/widgets.dart'; -export 'view/pillars_card.dart'; \ No newline at end of file +export 'view/pillars_card.dart'; +export 'widgets/widgets.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/pillars/view/pillars_card.dart b/lib/rearchitecture/dashboard/pillars/view/pillars_card.dart index d6628404..eb023942 100644 --- a/lib/rearchitecture/dashboard/pillars/view/pillars_card.dart +++ b/lib/rearchitecture/dashboard/pillars/view/pillars_card.dart @@ -11,9 +11,9 @@ class PillarsCard extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (_) { - final PillarsCubit cubit = PillarsCubit( + final cubit = PillarsCubit( zenon!, - PillarsState(), + const PillarsState(), ); cubit.fetchDataPeriodically(); return cubit; @@ -28,7 +28,7 @@ class PillarsCard extends StatelessWidget { error: state.error!, ), CubitStatus.success => PillarsPopulated( - data: state.data!, + data: state.data, ), }; }, diff --git a/lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart b/lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart index 3f79e8cd..f650ed29 100644 --- a/lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart +++ b/lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; class PillarsError extends StatelessWidget { - final Object error; const PillarsError({required this.error, super.key}); + final Object error; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/pillars/widgets/pillars_populated.dart b/lib/rearchitecture/dashboard/pillars/widgets/pillars_populated.dart index f35619a4..5c5a0062 100644 --- a/lib/rearchitecture/dashboard/pillars/widgets/pillars_populated.dart +++ b/lib/rearchitecture/dashboard/pillars/widgets/pillars_populated.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; class PillarsPopulated extends StatelessWidget { - final int? data; const PillarsPopulated({required this.data, super.key}); + final int? data; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart index a6abb70f..04a7847b 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart @@ -35,20 +35,20 @@ class RealtimeStatisticsCubit extends DashboardCubit, Realtim Future> fetch() async { try { // Get the current chain height - int chainHeight = (await zenon.ledger.getFrontierMomentum()).height; + final chainHeight = (await zenon.ledger.getFrontierMomentum()).height; // Calculate the starting height for the block retrieval - int height = chainHeight - kMomentumsPerWeek > 0 + final height = chainHeight - kMomentumsPerWeek > 0 ? chainHeight - kMomentumsPerWeek : 1; - int pageIndex = 0; // Start from the first page - int pageSize = 10; // Number of blocks to fetch per page - bool isLastPage = false; // Flag to determine if it's the last page - final List blockList = []; // List to store fetched account blocks + var pageIndex = 0; // Start from the first page + const pageSize = 10; // Number of blocks to fetch per page + var isLastPage = false; // Flag to determine if it's the last page + final blockList = []; // List to store fetched account blocks // Fetch account blocks until the last page is reached while (!isLastPage) { // Fetch account blocks for the current page - List response = + final response = (await zenon.ledger.getAccountBlocksByPage( Address.parse(kSelectedAddress!), pageIndex: pageIndex, diff --git a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart index a45a222d..9bbff3b1 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart @@ -8,7 +8,7 @@ class RealtimeStatisticsState extends DashboardState> { /// Constructs a new `RealtimeStatisticsState` with optional values for `status`, `data`, and `error`. /// /// The `data` field stores a list of `AccountBlock` objects that represent real-time blockchain statistics. - RealtimeStatisticsState({ + const RealtimeStatisticsState({ super.status, super.data, super.error, diff --git a/lib/rearchitecture/dashboard/realtime_statistics/realtime_statistics.dart b/lib/rearchitecture/dashboard/realtime_statistics/realtime_statistics.dart index 603b6938..02ab7917 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/realtime_statistics.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/realtime_statistics.dart @@ -1,3 +1,3 @@ export 'cubit/realtime_statistics_cubit.dart'; -export 'widgets/widgets.dart'; -export 'view/realtime_statistics_card.dart'; \ No newline at end of file +export 'view/realtime_statistics_card.dart'; +export 'widgets/widgets.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart b/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart index 7bb6396f..c38c61b3 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart @@ -12,9 +12,9 @@ class RealtimeStatisticsCard extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (_) { - final RealtimeStatisticsCubit cubit = RealtimeStatisticsCubit( + final cubit = RealtimeStatisticsCubit( zenon!, - RealtimeStatisticsState(), + const RealtimeStatisticsState(), ); cubit.fetchDataPeriodically(); return cubit; diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart index 5d170cf0..e6689e63 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; class RealtimeStatisticsError extends StatelessWidget { - final Object error; const RealtimeStatisticsError({required this.error, super.key}); + final Object error; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart index 909d7b7f..35f598a1 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class RealtimeStatisticsPopulated extends StatelessWidget { - final List data; const RealtimeStatisticsPopulated({required this.data, super.key}); + final List data; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart index 14d50c00..b40bd782 100644 --- a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart +++ b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart @@ -26,7 +26,7 @@ class SentinelsCubit extends DashboardCubit { Future fetch() async { try { // Fetches the list of all active sentinels from the Zenon network - final SentinelInfoList data = await zenon.embedded.sentinel.getAllActive(); + final data = await zenon.embedded.sentinel.getAllActive(); return data; // Returns the fetched sentinel information } catch (e) { rethrow; diff --git a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart index 94ce8445..24b799dd 100644 --- a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart +++ b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart @@ -8,7 +8,7 @@ class SentinelsState extends DashboardState { /// Constructs a new `SentinelsState` with optional values for `status`, `data`, and `error`. /// /// The `data` field stores a `SentinelInfoList` object, which contains the details of all active sentinels on the network. - SentinelsState({ + const SentinelsState({ super.status, super.data, super.error, diff --git a/lib/rearchitecture/dashboard/sentinels/sentinels.dart b/lib/rearchitecture/dashboard/sentinels/sentinels.dart index 06f3412e..ed5c0c5f 100644 --- a/lib/rearchitecture/dashboard/sentinels/sentinels.dart +++ b/lib/rearchitecture/dashboard/sentinels/sentinels.dart @@ -1,3 +1,3 @@ export 'cubit/sentinels_cubit.dart'; -export 'widgets/widgets.dart'; -export 'view/sentinels_card.dart'; \ No newline at end of file +export 'view/sentinels_card.dart'; +export 'widgets/widgets.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart b/lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart index 2c3f1824..d3eedfe1 100644 --- a/lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart +++ b/lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart @@ -10,9 +10,9 @@ class SentinelsCard extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (_) { - final SentinelsCubit cubit = SentinelsCubit( + final cubit = SentinelsCubit( zenon!, - SentinelsState(), + const SentinelsState(), ); cubit.fetchDataPeriodically(); return cubit; @@ -27,7 +27,7 @@ class SentinelsCard extends StatelessWidget { error: state.error!, ), CubitStatus.success => SentinelsPopulated( - data: state.data!, + data: state.data, ), }; }, diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart index 0451fd68..4eca8fe8 100644 --- a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart +++ b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; class SentinelsError extends StatelessWidget { - final Object error; const SentinelsError({required this.error, super.key}); + final Object error; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart index 408cc452..7e257919 100644 --- a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart +++ b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class SentinelsPopulated extends StatelessWidget { - final SentinelInfoList? data; const SentinelsPopulated({required this.data, super.key}); + final SentinelInfoList? data; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart b/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart index 64dc9dfe..3fcdba98 100644 --- a/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart +++ b/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart @@ -26,7 +26,7 @@ class StakingCubit extends DashboardCubit { Future fetch() async { try { // Retrieve the list of staking entries for the demo address - final StakeList data = await _getStakeList(); + final data = await _getStakeList(); if (data.list.isNotEmpty) { return data; // Return the fetched stake data if not empty } else { @@ -45,9 +45,8 @@ class StakingCubit extends DashboardCubit { /// Returns: /// - A `StakeList` containing the staking entries for the specified address. Future _getStakeList() async { - return await zenon.embedded.stake.getEntriesByAddress( + return zenon.embedded.stake.getEntriesByAddress( Address.parse(kSelectedAddress!), - pageIndex: 0, ); } } diff --git a/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart b/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart index e624c792..7a6297d7 100644 --- a/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart +++ b/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart @@ -8,7 +8,7 @@ class StakingState extends DashboardState { /// Constructs a new `StakingState` with optional values for `status`, `data`, and `error`. /// /// The `data` field holds a `StakeList` object, which contains the list of active staking entries for a particular address. - StakingState({ + const StakingState({ super.status, super.data, super.error, diff --git a/lib/rearchitecture/dashboard/staking/staking.dart b/lib/rearchitecture/dashboard/staking/staking.dart index d1d9983e..bdd14754 100644 --- a/lib/rearchitecture/dashboard/staking/staking.dart +++ b/lib/rearchitecture/dashboard/staking/staking.dart @@ -1,3 +1,3 @@ export 'cubit/staking_cubit.dart'; -export 'widgets/widgets.dart'; -export 'view/staking_card.dart'; \ No newline at end of file +export 'view/staking_card.dart'; +export 'widgets/widgets.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/staking/view/staking_card.dart b/lib/rearchitecture/dashboard/staking/view/staking_card.dart index 474d091a..0942ca68 100644 --- a/lib/rearchitecture/dashboard/staking/view/staking_card.dart +++ b/lib/rearchitecture/dashboard/staking/view/staking_card.dart @@ -10,9 +10,9 @@ class StakingCard extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (_) { - final StakingCubit cubit = StakingCubit( + final cubit = StakingCubit( zenon!, - StakingState(), + const StakingState(), ); cubit.fetchDataPeriodically(); return cubit; @@ -27,7 +27,7 @@ class StakingCard extends StatelessWidget { error: state.error!, ), CubitStatus.success => StakingPopulated( - data: state.data!, + data: state.data, ), }; }, diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart b/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart index 1b25d625..9b5a0e1b 100644 --- a/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart +++ b/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; class StakingError extends StatelessWidget { - final Object error; const StakingError({required this.error, super.key}); + final Object error; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart b/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart index 55da4416..27074ff2 100644 --- a/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart +++ b/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class StakingPopulated extends StatelessWidget { - final StakeList? data; const StakingPopulated({required this.data, super.key}); + final StakeList? data; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart index 5102a171..3f7dcdef 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart @@ -1,6 +1,5 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'total_hourly_transactions_state.dart'; @@ -29,10 +28,10 @@ class TotalHourlyTransactionsCubit Future> fetch() async { try { // Retrieve the current chain height - final int chainHeight = await _ledgerGetMomentumLedgerHeight(); + final chainHeight = await _ledgerGetMomentumLedgerHeight(); if (chainHeight - kMomentumsPerHour > 0) { // Fetch detailed momentums for the past hour - final List response = + final response = (await zenon.ledger.getDetailedMomentumsByHeight( chainHeight - kMomentumsPerHour, kMomentumsPerHour, @@ -41,7 +40,7 @@ class TotalHourlyTransactionsCubit []; // Prepare the transaction summary - final Map transactions = { + final transactions = { 'numAccountBlocks': response.fold( 0, (previousValue, element) => previousValue + element.blocks.length, diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart index a29f3e4d..31c655d8 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart @@ -10,7 +10,7 @@ class TotalHourlyTransactionsState extends DashboardState> /// Constructs a new `TotalHourlyTransactionsState` with optional values for `status`, `data`, and `error`. /// /// The `data` field holds a map containing the transaction statistics for the last hour. - TotalHourlyTransactionsState({ + const TotalHourlyTransactionsState({ super.status, super.data, super.error, diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/total_hourly_transactions.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/total_hourly_transactions.dart index 15c545d5..c87c8130 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/total_hourly_transactions.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/total_hourly_transactions.dart @@ -1,3 +1,3 @@ export 'cubit/total_hourly_transactions_cubit.dart'; -export 'widgets/widgets.dart'; -export 'view/total_hourly_transactions_card.dart'; \ No newline at end of file +export 'view/total_hourly_transactions_card.dart'; +export 'widgets/widgets.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart index 0a76e774..71c08953 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart @@ -10,9 +10,9 @@ class TotalHourlyTransactionsCard extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (_) { - final TotalHourlyTransactionsCubit cubit = TotalHourlyTransactionsCubit( + final cubit = TotalHourlyTransactionsCubit( zenon!, - TotalHourlyTransactionsState(), + const TotalHourlyTransactionsState(), ); cubit.fetchDataPeriodically(); return cubit; @@ -27,7 +27,7 @@ class TotalHourlyTransactionsCard extends StatelessWidget { error: state.error!, ), CubitStatus.success => TotalHourlyTransactionsPopulated( - data: state.data!, + data: state.data, ), }; }, diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart index ac1d6a2e..aa97c5fb 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; class TotalHourlyTransactionsError extends StatelessWidget { - final Object error; const TotalHourlyTransactionsError({required this.error, super.key}); + final Object error; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart index ead7a848..b69649d2 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; class TotalHourlyTransactionsPopulated extends StatelessWidget { - final Map? data; const TotalHourlyTransactionsPopulated({required this.data, super.key}); + final Map? data; @override Widget build(BuildContext context) { diff --git a/lib/screens/change_wallet_password_screen.dart b/lib/screens/change_wallet_password_screen.dart index f0f62cca..b27e64d5 100644 --- a/lib/screens/change_wallet_password_screen.dart +++ b/lib/screens/change_wallet_password_screen.dart @@ -9,12 +9,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ChangeWalletPasswordScreen extends StatefulWidget { - final VoidCallback onStepperNotificationSeeMorePressed; const ChangeWalletPasswordScreen({ required this.onStepperNotificationSeeMorePressed, super.key, }); + final VoidCallback onStepperNotificationSeeMorePressed; @override State createState() => @@ -43,7 +43,7 @@ class _ChangeWalletPasswordScreenState return Scaffold( body: Container( padding: const EdgeInsets.symmetric( - vertical: 30.0, + vertical: 30, ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -108,7 +108,7 @@ class _ChangeWalletPasswordScreenState ), ), const SizedBox( - height: 35.0, + height: 35, ), PasswordProgressBar( password: _newPasswordController.text, @@ -204,13 +204,13 @@ class _ChangeWalletPasswordScreenState 'An error occurred while trying to decrypt wallet', ); } - }); + },); }, builder: (_, model, __) { _loadingButton = _getLoadingButton(model); return _getLoadingButton(model); }, - viewModelBuilder: () => DecryptWalletFileBloc(), + viewModelBuilder: DecryptWalletFileBloc.new, ); } @@ -221,7 +221,7 @@ class _ChangeWalletPasswordScreenState ? () { _loadingButtonKey.currentState!.animateForward(); model.decryptWalletFile( - kWalletPath!, _currentPasswordController.text); + kWalletPath!, _currentPasswordController.text,); } : null, text: 'Change password', diff --git a/lib/screens/development_intialization_screen.dart b/lib/screens/development_intialization_screen.dart index 66f51c4a..2a8acc70 100644 --- a/lib/screens/development_intialization_screen.dart +++ b/lib/screens/development_intialization_screen.dart @@ -7,9 +7,9 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// development phase class DevelopmentInitializationScreen extends StatefulWidget { - static const String route = 'development-initialization-screen'; const DevelopmentInitializationScreen({super.key}); + static const String route = 'development-initialization-screen'; @override State createState() => @@ -24,7 +24,7 @@ class _DevelopmentInitializationScreenState future: _checkIfWalletPathIsNull(context: context), builder: (_, snapshot) { if (snapshot.hasData) { - final bool isWalletPathNull = snapshot.data!; + final isWalletPathNull = snapshot.data!; WidgetsBinding.instance.addPostFrameCallback((_) { if (isWalletPathNull) { @@ -34,12 +34,12 @@ class _DevelopmentInitializationScreenState } }); - return SizedBox.shrink(); + return const SizedBox.shrink(); } else if (snapshot.hasError) { return Text('Error: ${snapshot.error}'); } - return Center(child: CircularProgressIndicator()); + return const Center(child: CircularProgressIndicator()); }, ); } diff --git a/lib/screens/dump_mnemonic_screen.dart b/lib/screens/dump_mnemonic_screen.dart index ded64b06..4516d39c 100644 --- a/lib/screens/dump_mnemonic_screen.dart +++ b/lib/screens/dump_mnemonic_screen.dart @@ -27,7 +27,7 @@ class _DumpMnemonicScreenState extends State { return Scaffold( body: Container( padding: const EdgeInsets.symmetric( - vertical: 30.0, + vertical: 30, ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -103,7 +103,7 @@ class _DumpMnemonicScreenState extends State { if (_passwordController.text.isNotEmpty) { try { _continueButtonKey.currentState!.animateForward(); - var walletFile = await WalletUtils.decryptWalletFile( + final walletFile = await WalletUtils.decryptWalletFile( kWalletPath!, _passwordController.text, ); diff --git a/lib/screens/export/export.dart b/lib/screens/export/export.dart index 2cbcb21e..222c2a2b 100644 --- a/lib/screens/export/export.dart +++ b/lib/screens/export/export.dart @@ -1,4 +1,3 @@ -library; export 'export_wallet_info_screen.dart'; export 'export_wallet_password_screen.dart'; diff --git a/lib/screens/export/export_wallet_info_screen.dart b/lib/screens/export/export_wallet_info_screen.dart index 51d1e48f..7fbe53b9 100644 --- a/lib/screens/export/export_wallet_info_screen.dart +++ b/lib/screens/export/export_wallet_info_screen.dart @@ -6,14 +6,14 @@ import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class ExportWalletInfoScreen extends StatefulWidget { - final String seed; - final bool backupWalletFlow; const ExportWalletInfoScreen( this.seed, { this.backupWalletFlow = false, super.key, }); + final String seed; + final bool backupWalletFlow; @override State createState() => _ExportWalletInfoScreenState(); @@ -27,7 +27,7 @@ class _ExportWalletInfoScreenState extends State { return Scaffold( body: Container( padding: const EdgeInsets.symmetric( - vertical: 30.0, + vertical: 30, ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -42,7 +42,7 @@ class _ExportWalletInfoScreenState extends State { 'assets/svg/ic_export_seed.svg', colorFilter: const ColorFilter.mode(AppColors.znnColor, BlendMode.srcIn), - height: 55.0, + height: 55, ), ), Text( @@ -60,23 +60,23 @@ class _ExportWalletInfoScreenState extends State { } Widget _getSeedFieldsGrid() { - double seedFieldsGridWidth = MediaQuery.of(context).size.width * 0.5; - String text = 'A Seed Vault is an encrypted file for backing up your Seed.' + final seedFieldsGridWidth = MediaQuery.of(context).size.width * 0.5; + const text = 'A Seed Vault is an encrypted file for backing up your Seed.' ' The Seed is encrypted with a Seed Vault Key and cannot be accessed ' 'without it. Make sure you backup your Seed Vault in multiple offline locations ' '(e.g. USB, external HDD) and do not lose your Seed Vault Key.' - ' If you lose the Seed Vault file or you don\'t remember the Seed Vault ' + " If you lose the Seed Vault file or you don't remember the Seed Vault " 'Key you lose access to your funds.'; return Container( width: seedFieldsGridWidth, padding: const EdgeInsets.symmetric( - vertical: 40.0, - horizontal: 50.0, + vertical: 40, + horizontal: 50, ), decoration: BoxDecoration( color: Theme.of(context).colorScheme.secondaryContainer, borderRadius: const BorderRadius.all( - Radius.circular(10.0), + Radius.circular(10), ), ), child: Text( @@ -102,33 +102,33 @@ class _ExportWalletInfoScreenState extends State { child: SvgPicture.asset( 'assets/svg/ic_seed.svg', colorFilter: const ColorFilter.mode( - AppColors.qsrColor, BlendMode.srcIn), - height: 50.0, + AppColors.qsrColor, BlendMode.srcIn,), + height: 50, ), ), const Padding( - padding: EdgeInsets.only(top: 8.0), + padding: EdgeInsets.only(top: 8), ), Text( 'Seed', style: Theme.of(context).textTheme.bodyLarge, - ) + ), ], ), Column( children: [ const Icon( SimpleLineIcons.key, - size: 50.0, + size: 50, color: AppColors.errorColor, ), const Padding( - padding: EdgeInsets.only(top: 8.0), + padding: EdgeInsets.only(top: 8), ), Text( 'Seed Vault Key', style: Theme.of(context).textTheme.bodyLarge, - ) + ), ], ), Column( @@ -138,17 +138,17 @@ class _ExportWalletInfoScreenState extends State { child: SvgPicture.asset( 'assets/svg/ic_vault_seed.svg', colorFilter: const ColorFilter.mode( - AppColors.znnColor, BlendMode.srcIn), - height: 50.0, + AppColors.znnColor, BlendMode.srcIn,), + height: 50, ), ), const Padding( - padding: EdgeInsets.only(top: 8.0), + padding: EdgeInsets.only(top: 8), ), Text( 'Seed Vault', style: Theme.of(context).textTheme.bodyLarge, - ) + ), ], ), ], @@ -173,7 +173,7 @@ class _ExportWalletInfoScreenState extends State { Text( 'I will securely store the Seed Vault & Seed Vault Key', style: Theme.of(context).textTheme.headlineSmall, - ) + ), ], ); } diff --git a/lib/screens/export/export_wallet_password_screen.dart b/lib/screens/export/export_wallet_password_screen.dart index 620be245..363e997a 100644 --- a/lib/screens/export/export_wallet_password_screen.dart +++ b/lib/screens/export/export_wallet_password_screen.dart @@ -14,14 +14,14 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ExportWalletPasswordScreen extends StatefulWidget { - final String seed; - final bool backupWalletFlow; const ExportWalletPasswordScreen( this.seed, { this.backupWalletFlow = false, super.key, }); + final String seed; + final bool backupWalletFlow; @override State createState() => @@ -42,7 +42,7 @@ class _ExportWalletPasswordScreenState return Scaffold( body: Container( padding: const EdgeInsets.symmetric( - vertical: 30.0, + vertical: 30, ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -59,8 +59,8 @@ class _ExportWalletPasswordScreenState child: SvgPicture.asset( 'assets/svg/ic_export_seed.svg', colorFilter: const ColorFilter.mode( - AppColors.znnColor, BlendMode.srcIn), - height: 55.0, + AppColors.znnColor, BlendMode.srcIn,), + height: 55, ), ), kVerticalSpacing, @@ -74,7 +74,7 @@ class _ExportWalletPasswordScreenState style: Theme.of(context).textTheme.headlineMedium, ), const SizedBox( - height: 50.0, + height: 50, ), Column( children: [ @@ -126,7 +126,7 @@ class _ExportWalletPasswordScreenState children: [ _getGoBackButton(), kSpacingBetweenActionButtons, - _getExportButton() + _getExportButton(), ], ), ], @@ -159,12 +159,12 @@ class _ExportWalletPasswordScreenState )}.json', ); if (walletPath != null) { - KeyStoreManager keyStoreManager = KeyStoreManager( + final keyStoreManager = KeyStoreManager( walletPath: Directory( path.dirname(walletPath.path), ), ); - KeyStore keyStore = KeyStore.fromMnemonic(widget.seed); + final keyStore = KeyStore.fromMnemonic(widget.seed); await keyStoreManager.saveKeyStore( keyStore, _passwordController.text, @@ -185,11 +185,11 @@ class _ExportWalletPasswordScreenState } void _updateExportedSeedList() { - List exportedSeeds = []; + final exportedSeeds = []; exportedSeeds.addAll(Provider.of>>( context, listen: false, - ).value); + ).value,); exportedSeeds.add(widget.seed); Provider.of>>( context, diff --git a/lib/screens/node_management_screen.dart b/lib/screens/node_management_screen.dart index ab52cdca..f6412ea5 100644 --- a/lib/screens/node_management_screen.dart +++ b/lib/screens/node_management_screen.dart @@ -12,14 +12,14 @@ import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class NodeManagementScreen extends StatefulWidget { - final VoidCallback? nodeConfirmationCallback; - - static const String route = 'node-management-screen'; const NodeManagementScreen({ this.nodeConfirmationCallback, super.key, }); + final VoidCallback? nodeConfirmationCallback; + + static const String route = 'node-management-screen'; @override State createState() => _NodeManagementScreenState(); @@ -59,8 +59,8 @@ class _NodeManagementScreenState extends State { return Scaffold( body: Container( padding: const EdgeInsets.symmetric( - vertical: 30.0, - horizontal: 50.0, + vertical: 30, + horizontal: 50, ), child: ListView( shrinkWrap: true, @@ -128,7 +128,6 @@ class _NodeManagementScreenState extends State { Widget _getAutoReceiveCheckboxContainer() { return Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ Checkbox( value: _autoReceive, @@ -140,7 +139,7 @@ class _NodeManagementScreenState extends State { sl().autoReceive(); }).onError((error, stackTrace) { Logger('MainAppContainer').log(Level.WARNING, - '_getAutoReceiveCheckboxContainer', error, stackTrace); + '_getAutoReceiveCheckboxContainer', error, stackTrace,); }); } else if (value == false && sl().pool.isNotEmpty) { @@ -155,7 +154,7 @@ class _NodeManagementScreenState extends State { Text( 'Automatically receive transactions', style: Theme.of(context).textTheme.headlineSmall, - ) + ), ], ); } @@ -191,7 +190,7 @@ class _NodeManagementScreenState extends State { ); } - _getConfirmNodeSelectionButton() { + Row _getConfirmNodeSelectionButton() { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -212,10 +211,10 @@ class _NodeManagementScreenState extends State { try { _confirmNodeButtonKey.currentState?.animateForward(); - String url = _selectedNode == kEmbeddedNode + final url = _selectedNode == kEmbeddedNode ? kLocalhostDefaultNodeUrl : _selectedNode!; - bool isConnectionEstablished = + var isConnectionEstablished = await NodeUtils.establishConnectionToNode(url); if (_selectedNode == kEmbeddedNode) { // Check if node is already running @@ -224,7 +223,7 @@ class _NodeManagementScreenState extends State { await Isolate.spawn(EmbeddedNode.runNode, [''], onExit: sl(instanceName: 'embeddedStoppedPort').sendPort, - debugName: 'EmbeddedNodeIsolate'); + debugName: 'EmbeddedNodeIsolate',); kEmbeddedNodeRunning = true; // The node needs a couple of seconds to actually start await Future.delayed(kEmbeddedConnectionDelay); @@ -241,7 +240,7 @@ class _NodeManagementScreenState extends State { kSelectedNodeKey, _selectedNode, ); - kCurrentNode = _selectedNode!; + kCurrentNode = _selectedNode; await _sendChangingNodeSuccessNotification(); if (widget.nodeConfirmationCallback != null) { widget.nodeConfirmationCallback!(); @@ -257,7 +256,7 @@ class _NodeManagementScreenState extends State { 'Connection failed', ); setState(() { - _selectedNode = kCurrentNode!; + _selectedNode = kCurrentNode; }); } finally { _confirmNodeButtonKey.currentState?.animateReverse(); @@ -311,7 +310,7 @@ class _NodeManagementScreenState extends State { .contains(_newNodeController.text)) { await NotificationUtils.sendNotificationError( 'Node ${_newNodeController.text} already exists', - 'Node already exists'); + 'Node already exists',); } else { _addNodeToDb(); } @@ -342,8 +341,8 @@ class _NodeManagementScreenState extends State { children: { ...kDefaultNodes, ...kDefaultCommunityNodes, - ...kDbNodes - }.toList().map((e) => _getNodeTile(e)).toList(), + ...kDbNodes, + }.toList().map(_getNodeTile).toList(), ); } diff --git a/lib/screens/onboarding/access_wallet_screen.dart b/lib/screens/onboarding/access_wallet_screen.dart index 0a483a9a..145e9709 100644 --- a/lib/screens/onboarding/access_wallet_screen.dart +++ b/lib/screens/onboarding/access_wallet_screen.dart @@ -4,9 +4,9 @@ import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class AccessWalletScreen extends StatefulWidget { - static const String route = 'access-wallet-screen'; const AccessWalletScreen({super.key}); + static const String route = 'access-wallet-screen'; @override State createState() => _AccessWalletScreenState(); @@ -17,7 +17,7 @@ class _AccessWalletScreenState extends State { Widget build(BuildContext context) { return Scaffold( body: Container( - padding: const EdgeInsets.all(50.0), + padding: const EdgeInsets.all(50), child: Column( children: [ Column( @@ -32,7 +32,7 @@ class _AccessWalletScreenState extends State { style: Theme.of(context).textTheme.headlineMedium, ), const SizedBox( - height: 50.0, + height: 50, ), ], ), diff --git a/lib/screens/onboarding/create_key_store_screen.dart b/lib/screens/onboarding/create_key_store_screen.dart index 60283ecf..f513b98e 100644 --- a/lib/screens/onboarding/create_key_store_screen.dart +++ b/lib/screens/onboarding/create_key_store_screen.dart @@ -6,9 +6,6 @@ import 'package:zenon_syrius_wallet_flutter/utils/wallet_file.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class CreateKeyStoreScreen extends StatefulWidget { - final String seed; - final String password; - final int progressBarNumLevels; const CreateKeyStoreScreen( this.seed, @@ -16,6 +13,9 @@ class CreateKeyStoreScreen extends StatefulWidget { this.progressBarNumLevels = 5, super.key, }); + final String seed; + final String password; + final int progressBarNumLevels; @override State createState() => _CreateKeyStoreScreenState(); @@ -39,7 +39,7 @@ class _CreateKeyStoreScreenState extends State { return Scaffold( body: Container( padding: const EdgeInsets.symmetric( - vertical: 30.0, + vertical: 30, ), child: Center( child: StreamBuilder( diff --git a/lib/screens/onboarding/create_ledger_screen.dart b/lib/screens/onboarding/create_ledger_screen.dart index 951c3a70..d8beeb5c 100644 --- a/lib/screens/onboarding/create_ledger_screen.dart +++ b/lib/screens/onboarding/create_ledger_screen.dart @@ -7,9 +7,6 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class CreateLedgerWalletScreen extends StatefulWidget { - final WalletDefinition deviceInfo; - final String password; - final int progressBarNumLevels; const CreateLedgerWalletScreen( this.deviceInfo, @@ -17,6 +14,9 @@ class CreateLedgerWalletScreen extends StatefulWidget { this.progressBarNumLevels = 4, super.key, }); + final WalletDefinition deviceInfo; + final String password; + final int progressBarNumLevels; @override State createState() => @@ -42,7 +42,7 @@ class _CreateLedgerWalletScreenState extends State { return Scaffold( body: Container( padding: const EdgeInsets.symmetric( - vertical: 30.0, + vertical: 30, ), child: Center( child: StreamBuilder( diff --git a/lib/screens/onboarding/hardware_wallet/hardware_wallet.dart b/lib/screens/onboarding/hardware_wallet/hardware_wallet.dart index 61ac12fd..2e3ce215 100644 --- a/lib/screens/onboarding/hardware_wallet/hardware_wallet.dart +++ b/lib/screens/onboarding/hardware_wallet/hardware_wallet.dart @@ -1,4 +1,3 @@ -library; -export 'hardware_wallet_password_screen.dart'; export 'hardware_wallet_device_choice_screen.dart'; +export 'hardware_wallet_password_screen.dart'; diff --git a/lib/screens/onboarding/hardware_wallet/hardware_wallet_device_choice_screen.dart b/lib/screens/onboarding/hardware_wallet/hardware_wallet_device_choice_screen.dart index b3bc1de2..2d24df5e 100644 --- a/lib/screens/onboarding/hardware_wallet/hardware_wallet_device_choice_screen.dart +++ b/lib/screens/onboarding/hardware_wallet/hardware_wallet_device_choice_screen.dart @@ -4,8 +4,8 @@ import 'package:zenon_syrius_wallet_flutter/blocs/notifications_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_ledger_dart/znn_ledger_dart.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -48,7 +48,7 @@ class _HardwareWalletDeviceChoiceScreenState return Scaffold( body: Container( padding: const EdgeInsets.symmetric( - vertical: 30.0, + vertical: 30, ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -60,7 +60,7 @@ class _HardwareWalletDeviceChoiceScreenState numLevels: 4, ), const SizedBox( - height: 30.0, + height: 30, ), const NotificationWidget(), Text( @@ -74,7 +74,7 @@ class _HardwareWalletDeviceChoiceScreenState ), kVerticalSpacing, SizedBox( - height: 40.0, + height: 40, child: _getScanDevicesContainer(), ), kVerticalSpacing, @@ -95,17 +95,15 @@ class _HardwareWalletDeviceChoiceScreenState return Container( decoration: BoxDecoration( color: Colors.transparent, - borderRadius: const BorderRadius.all(Radius.circular(6.0)), + borderRadius: const BorderRadius.all(Radius.circular(6)), border: Border.all( color: AppColors.znnColor, - width: 1.0, - style: BorderStyle.solid, - )), + ),), child: InkWell( child: FocusableActionDetector( child: SizedBox( - height: 50.0, - width: 150.0, + height: 50, + width: 150, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -113,10 +111,10 @@ class _HardwareWalletDeviceChoiceScreenState color: Colors.transparent, child: Icon(Icons.search, color: - Theme.of(context).textTheme.headlineSmall!.color!, - size: 18.0)), + Theme.of(context).textTheme.headlineSmall!.color, + size: 18,),), const SizedBox( - width: 15.0, + width: 15, ), Text( 'Scan devices', @@ -128,27 +126,27 @@ class _HardwareWalletDeviceChoiceScreenState ), onTap: () async { await _scanDevices(); - }), + },), ); } Future _scanDevices() async { - List>> futures = _walletManagers + final futures = _walletManagers .map((manager) => manager.getWalletDefinitions()) .toList(); - List> listOfDefinitions = + final listOfDefinitions = await Future.wait(futures); // Combine all the iterables into a single list using fold or expand // For example, using fold: - List combinedList = + final combinedList = listOfDefinitions.fold>( [], (previousList, element) => previousList..addAll(element), ); - for (var device in combinedList) { + for (final device in combinedList) { if (!_deviceValueMap.containsKey(device.walletId)) { _deviceValueMap[device.walletId] = ValueNotifier(null); } @@ -158,7 +156,7 @@ class _HardwareWalletDeviceChoiceScreenState _devices = combinedList; _selectedDevice = null; - for (var valueNotifier in _deviceValueMap.values) { + for (final valueNotifier in _deviceValueMap.values) { valueNotifier.value = null; } }); @@ -177,19 +175,19 @@ class _HardwareWalletDeviceChoiceScreenState Expanded( child: Container( margin: const EdgeInsets.symmetric( - vertical: 5.0, + vertical: 5, ), child: Row( children: [ Expanded( child: InkWell( borderRadius: BorderRadius.circular( - 10.0, + 10, ), onTap: () => _onDevicePressedCallback(e), child: Padding( padding: const EdgeInsets.symmetric( - horizontal: 5.0, vertical: 5.0), + horizontal: 5, vertical: 5,), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -212,11 +210,11 @@ class _HardwareWalletDeviceChoiceScreenState height: 20, child: value == null ? const Text( - 'Select to connect the device') + 'Select to connect the device',) : Text(value, style: Theme.of(context) .textTheme - .bodyMedium), + .bodyMedium,), ), ), ], @@ -227,7 +225,7 @@ class _HardwareWalletDeviceChoiceScreenState ], ), ), - ) + ), ], ), ) @@ -235,11 +233,11 @@ class _HardwareWalletDeviceChoiceScreenState } Future _onDevicePressedCallback( - WalletDefinition? walletDefinition) async { + WalletDefinition? walletDefinition,) async { Wallet? wallet; try { - for (var walletManager in _walletManagers) { - WalletDefinition wd = walletDefinition!; + for (final walletManager in _walletManagers) { + final wd = walletDefinition!; if (await walletManager.supportsWallet(wd)) { wallet = await walletManager.getWallet(walletDefinition); break; @@ -248,7 +246,7 @@ class _HardwareWalletDeviceChoiceScreenState if (wallet == null) { throw const LedgerError.connectionError( origMessage: - 'Not connected, please connect the device and try again.'); + 'Not connected, please connect the device and try again.',); } final walletAddress = await _getWalletAddress(wallet); setState(() { @@ -280,9 +278,9 @@ class _HardwareWalletDeviceChoiceScreenState type: NotificationType.confirm, ), ); - return await account.getAddress(true); + return account.getAddress(true); } else { - return await account.getAddress(); + return account.getAddress(); } } diff --git a/lib/screens/onboarding/hardware_wallet/hardware_wallet_password_screen.dart b/lib/screens/onboarding/hardware_wallet/hardware_wallet_password_screen.dart index e16b8b8b..78b27273 100644 --- a/lib/screens/onboarding/hardware_wallet/hardware_wallet_password_screen.dart +++ b/lib/screens/onboarding/hardware_wallet/hardware_wallet_password_screen.dart @@ -5,9 +5,9 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class HardwareWalletPasswordScreen extends StatefulWidget { - final WalletDefinition deviceInfo; const HardwareWalletPasswordScreen(this.deviceInfo, {super.key}); + final WalletDefinition deviceInfo; @override State createState() => @@ -27,7 +27,7 @@ class _HardwareWalletPasswordScreenState extends State InputValidators.checkPasswordMatch( - _passwordController.text, value), + _passwordController.text, value,), onChanged: (value) { setState(() {}); }, @@ -80,7 +80,7 @@ class _HardwareWalletPasswordScreenState extends State[ _getPassiveButton(), kSpacingBetweenActionButtons, - _getActionButton() + _getActionButton(), ], ), ], diff --git a/lib/screens/onboarding/import_wallet/import_wallet.dart b/lib/screens/onboarding/import_wallet/import_wallet.dart index 0a269e46..4c0345cb 100644 --- a/lib/screens/onboarding/import_wallet/import_wallet.dart +++ b/lib/screens/onboarding/import_wallet/import_wallet.dart @@ -1,4 +1,3 @@ -library; export 'import_wallet_decrypt_screen.dart'; export 'import_wallet_password_screen.dart'; diff --git a/lib/screens/onboarding/import_wallet/import_wallet_decrypt_screen.dart b/lib/screens/onboarding/import_wallet/import_wallet_decrypt_screen.dart index 7416739b..574db2e3 100644 --- a/lib/screens/onboarding/import_wallet/import_wallet_decrypt_screen.dart +++ b/lib/screens/onboarding/import_wallet/import_wallet_decrypt_screen.dart @@ -2,15 +2,15 @@ import 'package:flutter/material.dart'; import 'package:stacked/stacked.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/wallet_file.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/wallet_file.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ImportWalletDecryptScreen extends StatefulWidget { - final String path; const ImportWalletDecryptScreen(this.path, {super.key}); + final String path; @override State createState() => @@ -31,7 +31,7 @@ class _ImportWalletDecryptScreenState extends State { return Scaffold( body: Container( padding: const EdgeInsets.symmetric( - vertical: 30.0, + vertical: 30, ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -42,7 +42,7 @@ class _ImportWalletDecryptScreenState extends State { currentLevel: 2, ), const SizedBox( - height: 30.0, + height: 30, ), Text( 'Unlock your Seed Vault', @@ -107,7 +107,7 @@ class _ImportWalletDecryptScreenState extends State { ); } - _getDecryptKeyStoreFileViewModel() { + ViewModelBuilder _getDecryptKeyStoreFileViewModel() { return ViewModelBuilder.reactive( onViewModelReady: (model) { model.stream.listen((walletFile) { @@ -119,7 +119,7 @@ class _ImportWalletDecryptScreenState extends State { walletFile .access((wallet) => Future.value((wallet as KeyStore).mnemonic!)) .then((value) => NavigationUtils.push( - context, ImportWalletPasswordScreen(value))); + context, ImportWalletPasswordScreen(value),),); } }, onError: (error) { _loadingButtonKey.currentState!.animateReverse(); @@ -132,13 +132,13 @@ class _ImportWalletDecryptScreenState extends State { _passwordErrorText = error.toString(); }); } - }); + },); }, builder: (_, model, __) { _loadingButton = _getLoadingButton(model); return _getLoadingButton(model); }, - viewModelBuilder: () => DecryptWalletFileBloc(), + viewModelBuilder: DecryptWalletFileBloc.new, ); } diff --git a/lib/screens/onboarding/import_wallet/import_wallet_password_screen.dart b/lib/screens/onboarding/import_wallet/import_wallet_password_screen.dart index 88a1d5f5..318e515e 100644 --- a/lib/screens/onboarding/import_wallet/import_wallet_password_screen.dart +++ b/lib/screens/onboarding/import_wallet/import_wallet_password_screen.dart @@ -4,14 +4,14 @@ import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class ImportWalletPasswordScreen extends StatefulWidget { - final String seed; - final int progressBarNumLevels; const ImportWalletPasswordScreen( this.seed, { this.progressBarNumLevels = 5, super.key, }); + final String seed; + final int progressBarNumLevels; @override State createState() => @@ -32,7 +32,7 @@ class _ImportWalletPasswordScreenState return Scaffold( body: Container( padding: const EdgeInsets.symmetric( - vertical: 30.0, + vertical: 30, ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -44,7 +44,7 @@ class _ImportWalletPasswordScreenState numLevels: widget.progressBarNumLevels, ), const SizedBox( - height: 30.0, + height: 30, ), Text( 'Create a wallet password', @@ -56,7 +56,7 @@ class _ImportWalletPasswordScreenState style: Theme.of(context).textTheme.headlineMedium, ), const SizedBox( - height: 100.0, + height: 100, ), Column( children: [ diff --git a/lib/screens/onboarding/import_wallet/import_wallet_seed_choice_screen.dart b/lib/screens/onboarding/import_wallet/import_wallet_seed_choice_screen.dart index 2e47fac4..85938f82 100644 --- a/lib/screens/onboarding/import_wallet/import_wallet_seed_choice_screen.dart +++ b/lib/screens/onboarding/import_wallet/import_wallet_seed_choice_screen.dart @@ -32,7 +32,7 @@ class _ImportWalletSeedChoiceScreenState return Scaffold( body: Container( padding: const EdgeInsets.symmetric( - vertical: 30.0, + vertical: 30, ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -45,7 +45,7 @@ class _ImportWalletSeedChoiceScreenState numLevels: _walletFilePath == null ? 4 : 5, ), const SizedBox( - height: 30.0, + height: 30, ), Text( 'Import your wallet', @@ -58,7 +58,7 @@ class _ImportWalletSeedChoiceScreenState ), kVerticalSpacing, SizedBox( - height: 45.0, + height: 45, child: _getSeedChoice(), ), kVerticalSpacing, @@ -71,7 +71,7 @@ class _ImportWalletSeedChoiceScreenState children: [ _getGoBackButton(), kSpacingBetweenActionButtons, - _getContinueButton() + _getContinueButton(), ], ), ], @@ -93,7 +93,7 @@ class _ImportWalletSeedChoiceScreenState _walletFilePath = path; _seedGridKey.currentState!.continueButtonDisabled = false; }); - }), + },), ); } diff --git a/lib/screens/onboarding/new_wallet/new_wallet.dart b/lib/screens/onboarding/new_wallet/new_wallet.dart index c0507b31..90d3004b 100644 --- a/lib/screens/onboarding/new_wallet/new_wallet.dart +++ b/lib/screens/onboarding/new_wallet/new_wallet.dart @@ -1,4 +1,3 @@ -library; export 'new_wallet_confirm_seed_screen.dart'; export 'new_wallet_password_screen.dart'; diff --git a/lib/screens/onboarding/new_wallet/new_wallet_confirm_seed_screen.dart b/lib/screens/onboarding/new_wallet/new_wallet_confirm_seed_screen.dart index 26c314a2..8c26a206 100644 --- a/lib/screens/onboarding/new_wallet/new_wallet_confirm_seed_screen.dart +++ b/lib/screens/onboarding/new_wallet/new_wallet_confirm_seed_screen.dart @@ -6,12 +6,12 @@ import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class NewWalletConfirmSeedScreen extends StatefulWidget { - final List seedWords; const NewWalletConfirmSeedScreen( this.seedWords, { super.key, }); + final List seedWords; @override State createState() => @@ -35,7 +35,7 @@ class _NewWalletConfirmSeedScreenState void initState() { super.initState(); _actionButton = _getVerifyButton(); - for (var word in widget.seedWords) { + for (final word in widget.seedWords) { _seedGridElements.add( SeedGridElement( word: word, @@ -45,7 +45,7 @@ class _NewWalletConfirmSeedScreenState ); } _generateRandomIndexes(); - for (var index in _randomIndexes) { + for (final index in _randomIndexes) { _seedGridElements[index].word = ''; } } @@ -55,7 +55,7 @@ class _NewWalletConfirmSeedScreenState return Scaffold( body: Container( padding: const EdgeInsets.symmetric( - vertical: 30.0, + vertical: 30, ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -66,7 +66,7 @@ class _NewWalletConfirmSeedScreenState currentLevel: 2, ), const SizedBox( - height: 30.0, + height: 30, ), Text( 'Confirm your seed', @@ -87,18 +87,17 @@ class _NewWalletConfirmSeedScreenState ], ), const SizedBox( - height: 75.0, + height: 75, ), _getSeedInputWidgetsGrid(), ], ), Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ Container( - margin: const EdgeInsets.only(left: 90.0), + margin: const EdgeInsets.only(left: 90), child: _getMissingSeedGridElements(widget.seedWords), - ) + ), ], ), Row( @@ -122,7 +121,7 @@ class _NewWalletConfirmSeedScreenState } void _generateRandomIndex() { - int randomNumber = Random().nextInt(_seedGridElements.length); + final randomNumber = Random().nextInt(_seedGridElements.length); if (!_randomIndexes.contains(randomNumber)) { _randomIndexes.add(randomNumber); } @@ -153,9 +152,9 @@ class _NewWalletConfirmSeedScreenState } Widget _seedFieldWidget(SeedGridElement seedGridElement) { - int seedGridElementIndex = _seedGridElements.indexOf(seedGridElement); + final seedGridElementIndex = _seedGridElements.indexOf(seedGridElement); - final TextEditingController controller = TextEditingController(); + final controller = TextEditingController(); controller.text = seedGridElement.word; if (_textCursor == seedGridElementIndex) { controller.selection = TextSelection.collapsed( @@ -164,8 +163,8 @@ class _NewWalletConfirmSeedScreenState } return SizedBox( - width: 200.0, - height: 30.0, + width: 200, + height: 30, child: Row( children: [ InkWell( @@ -188,18 +187,18 @@ class _NewWalletConfirmSeedScreenState } }, child: Container( - width: 30.0, - height: 30.0, + width: 30, + height: 30, decoration: BoxDecoration( border: Border.all( - width: 2.0, + width: 2, color: _hoveredSeedGridIndex == seedGridElementIndex || _randomIndexes.contains(seedGridElementIndex) ? _getColor(seedGridElement, false) : Theme.of(context).colorScheme.secondaryContainer, ), color: Theme.of(context).colorScheme.secondaryContainer, - shape: BoxShape.circle), + shape: BoxShape.circle,), child: Center( child: Text( '${seedGridElementIndex + 1}', @@ -210,7 +209,7 @@ class _NewWalletConfirmSeedScreenState ), ), const SizedBox( - width: 10.0, + width: 10, ), Expanded( child: FocusableActionDetector( @@ -240,7 +239,7 @@ class _NewWalletConfirmSeedScreenState _randomIndexes.contains(seedGridElementIndex) ? Colors.white : AppColors.znnColor, - fontSize: 12.0, + fontSize: 12, ), decoration: InputDecoration( filled: true, @@ -251,7 +250,7 @@ class _NewWalletConfirmSeedScreenState disabledBorder: UnderlineInputBorder( borderSide: BorderSide( color: _getColor(seedGridElement, true), - width: 3.0, + width: 3, ), ), hintText: '', @@ -263,7 +262,7 @@ class _NewWalletConfirmSeedScreenState !seedGridElement.isValid; }, onAcceptWithDetails: (DragTargetDetails data) { - var element = _seedGridElements[seedGridElementIndex]; + final element = _seedGridElements[seedGridElementIndex]; var i = -1; if (element.word != '') { while ((i = @@ -297,8 +296,8 @@ class _NewWalletConfirmSeedScreenState } Widget _getMissingSeedGridElements(List seedWords) { - List list = []; - for (var index in _randomIndexes) { + final list = []; + for (final index in _randomIndexes) { if (!_foundMissingRandomElementsIndexes.contains(index)) { list.add( Draggable( @@ -306,7 +305,7 @@ class _NewWalletConfirmSeedScreenState style: ElevatedButton.styleFrom( foregroundColor: AppColors.darkSecondary, shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5.0), + borderRadius: BorderRadius.circular(5), ), ), onPressed: () {}, @@ -335,7 +334,7 @@ class _NewWalletConfirmSeedScreenState .withOpacity(0.5) : Theme.of(context).colorScheme.secondaryContainer, shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5.0), + borderRadius: BorderRadius.circular(5), ), ), onPressed: () {}, @@ -353,26 +352,23 @@ class _NewWalletConfirmSeedScreenState } } return Wrap( - crossAxisAlignment: WrapCrossAlignment.start, - alignment: WrapAlignment.start, - direction: Axis.horizontal, - spacing: 5.0, + spacing: 5, children: list, ); } void _checkSeed() { _seedError = false; - for (var element in _seedGridElements) { - int i = _seedGridElements.indexOf(element); + for (final element in _seedGridElements) { + final i = _seedGridElements.indexOf(element); element.isValid = element.word == widget.seedWords[i]; if (!element.isValid) { _seedError = true; } } if (_seedError) { - for (var element in _seedGridElements) { - int i = _seedGridElements.indexOf(element); + for (final element in _seedGridElements) { + final i = _seedGridElements.indexOf(element); if (_randomIndexes.contains(i)) { element.isValid = false; element.word = ''; @@ -423,11 +419,11 @@ class _NewWalletConfirmSeedScreenState } Widget _getSeedInputWidgetsGrid() { - int divider = widget.seedWords.length ~/ kSeedGridNumOfRows; + final divider = widget.seedWords.length ~/ kSeedGridNumOfRows; - List columnChildren = []; + var columnChildren = []; - for (int i = 0; i <= _seedGridElements.length / divider - 1; i++) { + for (var i = 0; i <= _seedGridElements.length / divider - 1; i++) { columnChildren.add( _getSeedRow( List.generate( @@ -442,7 +438,7 @@ class _NewWalletConfirmSeedScreenState List.generate( kSeedGridNumOfRows - 1, (index) => const SizedBox( - height: 10.0, + height: 10, ), ), ); @@ -454,16 +450,16 @@ class _NewWalletConfirmSeedScreenState } Widget _getSeedRow(List rangeIndexes) { - List children = rangeIndexes.fold>( + final children = rangeIndexes.fold>( [], (previousValue, index) { previousValue.add(_seedFieldWidget( _seedGridElements[index], - )); + ),); if (rangeIndexes.last != index) { previousValue.add( const SizedBox( - width: 10.0, + width: 10, ), ); } diff --git a/lib/screens/onboarding/new_wallet/new_wallet_password_screen.dart b/lib/screens/onboarding/new_wallet/new_wallet_password_screen.dart index a9c458e1..f7687290 100644 --- a/lib/screens/onboarding/new_wallet/new_wallet_password_screen.dart +++ b/lib/screens/onboarding/new_wallet/new_wallet_password_screen.dart @@ -4,9 +4,9 @@ import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class NewWalletPasswordScreen extends StatefulWidget { - final List seedWords; const NewWalletPasswordScreen(this.seedWords, {super.key}); + final List seedWords; @override State createState() => @@ -26,7 +26,7 @@ class _NewWalletPasswordScreenState extends State { return Scaffold( body: Container( padding: const EdgeInsets.symmetric( - vertical: 30.0, + vertical: 30, ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -37,16 +37,16 @@ class _NewWalletPasswordScreenState extends State { currentLevel: 3, ), const SizedBox( - height: 30.0, + height: 30, ), Text('Create a wallet password', - style: Theme.of(context).textTheme.headlineLarge), + style: Theme.of(context).textTheme.headlineLarge,), kVerticalSpacing, Text( 'This is the password that will be required to unlock the wallet', - style: Theme.of(context).textTheme.headlineMedium), + style: Theme.of(context).textTheme.headlineMedium,), const SizedBox( - height: 65.0, + height: 65, ), Column( children: [ @@ -70,7 +70,7 @@ class _NewWalletPasswordScreenState extends State { controller: _confirmPasswordController, validator: (value) => InputValidators.checkPasswordMatch( - _passwordController.text, value), + _passwordController.text, value,), onChanged: (value) { setState(() {}); }, @@ -78,7 +78,7 @@ class _NewWalletPasswordScreenState extends State { ), ), const SizedBox( - height: 35.0, + height: 35, ), PasswordProgressBar( password: _passwordController.text, @@ -98,7 +98,7 @@ class _NewWalletPasswordScreenState extends State { children: [ _getPassiveButton(), kSpacingBetweenActionButtons, - _getActionButton() + _getActionButton(), ], ), ], diff --git a/lib/screens/onboarding/new_wallet/new_wallet_seed_choice_screen.dart b/lib/screens/onboarding/new_wallet/new_wallet_seed_choice_screen.dart index 0f1af50b..7ac63cd2 100644 --- a/lib/screens/onboarding/new_wallet/new_wallet_seed_choice_screen.dart +++ b/lib/screens/onboarding/new_wallet/new_wallet_seed_choice_screen.dart @@ -8,9 +8,9 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class NewWalletSeedChoiceScreen extends StatefulWidget { - final bool? export; const NewWalletSeedChoiceScreen({super.key, this.export}); + final bool? export; @override State createState() => @@ -22,7 +22,8 @@ class _NewWalletSeedChoiceScreenState extends State { bool? _isSeedSecure = false; bool? _isSeedWrittenDown = false; - late List _generatedSeed24, _generatedSeed12; + late List _generatedSeed24; + late List _generatedSeed12; final GlobalKey _seedGridKey = GlobalKey(); @@ -39,7 +40,7 @@ class _NewWalletSeedChoiceScreenState extends State { return Scaffold( body: Container( padding: const EdgeInsets.symmetric( - vertical: 30.0, + vertical: 30, ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -50,7 +51,7 @@ class _NewWalletSeedChoiceScreenState extends State { currentLevel: 1, ), const SizedBox( - height: 30.0, + height: 30, ), Text( _isSeed12Selected @@ -65,7 +66,7 @@ class _NewWalletSeedChoiceScreenState extends State { ), kVerticalSpacing, SizedBox( - height: 45.0, + height: 45, child: Visibility( visible: !_isSeedSecure!, child: _getSeedChoice(), @@ -76,7 +77,7 @@ class _NewWalletSeedChoiceScreenState extends State { ], ), SizedBox( - height: 40.0, + height: 40, child: Visibility( visible: !_isSeedSecure!, child: _getBackUpSeedContainer(), @@ -147,17 +148,15 @@ class _NewWalletSeedChoiceScreenState extends State { color: _isSeedExported(exportedSeed.value) ? AppColors.znnColor : Colors.transparent, - borderRadius: const BorderRadius.all(Radius.circular(6.0)), + borderRadius: const BorderRadius.all(Radius.circular(6)), border: Border.all( color: AppColors.znnColor, - width: 1.0, - style: BorderStyle.solid, - )), + ),), child: InkWell( child: FocusableActionDetector( child: SizedBox( - height: 50.0, - width: 150.0, + height: 50, + width: 150, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -167,12 +166,12 @@ class _NewWalletSeedChoiceScreenState extends State { 'assets/svg/ic_export_seed.svg', colorFilter: ColorFilter.mode( Theme.of(context).textTheme.headlineSmall!.color!, - BlendMode.srcIn), - height: 18.0, + BlendMode.srcIn,), + height: 18, ), ), const SizedBox( - width: 15.0, + width: 15, ), Text( 'Export Seed', @@ -221,7 +220,7 @@ class _NewWalletSeedChoiceScreenState extends State { Text( 'I have backed up my seed in a safe location', style: Theme.of(context).textTheme.headlineSmall, - ) + ), ], ); } diff --git a/lib/screens/onboarding/onboarding.dart b/lib/screens/onboarding/onboarding.dart index 6b624c50..ee868ba3 100644 --- a/lib/screens/onboarding/onboarding.dart +++ b/lib/screens/onboarding/onboarding.dart @@ -1,8 +1,7 @@ -library; export 'access_wallet_screen.dart'; export 'create_key_store_screen.dart'; -export 'wallet_success_screen.dart'; +export 'hardware_wallet/hardware_wallet.dart'; export 'import_wallet/import_wallet.dart'; export 'new_wallet/new_wallet.dart'; -export 'hardware_wallet/hardware_wallet.dart'; +export 'wallet_success_screen.dart'; diff --git a/lib/screens/onboarding/wallet_success_screen.dart b/lib/screens/onboarding/wallet_success_screen.dart index 07a84dd0..1b2b56db 100644 --- a/lib/screens/onboarding/wallet_success_screen.dart +++ b/lib/screens/onboarding/wallet_success_screen.dart @@ -5,12 +5,12 @@ import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class WalletSuccessScreen extends StatefulWidget { - final int progressBarNumLevels; const WalletSuccessScreen({ this.progressBarNumLevels = 5, super.key, }); + final int progressBarNumLevels; @override State createState() => _WalletSuccessScreenState(); @@ -22,7 +22,7 @@ class _WalletSuccessScreenState extends State { return Scaffold( body: Container( padding: const EdgeInsets.symmetric( - vertical: 30.0, + vertical: 30, ), child: _getSuccessBody(), ), @@ -39,10 +39,10 @@ class _WalletSuccessScreenState extends State { numLevels: widget.progressBarNumLevels, ), const SizedBox( - height: 30.0, + height: 30, ), Text( - 'You\'re all set', + "You're all set", style: Theme.of(context).textTheme.headlineLarge, ), kVerticalSpacing, diff --git a/lib/screens/project_details_screen.dart b/lib/screens/project_details_screen.dart index a2ccf598..95d91397 100644 --- a/lib/screens/project_details_screen.dart +++ b/lib/screens/project_details_screen.dart @@ -7,9 +7,6 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ProjectDetailsScreen extends StatefulWidget { - final VoidCallback onStepperNotificationSeeMorePressed; - final AcceleratorProject project; - final PillarInfo? pillarInfo; const ProjectDetailsScreen({ required this.project, @@ -17,6 +14,9 @@ class ProjectDetailsScreen extends StatefulWidget { required this.onStepperNotificationSeeMorePressed, super.key, }); + final VoidCallback onStepperNotificationSeeMorePressed; + final AcceleratorProject project; + final PillarInfo? pillarInfo; @override State createState() => _ProjectDetailsScreenState(); @@ -29,9 +29,9 @@ class _ProjectDetailsScreenState extends State { body: SafeArea( child: Container( margin: const EdgeInsets.only( - left: 20.0, - right: 20.0, - bottom: 20.0, + left: 20, + right: 20, + bottom: 20, ), child: Column( children: [ @@ -39,7 +39,7 @@ class _ProjectDetailsScreenState extends State { mainAxisAlignment: MainAxisAlignment.end, children: [ IconButton( - splashRadius: 20.0, + splashRadius: 20, onPressed: () { Navigator.pop(context); }, @@ -133,7 +133,7 @@ class _ProjectDetailsScreenState extends State { return const SyriusLoadingWidget(); }, ), - viewModelBuilder: () => RefreshProjectBloc(), + viewModelBuilder: RefreshProjectBloc.new, ); } } diff --git a/lib/screens/reset_wallet_screen.dart b/lib/screens/reset_wallet_screen.dart index 64c5a3e2..e00735d4 100644 --- a/lib/screens/reset_wallet_screen.dart +++ b/lib/screens/reset_wallet_screen.dart @@ -23,21 +23,21 @@ class _ResetWalletScreenState extends State { children: [ Container( padding: const EdgeInsets.only( - bottom: 10.0, + bottom: 10, ), decoration: BoxDecoration( shape: BoxShape.circle, border: Border.all( - width: 4.0, + width: 4, color: AppColors.errorColor, ), ), child: const Padding( - padding: EdgeInsets.all(20.0), + padding: EdgeInsets.all(20), child: Icon( Feather.alert_triangle, color: AppColors.errorColor, - size: 50.0, + size: 50, ), ), ), @@ -48,7 +48,7 @@ class _ResetWalletScreenState extends State { ), kVerticalSpacing, SizedBox( - width: 500.0, + width: 500, child: Text( 'All your wallet data will be erased permanently. Make sure ' 'you have a backup of your mnemonic or Seed Vault & Seed Vault Key before you proceed ' @@ -69,29 +69,29 @@ class _ResetWalletScreenState extends State { }, outlineColor: Colors.white, text: 'Cancel', - minimumSize: const Size(100.0, 40.0), + minimumSize: const Size(100, 40), ), const SizedBox( - width: 20.0, + width: 20, ), MyOutlinedButton( outlineColor: AppColors.errorColor, onPressed: _onResetPressed, text: 'Reset', textColor: AppColors.errorColor, - minimumSize: const Size(100.0, 40.0), - ) + minimumSize: const Size(100, 40), + ), ], ), const SizedBox( - height: 30.0, + height: 30, ), ], ), ); } - void _onResetPressed() async { + Future _onResetPressed() async { NodeUtils.closeEmbeddedNode(); kLastDismissedNotification = kLastNotification; diff --git a/lib/screens/screens.dart b/lib/screens/screens.dart index 072a53ab..fb963d2d 100644 --- a/lib/screens/screens.dart +++ b/lib/screens/screens.dart @@ -1,12 +1,11 @@ -library; export 'change_wallet_password_screen.dart'; export 'development_intialization_screen.dart'; export 'dump_mnemonic_screen.dart'; +export 'export/export.dart'; export 'node_management_screen.dart'; +export 'onboarding/onboarding.dart'; export 'project_details_screen.dart'; export 'reset_wallet_screen.dart'; export 'splash_screen.dart'; export 'stepper_screen.dart'; -export 'export/export.dart'; -export 'onboarding/onboarding.dart'; diff --git a/lib/screens/splash_screen.dart b/lib/screens/splash_screen.dart index 7710610d..f7185685 100644 --- a/lib/screens/splash_screen.dart +++ b/lib/screens/splash_screen.dart @@ -14,16 +14,16 @@ import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class SplashScreen extends StatefulWidget { - static const String route = 'splash-screen'; - - final bool resetWalletFlow; - final bool deleteCacheFlow; const SplashScreen({ this.resetWalletFlow = false, this.deleteCacheFlow = false, super.key, }); + static const String route = 'splash-screen'; + + final bool resetWalletFlow; + final bool deleteCacheFlow; @override State createState() => _SplashScreenState(); @@ -43,11 +43,9 @@ class _SplashScreenState extends State { return FutureBuilder( future: _composition, builder: (context, snapshot) { - var composition = snapshot.data; + final composition = snapshot.data; if (composition != null) { - Future.delayed(composition.duration, () { - _splashInits(); - }); + Future.delayed(composition.duration, _splashInits); return Lottie( composition: composition, repeat: false, @@ -118,7 +116,7 @@ class _SplashScreenState extends State { await Hive.close(); await Future.forEach( kCacheBoxesToBeDeleted, - (boxName) async => await Hive.deleteBoxFromDisk(boxName), + (boxName) async => Hive.deleteBoxFromDisk(boxName), ); await _deleteWeb3Cache(); } @@ -126,7 +124,7 @@ class _SplashScreenState extends State { Future _deleteWeb3Cache() async { try { final web3WalletService = sl(); - for (var pairing in web3WalletService.pairings.value) { + for (final pairing in web3WalletService.pairings.value) { await web3WalletService.deactivatePairing(topic: pairing.topic); } } catch (e, stackTrace) { diff --git a/lib/screens/stepper_screen.dart b/lib/screens/stepper_screen.dart index 14bebc5d..1c4dfb99 100644 --- a/lib/screens/stepper_screen.dart +++ b/lib/screens/stepper_screen.dart @@ -2,20 +2,20 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class StepperScreen extends StatelessWidget { - final VoidCallback onStepperNotificationSeeMorePressed; - final Widget stepper; const StepperScreen({ required this.stepper, required this.onStepperNotificationSeeMorePressed, super.key, }); + final VoidCallback onStepperNotificationSeeMorePressed; + final Widget stepper; @override Widget build(BuildContext context) { return Scaffold( body: Container( - margin: const EdgeInsets.all(20.0), + margin: const EdgeInsets.all(20), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ @@ -27,7 +27,7 @@ class StepperScreen extends StatelessWidget { decoration: BoxDecoration( color: Theme.of(context).colorScheme.primary, borderRadius: BorderRadius.circular( - 15.0, + 15, ), ), child: Stack( @@ -35,8 +35,8 @@ class StepperScreen extends StatelessWidget { children: [ stepper, Positioned( - top: 0.0, - right: 0.0, + top: 0, + right: 0, child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ @@ -44,7 +44,7 @@ class StepperScreen extends StatelessWidget { constraints: const BoxConstraints.tightForFinite(), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - padding: const EdgeInsets.all(20.0), + padding: const EdgeInsets.all(20), shape: const CircleBorder(), onPressed: () { Navigator.pop(context); diff --git a/lib/services/htlc_swaps_service.dart b/lib/services/htlc_swaps_service.dart index ce6b2f8c..c54db80c 100644 --- a/lib/services/htlc_swaps_service.dart +++ b/lib/services/htlc_swaps_service.dart @@ -20,16 +20,16 @@ class HtlcSwapsService { bool get isMaxSwapsReached => _htlcSwapsBox!.length >= kMaxP2pSwapsToStore; Future openBoxes(String htlcSwapsBoxSuffix, List cipherKey, - {List? newCipherKey}) async { + {List? newCipherKey,}) async { if (_htlcSwapsBox == null || !_htlcSwapsBox!.isOpen) { _htlcSwapsBox = await Hive.openBox('${kHtlcSwapsBox}_$htlcSwapsBoxSuffix', - encryptionCipher: HiveAesCipher(cipherKey)); + encryptionCipher: HiveAesCipher(cipherKey),); if (newCipherKey != null) { final values = _htlcSwapsBox!.toMap(); await _htlcSwapsBox!.deleteFromDisk(); _htlcSwapsBox = await Hive.openBox( '${kHtlcSwapsBox}_$htlcSwapsBoxSuffix', - encryptionCipher: HiveAesCipher(newCipherKey)); + encryptionCipher: HiveAesCipher(newCipherKey),); _htlcSwapsBox!.putAll(values); _htlcSwapsBox!.flush(); } @@ -39,13 +39,13 @@ class HtlcSwapsService { !_lastCheckedHtlcBlockHeightBox!.isOpen) { _lastCheckedHtlcBlockHeightBox = await Hive.openBox( kLastCheckedHtlcBlockBox, - encryptionCipher: HiveAesCipher(cipherKey)); + encryptionCipher: HiveAesCipher(cipherKey),); if (newCipherKey != null) { final values = _lastCheckedHtlcBlockHeightBox!.toMap(); await _lastCheckedHtlcBlockHeightBox!.deleteFromDisk(); _lastCheckedHtlcBlockHeightBox = await Hive.openBox( kLastCheckedHtlcBlockBox, - encryptionCipher: HiveAesCipher(newCipherKey)); + encryptionCipher: HiveAesCipher(newCipherKey),); _lastCheckedHtlcBlockHeightBox!.putAll(values); _lastCheckedHtlcBlockHeightBox!.flush(); } @@ -86,7 +86,7 @@ class HtlcSwapsService { HtlcSwap? getSwapByHtlcId(String htlcId) { try { return _swapsForCurrentChainId.firstWhereOrNull( - (e) => e.initialHtlcId == htlcId || e.counterHtlcId == htlcId); + (e) => e.initialHtlcId == htlcId || e.counterHtlcId == htlcId,); } on HiveError { return null; } @@ -105,34 +105,34 @@ class HtlcSwapsService { .get(kLastCheckedHtlcBlockKey, defaultValue: 0); } - Future storeSwap(HtlcSwap swap) async => await _htlcSwapsBox! + Future storeSwap(HtlcSwap swap) async => _htlcSwapsBox! .put( swap.id, jsonEncode(swap.toJson()), ) - .then((_) async => await _pruneSwapsHistoryIfNeeded()); + .then((_) async => _pruneSwapsHistoryIfNeeded()); Future storeLastCheckedHtlcBlockHeight(int height) async => - await _lastCheckedHtlcBlockHeightBox! + _lastCheckedHtlcBlockHeightBox! .put(kLastCheckedHtlcBlockKey, height); Future deleteSwap(String swapId) async => - await _htlcSwapsBox!.delete(swapId); + _htlcSwapsBox!.delete(swapId); Future deleteInactiveSwaps() async => - await _htlcSwapsBox!.deleteAll(_swapsForCurrentChainId + _htlcSwapsBox!.deleteAll(_swapsForCurrentChainId .where((e) => [ P2pSwapState.completed, P2pSwapState.unsuccessful, - P2pSwapState.error - ].contains(e.state)) - .map((e) => e.id)); + P2pSwapState.error, + ].contains(e.state),) + .map((e) => e.id),); List get _swapsForCurrentChainId { return kNodeChainId != null ? _htlcSwapsBox!.values .where( - (e) => HtlcSwap.fromJson(jsonDecode(e)).chainId == kNodeChainId) + (e) => HtlcSwap.fromJson(jsonDecode(e)).chainId == kNodeChainId,) .map((e) => HtlcSwap.fromJson(jsonDecode(e))) .toList() : []; @@ -141,7 +141,7 @@ class HtlcSwapsService { HtlcSwap? _getOldestPrunableSwap() { final swaps = getAllSwaps() .where((e) => [P2pSwapState.completed, P2pSwapState.unsuccessful] - .contains(e.state)) + .contains(e.state),) .toList(); swaps.sort((a, b) => b.startTime.compareTo(a.startTime)); return swaps.isNotEmpty ? swaps.last : null; diff --git a/lib/services/shared_prefs_service.dart b/lib/services/shared_prefs_service.dart index 547d2eb5..03140b9d 100644 --- a/lib/services/shared_prefs_service.dart +++ b/lib/services/shared_prefs_service.dart @@ -25,10 +25,10 @@ class SharedPrefsService { } } - Future close() async => await _sharedPrefsBox!.close(); + Future close() async => _sharedPrefsBox!.close(); Future put(String key, dynamic value) async => - await _sharedPrefsBox!.put( + _sharedPrefsBox!.put( key, value, ); diff --git a/lib/services/web3wallet_service.dart b/lib/services/web3wallet_service.dart index 5b67f2e5..e2873f39 100644 --- a/lib/services/web3wallet_service.dart +++ b/lib/services/web3wallet_service.dart @@ -45,7 +45,7 @@ class Web3WalletService extends IWeb3WalletService { description: 'A wallet for interacting with Zenon Network', url: 'https://zenon.network', icons: [ - 'https://raw.githubusercontent.com/zenon-network/syrius/master/macos/Runner/Assets.xcassets/AppIcon.appiconset/Icon-MacOS-512x512%402x.png' + 'https://raw.githubusercontent.com/zenon-network/syrius/master/macos/Runner/Assets.xcassets/AppIcon.appiconset/Icon-MacOS-512x512%402x.png', ], ), ); @@ -152,7 +152,7 @@ class Web3WalletService extends IWeb3WalletService { } catch (e, s) { // Catch anything else (not just Exceptions) and log stack Logger('WalletConnectService').log(Level.INFO, - 'disconnectAllParings - Unexpected error: $e, topic $topic\n$s'); + 'disconnectAllParings - Unexpected error: $e, topic $topic\n$s',); } } @@ -183,10 +183,10 @@ class Web3WalletService extends IWeb3WalletService { Future disconnectSessions() async { Logger('WalletConnectService') .log(Level.INFO, 'disconnectSessions triggered'); - for (int i = 0; i < pairings.value.length; i++) { + for (var i = 0; i < pairings.value.length; i++) { await _wcClient!.disconnectSession( topic: pairings.value[i].topic, - reason: Errors.getSdkError(Errors.USER_DISCONNECTED)); + reason: Errors.getSdkError(Errors.USER_DISCONNECTED),); } _idSessionsApproved.clear(); } @@ -208,22 +208,22 @@ class Web3WalletService extends IWeb3WalletService { return _wcClient!.getActiveSessions(); } - void _onRelayClientConnect(var args) async { + Future _onRelayClientConnect(var args) async { Logger('WalletConnectService') .log(Level.INFO, '_onRelayClientConnect triggered', args.toString()); } - void _onRelayClientDisconnect(var args) async { + Future _onRelayClientDisconnect(var args) async { Logger('WalletConnectService') .log(Level.INFO, '_onRelayClientDisconnect triggered', args.toString()); } - void _onRelayClientError(var args) async { + Future _onRelayClientError(var args) async { Logger('WalletConnectService') .log(Level.INFO, '_onRelayClientError triggered', args.toString()); } - void _onSessionsSync(StoreSyncEvent? args) async { + Future _onSessionsSync(StoreSyncEvent? args) async { if (args != null) { Logger('WalletConnectService') .log(Level.INFO, '_onSessionsSync triggered', args.toString()); @@ -231,19 +231,19 @@ class Web3WalletService extends IWeb3WalletService { } } - void _onPairingCreate(PairingEvent? args) async { + Future _onPairingCreate(PairingEvent? args) async { Logger('WalletConnectService') .log(Level.INFO, 'onPairingCreate triggered', args.toString()); sl.get().refreshResults(); } - void _onPairingActivate(PairingActivateEvent? args) async { + Future _onPairingActivate(PairingActivateEvent? args) async { Logger('WalletConnectService') .log(Level.INFO, '_onPairingActivate triggered', args.toString()); sl.get().refreshResults(); } - void _onPairingPing(PairingEvent? args) async { + Future _onPairingPing(PairingEvent? args) async { Logger('WalletConnectService') .log(Level.INFO, '_onPairingPing triggered', args.toString()); } @@ -253,12 +253,12 @@ class Web3WalletService extends IWeb3WalletService { .log(Level.INFO, 'onPairingInvalid triggered', args.toString()); } - void _onPairingDelete(PairingEvent? args) async { + Future _onPairingDelete(PairingEvent? args) async { Logger('WalletConnectService') .log(Level.INFO, '_onPairingDelete triggered', args.toString()); } - void _onPairingsSync(StoreSyncEvent? args) async { + Future _onPairingsSync(StoreSyncEvent? args) async { if (args != null) { Logger('WalletConnectService') .log(Level.INFO, '_onPairingsSync triggered', args.toString()); @@ -266,7 +266,7 @@ class Web3WalletService extends IWeb3WalletService { } } - void _onSessionRequest(SessionRequestEvent? args) async { + Future _onSessionRequest(SessionRequestEvent? args) async { Logger('WalletConnectService') .log(Level.INFO, '_onSessionRequest triggered', args.toString()); } @@ -283,7 +283,7 @@ class Web3WalletService extends IWeb3WalletService { sl.get().refreshResults(); } - void _onSessionProposal(SessionProposalEvent? event) async { + Future _onSessionProposal(SessionProposalEvent? event) async { Logger('WalletConnectService') .log(Level.INFO, '_onSessionProposal triggered', event.toString()); @@ -299,14 +299,13 @@ class Web3WalletService extends IWeb3WalletService { title: 'Approve session', content: Column( mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, children: [ Text('Are you sure you want to ' 'connect to ${dAppMetadata.name} ?'), kVerticalSpacing, Image( image: NetworkImage(dAppMetadata.icons.first), - height: 100.0, + height: 100, fit: BoxFit.fitHeight, ), kVerticalSpacing, @@ -318,7 +317,7 @@ class Web3WalletService extends IWeb3WalletService { Text(dAppMetadata.url), LinkIcon( url: dAppMetadata.url, - ) + ), ], ), ], @@ -331,15 +330,15 @@ class Web3WalletService extends IWeb3WalletService { if (!_idSessionsApproved.contains(event.id)) { _idSessionsApproved.add(event.id); try { - ApproveResponse approveResponse = + final approveResponse = await _approveSession(id: event.id); await _sendSuccessfullyApprovedSessionNotification(dAppMetadata); sessions.value.add(approveResponse.session); } catch (e, stackTrace) { await NotificationUtils.sendNotificationError( - e, 'WalletConnect session approval failed'); + e, 'WalletConnect session approval failed',); Logger('WalletConnectService').log( - Level.INFO, 'onSessionProposal approveResponse', e, stackTrace); + Level.INFO, 'onSessionProposal approveResponse', e, stackTrace,); } } } else { @@ -364,7 +363,7 @@ class Web3WalletService extends IWeb3WalletService { } Future _sendSuccessfullyApprovedSessionNotification( - PairingMetadata dAppMetadata) async { + PairingMetadata dAppMetadata,) async { await sl.get().addNotification( WalletNotification( title: 'Successfully connected to ${dAppMetadata.name}', @@ -377,7 +376,7 @@ class Web3WalletService extends IWeb3WalletService { } Future _approveSession( - {required int id, Map? namespaces}) async { + {required int id, Map? namespaces,}) async { if (!await windowManager.isFocused() || !await windowManager.isVisible()) { windowManager.show(); } @@ -421,7 +420,7 @@ class Web3WalletService extends IWeb3WalletService { return previousValue; }); - for (String sessionTopic in sessionTopics) { + for (final sessionTopic in sessionTopics) { _emitDAppEvent( sessionTopic: sessionTopic, changeName: changeName, diff --git a/lib/utils/account_block_utils.dart b/lib/utils/account_block_utils.dart index 72a0bf5b..d90c277d 100644 --- a/lib/utils/account_block_utils.dart +++ b/lib/utils/account_block_utils.dart @@ -15,11 +15,11 @@ class AccountBlockUtils { Address? address, bool waitForRequiredPlasma = false, }) async { - SyncInfo syncInfo = await zenon!.stats.syncInfo(); - bool nodeIsSynced = (syncInfo.state == SyncState.syncDone || + final syncInfo = await zenon!.stats.syncInfo(); + final nodeIsSynced = syncInfo.state == SyncState.syncDone || (syncInfo.targetHeight > 0 && syncInfo.currentHeight > 0 && - (syncInfo.targetHeight - syncInfo.currentHeight) < 20)); + (syncInfo.targetHeight - syncInfo.currentHeight) < 20); if (nodeIsSynced) { // Acquire wallet lock to prevent concurrent access. final wallet = await kWalletFile!.open(); @@ -28,11 +28,11 @@ class AccountBlockUtils { final walletAccount = await wallet .getAccount(kDefaultAddressList.indexOf(address.toString())); - bool needPlasma = await zenon!.requiresPoW( + final needPlasma = await zenon!.requiresPoW( transactionParams, blockSigningKey: walletAccount, ); - bool needReview = kWalletFile!.isHardwareWallet; + final needReview = kWalletFile!.isHardwareWallet; if (needPlasma) { await sl @@ -41,7 +41,7 @@ class AccountBlockUtils { } else if (needReview) { await _sendReviewNotification(transactionParams); } - final AccountBlockTemplate response = await zenon!.send( + final response = await zenon!.send( transactionParams, currentKeyPair: walletAccount, generatingPowCallback: (status) async { @@ -93,11 +93,11 @@ class AccountBlockUtils { try { for (final entry in abi.entries) { if (eq(AbiFunction.extractSignature(entry.encodeSignature()), - AbiFunction.extractSignature(encodedData))) { + AbiFunction.extractSignature(encodedData),)) { final decoded = AbiFunction(entry.name!, entry.inputs!).decode(encodedData); - final Map params = {}; - for (int i = 0; i < entry.inputs!.length; i += 1) { + final params = {}; + for (var i = 0; i < entry.inputs!.length; i += 1) { params[entry.inputs![i].name!] = decoded[i]; } return BlockData(function: entry.name!, params: params); @@ -112,13 +112,13 @@ class AccountBlockUtils { // Returns a list of AccountBlocks that are newer than a given timestamp. // The list is returned in ascending order. static Future> getAccountBlocksAfterTime( - Address address, int time) async { - final List blocks = []; - int pageIndex = 0; + Address address, int time,) async { + final blocks = []; + var pageIndex = 0; try { while (true) { final fetched = await zenon!.ledger.getAccountBlocksByPage(address, - pageIndex: pageIndex, pageSize: 100); + pageIndex: pageIndex, pageSize: 100,); final lastBlockConfirmation = fetched.list!.last.confirmationDetail; if (lastBlockConfirmation == null || @@ -149,7 +149,7 @@ class AccountBlockUtils { } static Future getTimeForAccountBlockHeight( - Address address, int height) async { + Address address, int height,) async { if (height >= 1) { try { final block = @@ -165,7 +165,7 @@ class AccountBlockUtils { } static Future _sendReviewNotification( - AccountBlockTemplate transactionParams) async { + AccountBlockTemplate transactionParams,) async { await sl.get().addNotification( WalletNotification( title: diff --git a/lib/utils/address_utils.dart b/lib/utils/address_utils.dart index 56f3e378..ea64d503 100644 --- a/lib/utils/address_utils.dart +++ b/lib/utils/address_utils.dart @@ -6,11 +6,11 @@ import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/wallet_file.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/node_utils.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/wallet_file.dart'; import 'package:znn_ledger_dart/znn_ledger_dart.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -22,15 +22,15 @@ class ZenonAddressUtils { kAddressLabelMap[address] ?? address; static Future generateNewAddress( - {int numAddr = 1, VoidCallback? callback}) async { + {int numAddr = 1, VoidCallback? callback,}) async { final wallet = await kWalletFile!.open(); try { await Future.delayed(const Duration(milliseconds: 500)); - List listAddr = []; - int addrListLength = kDefaultAddressList.length; - for (int i = 0; i < numAddr; i++) { - int addrListCounter = addrListLength + i; - WalletAccount walletAccount = await wallet.getAccount(addrListCounter); + final listAddr = []; + final addrListLength = kDefaultAddressList.length; + for (var i = 0; i < numAddr; i++) { + final addrListCounter = addrListLength + i; + final walletAccount = await wallet.getAccount(addrListCounter); Address? address; if (walletAccount is LedgerWalletAccount) { await sl.get().addNotification( @@ -48,10 +48,10 @@ class ZenonAddressUtils { address = await walletAccount.getAddress(); } listAddr.add(address); - Box addressesBox = Hive.box(kAddressesBox); + final addressesBox = Hive.box(kAddressesBox); await addressesBox.add(listAddr.elementAt(i).toString()); _initAddresses(addressesBox); - Box addressLabelsBox = Hive.box(kAddressLabelsBox); + final addressLabelsBox = Hive.box(kAddressLabelsBox); await addressLabelsBox.put( listAddr.elementAt(i).toString(), 'Address ${kDefaultAddressList.length}', @@ -63,19 +63,19 @@ class ZenonAddressUtils { listAddr.clear(); } catch (e) { await NotificationUtils.sendNotificationError( - e, 'Error while generating new address'); + e, 'Error while generating new address',); } finally { kWalletFile!.close(); } } static Future setAddressLabels() async { - Box addressLabelsBox = await Hive.openBox(kAddressLabelsBox); + final addressLabelsBox = await Hive.openBox(kAddressLabelsBox); if (addressLabelsBox.isEmpty) { - for (var address in kDefaultAddressList) { + for (final address in kDefaultAddressList) { await addressLabelsBox.put( - address, 'Address ${kDefaultAddressList.indexOf(address) + 1}'); + address, 'Address ${kDefaultAddressList.indexOf(address) + 1}',); } } _initAddressLabels(addressLabelsBox); @@ -92,16 +92,16 @@ class ZenonAddressUtils { } static Future setAddresses(WalletFile? walletFile) async { - Box addressesBox = await Hive.openBox(kAddressesBox); + final addressesBox = await Hive.openBox(kAddressesBox); if (addressesBox.isEmpty) { await walletFile!.access((wallet) async { - for (var element in (await Future.wait( + for (final element in await Future.wait( List>.generate( kNumOfInitialAddresses, (index) async => (await (await wallet.getAccount(index)).getAddress()) - .toString()), - ))) { + .toString(),), + )) { addressesBox.add(element); } }); diff --git a/lib/utils/app_colors.dart b/lib/utils/app_colors.dart index 01a0440b..6a25012e 100644 --- a/lib/utils/app_colors.dart +++ b/lib/utils/app_colors.dart @@ -5,7 +5,7 @@ class AppColors { static const qsrColor = Color(0xFF005FE3); static const ztsColor = Color(0xFFF91690); - static const errorColor = Color.fromRGBO(244, 4, 88, 1.0); + static const errorColor = Color.fromRGBO(244, 4, 88, 1); static const backgroundLight = Color(0xFFEAEAEA); static const backgroundDark = Color(0xFF1E1E1E); @@ -17,12 +17,12 @@ class AppColors { static const lightSecondary = Color(0xFFB3B3B3); static const lightSecondaryContainer = Color(0xFF545454); static const darkSecondary = Color(0xFF3F3F3F); - static const darkSecondaryContainer = Color.fromRGBO(46, 46, 46, 1.0); + static const darkSecondaryContainer = Color.fromRGBO(46, 46, 46, 1); static const alertNotification = Color(0xFFDAE240); - static const accessWalletContainersGray = Color.fromRGBO(46, 46, 46, 1.0); - static const inactiveIconsGray = Color.fromRGBO(51, 51, 51, 1.0); + static const accessWalletContainersGray = Color.fromRGBO(46, 46, 46, 1); + static const inactiveIconsGray = Color.fromRGBO(51, 51, 51, 1); static const darkPrimary = Color(0xFF262626); static const darkPrimaryContainer = Color(0xFF2D2D2D); @@ -32,7 +32,7 @@ class AppColors { static const darkDividerColor = Color(0xFF333333); static const lightTextFormFieldFill = Color(0xFFE4E4E4); - static const darkTextFormFieldFill = Color.fromRGBO(51, 51, 51, 1.0); + static const darkTextFormFieldFill = Color.fromRGBO(51, 51, 51, 1); static const darkHintTextColor = Color.fromRGBO(99, 99, 99, 1); static const lightHintTextColor = Color.fromRGBO(179, 179, 179, 1); diff --git a/lib/utils/app_theme.dart b/lib/utils/app_theme.dart index d8bf03fd..75337d97 100644 --- a/lib/utils/app_theme.dart +++ b/lib/utils/app_theme.dart @@ -2,17 +2,17 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; const DividerThemeData kDefaultDividerThemeData = DividerThemeData( - thickness: 1.0, - indent: 0.0, - endIndent: 0.0, - space: 1.0, + thickness: 1, + indent: 0, + endIndent: 0, + space: 1, ); final ButtonStyle kElevatedButtonStyle = ElevatedButton.styleFrom( tapTargetSize: MaterialTapTargetSize.shrinkWrap, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular( - 6.0, + 6, ), ), minimumSize: const Size(55, 42), @@ -23,7 +23,7 @@ final ButtonStyle kOutlinedButtonStyle = OutlinedButton.styleFrom( tapTargetSize: MaterialTapTargetSize.shrinkWrap, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular( - 6.0, + 6, ), ), side: const BorderSide( @@ -33,58 +33,58 @@ final ButtonStyle kOutlinedButtonStyle = OutlinedButton.styleFrom( ); const TextStyle kDisplaySmallTextStyle = TextStyle( - fontSize: 14.0, + fontSize: 14, fontWeight: FontWeight.w400, ); const TextStyle kBodyLargeTextStyle = TextStyle( - fontSize: 14.0, + fontSize: 14, fontWeight: FontWeight.w400, ); const TextStyle kBodyMediumTextStyle = TextStyle( - fontSize: 12.0, + fontSize: 12, fontWeight: FontWeight.w400, ); const TextStyle kBodySmallTextStyle = TextStyle( - fontSize: 10.0, + fontSize: 10, fontWeight: FontWeight.w300, ); const TextStyle kHeadlineLargeTextStyle = TextStyle( - fontSize: 26.0, + fontSize: 26, fontWeight: FontWeight.w500, ); const TextStyle kHeadlineMediumTextStyle = TextStyle( - fontSize: 24.0, + fontSize: 24, fontWeight: FontWeight.w500, ); const TextStyle kHeadlineSmallTextStyle = TextStyle( - fontSize: 16.0, + fontSize: 16, fontWeight: FontWeight.w400, ); const TextStyle kOutlinedButtonTextStyle = TextStyle( - fontSize: 16.0, + fontSize: 16, fontWeight: FontWeight.w400, ); const TextStyle kTextButtonTextStyle = TextStyle( - fontSize: 10.0, + fontSize: 10, fontWeight: FontWeight.w400, ); const TextStyle kTitleMediumTextStyle = TextStyle( - fontSize: 12.0, + fontSize: 12, fontWeight: FontWeight.w400, color: AppColors.subtitleColor, ); const TextStyle kTitleSmallTextStyle = TextStyle( - fontSize: 10.0, + fontSize: 10, fontWeight: FontWeight.w400, color: AppColors.subtitleColor, ); @@ -93,11 +93,11 @@ final TextButtonThemeData kTextButtonThemeData = TextButtonThemeData( style: TextButton.styleFrom( textStyle: kTextButtonTextStyle, tapTargetSize: MaterialTapTargetSize.shrinkWrap, - minimumSize: const Size(55.0, 25.0), + minimumSize: const Size(55, 25), backgroundColor: AppColors.znnColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular( - 8.0, + 8, ), ), ), @@ -105,7 +105,7 @@ final TextButtonThemeData kTextButtonThemeData = TextButtonThemeData( const TextStyle kHintTextStyle = TextStyle( fontWeight: FontWeight.w400, - fontSize: 14.0, + fontSize: 14, ); const TextStyle kTextFormFieldErrorStyle = TextStyle( @@ -113,10 +113,12 @@ const TextStyle kTextFormFieldErrorStyle = TextStyle( ); const OutlineInputBorder kOutlineInputBorder = OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(5.0)), + borderRadius: BorderRadius.all(Radius.circular(5)), ); class AppTheme { + + AppTheme._(); static final ThemeData lightTheme = ThemeData( useMaterial3: true, hoverColor: AppColors.lightTextFormFieldFill, @@ -160,13 +162,13 @@ class AppTheme { errorBorder: kOutlineInputBorder.copyWith( borderSide: const BorderSide( color: AppColors.errorColor, - width: 2.0, + width: 2, ), ), focusedErrorBorder: kOutlineInputBorder.copyWith( borderSide: const BorderSide( color: AppColors.errorColor, - width: 2.0, + width: 2, ), ), ), @@ -300,13 +302,13 @@ class AppTheme { errorBorder: kOutlineInputBorder.copyWith( borderSide: const BorderSide( color: AppColors.errorColor, - width: 2.0, + width: 2, ), ), focusedErrorBorder: kOutlineInputBorder.copyWith( borderSide: const BorderSide( color: AppColors.errorColor, - width: 2.0, + width: 2, ), ), ), @@ -393,6 +395,4 @@ class AppTheme { error: AppColors.errorColor, ).copyWith(surface: AppColors.backgroundDark), ); - - AppTheme._(); } diff --git a/lib/utils/card/card_data.dart b/lib/utils/card/card_data.dart index 3239ca3e..da278356 100644 --- a/lib/utils/card/card_data.dart +++ b/lib/utils/card/card_data.dart @@ -1,6 +1,6 @@ class CardData { - final String title; - final String description; CardData({required this.title, required this.description}); + final String title; + final String description; } \ No newline at end of file diff --git a/lib/utils/clipboard_utils.dart b/lib/utils/clipboard_utils.dart index f48f4a37..c7a74a51 100644 --- a/lib/utils/clipboard_utils.dart +++ b/lib/utils/clipboard_utils.dart @@ -24,11 +24,11 @@ class ClipboardUtils { text: stringValue, ), ).then((_) => - ToastUtils.showToast(context, 'Copied', color: AppColors.znnColor)); + ToastUtils.showToast(context, 'Copied', color: AppColors.znnColor),); } static void pasteToClipboard( - BuildContext context, Function(String) callback) { + BuildContext context, Function(String) callback,) { Clipboard.getData('text/plain').then((value) async { if (value != null) { callback(value.text!); diff --git a/lib/utils/color_utils.dart b/lib/utils/color_utils.dart index 08c9a27d..1a1941cf 100644 --- a/lib/utils/color_utils.dart +++ b/lib/utils/color_utils.dart @@ -15,7 +15,7 @@ class ColorUtils { } static String _getHexCodeFromTokenZts(TokenStandard tokenStandard) { - List bytes = + final bytes = tokenStandard.getBytes().sublist(tokenStandard.getBytes().length - 3); return BytesUtils.bytesToHex(bytes); } diff --git a/lib/utils/constants.dart b/lib/utils/constants.dart index 9c43950a..2be2a27b 100644 --- a/lib/utils/constants.dart +++ b/lib/utils/constants.dart @@ -9,23 +9,23 @@ const String kZenonNameSpace = 'zenon'; const walletConnectDirName = 'walletconnect'; // Dimensions -const double kAmountSuffixHeight = 25.0; -const double kAmountSuffixWidth = 40.0; -const double kAmountSuffixRadius = 5.0; -const double kContentPadding = 8.0; -const double kSeedWordCellWidth = 200.0; -const double kPasswordInputFieldWidth = 360.0; +const double kAmountSuffixHeight = 25; +const double kAmountSuffixWidth = 40; +const double kAmountSuffixRadius = 5; +const double kContentPadding = 8; +const double kSeedWordCellWidth = 200; +const double kPasswordInputFieldWidth = 360; // Size widgets -const Size kLoadingButtonMinSize = Size(120.0, 40.0); -const Size kSettingsButtonMinSize = Size(100.0, 35.0); +const Size kLoadingButtonMinSize = Size(120, 40); +const Size kSettingsButtonMinSize = Size(100, 35); const SizedBox kVerticalSpacing = SizedBox( - height: 15.0, + height: 15, ); const SizedBox kSpacingBetweenActionButtons = SizedBox( - width: 70.0, + width: 70, ); -const Size kAcceleratorProgressBarSize = Size(300.0, 10.0); +const Size kAcceleratorProgressBarSize = Size(300, 10); // Wallet version const String kWalletVersion = '0.2.1'; @@ -50,7 +50,7 @@ const List kCacheBoxesToBeDeleted = [ kRecipientAddressBox, kSharedPrefsBox, kNodesBox, - kLastCheckedHtlcBlockBox + kLastCheckedHtlcBlockBox, ]; // Wallet file name @@ -82,7 +82,7 @@ const String kP2pAtomicUnlockKey = 'p2p_atomic_unlock_key'; const String kP2pAutoReclaimKey = 'p2p_auto_reclaim_key'; const String kLastCheckedHtlcBlockKey = 'last_checked_htlc_block_key'; -const double kDefaultBorderOutlineWidth = 1.0; +const double kDefaultBorderOutlineWidth = 1; const double kStandardChartNumDays = 7; const int kAddressLabelMaxLength = 80; diff --git a/lib/utils/device_utils.dart b/lib/utils/device_utils.dart index d68bfac5..6ef786ca 100644 --- a/lib/utils/device_utils.dart +++ b/lib/utils/device_utils.dart @@ -6,7 +6,7 @@ import 'package:package_info_plus/package_info_plus.dart'; class DeviceUtils { static Future> getDeviceInfo() async { - DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin(); + final deviceInfoPlugin = DeviceInfoPlugin(); if (Platform.isLinux) { return _readLinuxDeviceInfo(await deviceInfoPlugin.linuxInfo); } @@ -58,7 +58,7 @@ class DeviceUtils { } static Future> getPackageInfo() async { - PackageInfo packageInfo = await PackageInfo.fromPlatform(); + final packageInfo = await PackageInfo.fromPlatform(); return { 'appName': packageInfo.appName, 'packageName': packageInfo.packageName, diff --git a/lib/utils/extensions.dart b/lib/utils/extensions.dart index 9d63bf7c..c9ab2217 100644 --- a/lib/utils/extensions.dart +++ b/lib/utils/extensions.dart @@ -16,12 +16,12 @@ extension StringExtensions on String { } return BigInt.parse(this + ''.padRight(decimals, '0')); } - List parts = split('.'); + final parts = split('.'); return BigInt.parse(parts[0] + (parts[1].length > decimals ? parts[1].substring(0, decimals) - : parts[1].padRight(decimals, '0'))); + : parts[1].padRight(decimals, '0')),); } String abs() => this; @@ -49,7 +49,7 @@ extension ZipTwoLists on List { return fold( [], (previousValue, element) { - int elementIndex = indexOf(element); + final elementIndex = indexOf(element); previousValue.add(element); if (elementIndex < smallerList.length) { previousValue.add( @@ -74,7 +74,7 @@ extension LedgerErrorExtensions on LedgerError { String toFriendlyString() { return when( connectionError: (origMessage) => origMessage, - responseError: (statusWord) => _mapStatusWord(statusWord)); + responseError: _mapStatusWord,); } String _mapStatusWord(StatusWord statusWord) { diff --git a/lib/utils/format_utils.dart b/lib/utils/format_utils.dart index b1c0b9b9..638f803c 100644 --- a/lib/utils/format_utils.dart +++ b/lib/utils/format_utils.dart @@ -10,7 +10,7 @@ class FormatUtils { ) => [ FilteringTextInputFormatter.allow(RegExp(r'^\d*\.?\d*?$'), - replacementString: replacementString), + replacementString: replacementString,), FilteringTextInputFormatter.deny( RegExp(r'^0\d+'), replacementString: replacementString, @@ -32,16 +32,16 @@ class FormatUtils { static List decodeHexString(String input) => HEX.decode(input); static String formatDate(int timestampMillis, - {String dateFormat = kDefaultDateFormat}) { - DateTime date = DateTime.fromMillisecondsSinceEpoch(timestampMillis); + {String dateFormat = kDefaultDateFormat,}) { + final date = DateTime.fromMillisecondsSinceEpoch(timestampMillis); return DateFormat(dateFormat).format(date); } static String extractNameFromEnum(T enumValue) { - String valueName = enumValue.toString().split('.')[1]; - if (RegExp(r'^[a-z]+[A-Z]+').hasMatch(valueName)) { - List parts = valueName - .split(RegExp(r'(?<=[a-z])(?=[A-Z])')) + final valueName = enumValue.toString().split('.')[1]; + if (RegExp('^[a-z]+[A-Z]+').hasMatch(valueName)) { + final parts = valueName + .split(RegExp('(?<=[a-z])(?=[A-Z])')) .map((e) => e.toLowerCase()) .toList(); parts.first = parts.first.capitalize(); @@ -61,7 +61,7 @@ class FormatUtils { } static String formatData(int transactionMillis) { - int currentMillis = DateTime.now().millisecondsSinceEpoch; + final currentMillis = DateTime.now().millisecondsSinceEpoch; if (currentMillis - transactionMillis <= const Duration(days: 1).inMilliseconds) { return formatDataShort(currentMillis - transactionMillis); @@ -70,7 +70,7 @@ class FormatUtils { } static String formatDataShort(int i) { - Duration duration = Duration(milliseconds: i); + final duration = Duration(milliseconds: i); if (duration.inHours > 0) { return '${duration.inHours} h ago'; } diff --git a/lib/utils/functions.dart b/lib/utils/functions.dart index 7cb1d350..e3d8cb52 100644 --- a/lib/utils/functions.dart +++ b/lib/utils/functions.dart @@ -5,10 +5,10 @@ import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class Signature { - String signature; - String publicKey; Signature(this.signature, this.publicKey); + String signature; + String publicKey; } Future walletSign(List message) async { @@ -16,20 +16,20 @@ Future walletSign(List message) async { try { final walletAccount = await wallet .getAccount(kDefaultAddressList.indexOf(kSelectedAddress)); - List publicKey = await walletAccount.getPublicKey(); - List signature = await walletAccount.sign( + final publicKey = await walletAccount.getPublicKey(); + final signature = await walletAccount.sign( Uint8List.fromList( message, ), ); return Signature( - BytesUtils.bytesToHex(signature), BytesUtils.bytesToHex(publicKey)); + BytesUtils.bytesToHex(signature), BytesUtils.bytesToHex(publicKey),); } finally { kWalletFile!.close(); } } Future loadJsonFromAssets(String filePath) async { - String jsonString = await rootBundle.loadString(filePath); + final jsonString = await rootBundle.loadString(filePath); return jsonDecode(jsonString); } \ No newline at end of file diff --git a/lib/utils/global.dart b/lib/utils/global.dart index 88930941..467d5999 100644 --- a/lib/utils/global.dart +++ b/lib/utils/global.dart @@ -1,7 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:zenon_syrius_wallet_flutter/model/model.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/wallet_file.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/wallet_file.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; ValueNotifier kLastWalletConnectUriNotifier = ValueNotifier(null); diff --git a/lib/utils/init_utils.dart b/lib/utils/init_utils.dart index 3d2ad2ec..6287b1e2 100644 --- a/lib/utils/init_utils.dart +++ b/lib/utils/init_utils.dart @@ -9,8 +9,8 @@ import 'package:zenon_syrius_wallet_flutter/services/shared_prefs_service.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/wallet_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/node_utils.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/wallet_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/widget_utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -70,7 +70,7 @@ class InitUtils { static Future initWalletAfterDecryption(List cipherKey) async { final walletVersion = Version.parse(sharedPrefsService! - .get(kWalletVersionKey, defaultValue: kWalletVersion)); + .get(kWalletVersionKey, defaultValue: kWalletVersion),); await ZenonAddressUtils.setAddresses(kWalletFile); await ZenonAddressUtils.setAddressLabels(); await ZenonAddressUtils.setDefaultAddress(); @@ -81,7 +81,7 @@ class InitUtils { await kWalletFile!.access((Wallet wallet) async { await htlcSwapsService!.openBoxes(WalletUtils.baseAddress.toString(), (wallet as KeyStore).getKeyPair().getPrivateKey()!, - newCipherKey: cipherKey); + newCipherKey: cipherKey,); }); } else { await htlcSwapsService! @@ -92,13 +92,13 @@ class InitUtils { } static Future _openFavoriteTokensBox() async => - await Hive.openBox(kFavoriteTokensBox); + Hive.openBox(kFavoriteTokensBox); static Future _openNotificationsBox() async => - await Hive.openBox(kNotificationsBox); + Hive.openBox(kNotificationsBox); static Future _openRecipientBox() async => - await Hive.openBox(kRecipientAddressBox); + Hive.openBox(kRecipientAddressBox); static Future _setWalletVersion() async => sharedPrefsService!.put( kWalletVersionKey, diff --git a/lib/utils/input_validators.dart b/lib/utils/input_validators.dart index 2e847934..96a34a55 100644 --- a/lib/utils/input_validators.dart +++ b/lib/utils/input_validators.dart @@ -1,8 +1,8 @@ +import 'package:convert/convert.dart'; import 'package:logging/logging.dart'; import 'package:validators/validators.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; -import 'package:convert/convert.dart'; class InputValidators { static String kEVMAddressRegex = r'^(0x)([a-fA-F0-9]){40}$'; @@ -90,7 +90,7 @@ class InputValidators { } } - BigInt inputNum = value.extractDecimals(decimals); + final inputNum = value.extractDecimals(decimals); if (value.contains('.') && value.split('.')[1].length > decimals) { return 'Inputted number has too many decimals'; @@ -116,7 +116,7 @@ class InputValidators { return 'Error'; } } - return 'Value can\'t be empty'; + return "Value can't be empty"; } static String? checkAddress(String? value) { @@ -142,9 +142,9 @@ class InputValidators { if (value.length < 8) { return 'Password not strong enough'; } - String pattern = + const pattern = r'''^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[`~!@#$%^&*()\-_=+\[\]\{\}\\|;:",<.>\/\?']).{8,}$'''; - RegExp regExp = RegExp(pattern); + final regExp = RegExp(pattern); if (regExp.hasMatch(value)) { return null; } diff --git a/lib/utils/navigation_utils.dart b/lib/utils/navigation_utils.dart index da5d1bbc..02bb8952 100644 --- a/lib/utils/navigation_utils.dart +++ b/lib/utils/navigation_utils.dart @@ -7,10 +7,10 @@ import 'package:zenon_syrius_wallet_flutter/model/model.dart'; class NavigationUtils { static Future openUrl(String url) async { - if (!RegExp(r'^http').hasMatch(url)) { + if (!RegExp('^http').hasMatch(url)) { url = 'http://$url'; } - var uri = Uri.parse(url); + final uri = Uri.parse(url); if (await canLaunchUrl(uri)) { await launchUrl(uri); } else { @@ -46,7 +46,7 @@ class NavigationUtils { } static void popRepeated(context, int times) { - int count = 0; + var count = 0; Navigator.popUntil(context, (route) => count++ == times); } } diff --git a/lib/utils/network_utils.dart b/lib/utils/network_utils.dart index d1413e3c..7ab07a7a 100644 --- a/lib/utils/network_utils.dart +++ b/lib/utils/network_utils.dart @@ -2,25 +2,24 @@ import 'dart:io'; class NetworkUtils { static Future getLocalIpAddress( - InternetAddressType internetAddressType) async { + InternetAddressType internetAddressType,) async { final interfaces = await NetworkInterface.list( type: internetAddressType, - includeLoopback: false, - includeLinkLocal: true); + includeLinkLocal: true,); try { - NetworkInterface vpnInterface = + final vpnInterface = interfaces.firstWhere((element) => element.name == 'tun0'); return vpnInterface.addresses.first.address; } on StateError { try { - NetworkInterface interface = + final interface = interfaces.firstWhere((element) => element.name == 'wlan0'); return interface.addresses.first.address; } catch (e) { try { - NetworkInterface interface = interfaces.firstWhere((element) => - !(element.name == 'tun0' || element.name == 'wlan0')); + final interface = interfaces.firstWhere((element) => + !(element.name == 'tun0' || element.name == 'wlan0'),); return interface.addresses.first.address; } catch (e) { return e.toString(); diff --git a/lib/utils/node_utils.dart b/lib/utils/node_utils.dart index d7f9f53c..e6f54e6c 100644 --- a/lib/utils/node_utils.dart +++ b/lib/utils/node_utils.dart @@ -18,7 +18,7 @@ int _kHeight = 0; class NodeUtils { static Future establishConnectionToNode(String url) async { - bool connectionStatus = await zenon!.wsClient.initialize( + final connectionStatus = await zenon!.wsClient.initialize( url, retry: false, ); @@ -26,7 +26,7 @@ class NodeUtils { } static Future getNodeChainIdentifier() async { - int nodeChainId = 1; + var nodeChainId = 1; try { await zenon!.ledger.getFrontierMomentum().then((value) { nodeChainId = value.chainIdentifier; @@ -58,7 +58,7 @@ class NodeUtils { ); // If the message is null, it means that the isolate has closed - Completer embeddedStoppedCompleter = Completer(); + final embeddedStoppedCompleter = Completer(); sl(instanceName: 'embeddedStoppedStream').listen( (message) { kEmbeddedNodeRunning = false; @@ -84,10 +84,10 @@ class NodeUtils { static initWebSocketClient() async { addOnWebSocketConnectedCallback(); - var url = kCurrentNode == kEmbeddedNode + final url = kCurrentNode == kEmbeddedNode ? kLocalhostDefaultNodeUrl : kCurrentNode ?? ''; - bool connected = false; + var connected = false; try { connected = await establishConnectionToNode(url); } catch (_) {} @@ -108,7 +108,7 @@ class NodeUtils { sl().autoReceive(); Future.delayed(const Duration(seconds: 30)) - .then((value) async => await NotificationUtils.sendNodeSyncingNotification()); + .then((value) async => NotificationUtils.sendNodeSyncingNotification()); _initListenForUnreceivedAccountBlocks(allResponseBroadcaster); }); } @@ -116,7 +116,7 @@ class NodeUtils { static Future getUnreceivedTransactions() async { await Future.forEach( kDefaultAddressList, - (address) async => await getUnreceivedTransactionsByAddress( + (address) async => getUnreceivedTransactionsByAddress( Address.parse(address!), ), ); @@ -125,14 +125,14 @@ class NodeUtils { static Future getUnreceivedTransactionsByAddress( Address address, ) async { - List unreceivedBlocks = + final unreceivedBlocks = (await zenon!.ledger.getUnreceivedBlocksByAddress( address, )) .list!; if (unreceivedBlocks.isNotEmpty) { - for (AccountBlock unreceivedBlock in unreceivedBlocks) { + for (final unreceivedBlock in unreceivedBlocks) { if (sharedPrefsService!.get( kAutoReceiveKey, defaultValue: kAutoReceiveDefaultValue, @@ -144,14 +144,14 @@ class NodeUtils { } static Future checkForLocalTimeDiscrepancy( - String warningMessage) async { + String warningMessage,) async { const maxAllowedDiscrepancy = Duration(minutes: 5); try { final syncInfo = await zenon!.stats.syncInfo(); - bool nodeIsSynced = (syncInfo.state == SyncState.syncDone || + final nodeIsSynced = syncInfo.state == SyncState.syncDone || (syncInfo.targetHeight > 0 && syncInfo.currentHeight > 0 && - (syncInfo.targetHeight - syncInfo.currentHeight) < 20)); + (syncInfo.targetHeight - syncInfo.currentHeight) < 20); if (nodeIsSynced) { final frontierTime = (await zenon!.ledger.getFrontierMomentum()).timestamp; @@ -178,15 +178,15 @@ class NodeUtils { sharedPrefsService! .get(kAutoReceiveKey, defaultValue: kAutoReceiveDefaultValue)) { for (var i = 0; i < event['params']['result'].length; i += 1) { - var tx = event['params']['result'][i]; + final tx = event['params']['result'][i]; if (tx.containsKey('toAddress') && kDefaultAddressList.contains(tx['toAddress'])) { - var hash = Hash.parse(tx['hash']); + final hash = Hash.parse(tx['hash']); sl().addHash(hash); } } - Map result = (event['params']['result'] as List).first; + final Map result = (event['params']['result'] as List).first; if (!result.containsKey('blockType') && result['height'] != null && (_kHeight == 0 || result['height'] >= _kHeight + 1)) { @@ -202,23 +202,23 @@ class NodeUtils { } static Future _getSubscriptionForMomentums() async => - await zenon!.subscribe.toMomentums(); + zenon!.subscribe.toMomentums(); static Future _getSubscriptionForAllAccountEvents() async => - await zenon!.subscribe.toAllAccountBlocks(); + zenon!.subscribe.toAllAccountBlocks(); static Future loadDbNodes() async { if (!Hive.isBoxOpen(kNodesBox)) { await Hive.openBox(kNodesBox); } - Box nodesBox = Hive.box(kNodesBox); + final nodesBox = Hive.box(kNodesBox); if (kDbNodes.isNotEmpty) { kDbNodes.clear(); } kDbNodes.addAll(nodesBox.values); // Handle the case in which some default nodes were deleted // so they can't be found in the cache - String? currentNode = kCurrentNode; + final currentNode = kCurrentNode; if (currentNode != null && !kDefaultNodes.contains(currentNode) && !kDbNodes.contains(currentNode)) { @@ -227,12 +227,12 @@ class NodeUtils { } static Future setNode() async { - String? savedNode = sharedPrefsService!.get(kSelectedNodeKey); + final String? savedNode = sharedPrefsService!.get(kSelectedNodeKey); kCurrentNode = savedNode; if (savedNode == kEmbeddedNode) { // First we need to check if the node is not already running - bool isConnectionEstablished = + final isConnectionEstablished = await NodeUtils.establishConnectionToNode(kLocalhostDefaultNodeUrl); if (isConnectionEstablished == false) { // Acquire WakeLock @@ -242,7 +242,7 @@ class NodeUtils { // Initialize local full node await Isolate.spawn(EmbeddedNode.runNode, [''], onExit: - sl(instanceName: 'embeddedStoppedPort').sendPort); + sl(instanceName: 'embeddedStoppedPort').sendPort,); kEmbeddedNodeRunning = true; } diff --git a/lib/utils/notifiers/notifiers.dart b/lib/utils/notifiers/notifiers.dart index b1da6ef6..425ad121 100644 --- a/lib/utils/notifiers/notifiers.dart +++ b/lib/utils/notifiers/notifiers.dart @@ -1,4 +1,3 @@ -library; export 'app_theme_notifier.dart'; export 'default_address_notifier.dart'; diff --git a/lib/utils/notifiers/text_scaling_notifier.dart b/lib/utils/notifiers/text_scaling_notifier.dart index ddfa321e..626c6b89 100644 --- a/lib/utils/notifiers/text_scaling_notifier.dart +++ b/lib/utils/notifiers/text_scaling_notifier.dart @@ -12,22 +12,22 @@ class TextScalingNotifier extends ChangeNotifier { } } - getTextScaleFactor(BuildContext context) { + double getTextScaleFactor(BuildContext context) { switch (_currentTextScaling) { case TextScaling.system: return MediaQuery.of(context).textScaler.scale(1); case TextScaling.normal: - return 1.0; + return 1; case TextScaling.small: return 0.8; case TextScaling.large: return 1.5; case TextScaling.huge: - return 2.0; + return 2; case null: - return 1.0; + return 1; } } - get currentTextScaling => _currentTextScaling; + TextScaling? get currentTextScaling => _currentTextScaling; } diff --git a/lib/utils/pair.dart b/lib/utils/pair.dart index 4795d61a..82dfd7e6 100644 --- a/lib/utils/pair.dart +++ b/lib/utils/pair.dart @@ -1,6 +1,6 @@ class Pair { - final T1 first; - final T2 second; Pair(this.first, this.second); + final T1 first; + final T2 second; } diff --git a/lib/utils/toast_utils.dart b/lib/utils/toast_utils.dart index e51e34bb..b861d6b2 100644 --- a/lib/utils/toast_utils.dart +++ b/lib/utils/toast_utils.dart @@ -9,9 +9,7 @@ class ToastUtils { if (_timer == null || !_timer!.isActive) { final overlay = _getOverlayEntry(message, color); Overlay.of(context).insert(overlay); - _timer = Timer(const Duration(seconds: 3), () { - overlay.remove(); - }); + _timer = Timer(const Duration(seconds: 3), overlay.remove); } } @@ -19,26 +17,26 @@ class ToastUtils { return OverlayEntry( builder: (_) => TweenAnimationBuilder( duration: const Duration(milliseconds: 200), - tween: Tween(begin: 0.0, end: 1.0), + tween: Tween(begin: 0, end: 1), builder: (_, double opacity, __) { return Opacity( opacity: opacity, child: Padding( - padding: const EdgeInsets.only(bottom: 50.0), + padding: const EdgeInsets.only(bottom: 50), child: Container( alignment: Alignment.bottomCenter, child: Material( - elevation: 6.0, + elevation: 6, color: color, surfaceTintColor: Colors.black, - borderRadius: BorderRadius.circular(50.0), + borderRadius: BorderRadius.circular(50), child: Padding( - padding: const EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), + padding: const EdgeInsets.fromLTRB(20, 15, 20, 15), child: Text( message, textAlign: TextAlign.center, style: - const TextStyle(fontSize: 14.0, color: Colors.white), + const TextStyle(fontSize: 14, color: Colors.white), ), ), ), diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index dd17d967..8cff3ac2 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -14,14 +14,14 @@ export 'format_utils.dart'; export 'global.dart'; export 'init_utils.dart'; export 'input_validators.dart'; -export 'wallet_utils.dart'; export 'navigation_utils.dart'; export 'network_utils.dart'; export 'node_utils.dart'; export 'notification_utils.dart'; +export 'notifiers/notifiers.dart'; export 'pair.dart'; export 'toast_utils.dart'; export 'utils.dart'; +export 'wallet_utils.dart'; export 'widget_utils.dart'; export 'zts_utils.dart'; -export 'notifiers/notifiers.dart'; diff --git a/lib/utils/wallet_file.dart b/lib/utils/wallet_file.dart index 9b8358b2..f3d5e5d7 100644 --- a/lib/utils/wallet_file.dart +++ b/lib/utils/wallet_file.dart @@ -3,11 +3,13 @@ import 'dart:io'; import 'package:hex/hex.dart'; import 'package:mutex/mutex.dart'; +import 'package:path/path.dart' as path; import 'package:znn_ledger_dart/znn_ledger_dart.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; -import 'package:path/path.dart' as path; abstract class WalletFile { + + WalletFile(this._path); final String _path; static Future decrypt(String walletPath, String password) async { @@ -15,12 +17,12 @@ abstract class WalletFile { final walletType = encrypted.metadata != null ? encrypted.metadata![walletTypeKey] : null; if (walletType == null || walletType == keyStoreWalletType) { - return await KeyStoreWalletFile.decrypt(walletPath, password); + return KeyStoreWalletFile.decrypt(walletPath, password); } else if (walletType == ledgerWalletType) { - return await LedgerWalletFile.decrypt(walletPath, password); + return LedgerWalletFile.decrypt(walletPath, password); } else { throw WalletException( - 'Wallet type (${encrypted.metadata![walletTypeKey]}) is not supported'); + 'Wallet type (${encrypted.metadata![walletTypeKey]}) is not supported',); } } @@ -33,15 +35,13 @@ abstract class WalletFile { } static Future write(String walletPath, String password, List data, - {Map? metadata}) async { + {Map? metadata,}) async { final file = File(walletPath); final encrypted = await EncryptedFile.encrypt(data, password, metadata: metadata); file.writeAsString(json.encode(encrypted), mode: FileMode.writeOnly); } - WalletFile(this._path); - String get walletPath => _path; String get walletType; @@ -64,15 +64,17 @@ abstract class WalletFile { } Future changePassword( - String currentPassword, String newPassword) async { + String currentPassword, String newPassword,) async { final file = await WalletFile.read(walletPath); final decrypted = await file.decrypt(currentPassword); await WalletFile.write(walletPath, newPassword, decrypted, - metadata: file.metadata); + metadata: file.metadata,); } } class KeyStoreWalletFile extends WalletFile { + + KeyStoreWalletFile._internal(super._path, this._walletSeed); final Mutex _lock = Mutex(); final String _walletSeed; KeyStore? _keyStore; @@ -81,29 +83,27 @@ class KeyStoreWalletFile extends WalletFile { KeyStoreManager(walletPath: znnDefaultWalletDirectory); static Future create(String mnemonic, String password, - {String? name}) async { - KeyStore wallet = KeyStore.fromMnemonic(mnemonic); - KeyStoreDefinition walletDefinition = + {String? name,}) async { + final wallet = KeyStore.fromMnemonic(mnemonic); + final walletDefinition = await keyStoreWalletManager.saveKeyStore(wallet, password, name: name); return KeyStoreWalletFile._internal( - walletDefinition.walletId, wallet.entropy); + walletDefinition.walletId, wallet.entropy,); } static Future decrypt( - String walletPath, String password) async { + String walletPath, String password,) async { final encrypted = await WalletFile.read(walletPath); if (encrypted.metadata != null && encrypted.metadata![walletTypeKey] != null && encrypted.metadata![walletTypeKey] != keyStoreWalletType) { throw WalletException( - 'Wallet type (${encrypted.metadata![walletTypeKey]}) is not supported'); + 'Wallet type (${encrypted.metadata![walletTypeKey]}) is not supported',); } final decrypted = await encrypted.decrypt(password); return KeyStoreWalletFile._internal(walletPath, HEX.encode(decrypted)); } - KeyStoreWalletFile._internal(super._path, this._walletSeed); - @override String get walletType => keyStoreWalletType; @@ -126,12 +126,14 @@ class KeyStoreWalletFile extends WalletFile { } @override - void close() async { + Future close() async { if (_lock.isLocked) _lock.release(); } } class LedgerWalletFile extends WalletFile { + + LedgerWalletFile._internal(super._path, this._walletName); final Mutex _lock = Mutex(); final String _walletName; LedgerWallet? _wallet; @@ -139,7 +141,7 @@ class LedgerWalletFile extends WalletFile { static final LedgerWalletManager ledgerWalletManager = LedgerWalletManager(); static Future _connect(String walletIdOrName) async { - for (var walletDefinition + for (final walletDefinition in await ledgerWalletManager.getWalletDefinitions()) { if (walletDefinition.walletId == walletIdOrName || walletDefinition.walletName == walletIdOrName) { @@ -149,21 +151,21 @@ class LedgerWalletFile extends WalletFile { } throw const LedgerError.connectionError( origMessage: - 'Cannot find the hardware device, please connect/unlock the device on which the wallet is initialized'); + 'Cannot find the hardware device, please connect/unlock the device on which the wallet is initialized',); } static Future create(String walletId, String password, - {String? walletName}) async { - LedgerWallet wallet = await _connect(walletId); + {String? walletName,}) async { + final wallet = await _connect(walletId); try { - final baseAddress = (await (await wallet.getAccount()).getAddress()); + final baseAddress = await (await wallet.getAccount()).getAddress(); walletName ??= baseAddress.toString(); final walletPath = path.join(znnDefaultWalletDirectory.path, walletName); await WalletFile.write(walletPath, password, utf8.encode(walletName), metadata: { baseAddressKey: baseAddress.toString(), - walletTypeKey: ledgerWalletType - }); + walletTypeKey: ledgerWalletType, + },); return LedgerWalletFile._internal(walletPath, walletName); } finally { await wallet.disconnect(); @@ -171,19 +173,17 @@ class LedgerWalletFile extends WalletFile { } static Future decrypt( - String walletPath, String password) async { + String walletPath, String password,) async { final encrypted = await WalletFile.read(walletPath); if (encrypted.metadata == null || encrypted.metadata![walletTypeKey] != ledgerWalletType) { throw WalletException( - 'Wallet type (${encrypted.metadata![walletTypeKey]}) is not supported'); + 'Wallet type (${encrypted.metadata![walletTypeKey]}) is not supported',); } final decrypted = await encrypted.decrypt(password); return LedgerWalletFile._internal(walletPath, utf8.decode(decrypted)); } - LedgerWalletFile._internal(super._path, this._walletName); - @override String get walletType => ledgerWalletType; @@ -206,7 +206,7 @@ class LedgerWalletFile extends WalletFile { } @override - void close() async { + Future close() async { if (_wallet != null) { try { await _wallet!.disconnect(); diff --git a/lib/utils/wallet_utils.dart b/lib/utils/wallet_utils.dart index d6f7f0c1..dcdb7507 100644 --- a/lib/utils/wallet_utils.dart +++ b/lib/utils/wallet_utils.dart @@ -1,18 +1,18 @@ import 'package:hive/hive.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/wallet_file.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/wallet_file.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class WalletUtils { - static get baseAddress { + static Address get baseAddress { return Address.parse(kDefaultAddressList.first!); } static Future decryptWalletFile( - String walletPath, String password) async { - return await WalletFile.decrypt(walletPath, password); + String walletPath, String password,) async { + return WalletFile.decrypt(walletPath, password); } static Future createLedgerWalletFile( @@ -21,7 +21,7 @@ class WalletUtils { String? walletName, }) async { kWalletFile = await LedgerWalletFile.create(walletId, password, - walletName: walletName); + walletName: walletName,); kWalletPath = kWalletFile!.walletPath; await _storeWalletPath(kWalletFile!.walletPath); } @@ -38,17 +38,17 @@ class WalletUtils { } static Future _storeWalletPath(String? walletPath) async { - Box keyStoreBox = await Hive.openBox(kKeyStoreBox); + final keyStoreBox = await Hive.openBox(kKeyStoreBox); await keyStoreBox.put(0, walletPath); } static Future setWalletPath() async { if (kWalletPath == null) { - Box keyStoreBox = await Hive.openBox(kKeyStoreBox); + final keyStoreBox = await Hive.openBox(kKeyStoreBox); if (keyStoreBox.isEmpty) { // Here we check if the key store path is saved in another place // and we copy that value, if it exists - String? keyStorePath = sharedPrefsService!.get(kEntropyFilePathKey); + final String? keyStorePath = sharedPrefsService!.get(kEntropyFilePathKey); if (keyStorePath != null) { keyStoreBox.add(keyStorePath); kWalletPath = keyStoreBox.values.first; diff --git a/lib/utils/widget_utils.dart b/lib/utils/widget_utils.dart index 6fb3c377..adc7c6a7 100644 --- a/lib/utils/widget_utils.dart +++ b/lib/utils/widget_utils.dart @@ -11,11 +11,11 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class WidgetUtils { static void setThemeMode(BuildContext context) { - AppThemeNotifier appThemeNotifier = Provider.of( + final appThemeNotifier = Provider.of( context, listen: false, ); - ThemeMode savedThemeMode = ThemeMode.values.firstWhere( + final savedThemeMode = ThemeMode.values.firstWhere( (element) => element.toString() == sharedPrefsService!.get(kThemeModeKey), orElse: () => kDefaultThemeMode, ); @@ -25,12 +25,12 @@ class WidgetUtils { } static void setTextScale(BuildContext context) { - TextScalingNotifier textScalingNotifier = Provider.of( + final textScalingNotifier = Provider.of( context, listen: false, ); - TextScaling savedTextScaling = TextScaling.values.firstWhere( + final savedTextScaling = TextScaling.values.firstWhere( (element) => element.toString() == sharedPrefsService!.get(kTextScalingKey), orElse: () => kDefaultTextScaling, @@ -47,7 +47,7 @@ class WidgetUtils { Address? address, BuildContext context, ) { - TextStyle? textStyle = address != null && address.isEmbedded() + final textStyle = address != null && address.isEmbedded() ? Theme.of(context).textTheme.titleMedium!.copyWith( color: AppColors.znnColor, fontWeight: FontWeight.bold, @@ -90,7 +90,7 @@ class WidgetUtils { bool isShortVersion = true, bool showCopyToClipboardIcon = false, }) { - TextStyle? textStyle = address != null && address.isEmbedded() + var textStyle = address != null && address.isEmbedded() ? Theme.of(context).textTheme.titleMedium!.copyWith( color: AppColors.znnColor, fontWeight: FontWeight.bold, diff --git a/lib/utils/zts_utils.dart b/lib/utils/zts_utils.dart index 2e027256..aad5ed54 100644 --- a/lib/utils/zts_utils.dart +++ b/lib/utils/zts_utils.dart @@ -45,6 +45,6 @@ bool isTrustedToken(String tokenStandard) { return [ znnTokenStandard, qsrTokenStandard, - ...Hive.box(kFavoriteTokensBox).values + ...Hive.box(kFavoriteTokensBox).values, ].contains(tokenStandard); } diff --git a/lib/widgets/charts/pillar_rewards_chart.dart b/lib/widgets/charts/pillar_rewards_chart.dart index 1310ed8c..44ce1951 100644 --- a/lib/widgets/charts/pillar_rewards_chart.dart +++ b/lib/widgets/charts/pillar_rewards_chart.dart @@ -8,12 +8,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PillarRewardsChart extends StatefulWidget { - final RewardHistoryList? rewardsHistory; const PillarRewardsChart( this.rewardsHistory, { super.key, }); + final RewardHistoryList? rewardsHistory; @override State createState() => PillarRewardsChartState(); @@ -66,7 +66,7 @@ class PillarRewardsChartState extends State { num _getMaxValueOfZnnRewards() { BigInt? max = widget.rewardsHistory!.list.first.znnAmount; - for (var element in widget.rewardsHistory!.list) { + for (final element in widget.rewardsHistory!.list) { if (element.znnAmount > max!) { max = element.znnAmount; } diff --git a/lib/widgets/charts/realtime_txs_chart.dart b/lib/widgets/charts/realtime_txs_chart.dart index 8c67fc63..18817c50 100644 --- a/lib/widgets/charts/realtime_txs_chart.dart +++ b/lib/widgets/charts/realtime_txs_chart.dart @@ -9,12 +9,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class RealtimeTxsChart extends StatefulWidget { - final List transactions; const RealtimeTxsChart( this.transactions, { super.key, }); + final List transactions; @override State createState() => RealtimeTxsChartState(); @@ -57,19 +57,19 @@ class RealtimeTxsChartState extends State { } double _getTransactionsByDay(TokenStandard tokenId, DateTime date) { - List transactions = []; - for (var transaction in widget.transactions) { + final transactions = []; + for (final transaction in widget.transactions) { AccountBlock? pairedAccountBlock; if (transaction.blockType == 3 && transaction.pairedAccountBlock != null) { - pairedAccountBlock = transaction.pairedAccountBlock!; + pairedAccountBlock = transaction.pairedAccountBlock; } if (DateFormat('d MMM, yyyy').format(date) == DateFormat('d MMM, yyyy').format( DateTime.fromMillisecondsSinceEpoch( (transaction.confirmationDetail?.momentumTimestamp ?? 0) * - 1000), + 1000,), )) { if (transaction.tokenStandard == tokenId || (pairedAccountBlock != null && @@ -79,7 +79,7 @@ class RealtimeTxsChartState extends State { } } - double transactionsPerDay = transactions.length.toDouble(); + final transactionsPerDay = transactions.length.toDouble(); if (transactionsPerDay > _maxTransactionsPerDay) { _maxTransactionsPerDay = transactionsPerDay; diff --git a/lib/widgets/charts/sentinel_rewards_chart.dart b/lib/widgets/charts/sentinel_rewards_chart.dart index d88de553..0fa352c2 100644 --- a/lib/widgets/charts/sentinel_rewards_chart.dart +++ b/lib/widgets/charts/sentinel_rewards_chart.dart @@ -10,12 +10,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class SentinelRewardsChart extends StatefulWidget { - final RewardHistoryList? rewardsHistory; const SentinelRewardsChart( this.rewardsHistory, { super.key, }); + final RewardHistoryList? rewardsHistory; @override State createState() { @@ -90,12 +90,12 @@ class _SentinelRewardsChart extends State { } num _getMaxValueOfRewards() { - num maxZnn = _getMaxValueOfZnnRewards() + final maxZnn = _getMaxValueOfZnnRewards() .addDecimals( coinDecimals, ) .toNum(); - num maxQsr = _getMaxValueOfQsrRewards() + final maxQsr = _getMaxValueOfQsrRewards() .addDecimals( coinDecimals, ) @@ -104,8 +104,8 @@ class _SentinelRewardsChart extends State { } BigInt _getMaxValueOfZnnRewards() { - BigInt max = widget.rewardsHistory!.list.first.znnAmount; - for (var element in widget.rewardsHistory!.list) { + var max = widget.rewardsHistory!.list.first.znnAmount; + for (final element in widget.rewardsHistory!.list) { if (element.znnAmount > max) { max = element.znnAmount; } @@ -114,8 +114,8 @@ class _SentinelRewardsChart extends State { } BigInt _getMaxValueOfQsrRewards() { - BigInt max = widget.rewardsHistory!.list.first.qsrAmount; - for (var element in widget.rewardsHistory!.list) { + var max = widget.rewardsHistory!.list.first.qsrAmount; + for (final element in widget.rewardsHistory!.list) { if (element.qsrAmount > max) { max = element.qsrAmount; } diff --git a/lib/widgets/charts/staking_rewards_chart.dart b/lib/widgets/charts/staking_rewards_chart.dart index bac5816e..c112f093 100644 --- a/lib/widgets/charts/staking_rewards_chart.dart +++ b/lib/widgets/charts/staking_rewards_chart.dart @@ -8,12 +8,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class StakingRewardsChart extends StatefulWidget { - final RewardHistoryList? rewardsHistory; const StakingRewardsChart( this.rewardsHistory, { super.key, }); + final RewardHistoryList? rewardsHistory; @override State createState() => _StakingRewardsChart(); @@ -49,7 +49,7 @@ class _StakingRewardsChart extends State { ), ); - _linesBarData() => [ + List _linesBarData() => [ StandardLineChartBarData( color: AppColors.qsrColor, spots: _getRewardsSpots(), @@ -65,8 +65,8 @@ class _StakingRewardsChart extends State { .toNum(); num _getMaxValueOfQsrRewards() { - BigInt max = widget.rewardsHistory!.list.first.qsrAmount; - for (var element in widget.rewardsHistory!.list) { + var max = widget.rewardsHistory!.list.first.qsrAmount; + for (final element in widget.rewardsHistory!.list) { if (element.qsrAmount > max) { max = element.qsrAmount; } diff --git a/lib/widgets/main_app_container.dart b/lib/widgets/main_app_container.dart index 11d214af..9c5bf5e9 100644 --- a/lib/widgets/main_app_container.dart +++ b/lib/widgets/main_app_container.dart @@ -50,14 +50,14 @@ enum Tabs { } class MainAppContainer extends StatefulWidget { - final bool redirectedFromWalletSuccess; - - static const String route = 'main-app-container'; const MainAppContainer({ super.key, this.redirectedFromWalletSuccess = false, }); + final bool redirectedFromWalletSuccess; + + static const String route = 'main-app-container'; @override State createState() => _MainAppContainerState(); @@ -99,7 +99,7 @@ class _MainAppContainerState extends State duration: const Duration(milliseconds: 500), ); _animationController.repeat(reverse: true); - _animation = Tween(begin: 1.0, end: 3.0).animate(_animationController); + _animation = Tween(begin: 1, end: 3).animate(_animationController); kCurrentPage = kWalletInitCompleted ? Tabs.dashboard : Tabs.lock; _initLockBlock(); _handleIncomingLinks(); @@ -118,7 +118,7 @@ class _MainAppContainerState extends State child: Scaffold( body: Container( margin: const EdgeInsets.all( - 20.0, + 20, ), child: Column( children: [ @@ -142,7 +142,7 @@ class _MainAppContainerState extends State Expanded( child: ClipRRect( borderRadius: BorderRadius.circular( - 15.0, + 15, ), child: Container( child: _getCurrentPageContainer(), @@ -158,7 +158,7 @@ class _MainAppContainerState extends State } Widget _getDesktopNavigationContainer() { - Color borderColor = NotificationUtils.shouldShowNotification() + final borderColor = NotificationUtils.shouldShowNotification() ? kLastNotification!.getColor() : Colors.transparent; @@ -173,7 +173,7 @@ class _MainAppContainerState extends State decoration: BoxDecoration( borderRadius: const BorderRadius.all( Radius.circular( - 15.0, + 15, ), ), boxShadow: (borderColor != Colors.transparent) @@ -182,24 +182,24 @@ class _MainAppContainerState extends State color: borderColor, blurRadius: _animation.value, spreadRadius: _animation.value, - ) + ), ] : [ const BoxShadow( color: Colors.transparent, - ) + ), ], ), child: Material( color: Theme.of(context).colorScheme.primary, borderRadius: const BorderRadius.all( Radius.circular( - 15.0, + 15, ), ), child: Padding( padding: const EdgeInsets.symmetric( - horizontal: 12.0, + horizontal: 12, ), child: Focus( focusNode: _focusNode, @@ -223,7 +223,7 @@ class _MainAppContainerState extends State .textTheme .headlineSmall! .copyWith( - fontSize: 15.0, + fontSize: 15, ), labelColor: Theme.of(context).textTheme.headlineSmall!.color, @@ -233,7 +233,7 @@ class _MainAppContainerState extends State } }, labelPadding: const EdgeInsets.symmetric( - vertical: 5.0, + vertical: 5, ), indicator: UnderlineTabIndicator( borderSide: BorderSide( @@ -242,10 +242,10 @@ class _MainAppContainerState extends State : _isIconTabSelected() ? Colors.transparent : AppColors.znnColor, - width: 2.0, + width: 2, ), ), - dividerHeight: 0.0, + dividerHeight: 0, controller: _tabController, tabs: _getTabs(), ), @@ -261,7 +261,7 @@ class _MainAppContainerState extends State ); } - void _onNavigateToLock() async { + Future _onNavigateToLock() async { if (kWalletFile != null) kWalletFile!.close(); kWalletFile = null; _navigateToLockTimer?.cancel(); @@ -282,7 +282,7 @@ class _MainAppContainerState extends State (e) => e == Tabs.p2pSwap ? const Tab(text: 'P2P Swap') : Tab( - text: FormatUtils.extractNameFromEnum(e).capitalize()), + text: FormatUtils.extractNameFromEnum(e).capitalize(),), ) .toList(); } @@ -293,18 +293,18 @@ class _MainAppContainerState extends State Tab( child: SvgPicture.asset( 'assets/svg/walletconnect-logo.svg', - width: 24.0, + width: 24, fit: BoxFit.fitWidth, colorFilter: _isTabSelected(Tabs.walletConnect) ? const ColorFilter.mode(AppColors.znnColor, BlendMode.srcIn) : ColorFilter.mode( - Theme.of(context).iconTheme.color!, BlendMode.srcIn), + Theme.of(context).iconTheme.color!, BlendMode.srcIn,), ), ), Tab( child: Icon( MaterialCommunityIcons.rocket, - size: 24.0, + size: 24, color: _isTabSelected(Tabs.accelerator) ? AppColors.znnColor : Theme.of(context).iconTheme.color, @@ -313,7 +313,7 @@ class _MainAppContainerState extends State Tab( child: Icon( Icons.info, - size: 24.0, + size: 24, color: _isTabSelected(Tabs.help) ? AppColors.znnColor : Theme.of(context).iconTheme.color, @@ -322,7 +322,7 @@ class _MainAppContainerState extends State Tab( child: Icon( Icons.notifications, - size: 24.0, + size: 24, color: _isTabSelected(Tabs.notifications) ? AppColors.znnColor : Theme.of(context).iconTheme.color, @@ -331,7 +331,7 @@ class _MainAppContainerState extends State Tab( child: Icon( Icons.settings, - size: 24.0, + size: 24, color: _isTabSelected(Tabs.settings) ? AppColors.znnColor : Theme.of(context).iconTheme.color, @@ -347,14 +347,14 @@ class _MainAppContainerState extends State child: _isTabSelected(Tabs.lock) ? Icon( Icons.lock, - size: 24.0, + size: 24, color: _isTabSelected(Tabs.lock) ? AppColors.znnColor : Theme.of(context).iconTheme.color, ) : Icon( MaterialCommunityIcons.lock_open_variant, - size: 24.0, + size: 24, color: Theme.of(context).iconTheme.color, ), ), @@ -386,7 +386,7 @@ class _MainAppContainerState extends State child: Lottie.asset( 'assets/lottie/ic_anim_plasma_generation.json', fit: BoxFit.contain, - width: 30.0, + width: 30, repeat: true, ), ); @@ -403,7 +403,7 @@ class _MainAppContainerState extends State } Widget _getSyncingStatusIcon(SyncState syncState, [SyncInfo? syncInfo]) { - String message = 'Connected and synced'; + var message = 'Connected and synced'; if (syncState != SyncState.notEnoughPeers && syncState != SyncState.syncDone && @@ -418,9 +418,9 @@ class _MainAppContainerState extends State message: message, child: Icon( Icons.sync_disabled, - size: 24.0, + size: 24, color: _getSyncIconColor(syncState), - )); + ),); } else if (syncState == SyncState.syncing) { if (syncInfo != null) { if (syncInfo.targetHeight > 0 && @@ -432,31 +432,31 @@ class _MainAppContainerState extends State message: message, child: Icon( Icons.radio_button_unchecked, - size: 24.0, + size: 24, color: _getSyncIconColor(syncState), - )); + ),); } else if (syncInfo.targetHeight == 0 || syncInfo.currentHeight == 0) { message = 'Started syncing with the network, please wait'; syncState = SyncState.syncing; return Tooltip( message: message, child: Icon(Icons.sync, - size: 24.0, color: _getSyncIconColor(syncState))); + size: 24, color: _getSyncIconColor(syncState),),); } else { message = 'Sync progress: momentum ${syncInfo.currentHeight} of ${syncInfo.targetHeight}'; return Tooltip( message: message, child: SizedBox( - height: 18.0, - width: 18.0, + height: 18, + width: 18, child: Center( child: CircularProgressIndicator( backgroundColor: Theme.of(context).iconTheme.color, color: _getSyncIconColor(syncState), value: syncInfo.currentHeight / syncInfo.targetHeight, - strokeWidth: 3.0, - )), + strokeWidth: 3, + ),), ), ); } @@ -465,7 +465,7 @@ class _MainAppContainerState extends State return Tooltip( message: message, child: Icon(Icons.sync, - size: 24.0, color: _getSyncIconColor(syncState))); + size: 24, color: _getSyncIconColor(syncState),),); } } else if (syncState == SyncState.notEnoughPeers) { if (syncInfo != null) { @@ -477,22 +477,22 @@ class _MainAppContainerState extends State return Tooltip( message: message, child: SizedBox( - height: 18.0, - width: 18.0, + height: 18, + width: 18, child: Center( child: CircularProgressIndicator( backgroundColor: Theme.of(context).iconTheme.color, color: _getSyncIconColor(syncState), value: syncInfo.currentHeight / syncInfo.targetHeight, - strokeWidth: 3.0, - )))); + strokeWidth: 3, + ),),),); } else if (syncInfo.targetHeight == 0 || syncInfo.currentHeight == 0) { message = 'Connecting to peers, please wait'; syncState = SyncState.syncing; return Tooltip( message: message, child: Icon(Icons.sync, - size: 24.0, color: _getSyncIconColor(syncState))); + size: 24, color: _getSyncIconColor(syncState),),); } else { message = 'Sync progress: momentum ${syncInfo.currentHeight} of ${syncInfo.targetHeight}'; @@ -500,15 +500,15 @@ class _MainAppContainerState extends State return Tooltip( message: message, child: SizedBox( - height: 18.0, - width: 18.0, + height: 18, + width: 18, child: Center( child: CircularProgressIndicator( backgroundColor: Theme.of(context).iconTheme.color, color: _getSyncIconColor(syncState), value: syncInfo.currentHeight / syncInfo.targetHeight, - strokeWidth: 3.0, - )))); + strokeWidth: 3, + ),),),); } } else { message = 'Connecting to peers'; @@ -516,7 +516,7 @@ class _MainAppContainerState extends State return Tooltip( message: message, child: Icon(Icons.sync_problem, - size: 24.0, color: _getSyncIconColor(syncState))); + size: 24, color: _getSyncIconColor(syncState),),); } } else { message = 'Connected and synced'; @@ -526,15 +526,15 @@ class _MainAppContainerState extends State return Tooltip( message: message, child: SizedBox( - height: 18.0, - width: 18.0, + height: 18, + width: 18, child: Center( child: CircularProgressIndicator( backgroundColor: Theme.of(context).iconTheme.color, color: _getSyncIconColor(syncState), value: 1, - strokeWidth: 2.0, - )), + strokeWidth: 2, + ),), ), ); } @@ -616,7 +616,6 @@ class _MainAppContainerState extends State details: 'Auto-lock interval changed successfully to ' '$kAutoLockWalletMinutes minutes.', timestamp: DateTime.now().millisecondsSinceEpoch, - id: null, type: NotificationType.autoLockIntervalChanged, ), ); @@ -692,7 +691,7 @@ class _MainAppContainerState extends State if (kDisabledTabs.contains( kTabs[_tabController!.index], )) { - int index = _tabController!.previousIndex; + final index = _tabController!.previousIndex; setState(() { _tabController!.index = index; }); @@ -711,10 +710,8 @@ class _MainAppContainerState extends State if (kCurrentPage != Tabs.lock) { _navigateToLockTimer = _createAutoLockTimer(); } - break; case LockEvent.navigateToDashboard: _tabController!.animateTo(_getTabChildIndex(Tabs.dashboard)); - break; case LockEvent.navigateToLock: if (Navigator.of(context).canPop()) { Navigator.popUntil( @@ -726,16 +723,13 @@ class _MainAppContainerState extends State _tabController!.animateTo( _getTabChildIndex(Tabs.lock), ); - break; case LockEvent.resetTimer: if (_navigateToLockTimer != null && _navigateToLockTimer!.isActive) { _navigateToLockTimer?.cancel(); _navigateToLockTimer = _createAutoLockTimer(); } - break; case LockEvent.navigateToPreviousTab: _tabController!.animateTo(_tabController!.previousIndex); - break; } }); if (widget.redirectedFromWalletSuccess) { @@ -751,7 +745,7 @@ class _MainAppContainerState extends State }); } - void _handleIncomingLinks() async { + Future _handleIncomingLinks() async { if (!kIsWeb && !Platform.isLinux) { _incomingLinkSubscription = _appLinks.uriLinkStream.listen((Uri? uri) async { @@ -761,7 +755,7 @@ class _MainAppContainerState extends State } if (uri != null) { - String uriRaw = uri.toString(); + var uriRaw = uri.toString(); Logger('MainAppContainer') .log(Level.INFO, '_handleIncomingLinks $uriRaw'); @@ -771,7 +765,7 @@ class _MainAppContainerState extends State if (Platform.isWindows) { uriRaw = uriRaw.replaceAll('/?', '?'); } - String wcUri = Uri.decodeFull(uriRaw.split('wc?uri=').last); + final wcUri = Uri.decodeFull(uriRaw.split('wc?uri=').last); if (WalletConnectUri.tryParse(wcUri) != null) { await _updateWalletConnectUri(wcUri); } @@ -779,11 +773,11 @@ class _MainAppContainerState extends State } // Deep link query parameters - String queryAddress = ''; - String queryAmount = ''; // with decimals - int queryDuration = 0; // in months - String queryZTS = ''; - String queryPillarName = ''; + var queryAddress = ''; + var queryAmount = ''; // with decimals + var queryDuration = 0; // in months + var queryZTS = ''; + var queryPillarName = ''; Token? token; if (uri.hasQuery) { @@ -840,10 +834,9 @@ class _MainAppContainerState extends State isBarrierDismissible: true, content: Column( mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( - 'Are you sure you want transfer $queryAmount ${token.symbol} from $kSelectedAddress to $queryAddress?'), + 'Are you sure you want transfer $queryAmount ${token.symbol} from $kSelectedAddress to $queryAddress?',), ], ), onYesButtonPressed: () { @@ -852,7 +845,6 @@ class _MainAppContainerState extends State toAddress: queryAddress, amount: queryAmount.extractDecimals(token!.decimals), - data: null, token: token, ); }, @@ -860,7 +852,6 @@ class _MainAppContainerState extends State ); } } - break; case 'stake': await sl().addNotification( @@ -881,21 +872,19 @@ class _MainAppContainerState extends State isBarrierDismissible: true, content: Column( mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( - 'Are you sure you want stake $queryAmount ${kZnnCoin.symbol} for $queryDuration month(s)?'), + 'Are you sure you want stake $queryAmount ${kZnnCoin.symbol} for $queryDuration month(s)?',), ], ), onYesButtonPressed: () { stakingOptionsBloc.stakeForQsr( Duration(seconds: queryDuration * stakeTimeUnitSec), - queryAmount.extractDecimals(kZnnCoin.decimals)); + queryAmount.extractDecimals(kZnnCoin.decimals),); }, onNoButtonPressed: () {}, ); } - break; case 'delegate': await sl().addNotification( @@ -916,10 +905,9 @@ class _MainAppContainerState extends State isBarrierDismissible: true, content: Column( mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( - 'Are you sure you want delegate the ${kZnnCoin.symbol} from $kSelectedAddress to Pillar $queryPillarName?'), + 'Are you sure you want delegate the ${kZnnCoin.symbol} from $kSelectedAddress to Pillar $queryPillarName?',), ], ), onYesButtonPressed: () { @@ -928,7 +916,6 @@ class _MainAppContainerState extends State onNoButtonPressed: () {}, ); } - break; case 'fuse': await sl().addNotification( @@ -949,20 +936,18 @@ class _MainAppContainerState extends State isBarrierDismissible: true, content: Column( mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( - 'Are you sure you want fuse $queryAmount ${kQsrCoin.symbol} for address $queryAddress?'), + 'Are you sure you want fuse $queryAmount ${kQsrCoin.symbol} for address $queryAddress?',), ], ), onYesButtonPressed: () { plasmaOptionsBloc.generatePlasma(queryAddress, - queryAmount.extractDecimals(kZnnCoin.decimals)); + queryAmount.extractDecimals(kZnnCoin.decimals),); }, onNoButtonPressed: () {}, ); } - break; case 'sentinel': await sl().addNotification( @@ -977,7 +962,6 @@ class _MainAppContainerState extends State if (kCurrentPage != Tabs.lock) { _navigateTo(Tabs.sentinels); } - break; case 'pillar': await sl().addNotification( @@ -992,7 +976,6 @@ class _MainAppContainerState extends State if (kCurrentPage != Tabs.lock) { _navigateTo(Tabs.pillars); } - break; default: await sl().addNotification( @@ -1014,11 +997,11 @@ class _MainAppContainerState extends State .log(Level.INFO, '_handleIncomingLinks', 'done'); }, onError: (Object err) async { await NotificationUtils.sendNotificationError( - err, 'Handle incoming link failed'); + err, 'Handle incoming link failed',); Logger('MainAppContainer') .log(Level.WARNING, '_handleIncomingLinks', err); if (!mounted) return; - }); + },); } } @@ -1033,18 +1016,18 @@ class _MainAppContainerState extends State if (!mounted) return; } on PlatformException catch (e, stackTrace) { Logger('MainAppContainer').log(Level.WARNING, - '_handleInitialUri PlatformException', e, stackTrace); + '_handleInitialUri PlatformException', e, stackTrace,); } on FormatException catch (e, stackTrace) { Logger('MainAppContainer').log( - Level.WARNING, '_handleInitialUri FormatException', e, stackTrace); + Level.WARNING, '_handleInitialUri FormatException', e, stackTrace,); if (!mounted) return; } } } @override - void onClipboardChanged() async { - ClipboardData? newClipboardData = + Future onClipboardChanged() async { + final newClipboardData = await Clipboard.getData(Clipboard.kTextPlain); final text = newClipboardData?.text ?? ''; if (text.isNotEmpty && WalletConnectUri.tryParse(text) != null) { diff --git a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donation_stepper.dart b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donation_stepper.dart index 6c12c0e7..bc671b9d 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donation_stepper.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donation_stepper.dart @@ -4,9 +4,9 @@ import 'package:stacked/stacked.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_material_stepper.dart' as custom_material_stepper; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; enum AcceleratorDonationStep { @@ -79,9 +79,9 @@ class _AcceleratorDonationStepperState Visibility( visible: _lastCompletedStep == AcceleratorDonationStep.values.last, child: Positioned( - bottom: 20.0, - right: 0.0, - left: 0.0, + bottom: 20, + right: 0, + left: 0, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -94,10 +94,9 @@ class _AcceleratorDonationStepperState }); }, iconData: Icons.refresh, - context: context, ), const SizedBox( - width: 75.0, + width: 75, ), StepperButton( text: 'Return to project list', @@ -112,10 +111,10 @@ class _AcceleratorDonationStepperState Visibility( visible: _lastCompletedStep == AcceleratorDonationStep.values.last, child: Positioned( - right: 50.0, + right: 50, child: SizedBox( - width: 400.0, - height: 400.0, + width: 400, + height: 400, child: Center( child: Lottie.asset( 'assets/lottie/ic_anim_zts.json', @@ -176,13 +175,13 @@ class _AcceleratorDonationStepperState } String _getDonationDetailsStepSubtitle() { - String znnPrefix = _znnAmountController.text.isNotEmpty + final znnPrefix = _znnAmountController.text.isNotEmpty ? '${_znnAmountController.text} ${kZnnCoin.symbol}' : ''; - String qsrSuffix = _qsrAmountController.text.isNotEmpty + final qsrSuffix = _qsrAmountController.text.isNotEmpty ? '${_qsrAmountController.text} ${kQsrCoin.symbol}' : ''; - String splitter = znnPrefix.isNotEmpty && qsrSuffix.isNotEmpty ? ' ● ' : ''; + final splitter = znnPrefix.isNotEmpty && qsrSuffix.isNotEmpty ? ' ● ' : ''; return znnPrefix + splitter + qsrSuffix; } @@ -195,7 +194,7 @@ class _AcceleratorDonationStepperState Row(children: [ StepperUtils.getBalanceWidget(kZnnCoin, accountInfo), StepperUtils.getBalanceWidget(kQsrCoin, accountInfo), - ]), + ],), const DottedBorderInfoWidget( text: 'All donated funds go directly into the Accelerator address', ), @@ -209,7 +208,7 @@ class _AcceleratorDonationStepperState text: 'Cancel', ), const SizedBox( - width: 15.0, + width: 15, ), StepperButton( onPressed: accountInfo.znn()! > BigInt.zero || @@ -253,7 +252,7 @@ class _AcceleratorDonationStepperState suffixIcon: AmountSuffixWidgets( kZnnCoin, onMaxPressed: () { - BigInt maxZnn = accountInfo.getBalance( + final maxZnn = accountInfo.getBalance( kZnnCoin.tokenStandard, ); if (_znnAmountController.text.isEmpty || @@ -292,7 +291,7 @@ class _AcceleratorDonationStepperState suffixIcon: AmountSuffixWidgets( kQsrCoin, onMaxPressed: () { - BigInt maxQsr = accountInfo.getBalance( + final maxQsr = accountInfo.getBalance( kQsrCoin.tokenStandard, ); if (_qsrAmountController.text.isEmpty || @@ -331,7 +330,7 @@ class _AcceleratorDonationStepperState }, ), const SizedBox( - width: 15.0, + width: 15, ), StepperButton( text: 'Continue', @@ -415,7 +414,7 @@ class _AcceleratorDonationStepperState text: 'Go back', ), const SizedBox( - width: 15.0, + width: 15, ), _getSubmitDonationViewModel(), ], @@ -460,7 +459,7 @@ class _AcceleratorDonationStepperState ); }, builder: (_, model, __) => _getSubmitDonationButton(model), - viewModelBuilder: () => SubmitDonationBloc(), + viewModelBuilder: SubmitDonationBloc.new, ); } diff --git a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donations.dart b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donations.dart index ab39b59d..017340c8 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donations.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donations.dart @@ -5,12 +5,12 @@ import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class AcceleratorDonations extends StatelessWidget { - final VoidCallback onStepperNotificationSeeMorePressed; const AcceleratorDonations({ required this.onStepperNotificationSeeMorePressed, super.key, }); + final VoidCallback onStepperNotificationSeeMorePressed; @override Widget build(BuildContext context) { @@ -27,7 +27,7 @@ class AcceleratorDonations extends StatelessWidget { children: [ const Icon( MaterialCommunityIcons.ufo_outline, - size: 75.0, + size: 75, color: AppColors.znnColor, ), Column( @@ -35,7 +35,7 @@ class AcceleratorDonations extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( - width: 200.0, + width: 200, child: Text( 'Fuel for the Mothership', style: Theme.of(context).textTheme.headlineSmall, diff --git a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list.dart b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list.dart index 450f2fd9..624a4e47 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list.dart @@ -10,10 +10,6 @@ enum AcceleratorProjectsFilterTag { } class AcceleratorProjectList extends StatefulWidget { - final PillarInfo? pillarInfo; - final List acceleratorProjects; - final Project? projects; - final VoidCallback onStepperNotificationSeeMorePressed; const AcceleratorProjectList( this.pillarInfo, @@ -22,6 +18,10 @@ class AcceleratorProjectList extends StatefulWidget { this.projects, super.key, }); + final PillarInfo? pillarInfo; + final List acceleratorProjects; + final Project? projects; + final VoidCallback onStepperNotificationSeeMorePressed; @override State createState() => _AcceleratorProjectListState(); @@ -40,18 +40,18 @@ class _AcceleratorProjectListState extends State { @override Widget build(BuildContext context) { return Container( - margin: const EdgeInsets.all(15.0), + margin: const EdgeInsets.all(15), child: Column( children: [ _getSearchInputField(), const SizedBox( - height: 10.0, + height: 10, ), if (widget.acceleratorProjects.first is Project) _getProjectsFilterTags(), if (widget.acceleratorProjects.first is Project) const SizedBox( - height: 10.0, + height: 10, ), Expanded( child: Scrollbar( @@ -59,7 +59,7 @@ class _AcceleratorProjectListState extends State { thumbVisibility: true, child: ListView.separated( separatorBuilder: (_, __) => const SizedBox( - height: 15.0, + height: 15, ), controller: _scrollController, shrinkWrap: true, @@ -105,7 +105,7 @@ class _AcceleratorProjectListState extends State { } Set _filterBaseProjects( - List acceleratorProjects) { + List acceleratorProjects,) { var filteredBaseProjects = _filterBaseProjectsBySearchKeyWord(acceleratorProjects); if (widget.acceleratorProjects.first is Project && @@ -120,7 +120,7 @@ class _AcceleratorProjectListState extends State { Set _filterBaseProjectsBySearchKeyWord( List acceleratorProjects, ) { - var filteredBaseProjects = {}; + final filteredBaseProjects = {}; filteredBaseProjects.addAll( acceleratorProjects.where( (element) => element.id.toString().toLowerCase().contains( @@ -176,7 +176,7 @@ class _AcceleratorProjectListState extends State { Widget _getProjectsFilterTag(AcceleratorProjectsFilterTag filterTag) { return TagWidget( text: FormatUtils.extractNameFromEnum( - filterTag), + filterTag,), hexColorCode: Theme.of(context) .colorScheme .primaryContainer diff --git a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list_item.dart b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list_item.dart index 8e5205bd..46641f68 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list_item.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list_item.dart @@ -8,18 +8,16 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class AcceleratorProjectListItem extends StatefulWidget { - final AcceleratorProject acceleratorProject; - final PillarInfo? pillarInfo; - final Project? project; - final VoidCallback onStepperNotificationSeeMorePressed; const AcceleratorProjectListItem({ - super.key, - required this.acceleratorProject, + required this.acceleratorProject, required this.onStepperNotificationSeeMorePressed, super.key, this.pillarInfo, this.project, - required this.onStepperNotificationSeeMorePressed, }); + final AcceleratorProject acceleratorProject; + final PillarInfo? pillarInfo; + final Project? project; + final VoidCallback onStepperNotificationSeeMorePressed; @override State createState() => @@ -50,12 +48,12 @@ class _AcceleratorProjectListItemState : null, child: Container( padding: const EdgeInsets.symmetric( - horizontal: 20.0, - vertical: 10.0, + horizontal: 20, + vertical: 10, ), decoration: BoxDecoration( borderRadius: BorderRadius.circular( - 10.0, + 10, ), color: Theme.of(context).colorScheme.primaryContainer, ), @@ -63,7 +61,7 @@ class _AcceleratorProjectListItemState children: [ _getProjectTitle(context), const SizedBox( - height: 10.0, + height: 10, ), AcceleratorProjectDetails( owner: widget.acceleratorProject is Project @@ -72,18 +70,18 @@ class _AcceleratorProjectListItemState hash: widget.acceleratorProject.id, creationTimestamp: widget.acceleratorProject.creationTimestamp, acceleratorProjectStatus: widget.acceleratorProject.status, - isPhase: widget.acceleratorProject is Phase + isPhase: widget.acceleratorProject is Phase, ), const SizedBox( - height: 10.0, + height: 10, ), _getProjectDescription(context), const SizedBox( - height: 10.0, + height: 10, ), _getProjectStatuses(context), const SizedBox( - height: 10.0, + height: 10, ), _getProjectVoteBreakdownViewModel(context), ], @@ -139,7 +137,7 @@ class _AcceleratorProjectListItemState } Widget _getProjectStatuses(BuildContext context) { - List tags = [ + final tags = [ _getProjectStatusTag(), ]; @@ -173,7 +171,7 @@ class _AcceleratorProjectListItemState List.generate( tags.length - 1, (index) => const SizedBox( - width: 5.0, + width: 5, ), ), ), @@ -241,12 +239,12 @@ class _AcceleratorProjectListItemState BuildContext context, VoteBreakdown voteBreakdown, ) { - int yesVotes = voteBreakdown.yes; - int noVotes = voteBreakdown.no; - int quorum = voteBreakdown.total; - int quorumNeeded = (kNumOfPillars! * 0.33).ceil(); - int votesToAchieveQuorum = quorumNeeded - quorum; - int pillarsThatCanStillVote = kNumOfPillars! - + final yesVotes = voteBreakdown.yes; + final noVotes = voteBreakdown.no; + final quorum = voteBreakdown.total; + final quorumNeeded = (kNumOfPillars! * 0.33).ceil(); + final votesToAchieveQuorum = quorumNeeded - quorum; + final pillarsThatCanStillVote = kNumOfPillars! - quorum - (votesToAchieveQuorum > 0 ? votesToAchieveQuorum : 0); @@ -279,7 +277,7 @@ class _AcceleratorProjectListItemState ), ), const SizedBox( - width: 10.0, + width: 10, ), Tooltip( message: yesVotes > noVotes @@ -290,13 +288,13 @@ class _AcceleratorProjectListItemState color: yesVotes > noVotes ? AppColors.znnColor : Theme.of(context).colorScheme.secondary, - size: 15.0, + size: 15, ), ), ], ), const SizedBox( - height: 10.0, + height: 10, ), Row( children: [ @@ -323,9 +321,9 @@ class _AcceleratorProjectListItemState '$pillarsThatCanStillVote Pillars that can still cast a vote', ), ], - )), + ),), const SizedBox( - width: 10.0, + width: 10, ), Tooltip( message: quorum >= quorumNeeded @@ -336,7 +334,7 @@ class _AcceleratorProjectListItemState color: quorum >= quorumNeeded ? AppColors.znnColor : Theme.of(context).colorScheme.secondary, - size: 15.0, + size: 15, ), ), ], @@ -348,8 +346,8 @@ class _AcceleratorProjectListItemState Widget _getOpenLinkIcon(BuildContext context) { return RawMaterialButton( constraints: const BoxConstraints( - minWidth: 50.0, - minHeight: 50.0, + minWidth: 50, + minHeight: 50, ), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, shape: const CircleBorder(), @@ -357,8 +355,8 @@ class _AcceleratorProjectListItemState child: Tooltip( message: 'Visit ${widget.acceleratorProject.url}', child: Container( - height: 50.0, - width: 50.0, + height: 50, + width: 50, padding: const EdgeInsets.all(4), decoration: const BoxDecoration( shape: BoxShape.circle, @@ -366,7 +364,7 @@ class _AcceleratorProjectListItemState ), child: const Icon( Icons.open_in_new, - size: 25.0, + size: 25, color: AppColors.znnColor, ), ), @@ -400,7 +398,7 @@ class _AcceleratorProjectListItemState Row( children: [ const SizedBox( - width: 10.0, + width: 10, ), _getOpenLinkIcon(context), ], @@ -412,11 +410,11 @@ class _AcceleratorProjectListItemState Row( children: [ const SizedBox( - width: 10.0, + width: 10, ), _getUpdatePhaseIcon(context), ], - ) + ), ], ); } @@ -432,76 +430,76 @@ class _AcceleratorProjectListItemState message: 'No', child: RawMaterialButton( constraints: const BoxConstraints( - minWidth: 50.0, - minHeight: 50.0, + minWidth: 50, + minHeight: 50, ), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, shape: const CircleBorder(), onPressed: () { model.voteProject( - widget.acceleratorProject.id, AcceleratorProjectVote.no); + widget.acceleratorProject.id, AcceleratorProjectVote.no,); }, child: Container( - height: 50.0, - width: 50.0, + height: 50, + width: 50, decoration: BoxDecoration( shape: BoxShape.circle, color: _ifOptionVotedByUser( - pillarVoteList, AcceleratorProjectVote.no) + pillarVoteList, AcceleratorProjectVote.no,) ? AppColors.errorColor : Theme.of(context).colorScheme.secondary, ), child: Icon( Icons.close_rounded, - size: 35.0, + size: 35, color: Theme.of(context).colorScheme.primary, ), ), ), ), const SizedBox( - width: 10.0, + width: 10, ), Tooltip( message: 'Yes', child: RawMaterialButton( constraints: const BoxConstraints( - minWidth: 50.0, - minHeight: 50.0, + minWidth: 50, + minHeight: 50, ), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, shape: const CircleBorder(), onPressed: () { model.voteProject( - widget.acceleratorProject.id, AcceleratorProjectVote.yes); + widget.acceleratorProject.id, AcceleratorProjectVote.yes,); }, child: Container( - height: 50.0, - width: 50.0, + height: 50, + width: 50, decoration: BoxDecoration( shape: BoxShape.circle, color: _ifOptionVotedByUser( - pillarVoteList, AcceleratorProjectVote.yes) + pillarVoteList, AcceleratorProjectVote.yes,) ? AppColors.znnColor : Theme.of(context).colorScheme.secondary, ), child: Icon( Icons.check_rounded, - size: 35.0, + size: 35, color: Theme.of(context).colorScheme.primary, ), ), ), ), const SizedBox( - width: 10.0, + width: 10, ), Tooltip( message: 'Abstain', child: RawMaterialButton( constraints: const BoxConstraints( - minWidth: 50.0, - minHeight: 50.0, + minWidth: 50, + minHeight: 50, ), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, shape: const CircleBorder(), @@ -512,8 +510,8 @@ class _AcceleratorProjectListItemState ); }, child: Container( - height: 50.0, - width: 50.0, + height: 50, + width: 50, decoration: BoxDecoration( shape: BoxShape.circle, color: _ifOptionVotedByUser( @@ -525,7 +523,7 @@ class _AcceleratorProjectListItemState ), child: Icon( Icons.stop, - size: 35.0, + size: 35, color: Theme.of(context).colorScheme.primary, ), ), @@ -540,8 +538,8 @@ class _AcceleratorProjectListItemState message: 'Update phase', child: RawMaterialButton( constraints: const BoxConstraints( - minWidth: 50.0, - minHeight: 50.0, + minWidth: 50, + minHeight: 50, ), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, shape: const CircleBorder(), @@ -561,8 +559,8 @@ class _AcceleratorProjectListItemState ); }, child: Container( - height: 50.0, - width: 50.0, + height: 50, + width: 50, padding: const EdgeInsets.all(4), decoration: const BoxDecoration( shape: BoxShape.circle, @@ -570,7 +568,7 @@ class _AcceleratorProjectListItemState ), child: const Icon( Icons.edit, - size: 25.0, + size: 25, color: AppColors.znnColor, ), ), @@ -597,7 +595,7 @@ class _AcceleratorProjectListItemState error, 'Error while voting project', ); - }); + },); }, builder: (_, model, __) => StreamBuilder( stream: model.stream, @@ -612,8 +610,8 @@ class _AcceleratorProjectListItemState return const SyriusLoadingWidget(); } return _getVotingIcons(context, model, pillarVoteList); - }), - viewModelBuilder: () => VoteProjectBloc(), + },), + viewModelBuilder: VoteProjectBloc.new, ); } @@ -621,13 +619,13 @@ class _AcceleratorProjectListItemState return ViewModelBuilder.reactive( onViewModelReady: (model) { model.getVoteBreakdown( - widget.pillarInfo?.name, widget.acceleratorProject.id); + widget.pillarInfo?.name, widget.acceleratorProject.id,); model.stream.listen((event) {}, onError: (error) async { await NotificationUtils.sendNotificationError( error, 'Error while trying to get the vote breakdown', ); - }); + },); }, builder: (_, model, __) => StreamBuilder?>?>( @@ -650,14 +648,14 @@ class _AcceleratorProjectListItemState return const SyriusLoadingWidget(); }, ), - viewModelBuilder: () => ProjectVoteBreakdownBloc(), + viewModelBuilder: ProjectVoteBreakdownBloc.new, ); } bool _ifOptionVotedByUser( - List pillarVoteList, AcceleratorProjectVote vote) { + List pillarVoteList, AcceleratorProjectVote vote,) { try { - PillarVote? pillarVote = pillarVoteList.firstWhere( + final pillarVote = pillarVoteList.firstWhere( (pillarVote) => pillarVote?.name == widget.pillarInfo!.name, ); return pillarVote!.vote == vote.index; diff --git a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_stats.dart b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_stats.dart index 2797e664..270f90e2 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_stats.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_stats.dart @@ -57,11 +57,11 @@ class _AcceleratorStatsState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( - width: 150.0, + width: 150, child: _getPieChart(accountInfo), ), SizedBox( - width: 200.0, + width: 200, child: _getPieChartLegend(context, accountInfo), ), ], @@ -85,7 +85,7 @@ class _AcceleratorStatsState extends State { tokenSymbol: kZnnCoin.symbol, builder: (amount, tokenSymbol) => Text( '$amount $tokenSymbol', - style: Theme.of(context).textTheme.titleMedium!, + style: Theme.of(context).textTheme.titleMedium, ), ), ), @@ -102,7 +102,7 @@ class _AcceleratorStatsState extends State { tokenSymbol: kQsrCoin.symbol, builder: (amount, tokenSymbol) => Text( '$amount $tokenSymbol', - style: Theme.of(context).textTheme.titleMedium!, + style: Theme.of(context).textTheme.titleMedium, ), ), ), @@ -112,11 +112,11 @@ class _AcceleratorStatsState extends State { Widget _getPieChart(AccountInfo accountInfo) { return AspectRatio( - aspectRatio: 1.0, + aspectRatio: 1, child: StandardPieChart( sections: showingSections(accountInfo), - centerSpaceRadius: 0.0, - sectionsSpace: 4.0, + centerSpaceRadius: 0, + sectionsSpace: 4, onChartSectionTouched: (pieTouchedSection) { setState(() { _touchedSectionTitle = pieTouchedSection?.touchedSection?.title; @@ -139,19 +139,19 @@ class _AcceleratorStatsState extends State { Token token, AccountInfo accountInfo, ) { - BigInt value = token.tokenStandard == kZnnCoin.tokenStandard + final value = token.tokenStandard == kZnnCoin.tokenStandard ? accountInfo.znn()! : accountInfo.qsr()!; - BigInt sumValues = accountInfo.znn()! + accountInfo.qsr()!; + final sumValues = accountInfo.znn()! + accountInfo.qsr()!; final isTouched = token.symbol == _touchedSectionTitle; - final double opacity = isTouched ? 1.0 : 0.5; + final opacity = isTouched ? 1.0 : 0.5; return PieChartSectionData( color: ColorUtils.getTokenColor(token.tokenStandard).withOpacity(opacity), value: value / sumValues, title: accountInfo.findTokenByTokenStandard(token.tokenStandard)!.symbol, - radius: 60.0, + radius: 60, titleStyle: Theme.of(context).textTheme.bodyLarge, ); } diff --git a/lib/widgets/modular_widgets/accelerator_widgets/create_phase.dart b/lib/widgets/modular_widgets/accelerator_widgets/create_phase.dart index 2f4688ee..c73d7fdb 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/create_phase.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/create_phase.dart @@ -6,14 +6,14 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class CreatePhase extends StatelessWidget { - final VoidCallback onStepperNotificationSeeMorePressed; - final Project project; const CreatePhase({ required this.onStepperNotificationSeeMorePressed, required this.project, super.key, }); + final VoidCallback onStepperNotificationSeeMorePressed; + final Project project; @override Widget build(BuildContext context) { @@ -32,7 +32,7 @@ class CreatePhase extends StatelessWidget { children: [ const Icon( MaterialCommunityIcons.creation, - size: 100.0, + size: 100, color: AppColors.znnColor, ), Column( @@ -40,7 +40,7 @@ class CreatePhase extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( - width: 200.0, + width: 200, child: Text( 'Start the project by creating a phase to unlock funds', style: Theme.of(context).textTheme.headlineSmall, diff --git a/lib/widgets/modular_widgets/accelerator_widgets/create_project.dart b/lib/widgets/modular_widgets/accelerator_widgets/create_project.dart index 022c48f8..ce08d8ae 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/create_project.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/create_project.dart @@ -5,12 +5,12 @@ import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class CreateProject extends StatelessWidget { - final VoidCallback onStepperNotificationSeeMorePressed; const CreateProject({ required this.onStepperNotificationSeeMorePressed, super.key, }); + final VoidCallback onStepperNotificationSeeMorePressed; @override Widget build(BuildContext context) { @@ -27,7 +27,7 @@ class CreateProject extends StatelessWidget { children: [ const Icon( MaterialCommunityIcons.alien, - size: 75.0, + size: 75, color: AppColors.znnColor, ), Column( @@ -35,7 +35,7 @@ class CreateProject extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( - width: 200.0, + width: 200, child: Text( 'Join the Aliens building the future on Network of Momentum', style: Theme.of(context).textTheme.headlineSmall, diff --git a/lib/widgets/modular_widgets/accelerator_widgets/phase_creation_stepper.dart b/lib/widgets/modular_widgets/accelerator_widgets/phase_creation_stepper.dart index 79ab1a93..fe61d1a1 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/phase_creation_stepper.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/phase_creation_stepper.dart @@ -15,9 +15,9 @@ enum PhaseCreationStep { } class PhaseCreationStepper extends StatefulWidget { - final Project project; const PhaseCreationStepper(this.project, {super.key}); + final Project project; @override State createState() => _PhaseCreationStepperState(); @@ -82,9 +82,9 @@ class _PhaseCreationStepperState extends State { Visibility( visible: _lastCompletedStep == PhaseCreationStep.values.last, child: Positioned( - bottom: 20.0, - right: 0.0, - left: 0.0, + bottom: 20, + right: 0, + left: 0, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -98,10 +98,9 @@ class _PhaseCreationStepperState extends State { }); }, iconData: Icons.refresh, - context: context, ), const SizedBox( - width: 75.0, + width: 75, ), StepperButton( text: 'View phases', @@ -116,10 +115,10 @@ class _PhaseCreationStepperState extends State { Visibility( visible: _lastCompletedStep == PhaseCreationStep.values.last, child: Positioned( - right: 50.0, + right: 50, child: SizedBox( - width: 400.0, - height: 400.0, + width: 400, + height: 400, child: Center( child: Lottie.asset( 'assets/lottie/ic_anim_zts.json', @@ -196,7 +195,7 @@ class _PhaseCreationStepperState extends State { ), // Empty space so that all the right edges will align const SizedBox( - width: 23.0, + width: 23, ), ], ), @@ -219,7 +218,7 @@ class _PhaseCreationStepperState extends State { ), // Empty space so that all the right edges will align const SizedBox( - width: 23.0, + width: 23, ), ], ), @@ -297,7 +296,7 @@ class _PhaseCreationStepperState extends State { ), // Empty space so that all the right edges will align const SizedBox( - width: 23.0, + width: 23, ), ], ), @@ -339,7 +338,7 @@ class _PhaseCreationStepperState extends State { ), // Empty space so that all the right edges will align const SizedBox( - width: 23.0, + width: 23, ), ], ), @@ -353,7 +352,7 @@ class _PhaseCreationStepperState extends State { }, ), const SizedBox( - width: 15.0, + width: 15, ), StepperButton( text: 'Continue', @@ -373,12 +372,12 @@ class _PhaseCreationStepperState extends State { } Widget _getSubmitPhaseStepContent() { - BigInt remainingZnnBudget = widget.project.getRemainingZnnFunds() - + final remainingZnnBudget = widget.project.getRemainingZnnFunds() - (_phaseZnnAmountController.text.isNotEmpty ? _phaseZnnAmountController.text.extractDecimals(coinDecimals) : BigInt.zero); - BigInt remainingQsrBudget = widget.project.getRemainingQsrFunds() - + final remainingQsrBudget = widget.project.getRemainingQsrFunds() - (_phaseQsrAmountController.text.isNotEmpty ? _phaseQsrAmountController.text.extractDecimals(coinDecimals) : BigInt.zero); @@ -404,7 +403,7 @@ class _PhaseCreationStepperState extends State { text: 'Go back', ), const SizedBox( - width: 15.0, + width: 15, ), _getCreatePhaseViewModel(), ], @@ -457,7 +456,7 @@ class _PhaseCreationStepperState extends State { ); }, builder: (_, model, __) => _getSubmitButton(model), - viewModelBuilder: () => CreatePhaseBloc(), + viewModelBuilder: CreatePhaseBloc.new, ); } diff --git a/lib/widgets/modular_widgets/accelerator_widgets/phase_list.dart b/lib/widgets/modular_widgets/accelerator_widgets/phase_list.dart index 62a535e7..28c9c393 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/phase_list.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/phase_list.dart @@ -3,10 +3,6 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PhaseList extends StatelessWidget { - final PillarInfo? pillarInfo; - final Project project; - final VoidCallback onRefreshButtonPressed; - final VoidCallback onStepperNotificationSeeMorePressed; const PhaseList( this.pillarInfo, @@ -15,6 +11,10 @@ class PhaseList extends StatelessWidget { required this.onStepperNotificationSeeMorePressed, super.key, }); + final PillarInfo? pillarInfo; + final Project project; + final VoidCallback onRefreshButtonPressed; + final VoidCallback onStepperNotificationSeeMorePressed; @override Widget build(BuildContext context) { diff --git a/lib/widgets/modular_widgets/accelerator_widgets/project_creation_stepper.dart b/lib/widgets/modular_widgets/accelerator_widgets/project_creation_stepper.dart index 4e65bbe7..c8028893 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/project_creation_stepper.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/project_creation_stepper.dart @@ -4,10 +4,10 @@ import 'package:stacked/stacked.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_material_stepper.dart' as custom_material_stepper; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; enum ProjectCreationStep { projectCreation, @@ -81,9 +81,9 @@ class _ProjectCreationStepperState extends State { Visibility( visible: _lastCompletedStep == ProjectCreationStep.values.last, child: Positioned( - bottom: 20.0, - right: 0.0, - left: 0.0, + bottom: 20, + right: 0, + left: 0, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -97,10 +97,9 @@ class _ProjectCreationStepperState extends State { }); }, iconData: Icons.refresh, - context: context, ), const SizedBox( - width: 75.0, + width: 75, ), StepperButton( text: 'View projects', @@ -115,10 +114,10 @@ class _ProjectCreationStepperState extends State { Visibility( visible: _lastCompletedStep == ProjectCreationStep.values.last, child: Positioned( - right: 50.0, + right: 50, child: SizedBox( - width: 400.0, - height: 400.0, + width: 400, + height: 400, child: Center( child: Lottie.asset( 'assets/lottie/ic_anim_zts.json', @@ -215,7 +214,7 @@ class _ProjectCreationStepperState extends State { text: 'Cancel', ), const SizedBox( - width: 15.0, + width: 15, ), StepperButton( onPressed: accountInfo.getBalance( @@ -260,7 +259,7 @@ class _ProjectCreationStepperState extends State { ), // Empty space so that all the right edges will align const SizedBox( - width: 23.0, + width: 23, ), ], ), @@ -283,7 +282,7 @@ class _ProjectCreationStepperState extends State { ), // Empty space so that all the right edges will align const SizedBox( - width: 23.0, + width: 23, ), ], ), @@ -339,7 +338,7 @@ class _ProjectCreationStepperState extends State { suffixIcon: AmountSuffixWidgets( kZnnCoin, onMaxPressed: () { - BigInt maxZnn = kZnnProjectMaximumFunds; + final maxZnn = kZnnProjectMaximumFunds; if (_projectZnnAmountController.text.isEmpty || _projectZnnAmountController.text .extractDecimals(coinDecimals) < @@ -366,7 +365,7 @@ class _ProjectCreationStepperState extends State { ), // Empty space so that all the right edges will align const SizedBox( - width: 23.0, + width: 23, ), ], ), @@ -386,7 +385,7 @@ class _ProjectCreationStepperState extends State { suffixIcon: AmountSuffixWidgets( kQsrCoin, onMaxPressed: () { - BigInt maxQsr = kQsrProjectMaximumFunds; + final maxQsr = kQsrProjectMaximumFunds; if (_projectQsrAmountController.text.isEmpty || _projectQsrAmountController.text .extractDecimals(coinDecimals) < @@ -412,7 +411,7 @@ class _ProjectCreationStepperState extends State { ), ), const SizedBox( - width: 23.0, + width: 23, ), ], ), @@ -426,7 +425,7 @@ class _ProjectCreationStepperState extends State { }, ), const SizedBox( - width: 15.0, + width: 15, ), StepperButton( text: 'Continue', @@ -466,7 +465,7 @@ class _ProjectCreationStepperState extends State { text: 'Go back', ), const SizedBox( - width: 15.0, + width: 15, ), _getSubmitProjectViewModel(), ], @@ -497,7 +496,7 @@ class _ProjectCreationStepperState extends State { ); }, builder: (_, model, __) => _getSubmitProjectButton(model), - viewModelBuilder: () => CreateProjectBloc(), + viewModelBuilder: CreateProjectBloc.new, ); } diff --git a/lib/widgets/modular_widgets/accelerator_widgets/project_list.dart b/lib/widgets/modular_widgets/accelerator_widgets/project_list.dart index 5a43aa04..5a6ca809 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/project_list.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/project_list.dart @@ -17,14 +17,14 @@ enum AccProjectsFilterTag { } class AccProjectList extends StatefulWidget { - final VoidCallback onStepperNotificationSeeMorePressed; - final PillarInfo? pillarInfo; const AccProjectList({ required this.onStepperNotificationSeeMorePressed, required this.pillarInfo, super.key, }); + final VoidCallback onStepperNotificationSeeMorePressed; + final PillarInfo? pillarInfo; @override State createState() => _AccProjectListState(); @@ -79,7 +79,7 @@ class _AccProjectListState extends State { Widget build(BuildContext context) { return CardScaffold( title: 'Project List', - childBuilder: () => _getInfiniteScrollList(), + childBuilder: _getInfiniteScrollList, onRefreshPressed: () { _searchKeyWordController.clear(); _bloc.refreshResults(); @@ -90,7 +90,7 @@ class _AccProjectListState extends State { Widget _getInfiniteScrollList() { return Padding( - padding: const EdgeInsets.all(15.0), + padding: const EdgeInsets.all(15), child: Column( children: [ _getSearchInputField(), @@ -103,7 +103,7 @@ class _AccProjectListState extends State { onTap: _sortProjectListByLastUpdate, child: Icon( Entypo.select_arrows, - size: 15.0, + size: 15, color: Theme.of(context).iconTheme.color, ), ), @@ -118,7 +118,7 @@ class _AccProjectListState extends State { scrollController: _scrollController, pagingController: _pagingController, separatorBuilder: (_, __) => const SizedBox( - height: 15.0, + height: 15, ), builderDelegate: PagedChildBuilderDelegate( itemBuilder: (_, project, __) => AcceleratorProjectListItem( @@ -163,13 +163,13 @@ class _AccProjectListState extends State { } Row _getProjectsFilterTags() { - List children = []; + final children = []; - for (var tag in AccProjectsFilterTag.values) { + for (final tag in AccProjectsFilterTag.values) { if (widget.pillarInfo == null) { if ([ AccProjectsFilterTag.needsVoting, - AccProjectsFilterTag.alreadyVoted + AccProjectsFilterTag.alreadyVoted, ].contains(tag)) { continue; } @@ -182,7 +182,7 @@ class _AccProjectListState extends State { ); } - _getProjectsFilterTag(AccProjectsFilterTag filterTag) { + TagWidget _getProjectsFilterTag(AccProjectsFilterTag filterTag) { return TagWidget( text: FormatUtils.extractNameFromEnum(filterTag), hexColorCode: Theme.of(context) @@ -226,9 +226,9 @@ class _AccProjectListState extends State { _pagingController.itemList!.isNotEmpty) { _sortAscending ? _pagingController.itemList!.sort( - (a, b) => a.lastUpdateTimestamp.compareTo(b.lastUpdateTimestamp)) + (a, b) => a.lastUpdateTimestamp.compareTo(b.lastUpdateTimestamp),) : _pagingController.itemList!.sort( - (a, b) => b.lastUpdateTimestamp.compareTo(a.lastUpdateTimestamp)); + (a, b) => b.lastUpdateTimestamp.compareTo(a.lastUpdateTimestamp),); setState(() { _sortAscending = !_sortAscending; }); diff --git a/lib/widgets/modular_widgets/accelerator_widgets/projects_stats.dart b/lib/widgets/modular_widgets/accelerator_widgets/projects_stats.dart index daf495c9..5bcb1d71 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/projects_stats.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/projects_stats.dart @@ -5,9 +5,9 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ProjectsStats extends StatelessWidget { - final Project project; const ProjectsStats(this.project, {super.key}); + final Project project; @override Widget build(BuildContext context) { @@ -20,7 +20,7 @@ class ProjectsStats extends StatelessWidget { Widget _getWidgetBody(BuildContext context) { return Padding( - padding: const EdgeInsets.all(15.0), + padding: const EdgeInsets.all(15), child: Column( children: [ Row( @@ -32,12 +32,12 @@ class ProjectsStats extends StatelessWidget { project.name, ), const SizedBox( - height: 5.0, + height: 5, ), AcceleratorProjectDetails( owner: project.owner, hash: project.id, - creationTimestamp: project.creationTimestamp + creationTimestamp: project.creationTimestamp, ), ], ), @@ -56,7 +56,7 @@ class ProjectsStats extends StatelessWidget { child: _getChart(_getZnnChartSections(context)), ), const SizedBox( - width: 15.0, + width: 15, ), Expanded( flex: 3, @@ -75,7 +75,7 @@ class ProjectsStats extends StatelessWidget { child: _getChart(_getQsrChartSections(context)), ), const SizedBox( - width: 15.0, + width: 15, ), Expanded( flex: 3, @@ -95,11 +95,11 @@ class ProjectsStats extends StatelessWidget { Widget _getChart(List sections) { return Container( constraints: const BoxConstraints( - maxWidth: 150.0, - maxHeight: 150.0, + maxWidth: 150, + maxHeight: 150, ), child: AspectRatio( - aspectRatio: 1.0, + aspectRatio: 1, child: StandardPieChart( sections: sections, ), @@ -113,7 +113,7 @@ class ProjectsStats extends StatelessWidget { ) { return PieChartSectionData( showTitle: false, - radius: 7.0, + radius: 7, color: color, value: value, ); @@ -165,7 +165,7 @@ class ProjectsStats extends StatelessWidget { Widget _getZnnProjectLegends(BuildContext context) { return SizedBox( - height: 100.0, + height: 100, child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, @@ -213,7 +213,7 @@ class ProjectsStats extends StatelessWidget { Widget _getQsrProjectLegends(BuildContext context) { return SizedBox( - height: 100.0, + height: 100, child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/widgets/modular_widgets/accelerator_widgets/update_phase_stepper.dart b/lib/widgets/modular_widgets/accelerator_widgets/update_phase_stepper.dart index e36beca2..37672c16 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/update_phase_stepper.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/update_phase_stepper.dart @@ -15,14 +15,14 @@ enum UpdatePhaseStep { } class UpdatePhaseStepper extends StatefulWidget { - final Phase phase; - final Project project; const UpdatePhaseStepper( this.phase, this.project, { super.key, }); + final Phase phase; + final Project project; @override State createState() => _UpdatePhaseStepperState(); @@ -96,9 +96,9 @@ class _UpdatePhaseStepperState extends State { Visibility( visible: _lastCompletedStep == UpdatePhaseStep.updatePhase, child: Positioned( - bottom: 20.0, - right: 0.0, - left: 0.0, + bottom: 20, + right: 0, + left: 0, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -115,10 +115,10 @@ class _UpdatePhaseStepperState extends State { Visibility( visible: _lastCompletedStep == UpdatePhaseStep.updatePhase, child: Positioned( - right: 50.0, + right: 50, child: SizedBox( - width: 400.0, - height: 400.0, + width: 400, + height: 400, child: Center( child: Lottie.asset( 'assets/lottie/ic_anim_zts.json', @@ -165,7 +165,7 @@ class _UpdatePhaseStepperState extends State { } custom_material_stepper.StepState _getStepState(UpdatePhaseStep step) { - int stepIndex = step.index; + final stepIndex = step.index; return stepIndex <= (_lastCompletedStep?.index ?? -1) ? custom_material_stepper.StepState.complete : custom_material_stepper.StepState.indexed; @@ -304,7 +304,7 @@ class _UpdatePhaseStepperState extends State { }, ), const SizedBox( - width: 15.0, + width: 15, ), StepperButton( text: 'Continue', @@ -343,7 +343,7 @@ class _UpdatePhaseStepperState extends State { text: 'Go back', ), const SizedBox( - width: 15.0, + width: 15, ), _getUpdatePhaseViewModel(), ], @@ -424,7 +424,7 @@ class _UpdatePhaseStepperState extends State { return _getUpdatePhaseButton(model); }, ), - viewModelBuilder: () => UpdatePhaseBloc(), + viewModelBuilder: UpdatePhaseBloc.new, ); } diff --git a/lib/widgets/modular_widgets/dashboard_widgets/balance.dart b/lib/widgets/modular_widgets/dashboard_widgets/balance.dart index 060c7579..941b5069 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/balance.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/balance.dart @@ -35,14 +35,14 @@ class _BalanceWidgetState extends State { @override Widget build(BuildContext context) { return ViewModelBuilder.reactive( - viewModelBuilder: () => BalanceDashboardBloc(), + viewModelBuilder: BalanceDashboardBloc.new, onViewModelReady: (model) { model.getDataPeriodically(); }, builder: (_, model, __) => CardScaffold( description: _kWidgetDescription, childStream: model.stream, - onCompletedStatusCallback: (data) => _widgetBody(data), + onCompletedStatusCallback: _widgetBody, title: _kWidgetTitle, ), ); @@ -57,20 +57,17 @@ class _BalanceWidgetState extends State { alignment: Alignment.center, children: [ AspectRatio( - aspectRatio: 1.0, + aspectRatio: 1, child: StandardPieChart( - sectionsSpace: 0.0, sections: _getChartSection(accountInfo), onChartSectionTouched: (pieChartSection) { setState(() { _touchedTokenStandard = pieChartSection?.touchedSection?.title; }); - }), + },), ), - _touchedTokenStandard != null - ? _getBalance(accountInfo) - : Container(), + if (_touchedTokenStandard != null) _getBalance(accountInfo) else Container(), ], ), ), @@ -90,15 +87,15 @@ class _BalanceWidgetState extends State { decoration: BoxDecoration( color: _backgroundAddressColor, border: Border.all(color: _backgroundAddressColor!), - borderRadius: BorderRadius.circular(15.0), + borderRadius: BorderRadius.circular(15), ), padding: const EdgeInsets.symmetric( - vertical: 4.0, - horizontal: 8.0, + vertical: 4, + horizontal: 8, ), margin: const EdgeInsets.only( - bottom: 12.0, - top: 12.0, + bottom: 12, + top: 12, ), child: AutoSizeText.rich( TextSpan( @@ -132,7 +129,7 @@ class _BalanceWidgetState extends State { ), const Divider(), Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Row( children: [ Expanded( @@ -168,7 +165,7 @@ class _BalanceWidgetState extends State { } List _getChartSection(AccountInfo accountInfo) { - List sections = []; + final sections = []; if (accountInfo.znn()! > BigInt.zero) { sections.add( _getBalanceChartSection( @@ -190,10 +187,10 @@ class _BalanceWidgetState extends State { } Widget _getBalance(AccountInfo accountInfo) { - TokenStandard tokenStandard = TokenStandard.parse(_touchedTokenStandard!); + final tokenStandard = TokenStandard.parse(_touchedTokenStandard!); return SizedBox( - width: 120.0, + width: 120, child: AutoSizeText( '${accountInfo.getBalance( tokenStandard, @@ -212,15 +209,15 @@ class _BalanceWidgetState extends State { AccountInfo accountInfo, ) { final isTouched = token.symbol == _touchedTokenStandard; - final double opacity = isTouched ? 1.0 : 0.7; + final opacity = isTouched ? 1.0 : 0.7; - double value = accountInfo.getBalance(token.tokenStandard) / + final value = accountInfo.getBalance(token.tokenStandard) / (accountInfo.znn()! + accountInfo.qsr()!); return PieChartSectionData( title: token.tokenStandard.toString(), showTitle: false, - radius: 7.0, + radius: 7, color: ColorUtils.getTokenColor(token.tokenStandard).withOpacity(opacity), value: value, ); diff --git a/lib/widgets/modular_widgets/dashboard_widgets/delegation_stats.dart b/lib/widgets/modular_widgets/dashboard_widgets/delegation_stats.dart index 36c3a912..9aeb1239 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/delegation_stats.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/delegation_stats.dart @@ -21,13 +21,13 @@ class _DelegationStatsState extends State { @override Widget build(BuildContext context) { return ViewModelBuilder.reactive( - viewModelBuilder: () => DelegationBloc(), + viewModelBuilder: DelegationBloc.new, onViewModelReady: (model) { model.getDataPeriodically(); }, builder: (_, model, __) => CardScaffold( childStream: model.stream, - onCompletedStatusCallback: (data) => _getWidgetBody(data), + onCompletedStatusCallback: _getWidgetBody, title: _kWidgetTitle, description: _kWidgetDescription, ), @@ -39,9 +39,9 @@ class _DelegationStatsState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Container( - padding: const EdgeInsets.all(8.0), - width: 36.0, - height: 36.0, + padding: const EdgeInsets.all(8), + width: 36, + height: 36, decoration: BoxDecoration( shape: BoxShape.circle, border: Border.all( @@ -52,17 +52,17 @@ class _DelegationStatsState extends State { ), child: Icon( SimpleLineIcons.trophy, - size: 12.0, + size: 12, color: Theme.of(context).textTheme.bodyLarge!.color, ), ), - Container(width: 16.0), + Container(width: 16), Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - delegationInfo.name.toString(), + delegationInfo.name, style: Theme.of(context).textTheme.bodyMedium, ), Text( diff --git a/lib/widgets/modular_widgets/dashboard_widgets/dual_coin_stats.dart b/lib/widgets/modular_widgets/dashboard_widgets/dual_coin_stats.dart index 78484d29..cf9e89d0 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/dual_coin_stats.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/dual_coin_stats.dart @@ -28,14 +28,14 @@ class _DualCoinStatsState extends State @override Widget build(BuildContext context) { return ViewModelBuilder.reactive( - viewModelBuilder: () => DualCoinStatsBloc(), + viewModelBuilder: DualCoinStatsBloc.new, onViewModelReady: (model) { model.getDataPeriodically(); }, builder: (_, model, __) => CardScaffold>( description: _kWidgetDescription, childStream: model.stream, - onCompletedStatusCallback: (data) => _getWidgetBody(data), + onCompletedStatusCallback: _getWidgetBody, title: _kWidgetTitle, ), ); @@ -46,10 +46,10 @@ class _DualCoinStatsState extends State children: [ Expanded( child: AspectRatio( - aspectRatio: 1.0, + aspectRatio: 1, child: StandardPieChart( - sectionsSpace: 4.0, - centerSpaceRadius: 0.0, + sectionsSpace: 4, + centerSpaceRadius: 0, sections: showingSections(tokenList), onChartSectionTouched: (pieTouchedSection) { setState(() { @@ -61,7 +61,7 @@ class _DualCoinStatsState extends State ), const Divider(), Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ @@ -93,22 +93,22 @@ class _DualCoinStatsState extends State } List showingSections(List tokenList) { - BigInt totalSupply = tokenList.fold( + final totalSupply = tokenList.fold( BigInt.zero, (previousValue, element) => previousValue + element!.totalSupply, ); return List.generate( tokenList.length, (i) { - Token currentTokenInfo = tokenList[i]!; + final currentTokenInfo = tokenList[i]!; final isTouched = i == _touchedIndex; - final double opacity = isTouched ? 1.0 : 0.5; + final opacity = isTouched ? 1.0 : 0.5; return PieChartSectionData( color: ColorUtils.getTokenColor(currentTokenInfo.tokenStandard) .withOpacity(opacity), value: currentTokenInfo.totalSupply / totalSupply, title: currentTokenInfo.symbol, - radius: 60.0, + radius: 60, titleStyle: Theme.of(context).textTheme.titleSmall!.copyWith( color: Colors.white, ), diff --git a/lib/widgets/modular_widgets/dashboard_widgets/pillars.dart b/lib/widgets/modular_widgets/dashboard_widgets/pillars.dart index 21dd2595..fd885a33 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/pillars.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/pillars.dart @@ -21,26 +21,26 @@ class _PillarsState extends State { @override Widget build(BuildContext context) { return ViewModelBuilder.reactive( - viewModelBuilder: () => PillarsBloc(), + viewModelBuilder: PillarsBloc.new, onViewModelReady: (model) { model.getDataPeriodically(); }, builder: (_, model, __) => CardScaffold( childStream: model.stream, - onCompletedStatusCallback: (data) => _widgetBody(data), + onCompletedStatusCallback: _widgetBody, title: _kWidgetTitle, description: _kWidgetDescription, ), ); } - _widgetBody(int numOfPillars) { + Row _widgetBody(int numOfPillars) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ SvgPicture.asset( 'assets/svg/ic_pillars_dashboard.svg', - width: 65.0, + width: 65, ), Column( mainAxisAlignment: MainAxisAlignment.center, diff --git a/lib/widgets/modular_widgets/dashboard_widgets/plasma_stats.dart b/lib/widgets/modular_widgets/dashboard_widgets/plasma_stats.dart index d6851a0b..c4331305 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/plasma_stats.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/plasma_stats.dart @@ -25,12 +25,12 @@ final String _kWidgetDescription = 'This card displays information about ' enum PlasmaStatsWidgetVersion { dashboardTab, plasmaTab } class PlasmaStats extends StatefulWidget { - final PlasmaStatsWidgetVersion version; const PlasmaStats({ this.version = PlasmaStatsWidgetVersion.dashboardTab, super.key, }); + final PlasmaStatsWidgetVersion version; @override State createState() => _PlasmaStatsState(); @@ -54,7 +54,7 @@ class _PlasmaStatsState extends State { title: kPlasmaStatsWidgetTitle, description: _kWidgetDescription, childStream: sl.get().stream, - onCompletedStatusCallback: (data) => _getTable(data), + onCompletedStatusCallback: _getTable, onRefreshPressed: widget.version == PlasmaStatsWidgetVersion.plasmaTab ? () => sl.get().getPlasmas() : null, @@ -82,18 +82,14 @@ class _PlasmaStatsState extends State { : null, generateRowCells: (plasmaStatsWrapper, isSelected) { return [ - widget.version == PlasmaStatsWidgetVersion.plasmaTab - ? isSelected + if (widget.version == PlasmaStatsWidgetVersion.plasmaTab) isSelected ? CustomTableCell.tooltipWithMarquee( Address.parse(plasmaStatsWrapper.address), - flex: 1, ) : CustomTableCell.tooltipWithText( context, Address.parse(plasmaStatsWrapper.address), - flex: 1, - ) - : isSelected + ) else isSelected ? CustomTableCell.tooltipWithMarquee( Address.parse(plasmaStatsWrapper.address), flex: 2, @@ -126,7 +122,6 @@ class _PlasmaStatsState extends State { _sortAscending ? _addresses.sort((a, b) => a.compareTo(b)) : _addresses.sort((a, b) => b.compareTo(a)); - break; default: _sortAscending diff --git a/lib/widgets/modular_widgets/dashboard_widgets/realtime_statistics.dart b/lib/widgets/modular_widgets/dashboard_widgets/realtime_statistics.dart index 6f20edc1..7d5411f0 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/realtime_statistics.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/realtime_statistics.dart @@ -10,7 +10,7 @@ const String _kWidgetTitle = 'Realtime Stats'; final String _kWidgetDescription = 'This card displays the number of ${kZnnCoin.symbol} and ' '${kQsrCoin.symbol} transactions. For example, a delegation is considered a ' - '${kZnnCoin.symbol} transaction from the network\'s perspective. Every interaction ' + "${kZnnCoin.symbol} transaction from the network's perspective. Every interaction " 'with the network embedded contracts is internally considered a transaction'; class RealtimeStatistics extends StatefulWidget { @@ -24,7 +24,7 @@ class _RealtimeStatisticsState extends State { @override Widget build(BuildContext context) { return ViewModelBuilder.reactive( - viewModelBuilder: () => RealtimeStatisticsBloc(), + viewModelBuilder: RealtimeStatisticsBloc.new, onViewModelReady: (model) { model.getDataPeriodically(); }, @@ -32,14 +32,14 @@ class _RealtimeStatisticsState extends State { childStream: model.stream, title: _kWidgetTitle, description: _kWidgetDescription, - onCompletedStatusCallback: (data) => _widgetBody(data), + onCompletedStatusCallback: _widgetBody, ), ); } Widget _widgetBody(List list) { return Padding( - padding: const EdgeInsets.all(16.0), + padding: const EdgeInsets.all(16), child: Column(children: [ Row( mainAxisAlignment: MainAxisAlignment.center, @@ -50,7 +50,7 @@ class _RealtimeStatisticsState extends State { 'transactions', ), const SizedBox( - width: 10.0, + width: 10, ), ChartLegend( dotColor: ColorUtils.getTokenColor(kZnnCoin.tokenStandard), @@ -60,7 +60,7 @@ class _RealtimeStatisticsState extends State { ], ), Expanded(child: RealtimeTxsChart(list)), - ]), + ],), ); } } diff --git a/lib/widgets/modular_widgets/dashboard_widgets/sentinels.dart b/lib/widgets/modular_widgets/dashboard_widgets/sentinels.dart index 36bdd0c4..f9edb63d 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/sentinels.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/sentinels.dart @@ -20,13 +20,13 @@ class _SentinelsState extends State { @override Widget build(BuildContext context) { return ViewModelBuilder.reactive( - viewModelBuilder: () => SentinelsBloc(), + viewModelBuilder: SentinelsBloc.new, onViewModelReady: (model) { model.getDataPeriodically(); }, builder: (_, model, __) => CardScaffold>( childStream: model.stream, - onCompletedStatusCallback: (data) => _getWidgetBody(data), + onCompletedStatusCallback: _getWidgetBody, title: _kWidgetTitle, description: _kWidgetDescription, ), @@ -38,10 +38,10 @@ class _SentinelsState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( - padding: const EdgeInsets.all(12.0), + padding: const EdgeInsets.all(12), child: SvgPicture.asset( 'assets/svg/ic_sentinels_dashboard.svg', - width: 42.0, + width: 42, ), ), Column( diff --git a/lib/widgets/modular_widgets/dashboard_widgets/staking.dart b/lib/widgets/modular_widgets/dashboard_widgets/staking.dart index 9f4fec07..c68a7a7a 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/staking.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/staking.dart @@ -21,13 +21,13 @@ class _StakingState extends State { @override Widget build(BuildContext context) { return ViewModelBuilder.reactive( - viewModelBuilder: () => StakingBloc(), + viewModelBuilder: StakingBloc.new, onViewModelReady: (model) { model.getDataPeriodically(); }, builder: (_, model, __) => CardScaffold( childStream: model.stream, - onCompletedStatusCallback: (data) => _widgetBody(data), + onCompletedStatusCallback: _widgetBody, title: _kWidgetTitle, description: _kWidgetDescription, ), @@ -39,9 +39,9 @@ class _StakingState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Container( - padding: const EdgeInsets.all(8.0), - width: 36.0, - height: 36.0, + padding: const EdgeInsets.all(8), + width: 36, + height: 36, decoration: BoxDecoration( shape: BoxShape.circle, border: Border.all( @@ -50,11 +50,11 @@ class _StakingState extends State { ), child: Icon( SimpleLineIcons.energy, - size: 12.0, + size: 12, color: Theme.of(context).textTheme.bodyLarge!.color, ), ), - Container(width: 16.0), + Container(width: 16), Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/widgets/modular_widgets/dashboard_widgets/total_hourly_transactions.dart b/lib/widgets/modular_widgets/dashboard_widgets/total_hourly_transactions.dart index f300563f..fa554bb5 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/total_hourly_transactions.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/total_hourly_transactions.dart @@ -20,13 +20,13 @@ class _TotalHourlyTransactionsState extends State { @override Widget build(BuildContext context) { return ViewModelBuilder.reactive( - viewModelBuilder: () => TotalHourlyTransactionsBloc(), + viewModelBuilder: TotalHourlyTransactionsBloc.new, onViewModelReady: (model) { model.getDataPeriodically(); }, builder: (_, model, __) => CardScaffold>( childStream: model.stream, - onCompletedStatusCallback: (data) => _getWidgetBody(data), + onCompletedStatusCallback: _getWidgetBody, title: _kWidgetTitle, description: _kWidgetDescription, ), @@ -41,7 +41,7 @@ class _TotalHourlyTransactionsState extends State { end: widgetData['numAccountBlocks'], isInt: true, style: Theme.of(context).textTheme.headlineLarge!.copyWith( - fontSize: 30.0, + fontSize: 30, ), ), kVerticalSpacing, diff --git a/lib/widgets/modular_widgets/dashboard_widgets/transfer.dart b/lib/widgets/modular_widgets/dashboard_widgets/transfer.dart index 2ebb3073..57d99ccc 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/transfer.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/transfer.dart @@ -9,16 +9,16 @@ const String _kWidgetDescription = 'can manage sending and receiving funds'; class Transfer extends StatefulWidget { - final Function( - Tabs, { - bool redirectWithSendContainerLarge, - bool redirectWithReceiveContainerLarge, - })? changePage; const Transfer({ super.key, this.changePage, }); + final Function( + Tabs, { + bool redirectWithSendContainerLarge, + bool redirectWithReceiveContainerLarge, + })? changePage; @override State createState() => _TransferState(); @@ -30,7 +30,7 @@ class _TransferState extends State { return CardScaffold( title: _kWidgetTitle, description: _kWidgetDescription, - childBuilder: () => _getTransferButtons(), + childBuilder: _getTransferButtons, ); } @@ -39,30 +39,30 @@ class _TransferState extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ IconButton( - splashRadius: 30.0, + splashRadius: 30, onPressed: () { widget.changePage!(Tabs.transfer, - redirectWithSendContainerLarge: true); + redirectWithSendContainerLarge: true,); }, icon: const Icon( SimpleLineIcons.arrow_up_circle, ), color: AppColors.darkHintTextColor, - iconSize: 48.0, + iconSize: 48, ), const TransferIconLegend( legendText: '● Send', ), IconButton( - splashRadius: 30.0, + splashRadius: 30, onPressed: () { widget.changePage!(Tabs.transfer, - redirectWithReceiveContainerLarge: true); + redirectWithReceiveContainerLarge: true,); }, icon: const Icon( SimpleLineIcons.arrow_down_circle, ), - iconSize: 48.0, + iconSize: 48, color: AppColors.lightHintTextColor, ), const TransferIconLegend( diff --git a/lib/widgets/modular_widgets/help_widgets/about_card.dart b/lib/widgets/modular_widgets/help_widgets/about_card.dart index 94a95ebb..704d5ff9 100644 --- a/lib/widgets/modular_widgets/help_widgets/about_card.dart +++ b/lib/widgets/modular_widgets/help_widgets/about_card.dart @@ -32,7 +32,7 @@ class AboutCardState extends State { return CardScaffold( title: 'About', description: 'Detailed information about wallet components', - childBuilder: () => _getStreamBuilder(), + childBuilder: _getStreamBuilder, ); } @@ -47,7 +47,7 @@ class AboutCardState extends State { CustomExpandablePanel( 'Zenon Node chain identifier', _getGenericTextExpandedChild( - generalStats.frontierMomentum.chainIdentifier.toString()), + generalStats.frontierMomentum.chainIdentifier.toString(),), ), CustomExpandablePanel( 'Client chain identifier', @@ -108,22 +108,22 @@ class AboutCardState extends State { CustomExpandablePanel( 'Zenon main data path', _getGenericOpenButtonExpandedChild( - znnDefaultPaths.main.absolute.path), + znnDefaultPaths.main.absolute.path,), ), CustomExpandablePanel( 'Syrius cache path', _getGenericOpenButtonExpandedChild( - znnDefaultPaths.cache.absolute.path), + znnDefaultPaths.cache.absolute.path,), ), CustomExpandablePanel( 'Syrius wallet path', _getGenericOpenButtonExpandedChild( - znnDefaultPaths.wallet.absolute.path), + znnDefaultPaths.wallet.absolute.path,), ), CustomExpandablePanel( 'Syrius wallet type', _getGenericOpenButtonExpandedChild( - kWalletFile!.walletType), + kWalletFile!.walletType,), ), CustomExpandablePanel( 'Client hostname', @@ -152,15 +152,15 @@ class AboutCardState extends State { Widget _getGenericTextExpandedChild(String expandedText) { return Row(children: [ CustomTableCell.withMarquee( - expandedText.toString(), - ) - ]); + expandedText, + ), + ],); } Widget _getGenericLinkButtonExpandedChild(String url) { return Row(children: [ CustomTableCell.withMarquee( - url.toString(), + url, ), IconButton( splashRadius: 16, @@ -173,13 +173,13 @@ class AboutCardState extends State { color: AppColors.znnColor, ), ), - ]); + ],); } Widget _getGenericOpenButtonExpandedChild(String expandedText) { return Row(children: [ CustomTableCell.withMarquee( - expandedText.toString(), + expandedText, ), IconButton( splashRadius: 16, @@ -192,7 +192,7 @@ class AboutCardState extends State { color: AppColors.znnColor, ), ), - ]); + ],); } Widget _getStreamBuilder() { diff --git a/lib/widgets/modular_widgets/help_widgets/community_card.dart b/lib/widgets/modular_widgets/help_widgets/community_card.dart index e55977c8..4aefbda2 100644 --- a/lib/widgets/modular_widgets/help_widgets/community_card.dart +++ b/lib/widgets/modular_widgets/help_widgets/community_card.dart @@ -97,7 +97,7 @@ class CommunityCard extends StatelessWidget { title: 'Zenon Hub Explorer', url: kHubCommunityExplorer, context: context, - ) + ), ], ); } @@ -193,22 +193,21 @@ class CommunityCard extends StatelessWidget { required BuildContext context, }) { return Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ Icon( iconData, color: AppColors.znnColor, - size: 20.0, + size: 20, ), const SizedBox( - width: 10.0, + width: 10, ), Text( title, style: Theme.of(context).textTheme.titleMedium, ), const SizedBox( - width: 10.0, + width: 10, ), LinkIcon(url: url), ], diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/detail_row.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/detail_row.dart index f0596d5f..e50b2a26 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/detail_row.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/detail_row.dart @@ -3,11 +3,6 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart'; class DetailRow extends StatelessWidget { - final String label; - final String value; - final String? valueToShow; - final Widget? prefixWidget; - final bool canBeCopied; const DetailRow({ required this.label, @@ -17,6 +12,11 @@ class DetailRow extends StatelessWidget { this.canBeCopied = true, super.key, }); + final String label; + final String value; + final String? valueToShow; + final Widget? prefixWidget; + final bool canBeCopied; @override Widget build(BuildContext context) { @@ -25,28 +25,28 @@ class DetailRow extends StatelessWidget { children: [ Text(label, style: const TextStyle( - fontSize: 12.0, color: AppColors.subtitleColor)), + fontSize: 12, color: AppColors.subtitleColor,),), Row( children: [ prefixWidget ?? Container(), if (prefixWidget != null) const SizedBox( - width: 5.0, + width: 5, ), Text(valueToShow ?? value, style: const TextStyle( - fontSize: 12.0, color: AppColors.subtitleColor)), + fontSize: 12, color: AppColors.subtitleColor,),), Visibility( visible: canBeCopied, child: CopyToClipboardIcon( value, iconColor: AppColors.subtitleColor, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - padding: const EdgeInsets.only(left: 8.0), + padding: const EdgeInsets.only(left: 8), ), ), ], - ) + ), ], ); } diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_card.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_card.dart index 33f5c067..3e29b97c 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_card.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_card.dart @@ -14,16 +14,6 @@ import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_inf import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class HtlcCard extends StatefulWidget { - final String title; - final String sender; - final String? htlcId; - final String? hashLock; - final int? expirationTime; - final String? recipient; - final BigInt? amount; - final String? tokenStandard; - final int? tokenDecimals; - final String? tokenSymbol; const HtlcCard({ required this.title, @@ -96,6 +86,16 @@ class HtlcCard extends StatefulWidget { tokenDecimals: token.decimals, tokenSymbol: token.symbol, ); + final String title; + final String sender; + final String? htlcId; + final String? hashLock; + final int? expirationTime; + final String? recipient; + final BigInt? amount; + final String? tokenStandard; + final int? tokenDecimals; + final String? tokenSymbol; @override State createState() => _HtlcCardState(); @@ -127,7 +127,7 @@ class _HtlcCardState extends State child: Container( decoration: BoxDecoration( color: Theme.of(context).colorScheme.primary, - borderRadius: const BorderRadius.all(Radius.circular(8.0)), + borderRadius: const BorderRadius.all(Radius.circular(8)), ), child: widget.htlcId == null ? _getWaitingBody() : _getWidgetBody(), ), @@ -136,7 +136,7 @@ class _HtlcCardState extends State Widget _getWaitingBody() { return const SizedBox( - height: 94.0, + height: 94, child: LoadingInfoText( text: 'Waiting for the counterparty to join the swap.', ), @@ -145,14 +145,14 @@ class _HtlcCardState extends State Widget _getWidgetBody() { return Padding( - padding: const EdgeInsets.all(20.0), + padding: const EdgeInsets.all(20), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Text( widget.title, style: - const TextStyle(fontSize: 14.0, color: AppColors.subtitleColor), + const TextStyle(fontSize: 14, color: AppColors.subtitleColor), ), const SizedBox( height: 10, @@ -167,7 +167,7 @@ class _HtlcCardState extends State constraints: const BoxConstraints(maxWidth: 280), child: Text( widget.amount!.addDecimals(widget.tokenDecimals!), - style: const TextStyle(fontSize: 18.0), + style: const TextStyle(fontSize: 18), overflow: TextOverflow.ellipsis, maxLines: 1, softWrap: false, @@ -177,27 +177,27 @@ class _HtlcCardState extends State constraints: const BoxConstraints(maxWidth: 150), child: Text( ' ${widget.tokenSymbol!}', - style: const TextStyle(fontSize: 18.0), + style: const TextStyle(fontSize: 18), overflow: TextOverflow.ellipsis, maxLines: 1, softWrap: false, ), ), const SizedBox( - width: 8.0, + width: 8, ), Container( - height: 6.0, - width: 6.0, + height: 6, + width: 6, decoration: BoxDecoration( shape: BoxShape.circle, color: ColorUtils.getTokenColor( - TokenStandard.parse(widget.tokenStandard!)), + TokenStandard.parse(widget.tokenStandard!),), ), ), ], ), - _getDetailsButton() + _getDetailsButton(), ], ), _getDetailsSection(), @@ -217,8 +217,8 @@ class _HtlcCardState extends State }); }, child: RotationTransition( - turns: Tween(begin: 0.0, end: 0.5).animate(_animationController), - child: const Icon(Icons.keyboard_arrow_down, size: 22.0), + turns: Tween(begin: 0, end: 0.5).animate(_animationController), + child: const Icon(Icons.keyboard_arrow_down, size: 22), ), ); } @@ -231,9 +231,9 @@ class _HtlcCardState extends State visible: _areDetailsExpanded, child: Column( children: [ - const SizedBox(height: 20.0), + const SizedBox(height: 20), Divider(color: Colors.white.withOpacity(0.1)), - const SizedBox(height: 20.0), + const SizedBox(height: 20), _getDetailsList(), ], ), @@ -242,7 +242,7 @@ class _HtlcCardState extends State } Widget _getDetailsList() { - final List children = []; + final children = []; final htlcId = Hash.parse(widget.htlcId!); final hashLock = Hash.parse(widget.hashLock!); children.add(_getExpirationRow(widget.expirationTime!)); @@ -250,7 +250,7 @@ class _HtlcCardState extends State DetailRow( label: 'Deposit ID', value: htlcId.toString(), - valueToShow: htlcId.toShortString()), + valueToShow: htlcId.toShortString(),), ); children.add( DetailRow( @@ -263,26 +263,26 @@ class _HtlcCardState extends State DetailRow( label: 'Sender', value: widget.sender, - valueToShow: ZenonAddressUtils.getLabel(widget.sender)), + valueToShow: ZenonAddressUtils.getLabel(widget.sender),), ); children.add( DetailRow( label: 'Recipient', value: widget.recipient!, - valueToShow: ZenonAddressUtils.getLabel(widget.recipient!)), + valueToShow: ZenonAddressUtils.getLabel(widget.recipient!),), ); children.add( DetailRow( label: 'Hashlock', value: hashLock.toString(), - valueToShow: hashLock.toShortString()), + valueToShow: hashLock.toShortString(),), ); return Column( children: children.zip( List.generate( children.length - 1, (index) => const SizedBox( - height: 15.0, + height: 15, ), ), ), @@ -305,11 +305,11 @@ class _HtlcCardState extends State return Tooltip( message: message, child: Padding( - padding: const EdgeInsets.only(top: 1.0), + padding: const EdgeInsets.only(top: 1), child: Icon( icon, color: iconColor, - size: 14.0, + size: 14, ), ), ); @@ -320,7 +320,7 @@ class _HtlcCardState extends State Duration(seconds: expirationTime - DateTimeUtils.unixTimeNow); if (duration.isNegative) { return const DetailRow( - label: 'Expires in', value: 'Expired', canBeCopied: false); + label: 'Expires in', value: 'Expired', canBeCopied: false,); } return TweenAnimationBuilder( duration: duration, @@ -329,7 +329,7 @@ class _HtlcCardState extends State return DetailRow( label: 'Expires in', value: d.toString().split('.').first, - canBeCopied: false); + canBeCopied: false,); }, ); } diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_swap_details_widget.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_swap_details_widget.dart index 9c1ba80a..15c80cda 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_swap_details_widget.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_swap_details_widget.dart @@ -8,12 +8,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/p2p_swap_wid import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class HtlcSwapDetailsWidget extends StatefulWidget { - final HtlcSwap swap; const HtlcSwapDetailsWidget({ required this.swap, super.key, }); + final HtlcSwap swap; @override State createState() => _HtlcSwapDetailsWidgetState(); @@ -53,7 +53,7 @@ class _HtlcSwapDetailsWidgetState extends State }); }, child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0), + padding: const EdgeInsets.symmetric(horizontal: 10), child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, @@ -61,17 +61,17 @@ class _HtlcSwapDetailsWidgetState extends State Text( _isExpanded ? 'Hide details' : 'Show details', style: const TextStyle( - fontSize: 14.0, + fontSize: 14, color: AppColors.subtitleColor, ), ), const SizedBox( - width: 3.0, + width: 3, ), RotationTransition( turns: - Tween(begin: 0.0, end: 0.5).animate(_animationController), - child: const Icon(Icons.keyboard_arrow_down, size: 18.0), + Tween(begin: 0, end: 0.5).animate(_animationController), + child: const Icon(Icons.keyboard_arrow_down, size: 18), ), ], ), @@ -84,10 +84,10 @@ class _HtlcSwapDetailsWidgetState extends State visible: _isExpanded, child: Column( children: [ - const SizedBox(height: 20.0), + const SizedBox(height: 20), Divider(color: Colors.white.withOpacity(0.1)), - const SizedBox(height: 20.0), - _getDetailsList(widget.swap) + const SizedBox(height: 20), + _getDetailsList(widget.swap), ], ), ), @@ -97,7 +97,7 @@ class _HtlcSwapDetailsWidgetState extends State } Widget _getDetailsList(HtlcSwap swap) { - final List children = []; + final children = []; final yourDepositId = swap.direction == P2pSwapDirection.outgoing ? swap.initialHtlcId : swap.counterHtlcId!; @@ -138,7 +138,7 @@ class _HtlcSwapDetailsWidgetState extends State DetailRow( label: 'Hashlock', value: swap.hashLock, - valueToShow: Hash.parse(swap.hashLock).toShortString()), + valueToShow: Hash.parse(swap.hashLock).toShortString(),), ); if (swap.preimage != null) { children.add( @@ -155,7 +155,7 @@ class _HtlcSwapDetailsWidgetState extends State List.generate( children.length - 1, (index) => const SizedBox( - height: 15.0, + height: 15, ), ), ), diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/join_native_swap_modal.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/join_native_swap_modal.dart index 9be18dc7..7562449c 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/join_native_swap_modal.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/join_native_swap_modal.dart @@ -28,12 +28,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/modals/base import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class JoinNativeSwapModal extends StatefulWidget { - final Function(String) onJoinedSwap; const JoinNativeSwapModal({ required this.onJoinedSwap, super.key, }); + final Function(String) onJoinedSwap; @override State createState() => _JoinNativeSwapModalState(); @@ -88,14 +88,14 @@ class _JoinNativeSwapModalState extends State { builder: (_, snapshot) { if (snapshot.hasError) { return Padding( - padding: const EdgeInsets.all(20.0), + padding: const EdgeInsets.all(20), child: SyriusErrorWidget(snapshot.error!), ); } else if (snapshot.hasData) { return _getContent(snapshot.data!); } return const Padding( - padding: EdgeInsets.all(50.0), + padding: EdgeInsets.all(50), child: SyriusLoadingWidget(), ); }, @@ -107,7 +107,7 @@ class _JoinNativeSwapModalState extends State { return Column( children: [ const SizedBox( - height: 20.0, + height: 20, ), Form( autovalidateMode: AutovalidateMode.onUserInteraction, @@ -115,7 +115,7 @@ class _JoinNativeSwapModalState extends State { onChanged: (value) { setState(() {}); }, - validator: (value) => InputValidators.checkHash(value), + validator: InputValidators.checkHash, controller: _depositIdController, suffixIcon: RawMaterialButton( shape: const CircleBorder(), @@ -129,19 +129,19 @@ class _JoinNativeSwapModalState extends State { child: const Icon( Icons.content_paste, color: AppColors.darkHintTextColor, - size: 15.0, + size: 15, ), ), suffixIconConstraints: const BoxConstraints( - maxWidth: 45.0, - maxHeight: 20.0, + maxWidth: 45, + maxHeight: 20, ), hintText: 'Deposit ID provided by the counterparty', - contentLeftPadding: 10.0, + contentLeftPadding: 10, ), ), const SizedBox( - height: 25.0, + height: 25, ), Visibility( visible: _initialHtlcError != null, @@ -152,7 +152,7 @@ class _JoinNativeSwapModalState extends State { showBorder: true, ), const SizedBox( - height: 20.0, + height: 20, ), ], ), @@ -162,7 +162,7 @@ class _JoinNativeSwapModalState extends State { ); } - _getInitialHtlcViewModel() { + ViewModelBuilder _getInitialHtlcViewModel() { return ViewModelBuilder.reactive( onViewModelReady: (model) { model.stream.listen( @@ -187,7 +187,7 @@ class _JoinNativeSwapModalState extends State { ); }, builder: (_, model, __) => _getContinueButton(model), - viewModelBuilder: () => InitialHtlcForSwapBloc(), + viewModelBuilder: InitialHtlcForSwapBloc.new, ); } @@ -202,7 +202,7 @@ class _JoinNativeSwapModalState extends State { ); } - void _onContinueButtonPressed(InitialHtlcForSwapBloc model) async { + Future _onContinueButtonPressed(InitialHtlcForSwapBloc model) async { setState(() { _isLoading = true; _initialHtlcError = null; @@ -215,7 +215,7 @@ class _JoinNativeSwapModalState extends State { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - const SizedBox(height: 20.0), + const SizedBox(height: 20), Row( children: [ Expanded( @@ -224,15 +224,15 @@ class _JoinNativeSwapModalState extends State { helpText: 'You will receive the swapped funds to this address.', inputWidget: DisabledAddressField( _addressController, - contentLeftPadding: 10.0, + contentLeftPadding: 10, ), ), ), ], ), - const SizedBox(height: 20.0), + const SizedBox(height: 20), Divider(color: Colors.white.withOpacity(0.1)), - const SizedBox(height: 20.0), + const SizedBox(height: 20), LabeledInputContainer( labelText: 'You are sending', inputWidget: Flexible( @@ -246,8 +246,8 @@ class _JoinNativeSwapModalState extends State { if (snapshot.hasData) { return AmountInputField( controller: _amountController, - accountInfo: (snapshot.data![_selfAddress]!), - valuePadding: 10.0, + accountInfo: snapshot.data![_selfAddress]!, + valuePadding: 10, textColor: Theme.of(context).colorScheme.inverseSurface, initialToken: _selectedToken, hintText: '0.0', @@ -280,24 +280,24 @@ class _JoinNativeSwapModalState extends State { htlc: _initialHltc!, token: tokenToReceive, ), - const SizedBox(height: 20.0), + const SizedBox(height: 20), Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0), + padding: const EdgeInsets.symmetric(horizontal: 10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const Text( 'Exchange Rate', style: - TextStyle(fontSize: 14.0, color: AppColors.subtitleColor), + TextStyle(fontSize: 14, color: AppColors.subtitleColor), ), _getExchangeRateWidget(tokenToReceive), ], ), ), - const SizedBox(height: 20.0), + const SizedBox(height: 20), Divider(color: Colors.white.withOpacity(0.1)), - if (_safeExpirationTime != null) const SizedBox(height: 20.0), + if (_safeExpirationTime != null) const SizedBox(height: 20), if (_safeExpirationTime != null) BulletPointCard( bulletPoints: [ @@ -309,7 +309,7 @@ class _JoinNativeSwapModalState extends State { text: '${(((_initialHltc!.expirationTime - kMinSafeTimeToFindPreimage.inSeconds - kCounterHtlcDuration.inSeconds) - DateTimeUtils.unixTimeNow) / 60).ceil()} minutes', style: const TextStyle( - fontSize: 14.0, color: Colors.white)), + fontSize: 14, color: Colors.white,),), BulletPointCard.textSpan(' left to join the swap.'), ], ), @@ -319,9 +319,9 @@ class _JoinNativeSwapModalState extends State { 'The counterparty will have ', children: [ TextSpan( - text: '~${(kCounterHtlcDuration).inHours} hour', + text: '~${kCounterHtlcDuration.inHours} hour', style: const TextStyle( - fontSize: 14.0, color: Colors.white)), + fontSize: 14, color: Colors.white,),), BulletPointCard.textSpan(' to complete the swap.'), ], ), @@ -333,40 +333,38 @@ class _JoinNativeSwapModalState extends State { ), ], ), - const SizedBox(height: 20.0), - _safeExpirationTime != null - ? Column(children: [ + const SizedBox(height: 20), + if (_safeExpirationTime != null) Column(children: [ Visibility( visible: !isTrustedToken(tokenToReceive.tokenStandard.toString()), child: Padding( - padding: const EdgeInsets.only(bottom: 20.0), + padding: const EdgeInsets.only(bottom: 20), child: ImportantTextContainer( text: '''You are receiving a token that is not in your favorites. ''' - '''Please verify that the token standard is correct: ${tokenToReceive.tokenStandard.toString()}''', + '''Please verify that the token standard is correct: ${tokenToReceive.tokenStandard}''', isSelectable: true, ), ), ), _getJoinSwapViewModel(tokenToReceive), - ]) - : const ImportantTextContainer( + ],) else const ImportantTextContainer( text: 'Cannot join swap. The swap will expire too soon for a safe swap.', showBorder: true, - ) + ), ], ); } - _getJoinSwapViewModel(Token tokenToReceive) { + ViewModelBuilder _getJoinSwapViewModel(Token tokenToReceive) { return ViewModelBuilder.reactive( onViewModelReady: (model) { model.stream.listen( (event) async { if (event is HtlcSwap) { - widget.onJoinedSwap.call(event.id.toString()); + widget.onJoinedSwap.call(event.id); } }, onError: (error) { @@ -378,7 +376,7 @@ class _JoinNativeSwapModalState extends State { ); }, builder: (_, model, __) => _getJoinSwapButton(model, tokenToReceive), - viewModelBuilder: () => JoinHtlcSwapBloc(), + viewModelBuilder: JoinHtlcSwapBloc.new, ); } @@ -393,8 +391,8 @@ class _JoinNativeSwapModalState extends State { ); } - void _onJoinButtonPressed( - JoinHtlcSwapBloc model, Token tokenToReceive) async { + Future _onJoinButtonPressed( + JoinHtlcSwapBloc model, Token tokenToReceive,) async { setState(() { _isLoading = true; }); @@ -407,7 +405,7 @@ class _JoinNativeSwapModalState extends State { swapType: P2pSwapType.native, fromChain: P2pSwapChain.nom, toChain: P2pSwapChain.nom, - counterHtlcExpirationTime: _safeExpirationTime!); + counterHtlcExpirationTime: _safeExpirationTime!,); } int? _calculateSafeExpirationTime(int initialHtlcExpiration) { @@ -428,7 +426,7 @@ class _JoinNativeSwapModalState extends State { fromSymbol: _selectedToken.symbol, toAmount: _initialHltc!.amount, toDecimals: tokenToReceive.decimals, - toSymbol: tokenToReceive.symbol); + toSymbol: tokenToReceive.symbol,); } bool _isInputValid() => _isAmountValid; diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/native_p2p_swap_modal.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/native_p2p_swap_modal.dart index 7426428e..b4f00c3f 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/native_p2p_swap_modal.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/native_p2p_swap_modal.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/p2p_swap/htlc_swap/reclaim_htlc_swap_funds_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/p2p_swap/htlc_swap/complete_htlc_swap_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/p2p_swap/htlc_swap/htlc_swap_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/p2p_swap/htlc_swap/reclaim_htlc_swap_funds_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/model/p2p_swap/htlc_swap.dart'; import 'package:zenon_syrius_wallet_flutter/model/p2p_swap/p2p_swap.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; @@ -21,14 +21,14 @@ import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/modals/base import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class NativeP2pSwapModal extends StatefulWidget { - final String swapId; - final Function(String)? onSwapStarted; const NativeP2pSwapModal({ required this.swapId, this.onSwapStarted, super.key, }); + final String swapId; + final Function(String)? onSwapStarted; @override State createState() => _NativeP2pSwapModalState(); @@ -69,7 +69,7 @@ class _NativeP2pSwapModalState extends State { return BaseModal( title: '', child: Padding( - padding: const EdgeInsets.all(20.0), + padding: const EdgeInsets.all(20), child: SyriusErrorWidget(snapshot.error!), ), ); @@ -101,18 +101,18 @@ class _NativeP2pSwapModalState extends State { Widget _getPendingView() { return const SizedBox( - height: 215.0, + height: 215, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Starting swap. This will take a moment.', style: TextStyle( - fontSize: 16.0, + fontSize: 16, ), ), - SizedBox(height: 25.0), - SyriusLoadingWidget() + SizedBox(height: 25), + SyriusLoadingWidget(), ], ), ); @@ -122,11 +122,11 @@ class _NativeP2pSwapModalState extends State { return Column( children: [ const SizedBox( - height: 20.0, + height: 20, ), HtlcCard.sending(swap: swap), const SizedBox( - height: 15.0, + height: 15, ), const Icon( AntDesign.arrowdown, @@ -134,7 +134,7 @@ class _NativeP2pSwapModalState extends State { size: 20, ), const SizedBox( - height: 15.0, + height: 15, ), HtlcCard.receiving(swap: swap), const SizedBox( @@ -150,11 +150,11 @@ class _NativeP2pSwapModalState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ const SizedBox( - height: 10.0, + height: 10, ), Container( - width: 72.0, - height: 72.0, + width: 72, + height: 72, color: Colors.transparent, child: SvgPicture.asset( 'assets/svg/ic_completed_symbol.svg', @@ -163,21 +163,21 @@ class _NativeP2pSwapModalState extends State { ), ), const SizedBox( - height: 30.0, + height: 30, ), Text( _swapCompletedText, style: const TextStyle( - fontSize: 16.0, + fontSize: 16, ), ), - const SizedBox(height: 25.0), + const SizedBox(height: 25), Container( decoration: const BoxDecoration( color: Color(0xff282828), - borderRadius: BorderRadius.all(Radius.circular(8.0))), + borderRadius: BorderRadius.all(Radius.circular(8)),), child: Padding( - padding: const EdgeInsets.all(20.0), + padding: const EdgeInsets.all(20), child: Column( children: [ Row( @@ -186,15 +186,15 @@ class _NativeP2pSwapModalState extends State { const Text( 'From', style: TextStyle( - fontSize: 14.0, color: AppColors.subtitleColor), + fontSize: 14, color: AppColors.subtitleColor,), ), _getAmountAndSymbolWidget( swap.fromAmount.addDecimals(swap.fromDecimals), - swap.fromSymbol), + swap.fromSymbol,), ], ), const SizedBox( - height: 15.0, + height: 15, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -202,15 +202,15 @@ class _NativeP2pSwapModalState extends State { const Text( 'To', style: TextStyle( - fontSize: 14.0, color: AppColors.subtitleColor), + fontSize: 14, color: AppColors.subtitleColor,), ), _getAmountAndSymbolWidget( swap.toAmount!.addDecimals(swap.toDecimals!), - swap.toSymbol!), + swap.toSymbol!,), ], ), const SizedBox( - height: 15.0, + height: 15, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -218,7 +218,7 @@ class _NativeP2pSwapModalState extends State { const Text( 'Exchange Rate', style: TextStyle( - fontSize: 14.0, color: AppColors.subtitleColor), + fontSize: 14, color: AppColors.subtitleColor,), ), _getExchangeRateWidget(swap), ], @@ -247,11 +247,11 @@ class _NativeP2pSwapModalState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ const SizedBox( - height: 10.0, + height: 10, ), Container( - width: 72.0, - height: 72.0, + width: 72, + height: 72, color: Colors.transparent, child: SvgPicture.asset( 'assets/svg/ic_unsuccessful_symbol.svg', @@ -260,24 +260,24 @@ class _NativeP2pSwapModalState extends State { ), ), const SizedBox( - height: 30.0, + height: 30, ), Text( isReclaimable || swap.state == P2pSwapState.unsuccessful ? 'The swap was unsuccessful.' : 'The swap was unsuccessful.\nPlease wait for your deposit to expire to reclaim your funds.', style: const TextStyle( - fontSize: 16.0, + fontSize: 16, ), textAlign: TextAlign.center, ), - const SizedBox(height: 25.0), + const SizedBox(height: 25), Container( decoration: BoxDecoration( color: Theme.of(context).colorScheme.primary, - borderRadius: const BorderRadius.all(Radius.circular(8.0))), + borderRadius: const BorderRadius.all(Radius.circular(8)),), child: Padding( - padding: const EdgeInsets.all(20.0), + padding: const EdgeInsets.all(20), child: Column( children: [ if (remainingDuration.inSeconds > 0) @@ -289,21 +289,21 @@ class _NativeP2pSwapModalState extends State { return Visibility( visible: d.inSeconds > 0, child: Padding( - padding: const EdgeInsets.only(bottom: 15.0), + padding: const EdgeInsets.only(bottom: 15), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const Text( 'Deposit expires in', style: TextStyle( - fontSize: 14.0, - color: AppColors.subtitleColor), + fontSize: 14, + color: AppColors.subtitleColor,), ), Text( d.toString().split('.').first, style: const TextStyle( - fontSize: 14.0, - color: AppColors.subtitleColor), + fontSize: 14, + color: AppColors.subtitleColor,), ), ], ), @@ -319,11 +319,11 @@ class _NativeP2pSwapModalState extends State { ? 'Deposited amount' : 'Deposited amount (reclaimed)', style: const TextStyle( - fontSize: 14.0, color: AppColors.subtitleColor), + fontSize: 14, color: AppColors.subtitleColor,), ), _getAmountAndSymbolWidget( swap.fromAmount.addDecimals(swap.fromDecimals), - swap.fromSymbol), + swap.fromSymbol,), ], ), ], @@ -332,7 +332,7 @@ class _NativeP2pSwapModalState extends State { ), if (isReclaimable) Padding( - padding: const EdgeInsets.fromLTRB(0.0, 20.0, 0.0, 5.0), + padding: const EdgeInsets.fromLTRB(0, 20, 0, 5), child: _getReclaimButton(swap), ), const SizedBox( @@ -348,12 +348,12 @@ class _NativeP2pSwapModalState extends State { return Column( children: [ const Padding( - padding: EdgeInsets.symmetric(horizontal: 10.0), + padding: EdgeInsets.symmetric(horizontal: 10), child: Text( 'Send your deposit ID to the counterparty via a messaging service so that they can join the swap.', textAlign: TextAlign.center, style: TextStyle( - fontSize: 16.0, + fontSize: 16, ), ), ), @@ -370,23 +370,23 @@ class _NativeP2pSwapModalState extends State { icon: const Icon( Icons.copy, color: Colors.white, - size: 18.0, + size: 18, ), - ) + ), ], ); } else { return Column( children: [ Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0), + padding: const EdgeInsets.symmetric(horizontal: 10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const Text( 'Exchange Rate', style: TextStyle( - fontSize: 14.0, + fontSize: 14, color: AppColors.subtitleColor, ), ), @@ -404,7 +404,7 @@ class _NativeP2pSwapModalState extends State { Visibility( visible: !isTrustedToken(swap.toTokenStandard ?? ''), child: Padding( - padding: const EdgeInsets.only(bottom: 25.0), + padding: const EdgeInsets.only(bottom: 25), child: ImportantTextContainer( text: '''You are receiving a token that is not in your favorites. ''' @@ -425,7 +425,7 @@ class _NativeP2pSwapModalState extends State { Visibility( visible: swap.direction == P2pSwapDirection.incoming, child: const Padding( - padding: EdgeInsets.symmetric(vertical: 15.0), + padding: EdgeInsets.symmetric(vertical: 15), child: LoadingInfoText( text: 'Waiting for the counterparty. Please keep Syrius running.', @@ -443,7 +443,7 @@ class _NativeP2pSwapModalState extends State { const warningThreshold = Duration(minutes: 10); final timeToCompleteSwap = Duration( seconds: - swap.counterHtlcExpirationTime! - DateTimeUtils.unixTimeNow) - + swap.counterHtlcExpirationTime! - DateTimeUtils.unixTimeNow,) - kMinSafeTimeToCompleteSwap; return TweenAnimationBuilder( duration: timeToCompleteSwap, @@ -453,7 +453,7 @@ class _NativeP2pSwapModalState extends State { return Visibility( visible: timeToCompleteSwap <= warningThreshold, child: Padding( - padding: const EdgeInsets.only(bottom: 25.0), + padding: const EdgeInsets.only(bottom: 25), child: ImportantTextContainer( text: 'The swap will expire in ${d.toString().split('.').first}', ), @@ -495,13 +495,13 @@ class _NativeP2pSwapModalState extends State { model.completeHtlcSwap(swap: swap); }, ), - viewModelBuilder: () => CompleteHtlcSwapBloc(), + viewModelBuilder: CompleteHtlcSwapBloc.new, ); } Widget _getIncorrectAmountButton(HtlcSwap swap) { return Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0), + padding: const EdgeInsets.symmetric(horizontal: 10), child: SizedBox( width: double.infinity, child: AnimatedCrossFade( @@ -513,9 +513,9 @@ class _NativeP2pSwapModalState extends State { }), child: const Center( child: Text( - 'I\'m receiving the wrong token or amount.', + "I'm receiving the wrong token or amount.", style: TextStyle( - fontSize: 14.0, + fontSize: 14, color: AppColors.subtitleColor, ), ), @@ -536,7 +536,7 @@ class _NativeP2pSwapModalState extends State { 'If the token or the amount you are receiving is not what you have agreed upon, wait until your deposit expires to reclaim your funds.\nYour deposit will expire at ${FormatUtils.formatDate(expirationTime * 1000, dateFormat: kDefaultDateTimeFormat)}.', textAlign: TextAlign.center, style: const TextStyle( - fontSize: 14.0, + fontSize: 14, ), ); } @@ -570,7 +570,7 @@ class _NativeP2pSwapModalState extends State { ); }, ), - viewModelBuilder: () => ReclaimHtlcSwapFundsBloc(), + viewModelBuilder: ReclaimHtlcSwapFundsBloc.new, ); } @@ -581,7 +581,7 @@ class _NativeP2pSwapModalState extends State { fromSymbol: swap.fromSymbol, toAmount: swap.toAmount!, toDecimals: swap.toDecimals!, - toSymbol: swap.toSymbol!); + toSymbol: swap.toSymbol!,); } Widget _getAmountAndSymbolWidget(String amount, String symbol) { @@ -592,7 +592,7 @@ class _NativeP2pSwapModalState extends State { child: Text( amount, style: - const TextStyle(fontSize: 14.0, color: AppColors.subtitleColor), + const TextStyle(fontSize: 14, color: AppColors.subtitleColor), overflow: TextOverflow.ellipsis, maxLines: 1, softWrap: false, @@ -603,7 +603,7 @@ class _NativeP2pSwapModalState extends State { child: Text( ' $symbol', style: - const TextStyle(fontSize: 14.0, color: AppColors.subtitleColor), + const TextStyle(fontSize: 14, color: AppColors.subtitleColor), overflow: TextOverflow.ellipsis, maxLines: 1, softWrap: false, diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/p2p_swap_warning_modal.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/p2p_swap_warning_modal.dart index 5ab0bdb9..f35f9dcb 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/p2p_swap_warning_modal.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/p2p_swap_warning_modal.dart @@ -2,12 +2,12 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/modals/base_modal.dart'; class P2PSwapWarningModal extends StatefulWidget { - final Function() onAccepted; const P2PSwapWarningModal({ required this.onAccepted, super.key, }); + final Function() onAccepted; @override State createState() => _P2PSwapWarningModalState(); @@ -26,17 +26,17 @@ class _P2PSwapWarningModalState extends State { return Column( children: [ const SizedBox( - height: 20.0, + height: 20, ), const Text( '''Please note that the P2P swap is an experimental feature and may result in funds being lost.\n\n''' '''Use the feature with caution and consider splitting large swaps into multiple smaller ones.''', style: TextStyle( - fontSize: 14.0, + fontSize: 14, ), ), const SizedBox( - height: 30.0, + height: 30, ), SizedBox( width: double.infinity, diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/recover_deposit_modal.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/recover_deposit_modal.dart index 2eb20d02..be439607 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/recover_deposit_modal.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/recover_deposit_modal.dart @@ -61,11 +61,11 @@ class _RecoverDepositModalState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ const SizedBox( - height: 10.0, + height: 10, ), Container( - width: 72.0, - height: 72.0, + width: 72, + height: 72, color: Colors.transparent, child: SvgPicture.asset( 'assets/svg/ic_completed_symbol.svg', @@ -74,16 +74,16 @@ class _RecoverDepositModalState extends State { ), ), const SizedBox( - height: 30.0, + height: 30, ), const Text( 'Recovery transaction sent. You will receive the funds shortly.', style: TextStyle( - fontSize: 16.0, + fontSize: 16, ), ), const SizedBox( - height: 30.0, + height: 30, ), ], ); @@ -93,16 +93,16 @@ class _RecoverDepositModalState extends State { return Column( children: [ const SizedBox( - height: 20.0, + height: 20, ), const Text( - 'If you have lost access to the machine that a swap was started on, the deposited funds can be recovered with the deposit ID.\n\nIf you don\'t have the deposit ID, please refer to the swap tutorial for instructions on how to recover it using a block explorer.', + "If you have lost access to the machine that a swap was started on, the deposited funds can be recovered with the deposit ID.\n\nIf you don't have the deposit ID, please refer to the swap tutorial for instructions on how to recover it using a block explorer.", style: TextStyle( - fontSize: 14.0, + fontSize: 14, ), ), const SizedBox( - height: 20.0, + height: 20, ), MouseRegion( cursor: SystemMouseCursors.click, @@ -113,15 +113,15 @@ class _RecoverDepositModalState extends State { 'View swap tutorial', style: TextStyle( color: AppColors.subtitleColor, - fontSize: 14.0, + fontSize: 14, ), ), SizedBox( - width: 3.0, + width: 3, ), Icon( Icons.open_in_new, - size: 18.0, + size: 18, color: AppColors.subtitleColor, ), ], @@ -130,7 +130,7 @@ class _RecoverDepositModalState extends State { ), ), const SizedBox( - height: 25.0, + height: 25, ), Form( autovalidateMode: AutovalidateMode.onUserInteraction, @@ -138,7 +138,7 @@ class _RecoverDepositModalState extends State { onChanged: (value) { setState(() {}); }, - validator: (value) => InputValidators.checkHash(value), + validator: InputValidators.checkHash, controller: _depositIdController, suffixIcon: RawMaterialButton( shape: const CircleBorder(), @@ -152,19 +152,19 @@ class _RecoverDepositModalState extends State { child: const Icon( Icons.content_paste, color: AppColors.darkHintTextColor, - size: 15.0, + size: 15, ), ), suffixIconConstraints: const BoxConstraints( - maxWidth: 45.0, - maxHeight: 20.0, + maxWidth: 45, + maxHeight: 20, ), hintText: 'Deposit ID', - contentLeftPadding: 10.0, + contentLeftPadding: 10, ), ), const SizedBox( - height: 25.0, + height: 25, ), Visibility( visible: _errorText != null, @@ -175,7 +175,7 @@ class _RecoverDepositModalState extends State { showBorder: true, ), const SizedBox( - height: 20.0, + height: 20, ), ], ), @@ -218,7 +218,7 @@ class _RecoverDepositModalState extends State { model.recoverFunds(htlcId: Hash.parse(_depositIdController.text)); }, ), - viewModelBuilder: () => RecoverHtlcSwapFundsBloc(), + viewModelBuilder: RecoverHtlcSwapFundsBloc.new, ); } diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/start_native_swap_modal.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/start_native_swap_modal.dart index 08af3a50..85f695f4 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/start_native_swap_modal.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/start_native_swap_modal.dart @@ -25,12 +25,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/modals/base import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class StartNativeSwapModal extends StatefulWidget { - final Function(String) onSwapStarted; const StartNativeSwapModal({ required this.onSwapStarted, super.key, }); + final Function(String) onSwapStarted; @override State createState() => _StartNativeSwapModalState(); @@ -73,7 +73,7 @@ class _StartNativeSwapModalState extends State { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - const SizedBox(height: 20.0), + const SizedBox(height: 20), Row( children: [ Expanded( @@ -89,7 +89,7 @@ class _StartNativeSwapModalState extends State { ), ), const SizedBox( - width: 20.0, + width: 20, ), Expanded( child: LabeledInputContainer( @@ -102,7 +102,7 @@ class _StartNativeSwapModalState extends State { setState(() {}); }, enabled: !_isLoading, - validator: (value) => _validateCounterpartyAddress(value), + validator: _validateCounterpartyAddress, controller: _counterpartyAddressController, suffixIcon: RawMaterialButton( shape: const CircleBorder(), @@ -116,15 +116,15 @@ class _StartNativeSwapModalState extends State { child: const Icon( Icons.content_paste, color: AppColors.darkHintTextColor, - size: 15.0, + size: 15, ), ), suffixIconConstraints: const BoxConstraints( - maxWidth: 45.0, - maxHeight: 20.0, + maxWidth: 45, + maxHeight: 20, ), hintText: 'Enter NoM address', - contentLeftPadding: 10.0, + contentLeftPadding: 10, ), ), ), @@ -146,8 +146,8 @@ class _StartNativeSwapModalState extends State { return AmountInputField( controller: _amountController, enabled: !_isLoading, - accountInfo: (snapshot.data![_selectedSelfAddress]!), - valuePadding: 10.0, + accountInfo: snapshot.data![_selectedSelfAddress]!, + valuePadding: 10, textColor: Theme.of(context).colorScheme.inverseSurface, initialToken: _selectedToken, hintText: '0.0', @@ -170,12 +170,12 @@ class _StartNativeSwapModalState extends State { ), ), ), - const SizedBox(height: 20.0), + const SizedBox(height: 20), BulletPointCard( bulletPoints: [ RichText( text: BulletPointCard.textSpan( - 'After starting the swap, wait for the counterparty to join the swap with the agreed upon amount.'), + 'After starting the swap, wait for the counterparty to join the swap with the agreed upon amount.',), ), RichText( text: BulletPointCard.textSpan( @@ -184,25 +184,25 @@ class _StartNativeSwapModalState extends State { TextSpan( text: '${kInitialHtlcDuration.inHours} hours', style: - const TextStyle(fontSize: 14.0, color: Colors.white)), + const TextStyle(fontSize: 14, color: Colors.white),), BulletPointCard.textSpan( - ' if the counterparty fails to join the swap.'), + ' if the counterparty fails to join the swap.',), ], ), ), RichText( text: BulletPointCard.textSpan( - 'The swap must be completed on this machine.'), + 'The swap must be completed on this machine.',), ), ], ), - const SizedBox(height: 20.0), + const SizedBox(height: 20), _getStartSwapViewModel(), ], ); } - _getStartSwapViewModel() { + ViewModelBuilder _getStartSwapViewModel() { return ViewModelBuilder.reactive( onViewModelReady: (model) { model.stream.listen( @@ -220,7 +220,7 @@ class _StartNativeSwapModalState extends State { ); }, builder: (_, model, __) => _getStartSwapButton(model), - viewModelBuilder: () => StartHtlcSwapBloc(), + viewModelBuilder: StartHtlcSwapBloc.new, ); } @@ -235,7 +235,7 @@ class _StartNativeSwapModalState extends State { ); } - void _onStartButtonPressed(StartHtlcSwapBloc model) async { + Future _onStartButtonPressed(StartHtlcSwapBloc model) async { setState(() { _isLoading = true; }); @@ -249,7 +249,7 @@ class _StartNativeSwapModalState extends State { swapType: P2pSwapType.native, fromChain: P2pSwapChain.nom, toChain: P2pSwapChain.nom, - initialHtlcDuration: kInitialHtlcDuration.inSeconds); + initialHtlcDuration: kInitialHtlcDuration.inSeconds,); } bool _isInputValid() => @@ -258,7 +258,7 @@ class _StartNativeSwapModalState extends State { _isAmountValid; String? _validateCounterpartyAddress(String? address) { - String? result = InputValidators.checkAddress(address); + final result = InputValidators.checkAddress(address); if (result != null) { return result; } else { diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_button.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_button.dart index 17fd132b..fc3041d4 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_button.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_button.dart @@ -2,16 +2,13 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; class P2pSwapOptionsButton extends StatefulWidget { - final VoidCallback onClick; - final String primaryText; - final String secondaryText; const P2pSwapOptionsButton({ - super.key, - required this.primaryText, - required this.secondaryText, - required this.onClick, + required this.primaryText, required this.secondaryText, required this.onClick, super.key, }); + final VoidCallback onClick; + final String primaryText; + final String secondaryText; @override State createState() => _P2pSwapOptionsButtonState(); @@ -23,7 +20,7 @@ class _P2pSwapOptionsButtonState extends State { return Material( color: Theme.of(context).colorScheme.primaryContainer, borderRadius: BorderRadius.circular( - 8.0, + 8, ), child: InkWell( borderRadius: BorderRadius.circular(8), @@ -33,18 +30,18 @@ class _P2pSwapOptionsButtonState extends State { }); }, child: Container( - padding: const EdgeInsets.all(20.0), + padding: const EdgeInsets.all(20), decoration: BoxDecoration( boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.02), - offset: const Offset(0.0, 4), + offset: const Offset(0, 4), blurRadius: 6, - spreadRadius: 8.0, + spreadRadius: 8, ), ], borderRadius: BorderRadius.circular( - 8.0, + 8, ), ), child: Row( @@ -59,25 +56,25 @@ class _P2pSwapOptionsButtonState extends State { style: Theme.of(context).textTheme.headlineSmall, ), const SizedBox( - height: 8.0, + height: 8, ), Text( widget.secondaryText, textAlign: TextAlign.left, style: const TextStyle( color: AppColors.subtitleColor, - fontSize: 14.0, + fontSize: 14, ), ), ], ), ), const SizedBox( - width: 15.0, + width: 15, ), const Column( children: [ - Icon(Icons.keyboard_arrow_right, size: 18.0), + Icon(Icons.keyboard_arrow_right, size: 18), ], ), ], diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_card.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_card.dart index aaf99522..d6f6b340 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_card.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_card.dart @@ -6,9 +6,9 @@ import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/p2p_swap_widgets/modals/join_native_swap_modal.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/p2p_swap_widgets/modals/native_p2p_swap_modal.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/p2p_swap_widgets/modals/p2p_swap_warning_modal.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/p2p_swap_widgets/modals/recover_deposit_modal.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/p2p_swap_widgets/modals/start_native_swap_modal.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/p2p_swap_widgets/modals/p2p_swap_warning_modal.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_button.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dialogs.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; @@ -50,11 +50,11 @@ class _P2pSwapOptionsCardState extends State { const Icon( Icons.refresh, color: AppColors.znnColor, - size: 20.0, + size: 20, ), const SizedBox( - width: 5.0, - height: 38.0, + width: 5, + height: 38, ), Expanded( child: Text( @@ -78,26 +78,26 @@ class _P2pSwapOptionsCardState extends State { } final isGeneratingPlasma = _isGeneratingPlasma(snapshot.data); return Container( - margin: const EdgeInsets.all(20.0), + margin: const EdgeInsets.all(20), child: _getNativeOptions(isGeneratingPlasma), ); }, ); } - void _showUserWarningModalIfNeeded({required Function() onContinue}) { + void _showUserWarningModalIfNeeded({required VoidCallback onContinue}) { final hasReadWarning = sharedPrefsService!.get( kHasReadP2pSwapWarningKey, defaultValue: kHasReadP2pSwapWarningDefaultValue, ); - if (!hasReadWarning) { + if (hasReadWarning == false) { showCustomDialog( context: context, content: P2PSwapWarningModal(onAccepted: () { Navigator.pop(context); sharedPrefsService!.put(kHasReadP2pSwapWarningKey, true); Timer.run(onContinue); - }), + },), ); } else { onContinue(); @@ -128,11 +128,11 @@ class _P2pSwapOptionsCardState extends State { onContinue: () => showCustomDialog( context: context, content: StartNativeSwapModal( - onSwapStarted: _showNativeSwapModal), - )), + onSwapStarted: _showNativeSwapModal,), + ),), ), const SizedBox( - height: 25.0, + height: 25, ), P2pSwapOptionsButton( primaryText: 'Join swap', @@ -148,7 +148,7 @@ class _P2pSwapOptionsCardState extends State { ), ), const SizedBox( - height: 40.0, + height: 40, ), MouseRegion( cursor: SystemMouseCursors.click, @@ -160,15 +160,15 @@ class _P2pSwapOptionsCardState extends State { 'View swap tutorial', style: TextStyle( color: AppColors.subtitleColor, - fontSize: 14.0, + fontSize: 14, ), ), SizedBox( - width: 3.0, + width: 3, ), Icon( Icons.open_in_new, - size: 18.0, + size: 18, color: AppColors.subtitleColor, ), ], @@ -177,7 +177,7 @@ class _P2pSwapOptionsCardState extends State { ), ), const SizedBox( - height: 40.0, + height: 40, ), ], ); diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_card.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_card.dart index cae5d8c3..6fea950b 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_card.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_card.dart @@ -8,12 +8,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/p2p_swap_wid import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class P2pSwapsCard extends StatefulWidget { - final VoidCallback onStepperNotificationSeeMorePressed; const P2pSwapsCard({ required this.onStepperNotificationSeeMorePressed, super.key, }); + final VoidCallback onStepperNotificationSeeMorePressed; @override State createState() => _P2pSwapsCardState(); @@ -57,7 +57,7 @@ class _P2pSwapsCardState extends State { onCompletedStatusCallback: (data) => data.isEmpty ? const SyriusErrorWidget('No P2P swaps') : _getTable(data), - onRefreshPressed: () => _p2pSwapsListBloc.getData(), + onRefreshPressed: _p2pSwapsListBloc.getData, description: 'This card displays a list of P2P swaps that have been conducted ' 'with this wallet.', @@ -70,11 +70,11 @@ class _P2pSwapsCardState extends State { const Icon( Icons.delete, color: AppColors.znnColor, - size: 20.0, + size: 20, ), const SizedBox( - width: 5.0, - height: 38.0, + width: 5, + height: 38, ), Expanded( child: Text( @@ -110,7 +110,7 @@ class _P2pSwapsCardState extends State { await htlcSwapsService!.deleteSwap(swap.id); } _p2pSwapsListBloc.getData(); - }); + },); } Future _onDeleteSwapHistoryTapped() async { @@ -123,17 +123,17 @@ class _P2pSwapsCardState extends State { onYesButtonPressed: () async { await htlcSwapsService!.deleteInactiveSwaps(); _p2pSwapsListBloc.getData(); - }); + },); } Widget _getTable(List swaps) { return Padding( - padding: const EdgeInsets.all(15.0), + padding: const EdgeInsets.all(15), child: Column( children: [ _getHeader(), const SizedBox( - height: 15.0, + height: 15, ), Visibility( visible: _isListScrolled, @@ -148,7 +148,7 @@ class _P2pSwapsCardState extends State { itemCount: swaps.length, separatorBuilder: (_, __) { return const SizedBox( - height: 15.0, + height: 15, ); }, itemBuilder: (_, index) { @@ -158,7 +158,7 @@ class _P2pSwapsCardState extends State { onTap: _onSwapTapped, onDelete: _onDeleteSwapTapped, ); - }), + },), ), ), ], @@ -168,7 +168,7 @@ class _P2pSwapsCardState extends State { Widget _getHeader() { return Padding( - padding: const EdgeInsets.symmetric(horizontal: 20.0), + padding: const EdgeInsets.symmetric(horizontal: 20), child: Row( children: [ Expanded( @@ -197,20 +197,20 @@ class _P2pSwapsCardState extends State { _getHeaderItem( 'Swap history is full', textColor: AppColors.errorColor, - textHeight: 1.0, + textHeight: 1, ), const SizedBox( - width: 5.0, + width: 5, ), const Tooltip( message: 'The oldest swap entry will be deleted when a new swap is started.', child: Padding( - padding: EdgeInsets.only(top: 3.0), + padding: EdgeInsets.only(top: 3), child: Icon( Icons.info, color: AppColors.errorColor, - size: 12.0, + size: 12, ), ), ), @@ -226,7 +226,7 @@ class _P2pSwapsCardState extends State { Widget _getHeaderItem(String text, {Color? textColor, double? textHeight}) { return Text( text, - style: TextStyle(fontSize: 12.0, height: textHeight, color: textColor), + style: TextStyle(fontSize: 12, height: textHeight, color: textColor), ); } } diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_list_item.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_list_item.dart index 0e22a195..4ac24f0c 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_list_item.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_list_item.dart @@ -8,9 +8,6 @@ import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_wid import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class P2pSwapsListItem extends StatefulWidget { - final P2pSwap swap; - final Function(String) onTap; - final Function(P2pSwap) onDelete; const P2pSwapsListItem({ required this.swap, @@ -18,6 +15,9 @@ class P2pSwapsListItem extends StatefulWidget { required this.onDelete, super.key, }); + final P2pSwap swap; + final Function(String) onTap; + final Function(P2pSwap) onDelete; @override State createState() => _P2pSwapsListItemState(); @@ -30,16 +30,16 @@ class _P2pSwapsListItemState extends State { Widget build(BuildContext context) { return Material( color: Theme.of(context).colorScheme.primaryContainer, - elevation: 1.0, + elevation: 1, borderRadius: BorderRadius.circular( - 8.0, + 8, ), child: InkWell( borderRadius: BorderRadius.circular(8), onTap: () => widget.onTap.call(widget.swap.id), child: Container( - height: 56.0, - padding: const EdgeInsets.symmetric(horizontal: 20.0), + height: 56, + padding: const EdgeInsets.symmetric(horizontal: 20), child: Row( children: [ Expanded( @@ -48,9 +48,9 @@ class _P2pSwapsListItemState extends State { children: [ _getStatusWidget(), const SizedBox( - width: 8.0, + width: 8, ), - _getStatusText() + _getStatusText(), ], ), ), @@ -60,7 +60,7 @@ class _P2pSwapsListItemState extends State { widget.swap.fromAmount, widget.swap.fromDecimals, widget.swap.fromTokenStandard, - widget.swap.fromSymbol), + widget.swap.fromSymbol,), ), Expanded( flex: 20, @@ -69,7 +69,7 @@ class _P2pSwapsListItemState extends State { widget.swap.toAmount, widget.swap.toDecimals, widget.swap.toTokenStandard, - widget.swap.toSymbol) + widget.swap.toSymbol,) : _getTextWidget('-'), ), Expanded( @@ -95,16 +95,16 @@ class _P2pSwapsListItemState extends State { case P2pSwapState.pending: case P2pSwapState.active: return const SyriusLoadingWidget( - size: 12.0, - strokeWidth: 2.0, - padding: 2.0, + size: 12, + strokeWidth: 2, + padding: 2, ); case P2pSwapState.completed: return const Icon(Icons.check_circle_outline, - color: AppColors.znnColor, size: size); + color: AppColors.znnColor, size: size,); default: return const Icon(Icons.cancel_outlined, - color: AppColors.errorColor, size: size); + color: AppColors.errorColor, size: size,); } } @@ -113,13 +113,10 @@ class _P2pSwapsListItemState extends State { switch (widget.swap.state) { case P2pSwapState.pending: text = 'Starting'; - break; case P2pSwapState.active: text = 'Active'; - break; case P2pSwapState.completed: text = 'Completed'; - break; default: text = 'Unsuccessful'; } @@ -129,14 +126,14 @@ class _P2pSwapsListItemState extends State { Widget _getTextWidget(String text) { return Text(text, style: const TextStyle( - fontSize: 12.0, height: 1, color: AppColors.subtitleColor), + fontSize: 12, height: 1, color: AppColors.subtitleColor,), overflow: TextOverflow.ellipsis, maxLines: 1, - softWrap: false); + softWrap: false,); } Widget _getAmountWidget( - BigInt? amount, int? decimals, String? tokenStandard, String? symbol) { + BigInt? amount, int? decimals, String? tokenStandard, String? symbol,) { if (amount == null || decimals == null || tokenStandard == null || @@ -158,11 +155,11 @@ class _P2pSwapsListItemState extends State { ], ), const SizedBox( - width: 6.0, + width: 6, ), Container( - height: 6.0, - width: 6.0, + height: 6, + width: 6, decoration: BoxDecoration( shape: BoxShape.circle, color: ColorUtils.getTokenColor( @@ -186,7 +183,7 @@ class _P2pSwapsListItemState extends State { height: 32, decoration: BoxDecoration( borderRadius: BorderRadius.circular( - 4.0, + 4, ), color: const Color(0xff333333), ), @@ -201,7 +198,7 @@ class _P2pSwapsListItemState extends State { color: _isDeleteIconHovered ? Colors.white : AppColors.subtitleColor, - size: 18.0, + size: 18, ), ), ), @@ -214,12 +211,12 @@ class _P2pSwapsListItemState extends State { child: FittedBox( fit: BoxFit.scaleDown, child: SizedBox( - height: 32.0, + height: 32, child: ElevatedButton( onPressed: () => widget.onTap.call(widget.swap.id), child: const Text( 'Reclaim funds', - style: TextStyle(fontSize: 12.0, color: Colors.white), + style: TextStyle(fontSize: 12, color: Colors.white), ), ), ), @@ -231,17 +228,17 @@ class _P2pSwapsListItemState extends State { } String _formatTime(int transactionMillis) { - int currentMillis = DateTime.now().millisecondsSinceEpoch; + final currentMillis = DateTime.now().millisecondsSinceEpoch; if (currentMillis - transactionMillis <= const Duration(days: 1).inMilliseconds) { return _formatTimeShort(currentMillis - transactionMillis); } return FormatUtils.formatDate(transactionMillis, - dateFormat: 'MM/dd/yyyy hh:mm a'); + dateFormat: 'MM/dd/yyyy hh:mm a',); } String _formatTimeShort(int i) { - Duration duration = Duration(milliseconds: i); + final duration = Duration(milliseconds: i); if (duration.inHours > 0) { return '${duration.inHours} h ago'; } diff --git a/lib/widgets/modular_widgets/pillar_widgets/create_pillar.dart b/lib/widgets/modular_widgets/pillar_widgets/create_pillar.dart index e6392158..967d9f8a 100644 --- a/lib/widgets/modular_widgets/pillar_widgets/create_pillar.dart +++ b/lib/widgets/modular_widgets/pillar_widgets/create_pillar.dart @@ -9,12 +9,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class CreatePillar extends StatefulWidget { - final VoidCallback onStepperNotificationSeeMorePressed; const CreatePillar({ required this.onStepperNotificationSeeMorePressed, super.key, }); + final VoidCallback onStepperNotificationSeeMorePressed; @override State createState() => _CreatePillarState(); @@ -79,7 +79,7 @@ class _CreatePillarState extends State { ], ), const SizedBox( - width: 10.0, + width: 10, ), ], ); @@ -147,7 +147,7 @@ class _CreatePillarState extends State { child: const Icon( MaterialCommunityIcons.plus, color: Colors.white, - size: 15.0, + size: 15, ), ); } diff --git a/lib/widgets/modular_widgets/pillar_widgets/pillar_collect.dart b/lib/widgets/modular_widgets/pillar_widgets/pillar_collect.dart index 70018726..87e0be6d 100644 --- a/lib/widgets/modular_widgets/pillar_widgets/pillar_collect.dart +++ b/lib/widgets/modular_widgets/pillar_widgets/pillar_collect.dart @@ -11,12 +11,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PillarCollect extends StatefulWidget { - final PillarRewardsHistoryBloc pillarRewardsHistoryBloc; const PillarCollect({ required this.pillarRewardsHistoryBloc, super.key, }); + final PillarRewardsHistoryBloc pillarRewardsHistoryBloc; @override State createState() => _PillarCollectState(); @@ -40,7 +40,7 @@ class _PillarCollectState extends State { 'registered in the network, but also deployed (use znn-controller for ' 'this operation) and it must produce momentums', childBuilder: () => Padding( - padding: const EdgeInsets.all(16.0), + padding: const EdgeInsets.all(16), child: _getFutureBuilder(), ), ); @@ -73,11 +73,10 @@ class _PillarCollectState extends State { coinDecimals, ) .toNum(), - isInt: false, after: ' ${kZnnCoin.symbol}', style: Theme.of(context).textTheme.headlineLarge!.copyWith( color: AppColors.znnColor, - fontSize: 30.0, + fontSize: 30, ), ), kVerticalSpacing, @@ -113,7 +112,7 @@ class _PillarCollectState extends State { ); } catch (e) { await NotificationUtils.sendNotificationError( - e, 'Error while collecting Pillar rewards'); + e, 'Error while collecting Pillar rewards',); } finally { _collectButtonKey.currentState?.animateReverse(); } diff --git a/lib/widgets/modular_widgets/pillar_widgets/pillar_list_widget.dart b/lib/widgets/modular_widgets/pillar_widgets/pillar_list_widget.dart index 180bbeec..b05a2774 100644 --- a/lib/widgets/modular_widgets/pillar_widgets/pillar_list_widget.dart +++ b/lib/widgets/modular_widgets/pillar_widgets/pillar_list_widget.dart @@ -15,9 +15,9 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PillarListWidget extends StatefulWidget { - final String? title; const PillarListWidget({super.key, this.title}); + final String? title; @override State createState() => _PillarListWidgetState(); @@ -147,19 +147,18 @@ class _PillarListWidgetState extends State { border: Border( bottom: BorderSide( color: Theme.of(context).dividerTheme.color!, - width: 1.0, ), ), ), padding: const EdgeInsets.symmetric( - vertical: 15.0, + vertical: 15, ), child: Row( children: List.from( [ const SizedBox( - width: 20.0, - ) + width: 20, + ), ], ) + [ @@ -178,9 +177,9 @@ class _PillarListWidgetState extends State { ), const InfiniteScrollTableHeaderColumn(columnName: 'Delegation'), const InfiniteScrollTableHeaderColumn( - columnName: 'Momentum reward'), + columnName: 'Momentum reward',), const InfiniteScrollTableHeaderColumn( - columnName: 'Delegation reward'), + columnName: 'Delegation reward',), const InfiniteScrollTableHeaderColumn( columnName: 'Expected/produced momentums', ), @@ -189,30 +188,28 @@ class _PillarListWidgetState extends State { ), const InfiniteScrollTableHeaderColumn( columnName: '', - flex: 1, ), const SizedBox( - width: 5.0, - ) + width: 5, + ), ] + [ SizedBox( width: 110, child: Row( mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, children: [ Visibility( visible: _delegationInfo?.name != null, child: _getUndelegateButtonViewModel(bloc), ), - ])), - ]), + ],),), + ],), ); } Widget _getTableRow(dynamic item, int indexOfRow) { - bool isSelected = _selectedRowIndex == indexOfRow; + final isSelected = _selectedRowIndex == indexOfRow; return InkWell( onTap: () { @@ -226,7 +223,7 @@ class _PillarListWidgetState extends State { }, child: Container( constraints: const BoxConstraints( - minHeight: 75.0, + minHeight: 75, ), decoration: BoxDecoration( color: isSelected @@ -242,7 +239,7 @@ class _PillarListWidgetState extends State { left: isSelected ? const BorderSide( color: AppColors.znnColor, - width: 2.0, + width: 2, ) : BorderSide.none, ), @@ -251,16 +248,16 @@ class _PillarListWidgetState extends State { children: List.from( [ const SizedBox( - width: 20.0, - ) + width: 20, + ), ], ) + generateRowCells(item, isSelected) + [ const SizedBox( width: 110, - ) - ]), + ), + ],), ), ); } @@ -321,7 +318,7 @@ class _PillarListWidgetState extends State { '${pillarInfo.giveDelegateRewardPercentage} %', ), InfiniteScrollTableCell.withText(context, - '${pillarInfo.expectedMomentums}/${pillarInfo.producedMomentums} '), + '${pillarInfo.expectedMomentums}/${pillarInfo.producedMomentums} ',), InfiniteScrollTableCell.withText( context, '${_getMomentumsPercentage(pillarInfo)} %', @@ -398,7 +395,7 @@ class _PillarListWidgetState extends State { Visibility( visible: pillarItem.isRevocable, child: const SizedBox( - width: 5.0, + width: 5, ), ), SizedBox( @@ -469,12 +466,12 @@ class _PillarListWidgetState extends State { if (snapshot.hasData) { return _getDisassembleButton(isSelected, model, pillarInfo); } - return const SyriusLoadingWidget(size: 25.0); + return const SyriusLoadingWidget(size: 25); } return _getDisassembleButton(isSelected, model, pillarInfo); }, ), - viewModelBuilder: () => DisassemblePillarBloc(), + viewModelBuilder: DisassemblePillarBloc.new, ); } @@ -484,7 +481,7 @@ class _PillarListWidgetState extends State { PillarInfo pillarItem, ) { return MyOutlinedButton( - minimumSize: const Size(55.0, 25.0), + minimumSize: const Size(55, 25), outlineColor: isSelected ? AppColors.errorColor : Theme.of(context).textTheme.titleSmall!.color, @@ -508,11 +505,11 @@ class _PillarListWidgetState extends State { : Theme.of(context).textTheme.titleSmall, ), const SizedBox( - width: 20.0, + width: 20, ), Icon( SimpleLineIcons.close, - size: 11.0, + size: 11, color: isSelected ? AppColors.errorColor : Theme.of(context).textTheme.titleSmall!.color, @@ -546,19 +543,16 @@ class _PillarListWidgetState extends State { _sortAscending ? _pillarInfoWrappers.sort((a, b) => a.name.compareTo(b.name)) : _pillarInfoWrappers.sort((a, b) => b.name.compareTo(a.name)); - break; case 'Producer Address': _sortAscending ? _pillarInfoWrappers .sort((a, b) => a.producerAddress.compareTo(b.producerAddress)) : _pillarInfoWrappers .sort((a, b) => b.producerAddress.compareTo(a.producerAddress)); - break; case 'Weight': _sortAscending ? _pillarInfoWrappers.sort((a, b) => a.weight.compareTo(b.weight)) : _pillarInfoWrappers.sort((a, b) => b.weight.compareTo(a.weight)); - break; default: _sortAscending ? _pillarInfoWrappers.sort((a, b) => a.name.compareTo(b.name)) @@ -572,7 +566,7 @@ class _PillarListWidgetState extends State { } Widget _getUndelegateButtonViewModel(PillarsListBloc pillarsModel) { - final GlobalKey undelegateButtonKey = GlobalKey(); + final undelegateButtonKey = GlobalKey(); return ViewModelBuilder.reactive( onViewModelReady: (model) { @@ -596,7 +590,7 @@ class _PillarListWidgetState extends State { model, undelegateButtonKey, ), - viewModelBuilder: () => UndelegateButtonBloc(), + viewModelBuilder: UndelegateButtonBloc.new, ); } @@ -672,7 +666,7 @@ class _PillarListWidgetState extends State { model, delegateButtonKey, ), - viewModelBuilder: () => DelegateButtonBloc(), + viewModelBuilder: DelegateButtonBloc.new, ), ); } @@ -686,7 +680,7 @@ class _PillarListWidgetState extends State { } int _getMomentumsPercentage(PillarInfo pillarInfo) { - double percentage = + final percentage = pillarInfo.producedMomentums / pillarInfo.expectedMomentums * 100; if (percentage.isNaN) { return 0; diff --git a/lib/widgets/modular_widgets/pillar_widgets/pillar_rewards.dart b/lib/widgets/modular_widgets/pillar_widgets/pillar_rewards.dart index d072a038..208d36ce 100644 --- a/lib/widgets/modular_widgets/pillar_widgets/pillar_rewards.dart +++ b/lib/widgets/modular_widgets/pillar_widgets/pillar_rewards.dart @@ -4,9 +4,9 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PillarRewards extends StatefulWidget { - final PillarRewardsHistoryBloc pillarRewardsHistoryBloc; const PillarRewards({required this.pillarRewardsHistoryBloc, super.key}); + final PillarRewardsHistoryBloc pillarRewardsHistoryBloc; @override State createState() => _PillarRewardsState(); @@ -21,7 +21,7 @@ class _PillarRewardsState extends State { 'Pillar rewards are generated either by operating a Pillar Node or from ' 'delegations to a Pillar Node', childBuilder: () => Padding( - padding: const EdgeInsets.all(16.0), + padding: const EdgeInsets.all(16), child: _getStreamBody(), ), ); diff --git a/lib/widgets/modular_widgets/pillar_widgets/pillar_stepper_container.dart b/lib/widgets/modular_widgets/pillar_widgets/pillar_stepper_container.dart index b72362de..736471cc 100644 --- a/lib/widgets/modular_widgets/pillar_widgets/pillar_stepper_container.dart +++ b/lib/widgets/modular_widgets/pillar_widgets/pillar_stepper_container.dart @@ -78,8 +78,8 @@ class _MainPillarState extends State { late PillarsQsrInfoBloc _pillarsQsrInfoViewModel; - double _momentumRewardPercentageGiven = 0.0; - double _delegateRewardPercentageGiven = 0.0; + double _momentumRewardPercentageGiven = 0; + double _delegateRewardPercentageGiven = 0; @override void initState() { @@ -153,12 +153,12 @@ class _MainPillarState extends State { return SyriusErrorWidget(snapshot.error!); } return const Padding( - padding: EdgeInsets.all(8.0), + padding: EdgeInsets.all(8), child: SyriusLoadingWidget(), ); }, ), - viewModelBuilder: () => PillarsQsrInfoBloc(), + viewModelBuilder: PillarsQsrInfoBloc.new, ); } @@ -185,10 +185,10 @@ class _MainPillarState extends State { ], ), const SizedBox( - height: 10.0, + height: 10, ), Padding( - padding: const EdgeInsets.only(left: 20.0), + padding: const EdgeInsets.only(left: 20), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -205,7 +205,7 @@ class _MainPillarState extends State { ), ), const SizedBox( - height: 10.0, + height: 10, ), Row( children: [ @@ -227,7 +227,7 @@ class _MainPillarState extends State { ), suffixIcon: _getAmountSuffix(accountInfo), suffixIconConstraints: - const BoxConstraints(maxWidth: 50.0), + const BoxConstraints(maxWidth: 50), hintText: 'Amount', onChanged: (value) { setState(() {}); @@ -238,7 +238,7 @@ class _MainPillarState extends State { ], ), Padding( - padding: const EdgeInsets.symmetric(vertical: 25.0), + padding: const EdgeInsets.symmetric(vertical: 25), child: DottedBorderInfoWidget( text: 'All the deposited ${kQsrCoin.symbol} will be burned ' @@ -262,12 +262,12 @@ class _MainPillarState extends State { ), ), ], - ) + ), ], ), ), const SizedBox( - width: 45.0, + width: 45, ), Expanded( child: Visibility( @@ -278,10 +278,10 @@ class _MainPillarState extends State { borderRadius: BorderRadius.circular(6), ), margin: const EdgeInsets.only( - bottom: 30.0, + bottom: 30, ), child: Padding( - padding: const EdgeInsets.symmetric(vertical: 30.0), + padding: const EdgeInsets.symmetric(vertical: 30), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ @@ -291,15 +291,15 @@ class _MainPillarState extends State { alignment: Alignment.center, children: [ SizedBox( - width: 150.0, - height: 150.0, + width: 150, + height: 150, child: AspectRatio( - aspectRatio: 1.0, + aspectRatio: 1, child: StandardPieChart( sections: [ PieChartSectionData( showTitle: false, - radius: 7.0, + radius: 7, value: (qsrInfo.cost - qsrInfo.deposit) / qsrInfo.cost, color: @@ -307,7 +307,7 @@ class _MainPillarState extends State { ), PieChartSectionData( showTitle: false, - radius: 7.0, + radius: 7, value: qsrInfo.deposit / qsrInfo.cost, color: AppColors.qsrColor, ), @@ -329,7 +329,7 @@ class _MainPillarState extends State { Column( children: [ SizedBox( - width: 130.0, + width: 130, child: Text( 'You have deposited ${qsrInfo.deposit.addDecimals(coinDecimals)} ' '${kQsrCoin.symbol}', @@ -354,7 +354,7 @@ class _MainPillarState extends State { } Widget _getDepositQsrViewModel( - AccountInfo accountInfo, PillarsQsrInfo qsrInfo) { + AccountInfo accountInfo, PillarsQsrInfo qsrInfo,) { return ViewModelBuilder.reactive( onViewModelReady: (model) { model.stream.listen( @@ -382,7 +382,7 @@ class _MainPillarState extends State { }, builder: (_, model, __) => _getDepositQsrButton(model, accountInfo, qsrInfo), - viewModelBuilder: () => PillarsDepositQsrBloc(), + viewModelBuilder: PillarsDepositQsrBloc.new, ); } @@ -430,7 +430,7 @@ class _MainPillarState extends State { ); }, builder: (_, model, __) => _getWithdrawQsrButton(model, qsrDeposit), - viewModelBuilder: () => PillarsWithdrawQsrBloc(), + viewModelBuilder: PillarsWithdrawQsrBloc.new, ); } @@ -510,7 +510,7 @@ class _MainPillarState extends State { return Row( children: [ Container( - height: 20.0, + height: 20, alignment: Alignment.center, decoration: BoxDecoration( borderRadius: BorderRadius.circular(3), @@ -518,8 +518,8 @@ class _MainPillarState extends State { ), child: Padding( padding: const EdgeInsets.symmetric( - vertical: 3.0, - horizontal: 7.0, + vertical: 3, + horizontal: 7, ), child: Row( children: [ @@ -539,7 +539,7 @@ class _MainPillarState extends State { Widget _getDeployPillarStepBody(BuildContext context) { return Padding( - padding: const EdgeInsets.only(bottom: 25.0), + padding: const EdgeInsets.only(bottom: 25), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -554,9 +554,7 @@ class _MainPillarState extends State { controller: _pillarNameController, thisNode: _pillarNameNode, nextNode: _pillarRewardNode, - validator: (value) => Validations.pillarName( - value, - ), + validator: Validations.pillarName, onChanged: (value) { setState(() {}); }, @@ -564,8 +562,8 @@ class _MainPillarState extends State { ), ), const SizedBox( - width: 23.0, - ) + width: 23, + ), ], ), kVerticalSpacing, @@ -604,8 +602,7 @@ class _MainPillarState extends State { hintText: 'Pillar producer address', controller: _pillarMomentumController, thisNode: _pillarMomentumNode, - validator: (value) => - InputValidators.validatePillarMomentumAddress(value), + validator: InputValidators.validatePillarMomentumAddress, onChanged: (value) { setState(() {}); }, @@ -621,7 +618,7 @@ class _MainPillarState extends State { kVerticalSpacing, _getPillarMomentumRewardsStepContent(), const SizedBox( - height: 25.0, + height: 25, ), _getDeployButton(), ], @@ -647,13 +644,13 @@ class _MainPillarState extends State { onError: (error) async { _registerButtonKey.currentState?.animateReverse(); await NotificationUtils.sendNotificationError( - error, 'Error while deploying a Pillar'); + error, 'Error while deploying a Pillar',); setState(() {}); }, ); }, builder: (_, model, __) => _getRegisterPillarButton(model), - viewModelBuilder: () => PillarsDeployBloc(), + viewModelBuilder: PillarsDeployBloc.new, ); } @@ -673,7 +670,6 @@ class _MainPillarState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( child: DisabledAddressField(_addressController), @@ -695,11 +691,10 @@ class _MainPillarState extends State { ], ), Padding( - padding: const EdgeInsets.symmetric(vertical: 25.0), + padding: const EdgeInsets.symmetric(vertical: 25), child: DottedBorderInfoWidget( text: 'You will be able to unlock the ${kZnnCoin.symbol} if you ' 'choose to disassemble the Pillar', - borderColor: AppColors.znnColor, ), ), StepperButton( @@ -756,7 +751,7 @@ class _MainPillarState extends State { giveDelegateRewardPercentage: _delegateRewardPercentageGiven.toInt(), ); } else { - for (var element in _pillarFormKeys) { + for (final element in _pillarFormKeys) { element.currentState!.validate(); } } @@ -783,22 +778,21 @@ class _MainPillarState extends State { visible: (_lastCompletedStep?.index ?? -1) == _numSteps - 1, child: Column( mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( padding: const EdgeInsets.symmetric( - vertical: 40.0, - horizontal: 50.0, + vertical: 40, + horizontal: 50, ), margin: const EdgeInsets.symmetric( - vertical: 20.0, - horizontal: 50.0, + vertical: 20, + horizontal: 50, ), decoration: BoxDecoration( color: Theme.of(context).colorScheme.secondaryContainer, borderRadius: const BorderRadius.all( Radius.circular( - 10.0, + 10, ), ), ), @@ -840,7 +834,7 @@ class _MainPillarState extends State { ), const WidgetSpan( child: Icon(MaterialCommunityIcons.link, - size: 20.0, color: AppColors.znnColor), + size: 20, color: AppColors.znnColor,), ), TextSpan( text: ' to check the Pillar status', @@ -854,18 +848,17 @@ class _MainPillarState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ StepperButton.icon( - context: context, label: 'Register another Pillar', onPressed: _onDeployAnotherPillarButtonPressed, iconData: Icons.refresh, ), const SizedBox( - width: 80.0, + width: 80, ), - _getViewPillarsButton() + _getViewPillarsButton(), ], ), - Container(height: 20.0) + Container(height: 20), ], ), ), @@ -874,10 +867,10 @@ class _MainPillarState extends State { Visibility( visible: (_lastCompletedStep?.index ?? -1) == _numSteps - 1, child: Positioned( - right: 50.0, + right: 50, child: SizedBox( - width: 400.0, - height: 400.0, + width: 400, + height: 400, child: Center( child: Lottie.asset( 'assets/lottie/ic_anim_pillar.json', @@ -893,7 +886,6 @@ class _MainPillarState extends State { Widget _getViewPillarsButton() { return StepperButton.icon( - context: context, label: 'View Pillars', onPressed: () { Navigator.pop(context); @@ -902,7 +894,7 @@ class _MainPillarState extends State { ); } - void _onDeployAnotherPillarButtonPressed() async { + Future _onDeployAnotherPillarButtonPressed() async { _pillarNameController.clear(); _pillarRewardAddressController.clear(); _pillarMomentumController.clear(); @@ -911,9 +903,7 @@ class _MainPillarState extends State { _selectedPillarType, _addressController.text, ); - setState(() { - _iniStepperControllers(); - }); + setState(_iniStepperControllers); } void _saveProgressAndNavigateToNextStep(PillarStepperStep completedStep) { @@ -978,7 +968,7 @@ class _MainPillarState extends State { return _getPlasmaCheckBody(snapshot.data!); } return const Padding( - padding: EdgeInsets.all(8.0), + padding: EdgeInsets.all(8), child: SyriusLoadingWidget(), ); }, @@ -994,22 +984,21 @@ class _MainPillarState extends State { style: Theme.of(context).textTheme.headlineSmall, ), const SizedBox( - height: 25.0, + height: 25, ), Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( child: DisabledAddressField(_addressController), ), const SizedBox( - width: 25.0, + width: 25, ), PlasmaIcon(plasmaInfo), ], ), const SizedBox( - height: 25.0, + height: 25, ), StepperButton( text: 'Next', @@ -1048,11 +1037,10 @@ class _MainPillarState extends State { ], ), CustomSlider( - activeColor: AppColors.znnColor, description: '', - startValue: 0.0, + startValue: 0, min: 0, - maxValue: 100.0, + maxValue: 100, callback: (double value) { setState(() { _momentumRewardPercentageGiven = value; @@ -1083,11 +1071,10 @@ class _MainPillarState extends State { ], ), CustomSlider( - activeColor: AppColors.znnColor, description: '', - startValue: 0.0, + startValue: 0, min: 0, - maxValue: 100.0, + maxValue: 100, callback: (double value) { setState(() { _delegateRewardPercentageGiven = value; diff --git a/lib/widgets/modular_widgets/pillar_widgets/pillar_update_stepper.dart b/lib/widgets/modular_widgets/pillar_widgets/pillar_update_stepper.dart index 8abcf6ca..316d5803 100644 --- a/lib/widgets/modular_widgets/pillar_widgets/pillar_update_stepper.dart +++ b/lib/widgets/modular_widgets/pillar_widgets/pillar_update_stepper.dart @@ -2,13 +2,12 @@ import 'package:flutter/material.dart'; import 'package:lottie/lottie.dart'; import 'package:stacked/stacked.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_material_stepper.dart' as custom_material_stepper; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; enum PillarUpdateStep { @@ -18,9 +17,9 @@ enum PillarUpdateStep { } class PillarUpdateStepper extends StatefulWidget { - final PillarInfo pillarInfo; const PillarUpdateStepper(this.pillarInfo, {super.key}); + final PillarInfo pillarInfo; @override State createState() => _PillarUpdateStepperState(); @@ -71,9 +70,9 @@ class _PillarUpdateStepperState extends State { Visibility( visible: _lastCompletedStep == PillarUpdateStep.pillarUpdate, child: Positioned( - bottom: 20.0, - right: 0.0, - left: 0.0, + bottom: 20, + right: 0, + left: 0, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -90,13 +89,13 @@ class _PillarUpdateStepperState extends State { Visibility( visible: _lastCompletedStep == PillarUpdateStep.pillarUpdate, child: Positioned( - right: 50.0, + right: 50, child: SizedBox( - width: 400.0, - height: 400.0, + width: 400, + height: 400, child: Center( child: Lottie.asset('assets/lottie/ic_anim_pillar.json', - repeat: false), + repeat: false,), ), ), ), @@ -200,9 +199,7 @@ class _PillarUpdateStepperState extends State { hintText: 'Pillar producer address', controller: _pillarProducerController, thisNode: _pillarMomentumNode, - validator: (value) => InputValidators.validatePillarMomentumAddress( - value, - ), + validator: InputValidators.validatePillarMomentumAddress, onChanged: (value) { setState(() {}); }, @@ -218,7 +215,7 @@ class _PillarUpdateStepperState extends State { text: 'Cancel', ), const SizedBox( - width: 25.0, + width: 25, ), StepperButton( onPressed: _arePillarDetailsValid() @@ -250,11 +247,10 @@ class _PillarUpdateStepperState extends State { ], ), CustomSlider( - activeColor: AppColors.znnColor, description: '', startValue: widget.pillarInfo.giveMomentumRewardPercentage.toDouble(), - min: 0.0, - maxValue: 100.0, + min: 0, + maxValue: 100, callback: (double value) { setState(() { _momentumRewardPercentageGiven = value; @@ -285,11 +281,10 @@ class _PillarUpdateStepperState extends State { ], ), CustomSlider( - activeColor: AppColors.znnColor, description: '', startValue: widget.pillarInfo.giveDelegateRewardPercentage.toDouble(), - min: 0.0, - maxValue: 100.0, + min: 0, + maxValue: 100, callback: (double value) { setState(() { _delegateRewardPercentageGiven = value; @@ -322,7 +317,7 @@ class _PillarUpdateStepperState extends State { text: 'Go back', ), const SizedBox( - width: 25.0, + width: 25, ), StepperButton( onPressed: () { @@ -352,7 +347,7 @@ class _PillarUpdateStepperState extends State { text: 'Go back', ), const SizedBox( - width: 25.0, + width: 25, ), _getUpdatePillarViewModel(), ], @@ -379,7 +374,7 @@ class _PillarUpdateStepperState extends State { bool _arePillarDetailsValid() => InputValidators.checkAddress(_pillarRewardController.text) == null && InputValidators.validatePillarMomentumAddress( - _pillarProducerController.text) == + _pillarProducerController.text,) == null; Widget _getUpdatePillarViewModel() { @@ -404,7 +399,7 @@ class _PillarUpdateStepperState extends State { ); }, builder: (_, model, __) => _getUpdatePillarButton(model), - viewModelBuilder: () => UpdatePillarBloc(), + viewModelBuilder: UpdatePillarBloc.new, ); } diff --git a/lib/widgets/modular_widgets/plasma_widgets/plasma_list/plasma_list.dart b/lib/widgets/modular_widgets/plasma_widgets/plasma_list/plasma_list.dart index d0f0d612..8340482a 100644 --- a/lib/widgets/modular_widgets/plasma_widgets/plasma_list/plasma_list.dart +++ b/lib/widgets/modular_widgets/plasma_widgets/plasma_list/plasma_list.dart @@ -10,10 +10,10 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PlasmaList extends StatefulWidget { - final String? errorText; - final PlasmaListBloc bloc; const PlasmaList({required this.bloc, this.errorText, super.key}); + final String? errorText; + final PlasmaListBloc bloc; @override State createState() { @@ -94,11 +94,8 @@ class _PlasmaListState extends State { ) { return Stack( alignment: Alignment.centerLeft, - fit: StackFit.loose, children: [ - plasmaItem.isRevocable! - ? _getCancelButtonViewModel(plasmaModel, isSelected, plasmaItem) - : _getCancelCountdownTimer(plasmaItem, plasmaModel) + if (plasmaItem.isRevocable!) _getCancelButtonViewModel(plasmaModel, isSelected, plasmaItem) else _getCancelCountdownTimer(plasmaItem, plasmaModel), ], ); } @@ -108,7 +105,7 @@ class _PlasmaListState extends State { bool isSelected, FusionEntry plasmaItem, ) { - final GlobalKey cancelButtonKey = GlobalKey(); + final cancelButtonKey = GlobalKey(); return ViewModelBuilder.reactive( onViewModelReady: (model) { @@ -122,7 +119,7 @@ class _PlasmaListState extends State { onError: (error) async { cancelButtonKey.currentState?.animateReverse(); await NotificationUtils.sendNotificationError( - error, 'Error while cancelling plasma'); + error, 'Error while cancelling plasma',); }, ); }, @@ -131,7 +128,7 @@ class _PlasmaListState extends State { plasmaItem.id.toString(), cancelButtonKey, ), - viewModelBuilder: () => CancelPlasmaBloc(), + viewModelBuilder: CancelPlasmaBloc.new, ); } @@ -149,7 +146,7 @@ class _PlasmaListState extends State { key: key, icon: const Icon( SimpleLineIcons.close, - size: 11.0, + size: 11, color: AppColors.errorColor, ), outlineColor: AppColors.errorColor, @@ -165,14 +162,12 @@ class _PlasmaListState extends State { _sortAscending ? _stakingList.sort((a, b) => a.qsrAmount.compareTo(b.qsrAmount)) : _stakingList.sort((a, b) => b.qsrAmount.compareTo(a.qsrAmount)); - break; case 'Beneficiary': _sortAscending ? _stakingList .sort((a, b) => a.beneficiary.compareTo(b.beneficiary)) : _stakingList .sort((a, b) => b.beneficiary.compareTo(a.beneficiary)); - break; default: _sortAscending ? _stakingList @@ -195,10 +190,10 @@ class _PlasmaListState extends State { FusionEntry plasmaItem, PlasmaListBloc model, ) { - int heightUntilCancellation = + final heightUntilCancellation = plasmaItem.expirationHeight - model.lastMomentumHeight!; - Duration durationUntilCancellation = + final durationUntilCancellation = kIntervalBetweenMomentums * heightUntilCancellation; if (plasmaItem.isRevocable!) { diff --git a/lib/widgets/modular_widgets/plasma_widgets/plasma_options/plasma_options.dart b/lib/widgets/modular_widgets/plasma_widgets/plasma_options/plasma_options.dart index 91329af2..219c5136 100644 --- a/lib/widgets/modular_widgets/plasma_widgets/plasma_options/plasma_options.dart +++ b/lib/widgets/modular_widgets/plasma_widgets/plasma_options/plasma_options.dart @@ -19,16 +19,15 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PlasmaOptions extends StatefulWidget { - final List plasmaStatsResults; - final String? errorText; - final PlasmaListBloc plasmaListBloc; const PlasmaOptions({ required this.plasmaListBloc, - this.errorText, - required this.plasmaStatsResults, + required this.plasmaStatsResults, this.errorText, super.key, }); + final List plasmaStatsResults; + final String? errorText; + final PlasmaListBloc plasmaListBloc; @override State createState() { @@ -50,8 +49,8 @@ class _PlasmaOptionsState extends State { BigInt _maxQsrAmount = BigInt.zero; double? _maxWidth; - final double _marginWidth = 20.0; - final double _spaceBetweenExpandedWidgets = 10.0; + final double _marginWidth = 20; + final double _spaceBetweenExpandedWidgets = 10; final int _beneficiaryAddressExpandedFlex = 8; final int _fuseButtonExpandedFlex = 6; @@ -112,12 +111,12 @@ class _PlasmaOptionsState extends State { ); } return const Padding( - padding: EdgeInsets.all(8.0), + padding: EdgeInsets.all(8), child: SyriusLoadingWidget(), ); } return const Padding( - padding: EdgeInsets.all(8.0), + padding: EdgeInsets.all(8), child: SyriusLoadingWidget(), ); }, @@ -148,7 +147,7 @@ class _PlasmaOptionsState extends State { children: [ DisabledAddressField( _addressController, - contentLeftPadding: 20.0, + contentLeftPadding: 20, ), StepperUtils.getBalanceWidget(kQsrCoin, accountInfo!), Form( @@ -159,12 +158,12 @@ class _PlasmaOptionsState extends State { _beneficiaryAddressString.value = value; }, inputFormatters: [ - FilteringTextInputFormatter.allow(RegExp(r'[0-9a-z]')), + FilteringTextInputFormatter.allow(RegExp('[0-9a-z]')), ], controller: _beneficiaryAddressController, hintText: 'Beneficiary address', - contentLeftPadding: 20.0, - validator: (value) => InputValidators.checkAddress(value), + contentLeftPadding: 20, + validator: InputValidators.checkAddress, ), ), ], @@ -179,7 +178,7 @@ class _PlasmaOptionsState extends State { crossAxisAlignment: CrossAxisAlignment.stretch, children: [ SizedBox( - height: 87.0, + height: 87, child: Form( key: _qsrAmountKey, autovalidateMode: AutovalidateMode.onUserInteraction, @@ -202,7 +201,7 @@ class _PlasmaOptionsState extends State { ), suffixIcon: _getAmountSuffix(), hintText: 'Amount', - contentLeftPadding: 20.0, + contentLeftPadding: 20, ), ), ), @@ -217,12 +216,12 @@ class _PlasmaOptionsState extends State { child: Row( children: [ const SizedBox( - width: 10.0, + width: 10, ), _getPlasmaIcon(), ], ), - ) + ), ], ); }, @@ -242,8 +241,8 @@ class _PlasmaOptionsState extends State { 'currentPlasma': ((_qsrAmountController.text.isNotEmpty ? BigInt.parse(zenon!.embedded.plasma .getPlasmaByQsr(_qsrAmountController.text - .extractDecimals(coinDecimals)) - .addDecimals(coinDecimals)) + .extractDecimals(coinDecimals),) + .addDecimals(coinDecimals),) : BigInt.zero) + BigInt.from(_getPlasmaForCurrentBeneficiary())) .toInt(), @@ -269,21 +268,21 @@ class _PlasmaOptionsState extends State { } Widget _getGeneratePlasmaButton(PlasmaOptionsBloc model) { - Widget icon = Container( + final Widget icon = Container( decoration: const BoxDecoration( shape: BoxShape.circle, color: AppColors.qsrColor, ), - padding: const EdgeInsets.symmetric(horizontal: 5.0, vertical: 15.0), + padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 15), child: const Icon( MaterialCommunityIcons.lightning_bolt, - size: 15.0, + size: 15, color: Colors.white, ), ); - double widthOfPlasmaIcon = _isInputValid() ? 20.0 : 0.0; - double plasmaIconMargin = _isInputValid() ? 10.0 : 0.0; + final widthOfPlasmaIcon = _isInputValid() ? 20.0 : 0.0; + final plasmaIconMargin = _isInputValid() ? 10.0 : 0.0; return LoadingButton.icon( onPressed: _isInputValid() ? () => _onGeneratePlasmaPressed(model) : null, @@ -291,12 +290,12 @@ class _PlasmaOptionsState extends State { outlineColor: AppColors.qsrColor, icon: icon, minimumSize: Size( - ((_maxWidth! - _marginWidth * 2 - _spaceBetweenExpandedWidgets) / + (_maxWidth! - _marginWidth * 2 - _spaceBetweenExpandedWidgets) / (_beneficiaryAddressExpandedFlex + _fuseButtonExpandedFlex) * _fuseButtonExpandedFlex - widthOfPlasmaIcon - - plasmaIconMargin), - 40.0), + plasmaIconMargin, + 40,), key: _fuseButtonKey, ); } @@ -352,7 +351,7 @@ class _PlasmaOptionsState extends State { ); }, builder: (_, model, __) => _getGeneratePlasmaButton(model), - viewModelBuilder: () => PlasmaOptionsBloc(), + viewModelBuilder: PlasmaOptionsBloc.new, ); } diff --git a/lib/widgets/modular_widgets/sentinel_widgets/create_sentinel.dart b/lib/widgets/modular_widgets/sentinel_widgets/create_sentinel.dart index 0d741f83..fed62bc1 100644 --- a/lib/widgets/modular_widgets/sentinel_widgets/create_sentinel.dart +++ b/lib/widgets/modular_widgets/sentinel_widgets/create_sentinel.dart @@ -8,12 +8,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class CreateSentinel extends StatefulWidget { - final VoidCallback onStepperNotificationSeeMorePressed; const CreateSentinel({ required this.onStepperNotificationSeeMorePressed, super.key, }); + final VoidCallback onStepperNotificationSeeMorePressed; @override State createState() => _CreateSentinelState(); @@ -94,8 +94,8 @@ class _CreateSentinelState extends State { icon: _getFilledButtonIcon(), ), const SizedBox( - width: 10.0, - ) + width: 10, + ), ], ); } @@ -110,7 +110,7 @@ class _CreateSentinelState extends State { child: const Icon( MaterialCommunityIcons.eye, color: Colors.white, - size: 15.0, + size: 15, ), ); } diff --git a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_collect.dart b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_collect.dart index c079c805..e80f93bc 100644 --- a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_collect.dart +++ b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_collect.dart @@ -11,12 +11,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class SentinelCollect extends StatefulWidget { - final SentinelRewardsHistoryBloc sentinelRewardsHistoryBloc; const SentinelCollect({ required this.sentinelRewardsHistoryBloc, super.key, }); + final SentinelRewardsHistoryBloc sentinelRewardsHistoryBloc; @override State createState() => _SentinelCollectState(); @@ -39,7 +39,7 @@ class _SentinelCollectState extends State { 'deployed (use znn-controller for this operation) and it must have >90% ' 'daily uptime', childBuilder: () => Padding( - padding: const EdgeInsets.all(16.0), + padding: const EdgeInsets.all(16), child: _getFutureBuilder(), ), ); @@ -69,21 +69,19 @@ class _SentinelCollectState extends State { children: [ NumberAnimation( end: uncollectedReward.znnAmount.addDecimals(coinDecimals).toNum(), - isInt: false, after: ' ${kZnnCoin.symbol}', style: Theme.of(context).textTheme.headlineLarge!.copyWith( color: AppColors.znnColor, - fontSize: 30.0, + fontSize: 30, ), ), kVerticalSpacing, NumberAnimation( end: uncollectedReward.qsrAmount.addDecimals(coinDecimals).toNum(), - isInt: false, after: ' ${kQsrCoin.symbol}', style: Theme.of(context).textTheme.headlineLarge!.copyWith( color: AppColors.qsrColor, - fontSize: 30.0, + fontSize: 30, ), ), kVerticalSpacing, @@ -103,7 +101,7 @@ class _SentinelCollectState extends State { ); } - void _onCollectPressed() async { + Future _onCollectPressed() async { try { _collectButtonKey.currentState?.animateForward(); await AccountBlockUtils.createAccountBlock( diff --git a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_list_widget.dart b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_list_widget.dart index 3e48cbcf..2140e5de 100644 --- a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_list_widget.dart +++ b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_list_widget.dart @@ -50,7 +50,6 @@ class _SentinelListWidgetState extends State { ), const InfiniteScrollTableHeaderColumn( columnName: '', - onSortArrowsPressed: null, ), ], generateRowCells: (sentinelInfo, isSelected) { @@ -65,11 +64,9 @@ class _SentinelListWidgetState extends State { InfiniteScrollTableCell( _getSentinelRevokeTimer(sentinelInfo, bloc), ), - isStakeAddressDefault(sentinelInfo) - ? InfiniteScrollTableCell( + if (isStakeAddressDefault(sentinelInfo)) InfiniteScrollTableCell( _getCancelContainer(isSelected, sentinelInfo, bloc), - ) - : const Spacer(), + ) else const Spacer(), ]; }, ); @@ -82,12 +79,10 @@ class _SentinelListWidgetState extends State { return Visibility( visible: isStakeAddressDefault(sentinelInfo), child: Stack( - fit: StackFit.loose, children: [ Row( children: [ - sentinelInfo.isRevocable - ? CancelTimer( + if (sentinelInfo.isRevocable) CancelTimer( Duration( seconds: sentinelInfo.revokeCooldown, ), @@ -95,8 +90,7 @@ class _SentinelListWidgetState extends State { onTimeFinishedCallback: () { model.refreshResults(); }, - ) - : CancelTimer( + ) else CancelTimer( Duration( seconds: sentinelInfo.revokeCooldown, ), @@ -106,7 +100,7 @@ class _SentinelListWidgetState extends State { }, ), const SizedBox( - width: 5.0, + width: 5, ), StandardTooltipIcon( sentinelInfo.isRevocable @@ -136,7 +130,6 @@ class _SentinelListWidgetState extends State { return Visibility( visible: sentinelInfo.isRevocable, child: Stack( - fit: StackFit.loose, alignment: Alignment.center, children: [ _getDisassembleButtonViewModel(isSelected, model, sentinelInfo), @@ -151,7 +144,7 @@ class _SentinelListWidgetState extends State { SentinelInfo sentinelInfo, ) { return MyOutlinedButton( - minimumSize: const Size(55.0, 25.0), + minimumSize: const Size(55, 25), outlineColor: isSelected ? AppColors.errorColor : Theme.of(context).textTheme.titleSmall!.color, @@ -172,11 +165,11 @@ class _SentinelListWidgetState extends State { : Theme.of(context).textTheme.titleSmall, ), const SizedBox( - width: 20.0, + width: 20, ), Icon( SimpleLineIcons.close, - size: 11.0, + size: 11, color: isSelected ? AppColors.errorColor : Theme.of(context).textTheme.titleSmall!.color, @@ -192,14 +185,12 @@ class _SentinelListWidgetState extends State { _sortAscending ? _sentinels.sort((a, b) => a.owner.compareTo(b.owner)) : _sentinels.sort((a, b) => b.owner.compareTo(a.owner)); - break; case 'Registration time': _sortAscending ? _sentinels.sort((a, b) => - a.registrationTimestamp.compareTo(b.registrationTimestamp)) + a.registrationTimestamp.compareTo(b.registrationTimestamp),) : _sentinels.sort((a, b) => - b.registrationTimestamp.compareTo(a.registrationTimestamp)); - break; + b.registrationTimestamp.compareTo(a.registrationTimestamp),); case 'Reward Address': default: break; @@ -241,12 +232,12 @@ class _SentinelListWidgetState extends State { if (snapshot.hasData) { return _getDisassembleButton(isSelected, model, sentinelInfo); } - return const SyriusLoadingWidget(size: 25.0); + return const SyriusLoadingWidget(size: 25); } return _getDisassembleButton(isSelected, model, sentinelInfo); }, ), - viewModelBuilder: () => DisassembleButtonBloc(), + viewModelBuilder: DisassembleButtonBloc.new, ); } } diff --git a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_rewards.dart b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_rewards.dart index 0409c1fb..8b93214d 100644 --- a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_rewards.dart +++ b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_rewards.dart @@ -4,12 +4,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class SentinelRewards extends StatefulWidget { - final SentinelRewardsHistoryBloc sentinelRewardsHistoryBloc; const SentinelRewards({ required this.sentinelRewardsHistoryBloc, super.key, }); + final SentinelRewardsHistoryBloc sentinelRewardsHistoryBloc; @override State createState() { @@ -25,7 +25,7 @@ class _SentinelRewardsState extends State { description: 'This card displays a chart with your Sentinel rewards from ' 'your Sentinel Node', childBuilder: () => Padding( - padding: const EdgeInsets.all(16.0), + padding: const EdgeInsets.all(16), child: _getStreamBody(), ), ); diff --git a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_stepper_container.dart b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_stepper_container.dart index 3de109f9..d7d9567e 100644 --- a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_stepper_container.dart +++ b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_stepper_container.dart @@ -125,12 +125,12 @@ class _MainSentinelState extends State { return SyriusErrorWidget(snapshot.error!); } return const Padding( - padding: EdgeInsets.all(8.0), + padding: EdgeInsets.all(8), child: SyriusLoadingWidget(), ); }, ), - viewModelBuilder: () => SentinelsQsrInfoBloc(), + viewModelBuilder: SentinelsQsrInfoBloc.new, ); } @@ -157,10 +157,10 @@ class _MainSentinelState extends State { ], ), const SizedBox( - height: 10.0, + height: 10, ), Padding( - padding: const EdgeInsets.only(left: 20.0), + padding: const EdgeInsets.only(left: 20), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -177,7 +177,7 @@ class _MainSentinelState extends State { ), ), const SizedBox( - height: 10.0, + height: 10, ), Row( children: [ @@ -199,7 +199,7 @@ class _MainSentinelState extends State { ), suffixIcon: _getAmountSuffix(accountInfo), suffixIconConstraints: - const BoxConstraints(maxWidth: 50.0), + const BoxConstraints(maxWidth: 50), hintText: 'Amount', onChanged: (value) { setState(() {}); @@ -210,7 +210,7 @@ class _MainSentinelState extends State { ], ), Padding( - padding: const EdgeInsets.symmetric(vertical: 25.0), + padding: const EdgeInsets.symmetric(vertical: 25), child: DottedBorderInfoWidget( text: 'You will be able to unlock the ${kQsrCoin.symbol} if you ' @@ -234,12 +234,12 @@ class _MainSentinelState extends State { ), ), ], - ) + ), ], ), ), const SizedBox( - width: 45.0, + width: 45, ), Expanded( child: Visibility( @@ -250,10 +250,10 @@ class _MainSentinelState extends State { borderRadius: BorderRadius.circular(6), ), margin: const EdgeInsets.only( - bottom: 30.0, + bottom: 30, ), child: Padding( - padding: const EdgeInsets.symmetric(vertical: 30.0), + padding: const EdgeInsets.symmetric(vertical: 30), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ @@ -263,15 +263,15 @@ class _MainSentinelState extends State { alignment: Alignment.center, children: [ SizedBox( - width: 150.0, - height: 150.0, + width: 150, + height: 150, child: AspectRatio( - aspectRatio: 1.0, + aspectRatio: 1, child: StandardPieChart( sections: [ PieChartSectionData( showTitle: false, - radius: 7.0, + radius: 7, value: (qsrInfo.cost - qsrInfo.deposit) / qsrInfo.cost, color: @@ -279,7 +279,7 @@ class _MainSentinelState extends State { ), PieChartSectionData( showTitle: false, - radius: 7.0, + radius: 7, value: qsrInfo.deposit / qsrInfo.cost, color: AppColors.qsrColor, ), @@ -300,7 +300,7 @@ class _MainSentinelState extends State { Column( children: [ SizedBox( - width: 130.0, + width: 130, child: Text( 'You have deposited ${qsrInfo.deposit.addDecimals(coinDecimals)} ' '${kQsrCoin.symbol}', @@ -325,7 +325,7 @@ class _MainSentinelState extends State { } Widget _getDepositQsrViewModel( - AccountInfo accountInfo, SentinelsQsrInfo qsrInfo) { + AccountInfo accountInfo, SentinelsQsrInfo qsrInfo,) { return ViewModelBuilder.reactive( onViewModelReady: (model) { model.stream.listen( @@ -352,7 +352,7 @@ class _MainSentinelState extends State { }, builder: (_, model, __) => _getDepositQsrButton(model, accountInfo, qsrInfo), - viewModelBuilder: () => SentinelsDepositQsrBloc(), + viewModelBuilder: SentinelsDepositQsrBloc.new, ); } @@ -397,7 +397,7 @@ class _MainSentinelState extends State { ); }, builder: (_, model, __) => _getWithdrawQsrButton(model, qsrDeposit), - viewModelBuilder: () => SentinelsWithdrawQsrBloc(), + viewModelBuilder: SentinelsWithdrawQsrBloc.new, ); } @@ -483,7 +483,7 @@ class _MainSentinelState extends State { Widget _getDeploySentinelStepBody(BuildContext context) { return Padding( padding: const EdgeInsets.only( - bottom: 25.0, + bottom: 25, ), child: Row( children: [ @@ -501,7 +501,7 @@ class _MainSentinelState extends State { if (response != null) { _registerButtonKey.currentState?.animateReverse(); _saveProgressAndNavigateToNextStep( - SentinelStepperStep.deploySentinel); + SentinelStepperStep.deploySentinel,); setState(() {}); } else { setState(() {}); @@ -518,7 +518,7 @@ class _MainSentinelState extends State { ); }, builder: (_, model, __) => _getRegisterSentinelButton(model), - viewModelBuilder: () => SentinelsDeployBloc(), + viewModelBuilder: SentinelsDeployBloc.new, ); } @@ -538,7 +538,6 @@ class _MainSentinelState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( child: DisabledAddressField(_addressController), @@ -560,11 +559,10 @@ class _MainSentinelState extends State { ], ), Padding( - padding: const EdgeInsets.symmetric(vertical: 25.0), + padding: const EdgeInsets.symmetric(vertical: 25), child: DottedBorderInfoWidget( text: 'You will be able to unlock the ${kZnnCoin.symbol} if you ' 'choose to disassemble the Sentinel', - borderColor: AppColors.znnColor, ), ), StepperButton( @@ -576,7 +574,7 @@ class _MainSentinelState extends State { } void _onDepositButtonPressed( - SentinelsDepositQsrBloc model, SentinelsQsrInfo qsrInfo) { + SentinelsDepositQsrBloc model, SentinelsQsrInfo qsrInfo,) { if (qsrInfo.deposit >= qsrInfo.cost) { _depositQsrButtonKey.currentState?.animateForward(); model.depositQsr( @@ -609,7 +607,7 @@ class _MainSentinelState extends State { if (_lastCompletedStep == SentinelStepperStep.znnManagement) { _registerButtonKey.currentState?.animateForward(); model.deploySentinel( - _znnAmountController.text.extractDecimals(coinDecimals)); + _znnAmountController.text.extractDecimals(coinDecimals),); } } @@ -633,22 +631,21 @@ class _MainSentinelState extends State { visible: _lastCompletedStep == SentinelStepperStep.deploySentinel, child: Column( mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( padding: const EdgeInsets.symmetric( - vertical: 40.0, - horizontal: 50.0, + vertical: 40, + horizontal: 50, ), margin: const EdgeInsets.symmetric( - vertical: 20.0, - horizontal: 50.0, + vertical: 20, + horizontal: 50, ), decoration: BoxDecoration( color: Theme.of(context).colorScheme.secondaryContainer, borderRadius: const BorderRadius.all( Radius.circular( - 10.0, + 10, ), ), ), @@ -691,7 +688,7 @@ class _MainSentinelState extends State { const WidgetSpan( child: Icon( MaterialCommunityIcons.link, - size: 20.0, + size: 20, color: AppColors.znnColor, ), ), @@ -709,7 +706,7 @@ class _MainSentinelState extends State { _getViewSentinelsButton(), ], ), - Container(height: 20.0) + Container(height: 20), ], ), ), @@ -718,10 +715,10 @@ class _MainSentinelState extends State { Visibility( visible: _lastCompletedStep == SentinelStepperStep.deploySentinel, child: Positioned( - right: 50.0, + right: 50, child: SizedBox( - width: 400.0, - height: 400.0, + width: 400, + height: 400, child: Center( child: Lottie.asset( 'assets/lottie/ic_anim_sentinel.json', @@ -737,7 +734,6 @@ class _MainSentinelState extends State { Widget _getViewSentinelsButton() { return StepperButton.icon( - context: context, label: 'View Sentinels', onPressed: () { Navigator.pop(context); @@ -790,7 +786,7 @@ class _MainSentinelState extends State { return _getPlasmaCheckBody(snapshot.data!); } return const Padding( - padding: EdgeInsets.all(8.0), + padding: EdgeInsets.all(8), child: SyriusLoadingWidget(), ); }, @@ -806,22 +802,21 @@ class _MainSentinelState extends State { style: Theme.of(context).textTheme.headlineSmall, ), const SizedBox( - height: 25.0, + height: 25, ), Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( child: DisabledAddressField(_addressController), ), const SizedBox( - width: 25.0, + width: 25, ), PlasmaIcon(plasmaInfo), ], ), const SizedBox( - height: 25.0, + height: 25, ), StepperButton( text: 'Next', diff --git a/lib/widgets/modular_widgets/settings_widgets/account_chain_stats.dart b/lib/widgets/modular_widgets/settings_widgets/account_chain_stats.dart index 468c77cc..811d7968 100644 --- a/lib/widgets/modular_widgets/settings_widgets/account_chain_stats.dart +++ b/lib/widgets/modular_widgets/settings_widgets/account_chain_stats.dart @@ -13,12 +13,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class AccountChainStatsWidget extends StatefulWidget { - final AccountChainStatsBloc accountChainStatsBloc; const AccountChainStatsWidget({ required this.accountChainStatsBloc, super.key, }); + final AccountChainStatsBloc accountChainStatsBloc; @override State createState() { @@ -33,7 +33,7 @@ class _AccountChainStatsState extends State { title: 'Account-chain Stats', description: 'This card displays information regarding the account-chain ' 'for the specified address', - childBuilder: () => _getStreamBuilder(), + childBuilder: _getStreamBuilder, ); } @@ -43,7 +43,7 @@ class _AccountChainStatsState extends State { shrinkWrap: true, children: [ Padding( - padding: const EdgeInsets.symmetric(vertical: 12.0), + padding: const EdgeInsets.symmetric(vertical: 12), child: Column( children: [ Text( @@ -64,8 +64,8 @@ class _AccountChainStatsState extends State { _getChartLegend(stats), RawMaterialButton( constraints: const BoxConstraints( - minWidth: 40.0, - minHeight: 40.0, + minWidth: 40, + minHeight: 40, ), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, onPressed: () => NavigationUtils.openUrl( @@ -78,10 +78,10 @@ class _AccountChainStatsState extends State { 'Block hash', style: Theme.of(context).textTheme.bodyMedium, ), - Container(width: 10.0), + Container(width: 10), const Icon( MaterialCommunityIcons.compass, - size: 20.0, + size: 20, color: AppColors.qsrColor, ), ], @@ -92,9 +92,9 @@ class _AccountChainStatsState extends State { Expanded( child: Container( padding: const EdgeInsets.only( - top: 12.0, - right: 22.0, - left: 22.0, + top: 12, + right: 22, + left: 22, ), child: Marquee( child: Text( @@ -103,7 +103,7 @@ class _AccountChainStatsState extends State { ), ), ), - ) + ), ], ), ], @@ -116,10 +116,10 @@ class _AccountChainStatsState extends State { Container _getChart(AccountChainStats stats) { return Container( - width: 150.0, - height: 150.0, + width: 150, + height: 150, margin: const EdgeInsets.all( - 10.0, + 10, ), child: StandardPieChart( sections: _getChartSections(stats), @@ -131,11 +131,11 @@ class _AccountChainStatsState extends State { AccountChainStats stats, BlockTypeEnum blockType, ) { - int blockTypeCount = stats.blockTypeNumOfBlocksMap[blockType]!; + final blockTypeCount = stats.blockTypeNumOfBlocksMap[blockType]!; return PieChartSectionData( showTitle: false, - radius: 7.0, + radius: 7, color: kBlockTypeColorMap[blockType] ?? AppColors.errorColor, value: 100.0 * blockTypeCount / stats.blockCount, ); @@ -174,8 +174,8 @@ class _AccountChainStatsState extends State { ) { return Container( margin: const EdgeInsets.symmetric( - horizontal: 20.0, - vertical: 4.0, + horizontal: 20, + vertical: 4, ), child: Row( mainAxisAlignment: MainAxisAlignment.center, @@ -191,7 +191,7 @@ class _AccountChainStatsState extends State { style: Theme.of(context).textTheme.bodyMedium, ), const SizedBox( - width: 10.0, + width: 10, ), AutoSizeText( blockTypeCount.toString(), @@ -203,7 +203,7 @@ class _AccountChainStatsState extends State { } Widget _getChartLegend(AccountChainStats stats) { - List typesWithBlocks = stats.blockTypeNumOfBlocksMap.keys + final typesWithBlocks = stats.blockTypeNumOfBlocksMap.keys .where((key) => stats.blockTypeNumOfBlocksMap[key]! > 0) .toList(); diff --git a/lib/widgets/modular_widgets/settings_widgets/addresses.dart b/lib/widgets/modular_widgets/settings_widgets/addresses.dart index 4736985f..ce6e80ca 100644 --- a/lib/widgets/modular_widgets/settings_widgets/addresses.dart +++ b/lib/widgets/modular_widgets/settings_widgets/addresses.dart @@ -14,12 +14,12 @@ import 'package:zenon_syrius_wallet_flutter/utils/notifiers/plasma_beneficiary_a import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class Addresses extends StatefulWidget { - final AccountChainStatsBloc accountChainStatsBloc; const Addresses({ required this.accountChainStatsBloc, super.key, }); + final AccountChainStatsBloc accountChainStatsBloc; @override State createState() { @@ -51,13 +51,13 @@ class AddressesState extends State { title: 'Addresses', description: 'Select the default address that will be used throughout ' 'the wallet for any network operation', - childBuilder: () => _getGenerateNewAddressFutureBuilder(), + childBuilder: _getGenerateNewAddressFutureBuilder, ); } Future _changeDefaultAddress(String? newDefaultAddress) async { try { - Box box = Hive.box(kSharedPrefsBox); + final box = Hive.box(kSharedPrefsBox); await box.put(kDefaultAddressKey, newDefaultAddress); if (!mounted) return; Provider.of( @@ -77,19 +77,17 @@ class AddressesState extends State { Widget _getAddAddressWidget() { return Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Expanded( - flex: 1, child: Container( - padding: const EdgeInsets.symmetric(horizontal: 20.0), + padding: const EdgeInsets.symmetric(horizontal: 20), child: NumberSelector.plain( borderColor: AppColors.znnColor, iconColor: AppColors.znnColor, dividerColor: AppColors.znnColor, - step: 1, current: 1, min: 1, max: 10, @@ -109,21 +107,21 @@ class AddressesState extends State { setState(() { _shouldScrollToTheEnd = true; }); - }); + },); }); }, child: Container( constraints: - const BoxConstraints(minWidth: 150.0, minHeight: 50.0), + const BoxConstraints(minWidth: 150, minHeight: 50), alignment: Alignment.center, child: Row( children: [ const Icon( Icons.add_circle, color: AppColors.znnColor, - size: 20.0, + size: 20, ), - const SizedBox(width: 10.0), + const SizedBox(width: 10), Text( (numberOfAddressesToAdd == 1) ? 'Add $numberOfAddressesToAdd address ' @@ -131,16 +129,16 @@ class AddressesState extends State { style: Theme.of(context).textTheme.bodyLarge, ), ], - )), + ),), ), - const SizedBox(width: 10.0), + const SizedBox(width: 10), ], ), ); } Widget _getAddresses() { - List addresses = kDefaultAddressList + final List addresses = kDefaultAddressList .map( (e) => Row( children: [ @@ -160,7 +158,7 @@ class AddressesState extends State { ) .toList(); - Widget listView = ListView.builder( + final Widget listView = ListView.builder( controller: _scrollController, key: const PageStorageKey('Addresses list view'), shrinkWrap: true, diff --git a/lib/widgets/modular_widgets/settings_widgets/backup.dart b/lib/widgets/modular_widgets/settings_widgets/backup.dart index 3c67f1ee..5434926b 100644 --- a/lib/widgets/modular_widgets/settings_widgets/backup.dart +++ b/lib/widgets/modular_widgets/settings_widgets/backup.dart @@ -45,7 +45,7 @@ class _BackupWidgetState extends State { ); } - void _onBackupWalletPressed() async { + Future _onBackupWalletPressed() async { kWalletFile! .access((wallet) => Future.value((wallet as KeyStore).mnemonic!)) .then((value) => NavigationUtils.push( @@ -54,7 +54,7 @@ class _BackupWidgetState extends State { value, backupWalletFlow: true, ), - )); + ),); } Widget _getDumpMnemonicButton() { diff --git a/lib/widgets/modular_widgets/settings_widgets/display.dart b/lib/widgets/modular_widgets/settings_widgets/display.dart index 63a5f396..2646ff77 100644 --- a/lib/widgets/modular_widgets/settings_widgets/display.dart +++ b/lib/widgets/modular_widgets/settings_widgets/display.dart @@ -40,7 +40,7 @@ class _DisplayWidget extends State { return CardScaffold( title: 'Display', description: 'Wallet appearance and theme settings', - childBuilder: () => _getWidgetBody(), + childBuilder: _getWidgetBody, ); } @@ -50,7 +50,7 @@ class _DisplayWidget extends State { children: [ CustomExpandablePanel('Text scaling', _getTextScalingExpandableChild()), CustomExpandablePanel('Locale', _getLocaleExpandableChild()), - CustomExpandablePanel('Theme', _getThemeExpandableChild()) + CustomExpandablePanel('Theme', _getThemeExpandableChild()), ], ); } @@ -88,7 +88,7 @@ class _DisplayWidget extends State { ? Provider.of( context, listen: false, - ).currentTextScaling + ).currentTextScaling as T : value is LocaleType ? _selectedLocaleType as T? : Provider.of( @@ -117,7 +117,7 @@ class _DisplayWidget extends State { child: Text( text, style: Theme.of(context).textTheme.bodyLarge!.copyWith( - fontSize: 10.0, + fontSize: 10, ), ), ), @@ -167,7 +167,7 @@ class _DisplayWidget extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: LoadingButton.settings( text: 'Confirm theme', onPressed: _onConfirmThemeButtonPressed, @@ -181,7 +181,7 @@ class _DisplayWidget extends State { Future _onConfirmThemeButtonPressed() async { try { _confirmThemeButtonKey.currentState!.animateForward(); - ThemeMode? currentThemeMode = Provider.of( + final currentThemeMode = Provider.of( context, listen: false, ).currentThemeMode; @@ -215,7 +215,7 @@ class _DisplayWidget extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: LoadingButton.settings( text: 'Confirm scale', onPressed: _onConfirmScaleButtonPressed, @@ -226,11 +226,11 @@ class _DisplayWidget extends State { ); } - void _onConfirmScaleButtonPressed() async { + Future _onConfirmScaleButtonPressed() async { try { _confirmScaleButtonKey.currentState!.animateForward(); - TextScaling? currentTextScaling = Provider.of( + final currentTextScaling = Provider.of( context, listen: false, ).currentTextScaling; @@ -246,7 +246,7 @@ class _DisplayWidget extends State { timestamp: DateTime.now().millisecondsSinceEpoch, details: 'Text scale successfully changed to ' '${FormatUtils.extractNameFromEnum(currentTextScaling)}', - type: NotificationType.paymentSent), + type: NotificationType.paymentSent,), ); } catch (e) { await NotificationUtils.sendNotificationError(e, 'Text scale change failed'); diff --git a/lib/widgets/modular_widgets/settings_widgets/general.dart b/lib/widgets/modular_widgets/settings_widgets/general.dart index a4400f67..c5287c5a 100644 --- a/lib/widgets/modular_widgets/settings_widgets/general.dart +++ b/lib/widgets/modular_widgets/settings_widgets/general.dart @@ -31,7 +31,7 @@ class GeneralWidgetState extends State { return CardScaffold( title: 'General', description: 'Generic wallet & network information', - childBuilder: () => _getStreamBuilder(), + childBuilder: _getStreamBuilder, ); } @@ -46,15 +46,15 @@ class GeneralWidgetState extends State { 'Momentum height', style: Theme.of(context).textTheme.titleMedium, ), - Container(height: 10.0), + Container(height: 10), Container( - width: 150.0, - height: 150.0, + width: 150, + height: 150, decoration: const ShapeDecoration( color: Colors.transparent, shape: CircleBorder( side: BorderSide( - width: 6.0, + width: 6, color: AppColors.znnColor, ), ), @@ -67,62 +67,56 @@ class GeneralWidgetState extends State { ), ), ), - Container(height: 10.0), + Container(height: 10), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - (generalStats.networkInfo.peers.isNotEmpty) - ? const Icon( + if (generalStats.networkInfo.peers.isNotEmpty) const Icon( MaterialCommunityIcons.lan_connect, - size: 15.0, + size: 15, color: AppColors.znnColor, - ) - : const Icon( + ) else const Icon( MaterialCommunityIcons.lan_disconnect, - size: 15.0, + size: 15, color: AppColors.errorColor, ), const SizedBox( - width: 4.0, + width: 4, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - (generalStats.networkInfo.peers.isNotEmpty) - ? Text( + if (generalStats.networkInfo.peers.isNotEmpty) Text( 'Peers connected', style: Theme.of(context).textTheme.bodyMedium, - ) - : const Text('Peers available'), + ) else const Text('Peers available'), const SizedBox( - width: 10.0, + width: 10, ), - (generalStats.networkInfo.peers.isNotEmpty) - ? Text( + if (generalStats.networkInfo.peers.isNotEmpty) Text( '${generalStats.networkInfo.peers.length}', style: Theme.of(context).textTheme.titleMedium, - ) - : Text( + ) else Text( 'No peers found', style: Theme.of(context).textTheme.bodyMedium, ), ], - ) + ), ], ), const SizedBox( - height: 10.0, + height: 10, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ const Icon( MaterialCommunityIcons.timer, - size: 15.0, + size: 15, color: AppColors.qsrColor, ), const SizedBox( - width: 4.0, + width: 4, ), Row( mainAxisAlignment: MainAxisAlignment.center, @@ -133,7 +127,7 @@ class GeneralWidgetState extends State { ), ], ), - const SizedBox(width: 10.0), + const SizedBox(width: 10), Text( '${generalStats.frontierMomentum.timestamp}', style: Theme.of(context).textTheme.titleMedium, @@ -145,7 +139,7 @@ class GeneralWidgetState extends State { ), RawMaterialButton( constraints: const BoxConstraints( - minHeight: 40.0, + minHeight: 40, ), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, onPressed: () => NavigationUtils.openUrl( @@ -158,10 +152,10 @@ class GeneralWidgetState extends State { 'Momentum hash', style: Theme.of(context).textTheme.bodyMedium, ), - Container(width: 10.0), + Container(width: 10), const Icon( MaterialCommunityIcons.compass, - size: 20.0, + size: 20, color: AppColors.znnColor, ), ], @@ -172,9 +166,9 @@ class GeneralWidgetState extends State { Expanded( child: Container( padding: const EdgeInsets.only( - top: 12.0, - right: 22.0, - left: 22.0, + top: 12, + right: 22, + left: 22, ), child: Marquee( child: Text( @@ -183,9 +177,9 @@ class GeneralWidgetState extends State { ), ), ), - ) + ), ], - ) + ), ], ), ], diff --git a/lib/widgets/modular_widgets/settings_widgets/node_management.dart b/lib/widgets/modular_widgets/settings_widgets/node_management.dart index e545c89b..e3b2d663 100644 --- a/lib/widgets/modular_widgets/settings_widgets/node_management.dart +++ b/lib/widgets/modular_widgets/settings_widgets/node_management.dart @@ -15,12 +15,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class NodeManagement extends StatefulWidget { - final VoidCallback onNodeChangedCallback; const NodeManagement({ required this.onNodeChangedCallback, super.key, }); + final VoidCallback onNodeChangedCallback; @override State createState() => _NodeManagementState(); @@ -73,7 +73,7 @@ class _NodeManagementState extends State { 'This card allows one to set the ZNN Node used to connect to. ' 'By default the wallet is connected to the Embedded Node. ' 'If you are running a local ZNN Node, please use the localhost option', - childBuilder: () => _getWidgetBody(), + childBuilder: _getWidgetBody, ); } @@ -106,7 +106,7 @@ class _NodeManagementState extends State { ); } - _getConfirmNodeSelectionButton() { + Row _getConfirmNodeSelectionButton() { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -127,7 +127,7 @@ class _NodeManagementState extends State { try { _confirmNodeButtonKey.currentState?.animateForward(); - var isConnectionEstablished = + final isConnectionEstablished = await _establishConnectionToNode(_selectedNode); if (isConnectionEstablished) { kNodeChainId = await NodeUtils.getNodeChainIdentifier(); @@ -137,14 +137,14 @@ class _NodeManagementState extends State { kSelectedNodeKey, _selectedNode, ); - kCurrentNode = _selectedNode!; + kCurrentNode = _selectedNode; await _sendChangingNodeSuccessNotification(); widget.onNodeChangedCallback(); } else { await _establishConnectionToNode(kCurrentNode); kNodeChainId = await NodeUtils.getNodeChainIdentifier(); setState(() { - _selectedNode = kCurrentNode!; + _selectedNode = kCurrentNode; }); } } else { @@ -156,7 +156,7 @@ class _NodeManagementState extends State { 'Connection failed', ); setState(() { - _selectedNode = kCurrentNode!; + _selectedNode = kCurrentNode; }); } finally { _confirmNodeButtonKey.currentState?.animateReverse(); @@ -164,8 +164,8 @@ class _NodeManagementState extends State { } Future _establishConnectionToNode(String? url) async { - String targetUrl = url == kEmbeddedNode ? kLocalhostDefaultNodeUrl : url!; - bool isConnectionEstablished = + final targetUrl = url == kEmbeddedNode ? kLocalhostDefaultNodeUrl : url!; + var isConnectionEstablished = await NodeUtils.establishConnectionToNode(targetUrl); if (url == kEmbeddedNode) { // Check if node is already running @@ -173,7 +173,7 @@ class _NodeManagementState extends State { // Initialize local full node await Isolate.spawn(EmbeddedNode.runNode, [''], onExit: - sl(instanceName: 'embeddedStoppedPort').sendPort); + sl(instanceName: 'embeddedStoppedPort').sendPort,); kEmbeddedNodeRunning = true; // The node needs a couple of seconds to actually start await Future.delayed(kEmbeddedConnectionDelay); @@ -230,7 +230,7 @@ class _NodeManagementState extends State { .contains(_newNodeController.text)) { await NotificationUtils.sendNotificationError( 'Node ${_newNodeController.text} already exists', - 'Node already exists'); + 'Node already exists',); } else { _addNodeToDb(); } @@ -259,8 +259,8 @@ class _NodeManagementState extends State { children: { ...kDefaultNodes, ...kDefaultCommunityNodes, - ...kDbNodes - }.toList().map((e) => _getNodeTile(e)).toList(), + ...kDbNodes, + }.toList().map(_getNodeTile).toList(), ); } @@ -328,7 +328,6 @@ class _NodeManagementState extends State { return Column( children: [ Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( child: Form( @@ -340,7 +339,7 @@ class _NodeManagementState extends State { ], controller: _newChainIdController, hintText: - 'Current client chain identifier is ${getChainIdentifier().toString()}', + 'Current client chain identifier is ${getChainIdentifier()}', onSubmitted: (value) async { if (_isChainIdSelectionInputIsValid()) { _onConfirmChainIdPressed(); @@ -353,7 +352,7 @@ class _NodeManagementState extends State { }, validator: InputValidators.validateNumber, ), - )), + ),), StandardTooltipIcon( (getChainIdentifier() == 1) ? 'Alphanet chain identifier' @@ -420,9 +419,9 @@ class _NodeManagementState extends State { } Future _checkForChainIdMismatch() async { - bool match = false; + var match = false; await zenon!.ledger.getFrontierMomentum().then((momentum) async { - int nodeChainId = momentum.chainIdentifier; + final nodeChainId = momentum.chainIdentifier; if (nodeChainId != _currentChainId) { match = await _showChainIdWarningDialog(nodeChainId, _currentChainId); } else { @@ -433,8 +432,8 @@ class _NodeManagementState extends State { } Future _showChainIdWarningDialog( - int nodeChainId, int currentChainId) async { - return await showWarningDialog( + int nodeChainId, int currentChainId,) async { + return showWarningDialog( context: context, title: 'Chain identifier mismatch', buttonText: 'Proceed anyway', diff --git a/lib/widgets/modular_widgets/settings_widgets/peers.dart b/lib/widgets/modular_widgets/settings_widgets/peers.dart index ce0ad654..ca12b3bc 100644 --- a/lib/widgets/modular_widgets/settings_widgets/peers.dart +++ b/lib/widgets/modular_widgets/settings_widgets/peers.dart @@ -29,7 +29,7 @@ class _PeersWidget extends State { title: 'Peers', description: 'This card displays information about connected network peers', - childBuilder: () => _getStreamBuilder(), + childBuilder: _getStreamBuilder, ); } @@ -81,12 +81,10 @@ class _PeersWidget extends State { _sortAscending ? _peers!.sort((a, b) => a.ip.compareTo(b.ip)) : _peers!.sort((a, b) => b.ip.compareTo(a.ip)); - break; case 'Public Key': _sortAscending ? _peers!.sort((a, b) => a.publicKey.compareTo(b.publicKey)) : _peers!.sort((a, b) => b.publicKey.compareTo(a.publicKey)); - break; default: _sortAscending ? _peers!.sort((a, b) => a.ip.compareTo(b.ip)) diff --git a/lib/widgets/modular_widgets/settings_widgets/security.dart b/lib/widgets/modular_widgets/settings_widgets/security.dart index 1fce58e4..99ece4dd 100644 --- a/lib/widgets/modular_widgets/settings_widgets/security.dart +++ b/lib/widgets/modular_widgets/settings_widgets/security.dart @@ -17,19 +17,19 @@ import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; -const double _kMaxMinutesOfInactivity = 30.0; -const double _kMinUnlockAttempts = 3.0; -const double _kMaxUnlockAttempts = 10.0; +const double _kMaxMinutesOfInactivity = 30; +const double _kMinUnlockAttempts = 3; +const double _kMaxUnlockAttempts = 10; class SecurityWidget extends StatefulWidget { - final VoidCallback _onChangeAutoLockTime; - final VoidCallback onStepperNotificationSeeMorePressed; const SecurityWidget( this._onChangeAutoLockTime, { required this.onStepperNotificationSeeMorePressed, super.key, }); + final VoidCallback _onChangeAutoLockTime; + final VoidCallback onStepperNotificationSeeMorePressed; @override State createState() { @@ -174,7 +174,7 @@ class _SecurityWidgetState extends State { ); } - void _onConfirmAutoLockDurationButtonPressed() async { + Future _onConfirmAutoLockDurationButtonPressed() async { try { _confirmIntervalButtonKey.currentState?.animateForward(); await sharedPrefsService! @@ -223,7 +223,6 @@ class _SecurityWidgetState extends State { details: 'The auto-erase limit has now ' '$kAutoEraseWalletLimit attempt(s)', timestamp: DateTime.now().millisecondsSinceEpoch, - id: null, type: NotificationType.autoEraseNumAttemptsChanged, ), ); @@ -268,11 +267,11 @@ class _SecurityWidgetState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox( - height: 10.0, + height: 10, ), const Text('Signature:'), const SizedBox( - height: 10.0, + height: 10, ), Row( children: [ @@ -286,11 +285,11 @@ class _SecurityWidgetState extends State { ], ), const SizedBox( - height: 10.0, + height: 10, ), const Text('Public key:'), const SizedBox( - height: 10.0, + height: 10, ), Row( children: [ @@ -353,12 +352,12 @@ class _SecurityWidgetState extends State { child: const Icon( Icons.content_paste, color: AppColors.darkHintTextColor, - size: 15.0, + size: 15, ), ), suffixIconConstraints: const BoxConstraints( - maxWidth: 45.0, - maxHeight: 20.0, + maxWidth: 45, + maxHeight: 20, ), ), kVerticalSpacing, @@ -384,12 +383,12 @@ class _SecurityWidgetState extends State { child: const Icon( Icons.content_paste, color: AppColors.darkHintTextColor, - size: 15.0, + size: 15, ), ), suffixIconConstraints: const BoxConstraints( - maxWidth: 45.0, - maxHeight: 20.0, + maxWidth: 45, + maxHeight: 20, ), ), kVerticalSpacing, @@ -415,12 +414,12 @@ class _SecurityWidgetState extends State { child: const Icon( Icons.content_paste, color: AppColors.darkHintTextColor, - size: 15.0, + size: 15, ), ), suffixIconConstraints: const BoxConstraints( - maxWidth: 45.0, - maxHeight: 20.0, + maxWidth: 45, + maxHeight: 20, ), ), kVerticalSpacing, @@ -440,7 +439,7 @@ class _SecurityWidgetState extends State { Future _onVerifyButtonPressed() async { try { _verifyButtonKey.currentState?.animateForward(); - bool verified = await Crypto.verify( + final verified = await Crypto.verify( FormatUtils.decodeHexString(_signatureController.text), Uint8List.fromList(_textToBeVerifiedController.text.codeUnits), FormatUtils.decodeHexString(_publicKeyToBeFilledController.text), @@ -466,7 +465,7 @@ class _SecurityWidgetState extends State { } } catch (e) { await NotificationUtils.sendNotificationError( - e, 'Error while verifying message'); + e, 'Error while verifying message',); } finally { _verifyButtonKey.currentState?.animateReverse(); } @@ -546,15 +545,15 @@ class _SecurityWidgetState extends State { ); } - void _onSignFileButtonPressed() async { + Future _onSignFileButtonPressed() async { try { _signFileButtonKey.currentState?.animateForward(); - File droppedFile = File( + final droppedFile = File( _toBeSignedFilePath!, ); final fileSignature = await walletSign(Crypto.digest( await droppedFile.readAsBytes(), - )); + ),); setState(() { _fileHashController.text = fileSignature.signature; _publicKeySignFileController.text = fileSignature.publicKey; @@ -621,12 +620,12 @@ class _SecurityWidgetState extends State { child: const Icon( Icons.content_paste, color: AppColors.darkHintTextColor, - size: 15.0, + size: 15, ), ), suffixIconConstraints: const BoxConstraints( - maxWidth: 45.0, - maxHeight: 20.0, + maxWidth: 45, + maxHeight: 20, ), ), kVerticalSpacing, @@ -652,15 +651,15 @@ class _SecurityWidgetState extends State { child: const Icon( Icons.content_paste, color: AppColors.darkHintTextColor, - size: 15.0, + size: 15, ), ), suffixIconConstraints: const BoxConstraints( - maxWidth: 45.0, - maxHeight: 20.0, + maxWidth: 45, + maxHeight: 20, ), ), - kVerticalSpacing + kVerticalSpacing, ], ), ], @@ -670,11 +669,11 @@ class _SecurityWidgetState extends State { Future _onVerifyFileButtonPressed() async { try { _verifyFileButtonKey.currentState?.animateForward(); - bool verified = await Crypto.verify( + final verified = await Crypto.verify( FormatUtils.decodeHexString(_fileHashVerifyController.text), Uint8List.fromList(Crypto.digest(await File( _toBeVerifiedFilePath!, - ).readAsBytes())), + ).readAsBytes(),),), FormatUtils.decodeHexString(_publicKeyVerifyFileController.text), ); if (verified) { @@ -699,7 +698,7 @@ class _SecurityWidgetState extends State { } } catch (e) { await NotificationUtils.sendNotificationError( - e, 'Error while verifying file hash:'); + e, 'Error while verifying file hash:',); } finally { _verifyFileButtonKey.currentState?.animateReverse(); } diff --git a/lib/widgets/modular_widgets/settings_widgets/wallet_options.dart b/lib/widgets/modular_widgets/settings_widgets/wallet_options.dart index 2d335549..5cf76f89 100644 --- a/lib/widgets/modular_widgets/settings_widgets/wallet_options.dart +++ b/lib/widgets/modular_widgets/settings_widgets/wallet_options.dart @@ -50,7 +50,7 @@ class _WalletOptionsState extends State { return CardScaffold( title: 'Wallet Options', description: 'Other wallet options', - childBuilder: () => _getWidgetBody(), + childBuilder: _getWidgetBody, ); } @@ -120,7 +120,7 @@ class _WalletOptionsState extends State { _getLaunchAtStartupWidget(), _getEnableDesktopNotifications(), _buildEnableClipboardWatcher(), - _getAutoReceiveWidget() + _getAutoReceiveWidget(), ], ); } @@ -160,7 +160,7 @@ class _WalletOptionsState extends State { sl().autoReceive(); }).onError((error, stackTrace) { Logger('MainAppContainer').log( - Level.WARNING, '_getAutoReceiveWidget', error, stackTrace); + Level.WARNING, '_getAutoReceiveWidget', error, stackTrace,); }); } else if (value == false && sl().pool.isNotEmpty) { @@ -183,7 +183,7 @@ class _WalletOptionsState extends State { } Future _setupLaunchAtStartup() async { - PackageInfo packageInfo = await PackageInfo.fromPlatform(); + final packageInfo = await PackageInfo.fromPlatform(); launchAtStartup.setup( appName: packageInfo.appName, appPath: Platform.resolvedExecutable, @@ -331,7 +331,7 @@ class _WalletOptionsState extends State { } Future _sendEnabledDesktopNotificationsStatusNotification( - bool enabled) async { + bool enabled,) async { await sl.get().addNotification( WalletNotification( title: 'Desktop notifications ${enabled ? 'enabled' : 'disabled'}', @@ -344,7 +344,7 @@ class _WalletOptionsState extends State { } Future _sendEnableClipboardWatcherStatusNotification( - bool enabled) async { + bool enabled,) async { await sl.get().addNotification( WalletNotification( title: 'Clipboard watcher ${enabled ? 'enabled' : 'disabled'}', diff --git a/lib/widgets/modular_widgets/staking_widgets/stake_collect.dart b/lib/widgets/modular_widgets/staking_widgets/stake_collect.dart index 90b8c0cd..5c550d75 100644 --- a/lib/widgets/modular_widgets/staking_widgets/stake_collect.dart +++ b/lib/widgets/modular_widgets/staking_widgets/stake_collect.dart @@ -11,12 +11,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class StakeCollect extends StatefulWidget { - final StakingRewardsHistoryBloc stakingRewardsHistoryBloc; const StakeCollect({ required this.stakingRewardsHistoryBloc, super.key, }); + final StakingRewardsHistoryBloc stakingRewardsHistoryBloc; @override State createState() => _StakeCollectState(); @@ -36,7 +36,7 @@ class _StakeCollectState extends State { 'ready to be collected. If there are any rewards available, you ' 'will be able to collect them', childBuilder: () => Padding( - padding: const EdgeInsets.all(16.0), + padding: const EdgeInsets.all(16), child: _getFutureBuilder(), ), ); @@ -65,11 +65,10 @@ class _StakeCollectState extends State { children: [ NumberAnimation( end: uncollectedReward.qsrAmount.addDecimals(coinDecimals).toNum(), - isInt: false, after: ' ${kQsrCoin.symbol}', style: Theme.of(context).textTheme.headlineLarge!.copyWith( color: AppColors.qsrColor, - fontSize: 30.0, + fontSize: 30, ), ), kVerticalSpacing, @@ -88,7 +87,7 @@ class _StakeCollectState extends State { ); } - void _onCollectPressed() async { + Future _onCollectPressed() async { try { _collectButtonKey.currentState?.animateForward(); await AccountBlockUtils.createAccountBlock( diff --git a/lib/widgets/modular_widgets/staking_widgets/staking_list/staking_list.dart b/lib/widgets/modular_widgets/staking_widgets/staking_list/staking_list.dart index 8ce9f82b..0aef875a 100644 --- a/lib/widgets/modular_widgets/staking_widgets/staking_list/staking_list.dart +++ b/lib/widgets/modular_widgets/staking_widgets/staking_list/staking_list.dart @@ -10,9 +10,9 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class StakingList extends StatefulWidget { - final StakingListBloc bloc; const StakingList(this.bloc, {super.key}); + final StakingListBloc bloc; @override State createState() { @@ -91,8 +91,8 @@ class _StakingListState extends State { showCopyToClipboardIcon: isSelected ? true : false, ), InfiniteScrollTableCell( - _getCancelContainer(isSelected, stakingItem, bloc)), - InfiniteScrollTableCell.withText(context, '') + _getCancelContainer(isSelected, stakingItem, bloc),), + InfiniteScrollTableCell.withText(context, ''), ]; }, ); @@ -105,16 +105,13 @@ class _StakingListState extends State { ) { return Stack( alignment: Alignment.centerLeft, - fit: StackFit.loose, children: [ - stakingItem.expirationTimestamp * 1000 < - DateTime.now().millisecondsSinceEpoch - ? _getCancelButtonViewModel( + if (stakingItem.expirationTimestamp * 1000 < + DateTime.now().millisecondsSinceEpoch) _getCancelButtonViewModel( stakingListModel, isSelected, stakingItem.id.toString(), - ) - : _getCancelTimer(stakingItem, stakingListModel) + ) else _getCancelTimer(stakingItem, stakingListModel), ], ); } @@ -124,7 +121,7 @@ class _StakingListState extends State { bool isSelected, String stakeHash, ) { - final GlobalKey cancelButtonKey = GlobalKey(); + final cancelButtonKey = GlobalKey(); return ViewModelBuilder.reactive( onViewModelReady: (model) { @@ -149,7 +146,7 @@ class _StakingListState extends State { stakeHash, cancelButtonKey, ), - viewModelBuilder: () => CancelStakeBloc(), + viewModelBuilder: CancelStakeBloc.new, ); } @@ -168,7 +165,7 @@ class _StakingListState extends State { key: key, icon: const Icon( SimpleLineIcons.close, - size: 11.0, + size: 11, color: AppColors.errorColor, ), textStyle: Theme.of(context).textTheme.titleSmall!.copyWith( @@ -183,7 +180,6 @@ class _StakingListState extends State { _sortAscending ? _stakingList.sort((a, b) => a.amount.compareTo(b.amount)) : _stakingList.sort((a, b) => b.amount.compareTo(a.amount)); - break; case 'Staking duration': _sortAscending ? _stakingList.sort( @@ -194,19 +190,16 @@ class _StakingListState extends State { (a, b) => (b.expirationTimestamp - b.startTimestamp) .compareTo(a.expirationTimestamp - a.startTimestamp), ); - break; case 'Recipient': _sortAscending ? _stakingList.sort((a, b) => a.address.compareTo(b.address)) : _stakingList.sort((a, b) => b.address.compareTo(a.address)); - break; case 'Expiration': _sortAscending ? _stakingList.sort((a, b) => - a.expirationTimestamp.compareTo(b.expirationTimestamp)) + a.expirationTimestamp.compareTo(b.expirationTimestamp),) : _stakingList.sort((a, b) => - b.expirationTimestamp.compareTo(a.expirationTimestamp)); - break; + b.expirationTimestamp.compareTo(a.expirationTimestamp),); default: _sortAscending ? _stakingList.sort((a, b) => a.address.compareTo(b.address)) @@ -223,7 +216,7 @@ class _StakingListState extends State { StakeEntry stakingItem, StakingListBloc model, ) { - int secondsUntilExpiration = stakingItem.expirationTimestamp - + final secondsUntilExpiration = stakingItem.expirationTimestamp - DateTime.now().millisecondsSinceEpoch ~/ 1000; return CancelTimer( Duration(seconds: secondsUntilExpiration), @@ -235,8 +228,8 @@ class _StakingListState extends State { } String _getStakingDurationInMonths(int seconds) { - int numDays = seconds / 3600 ~/ 24; - int numMonths = numDays ~/ 30; + final numDays = seconds / 3600 ~/ 24; + final numMonths = numDays ~/ 30; return '$numMonths month${numMonths > 1 ? 's' : ''}'; } diff --git a/lib/widgets/modular_widgets/staking_widgets/staking_options/staking_options.dart b/lib/widgets/modular_widgets/staking_widgets/staking_options/staking_options.dart index cc5d42df..d658ecd5 100644 --- a/lib/widgets/modular_widgets/staking_widgets/staking_options/staking_options.dart +++ b/lib/widgets/modular_widgets/staking_widgets/staking_options/staking_options.dart @@ -15,12 +15,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class StakingOptions extends StatefulWidget { - final StakingListBloc? stakingListViewModel; const StakingOptions( this.stakingListViewModel, { super.key, }); + final StakingListBloc? stakingListViewModel; @override State createState() { @@ -32,10 +32,10 @@ class _StakingOptionsState extends State { Duration? _selectedStakeDuration; final List _durations = List.generate( - (stakeTimeMaxSec ~/ stakeTimeUnitSec), + stakeTimeMaxSec ~/ stakeTimeUnitSec, (index) => Duration( seconds: (index + 1) * stakeTimeUnitSec, - )); + ),); BigInt _maxZnnAmount = BigInt.zero; @@ -95,21 +95,21 @@ class _StakingOptionsState extends State { Widget _getWidgetBody(AccountInfo? accountInfo) { return Container( margin: const EdgeInsets.all( - 20.0, + 20, ), child: ListView( shrinkWrap: true, children: [ DisabledAddressField( _addressController, - contentLeftPadding: 20.0, + contentLeftPadding: 20, ), StepperUtils.getBalanceWidget(kZnnCoin, accountInfo!), Container( - padding: const EdgeInsets.only(left: 20.0), + padding: const EdgeInsets.only(left: 20), decoration: BoxDecoration( color: Theme.of(context).inputDecorationTheme.fillColor, - borderRadius: BorderRadius.circular(5.0), + borderRadius: BorderRadius.circular(5), ), child: _getStakeDurationDropdown(), ), @@ -134,7 +134,7 @@ class _StakingOptionsState extends State { ), suffixIcon: _getZnnAmountSuffix(), hintText: 'Amount', - contentLeftPadding: 20.0, + contentLeftPadding: 20, ), ), kVerticalSpacing, @@ -174,20 +174,20 @@ class _StakingOptionsState extends State { ); }, builder: (_, model, __) => _getStakeForQsrButton(model), - viewModelBuilder: () => StakingOptionsBloc(), + viewModelBuilder: StakingOptionsBloc.new, ); } Widget _getStakeForQsrButton(StakingOptionsBloc model) { - Widget icon = Container( + final Widget icon = Container( decoration: const BoxDecoration( shape: BoxShape.circle, color: AppColors.znnColor, ), - padding: const EdgeInsets.symmetric(horizontal: 5.0, vertical: 15.0), + padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 15), child: const Icon( MaterialCommunityIcons.lock_smart, - size: 15.0, + size: 15, color: Colors.white, ), ); @@ -197,7 +197,7 @@ class _StakingOptionsState extends State { label: 'Stake', icon: icon, key: _stakeButtonKey, - minimumSize: Size(_maxWidth! - 2 * 20.0, 40.0), + minimumSize: Size(_maxWidth! - 2 * 20.0, 40), ); } @@ -209,10 +209,10 @@ class _StakingOptionsState extends State { style: Theme.of(context).inputDecorationTheme.hintStyle, ), icon: Container( - margin: const EdgeInsets.symmetric(horizontal: 10.0), + margin: const EdgeInsets.symmetric(horizontal: 10), child: Icon( SimpleLineIcons.arrow_down, - size: 10.0, + size: 10, color: Theme.of(context).inputDecorationTheme.hintStyle!.color, ), ), @@ -225,7 +225,7 @@ class _StakingOptionsState extends State { '${duration.inSeconds ~/ stakeTimeUnitSec} $stakeUnitDurationName' '${(duration.inSeconds ~/ stakeTimeUnitSec) > 1 ? 's' : ''}', style: Theme.of(context).textTheme.bodyLarge!.copyWith( - fontSize: 12.0, + fontSize: 12, color: _selectedStakeDuration?.inDays == duration.inDays ? AppColors.znnColor : null, diff --git a/lib/widgets/modular_widgets/staking_widgets/staking_rewards.dart b/lib/widgets/modular_widgets/staking_widgets/staking_rewards.dart index db3d5865..67dac5f4 100644 --- a/lib/widgets/modular_widgets/staking_widgets/staking_rewards.dart +++ b/lib/widgets/modular_widgets/staking_widgets/staking_rewards.dart @@ -4,12 +4,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class StakingRewards extends StatefulWidget { - final StakingRewardsHistoryBloc stakingRewardsHistoryBloc; const StakingRewards({ required this.stakingRewardsHistoryBloc, super.key, }); + final StakingRewardsHistoryBloc stakingRewardsHistoryBloc; @override State createState() { @@ -26,7 +26,7 @@ class _StakingRewardsState extends State { 'your staking entries', childBuilder: () => Padding( padding: const EdgeInsets.all( - 16.0, + 16, ), child: _getStreamBody(), ), diff --git a/lib/widgets/modular_widgets/token_widgets/create_token.dart b/lib/widgets/modular_widgets/token_widgets/create_token.dart index 38e3715a..e4719034 100644 --- a/lib/widgets/modular_widgets/token_widgets/create_token.dart +++ b/lib/widgets/modular_widgets/token_widgets/create_token.dart @@ -5,12 +5,12 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class CreateToken extends StatefulWidget { - final VoidCallback onStepperNotificationSeeMorePressed; const CreateToken({ required this.onStepperNotificationSeeMorePressed, super.key, }); + final VoidCallback onStepperNotificationSeeMorePressed; @override State createState() { @@ -24,7 +24,7 @@ class _CreateTokenState extends State { return CardScaffold( title: 'Create Token', description: 'Create a token following the ZTS specification', - childBuilder: () => _getWidgetBody(), + childBuilder: _getWidgetBody, ); } @@ -34,12 +34,12 @@ class _CreateTokenState extends State { children: [ Lottie.asset( 'assets/lottie/ic_anim_zts.json', - width: 128.0, - height: 128.0, + width: 128, + height: 128, repeat: false, ), Container( - padding: const EdgeInsets.symmetric(horizontal: 48.0, vertical: 12.0), + padding: const EdgeInsets.symmetric(horizontal: 48, vertical: 12), child: SyriusElevatedButton( onPressed: () { Navigator.push( @@ -72,7 +72,7 @@ class _CreateTokenState extends State { child: const Icon( Icons.add, color: Colors.white, - size: 15.0, + size: 15, ), ); } diff --git a/lib/widgets/modular_widgets/token_widgets/token_balance.dart b/lib/widgets/modular_widgets/token_widgets/token_balance.dart index 6ece0033..ba1d9ef7 100644 --- a/lib/widgets/modular_widgets/token_widgets/token_balance.dart +++ b/lib/widgets/modular_widgets/token_widgets/token_balance.dart @@ -97,11 +97,11 @@ class _TokenBalanceState extends State { gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, childAspectRatio: 100 / 20, - crossAxisSpacing: 10.0, - mainAxisSpacing: 10.0, + crossAxisSpacing: 10, + mainAxisSpacing: 10, ), itemBuilder: (context, index) => Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Marquee( child: FormattedAmountWithTooltip( amount: _newTokenIds[index] @@ -115,10 +115,10 @@ class _TokenBalanceState extends State { '● ', style: Theme.of(context).textTheme.bodyLarge!.copyWith( color: ColorUtils.getTokenColor( - _newTokenIds[index].token!.tokenStandard), + _newTokenIds[index].token!.tokenStandard,), ), ), - _getTokenStatus(amount, symbol) + _getTokenStatus(amount, symbol), ], ), ), diff --git a/lib/widgets/modular_widgets/token_widgets/token_card.dart b/lib/widgets/modular_widgets/token_widgets/token_card.dart index f21e71a3..3949f23f 100644 --- a/lib/widgets/modular_widgets/token_widgets/token_card.dart +++ b/lib/widgets/modular_widgets/token_widgets/token_card.dart @@ -26,14 +26,14 @@ enum TokenCardBackVersion { } class TokenCard extends StatefulWidget { - final Token token; - final VoidCallback _favoritesCallback; const TokenCard( this.token, this._favoritesCallback, { super.key, }); + final Token token; + final VoidCallback _favoritesCallback; @override State createState() => _TokenCardState(); @@ -75,9 +75,6 @@ class _TokenCardState extends State { key: _cardKey, rotateSide: RotateSide.right, animationDuration: const Duration(milliseconds: 500), - axis: FlipAxis.vertical, - disableSplashEffect: false, - onTapFlipping: false, controller: _flipCardController, frontWidget: _getFrontOfCard(), backWidget: _getBackOfCard(), @@ -91,11 +88,11 @@ class _TokenCardState extends State { Widget _getBackOfCard() { return Container( padding: const EdgeInsets.symmetric( - horizontal: 20.0, - vertical: 10.0, + horizontal: 20, + vertical: 10, ), decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(10), color: Theme.of(context).colorScheme.primaryContainer, ), child: StreamBuilder?>( @@ -112,17 +109,17 @@ class _TokenCardState extends State { } return const SyriusLoadingWidget(); }, - )); + ),); } Container _getFrontOfCard() { return Container( padding: const EdgeInsets.symmetric( - horizontal: 20.0, - vertical: 10.0, + horizontal: 20, + vertical: 10, ), decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(10), color: Theme.of(context).colorScheme.primaryContainer, ), child: Column( @@ -132,15 +129,15 @@ class _TokenCardState extends State { Row( children: [ Container( - height: 5.0, - width: 5.0, + height: 5, + width: 5, decoration: BoxDecoration( shape: BoxShape.circle, color: ColorUtils.getTokenColor(widget.token.tokenStandard), ), ), const SizedBox( - width: 5.0, + width: 5, ), Tooltip( message: '${widget.token.name}: ${widget.token.symbol}', @@ -150,7 +147,7 @@ class _TokenCardState extends State { ), ), const SizedBox( - width: 5.0, + width: 5, ), ], ), @@ -178,7 +175,7 @@ class _TokenCardState extends State { ], ), const SizedBox( - height: 5.0, + height: 5, ), Wrap( children: [ @@ -238,7 +235,6 @@ class _TokenCardState extends State { _getTokenOptionIconButton( tooltip: 'Utility token', mouseCursor: SystemMouseCursors.basic, - onPressed: null, iconData: Icons.settings, ), TokenFavorite( @@ -248,7 +244,7 @@ class _TokenCardState extends State { ], ), const SizedBox( - height: 10.0, + height: 10, ), Text( '${widget.token.decimals} decimals', @@ -257,7 +253,7 @@ class _TokenCardState extends State { ], ), ), - _getAnimatedChart(widget.token) + _getAnimatedChart(widget.token), ], ), Row( @@ -276,8 +272,8 @@ class _TokenCardState extends State { ), RawMaterialButton( constraints: const BoxConstraints( - minWidth: 40.0, - minHeight: 40.0, + minWidth: 40, + minHeight: 40, ), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, shape: const CircleBorder(), @@ -285,8 +281,8 @@ class _TokenCardState extends State { child: Tooltip( message: 'Visit ${widget.token.domain}', child: Container( - height: 25.0, - width: 25.0, + height: 25, + width: 25, padding: const EdgeInsets.all(4), decoration: const BoxDecoration( shape: BoxShape.circle, @@ -294,12 +290,12 @@ class _TokenCardState extends State { ), child: const Icon( Icons.open_in_new, - size: 13.0, + size: 13, color: AppColors.darkHintTextColor, ), ), ), - ) + ), ], ), ], @@ -327,9 +323,9 @@ class _TokenCardState extends State { : mouseCursor, tooltip: tooltip, padding: EdgeInsets.zero, - splashRadius: 18.0, + splashRadius: 18, onPressed: onPressed, - iconSize: 25.0, + iconSize: 25, icon: Icon( iconData, color: isOwner != null @@ -343,27 +339,27 @@ class _TokenCardState extends State { } Widget _getAnimatedChart(Token token) { - BigInt totalSupply = token.totalSupply; + final totalSupply = token.totalSupply; - BigInt maxSupply = token.maxSupply; + final maxSupply = token.maxSupply; return Stack( alignment: Alignment.center, children: [ SizedBox( - height: 100.0, - width: 100.0, + height: 100, + width: 100, child: StandardPieChart( sections: [ PieChartSectionData( showTitle: false, - radius: 5.0, + radius: 5, value: totalSupply / maxSupply, color: ColorUtils.getTokenColor(widget.token.tokenStandard), ), PieChartSectionData( showTitle: false, - radius: 5.0, + radius: 5, value: (maxSupply - totalSupply) / maxSupply, color: Colors.white12, ), @@ -371,7 +367,7 @@ class _TokenCardState extends State { ), ), SizedBox( - width: 70.0, + width: 70, child: Marquee( child: FormattedAmountWithTooltip( amount: totalSupply.addDecimals(token.decimals), @@ -408,11 +404,11 @@ class _TokenCardState extends State { ), controller: _burnAmountController, validator: (value) => InputValidators.correctValue( - value, _burnMaxAmount, widget.token.decimals, BigInt.zero), + value, _burnMaxAmount, widget.token.decimals, BigInt.zero,), suffixIcon: _getAmountSuffix(), - suffixIconConstraints: const BoxConstraints(maxWidth: 50.0), + suffixIconConstraints: const BoxConstraints(maxWidth: 50), hintText: 'Amount', - contentLeftPadding: 20.0, + contentLeftPadding: 20, ), ), StepperUtils.getBalanceWidget(widget.token, accountInfo), @@ -424,13 +420,11 @@ class _TokenCardState extends State { children: [ _getBurnButtonViewModel(), const SizedBox( - height: 10.0, + height: 10, ), StepperButton( text: 'Go back', - onPressed: () { - _flipCard(); - }, + onPressed: _flipCard, ), ], ), @@ -463,12 +457,12 @@ class _TokenCardState extends State { ); }, builder: (_, model, __) => _getBurnButton(model), - viewModelBuilder: () => BurnTokenBloc(), + viewModelBuilder: BurnTokenBloc.new, ); } Future _sendBurnSuccessfulNotification( - AccountBlockTemplate event) async { + AccountBlockTemplate event,) async { await sl.get().addNotification( WalletNotification( title: 'Successfully burned ${event.amount.addDecimals( @@ -478,7 +472,7 @@ class _TokenCardState extends State { details: 'You have successfully burned the requested amount: ' '${event.amount.addDecimals( widget.token.decimals, - )} ${widget.token.symbol} ${event.hash.toString()}', + )} ${widget.token.symbol} ${event.hash}', type: NotificationType.burnToken, ), ); @@ -490,14 +484,14 @@ class _TokenCardState extends State { onPressed: _burnMaxAmount > BigInt.zero && _burnAmountController.text.isNotEmpty && InputValidators.correctValue(_burnAmountController.text, - _burnMaxAmount, widget.token.decimals, BigInt.zero) == + _burnMaxAmount, widget.token.decimals, BigInt.zero,) == null ? () { _burnButtonKey.currentState?.animateForward(); model.burnToken( widget.token, _burnAmountController.text - .extractDecimals(widget.token.decimals)); + .extractDecimals(widget.token.decimals),); } : null, key: _burnButtonKey, @@ -534,7 +528,7 @@ class _TokenCardState extends State { } Widget _getMintBackOfCard(AccountInfo? accountInfo) { - _mintMaxAmount = (widget.token.maxSupply - widget.token.totalSupply); + _mintMaxAmount = widget.token.maxSupply - widget.token.totalSupply; return ListView( shrinkWrap: true, @@ -547,12 +541,12 @@ class _TokenCardState extends State { setState(() {}); }, inputFormatters: [ - FilteringTextInputFormatter.allow(RegExp(r'[0-9a-z]')), + FilteringTextInputFormatter.allow(RegExp('[0-9a-z]')), ], controller: _beneficiaryAddressController, hintText: 'Beneficiary address', - contentLeftPadding: 20.0, - validator: (value) => InputValidators.checkAddress(value), + contentLeftPadding: 20, + validator: InputValidators.checkAddress, ), ), StepperUtils.getBalanceWidget(widget.token, accountInfo!), @@ -568,11 +562,11 @@ class _TokenCardState extends State { ), controller: _mintAmountController, validator: (value) => InputValidators.correctValue( - value, _mintMaxAmount, widget.token.decimals, BigInt.zero), + value, _mintMaxAmount, widget.token.decimals, BigInt.zero,), suffixIcon: _getAmountSuffix(), - suffixIconConstraints: const BoxConstraints(maxWidth: 50.0), + suffixIconConstraints: const BoxConstraints(maxWidth: 50), hintText: 'Amount', - contentLeftPadding: 20.0, + contentLeftPadding: 20, ), ), kVerticalSpacing, @@ -584,13 +578,11 @@ class _TokenCardState extends State { children: [ _getMintButtonViewModel(), const SizedBox( - height: 10.0, + height: 10, ), StepperButton( text: 'Go back', - onPressed: () { - _flipCard(); - }, + onPressed: _flipCard, ), ], ), @@ -618,15 +610,15 @@ class _TokenCardState extends State { 'Error while trying to mint ${widget.token.symbol}}', ); _mintButtonKey.currentState!.animateReverse(); - }); + },); }, builder: (_, model, __) => _getMintButton(model), - viewModelBuilder: () => MintTokenBloc(), + viewModelBuilder: MintTokenBloc.new, ); } Future _sendMintSuccessfulNotification( - AccountBlockTemplate event) async { + AccountBlockTemplate event,) async { await sl.get().addNotification( WalletNotification( title: 'Successfully minted ${event.amount.addDecimals( @@ -636,7 +628,7 @@ class _TokenCardState extends State { details: 'You have successfully minted the requested amount: ' '${event.amount.addDecimals( widget.token.decimals, - )} ${widget.token.symbol} ${event.hash.toString()}', + )} ${widget.token.symbol} ${event.hash}', type: NotificationType.paymentSent, ), ); @@ -651,7 +643,7 @@ class _TokenCardState extends State { _mintMaxAmount > BigInt.zero && _mintAmountController.text.isNotEmpty && InputValidators.correctValue(_mintAmountController.text, - _mintMaxAmount, widget.token.decimals, BigInt.zero) == + _mintMaxAmount, widget.token.decimals, BigInt.zero,) == null ? () { _mintButtonKey.currentState!.animateForward(); @@ -686,12 +678,12 @@ class _TokenCardState extends State { setState(() {}); }, inputFormatters: [ - FilteringTextInputFormatter.allow(RegExp(r'[0-9a-z]')), + FilteringTextInputFormatter.allow(RegExp('[0-9a-z]')), ], controller: _newOwnerAddressController, hintText: 'New owner address', - contentLeftPadding: 20.0, - validator: (value) => InputValidators.checkAddress(value), + contentLeftPadding: 20, + validator: InputValidators.checkAddress, ), ), kVerticalSpacing, @@ -703,13 +695,11 @@ class _TokenCardState extends State { children: [ _getTransferOwnershipButtonViewModel(), const SizedBox( - height: 10.0, + height: 10, ), StepperButton( text: 'Go back', - onPressed: () { - _flipCard(); - }, + onPressed: _flipCard, ), ], ), @@ -724,7 +714,7 @@ class _TokenCardState extends State { case TokenCardBackVersion.burn: return _getBurnBackOfCard(balanceMap[kSelectedAddress!]!); case TokenCardBackVersion.mint: - return _getMintBackOfCard(balanceMap[kSelectedAddress!]!); + return _getMintBackOfCard(balanceMap[kSelectedAddress!]); case TokenCardBackVersion.transferOwnership: return _getTransferOwnershipBackOfCard(); } @@ -748,7 +738,7 @@ class _TokenCardState extends State { error, 'Error while trying to transfer token ownership', ); - }); + },); }, builder: (_, model, __) => StreamBuilder( stream: model.stream, @@ -765,7 +755,7 @@ class _TokenCardState extends State { return _getTransferOwnershipButton(model); }, ), - viewModelBuilder: () => TransferOwnershipBloc(), + viewModelBuilder: TransferOwnershipBloc.new, ); } diff --git a/lib/widgets/modular_widgets/token_widgets/token_favorite.dart b/lib/widgets/modular_widgets/token_widgets/token_favorite.dart index f9fe7608..24645beb 100644 --- a/lib/widgets/modular_widgets/token_widgets/token_favorite.dart +++ b/lib/widgets/modular_widgets/token_widgets/token_favorite.dart @@ -10,14 +10,14 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class TokenFavorite extends StatefulWidget { - final Token token; - final VoidCallback _tokenFavoritesCallback; const TokenFavorite( this.token, this._tokenFavoritesCallback, { super.key, }); + final Token token; + final VoidCallback _tokenFavoritesCallback; @override State createState() => _TokenFavoriteState(); @@ -36,13 +36,13 @@ class _TokenFavoriteState extends State { color: Colors.transparent, child: _showLoading ? const SyriusLoadingWidget( - size: 15.0, + size: 15, ) : IconButton( padding: EdgeInsets.zero, - splashRadius: 18.0, + splashRadius: 18, onPressed: _onFavoriteIconPressed, - iconSize: 30.0, + iconSize: 30, icon: Icon( _getFavoriteIcons(), color: _getIconColor(), @@ -69,7 +69,7 @@ class _TokenFavoriteState extends State { title: '${widget.token.name} token has been added to favorites', details: 'Token ${widget.token.name} with symbol ' '${widget.token.name} and ZTS ' - '${widget.token.tokenStandard.toString()}', + '${widget.token.tokenStandard}', timestamp: DateTime.now().millisecondsSinceEpoch, type: NotificationType.addedTokenFavourite, ), @@ -88,7 +88,7 @@ class _TokenFavoriteState extends State { ); } - void _removeTokenFromFavorites() async { + Future _removeTokenFromFavorites() async { setState(() { _showLoading = true; }); @@ -106,7 +106,7 @@ class _TokenFavoriteState extends State { 'from favorites', details: 'Token ${widget.token.name} with symbol ' '${widget.token.name} and ZTS ' - '${widget.token.tokenStandard.toString()}', + '${widget.token.tokenStandard}', timestamp: DateTime.now().millisecondsSinceEpoch, type: NotificationType.addedTokenFavourite, ), diff --git a/lib/widgets/modular_widgets/token_widgets/token_map.dart b/lib/widgets/modular_widgets/token_widgets/token_map.dart index 98695a8c..57d88557 100644 --- a/lib/widgets/modular_widgets/token_widgets/token_map.dart +++ b/lib/widgets/modular_widgets/token_widgets/token_map.dart @@ -75,7 +75,7 @@ class _TokenMapState extends State { Widget _getWidgetBody(TokenMapBloc bloc) { return Padding( - padding: const EdgeInsets.all(15.0), + padding: const EdgeInsets.all(15), child: Column( children: [ InputField( diff --git a/lib/widgets/modular_widgets/token_widgets/token_stepper.dart b/lib/widgets/modular_widgets/token_widgets/token_stepper.dart index 1c81cae5..e77efe72 100644 --- a/lib/widgets/modular_widgets/token_widgets/token_stepper.dart +++ b/lib/widgets/modular_widgets/token_widgets/token_stepper.dart @@ -117,7 +117,6 @@ class _TokenStepperState extends State { child: Column( children: [ Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( child: Form( @@ -171,7 +170,7 @@ class _TokenStepperState extends State { ), ), const SizedBox( - height: 25.0, + height: 25, ), _getTokenDetailsActionButtons(), ], @@ -301,22 +300,21 @@ class _TokenStepperState extends State { style: Theme.of(context).textTheme.headlineSmall, ), const SizedBox( - height: 25.0, + height: 25, ), Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( child: DisabledAddressField(_addressController), ), const SizedBox( - width: 25.0, + width: 25, ), PlasmaIcon(plasmaInfo), ], ), const SizedBox( - height: 25.0, + height: 25, ), StepperButton( text: 'Next', @@ -344,7 +342,7 @@ class _TokenStepperState extends State { Widget _getIssueTokenStepContent(BuildContext context) { return Container( - margin: const EdgeInsets.only(bottom: 25.0), + margin: const EdgeInsets.only(bottom: 25), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -364,9 +362,9 @@ class _TokenStepperState extends State { style: Theme.of(context).inputDecorationTheme.hintStyle, ), const SizedBox( - width: 3.0, + width: 3, ), - const Icon(Icons.settings, size: 15.0, color: AppColors.ztsColor), + const Icon(Icons.settings, size: 15, color: AppColors.ztsColor), const StandardTooltipIcon( 'Token status: utility or ' 'non-utility (e.g. security token)', @@ -376,7 +374,7 @@ class _TokenStepperState extends State { ], ), Padding( - padding: const EdgeInsets.only(top: 25.0, bottom: 25.0, left: 15.0), + padding: const EdgeInsets.only(top: 25, bottom: 25, left: 15), child: DottedBorderInfoWidget( text: 'You will need to burn ' '${tokenZtsIssueFeeInZnn.addDecimals( @@ -387,7 +385,7 @@ class _TokenStepperState extends State { ), ), Padding( - padding: const EdgeInsets.only(left: 15.0), + padding: const EdgeInsets.only(left: 15), child: Row( children: [ Visibility( @@ -398,7 +396,7 @@ class _TokenStepperState extends State { children: [ _getStepBackButton(), const SizedBox( - width: 25.0, + width: 25, ), ], ), @@ -428,13 +426,13 @@ class _TokenStepperState extends State { return Column( children: [ Padding( - padding: const EdgeInsets.only(bottom: 20.0), + padding: const EdgeInsets.only(bottom: 20), child: CustomSlider( activeColor: AppColors.ztsColor, - description: 'Number of decimals: ${_selectedNumDecimals.toInt()}', - startValue: 0.0, - min: 0.0, - maxValue: 18.0, + description: 'Number of decimals: $_selectedNumDecimals', + startValue: 0, + min: 0, + maxValue: 18, callback: (double value) { setState(() { _selectedNumDecimals = value.toInt(); @@ -445,9 +443,8 @@ class _TokenStepperState extends State { Visibility( visible: _isMintable, child: Container( - margin: const EdgeInsets.only(bottom: 15.0), + margin: const EdgeInsets.only(bottom: 15), child: Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( child: Form( @@ -466,12 +463,11 @@ class _TokenStepperState extends State { ? (String? value) => InputValidators.correctValue( value, kBigP255m1, - _selectedNumDecimals.toInt(), + _selectedNumDecimals, kMinTokenTotalMaxSupply, canBeEqualToMin: true, ) - : (String? value) => - InputValidators.isMaxSupplyZero(value), + : InputValidators.isMaxSupplyZero, ), ), ), @@ -480,7 +476,6 @@ class _TokenStepperState extends State { ), ), Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( child: Form( @@ -503,7 +498,7 @@ class _TokenStepperState extends State { .extractDecimals(_selectedNumDecimals) : kBigP255m1 : kBigP255m1, - _selectedNumDecimals.toInt(), + _selectedNumDecimals, _isMintable ? BigInt.zero : kMinTokenTotalMaxSupply, canBeEqualToMin: true, ), @@ -525,7 +520,7 @@ class _TokenStepperState extends State { children: [ _getStepBackButton(), const SizedBox( - width: 25.0, + width: 25, ), _getTokenMetricsContinueButton(), ], @@ -560,8 +555,8 @@ class _TokenStepperState extends State { _getMaterialStepper(context, accountInfo), Padding( padding: const EdgeInsets.only( - top: 50.0, - bottom: 20.0, + top: 50, + bottom: 20, ), child: Visibility( visible: (_lastCompletedStep?.index ?? -1) == _numSteps - 1, @@ -572,10 +567,9 @@ class _TokenStepperState extends State { label: 'Create another Token', onPressed: _onCreateAnotherTokenPressed, iconData: Icons.refresh, - context: context, ), const SizedBox( - width: 80.0, + width: 80, ), _getViewTokensButton(), ], @@ -587,10 +581,10 @@ class _TokenStepperState extends State { Visibility( visible: (_lastCompletedStep?.index ?? -1) == _numSteps - 1, child: Positioned( - right: 50.0, + right: 50, child: SizedBox( - width: 400.0, - height: 400.0, + width: 400, + height: 400, child: Center( child: Lottie.asset( 'assets/lottie/ic_anim_zts.json', @@ -626,9 +620,7 @@ class _TokenStepperState extends State { _tokenDomainKey = GlobalKey(); _tokenDomainController = TextEditingController(); _lastCompletedStep = null; - setState(() { - _initStepperControllers(); - }); + setState(_initStepperControllers); } Widget _getTokenCreationStepContent(AccountInfo accountInfo) { @@ -641,7 +633,6 @@ class _TokenStepperState extends State { ), kVerticalSpacing, Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( child: DisabledAddressField(_addressController), @@ -698,7 +689,7 @@ class _TokenStepperState extends State { void _onTokenMetricsContinuePressed() { if ((!_isMintable || _maxSupplyKey.currentState!.validate()) && _totalSupplyKey.currentState!.validate()) { - _tokenStepperData.decimals = _selectedNumDecimals.toInt(); + _tokenStepperData.decimals = _selectedNumDecimals; _tokenStepperData.totalSupply = _totalSupplyController.text.extractDecimals(_selectedNumDecimals); _tokenStepperData.isMintable = _isMintable; @@ -728,7 +719,7 @@ class _TokenStepperState extends State { ); }, builder: (_, model, __) => _getCreateButton(model), - viewModelBuilder: () => IssueTokenBloc(), + viewModelBuilder: IssueTokenBloc.new, ); } @@ -749,7 +740,7 @@ class _TokenStepperState extends State { children: [ _getStepBackButton(), const SizedBox( - width: 25.0, + width: 25, ), _getTokenDetailsContinueButton(), ], @@ -791,7 +782,7 @@ class _TokenStepperState extends State { ? InputValidators.correctValue( _maxSupplyController.text, kBigP255m1, - _selectedNumDecimals.toInt(), + _selectedNumDecimals, kMinTokenTotalMaxSupply, canBeEqualToMin: true, ) == @@ -801,9 +792,9 @@ class _TokenStepperState extends State { _totalSupplyController.text, _isMintable ? _maxSupplyController.text - .extractDecimals(_selectedNumDecimals.toInt()) + .extractDecimals(_selectedNumDecimals) : kBigP255m1, - _selectedNumDecimals.toInt(), + _selectedNumDecimals, _isMintable ? BigInt.zero : kMinTokenTotalMaxSupply, canBeEqualToMin: true, ) == @@ -815,7 +806,7 @@ class _TokenStepperState extends State { ); void _changeFocusToNextNode() { - int indexOfFocusedNode = _focusNodes.indexOf( + final indexOfFocusedNode = _focusNodes.indexOf( _focusNodes.firstWhere( (node) => node.hasFocus, ), @@ -833,7 +824,7 @@ class _TokenStepperState extends State { Row( children: [ const SizedBox( - width: 20.0, + width: 20, ), Checkbox( activeColor: AppColors.ztsColor, @@ -861,7 +852,7 @@ class _TokenStepperState extends State { Row( children: [ const SizedBox( - width: 20.0, + width: 20, ), Checkbox( activeColor: AppColors.ztsColor, @@ -878,7 +869,7 @@ class _TokenStepperState extends State { ), const Icon( Icons.whatshot, - size: 15.0, + size: 15, color: AppColors.ztsColor, ), const StandardTooltipIcon( @@ -893,7 +884,7 @@ class _TokenStepperState extends State { children: [ _getStepBackButton(), const SizedBox( - width: 25.0, + width: 25, ), StepperButton( text: 'Continue', diff --git a/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions.dart b/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions.dart index 4c0dbc9d..92733ff1 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions.dart @@ -13,12 +13,12 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; enum LatestTransactionsVersion { standard, dashboard, token } class LatestTransactions extends StatefulWidget { - final LatestTransactionsVersion version; const LatestTransactions({ super.key, this.version = LatestTransactionsVersion.standard, }); + final LatestTransactionsVersion version; @override State createState() => _LatestTransactionsState(); @@ -68,21 +68,15 @@ class _LatestTransactionsState extends State { bool isSelected, AccountBlock transactionBlock, ) { - AccountBlock infoBlock = + final infoBlock = BlockUtils.isReceiveBlock(transactionBlock.blockType) ? transactionBlock.pairedAccountBlock! : transactionBlock; return [ - isSelected - ? WidgetUtils.getMarqueeAddressTableCell(infoBlock.address, context) - : WidgetUtils.getTextAddressTableCell(infoBlock.address, context), - isSelected - ? WidgetUtils.getMarqueeAddressTableCell(infoBlock.toAddress, context) - : WidgetUtils.getTextAddressTableCell(infoBlock.toAddress, context), - isSelected - ? InfiniteScrollTableCell.withMarquee(infoBlock.hash.toString(), - flex: 2) - : InfiniteScrollTableCell.withText( + if (isSelected) WidgetUtils.getMarqueeAddressTableCell(infoBlock.address, context) else WidgetUtils.getTextAddressTableCell(infoBlock.address, context), + if (isSelected) WidgetUtils.getMarqueeAddressTableCell(infoBlock.toAddress, context) else WidgetUtils.getTextAddressTableCell(infoBlock.toAddress, context), + if (isSelected) InfiniteScrollTableCell.withMarquee(infoBlock.hash.toString(), + flex: 2,) else InfiniteScrollTableCell.withText( context, infoBlock.hash.toShortString(), flex: 2, @@ -105,23 +99,23 @@ class _LatestTransactionsState extends State { ), ), ), - )), + ),), InfiniteScrollTableCell.withText( context, infoBlock.confirmationDetail?.momentumTimestamp == null ? 'Pending' : FormatUtils.formatData( - infoBlock.confirmationDetail!.momentumTimestamp * 1000), + infoBlock.confirmationDetail!.momentumTimestamp * 1000,), ), InfiniteScrollTableCell(Align( alignment: Alignment.centerLeft, - child: _getTransactionTypeIcon(transactionBlock))), + child: _getTransactionTypeIcon(transactionBlock),),), InfiniteScrollTableCell( Align( alignment: Alignment.centerLeft, child: infoBlock.token != null ? _showTokenSymbol(infoBlock) - : Container()), + : Container(),), ), ]; } @@ -167,14 +161,14 @@ class _LatestTransactionsState extends State { return const Icon( MaterialCommunityIcons.arrow_up, color: AppColors.darkHintTextColor, - size: 20.0, + size: 20, ); } if (BlockUtils.isReceiveBlock(block.blockType)) { return const Icon( MaterialCommunityIcons.arrow_down, color: AppColors.lightHintTextColor, - size: 20.0, + size: 20, ); } return Text( @@ -194,7 +188,7 @@ class _LatestTransactionsState extends State { backgroundColor: ColorUtils.getTokenColor(block.tokenStandard), label: Text(block.token?.symbol ?? ''), side: BorderSide.none, - materialTapTargetSize: MaterialTapTargetSize.shrinkWrap)); + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,),); } void _onSortArrowsPressed(String columnName) { @@ -211,7 +205,6 @@ class _LatestTransactionsState extends State { a.address.toString(), ), ); - break; case 'Receiver': _sortAscending ? _transactions!.sort( @@ -220,8 +213,7 @@ class _LatestTransactionsState extends State { ), ) : _transactions!.sort((a, b) => - b.toAddress.toString().compareTo(a.toAddress.toString())); - break; + b.toAddress.toString().compareTo(a.toAddress.toString()),); case 'Hash': _sortAscending ? _transactions!.sort( @@ -234,28 +226,24 @@ class _LatestTransactionsState extends State { a.hash.toString(), ), ); - break; case 'Amount': _sortAscending ? _transactions!.sort((a, b) => a.amount.compareTo(b.amount)) : _transactions!.sort((a, b) => b.amount.compareTo(a.amount)); - break; case 'Date': _sortAscending ? _transactions!.sort( (a, b) => a.confirmationDetail!.momentumTimestamp.compareTo( b.confirmationDetail!.momentumTimestamp, - )) + ),) : _transactions!.sort( (a, b) => b.confirmationDetail!.momentumTimestamp.compareTo( a.confirmationDetail!.momentumTimestamp, - )); - break; + ),); case 'Type': _sortAscending ? _transactions!.sort((a, b) => a.blockType.compareTo(b.blockType)) : _transactions!.sort((a, b) => b.blockType.compareTo(a.blockType)); - break; case 'Assets': _sortAscending ? _transactions!.sort( @@ -264,7 +252,6 @@ class _LatestTransactionsState extends State { : _transactions!.sort( (a, b) => b.token!.symbol.compareTo(a.token!.symbol), ); - break; default: _sortAscending ? _transactions!.sort( @@ -321,15 +308,13 @@ class _LatestTransactionsState extends State { bool isSelected, AccountBlock transactionBlock, ) { - AccountBlock infoBlock = + final infoBlock = BlockUtils.isReceiveBlock(transactionBlock.blockType) ? transactionBlock.pairedAccountBlock! : transactionBlock; return [ - isSelected - ? WidgetUtils.getMarqueeAddressTableCell(infoBlock.address, context) - : WidgetUtils.getTextAddressTableCell(infoBlock.address, context), + if (isSelected) WidgetUtils.getMarqueeAddressTableCell(infoBlock.address, context) else WidgetUtils.getTextAddressTableCell(infoBlock.address, context), InfiniteScrollTableCell( Padding( padding: const EdgeInsets.only(right: 10), @@ -361,16 +346,15 @@ class _LatestTransactionsState extends State { ), InfiniteScrollTableCell( Align( - alignment: Alignment.center, - child: _getTransactionTypeIcon(transactionBlock)), + child: _getTransactionTypeIcon(transactionBlock),), ), InfiniteScrollTableCell( Align( alignment: Alignment.centerLeft, child: infoBlock.token != null ? _showTokenSymbol(infoBlock) - : Container()), - ) + : Container(),), + ), ]; } diff --git a/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions_transfer_widget.dart b/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions_transfer_widget.dart index b49d8903..424376d7 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions_transfer_widget.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions_transfer_widget.dart @@ -13,12 +13,12 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; enum LatestTransactionsVersion { standard, dashboard, token } class LatestTransactions extends StatefulWidget { - final LatestTransactionsVersion version; const LatestTransactions({ super.key, this.version = LatestTransactionsVersion.standard, }); + final LatestTransactionsVersion version; @override State createState() => _LatestTransactionsState(); @@ -68,21 +68,15 @@ class _LatestTransactionsState extends State { bool isSelected, AccountBlock transactionBlock, ) { - AccountBlock infoBlock = + final infoBlock = BlockUtils.isReceiveBlock(transactionBlock.blockType) ? transactionBlock.pairedAccountBlock! : transactionBlock; return [ - isSelected - ? WidgetUtils.getMarqueeAddressTableCell(infoBlock.address, context) - : WidgetUtils.getTextAddressTableCell(infoBlock.address, context), - isSelected - ? WidgetUtils.getMarqueeAddressTableCell(infoBlock.toAddress, context) - : WidgetUtils.getTextAddressTableCell(infoBlock.toAddress, context), - isSelected - ? InfiniteScrollTableCell.withMarquee(infoBlock.hash.toString(), - flex: 2) - : InfiniteScrollTableCell.withText( + if (isSelected) WidgetUtils.getMarqueeAddressTableCell(infoBlock.address, context) else WidgetUtils.getTextAddressTableCell(infoBlock.address, context), + if (isSelected) WidgetUtils.getMarqueeAddressTableCell(infoBlock.toAddress, context) else WidgetUtils.getTextAddressTableCell(infoBlock.toAddress, context), + if (isSelected) InfiniteScrollTableCell.withMarquee(infoBlock.hash.toString(), + flex: 2,) else InfiniteScrollTableCell.withText( context, infoBlock.hash.toShortString(), flex: 2, @@ -105,13 +99,13 @@ class _LatestTransactionsState extends State { ), ), ), - )), + ),), InfiniteScrollTableCell.withText( context, infoBlock.confirmationDetail?.momentumTimestamp == null ? 'Pending' : _formatData( - infoBlock.confirmationDetail!.momentumTimestamp * 1000), + infoBlock.confirmationDetail!.momentumTimestamp * 1000,), ), InfiniteScrollTableCell(_getTransactionTypeIcon(transactionBlock)), InfiniteScrollTableCell( @@ -158,7 +152,7 @@ class _LatestTransactionsState extends State { } String _formatData(int transactionMillis) { - int currentMillis = DateTime.now().millisecondsSinceEpoch; + final currentMillis = DateTime.now().millisecondsSinceEpoch; if (currentMillis - transactionMillis <= const Duration(days: 1).inMilliseconds) { return _formatDataShort(currentMillis - transactionMillis); @@ -167,7 +161,7 @@ class _LatestTransactionsState extends State { } String _formatDataShort(int i) { - Duration duration = Duration(milliseconds: i); + final duration = Duration(milliseconds: i); if (duration.inHours > 0) { return '${duration.inHours} h ago'; } @@ -182,14 +176,14 @@ class _LatestTransactionsState extends State { return const Icon( MaterialCommunityIcons.arrow_up, color: AppColors.darkHintTextColor, - size: 20.0, + size: 20, ); } if (BlockUtils.isReceiveBlock(block.blockType)) { return const Icon( MaterialCommunityIcons.arrow_down, color: AppColors.lightHintTextColor, - size: 20.0, + size: 20, ); } return Text( @@ -209,7 +203,7 @@ class _LatestTransactionsState extends State { backgroundColor: ColorUtils.getTokenColor(block.tokenStandard), label: Text(block.token?.symbol ?? ''), side: BorderSide.none, - materialTapTargetSize: MaterialTapTargetSize.shrinkWrap)); + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,),); } void _onSortArrowsPressed(String columnName) { @@ -226,7 +220,6 @@ class _LatestTransactionsState extends State { a.address.toString(), ), ); - break; case 'Receiver': _sortAscending ? _transactions!.sort( @@ -235,8 +228,7 @@ class _LatestTransactionsState extends State { ), ) : _transactions!.sort((a, b) => - b.toAddress.toString().compareTo(a.toAddress.toString())); - break; + b.toAddress.toString().compareTo(a.toAddress.toString()),); case 'Hash': _sortAscending ? _transactions!.sort( @@ -249,28 +241,24 @@ class _LatestTransactionsState extends State { a.hash.toString(), ), ); - break; case 'Amount': _sortAscending ? _transactions!.sort((a, b) => a.amount.compareTo(b.amount)) : _transactions!.sort((a, b) => b.amount.compareTo(a.amount)); - break; case 'Date': _sortAscending ? _transactions!.sort( (a, b) => a.confirmationDetail!.momentumTimestamp.compareTo( b.confirmationDetail!.momentumTimestamp, - )) + ),) : _transactions!.sort( (a, b) => b.confirmationDetail!.momentumTimestamp.compareTo( a.confirmationDetail!.momentumTimestamp, - )); - break; + ),); case 'Type': _sortAscending ? _transactions!.sort((a, b) => a.blockType.compareTo(b.blockType)) : _transactions!.sort((a, b) => b.blockType.compareTo(a.blockType)); - break; case 'Assets': _sortAscending ? _transactions!.sort( @@ -279,7 +267,6 @@ class _LatestTransactionsState extends State { : _transactions!.sort( (a, b) => b.token!.symbol.compareTo(a.token!.symbol), ); - break; default: _sortAscending ? _transactions!.sort( @@ -337,15 +324,13 @@ class _LatestTransactionsState extends State { bool isSelected, AccountBlock transactionBlock, ) { - AccountBlock infoBlock = + final infoBlock = BlockUtils.isReceiveBlock(transactionBlock.blockType) ? transactionBlock.pairedAccountBlock! : transactionBlock; return [ - isSelected - ? WidgetUtils.getMarqueeAddressTableCell(infoBlock.address, context) - : WidgetUtils.getTextAddressTableCell(infoBlock.address, context), + if (isSelected) WidgetUtils.getMarqueeAddressTableCell(infoBlock.address, context) else WidgetUtils.getTextAddressTableCell(infoBlock.address, context), InfiniteScrollTableCell( Padding( padding: const EdgeInsets.only(right: 10), @@ -378,7 +363,7 @@ class _LatestTransactionsState extends State { InfiniteScrollTableCell(_getTransactionTypeIcon(transactionBlock)), InfiniteScrollTableCell( infoBlock.token != null ? _showTokenSymbol(infoBlock) : Container(), - ) + ), ]; } diff --git a/lib/widgets/modular_widgets/transfer_widgets/pending_transactions/pending_transactions.dart b/lib/widgets/modular_widgets/transfer_widgets/pending_transactions/pending_transactions.dart index 0db45847..60381cef 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/pending_transactions/pending_transactions.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/pending_transactions/pending_transactions.dart @@ -53,21 +53,15 @@ class _PendingTransactionsState extends State { _getCellsForPendingTransactions(isSelected, transaction); List _getCellsForPendingTransactions( - bool isSelected, AccountBlock transaction) { - AccountBlock infoBlock = BlockUtils.isReceiveBlock(transaction.blockType) + bool isSelected, AccountBlock transaction,) { + final infoBlock = BlockUtils.isReceiveBlock(transaction.blockType) ? transaction.pairedAccountBlock! : transaction; return [ - isSelected - ? WidgetUtils.getMarqueeAddressTableCell(infoBlock.address, context) - : WidgetUtils.getTextAddressTableCell(infoBlock.address, context), - isSelected - ? WidgetUtils.getMarqueeAddressTableCell(infoBlock.toAddress, context) - : WidgetUtils.getTextAddressTableCell(infoBlock.toAddress, context), - isSelected - ? InfiniteScrollTableCell.withMarquee(infoBlock.hash.toString(), - flex: 2) - : InfiniteScrollTableCell.withText( + if (isSelected) WidgetUtils.getMarqueeAddressTableCell(infoBlock.address, context) else WidgetUtils.getTextAddressTableCell(infoBlock.address, context), + if (isSelected) WidgetUtils.getMarqueeAddressTableCell(infoBlock.toAddress, context) else WidgetUtils.getTextAddressTableCell(infoBlock.toAddress, context), + if (isSelected) InfiniteScrollTableCell.withMarquee(infoBlock.hash.toString(), + flex: 2,) else InfiniteScrollTableCell.withText( context, infoBlock.hash.toShortString(), flex: 2, @@ -90,23 +84,23 @@ class _PendingTransactionsState extends State { ), ), ), - )), + ),), InfiniteScrollTableCell.withText( context, infoBlock.confirmationDetail?.momentumTimestamp == null ? 'Pending' : FormatUtils.formatData( - infoBlock.confirmationDetail!.momentumTimestamp * 1000), + infoBlock.confirmationDetail!.momentumTimestamp * 1000,), ), InfiniteScrollTableCell( Align( alignment: Alignment.centerLeft, child: infoBlock.token != null ? _showTokenSymbol(infoBlock) - : Container()), + : Container(),), ), InfiniteScrollTableCell( - _getReceiveContainer(isSelected, infoBlock, _bloc)), + _getReceiveContainer(isSelected, infoBlock, _bloc),), ]; } @@ -160,7 +154,6 @@ class _PendingTransactionsState extends State { a.address.toString(), ), ); - break; case 'Receiver': _sortAscending ? _transactions!.sort( @@ -169,8 +162,7 @@ class _PendingTransactionsState extends State { ), ) : _transactions!.sort((a, b) => - b.toAddress.toString().compareTo(a.toAddress.toString())); - break; + b.toAddress.toString().compareTo(a.toAddress.toString()),); case 'Hash': _sortAscending ? _transactions!.sort( @@ -183,23 +175,20 @@ class _PendingTransactionsState extends State { a.hash.toString(), ), ); - break; case 'Amount': _sortAscending ? _transactions!.sort((a, b) => a.amount.compareTo(b.amount)) : _transactions!.sort((a, b) => b.amount.compareTo(a.amount)); - break; case 'Date': _sortAscending ? _transactions!.sort( (a, b) => a.confirmationDetail!.momentumTimestamp.compareTo( b.confirmationDetail!.momentumTimestamp, - )) + ),) : _transactions!.sort( (a, b) => b.confirmationDetail!.momentumTimestamp.compareTo( a.confirmationDetail!.momentumTimestamp, - )); - break; + ),); case 'Assets': _sortAscending ? _transactions!.sort( @@ -208,7 +197,6 @@ class _PendingTransactionsState extends State { : _transactions!.sort( (a, b) => b.token!.symbol.compareTo(a.token!.symbol), ); - break; default: _sortAscending ? _transactions!.sort( @@ -236,7 +224,7 @@ class _PendingTransactionsState extends State { ) { return Align( alignment: Alignment.centerLeft, - child: _getReceiveButtonViewModel(model, isSelected, transaction)); + child: _getReceiveButtonViewModel(model, isSelected, transaction),); } Widget _getReceiveButtonViewModel( @@ -254,7 +242,7 @@ class _PendingTransactionsState extends State { }, onError: (error) async { await NotificationUtils.sendNotificationError( - error, 'Error while receiving transaction'); + error, 'Error while receiving transaction',); }, ); }, @@ -262,7 +250,7 @@ class _PendingTransactionsState extends State { model, transactionItem.hash.toString(), ), - viewModelBuilder: () => ReceiveTransactionBloc(), + viewModelBuilder: ReceiveTransactionBloc.new, ); } @@ -271,7 +259,7 @@ class _PendingTransactionsState extends State { String transactionHash, ) { return MaterialIconButton( - size: 25.0, + size: 25, iconData: Icons.download_for_offline, onPressed: () { _onReceivePressed(model, transactionHash); @@ -291,7 +279,7 @@ class _PendingTransactionsState extends State { backgroundColor: ColorUtils.getTokenColor(block.tokenStandard), label: Text(block.token?.symbol ?? ''), side: BorderSide.none, - materialTapTargetSize: MaterialTapTargetSize.shrinkWrap)); + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,),); } @override diff --git a/lib/widgets/modular_widgets/transfer_widgets/receive/receive_large.dart b/lib/widgets/modular_widgets/transfer_widgets/receive/receive_large.dart index 05ff483a..99826b32 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/receive/receive_large.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/receive/receive_large.dart @@ -12,14 +12,13 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ReceiveLargeCard extends StatefulWidget { - final bool? extendIcon; - final VoidCallback onCollapseClicked; const ReceiveLargeCard({ - super.key, + required this.onCollapseClicked, super.key, this.extendIcon, - required this.onCollapseClicked, }); + final bool? extendIcon; + final VoidCallback onCollapseClicked; @override State createState() => _ReceiveLargeCardState(); @@ -55,7 +54,7 @@ class _ReceiveLargeCardState extends State { title: 'Receive', titleFontSize: Theme.of(context).textTheme.headlineSmall!.fontSize, description: 'Manage receiving funds', - childBuilder: () => _getTokensStreamBuilder(), + childBuilder: _getTokensStreamBuilder, ); } @@ -82,8 +81,8 @@ class _ReceiveLargeCardState extends State { return Container( margin: const EdgeInsets.only( - right: 20.0, - top: 20.0, + right: 20, + top: 20, ), child: Form( key: _formKey, @@ -96,7 +95,7 @@ class _ReceiveLargeCardState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox( - width: 20.0, + width: 20, ), ReceiveQrImage( data: _getQrString(), @@ -105,11 +104,10 @@ class _ReceiveLargeCardState extends State { context: context, ), const SizedBox( - width: 20.0, + width: 20, ), Expanded( child: Column( - mainAxisAlignment: MainAxisAlignment.start, children: [ Row( children: [ @@ -132,7 +130,7 @@ class _ReceiveLargeCardState extends State { value, kBigP255m1, _selectedToken.decimals, - BigInt.zero), + BigInt.zero,), onChanged: (value) => setState(() {}), inputFormatters: FormatUtils.getAmountTextInputFormatters( @@ -145,7 +143,7 @@ class _ReceiveLargeCardState extends State { children: [ _getCoinDropdown(), const SizedBox( - width: 15.0, + width: 15, ), ], ), @@ -158,7 +156,6 @@ class _ReceiveLargeCardState extends State { ], ), Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ Visibility( visible: widget.extendIcon!, @@ -227,7 +224,7 @@ class _ReceiveLargeCardState extends State { _tokens.clear(); } _tokens.addAll(kDualCoin); - for (var element in tokens) { + for (final element in tokens) { if (!_tokens.contains(element)) { _tokens.add(element); } diff --git a/lib/widgets/modular_widgets/transfer_widgets/receive/receive_medium.dart b/lib/widgets/modular_widgets/transfer_widgets/receive/receive_medium.dart index 9c5e7b02..0017af27 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/receive/receive_medium.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/receive/receive_medium.dart @@ -12,9 +12,9 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ReceiveMediumCard extends StatefulWidget { - final VoidCallback onExpandClicked; - const ReceiveMediumCard({super.key, required this.onExpandClicked}); + const ReceiveMediumCard({required this.onExpandClicked, super.key}); + final VoidCallback onExpandClicked; @override State createState() => _ReceiveMediumCardState(); @@ -51,7 +51,7 @@ class _ReceiveMediumCardState extends State { title: 'Receive', titleFontSize: Theme.of(context).textTheme.headlineSmall!.fontSize, description: 'Manage receiving funds', - childBuilder: () => _getTokensStreamBuilder(), + childBuilder: _getTokensStreamBuilder, ); } @@ -69,7 +69,7 @@ class _ReceiveMediumCardState extends State { return const SyriusLoadingWidget(); } return const SyriusLoadingWidget(); - }); + },); } Widget _getWidgetBody(BuildContext context, List tokens) { @@ -77,8 +77,8 @@ class _ReceiveMediumCardState extends State { return Container( margin: const EdgeInsets.only( - right: 20.0, - top: 20.0, + right: 20, + top: 20, ), child: Form( key: _formKey, @@ -91,7 +91,7 @@ class _ReceiveMediumCardState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const SizedBox( - width: 20.0, + width: 20, ), ReceiveQrImage( data: _getQrString(), @@ -100,7 +100,7 @@ class _ReceiveMediumCardState extends State { context: context, ), const SizedBox( - width: 20.0, + width: 20, ), Expanded( child: Column( @@ -126,7 +126,7 @@ class _ReceiveMediumCardState extends State { value, kBigP255m1, _selectedToken.decimals, - BigInt.zero), + BigInt.zero,), onChanged: (value) => setState(() {}), inputFormatters: FormatUtils.getAmountTextInputFormatters( @@ -139,7 +139,7 @@ class _ReceiveMediumCardState extends State { children: [ _getCoinDropdown(), const SizedBox( - width: 15.0, + width: 15, ), ], ), @@ -152,10 +152,9 @@ class _ReceiveMediumCardState extends State { ], ), const SizedBox( - height: 35.0, + height: 35, ), Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ TransferToggleCardSizeButton( onPressed: widget.onExpandClicked, @@ -217,7 +216,7 @@ class _ReceiveMediumCardState extends State { _tokens.clear(); } _tokens.addAll(kDualCoin); - for (var element in tokens) { + for (final element in tokens) { if (!_tokens.contains(element)) { _tokens.add(element); } diff --git a/lib/widgets/modular_widgets/transfer_widgets/receive/receive_small.dart b/lib/widgets/modular_widgets/transfer_widgets/receive/receive_small.dart index cd10705b..5cc279d6 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/receive/receive_small.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/receive/receive_small.dart @@ -4,12 +4,12 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class ReceiveSmallCard extends StatefulWidget { - final VoidCallback onPressed; const ReceiveSmallCard( this.onPressed, { super.key, }); + final VoidCallback onPressed; @override State createState() => _ReceiveSmallCardState(); @@ -24,20 +24,19 @@ class _ReceiveSmallCardState extends State { decoration: BoxDecoration( color: Theme.of(context).colorScheme.primary, borderRadius: BorderRadius.circular( - 15.0, + 15, ), ), child: const Column( - crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( SimpleLineIcons.arrow_down_circle, - size: 60.0, + size: 60, color: AppColors.lightHintTextColor, ), SizedBox( - height: 20.0, + height: 20, ), TransferIconLegend( legendText: '● Receive', diff --git a/lib/widgets/modular_widgets/transfer_widgets/send/send_large.dart b/lib/widgets/modular_widgets/transfer_widgets/send/send_large.dart index 080ca2f8..13f77e87 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/send/send_large.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/send/send_large.dart @@ -17,9 +17,6 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class SendLargeCard extends StatefulWidget { - final double? cardWidth; - final bool? extendIcon; - final VoidCallback? onCollapsePressed; const SendLargeCard({ super.key, @@ -27,6 +24,9 @@ class SendLargeCard extends StatefulWidget { this.extendIcon, this.onCollapsePressed, }); + final double? cardWidth; + final bool? extendIcon; + final VoidCallback? onCollapsePressed; @override State createState() => _SendLargeCardState(); @@ -60,7 +60,7 @@ class _SendLargeCardState extends State { title: 'Send', titleFontSize: Theme.of(context).textTheme.headlineSmall!.fontSize, description: 'Manage sending funds', - childBuilder: () => _getBalanceStreamBuilder(), + childBuilder: _getBalanceStreamBuilder, ); } @@ -91,14 +91,14 @@ class _SendLargeCardState extends State { Widget _getBody(BuildContext context, AccountInfo accountInfo) { return Container( margin: const EdgeInsets.only( - left: 20.0, - top: 20.0, + left: 20, + top: 20, ), child: ListView( shrinkWrap: true, children: [ Container( - margin: const EdgeInsets.only(right: 20.0), + margin: const EdgeInsets.only(right: 20), child: Form( key: _recipientKey, autovalidateMode: AutovalidateMode.onUserInteraction, @@ -107,7 +107,7 @@ class _SendLargeCardState extends State { setState(() {}); }, controller: _recipientController, - validator: (value) => InputValidators.checkAddress(value), + validator: InputValidators.checkAddress, suffixIcon: RawMaterialButton( shape: const CircleBorder(), onPressed: () { @@ -119,12 +119,12 @@ class _SendLargeCardState extends State { child: const Icon( Icons.content_paste, color: AppColors.darkHintTextColor, - size: 15.0, + size: 15, ), ), suffixIconConstraints: const BoxConstraints( - maxWidth: 45.0, - maxHeight: 20.0, + maxWidth: 45, + maxHeight: 20, ), hintText: 'Recipient Address', ), @@ -137,7 +137,7 @@ class _SendLargeCardState extends State { Expanded( flex: 8, child: Container( - margin: const EdgeInsets.only(right: 20.0), + margin: const EdgeInsets.only(right: 20), child: Form( key: _amountKey, autovalidateMode: AutovalidateMode.onUserInteraction, @@ -155,7 +155,7 @@ class _SendLargeCardState extends State { _selectedToken.tokenStandard, ), _selectedToken.decimals, - BigInt.zero), + BigInt.zero,), suffixIcon: _getAmountSuffix(accountInfo), hintText: 'Amount', ), @@ -165,17 +165,17 @@ class _SendLargeCardState extends State { ], ), const SizedBox( - height: 5.0, + height: 5, ), Padding( - padding: const EdgeInsets.only(left: 10.0), + padding: const EdgeInsets.only(left: 10), child: Text( 'Send from', style: Theme.of(context).inputDecorationTheme.hintStyle, ), ), const SizedBox( - height: 5.0, + height: 5, ), Row( crossAxisAlignment: CrossAxisAlignment.start, @@ -184,12 +184,12 @@ class _SendLargeCardState extends State { child: _getDefaultAddressDropdown(), ), Container( - width: 10.0, + width: 10, ), _getSendPaymentViewModel(accountInfo), const SizedBox( - width: 20.0, - ) + width: 20, + ), ], ), Row( @@ -198,8 +198,8 @@ class _SendLargeCardState extends State { children: [ Padding( padding: const EdgeInsets.only( - left: 10.0, - top: 10.0, + left: 10, + top: 10, ), child: AvailableBalance( _selectedToken, @@ -212,9 +212,9 @@ class _SendLargeCardState extends State { onPressed: widget.onCollapsePressed, iconData: Icons.navigate_before, ), - ) + ), ], - ) + ), ], ), ); @@ -242,14 +242,14 @@ class _SendLargeCardState extends State { children: [ _getCoinDropdown(), const SizedBox( - width: 5.0, + width: 5, ), AmountSuffixMaxWidget( onPressed: () => _onMaxPressed(accountInfo), context: context, ), const SizedBox( - width: 15.0, + width: 15, ), ], ); @@ -261,7 +261,6 @@ class _SendLargeCardState extends State { fromAddress: _selectedSelfAddress, toAddress: _recipientController.text, amount: _amountController.text.extractDecimals(_selectedToken.decimals), - data: null, token: _selectedToken, ); } @@ -296,7 +295,7 @@ class _SendLargeCardState extends State { ); void _onMaxPressed(AccountInfo accountInfo) { - BigInt maxBalance = accountInfo.getBalance( + final maxBalance = accountInfo.getBalance( _selectedToken.tokenStandard, ); @@ -336,17 +335,17 @@ class _SendLargeCardState extends State { onPressed: _hasBalance(accountInfo!) && _isInputValid(accountInfo) ? () => _onSendPaymentPressed(model) : null, - minimumSize: const Size(50.0, 48.0), + minimumSize: const Size(50, 48), key: _sendPaymentButtonKey, ), - viewModelBuilder: () => SendPaymentBloc(), + viewModelBuilder: SendPaymentBloc.new, ); } Future _sendErrorNotification(error) async { await NotificationUtils.sendNotificationError( error, - 'Couldn\'t send ${_amountController.text} ' + "Couldn't send ${_amountController.text} " '${_selectedToken.symbol} ' 'to ${_recipientController.text}', ); @@ -361,7 +360,6 @@ class _SendLargeCardState extends State { details: 'Sent ${_amountController.text} ${_selectedToken.symbol} ' 'from ${ZenonAddressUtils.getLabel(_selectedSelfAddress!)} to ${ZenonAddressUtils.getLabel(_recipientController.text)}', type: NotificationType.paymentSent, - id: null, ), ); } @@ -373,7 +371,7 @@ class _SendLargeCardState extends State { BigInt.zero; void _addTokensWithBalance(AccountInfo accountInfo) { - for (var balanceInfo in accountInfo.balanceInfoList!) { + for (final balanceInfo in accountInfo.balanceInfoList!) { if (balanceInfo.balance! > BigInt.zero && !_tokensWithBalance.contains(balanceInfo.token)) { _tokensWithBalance.add(balanceInfo.token); diff --git a/lib/widgets/modular_widgets/transfer_widgets/send/send_medium.dart b/lib/widgets/modular_widgets/transfer_widgets/send/send_medium.dart index 6b671700..97b0eb80 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/send/send_medium.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/send/send_medium.dart @@ -17,12 +17,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class SendMediumCard extends StatefulWidget { - final VoidCallback onExpandClicked; const SendMediumCard({ required this.onExpandClicked, super.key, }); + final VoidCallback onExpandClicked; @override State createState() => _SendMediumCardState(); @@ -56,7 +56,7 @@ class _SendMediumCardState extends State { title: 'Send', titleFontSize: Theme.of(context).textTheme.headlineSmall!.fontSize, description: 'Manage sending funds', - childBuilder: () => _getBalanceStreamBuilder(), + childBuilder: _getBalanceStreamBuilder, ); } @@ -87,14 +87,14 @@ class _SendMediumCardState extends State { Widget _getBody(BuildContext context, AccountInfo accountInfo) { return Container( margin: const EdgeInsets.only( - left: 20.0, - top: 20.0, + left: 20, + top: 20, ), child: ListView( shrinkWrap: true, children: [ Container( - margin: const EdgeInsets.only(right: 20.0), + margin: const EdgeInsets.only(right: 20), child: Form( key: _recipientKey, autovalidateMode: AutovalidateMode.onUserInteraction, @@ -103,7 +103,7 @@ class _SendMediumCardState extends State { setState(() {}); }, thisNode: _recipientFocusNode, - validator: (value) => InputValidators.checkAddress(value), + validator: InputValidators.checkAddress, controller: _recipientController, suffixIcon: RawMaterialButton( shape: const CircleBorder(), @@ -116,12 +116,12 @@ class _SendMediumCardState extends State { child: const Icon( Icons.content_paste, color: AppColors.darkHintTextColor, - size: 15.0, + size: 15, ), ), suffixIconConstraints: const BoxConstraints( - maxWidth: 45.0, - maxHeight: 20.0, + maxWidth: 45, + maxHeight: 20, ), hintText: 'Recipient Address', ), @@ -129,7 +129,7 @@ class _SendMediumCardState extends State { ), kVerticalSpacing, Container( - margin: const EdgeInsets.only(right: 20.0), + margin: const EdgeInsets.only(right: 20), child: Form( key: _amountKey, autovalidateMode: AutovalidateMode.onUserInteraction, @@ -195,7 +195,6 @@ class _SendMediumCardState extends State { fromAddress: kSelectedAddress, toAddress: _recipientController.text, amount: _amountController.text.extractDecimals(_selectedToken.decimals), - data: null, token: _selectedToken, ); } @@ -207,14 +206,14 @@ class _SendMediumCardState extends State { children: [ _getCoinDropdown(), const SizedBox( - width: 5.0, + width: 5, ), AmountSuffixMaxWidget( onPressed: () => _onMaxPressed(accountInfo), context: context, ), const SizedBox( - width: 15.0, + width: 15, ), ], ); @@ -235,7 +234,7 @@ class _SendMediumCardState extends State { ); void _onMaxPressed(AccountInfo accountInfo) { - BigInt maxBalance = accountInfo.getBalance( + final maxBalance = accountInfo.getBalance( _selectedToken.tokenStandard, ); @@ -278,14 +277,14 @@ class _SendMediumCardState extends State { : null, key: _sendPaymentButtonKey, ), - viewModelBuilder: () => SendPaymentBloc(), + viewModelBuilder: SendPaymentBloc.new, ); } Future _sendErrorNotification(error) async { await NotificationUtils.sendNotificationError( error, - 'Couldn\'t send ${_amountController.text} ${_selectedToken.symbol} ' + "Couldn't send ${_amountController.text} ${_selectedToken.symbol} " 'to ${_recipientController.text}', ); } @@ -299,7 +298,6 @@ class _SendMediumCardState extends State { details: 'Sent ${_amountController.text} ${_selectedToken.symbol} ' 'from ${ZenonAddressUtils.getLabel(kSelectedAddress!)} to ${ZenonAddressUtils.getLabel(_recipientController.text)}', type: NotificationType.paymentSent, - id: null, ), ); } @@ -311,7 +309,7 @@ class _SendMediumCardState extends State { BigInt.zero; void _addTokensWithBalance(AccountInfo accountInfo) { - for (var balanceInfo in accountInfo.balanceInfoList!) { + for (final balanceInfo in accountInfo.balanceInfoList!) { if (balanceInfo.balance! > BigInt.zero && !_tokensWithBalance.contains(balanceInfo.token)) { _tokensWithBalance.add(balanceInfo.token); diff --git a/lib/widgets/modular_widgets/transfer_widgets/send/send_small.dart b/lib/widgets/modular_widgets/transfer_widgets/send/send_small.dart index 7f41b2cd..ccaedbb9 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/send/send_small.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/send/send_small.dart @@ -4,12 +4,12 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class SendSmallCard extends StatefulWidget { - final VoidCallback onClicked; const SendSmallCard( this.onClicked, { super.key, }); + final VoidCallback onClicked; @override State createState() => _SendSmallCardState(); @@ -24,24 +24,23 @@ class _SendSmallCardState extends State { decoration: BoxDecoration( color: Theme.of(context).colorScheme.primary, borderRadius: BorderRadius.circular( - 15.0, + 15, ), ), child: Container( padding: const EdgeInsets.all( - 20.0, + 20, ), child: const Column( - crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( SimpleLineIcons.arrow_up_circle, - size: 60.0, + size: 60, color: AppColors.darkHintTextColor, ), SizedBox( - height: 20.0, + height: 20, ), TransferIconLegend( legendText: '● Send', diff --git a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_camera_card.dart b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_camera_card.dart index fd6d987b..7ec59ab2 100644 --- a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_camera_card.dart +++ b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_camera_card.dart @@ -34,27 +34,26 @@ class _WalletConnectCameraCardState extends State { return CardScaffold( title: _kWidgetTitle, description: _kWidgetDescription, - childBuilder: () => _getCardBody(), + childBuilder: _getCardBody, ); } Widget _getCardBody() { return Padding( - padding: const EdgeInsets.all(15.0), + padding: const EdgeInsets.all(15), child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ const CircleAvatar( - radius: 60.0, + radius: 60, backgroundColor: Colors.white12, child: Icon( Icons.camera_alt_outlined, color: AppColors.znnColor, - size: 60.0, + size: 60, ), ), - Platform.isMacOS - ? MyOutlinedButton( + if (Platform.isMacOS) MyOutlinedButton( text: 'Scan QR', onPressed: () async { await Navigator.of(context).push( @@ -68,7 +67,7 @@ class _WalletConnectCameraCardState extends State { value.toString(), ); final wcService = sl.get(); - final Barcode? barcode = _filterBarcodes(value); + final barcode = _filterBarcodes(value); if (barcode != null) { final pairingInfo = await wcService.pair( Uri.parse(value.barcodes.first.displayValue!), @@ -101,7 +100,7 @@ class _WalletConnectCameraCardState extends State { Text('${p1.errorCode}', style: Theme.of(context) .textTheme - .bodyMedium), + .bodyMedium,), Container(height: 16), const Icon( MaterialCommunityIcons.camera_off, @@ -117,8 +116,7 @@ class _WalletConnectCameraCardState extends State { ); }, minimumSize: kLoadingButtonMinSize, - ) - : Text( + ) else Text( 'Only MacOS is supported at the moment', style: Theme.of(context).textTheme.bodyLarge, ), @@ -145,7 +143,7 @@ class _WalletConnectCameraCardState extends State { /// the first valid WC barcode Barcode? _filterBarcodes(BarcodeCapture capture) { for (final barcode in capture.barcodes) { - final String? uri = barcode.displayValue; + final uri = barcode.displayValue; if (uri != null) { if (!canParseWalletConnectUri(uri)) { return barcode; diff --git a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_pairing_list_card.dart b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_pairing_list_card.dart index c41abf1d..c876aff5 100644 --- a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_pairing_list_card.dart +++ b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_pairing_list_card.dart @@ -38,8 +38,8 @@ class _WalletConnectPairingsCardState extends State { return CardScaffold( title: _kWidgetTitle, description: _kWidgetDescription, - childBuilder: () => _getCardBody(), - onRefreshPressed: () => _pairingsBloc.refreshResults(), + childBuilder: _getCardBody, + onRefreshPressed: _pairingsBloc.refreshResults, ); } @@ -82,17 +82,15 @@ class _WalletConnectPairingsCardState extends State { _buildTableUrlWidget(pairingInfo), flex: 2, ), - isSelected - ? InfiniteScrollTableCell.withMarquee( + if (isSelected) InfiniteScrollTableCell.withMarquee( pairingInfo.topic, - ) - : InfiniteScrollTableCell.withText( + ) else InfiniteScrollTableCell.withText( context, pairingInfo.topic.short, ), InfiniteScrollTableCell.withText( context, - _formatExpiryDateTime(pairingInfo.expiry).toString(), + _formatExpiryDateTime(pairingInfo.expiry), ), InfiniteScrollTableCell.withText( context, diff --git a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_qr_card.dart b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_qr_card.dart index 4bfa2800..cb8099e9 100644 --- a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_qr_card.dart +++ b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_qr_card.dart @@ -45,23 +45,23 @@ class _WalletConnectQrCardState extends State { return CardScaffold( title: _kWidgetTitle, description: _kWidgetDescription, - childBuilder: () => _getCardBody(), + childBuilder: _getCardBody, ); } Widget _getCardBody() { return Padding( - padding: const EdgeInsets.all(15.0), + padding: const EdgeInsets.all(15), child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Container( height: 130, width: 130, - padding: const EdgeInsets.all(10.0), + padding: const EdgeInsets.all(10), decoration: BoxDecoration( color: Theme.of(context).colorScheme.surface, - borderRadius: BorderRadius.circular(15.0), + borderRadius: BorderRadius.circular(15), ), child: PrettyQrView.data( data: 'Scan the WalletConnect QR from the dApp', @@ -74,7 +74,7 @@ class _WalletConnectQrCardState extends State { scale: 0.3, padding: EdgeInsets.only(top: 10, bottom: 10), image: AssetImage( - 'assets/images/qr_code_child_image_znn.png'))), + 'assets/images/qr_code_child_image_znn.png',),),), errorCorrectLevel: QrErrorCorrectLevel.H, ), ), @@ -110,37 +110,36 @@ class _WalletConnectQrCardState extends State { } } - void _handleClickCapture(CaptureMode mode) async { + Future _handleClickCapture(CaptureMode mode) async { try { - Directory walletConnectDirectory = Directory( - path.join(znnDefaultPaths.cache.path, walletConnectDirName)); + final walletConnectDirectory = Directory( + path.join(znnDefaultPaths.cache.path, walletConnectDirName),); if (!walletConnectDirectory.existsSync()) { walletConnectDirectory.createSync(recursive: true); } - String screenshotName = + final screenshotName = 'screenshot-${DateTime.now().millisecondsSinceEpoch}'; final imagePath = await File( - '${walletConnectDirectory.absolute.path}${path.separator}$screenshotName.png') + '${walletConnectDirectory.absolute.path}${path.separator}$screenshotName.png',) .create(); _lastCapturedData = await screenCapturer.capture( mode: mode, imagePath: imagePath.absolute.path, - silent: true, ); if (_lastCapturedData != null) { - var image = img.decodePng(imagePath.readAsBytesSync())!; + final image = img.decodePng(imagePath.readAsBytesSync())!; - LuminanceSource source = RGBLuminanceSource( - image.width, image.height, image.getBytes().buffer.asInt32List()); - var bitmap = BinaryBitmap(HybridBinarizer(source)); + final LuminanceSource source = RGBLuminanceSource( + image.width, image.height, image.getBytes().buffer.asInt32List(),); + final bitmap = BinaryBitmap(HybridBinarizer(source)); - var reader = QRCodeReader(); - var result = reader.decode(bitmap); + final reader = QRCodeReader(); + final result = reader.decode(bitmap); if (result.rawBytes!.isNotEmpty) { if (result.text.isNotEmpty && @@ -153,7 +152,7 @@ class _WalletConnectQrCardState extends State { title: 'Invalid QR code', timestamp: DateTime.now().millisecondsSinceEpoch, details: 'Please scan a valid WalletConnect QR code', - type: NotificationType.error)); + type: NotificationType.error,),); } } else { await windowManager.show(); @@ -161,7 +160,7 @@ class _WalletConnectQrCardState extends State { title: 'QR code scan failed', timestamp: DateTime.now().millisecondsSinceEpoch, details: 'Please scan a valid WalletConnect QR code', - type: NotificationType.error)); + type: NotificationType.error,),); } await _pairWithDapp(Uri.parse(result.text)); } else { @@ -186,7 +185,7 @@ class _WalletConnectQrCardState extends State { timestamp: DateTime.now().millisecondsSinceEpoch, details: 'Screen Recording permission is required to scan and process the on-screen WalletConnect QR code', - type: NotificationType.generatingPlasma)); + type: NotificationType.generatingPlasma,),); return false; } return true; @@ -195,7 +194,7 @@ class _WalletConnectQrCardState extends State { } Future _requestAccessForMacOS() async { - bool isAccessAllowed = await ScreenCapturer.instance.isAccessAllowed(); + final isAccessAllowed = await ScreenCapturer.instance.isAccessAllowed(); if (!isAccessAllowed) { await ScreenCapturer.instance.requestAccess(); } diff --git a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_session_list_card.dart b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_session_list_card.dart index d476e316..2a990506 100644 --- a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_session_list_card.dart +++ b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_session_list_card.dart @@ -8,7 +8,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; const String _kWidgetTitle = 'WalletConnect Sessions List'; const String _kWidgetDescription = - 'A session refers to a live connection between a user\'s wallet and a dApp ' + "A session refers to a live connection between a user's wallet and a dApp " 'A session allows the dApp to communicate with the wallet ' 'securely over the Internet'; @@ -29,8 +29,8 @@ class _WalletConnectSessionsCardState extends State { return CardScaffold( title: _kWidgetTitle, description: _kWidgetDescription, - childBuilder: () => _getCardBody(), - onRefreshPressed: () => _sessionsBloc.refreshResults(), + childBuilder: _getCardBody, + onRefreshPressed: _sessionsBloc.refreshResults, ); } @@ -73,25 +73,21 @@ class _WalletConnectSessionsCardState extends State { _buildTableUrlWidget(sessionData.peer.metadata.url), flex: 2, ), - isSelected - ? InfiniteScrollTableCell.withMarquee( + if (isSelected) InfiniteScrollTableCell.withMarquee( sessionData.pairingTopic, - ) - : InfiniteScrollTableCell.withText( + ) else InfiniteScrollTableCell.withText( context, sessionData.pairingTopic.short, ), - isSelected - ? InfiniteScrollTableCell.withMarquee( + if (isSelected) InfiniteScrollTableCell.withMarquee( sessionData.topic, - ) - : InfiniteScrollTableCell.withText( + ) else InfiniteScrollTableCell.withText( context, sessionData.topic.short, ), InfiniteScrollTableCell.withText( context, - _formatExpiryDateTime(sessionData.expiry).toString(), + _formatExpiryDateTime(sessionData.expiry), ), InfiniteScrollTableCell.withText( context, diff --git a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_uri_card.dart b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_uri_card.dart index cca6e9ae..44aba894 100644 --- a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_uri_card.dart +++ b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_uri_card.dart @@ -28,13 +28,13 @@ class _WalletConnectUriCardState extends State { return CardScaffold( title: _kWidgetTitle, description: _kWidgetDescription, - childBuilder: () => _getCardBody(), + childBuilder: _getCardBody, ); } Widget _getCardBody() { return Padding( - padding: const EdgeInsets.all(15.0), + padding: const EdgeInsets.all(15), child: ValueListenableBuilder( builder: (_, value, child) { if (value != null) { @@ -45,7 +45,7 @@ class _WalletConnectUriCardState extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ SizedBox( - height: 120.0, + height: 120, child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -83,12 +83,12 @@ class _WalletConnectUriCardState extends State { child: const Icon( Icons.content_paste, color: AppColors.darkHintTextColor, - size: 15.0, + size: 15, ), ), suffixIconConstraints: const BoxConstraints( - maxWidth: 45.0, - maxHeight: 20.0, + maxWidth: 45, + maxHeight: 20, ), hintText: 'WalletConnect URI', ), diff --git a/lib/widgets/reusable_widgets/accelerator_project_details.dart b/lib/widgets/reusable_widgets/accelerator_project_details.dart index d904e1f6..87638178 100644 --- a/lib/widgets/reusable_widgets/accelerator_project_details.dart +++ b/lib/widgets/reusable_widgets/accelerator_project_details.dart @@ -6,11 +6,6 @@ import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class AcceleratorProjectDetails extends StatelessWidget { - final Address? owner; - final Hash? hash; - final int? creationTimestamp; - final AcceleratorProjectStatus? acceleratorProjectStatus; - final bool isPhase; const AcceleratorProjectDetails({ this.owner, @@ -20,16 +15,21 @@ class AcceleratorProjectDetails extends StatelessWidget { this.isPhase = false, super.key, }); + final Address? owner; + final Hash? hash; + final int? creationTimestamp; + final AcceleratorProjectStatus? acceleratorProjectStatus; + final bool isPhase; @override Widget build(BuildContext context) { - List children = []; + final children = []; if (owner != null) { children.add(Text( _getOwnerDetails(), style: Theme.of(context).inputDecorationTheme.hintStyle, - )); + ),); } if (hash != null) { @@ -45,14 +45,14 @@ class AcceleratorProjectDetails extends StatelessWidget { children.add(Text( 'Created ${_formatData(creationTimestamp! * 1000)}', style: Theme.of(context).inputDecorationTheme.hintStyle, - )); + ),); if (!isPhase && acceleratorProjectStatus != null && acceleratorProjectStatus == AcceleratorProjectStatus.voting) { children.add(Text( _getTimeUntilVotingCloses(), style: Theme.of(context).inputDecorationTheme.hintStyle, - )); + ),); } } @@ -63,18 +63,15 @@ class AcceleratorProjectDetails extends StatelessWidget { ' ● ', style: Theme.of(context).inputDecorationTheme.hintStyle, ), - )), + ),), ); } String _formatData(int transactionMillis) { - int currentMillis = DateTime.now().millisecondsSinceEpoch; + final currentMillis = DateTime.now().millisecondsSinceEpoch; if (currentMillis - transactionMillis <= const Duration( days: 1, - minutes: 0, - seconds: 0, - milliseconds: 0, ).inMilliseconds) { return _formatDataShort(currentMillis - transactionMillis); } @@ -82,7 +79,7 @@ class AcceleratorProjectDetails extends StatelessWidget { } String _formatDataShort(int i) { - Duration duration = Duration(milliseconds: i); + final duration = Duration(milliseconds: i); if (duration.inHours > 0) { return '${duration.inHours} h ago'; } @@ -93,12 +90,12 @@ class AcceleratorProjectDetails extends StatelessWidget { } String _getTimeUntilVotingCloses() { - String prefix = 'Voting closes in '; - String suffix = ''; - DateTime creationDate = + const prefix = 'Voting closes in '; + var suffix = ''; + final creationDate = DateTime.fromMillisecondsSinceEpoch((creationTimestamp ?? 0) * 1000); - DateTime votingEnds = creationDate.add(kProjectVotingPeriod); - Duration difference = votingEnds.difference(DateTime.now()); + final votingEnds = creationDate.add(kProjectVotingPeriod); + final difference = votingEnds.difference(DateTime.now()); if (difference.isNegative) { return 'Voting closed'; } @@ -115,7 +112,7 @@ class AcceleratorProjectDetails extends StatelessWidget { } String _getOwnerDetails() { - String address = owner!.toShortString(); + var address = owner!.toShortString(); if (kDefaultAddressList.contains(owner.toString())) { address = kAddressLabelMap[owner.toString()]!; } diff --git a/lib/widgets/reusable_widgets/access_wallet_fluid_cell.dart b/lib/widgets/reusable_widgets/access_wallet_fluid_cell.dart index c969c65c..3247aa34 100644 --- a/lib/widgets/reusable_widgets/access_wallet_fluid_cell.dart +++ b/lib/widgets/reusable_widgets/access_wallet_fluid_cell.dart @@ -5,13 +5,8 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class AccessWalletFluidCell extends FluidCell { - final VoidCallback? onPressed; - final String buttonIconLocation; - final String buttonText; - final BuildContext context; AccessWalletFluidCell({ - Key? key, required this.onPressed, required this.buttonIconLocation, required this.buttonText, @@ -28,11 +23,11 @@ class AccessWalletFluidCell extends FluidCell { disabledColor: Theme.of(context).colorScheme.secondary.withOpacity( 0.7, ), - padding: const EdgeInsets.all(50.0), + padding: const EdgeInsets.all(50), color: Theme.of(context).colorScheme.secondaryContainer, hoverColor: Theme.of(context).colorScheme.secondary, shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12.0), + borderRadius: BorderRadius.circular(12), side: const BorderSide(color: Colors.transparent), ), onPressed: onPressed, @@ -40,19 +35,19 @@ class AccessWalletFluidCell extends FluidCell { mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Container( - width: 70.0, - height: 70.0, + width: 70, + height: 70, color: Colors.transparent, child: SvgPicture.asset( buttonIconLocation, colorFilter: const ColorFilter.mode( - AppColors.znnColor, BlendMode.srcIn), + AppColors.znnColor, BlendMode.srcIn,), ), ), Padding( padding: const EdgeInsets.only( - left: 40.0, - right: 40.0, + left: 40, + right: 40, ), child: Text( buttonText, @@ -64,4 +59,8 @@ class AccessWalletFluidCell extends FluidCell { ), ), ); + final VoidCallback? onPressed; + final String buttonIconLocation; + final String buttonText; + final BuildContext context; } diff --git a/lib/widgets/reusable_widgets/amount_info_column.dart b/lib/widgets/reusable_widgets/amount_info_column.dart index 985109d4..321f844e 100644 --- a/lib/widgets/reusable_widgets/amount_info_column.dart +++ b/lib/widgets/reusable_widgets/amount_info_column.dart @@ -1,15 +1,9 @@ import 'package:flutter/material.dart'; class AmountInfoColumn extends Column { - final String amount; - final String tokenSymbol; - final BuildContext context; AmountInfoColumn({ - super.key, - required this.context, - required this.amount, - required this.tokenSymbol, + required this.context, required this.amount, required this.tokenSymbol, super.key, }) : super( children: [ Text( @@ -22,4 +16,7 @@ class AmountInfoColumn extends Column { ), ], ); + final String amount; + final String tokenSymbol; + final BuildContext context; } diff --git a/lib/widgets/reusable_widgets/available_balance.dart b/lib/widgets/reusable_widgets/available_balance.dart index 47f61ffe..28688ce9 100644 --- a/lib/widgets/reusable_widgets/available_balance.dart +++ b/lib/widgets/reusable_widgets/available_balance.dart @@ -3,14 +3,14 @@ import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class AvailableBalance extends StatelessWidget { - final Token token; - final AccountInfo accountInfo; const AvailableBalance( this.token, this.accountInfo, { super.key, }); + final Token token; + final AccountInfo accountInfo; @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/bullet_point_card.dart b/lib/widgets/reusable_widgets/bullet_point_card.dart index b01563ad..8792351f 100644 --- a/lib/widgets/reusable_widgets/bullet_point_card.dart +++ b/lib/widgets/reusable_widgets/bullet_point_card.dart @@ -3,18 +3,18 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; class BulletPointCard extends StatelessWidget { - final List bulletPoints; const BulletPointCard({ required this.bulletPoints, super.key, }); + final List bulletPoints; static TextSpan textSpan(String text, {List? children}) { return TextSpan( text: text, - style: const TextStyle(fontSize: 14.0, color: AppColors.subtitleColor), - children: children); + style: const TextStyle(fontSize: 14, color: AppColors.subtitleColor), + children: children,); } @override @@ -22,10 +22,10 @@ class BulletPointCard extends StatelessWidget { return Container( decoration: BoxDecoration( color: Theme.of(context).hoverColor, - borderRadius: const BorderRadius.all(Radius.circular(8.0)), + borderRadius: const BorderRadius.all(Radius.circular(8)), ), child: Padding( - padding: const EdgeInsets.all(20.0), + padding: const EdgeInsets.all(20), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: bulletPoints @@ -33,17 +33,17 @@ class BulletPointCard extends StatelessWidget { children: [ const Text('●', style: TextStyle( - fontSize: 14.0, color: AppColors.subtitleColor)), - const SizedBox(width: 10.0), - Expanded(child: e) + fontSize: 14, color: AppColors.subtitleColor,),), + const SizedBox(width: 10), + Expanded(child: e), ], - )) + ),) .toList() .zip( List.generate( bulletPoints.length - 1, (index) => const SizedBox( - height: 15.0, + height: 15, ), ), ), diff --git a/lib/widgets/reusable_widgets/buttons/elevated_button.dart b/lib/widgets/reusable_widgets/buttons/elevated_button.dart index 2e12462f..53156092 100644 --- a/lib/widgets/reusable_widgets/buttons/elevated_button.dart +++ b/lib/widgets/reusable_widgets/buttons/elevated_button.dart @@ -3,11 +3,6 @@ import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; class SyriusElevatedButton extends StatefulWidget { - final String text; - final Color initialFillColor; - final VoidCallback? onPressed; - final Widget? icon; - final ButtonStyle? style; const SyriusElevatedButton({ required this.text, @@ -17,6 +12,11 @@ class SyriusElevatedButton extends StatefulWidget { this.style, super.key, }); + final String text; + final Color initialFillColor; + final VoidCallback? onPressed; + final Widget? icon; + final ButtonStyle? style; @override State createState() { @@ -33,7 +33,7 @@ class SyriusElevatedButton extends StatefulWidget { child: const Icon( MaterialCommunityIcons.plus, color: Colors.white, - size: 15.0, + size: 15, ), ); } @@ -52,15 +52,15 @@ class _SyriusElevatedButtonState extends State { visible: widget.icon != null, child: Container( alignment: Alignment.center, - height: 20.0, - width: 20.0, + height: 20, + width: 20, child: widget.icon, ), ), Visibility( visible: widget.icon != null, child: const SizedBox( - width: 5.0, + width: 5, ), ), Text( diff --git a/lib/widgets/reusable_widgets/buttons/instruction_button.dart b/lib/widgets/reusable_widgets/buttons/instruction_button.dart index f1378f7a..c4f9c89c 100644 --- a/lib/widgets/reusable_widgets/buttons/instruction_button.dart +++ b/lib/widgets/reusable_widgets/buttons/instruction_button.dart @@ -3,12 +3,6 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_info_text.dart'; class InstructionButton extends StatefulWidget { - final String text; - final bool isEnabled; - final bool isLoading; - final VoidCallback onPressed; - final String? instructionText; - final String? loadingText; const InstructionButton({ required this.text, @@ -19,6 +13,12 @@ class InstructionButton extends StatefulWidget { this.loadingText, super.key, }); + final String text; + final bool isEnabled; + final bool isLoading; + final VoidCallback onPressed; + final String? instructionText; + final String? loadingText; @override State createState() => _InstructionButtonState(); diff --git a/lib/widgets/reusable_widgets/buttons/loading_button.dart b/lib/widgets/reusable_widgets/buttons/loading_button.dart index 28fe64ea..ec3322bc 100644 --- a/lib/widgets/reusable_widgets/buttons/loading_button.dart +++ b/lib/widgets/reusable_widgets/buttons/loading_button.dart @@ -9,16 +9,6 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; enum ButtonState { busy, idle } class LoadingButton extends StatefulWidget { - final Size minimumSize; - final double minWidth; - final VoidCallback? onPressed; - final String? text; - final Widget? child; - final Color? outlineColor; - final EdgeInsets paddingAroundChild; - final double borderWidth; - final double circularBorderRadius; - final TextStyle? textStyle; const LoadingButton({ required this.onPressed, @@ -47,7 +37,7 @@ class LoadingButton extends StatefulWidget { onPressed: onPressed, label: text, key: key, - minimumSize: const Size(90.0, 25.0), + minimumSize: const Size(90, 25), textStyle: textStyle, outlineColor: outlineColor, icon: icon, @@ -64,7 +54,7 @@ class LoadingButton extends StatefulWidget { onPressed: onPressed, text: text, key: key, - minimumSize: const Size(80.0, 25.0), + minimumSize: const Size(80, 25), textStyle: textStyle, outlineColor: outlineColor, ); @@ -79,7 +69,6 @@ class LoadingButton extends StatefulWidget { text: text, minimumSize: kSettingsButtonMinSize, key: key, - paddingAroundChild: EdgeInsets.zero, textStyle: kBodyMediumTextStyle, ); @@ -91,7 +80,7 @@ class LoadingButton extends StatefulWidget { LoadingButton( onPressed: onPressed, text: text, - minimumSize: const Size(360.0, 40.0), + minimumSize: const Size(360, 40), key: key, ); @@ -115,7 +104,7 @@ class LoadingButton extends StatefulWidget { required Widget icon, required Key key, String label = '', - Size minimumSize = const Size(50.0, 50.0), + Size minimumSize = const Size(50, 50), Color? outlineColor, TextStyle? textStyle, }) => @@ -140,6 +129,16 @@ class LoadingButton extends StatefulWidget { ], ), ); + final Size minimumSize; + final double minWidth; + final VoidCallback? onPressed; + final String? text; + final Widget? child; + final Color? outlineColor; + final EdgeInsets paddingAroundChild; + final double borderWidth; + final double circularBorderRadius; + final TextStyle? textStyle; @override LoadingButtonState createState() => LoadingButtonState(); @@ -154,7 +153,7 @@ class LoadingButtonState extends State ButtonState btnState = ButtonState.idle; final GlobalKey _outlineButtonKey = GlobalKey(); - double _minWidth = 0.0; + double _minWidth = 0; double get minWidth => _minWidth; @@ -177,7 +176,7 @@ class LoadingButtonState extends State ), ); - _animation = Tween(begin: 0.0, end: 1.0).animate( + _animation = Tween(begin: 0, end: 1).animate( CurvedAnimation( parent: _animationController, curve: Curves.easeInOutCirc, @@ -219,7 +218,7 @@ class LoadingButtonState extends State borderWidth: widget.borderWidth, outlineColor: widget.outlineColor, minimumSize: Size( - lerpWidth(widget.minimumSize.width, minWidth, _animation.value), + lerpWidth(widget.minimumSize.width, minWidth, _animation.value)!, widget.minimumSize.height, ), onPressed: btnState == ButtonState.idle ? widget.onPressed : null, @@ -228,15 +227,15 @@ class LoadingButtonState extends State widget.circularBorderRadius, widget.minimumSize.height / 2, _animation.value, - )!, + ), padding: widget.paddingAroundChild, child: btnState == ButtonState.idle ? widget.child ?? Text(widget.text!) : const SizedBox( - width: 15.0, - height: 15.0, + width: 15, + height: 15, child: CircularProgressIndicator( - strokeWidth: 1.0, + strokeWidth: 1, valueColor: AlwaysStoppedAnimation(AppColors.znnColor), ), ), @@ -258,7 +257,7 @@ class LoadingButtonState extends State } } - lerpWidth(a, b, t) { + double? lerpWidth(double a, double b, double t) { if (a == 0.0 || b == 0.0) { return null; } else { diff --git a/lib/widgets/reusable_widgets/buttons/material_icon_button.dart b/lib/widgets/reusable_widgets/buttons/material_icon_button.dart index c44f0ff4..87f72d62 100644 --- a/lib/widgets/reusable_widgets/buttons/material_icon_button.dart +++ b/lib/widgets/reusable_widgets/buttons/material_icon_button.dart @@ -2,13 +2,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; class MaterialIconButton extends StatelessWidget { - final Color iconColor; - final Color? hoverColor; - final double padding; - final MaterialTapTargetSize materialTapTargetSize; - final VoidCallback onPressed; - final IconData iconData; - final double size; const MaterialIconButton({ required this.onPressed, @@ -20,6 +13,13 @@ class MaterialIconButton extends StatelessWidget { this.materialTapTargetSize = MaterialTapTargetSize.padded, super.key, }); + final Color iconColor; + final Color? hoverColor; + final double padding; + final MaterialTapTargetSize materialTapTargetSize; + final VoidCallback onPressed; + final IconData iconData; + final double size; @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/buttons/onboarding_button.dart b/lib/widgets/reusable_widgets/buttons/onboarding_button.dart index cb63d23a..81b2bb5f 100644 --- a/lib/widgets/reusable_widgets/buttons/onboarding_button.dart +++ b/lib/widgets/reusable_widgets/buttons/onboarding_button.dart @@ -7,6 +7,6 @@ class OnboardingButton extends MyOutlinedButton { required String super.text, super.key, }) : super( - minimumSize: const Size(360.0, 40.0), + minimumSize: const Size(360, 40), ); } diff --git a/lib/widgets/reusable_widgets/buttons/outlined_button.dart b/lib/widgets/reusable_widgets/buttons/outlined_button.dart index 0a10d0c1..1009656d 100644 --- a/lib/widgets/reusable_widgets/buttons/outlined_button.dart +++ b/lib/widgets/reusable_widgets/buttons/outlined_button.dart @@ -4,19 +4,9 @@ import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class MyOutlinedButton extends StatefulWidget { - final String? text; - final TextStyle? textStyle; - final Color? outlineColor; - final VoidCallback? onPressed; - final Size? minimumSize; - final Widget? child; - final double borderWidth; - final double? circularBorderRadius; - final Color? textColor; - final EdgeInsets? padding; const MyOutlinedButton({ - this.text, + required this.onPressed, this.text, this.textStyle, this.outlineColor, this.minimumSize, @@ -25,7 +15,6 @@ class MyOutlinedButton extends StatefulWidget { this.circularBorderRadius, this.textColor, this.padding, - required this.onPressed, super.key, }); @@ -43,6 +32,16 @@ class MyOutlinedButton extends StatefulWidget { outlineColor: outlineColor, key: key, ); + final String? text; + final TextStyle? textStyle; + final Color? outlineColor; + final VoidCallback? onPressed; + final Size? minimumSize; + final Widget? child; + final double borderWidth; + final double? circularBorderRadius; + final Color? textColor; + final EdgeInsets? padding; @override MyOutlinedButtonState createState() => MyOutlinedButtonState(); @@ -99,7 +98,7 @@ class MyOutlinedButtonState extends State { ), child: _showLoading ? const SyriusLoadingWidget( - size: 25.0, + size: 25, ) : widget.text != null ? Text( @@ -122,8 +121,7 @@ class _MyOutlinedButtonWithIcon extends MyOutlinedButton { _MyOutlinedButtonWithIcon({ required String label, required Widget icon, - super.outlineColor, - required super.onPressed, + required super.onPressed, super.outlineColor, super.key, }) : super( child: _MyOutlinedButtonWithIconChild( @@ -134,13 +132,13 @@ class _MyOutlinedButtonWithIcon extends MyOutlinedButton { } class _MyOutlinedButtonWithIconChild extends StatelessWidget { - final String label; - final Widget icon; const _MyOutlinedButtonWithIconChild({ required this.label, required this.icon, }); + final String label; + final Widget icon; @override Widget build(BuildContext context) { @@ -149,7 +147,7 @@ class _MyOutlinedButtonWithIconChild extends StatelessWidget { children: [ icon, const SizedBox( - width: 15.0, + width: 15, ), Text(label), ], diff --git a/lib/widgets/reusable_widgets/buttons/send_payment_button.dart b/lib/widgets/reusable_widgets/buttons/send_payment_button.dart index 81605815..470d25c9 100644 --- a/lib/widgets/reusable_widgets/buttons/send_payment_button.dart +++ b/lib/widgets/reusable_widgets/buttons/send_payment_button.dart @@ -8,18 +8,17 @@ class SendPaymentButton extends LoadingButton { required super.key, String super.text = 'Send', super.outlineColor, - super.minimumSize = const Size(100.0, 40.0), + super.minimumSize = const Size(100, 40), }) : super( paddingAroundChild: const EdgeInsets.symmetric( - horizontal: 10.0, + horizontal: 10, ), ); factory SendPaymentButton.error({ required VoidCallback? onPressed, required Key key, - String text = 'Retry', - Size minimumSize = const Size(150.0, 40.0), + Size minimumSize = const Size(150, 40), }) => SendPaymentButton( onPressed: onPressed, diff --git a/lib/widgets/reusable_widgets/buttons/stepper_button.dart b/lib/widgets/reusable_widgets/buttons/stepper_button.dart index 727bb861..16a028d9 100644 --- a/lib/widgets/reusable_widgets/buttons/stepper_button.dart +++ b/lib/widgets/reusable_widgets/buttons/stepper_button.dart @@ -9,18 +9,15 @@ class StepperButton extends MyOutlinedButton { super.child, super.key, }) : super( - minimumSize: const Size(120.0, 40.0), + minimumSize: const Size(120, 40), ); factory StepperButton.icon({ required String label, required IconData iconData, - required context, required VoidCallback onPressed, - Color? outlineColor, }) => _MyStepperButtonWithIcon( - context: context, onPressed: onPressed, label: label, iconData: iconData, @@ -32,7 +29,6 @@ class _MyStepperButtonWithIcon extends StepperButton { required String label, required IconData iconData, required VoidCallback super.onPressed, - required BuildContext context, }) : super( child: _MyStepperButtonWithIconChild( label: label, @@ -42,13 +38,13 @@ class _MyStepperButtonWithIcon extends StepperButton { } class _MyStepperButtonWithIconChild extends StatelessWidget { - final String label; - final IconData iconData; const _MyStepperButtonWithIconChild({ required this.label, required this.iconData, }); + final String label; + final IconData iconData; @override Widget build(BuildContext context) { @@ -57,11 +53,11 @@ class _MyStepperButtonWithIconChild extends StatelessWidget { children: [ Text(label), const SizedBox( - width: 10.0, + width: 10, ), Icon( iconData, - size: 17.0, + size: 17, color: Theme.of(context).textTheme.headlineSmall!.color, ), ], diff --git a/lib/widgets/reusable_widgets/buttons/transfer_toggle_card_size_button.dart b/lib/widgets/reusable_widgets/buttons/transfer_toggle_card_size_button.dart index eef17f71..9b14128c 100644 --- a/lib/widgets/reusable_widgets/buttons/transfer_toggle_card_size_button.dart +++ b/lib/widgets/reusable_widgets/buttons/transfer_toggle_card_size_button.dart @@ -4,14 +4,14 @@ import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class TransferToggleCardSizeButton extends StatelessWidget { - final VoidCallback? onPressed; - final IconData iconData; const TransferToggleCardSizeButton({ required this.onPressed, required this.iconData, super.key, }); + final VoidCallback? onPressed; + final IconData iconData; @override Widget build(BuildContext context) { @@ -42,7 +42,7 @@ class TransferToggleCardSizeButton extends StatelessWidget { return RawMaterialButton( constraints: const BoxConstraints.tightForFinite(), padding: const EdgeInsets.all( - 20.0, + 20, ), shape: const CircleBorder(), onPressed: onButtonPressed, diff --git a/lib/widgets/reusable_widgets/cancel_timer.dart b/lib/widgets/reusable_widgets/cancel_timer.dart index 00ac3621..4a64ca08 100644 --- a/lib/widgets/reusable_widgets/cancel_timer.dart +++ b/lib/widgets/reusable_widgets/cancel_timer.dart @@ -3,9 +3,6 @@ import 'dart:async'; import 'package:flutter/material.dart'; class CancelTimer extends StatefulWidget { - final Duration timerDuration; - final Color borderColor; - final VoidCallback onTimeFinishedCallback; const CancelTimer( this.timerDuration, @@ -13,6 +10,9 @@ class CancelTimer extends StatefulWidget { required this.onTimeFinishedCallback, super.key, }); + final Duration timerDuration; + final Color borderColor; + final VoidCallback onTimeFinishedCallback; @override State createState() => _CancelTimerState(); @@ -36,7 +36,7 @@ class _CancelTimerState extends State { if (mounted && _currentDuration > const Duration( - seconds: 0, + )) { setState(() { _currentDuration = _currentDuration - @@ -56,7 +56,7 @@ class _CancelTimerState extends State { return Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular( - 5.0, + 5, ), border: Border.all( color: _borderColor, @@ -64,8 +64,8 @@ class _CancelTimerState extends State { ), child: Padding( padding: const EdgeInsets.symmetric( - horizontal: 10.0, - vertical: 5.0, + horizontal: 10, + vertical: 5, ), child: Text( _currentDuration.toString().split('.').first, diff --git a/lib/widgets/reusable_widgets/chart/chart_legend.dart b/lib/widgets/reusable_widgets/chart/chart_legend.dart index 53b6647b..b4620e37 100644 --- a/lib/widgets/reusable_widgets/chart/chart_legend.dart +++ b/lib/widgets/reusable_widgets/chart/chart_legend.dart @@ -1,9 +1,6 @@ import 'package:flutter/material.dart'; class ChartLegend extends StatelessWidget { - final Color dotColor; - final String mainText; - final Widget? detailsWidget; const ChartLegend({ required this.dotColor, @@ -11,11 +8,13 @@ class ChartLegend extends StatelessWidget { this.detailsWidget, super.key, }); + final Color dotColor; + final String mainText; + final Widget? detailsWidget; @override Widget build(BuildContext context) { return Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ Text( '● ', @@ -28,7 +27,7 @@ class ChartLegend extends StatelessWidget { style: Theme.of(context).textTheme.bodyMedium, ), const SizedBox( - width: 5.0, + width: 5, ), if (detailsWidget != null) Expanded( diff --git a/lib/widgets/reusable_widgets/chart/standard_chart.dart b/lib/widgets/reusable_widgets/chart/standard_chart.dart index c00d97ce..e95894f9 100644 --- a/lib/widgets/reusable_widgets/chart/standard_chart.dart +++ b/lib/widgets/reusable_widgets/chart/standard_chart.dart @@ -4,13 +4,6 @@ import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; class StandardChart extends StatelessWidget { - final double? yValuesInterval; - final double maxX; - final double maxY; - final List lineBarsData; - final String lineBarDotSymbol; - final DateTime titlesReferenceDate; - final bool convertLeftSideTitlesToInt; const StandardChart({ required this.yValuesInterval, @@ -22,25 +15,31 @@ class StandardChart extends StatelessWidget { this.convertLeftSideTitlesToInt = false, super.key, }); + final double? yValuesInterval; + final double maxX; + final double maxY; + final List lineBarsData; + final String lineBarDotSymbol; + final DateTime titlesReferenceDate; + final bool convertLeftSideTitlesToInt; @override Widget build(BuildContext context) { return Container( margin: const EdgeInsets.only( - left: 5.0, - right: 20.0, - top: 20.0, - bottom: 10.0, + left: 5, + right: 20, + top: 20, + bottom: 10, ), child: LineChart( LineChartData( lineTouchData: LineTouchData( - enabled: true, touchTooltipData: LineTouchTooltipData( fitInsideHorizontally: true, - tooltipMargin: 14.0, - tooltipPadding: const EdgeInsets.all(4.0), - tooltipRoundedRadius: 6.0, + tooltipMargin: 14, + tooltipPadding: const EdgeInsets.all(4), + tooltipRoundedRadius: 6, getTooltipColor: (LineBarSpot lineBarSpot) => Theme.of(context).colorScheme.surface, getTooltipItems: (touchedSpots) { @@ -49,7 +48,7 @@ class StandardChart extends StatelessWidget { final textStyle = TextStyle( color: touchedSpot.bar.color, fontWeight: FontWeight.bold, - fontSize: 14.0, + fontSize: 14, ); return LineTooltipItem( '${touchedSpot.y == touchedSpot.y.toInt() ? touchedSpot.y.toInt() : touchedSpot.y} ' @@ -64,10 +63,9 @@ class StandardChart extends StatelessWidget { gridData: FlGridData( show: false, drawVerticalLine: false, - drawHorizontalLine: true, getDrawingHorizontalLine: (_) { return const FlLine( - strokeWidth: 1.0, + strokeWidth: 1, color: Colors.black87, dashArray: [3, 3], ); @@ -77,19 +75,18 @@ class StandardChart extends StatelessWidget { bottomTitles: AxisTitles( sideTitles: SideTitles( getTitlesWidget: (value, titleMeta) => Padding( - padding: const EdgeInsets.only(top: 8.0), + padding: const EdgeInsets.only(top: 8), child: Text( FormatUtils.formatDate( FormatUtils.subtractDaysFromDate( - value.toInt(), titlesReferenceDate), + value.toInt(), titlesReferenceDate,), dateFormat: 'd MMM', ), - style: Theme.of(context).textTheme.titleSmall!, + style: Theme.of(context).textTheme.titleSmall, ), ), showTitles: true, - reservedSize: 22.0, - interval: 1.0, + interval: 1, ), ), leftTitles: AxisTitles( @@ -97,34 +94,29 @@ class StandardChart extends StatelessWidget { interval: yValuesInterval, showTitles: true, getTitlesWidget: (value, _) => Padding( - padding: const EdgeInsets.only(top: 8.0), + padding: const EdgeInsets.only(top: 8), child: Text( value != 0 ? convertLeftSideTitlesToInt ? '${value.toInt()}' : value.toStringAsFixed(2) : '', - style: Theme.of(context).textTheme.titleSmall!, + style: Theme.of(context).textTheme.titleSmall, ), ), - reservedSize: 26.0, + reservedSize: 26, ), ), rightTitles: const AxisTitles( - sideTitles: SideTitles( - showTitles: false, - ), + ), - topTitles: const AxisTitles( - sideTitles: SideTitles( - showTitles: false, - )), + topTitles: const AxisTitles(), ), borderData: FlBorderData(show: false), - minX: 0.0, + minX: 0, maxX: maxX, maxY: maxY, - minY: 0.0, + minY: 0, lineBarsData: lineBarsData, ), ), diff --git a/lib/widgets/reusable_widgets/chart/standard_line_chart_bar_data.dart b/lib/widgets/reusable_widgets/chart/standard_line_chart_bar_data.dart index 92e34146..8e59e767 100644 --- a/lib/widgets/reusable_widgets/chart/standard_line_chart_bar_data.dart +++ b/lib/widgets/reusable_widgets/chart/standard_line_chart_bar_data.dart @@ -7,8 +7,8 @@ class StandardLineChartBarData extends LineChartBarData { required List? spots, }) : super( color: color, - barWidth: 3.0, + barWidth: 3, isStrokeCapRound: true, - spots: spots ?? const [] + spots: spots ?? const [], ); } diff --git a/lib/widgets/reusable_widgets/chart/standard_pie_chart.dart b/lib/widgets/reusable_widgets/chart/standard_pie_chart.dart index aa08fb75..14bb3e31 100644 --- a/lib/widgets/reusable_widgets/chart/standard_pie_chart.dart +++ b/lib/widgets/reusable_widgets/chart/standard_pie_chart.dart @@ -2,14 +2,9 @@ import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; class StandardPieChart extends PieChart { - final List sections; - final void Function(PieTouchedSection?)? onChartSectionTouched; - final double? centerSpaceRadius; - final double sectionsSpace; StandardPieChart({ - Key? key, - required this.sections, + required this.sections, Key? key, this.sectionsSpace = 0.0, this.centerSpaceRadius, this.onChartSectionTouched, @@ -24,7 +19,7 @@ class StandardPieChart extends PieChart { return; } onChartSectionTouched?.call( - pieTouchResponse.touchedSection!, + pieTouchResponse.touchedSection, ); }, ), @@ -37,4 +32,8 @@ class StandardPieChart extends PieChart { ), key: key, ); + final List sections; + final void Function(PieTouchedSection?)? onChartSectionTouched; + final double? centerSpaceRadius; + final double sectionsSpace; } diff --git a/lib/widgets/reusable_widgets/context_menu_region.dart b/lib/widgets/reusable_widgets/context_menu_region.dart index e9f7e445..592cd397 100644 --- a/lib/widgets/reusable_widgets/context_menu_region.dart +++ b/lib/widgets/reusable_widgets/context_menu_region.dart @@ -2,7 +2,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; typedef ContextMenuBuilder = Widget Function( - BuildContext context, Offset offset); + BuildContext context, Offset offset,); /// Shows and hides the context menu based on user gestures. /// @@ -10,9 +10,7 @@ typedef ContextMenuBuilder = Widget Function( class ContextMenuRegion extends StatefulWidget { /// Creates an instance of [ContextMenuRegion]. const ContextMenuRegion({ - super.key, - required this.child, - required this.contextMenuBuilder, + required this.child, required this.contextMenuBuilder, super.key, }); /// Builds the context menu. diff --git a/lib/widgets/reusable_widgets/custom_expandable_panel.dart b/lib/widgets/reusable_widgets/custom_expandable_panel.dart index a05954a1..f9074e7b 100644 --- a/lib/widgets/reusable_widgets/custom_expandable_panel.dart +++ b/lib/widgets/reusable_widgets/custom_expandable_panel.dart @@ -3,14 +3,14 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; class CustomExpandablePanel extends StatefulWidget { - final String header; - final Widget expandedChild; const CustomExpandablePanel( this.header, this.expandedChild, { super.key, }); + final String header; + final Widget expandedChild; @override State createState() => _CustomExpandablePanelState(); @@ -39,7 +39,7 @@ class _CustomExpandablePanelState extends State { collapsed: Container(), header: Padding( padding: const EdgeInsets.only( - left: 15.0, + left: 15, ), child: Text( widget.header, @@ -48,8 +48,8 @@ class _CustomExpandablePanelState extends State { ), expanded: Padding( padding: const EdgeInsets.symmetric( - vertical: 5.0, - horizontal: 15.0, + vertical: 5, + horizontal: 15, ), child: widget.expandedChild, ), diff --git a/lib/widgets/reusable_widgets/custom_material_stepper.dart b/lib/widgets/reusable_widgets/custom_material_stepper.dart index 8e7c6aa0..b5cfdce8 100644 --- a/lib/widgets/reusable_widgets/custom_material_stepper.dart +++ b/lib/widgets/reusable_widgets/custom_material_stepper.dart @@ -35,7 +35,7 @@ enum StepperType { } const TextStyle _kStepStyle = TextStyle( - fontSize: 23.0, + fontSize: 23, color: Colors.white, fontWeight: FontWeight.w400, ); @@ -45,7 +45,7 @@ const Color _kCircleActiveLight = Colors.white; const Color _kCircleActiveDark = Colors.black87; const Color _kDisabledLight = Colors.black38; const Color _kDisabledDark = Colors.white38; -const double _kStepSize = 40.0; +const double _kStepSize = 40; const double _kTriangleHeight = _kStepSize * 0.866025; // Triangle height. sqrt(3.0) / 2.0 @@ -64,8 +64,7 @@ class Step { /// The [title], [content], and [state] arguments must not be null. const Step({ required this.title, - this.subtitle, - required this.content, + required this.content, this.subtitle, this.state = StepState.indexed, this.isActive = false, }); @@ -114,8 +113,7 @@ class Stepper extends StatefulWidget { /// /// The [steps], [type], and [currentStep] arguments must not be null. const Stepper({ - super.key, - required this.steps, + required this.steps, super.key, this.physics, this.type = StepperType.vertical, this.currentStep = 0, @@ -233,7 +231,7 @@ class _StepperState extends State with TickerProviderStateMixin { (int i) => GlobalKey(), ); - for (int i = 0; i < widget.steps.length; i += 1) { + for (var i = 0; i < widget.steps.length; i += 1) { _oldStates[i] = widget.steps[i].state; } } @@ -243,7 +241,7 @@ class _StepperState extends State with TickerProviderStateMixin { super.didUpdateWidget(oldWidget); assert(widget.steps.length == oldWidget.steps.length); - for (int i = 0; i < oldWidget.steps.length; i += 1) { + for (var i = 0; i < oldWidget.steps.length; i += 1) { _oldStates[i] = oldWidget.steps[i].state; } } @@ -267,15 +265,15 @@ class _StepperState extends State with TickerProviderStateMixin { Widget _buildLine(bool visible) { return Container( width: visible ? 2.0 : 0.0, - height: 16.0, + height: 16, color: AppColors.darkSecondary, ); } Widget? _buildCircleChild(int index, bool oldState) { - final StepState state = + final state = oldState ? _oldStates[index]! : widget.steps[index].state; - final bool isDarkActive = _isDark() && widget.steps[index].isActive; + final isDarkActive = _isDark() && widget.steps[index].isActive; switch (state) { case StepState.indexed: case StepState.disabled: @@ -289,13 +287,13 @@ class _StepperState extends State with TickerProviderStateMixin { return Icon( Icons.edit, color: isDarkActive ? _kCircleActiveDark : _kCircleActiveLight, - size: 18.0, + size: 18, ); case StepState.complete: return Icon( Icons.check, color: isDarkActive ? _kCircleActiveDark : _kCircleActiveLight, - size: 18.0, + size: 18, ); case StepState.error: return const Text('!', style: _kStepStyle); @@ -304,7 +302,7 @@ class _StepperState extends State with TickerProviderStateMixin { Widget _buildCircle(int index, bool oldState) { return Container( - margin: const EdgeInsets.symmetric(vertical: 8.0), + margin: const EdgeInsets.symmetric(vertical: 8), width: _kStepSize, height: _kStepSize, child: AnimatedContainer( @@ -320,7 +318,7 @@ class _StepperState extends State with TickerProviderStateMixin { ), child: Center( child: _buildCircleChild( - index, oldState && widget.steps[index].state == StepState.error), + index, oldState && widget.steps[index].state == StepState.error,), ), ), ); @@ -328,7 +326,7 @@ class _StepperState extends State with TickerProviderStateMixin { Widget _buildTriangle(int index, bool oldState) { return Container( - margin: const EdgeInsets.symmetric(vertical: 8.0), + margin: const EdgeInsets.symmetric(vertical: 8), width: _kStepSize, height: _kStepSize, child: Center( @@ -342,9 +340,9 @@ class _StepperState extends State with TickerProviderStateMixin { ), child: Align( alignment: const Alignment( - 0.0, 0.8), // 0.8 looks better than the geometrical 0.33. + 0, 0.8,), // 0.8 looks better than the geometrical 0.33. child: _buildCircleChild(index, - oldState && widget.steps[index].state != StepState.error), + oldState && widget.steps[index].state != StepState.error,), ), ), ), @@ -357,8 +355,8 @@ class _StepperState extends State with TickerProviderStateMixin { return AnimatedCrossFade( firstChild: _buildCircle(index, true), secondChild: _buildTriangle(index, true), - firstCurve: const Interval(0.0, 0.6, curve: Curves.fastOutSlowIn), - secondCurve: const Interval(0.4, 1.0, curve: Curves.fastOutSlowIn), + firstCurve: const Interval(0, 0.6, curve: Curves.fastOutSlowIn), + secondCurve: const Interval(0.4, 1, curve: Curves.fastOutSlowIn), sizeCurve: Curves.fastOutSlowIn, crossFadeState: widget.steps[index].state == StepState.error ? CrossFadeState.showSecond @@ -376,13 +374,13 @@ class _StepperState extends State with TickerProviderStateMixin { Widget _buildVerticalControls() { return const SizedBox( - height: 0.0, + height: 0, ); } TextStyle? _titleStyle(int index) { - final ThemeData themeData = Theme.of(context); - final TextTheme textTheme = themeData.textTheme; + final themeData = Theme.of(context); + final textTheme = themeData.textTheme; switch (widget.steps[index].state) { case StepState.indexed: @@ -399,8 +397,8 @@ class _StepperState extends State with TickerProviderStateMixin { } TextStyle? _subtitleStyle(int index) { - final ThemeData themeData = Theme.of(context); - final TextTheme textTheme = themeData.textTheme; + final themeData = Theme.of(context); + final textTheme = themeData.textTheme; switch (widget.steps[index].state) { case StepState.indexed: @@ -429,7 +427,7 @@ class _StepperState extends State with TickerProviderStateMixin { ), if (widget.steps[index].subtitle != null) Container( - margin: const EdgeInsets.only(top: 2.0), + margin: const EdgeInsets.only(top: 2), child: AnimatedDefaultTextStyle( style: _subtitleStyle(index)!, duration: kThemeAnimationDuration, @@ -443,7 +441,7 @@ class _StepperState extends State with TickerProviderStateMixin { Widget _buildVerticalHeader(int index) { return Container( - margin: const EdgeInsets.symmetric(horizontal: 24.0), + margin: const EdgeInsets.symmetric(horizontal: 24), child: Row( children: [ Column( @@ -457,9 +455,9 @@ class _StepperState extends State with TickerProviderStateMixin { ), Expanded( child: Container( - margin: const EdgeInsetsDirectional.only(start: 12.0), + margin: const EdgeInsetsDirectional.only(start: 12), child: _buildHeaderText(index), - )), + ),), ], ), ); @@ -469,11 +467,11 @@ class _StepperState extends State with TickerProviderStateMixin { return Stack( children: [ PositionedDirectional( - start: 32.0, - top: 0.0, - bottom: 0.0, + start: 32, + top: 0, + bottom: 0, child: SizedBox( - width: 24.0, + width: 24, child: Center( child: SizedBox( width: _isLast(index) ? 0.0 : 2.0, @@ -485,12 +483,11 @@ class _StepperState extends State with TickerProviderStateMixin { ), ), AnimatedCrossFade( - firstChild: Container(height: 0.0), + firstChild: Container(height: 0), secondChild: Container( margin: const EdgeInsetsDirectional.only( - start: 40.0, - end: 24.0, - bottom: 0.0, + start: 40, + end: 24, ), child: Column( children: [ @@ -498,13 +495,13 @@ class _StepperState extends State with TickerProviderStateMixin { visible: index == widget.steps.length - 1 ? widget.steps[index].state != StepState.complete : true, - child: widget.steps[index].content), + child: widget.steps[index].content,), _buildVerticalControls(), ], ), ), - firstCurve: const Interval(0.0, 0.6, curve: Curves.fastOutSlowIn), - secondCurve: const Interval(0.4, 1.0, curve: Curves.fastOutSlowIn), + firstCurve: const Interval(0, 0.6, curve: Curves.fastOutSlowIn), + secondCurve: const Interval(0.4, 1, curve: Curves.fastOutSlowIn), sizeCurve: Curves.fastOutSlowIn, crossFadeState: _isCurrent(index) ? CrossFadeState.showSecond @@ -528,7 +525,7 @@ class _StepperState extends State with TickerProviderStateMixin { overlayColor: WidgetStateProperty.resolveWith((states) => states.contains(WidgetState.hovered) ? Colors.transparent - : null), + : null,), onTap: widget.steps[i].state != StepState.disabled ? () { // In the vertical case we need to scroll to the newly tapped @@ -555,7 +552,7 @@ class _StepperState extends State with TickerProviderStateMixin { } Widget _buildHorizontal() { - final List children = [ + final children = [ for (int i = 0; i < widget.steps.length; i += 1) ...[ InkResponse( onTap: widget.steps[i].state != StepState.disabled @@ -567,13 +564,13 @@ class _StepperState extends State with TickerProviderStateMixin { child: Row( children: [ SizedBox( - height: 72.0, + height: 72, child: Center( child: _buildIcon(i), ), ), Container( - margin: const EdgeInsetsDirectional.only(start: 12.0), + margin: const EdgeInsetsDirectional.only(start: 12), child: _buildHeaderText(i), ), ], @@ -582,8 +579,8 @@ class _StepperState extends State with TickerProviderStateMixin { if (!_isLast(i)) Expanded( child: Container( - margin: const EdgeInsets.symmetric(horizontal: 8.0), - height: 1.0, + margin: const EdgeInsets.symmetric(horizontal: 8), + height: 1, color: Colors.grey.shade400, ), ), @@ -593,9 +590,9 @@ class _StepperState extends State with TickerProviderStateMixin { return Column( children: [ Material( - elevation: 2.0, + elevation: 2, child: Container( - margin: const EdgeInsets.symmetric(horizontal: 24.0), + margin: const EdgeInsets.symmetric(horizontal: 24), child: Row( children: children, ), @@ -604,7 +601,7 @@ class _StepperState extends State with TickerProviderStateMixin { Expanded( child: ListView( physics: widget.physics, - padding: const EdgeInsets.all(24.0), + padding: const EdgeInsets.all(24), children: [ Visibility( visible: widget.currentStep == widget.steps.length - 1 @@ -666,13 +663,13 @@ class _TrianglePainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { - final double base = size.width; - final double halfBase = size.width / 2.0; - final double height = size.height; - final List points = [ - Offset(0.0, height), + final base = size.width; + final halfBase = size.width / 2.0; + final height = size.height; + final points = [ + Offset(0, height), Offset(base, height), - Offset(halfBase, 0.0), + Offset(halfBase, 0), ]; canvas.drawPath( diff --git a/lib/widgets/reusable_widgets/custom_slider.dart b/lib/widgets/reusable_widgets/custom_slider.dart index 35219b9e..6138c1de 100644 --- a/lib/widgets/reusable_widgets/custom_slider.dart +++ b/lib/widgets/reusable_widgets/custom_slider.dart @@ -35,8 +35,8 @@ Path _upTriangle(double size, Offset thumbCenter) => class _CustomThumbShape extends SliderComponentShape { const _CustomThumbShape(); - static const double _thumbSize = 4.0; - static const double _disabledThumbSize = 3.0; + static const double _thumbSize = 4; + static const double _disabledThumbSize = 3; @override Size getPreferredSize(bool isEnabled, bool isDiscrete) { @@ -54,12 +54,10 @@ class _CustomThumbShape extends SliderComponentShape { void paint( PaintingContext context, Offset thumbCenter, { - Animation? activationAnimation, - required Animation enableAnimation, + required Animation enableAnimation, required SliderThemeData sliderTheme, Animation? activationAnimation, bool? isDiscrete, TextPainter? labelPainter, RenderBox? parentBox, - required SliderThemeData sliderTheme, TextDirection? textDirection, double? value, double? textScaleFactor, @@ -82,9 +80,9 @@ class _CustomThumbShape extends SliderComponentShape { class _CustomValueIndicatorShape extends SliderComponentShape { const _CustomValueIndicatorShape(); - static const double _indicatorSize = 4.0; - static const double _disabledIndicatorSize = 3.0; - static const double _slideUpHeight = 40.0; + static const double _indicatorSize = 4; + static const double _disabledIndicatorSize = 3; + static const double _slideUpHeight = 40; @override Size getPreferredSize(bool isEnabled, bool isDiscrete) { @@ -102,10 +100,8 @@ class _CustomValueIndicatorShape extends SliderComponentShape { Offset thumbCenter, { required Animation activationAnimation, required Animation enableAnimation, - bool? isDiscrete, - required TextPainter labelPainter, + required TextPainter labelPainter, required SliderThemeData sliderTheme, bool? isDiscrete, RenderBox? parentBox, - required SliderThemeData sliderTheme, TextDirection? textDirection, double? value, double? textScaleFactor, @@ -117,12 +113,12 @@ class _CustomValueIndicatorShape extends SliderComponentShape { end: sliderTheme.valueIndicatorColor, ); final slideUpTween = Tween( - begin: 0.0, + begin: 0, end: _slideUpHeight, ); final size = _indicatorSize * sizeTween.evaluate(enableAnimation); final slideUpOffset = - Offset(0.0, -slideUpTween.evaluate(activationAnimation)); + Offset(0, -slideUpTween.evaluate(activationAnimation)); final thumbPath = _upTriangle(size, thumbCenter + slideUpOffset); final paintColor = enableColor .evaluate(enableAnimation)! @@ -137,7 +133,7 @@ class _CustomValueIndicatorShape extends SliderComponentShape { Paint() ..color = paintColor ..style = PaintingStyle.stroke - ..strokeWidth = 2.0); + ..strokeWidth = 2.0,); labelPainter.paint( canvas, thumbCenter + @@ -148,12 +144,6 @@ class _CustomValueIndicatorShape extends SliderComponentShape { } class CustomSlider extends StatefulWidget { - final String description; - final double? startValue; - final double maxValue; - final Function callback; - final double min; - final Color activeColor; const CustomSlider({ required this.description, @@ -164,6 +154,12 @@ class CustomSlider extends StatefulWidget { this.activeColor = AppColors.znnColor, super.key, }); + final String description; + final double? startValue; + final double maxValue; + final Function callback; + final double min; + final Color activeColor; @override State createState() => _CustomSliderState(); @@ -185,7 +181,7 @@ class _CustomSliderState extends State { children: [ SliderTheme( data: theme.sliderTheme.copyWith( - trackHeight: 2.0, + trackHeight: 2, activeTrackColor: widget.activeColor, inactiveTrackColor: theme.colorScheme.onSurface.withOpacity(0.5), diff --git a/lib/widgets/reusable_widgets/custom_table.dart b/lib/widgets/reusable_widgets/custom_table.dart index 70356e28..565bb437 100644 --- a/lib/widgets/reusable_widgets/custom_table.dart +++ b/lib/widgets/reusable_widgets/custom_table.dart @@ -8,11 +8,6 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class CustomTable extends StatefulWidget { - final List? items; - final List? headerColumns; - final List Function(T, bool) generateRowCells; - final VoidCallback? onShowMoreButtonPressed; - final void Function(int index)? onRowTappedCallback; const CustomTable({ required this.items, @@ -22,6 +17,11 @@ class CustomTable extends StatefulWidget { this.onRowTappedCallback, super.key, }); + final List? items; + final List? headerColumns; + final List Function(T, bool) generateRowCells; + final VoidCallback? onShowMoreButtonPressed; + final void Function(int index)? onRowTappedCallback; @override State createState() => _CustomTableState(); @@ -71,19 +71,18 @@ class _CustomTableState extends State> { border: Border( bottom: BorderSide( color: Theme.of(context).dividerTheme.color!, - width: 1.0, ), ), ), padding: const EdgeInsets.symmetric( - vertical: 15.0, + vertical: 15, ), child: Row( children: List.from( [ const SizedBox( - width: 20.0, - ) + width: 20, + ), ], ) + (widget.headerColumns ?? []), @@ -92,7 +91,7 @@ class _CustomTableState extends State> { } Widget _getTableRow(dynamic item, int indexOfRow) { - bool isSelected = _selectedRowIndex == indexOfRow; + final isSelected = _selectedRowIndex == indexOfRow; return InkWell( onTap: () { @@ -120,20 +119,20 @@ class _CustomTableState extends State> { left: isSelected ? const BorderSide( color: AppColors.znnColor, - width: 2.0, + width: 2, ) : BorderSide.none, ), ), padding: const EdgeInsets.symmetric( - vertical: 15.0, + vertical: 15, ), child: Row( children: List.from( [ const SizedBox( - width: 20.0, - ) + width: 20, + ), ], ) + widget.generateRowCells(item, isSelected), @@ -165,10 +164,6 @@ class _CustomTableState extends State> { } class CustomHeaderColumn extends StatelessWidget { - final String columnName; - final Function(String)? onSortArrowsPressed; - final MainAxisAlignment contentAlign; - final int flex; const CustomHeaderColumn({ required this.columnName, @@ -177,6 +172,10 @@ class CustomHeaderColumn extends StatelessWidget { this.flex = 1, super.key, }); + final String columnName; + final Function(String)? onSortArrowsPressed; + final MainAxisAlignment contentAlign; + final int flex; @override Widget build(BuildContext context) { @@ -195,11 +194,11 @@ class CustomHeaderColumn extends StatelessWidget { onTap: () => onSortArrowsPressed!(columnName), child: Icon( Entypo.select_arrows, - size: 15.0, + size: 15, color: Theme.of(context).iconTheme.color, ), ), - ) + ), ], ), ); @@ -207,8 +206,6 @@ class CustomHeaderColumn extends StatelessWidget { } class CustomTableCell extends StatelessWidget { - final Widget child; - final int flex; const CustomTableCell( this.child, { @@ -229,7 +226,7 @@ class CustomTableCell extends StatelessWidget { message: address.toString(), child: Container( margin: const EdgeInsets.only( - right: 10.0, + right: 10, ), child: Marquee( child: Text( @@ -237,7 +234,7 @@ class CustomTableCell extends StatelessWidget { style: textStyle ?? TextStyle( color: textColor, - fontSize: 12.0, + fontSize: 12, ), ), ), @@ -249,7 +246,7 @@ class CustomTableCell extends StatelessWidget { materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, ), const SizedBox( - width: 10.0, + width: 10, ), ], ); @@ -266,7 +263,7 @@ class CustomTableCell extends StatelessWidget { Expanded( child: Container( margin: const EdgeInsets.only( - right: 10.0, + right: 10, ), child: Marquee( child: Text( @@ -274,7 +271,7 @@ class CustomTableCell extends StatelessWidget { style: textStyle ?? TextStyle( color: textColor, - fontSize: 12.0, + fontSize: 12, ), ), ), @@ -289,7 +286,7 @@ class CustomTableCell extends StatelessWidget { materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, ), const SizedBox( - width: 10.0, + width: 10, ), ], ), @@ -331,7 +328,7 @@ class CustomTableCell extends StatelessWidget { materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, ), const SizedBox( - width: 10.0, + width: 10, ), ], ), @@ -369,13 +366,15 @@ class CustomTableCell extends StatelessWidget { materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, ), const SizedBox( - width: 10.0, + width: 10, ), ], ), ), ], ); + final Widget child; + final int flex; @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/dialogs.dart b/lib/widgets/reusable_widgets/dialogs.dart index 26012994..5619a2be 100644 --- a/lib/widgets/reusable_widgets/dialogs.dart +++ b/lib/widgets/reusable_widgets/dialogs.dart @@ -1,20 +1,20 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -showWarningDialog({ +Future showWarningDialog({ required BuildContext context, required String title, required String description, required String buttonText, VoidCallback? onActionButtonPressed, }) async { - bool isPressed = false; + var isPressed = false; await showDialog( context: context, builder: (context) => AlertDialog( icon: const Icon( Icons.warning, - size: 24.0, + size: 24, color: Colors.orange, ), title: Text(title), @@ -46,7 +46,7 @@ showWarningDialog({ buttonText.isEmpty ? 'OK' : buttonText, style: Theme.of(context).textTheme.bodyMedium, ), - ) + ), ], ), barrierDismissible: false, @@ -54,7 +54,7 @@ showWarningDialog({ return isPressed; } -showDialogWithNoAndYesOptions({ +Future showDialogWithNoAndYesOptions({ required BuildContext context, required String title, required VoidCallback onYesButtonPressed, @@ -83,7 +83,7 @@ showDialogWithNoAndYesOptions({ TextButton( style: Theme.of(context).textButtonTheme.style!.copyWith( backgroundColor: WidgetStateColor.resolveWith( - (states) => AppColors.errorColor), + (states) => AppColors.errorColor,), ), onPressed: () { onYesButtonPressed.call(); @@ -98,15 +98,15 @@ showDialogWithNoAndYesOptions({ ), ); -showCustomDialog({required BuildContext context, required Widget content}) => +Future showCustomDialog({required BuildContext context, required Widget content}) => showGeneralDialog( context: context, barrierLabel: '', barrierDismissible: true, pageBuilder: (context, Animation animation, - Animation secondaryAnimation) => + Animation secondaryAnimation,) => Center( child: ClipRRect( - borderRadius: BorderRadius.circular(15.0), child: content), + borderRadius: BorderRadius.circular(15), child: content,), ), ); diff --git a/lib/widgets/reusable_widgets/dotted_border_info_widget.dart b/lib/widgets/reusable_widgets/dotted_border_info_widget.dart index 62143213..279461b5 100644 --- a/lib/widgets/reusable_widgets/dotted_border_info_widget.dart +++ b/lib/widgets/reusable_widgets/dotted_border_info_widget.dart @@ -4,14 +4,14 @@ import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; class DottedBorderInfoWidget extends StatefulWidget { - final String text; - final Color borderColor; const DottedBorderInfoWidget({ required this.text, this.borderColor = AppColors.znnColor, super.key, }); + final String text; + final Color borderColor; @override State createState() => _DottedBorderInfoWidgetState(); @@ -21,19 +21,19 @@ class _DottedBorderInfoWidgetState extends State { @override Widget build(BuildContext context) { return DottedBorder( - padding: const EdgeInsets.all(5.0), + padding: const EdgeInsets.all(5), color: widget.borderColor, borderType: BorderType.RRect, - radius: const Radius.circular(6.0), + radius: const Radius.circular(6), dashPattern: const [3.0], - strokeWidth: 2.0, + strokeWidth: 2, child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( MaterialCommunityIcons.exclamation_thick, - size: 25.0, + size: 25, color: widget.borderColor, ), Flexible( @@ -44,7 +44,7 @@ class _DottedBorderInfoWidgetState extends State { ), ), const SizedBox( - width: 10.0, + width: 10, ), ], ), diff --git a/lib/widgets/reusable_widgets/dropdown/addresses_dropdown.dart b/lib/widgets/reusable_widgets/dropdown/addresses_dropdown.dart index 3478c699..da6de00f 100644 --- a/lib/widgets/reusable_widgets/dropdown/addresses_dropdown.dart +++ b/lib/widgets/reusable_widgets/dropdown/addresses_dropdown.dart @@ -4,27 +4,27 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; class AddressesDropdown extends StatelessWidget { - final Function(String?)? onChangedCallback; - final String? _selectedSelfAddress; const AddressesDropdown( this._selectedSelfAddress, this.onChangedCallback, { super.key, }); + final Function(String?)? onChangedCallback; + final String? _selectedSelfAddress; @override Widget build(BuildContext context) { return Tooltip( - message: _selectedSelfAddress!, + message: _selectedSelfAddress, child: FocusableActionDetector( mouseCursor: SystemMouseCursors.click, child: Container( padding: const EdgeInsets.only( - left: 10.0, + left: 10, ), decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), + borderRadius: BorderRadius.circular(5), color: Theme.of(context).inputDecorationTheme.fillColor, ), child: DropdownButtonHideUnderline( @@ -32,14 +32,14 @@ class AddressesDropdown extends StatelessWidget { isExpanded: true, icon: Container( margin: const EdgeInsets.symmetric( - horizontal: 10.0, + horizontal: 10, ), padding: const EdgeInsets.only( right: 7.5, ), child: Icon( SimpleLineIcons.arrow_down, - size: 10.0, + size: 10, color: onChangedCallback != null ? AppColors.znnColor : AppColors.lightSecondary, diff --git a/lib/widgets/reusable_widgets/dropdown/basic_dropdown.dart b/lib/widgets/reusable_widgets/dropdown/basic_dropdown.dart index 9d845abf..f4ca909a 100644 --- a/lib/widgets/reusable_widgets/dropdown/basic_dropdown.dart +++ b/lib/widgets/reusable_widgets/dropdown/basic_dropdown.dart @@ -4,10 +4,6 @@ import 'package:zenon_syrius_wallet_flutter/model/basic_dropdown_item.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; class BasicDropdown extends StatelessWidget { - final String _hint; - final BasicDropdownItem? _selectedValue; - final List> _items; - final Function(BasicDropdownItem?)? onChangedCallback; const BasicDropdown( this._hint, @@ -16,14 +12,18 @@ class BasicDropdown extends StatelessWidget { this.onChangedCallback, { super.key, }); + final String _hint; + final BasicDropdownItem? _selectedValue; + final List> _items; + final Function(BasicDropdownItem?)? onChangedCallback; @override Widget build(BuildContext context) { return Container( - padding: const EdgeInsets.only(left: 10.0), + padding: const EdgeInsets.only(left: 10), decoration: BoxDecoration( color: Theme.of(context).inputDecorationTheme.fillColor, - borderRadius: BorderRadius.circular(5.0), + borderRadius: BorderRadius.circular(5), ), child: DropdownButtonHideUnderline( child: DropdownButton>( @@ -32,10 +32,10 @@ class BasicDropdown extends StatelessWidget { style: Theme.of(context).inputDecorationTheme.hintStyle, ), icon: Container( - margin: const EdgeInsets.fromLTRB(10.0, 0.0, 17.5, 0.0), + margin: const EdgeInsets.fromLTRB(10, 0, 17.5, 0), child: Icon( SimpleLineIcons.arrow_down, - size: 10.0, + size: 10, color: _selectedValue != null ? AppColors.znnColor : AppColors.lightSecondary, diff --git a/lib/widgets/reusable_widgets/dropdown/coin_dropdown.dart b/lib/widgets/reusable_widgets/dropdown/coin_dropdown.dart index 2cb005b2..c980b392 100644 --- a/lib/widgets/reusable_widgets/dropdown/coin_dropdown.dart +++ b/lib/widgets/reusable_widgets/dropdown/coin_dropdown.dart @@ -6,9 +6,6 @@ import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class CoinDropdown extends StatelessWidget { - final Function(Token?) _onChangeCallback; - final Token _selectedToken; - final List _availableTokens; const CoinDropdown( this._availableTokens, @@ -16,6 +13,9 @@ class CoinDropdown extends StatelessWidget { this._onChangeCallback, { super.key, }); + final Function(Token?) _onChangeCallback; + final Token _selectedToken; + final List _availableTokens; @override Widget build(BuildContext context) { @@ -39,7 +39,7 @@ class CoinDropdown extends StatelessWidget { color: ColorUtils.getTokenColor(e!.tokenStandard), ), child: Padding( - padding: const EdgeInsets.only(left: 8.0), + padding: const EdgeInsets.only(left: 8), child: Row( children: [ Text( @@ -53,14 +53,14 @@ class CoinDropdown extends StatelessWidget { ), const Padding( padding: EdgeInsets.symmetric( - horizontal: 5.0, + horizontal: 5, ), child: Icon( SimpleLineIcons.arrow_down, - size: 8.0, + size: 8, color: Colors.white, ), - ) + ), ], ), ), diff --git a/lib/widgets/reusable_widgets/error_widget.dart b/lib/widgets/reusable_widgets/error_widget.dart index 804a95d3..8b0a45ef 100644 --- a/lib/widgets/reusable_widgets/error_widget.dart +++ b/lib/widgets/reusable_widgets/error_widget.dart @@ -2,27 +2,27 @@ import 'package:flutter/material.dart'; import 'package:lottie/lottie.dart'; class SyriusErrorWidget extends StatelessWidget { - static const String route = 'syrius-error-widget'; - - final Object error; const SyriusErrorWidget( this.error, { super.key, }); + static const String route = 'syrius-error-widget'; + + final Object error; @override Widget build(BuildContext context) { return Center( child: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: SingleChildScrollView( child: Column( children: [ Lottie.asset( 'assets/lottie/ic_anim_no_data.json', - width: 32.0, - height: 32.0, + width: 32, + height: 32, ), Text( _getErrorText(error.toString()), diff --git a/lib/widgets/reusable_widgets/exchange_rate_widget.dart b/lib/widgets/reusable_widgets/exchange_rate_widget.dart index a077a3ea..ba6f1f51 100644 --- a/lib/widgets/reusable_widgets/exchange_rate_widget.dart +++ b/lib/widgets/reusable_widgets/exchange_rate_widget.dart @@ -4,12 +4,6 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; class ExchangeRateWidget extends StatefulWidget { - final BigInt fromAmount; - final int fromDecimals; - final String fromSymbol; - final BigInt toAmount; - final int toDecimals; - final String toSymbol; const ExchangeRateWidget({ required this.fromAmount, @@ -20,6 +14,12 @@ class ExchangeRateWidget extends StatefulWidget { required this.toSymbol, super.key, }); + final BigInt fromAmount; + final int fromDecimals; + final String fromSymbol; + final BigInt toAmount; + final int toDecimals; + final String toSymbol; @override State createState() => _ExchangeRateWidgetState(); @@ -37,10 +37,10 @@ class _ExchangeRateWidgetState extends State { Text( _getFormattedRate(), style: - const TextStyle(fontSize: 14.0, color: AppColors.subtitleColor), + const TextStyle(fontSize: 14, color: AppColors.subtitleColor), ), const SizedBox( - width: 5.0, + width: 5, ), MouseRegion( cursor: SystemMouseCursors.click, @@ -51,7 +51,7 @@ class _ExchangeRateWidgetState extends State { child: const Icon( Icons.swap_horiz, color: AppColors.subtitleColor, - size: 22.0, + size: 22, ), ), ), @@ -65,16 +65,16 @@ class _ExchangeRateWidgetState extends State { return '-'; } final fromAmountWithDecimals = BigDecimal.createAndStripZerosForScale( - widget.fromAmount, widget.fromDecimals, widget.fromDecimals); + widget.fromAmount, widget.fromDecimals, widget.fromDecimals,); final toAmountWithDecimals = BigDecimal.createAndStripZerosForScale( - widget.toAmount, widget.toDecimals, widget.toDecimals); + widget.toAmount, widget.toDecimals, widget.toDecimals,); if (_isToggled) { - final rate = (fromAmountWithDecimals.divide(toAmountWithDecimals, - roundingMode: RoundingMode.DOWN)); + final rate = fromAmountWithDecimals.divide(toAmountWithDecimals, + roundingMode: RoundingMode.DOWN,); return '1 ${widget.toSymbol} = ${rate.toDouble().toStringFixedNumDecimals(5)} ${widget.fromSymbol}'; } else { - final rate = (toAmountWithDecimals.divide(fromAmountWithDecimals, - roundingMode: RoundingMode.DOWN)); + final rate = toAmountWithDecimals.divide(fromAmountWithDecimals, + roundingMode: RoundingMode.DOWN,); return '1 ${widget.fromSymbol} = ${rate.toDouble().toStringFixedNumDecimals(5)} ${widget.toSymbol}'; } } diff --git a/lib/widgets/reusable_widgets/formatted_amount_with_tooltip.dart b/lib/widgets/reusable_widgets/formatted_amount_with_tooltip.dart index 626527a4..ea4e1142 100644 --- a/lib/widgets/reusable_widgets/formatted_amount_with_tooltip.dart +++ b/lib/widgets/reusable_widgets/formatted_amount_with_tooltip.dart @@ -3,15 +3,9 @@ import 'package:intl/intl.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; class FormattedAmountWithTooltip extends Tooltip { - final String amount; - final String tokenSymbol; - final Widget Function(String, String) builder; FormattedAmountWithTooltip({ - super.key, - required this.amount, - required this.tokenSymbol, - required this.builder, + required this.amount, required this.tokenSymbol, required this.builder, super.key, }) : super( message: '$amount $tokenSymbol', child: builder( @@ -22,6 +16,9 @@ class FormattedAmountWithTooltip extends Tooltip { : NumberFormat.compact().format(amount.toNum()).length > 8 ? '…' : NumberFormat.compact().format(amount.toNum()), - tokenSymbol), + tokenSymbol,), ); + final String amount; + final String tokenSymbol; + final Widget Function(String, String) builder; } diff --git a/lib/widgets/reusable_widgets/icons/clear_icon.dart b/lib/widgets/reusable_widgets/icons/clear_icon.dart index c4bc17c9..4ca46197 100644 --- a/lib/widgets/reusable_widgets/icons/clear_icon.dart +++ b/lib/widgets/reusable_widgets/icons/clear_icon.dart @@ -3,15 +3,13 @@ import 'package:flutter_vector_icons/flutter_vector_icons.dart'; class ClearIcon extends RawMaterialButton { ClearIcon({ - super.key, - required VoidCallback super.onPressed, - required BuildContext context, + required VoidCallback super.onPressed, required BuildContext context, super.key, }) : super( shape: const CircleBorder(), child: Icon( SimpleLineIcons.close, color: Theme.of(context).colorScheme.secondary, - size: 20.0, + size: 20, ), ); } diff --git a/lib/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart b/lib/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart index 52ba4a87..57bd0172 100644 --- a/lib/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart +++ b/lib/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart @@ -5,12 +5,6 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/clipboard_utils.dart'; class CopyToClipboardIcon extends StatefulWidget { - final String? textToBeCopied; - final Color iconColor; - final Color? hoverColor; - final MaterialTapTargetSize materialTapTargetSize; - final IconData icon; - final EdgeInsets padding; const CopyToClipboardIcon( this.textToBeCopied, { @@ -18,9 +12,15 @@ class CopyToClipboardIcon extends StatefulWidget { this.hoverColor, this.materialTapTargetSize = MaterialTapTargetSize.padded, this.icon = Icons.content_copy, - this.padding = const EdgeInsets.all(8.0), + this.padding = const EdgeInsets.all(8), super.key, }); + final String? textToBeCopied; + final Color iconColor; + final Color? hoverColor; + final MaterialTapTargetSize materialTapTargetSize; + final IconData icon; + final EdgeInsets padding; @override State createState() => _CopyToClipboardIcon(); diff --git a/lib/widgets/reusable_widgets/icons/icons.dart b/lib/widgets/reusable_widgets/icons/icons.dart index 8f4beae2..2dc39289 100644 --- a/lib/widgets/reusable_widgets/icons/icons.dart +++ b/lib/widgets/reusable_widgets/icons/icons.dart @@ -1,3 +1,3 @@ export 'copy_to_clipboard_icon.dart'; -export 'standard_tooltip_icon.dart'; export 'link_icon.dart'; +export 'standard_tooltip_icon.dart'; diff --git a/lib/widgets/reusable_widgets/icons/link_icon.dart b/lib/widgets/reusable_widgets/icons/link_icon.dart index 7c0de633..0fe7d2b7 100644 --- a/lib/widgets/reusable_widgets/icons/link_icon.dart +++ b/lib/widgets/reusable_widgets/icons/link_icon.dart @@ -5,26 +5,26 @@ import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; class LinkIcon extends RawMaterialButton { LinkIcon({ required String url, - super.key}) + super.key,}) : super( constraints: const BoxConstraints( - minWidth: 40.0, - minHeight: 40.0, + minWidth: 40, + minHeight: 40, ), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, shape: const CircleBorder(), onPressed: () => NavigationUtils.openUrl(url), child: Container( - height: 25.0, - width: 25.0, - padding: const EdgeInsets.all(4.0), + height: 25, + width: 25, + padding: const EdgeInsets.all(4), decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.white12, ), child: const Icon( SimpleLineIcons.link, - size: 10.0, + size: 10, color: AppColors.znnColor, ), ), diff --git a/lib/widgets/reusable_widgets/icons/standard_tooltip_icon.dart b/lib/widgets/reusable_widgets/icons/standard_tooltip_icon.dart index 9f39f374..24e9fef7 100644 --- a/lib/widgets/reusable_widgets/icons/standard_tooltip_icon.dart +++ b/lib/widgets/reusable_widgets/icons/standard_tooltip_icon.dart @@ -2,9 +2,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; class StandardTooltipIcon extends StatelessWidget { - final String tooltipMessage; - final Color iconColor; - final IconData iconData; const StandardTooltipIcon( this.tooltipMessage, @@ -12,14 +9,17 @@ class StandardTooltipIcon extends StatelessWidget { this.iconColor = AppColors.znnColor, super.key, }); + final String tooltipMessage; + final Color iconColor; + final IconData iconData; @override Widget build(BuildContext context) { return IconButton( hoverColor: Colors.transparent, - padding: const EdgeInsets.all(4.0), + padding: const EdgeInsets.all(4), constraints: const BoxConstraints(), - iconSize: 15.0, + iconSize: 15, icon: Icon( iconData, color: iconColor, diff --git a/lib/widgets/reusable_widgets/important_text_container.dart b/lib/widgets/reusable_widgets/important_text_container.dart index aa6d7be0..1cd91c9a 100644 --- a/lib/widgets/reusable_widgets/important_text_container.dart +++ b/lib/widgets/reusable_widgets/important_text_container.dart @@ -2,9 +2,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; class ImportantTextContainer extends StatelessWidget { - final String text; - final bool showBorder; - final bool isSelectable; const ImportantTextContainer({ required this.text, @@ -12,6 +9,9 @@ class ImportantTextContainer extends StatelessWidget { this.isSelectable = false, super.key, }); + final String text; + final bool showBorder; + final bool isSelectable; @override Widget build(BuildContext context) { @@ -20,30 +20,29 @@ class ImportantTextContainer extends StatelessWidget { color: Theme.of(context).colorScheme.primary, border: showBorder ? Border.all( - width: 1.0, color: AppColors.errorColor, ) : null, borderRadius: const BorderRadius.all( - Radius.circular(8.0), + Radius.circular(8), ), ), child: Padding( - padding: const EdgeInsets.fromLTRB(15.0, 20.0, 15.0, 20.0), + padding: const EdgeInsets.fromLTRB(15, 20, 15, 20), child: Row( children: [ const Icon( Icons.info, - size: 20.0, + size: 20, color: Colors.white, ), const SizedBox( - width: 15.0, + width: 15, ), Expanded( child: isSelectable - ? SelectableText(text, style: const TextStyle(fontSize: 14.0)) - : Text(text, style: const TextStyle(fontSize: 14.0)), + ? SelectableText(text, style: const TextStyle(fontSize: 14)) + : Text(text, style: const TextStyle(fontSize: 14)), ), ], ), diff --git a/lib/widgets/reusable_widgets/infinite_scroll_table.dart b/lib/widgets/reusable_widgets/infinite_scroll_table.dart index b4cd80f9..f8eaa416 100644 --- a/lib/widgets/reusable_widgets/infinite_scroll_table.dart +++ b/lib/widgets/reusable_widgets/infinite_scroll_table.dart @@ -12,11 +12,6 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class InfiniteScrollTable extends StatefulWidget { - final List? headerColumns; - final List Function(T, bool) generateRowCells; - final void Function(int index)? onRowTappedCallback; - final InfiniteScrollBloc bloc; - final bool disposeBloc; const InfiniteScrollTable({ required this.bloc, @@ -26,6 +21,11 @@ class InfiniteScrollTable extends StatefulWidget { this.disposeBloc = true, super.key, }); + final List? headerColumns; + final List Function(T, bool) generateRowCells; + final void Function(int index)? onRowTappedCallback; + final InfiniteScrollBloc bloc; + final bool disposeBloc; @override State createState() => _InfiniteScrollTableState(); @@ -99,19 +99,18 @@ class _InfiniteScrollTableState extends State> { border: Border( bottom: BorderSide( color: Theme.of(context).dividerTheme.color!, - width: 1.0, ), ), ), padding: const EdgeInsets.symmetric( - vertical: 15.0, + vertical: 15, ), child: Row( children: List.from( [ const SizedBox( - width: 20.0, - ) + width: 20, + ), ], ) + (widget.headerColumns ?? []), @@ -120,7 +119,7 @@ class _InfiniteScrollTableState extends State> { } Widget _getTableRow(dynamic item, int indexOfRow) { - bool isSelected = _selectedRowIndex == indexOfRow; + final isSelected = _selectedRowIndex == indexOfRow; return InkWell( onTap: () { @@ -148,20 +147,20 @@ class _InfiniteScrollTableState extends State> { left: isSelected ? const BorderSide( color: AppColors.znnColor, - width: 2.0, + width: 2, ) : BorderSide.none, ), ), padding: const EdgeInsets.symmetric( - vertical: 15.0, + vertical: 15, ), child: Row( children: List.from( [ const SizedBox( - width: 20.0, - ) + width: 20, + ), ], ) + widget.generateRowCells(item, isSelected), @@ -183,10 +182,6 @@ class _InfiniteScrollTableState extends State> { } class InfiniteScrollTableHeaderColumn extends StatelessWidget { - final String columnName; - final Function(String)? onSortArrowsPressed; - final MainAxisAlignment contentAlign; - final int flex; const InfiniteScrollTableHeaderColumn({ required this.columnName, @@ -195,6 +190,10 @@ class InfiniteScrollTableHeaderColumn extends StatelessWidget { this.flex = 1, super.key, }); + final String columnName; + final Function(String)? onSortArrowsPressed; + final MainAxisAlignment contentAlign; + final int flex; @override Widget build(BuildContext context) { @@ -215,11 +214,11 @@ class InfiniteScrollTableHeaderColumn extends StatelessWidget { onTap: () => onSortArrowsPressed!(columnName), child: Icon( Entypo.select_arrows, - size: 15.0, + size: 15, color: Theme.of(context).iconTheme.color, ), ), - ) + ), ], ), ); @@ -227,8 +226,6 @@ class InfiniteScrollTableHeaderColumn extends StatelessWidget { } class InfiniteScrollTableCell extends StatelessWidget { - final Widget child; - final int flex; const InfiniteScrollTableCell( this.child, { @@ -251,7 +248,7 @@ class InfiniteScrollTableCell extends StatelessWidget { message: address.toString(), child: Container( margin: const EdgeInsets.only( - right: 10.0, + right: 10, ), child: Marquee( child: Text( @@ -259,7 +256,7 @@ class InfiniteScrollTableCell extends StatelessWidget { style: textStyle ?? TextStyle( color: textColor, - fontSize: 12.0, + fontSize: 12, ), ), ), @@ -271,7 +268,7 @@ class InfiniteScrollTableCell extends StatelessWidget { materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, ), const SizedBox( - width: 10.0, + width: 10, ), ], ), @@ -293,7 +290,7 @@ class InfiniteScrollTableCell extends StatelessWidget { Expanded( child: Container( margin: const EdgeInsets.only( - right: 10.0, + right: 10, ), child: Marquee( child: Text( @@ -301,7 +298,7 @@ class InfiniteScrollTableCell extends StatelessWidget { style: textStyle ?? TextStyle( color: textColor, - fontSize: 12.0, + fontSize: 12, ), ), ), @@ -316,7 +313,7 @@ class InfiniteScrollTableCell extends StatelessWidget { materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, ), const SizedBox( - width: 10.0, + width: 10, ), ], ), @@ -363,7 +360,7 @@ class InfiniteScrollTableCell extends StatelessWidget { materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, ), const SizedBox( - width: 10.0, + width: 10, ), ], ), @@ -406,7 +403,7 @@ class InfiniteScrollTableCell extends StatelessWidget { materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, ), const SizedBox( - width: 10.0, + width: 10, ), ], ), @@ -416,6 +413,8 @@ class InfiniteScrollTableCell extends StatelessWidget { flex: flex, key: key, ); + final Widget child; + final int flex; @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/input_fields/amount_input_field.dart b/lib/widgets/reusable_widgets/input_fields/amount_input_field.dart index 0ec58599..04c23b8a 100644 --- a/lib/widgets/reusable_widgets/input_fields/amount_input_field.dart +++ b/lib/widgets/reusable_widgets/input_fields/amount_input_field.dart @@ -10,14 +10,6 @@ import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class AmountInputField extends StatefulWidget { - final TextEditingController controller; - final AccountInfo accountInfo; - final void Function(Token, bool)? onChanged; - final double? valuePadding; - final Color? textColor; - final Token? initialToken; - final String hintText; - final bool enabled; const AmountInputField({ required this.controller, @@ -30,6 +22,14 @@ class AmountInputField extends StatefulWidget { this.enabled = true, super.key, }); + final TextEditingController controller; + final AccountInfo accountInfo; + final void Function(Token, bool)? onChanged; + final double? valuePadding; + final Color? textColor; + final Token? initialToken; + final String hintText; + final bool enabled; @override State createState() { @@ -88,14 +88,14 @@ class _AmountInputFieldState extends State { children: [ _getCoinDropdown(), const SizedBox( - width: 5.0, + width: 5, ), AmountSuffixMaxWidget( - onPressed: () => _onMaxPressed(), + onPressed: _onMaxPressed, context: context, ), const SizedBox( - width: 5.0, + width: 5, ), ], ); @@ -106,7 +106,7 @@ class _AmountInputFieldState extends State { _selectedToken!.tokenStandard, ); widget.controller.text = - maxBalance.addDecimals(_selectedToken!.decimals).toString(); + maxBalance.addDecimals(_selectedToken!.decimals); }); Widget _getCoinDropdown() => CoinDropdown( @@ -116,7 +116,7 @@ class _AmountInputFieldState extends State { if (_selectedToken != value) { setState( () { - _selectedToken = value!; + _selectedToken = value; _isInputValid(); widget.onChanged!(_selectedToken!, _isInputValid()); }, @@ -126,7 +126,7 @@ class _AmountInputFieldState extends State { ); void _addTokensWithBalance() { - for (var balanceInfo in widget.accountInfo.balanceInfoList!) { + for (final balanceInfo in widget.accountInfo.balanceInfoList!) { if (balanceInfo.balance! > BigInt.zero && !_tokensWithBalance.contains(balanceInfo.token)) { _tokensWithBalance.add(balanceInfo.token); diff --git a/lib/widgets/reusable_widgets/input_fields/amount_suffix_widgets.dart b/lib/widgets/reusable_widgets/input_fields/amount_suffix_widgets.dart index 910efdc9..01c19c5b 100644 --- a/lib/widgets/reusable_widgets/input_fields/amount_suffix_widgets.dart +++ b/lib/widgets/reusable_widgets/input_fields/amount_suffix_widgets.dart @@ -5,14 +5,14 @@ import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class AmountSuffixWidgets extends StatelessWidget { - final Token tokenId; - final VoidCallback? onMaxPressed; const AmountSuffixWidgets( this.tokenId, { this.onMaxPressed, super.key, }); + final Token tokenId; + final VoidCallback? onMaxPressed; @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/input_fields/disabled_address_field.dart b/lib/widgets/reusable_widgets/input_fields/disabled_address_field.dart index d32d086f..a71784d0 100644 --- a/lib/widgets/reusable_widgets/input_fields/disabled_address_field.dart +++ b/lib/widgets/reusable_widgets/input_fields/disabled_address_field.dart @@ -3,14 +3,14 @@ import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class DisabledAddressField extends StatelessWidget { - final TextEditingController _addressController; - final double contentLeftPadding; const DisabledAddressField( this._addressController, { this.contentLeftPadding = 8.0, super.key, }); + final TextEditingController _addressController; + final double contentLeftPadding; @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/input_fields/input_field.dart b/lib/widgets/reusable_widgets/input_fields/input_field.dart index 04e36cae..f81c5139 100644 --- a/lib/widgets/reusable_widgets/input_fields/input_field.dart +++ b/lib/widgets/reusable_widgets/input_fields/input_field.dart @@ -4,27 +4,6 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; class InputField extends StatefulWidget { - final TextEditingController controller; - final FocusNode? thisNode; - final FocusNode? nextNode; - final String? hintText; - final bool enabled; - final List? inputFormatters; - final String? Function(String?)? validator; - final Widget? suffixIcon; - final BoxConstraints? suffixIconConstraints; - final double contentLeftPadding; - final Function(String)? onChanged; - final bool obscureText; - final String? errorText; - final int maxLines; - final Function(String)? onSubmitted; - final TextStyle inputtedTextStyle; - final InputBorder? enabledBorder; - final InputBorder? focusedBorder; - final InputBorder? disabledBorder; - final InputBorder? errorBorder; - final InputBorder? focusedErrorBorder; const InputField({ required this.controller, @@ -43,7 +22,7 @@ class InputField extends StatefulWidget { this.errorText, this.onSubmitted, this.inputtedTextStyle = const TextStyle( - fontSize: 14.0, + fontSize: 14, color: AppColors.znnColor, ), this.disabledBorder, @@ -53,6 +32,27 @@ class InputField extends StatefulWidget { this.focusedErrorBorder, super.key, }); + final TextEditingController controller; + final FocusNode? thisNode; + final FocusNode? nextNode; + final String? hintText; + final bool enabled; + final List? inputFormatters; + final String? Function(String?)? validator; + final Widget? suffixIcon; + final BoxConstraints? suffixIconConstraints; + final double contentLeftPadding; + final Function(String)? onChanged; + final bool obscureText; + final String? errorText; + final int maxLines; + final Function(String)? onSubmitted; + final TextStyle inputtedTextStyle; + final InputBorder? enabledBorder; + final InputBorder? focusedBorder; + final InputBorder? disabledBorder; + final InputBorder? errorBorder; + final InputBorder? focusedErrorBorder; @override State createState() { @@ -78,11 +78,11 @@ class _InputFieldState extends State { ), child: Text( AdaptiveTextSelectionToolbar.getButtonLabel( - context, buttonItem), - style: Theme.of(context).textTheme.bodyMedium), - )) - ]); - }).toList()); + context, buttonItem,), + style: Theme.of(context).textTheme.bodyMedium,), + ),), + ],); + }).toList(),); }, maxLines: widget.maxLines, obscureText: widget.obscureText, @@ -91,7 +91,6 @@ class _InputFieldState extends State { inputFormatters: widget.inputFormatters ?? [], enabled: widget.enabled, controller: widget.controller, - autofocus: false, focusNode: widget.thisNode, onFieldSubmitted: widget.onSubmitted, style: widget.inputtedTextStyle, diff --git a/lib/widgets/reusable_widgets/input_fields/labeled_input_container.dart b/lib/widgets/reusable_widgets/input_fields/labeled_input_container.dart index e803c2d1..535ffee0 100644 --- a/lib/widgets/reusable_widgets/input_fields/labeled_input_container.dart +++ b/lib/widgets/reusable_widgets/input_fields/labeled_input_container.dart @@ -2,9 +2,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; class LabeledInputContainer extends StatelessWidget { - final String labelText; - final Widget inputWidget; - final String? helpText; const LabeledInputContainer({ required this.labelText, @@ -12,6 +9,9 @@ class LabeledInputContainer extends StatelessWidget { this.helpText, super.key, }); + final String labelText; + final Widget inputWidget; + final String? helpText; @override Widget build(BuildContext context) { @@ -20,34 +20,33 @@ class LabeledInputContainer extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Row( - crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( labelText, style: const TextStyle( - fontSize: 14.0, + fontSize: 14, color: AppColors.darkHintTextColor, ), ), - const SizedBox(width: 3.0), + const SizedBox(width: 3), Visibility( visible: helpText != null, child: Tooltip( message: helpText ?? '', child: const Padding( - padding: EdgeInsets.only(top: 3.0), + padding: EdgeInsets.only(top: 3), child: Icon( Icons.help, color: AppColors.darkHintTextColor, - size: 12.0, + size: 12, ), ), ), ), ], ), - const SizedBox(height: 3.0), - inputWidget + const SizedBox(height: 3), + inputWidget, ], ); } diff --git a/lib/widgets/reusable_widgets/input_fields/password_input_field.dart b/lib/widgets/reusable_widgets/input_fields/password_input_field.dart index 380ad9f4..0d44ee9a 100644 --- a/lib/widgets/reusable_widgets/input_fields/password_input_field.dart +++ b/lib/widgets/reusable_widgets/input_fields/password_input_field.dart @@ -4,12 +4,6 @@ import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class PasswordInputField extends StatefulWidget { - final TextEditingController controller; - final String hintText; - final void Function(String)? onSubmitted; - final void Function(String)? onChanged; - final String? Function(String?)? validator; - final String? errorText; const PasswordInputField({ required this.controller, @@ -20,6 +14,12 @@ class PasswordInputField extends StatefulWidget { this.errorText, super.key, }); + final TextEditingController controller; + final String hintText; + final void Function(String)? onSubmitted; + final void Function(String)? onChanged; + final String? Function(String?)? validator; + final String? errorText; @override State createState() => _PasswordInputFieldState(); @@ -44,8 +44,8 @@ class _PasswordInputFieldState extends State { }); }, child: SizedBox( - height: 10.0, - width: 10.0, + height: 10, + width: 10, child: Icon( _obscureText ? Icons.visibility_off_outlined diff --git a/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart b/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart index 76ba0a2c..4de21b14 100644 --- a/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart +++ b/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart @@ -13,15 +13,6 @@ import 'package:zenon_syrius_wallet_flutter/utils/widget_utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class CardScaffold extends StatefulWidget { - final String? title; - final String description; - final Widget Function()? childBuilder; - final Stream? childStream; - final VoidCallback? onRefreshPressed; - final Widget Function(T)? onCompletedStatusCallback; - final double? titleFontSize; - final Widget? titleIcon; - final Widget? customItem; const CardScaffold({ required this.title, @@ -35,6 +26,15 @@ class CardScaffold extends StatefulWidget { this.customItem, super.key, }); + final String? title; + final String description; + final Widget Function()? childBuilder; + final Stream? childStream; + final VoidCallback? onRefreshPressed; + final Widget Function(T)? onCompletedStatusCallback; + final double? titleFontSize; + final Widget? titleIcon; + final Widget? customItem; @override State> createState() => _CardScaffoldState(); @@ -62,14 +62,12 @@ class _CardScaffoldState extends State> { @override Widget build(BuildContext context) { return FlipCard( - direction: FlipDirection.HORIZONTAL, - speed: 500, flipOnTouch: false, key: cardKey, onFlipDone: (status) {}, front: ClipRRect( borderRadius: BorderRadius.circular( - 15.0, + 15, ), child: Container( color: Theme.of(context).colorScheme.primary, @@ -83,14 +81,14 @@ class _CardScaffoldState extends State> { color: Theme.of(context).colorScheme.primary, child: _getWidgetFrontBody(), ), - ) + ), ], ), ), ), back: ClipRRect( borderRadius: BorderRadius.circular( - 15.0, + 15, ), child: Material( child: Container( @@ -112,7 +110,7 @@ class _CardScaffoldState extends State> { Widget _getBackBody(HideWidgetStatusBloc model) { return Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: ListView( shrinkWrap: true, children: [ @@ -128,10 +126,10 @@ class _CardScaffoldState extends State> { const Icon( Icons.info, color: AppColors.znnColor, - size: 20.0, + size: 20, ), const SizedBox( - width: 5.0, + width: 5, ), Expanded( child: Text( @@ -143,9 +141,9 @@ class _CardScaffoldState extends State> { ), expanded: Padding( padding: const EdgeInsets.only( - left: 14.0, - top: 5.0, - bottom: 5.0, + left: 14, + top: 5, + bottom: 5, ), child: Text( widget.description, @@ -154,15 +152,14 @@ class _CardScaffoldState extends State> { ), ), Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ const Icon( Icons.remove_red_eye_rounded, color: AppColors.znnColor, - size: 20.0, + size: 20, ), const SizedBox( - width: 5.0, + width: 5, ), Expanded( child: Text( @@ -172,7 +169,7 @@ class _CardScaffoldState extends State> { ), const Spacer(), Switch( - splashRadius: 0.0, + splashRadius: 0, value: _hideWidgetInfo!, onChanged: (value) { setState(() { @@ -196,7 +193,7 @@ class _CardScaffoldState extends State> { }); } }, - ) + ), ], ), Visibility( @@ -208,13 +205,13 @@ class _CardScaffoldState extends State> { child: _getPasswordInputField(model), ), const SizedBox( - width: 10.0, + width: 10, ), _actionButton!, ], ), ), - if (widget.customItem != null) widget.customItem! + if (widget.customItem != null) widget.customItem!, ], ), ); @@ -226,7 +223,7 @@ class _CardScaffoldState extends State> { children: [ Expanded( child: Padding( - padding: const EdgeInsets.all(14.0), + padding: const EdgeInsets.all(14), child: Row( children: [ Expanded( @@ -234,14 +231,14 @@ class _CardScaffoldState extends State> { title, style: Theme.of(context).textTheme.bodyLarge!.copyWith( fontSize: widget.titleFontSize, - height: 1.0, + height: 1, ), ), ), const SizedBox( - width: 5.0, + width: 5, ), - widget.titleIcon != null ? widget.titleIcon! : Container(), + if (widget.titleIcon != null) widget.titleIcon! else Container(), ], ), ), @@ -256,9 +253,9 @@ class _CardScaffoldState extends State> { shadowColor: Colors.transparent, color: Colors.transparent, child: IconButton( - splashRadius: 15.0, + splashRadius: 15, icon: const Icon(Icons.refresh), - iconSize: 18.0, + iconSize: 18, color: Theme.of(context).colorScheme.secondary, onPressed: widget.onRefreshPressed, ), @@ -268,9 +265,9 @@ class _CardScaffoldState extends State> { shadowColor: Colors.transparent, color: Colors.transparent, child: IconButton( - splashRadius: 15.0, + splashRadius: 15, icon: const Icon(Icons.more_horiz), - iconSize: 18.0, + iconSize: 18, color: Theme.of(context).textTheme.bodyLarge!.color, onPressed: () { cardKey.currentState!.toggleCard(); @@ -301,7 +298,7 @@ class _CardScaffoldState extends State> { icon: const Icon( AntDesign.arrowright, color: AppColors.znnColor, - size: 25.0, + size: 25, ), ); } @@ -341,14 +338,14 @@ class _CardScaffoldState extends State> { } return const Center( child: SyriusLoadingWidget( - size: 25.0, + size: 25, ), ); } return _getBackBody(model); }, ), - viewModelBuilder: () => HideWidgetStatusBloc(), + viewModelBuilder: HideWidgetStatusBloc.new, ); } @@ -357,7 +354,7 @@ class _CardScaffoldState extends State> { ? _getHiddenInfoWidget() : widget.childStream != null && widget.onCompletedStatusCallback != null ? StreamBuilder( - stream: widget.childStream as Stream, + stream: widget.childStream, builder: (context, snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); @@ -382,7 +379,7 @@ class _CardScaffoldState extends State> { ); } - void _onActionButtonPressed(HideWidgetStatusBloc model) async { + Future _onActionButtonPressed(HideWidgetStatusBloc model) async { if (_passwordController.text.isNotEmpty && _actionButtonKey.currentState!.btnState == ButtonState.idle) { try { diff --git a/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart b/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart index ae3be738..8314325c 100644 --- a/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart +++ b/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart @@ -6,13 +6,10 @@ import 'package:lottie/lottie.dart'; import 'package:stacked/stacked.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class CardScaffoldWithoutListener extends StatefulWidget { - final Widget body; - final CardType type; - final VoidCallback? onRefreshPressed; const CardScaffoldWithoutListener({ required this.body, @@ -20,6 +17,9 @@ class CardScaffoldWithoutListener extends StatefulWidget { this.onRefreshPressed, super.key, }); + final Widget body; + final CardType type; + final VoidCallback? onRefreshPressed; @override State createState() => _CardScaffoldWithoutListenerState(); @@ -50,14 +50,12 @@ class _CardScaffoldWithoutListenerState extends State[ Expanded( child: Padding( - padding: const EdgeInsets.all(14.0), + padding: const EdgeInsets.all(14), child: Row( children: [ Expanded( @@ -223,7 +220,7 @@ class _CardScaffoldWithoutListenerState extends State HideWidgetStatusBloc(), + viewModelBuilder: HideWidgetStatusBloc.new, ); } @@ -352,7 +349,7 @@ class _CardScaffoldWithoutListenerState extends State _onActionButtonPressed(HideWidgetStatusBloc model) async { if (_passwordController.text.isNotEmpty && _actionButtonKey.currentState!.btnState == ButtonState.idle) { try { diff --git a/lib/widgets/reusable_widgets/layout_scaffold/overscroll_remover.dart b/lib/widgets/reusable_widgets/layout_scaffold/overscroll_remover.dart index 5b8ee4e7..fb381fd1 100644 --- a/lib/widgets/reusable_widgets/layout_scaffold/overscroll_remover.dart +++ b/lib/widgets/reusable_widgets/layout_scaffold/overscroll_remover.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; class RemoveOverscrollEffect extends ScrollBehavior { @override Widget buildOverscrollIndicator( - BuildContext context, Widget child, ScrollableDetails details) { + BuildContext context, Widget child, ScrollableDetails details,) { return child; } } diff --git a/lib/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart b/lib/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart index d2992199..efbf764f 100644 --- a/lib/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart +++ b/lib/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart @@ -6,9 +6,6 @@ import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaf const int kStaggeredNumOfColumns = 12; class StandardFluidLayout extends StatelessWidget { - final List children; - final int? defaultCellWidth; - final double? defaultCellHeight; const StandardFluidLayout({ required this.children, @@ -16,6 +13,9 @@ class StandardFluidLayout extends StatelessWidget { this.defaultCellHeight = kStaggeredNumOfColumns / 4, super.key, }); + final List children; + final int? defaultCellWidth; + final double? defaultCellHeight; @override Widget build(BuildContext context) { @@ -23,19 +23,19 @@ class StandardFluidLayout extends StatelessWidget { format: FluidLayoutFormat(), child: Builder( builder: (context) { - const int crossAxisCount = kStaggeredNumOfColumns; + const crossAxisCount = kStaggeredNumOfColumns; - final double spacing = + final spacing = context.breakpoint < LayoutBreakpoint.sm ? 4.0 : 12.0; - final double totalDurationMs = children.length > 5 ? 800 : 400; + final totalDurationMs = children.length > 5 ? 800 : 400; - final int durationPerTile = totalDurationMs ~/ children.length; + final durationPerTile = totalDurationMs ~/ children.length; - final List tiles = List.generate( + final tiles = List.generate( children.length, (index) { - final int widgetAnimatorOffset = durationPerTile * (index + 1); + final widgetAnimatorOffset = durationPerTile * (index + 1); return _generateStaggeredTitle( children[index], @@ -65,7 +65,6 @@ class StandardFluidLayout extends StatelessWidget { crossAxisCellCount: fluidCell.width ?? defaultCellWidth!, mainAxisCellCount: fluidCell.height ?? defaultCellHeight!, child: WidgetAnimator( - curve: Curves.linear, animationOffset: Duration( milliseconds: widgetAnimatorOffset, ), @@ -76,13 +75,13 @@ class StandardFluidLayout extends StatelessWidget { } class FluidCell { - final int? width; - final double? height; - final Widget child; const FluidCell({ required this.child, this.width, this.height, }); + final int? width; + final double? height; + final Widget child; } diff --git a/lib/widgets/reusable_widgets/layout_scaffold/widget_animator.dart b/lib/widgets/reusable_widgets/layout_scaffold/widget_animator.dart index dc37c4a3..4fa9493a 100644 --- a/lib/widgets/reusable_widgets/layout_scaffold/widget_animator.dart +++ b/lib/widgets/reusable_widgets/layout_scaffold/widget_animator.dart @@ -3,10 +3,6 @@ import 'dart:async'; import 'package:flutter/material.dart'; class WidgetAnimator extends StatefulWidget { - final Widget? child; - final Duration duration; - final Curve curve; - final Duration animationOffset; const WidgetAnimator({ required this.child, @@ -15,6 +11,10 @@ class WidgetAnimator extends StatefulWidget { this.curve = Curves.linear, super.key, }); + final Widget? child; + final Duration duration; + final Curve curve; + final Duration animationOffset; @override State createState() => _WidgetAnimatorState(); @@ -60,7 +60,7 @@ class _WidgetAnimatorState extends State opacity: _animation!.value, child: Transform.translate( offset: Offset( - 0.0, + 0, (1.0 - _animation!.value) * 20.0, ), child: child, diff --git a/lib/widgets/reusable_widgets/loading_info_text.dart b/lib/widgets/reusable_widgets/loading_info_text.dart index 1a6e7147..8aa6e950 100644 --- a/lib/widgets/reusable_widgets/loading_info_text.dart +++ b/lib/widgets/reusable_widgets/loading_info_text.dart @@ -3,14 +3,14 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; class LoadingInfoText extends StatelessWidget { - final String text; - final String? tooltipText; const LoadingInfoText({ required this.text, this.tooltipText, super.key, }); + final String text; + final String? tooltipText; @override Widget build(BuildContext context) { @@ -18,21 +18,21 @@ class LoadingInfoText extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ const SyriusLoadingWidget( - size: 16.0, - strokeWidth: 2.0, + size: 16, + strokeWidth: 2, ), const SizedBox( - width: 10.0, + width: 10, ), Text( text, style: - const TextStyle(fontSize: 14.0, color: AppColors.subtitleColor), + const TextStyle(fontSize: 14, color: AppColors.subtitleColor), ), Visibility( visible: tooltipText != null, child: const SizedBox( - width: 5.0, + width: 5, ), ), Visibility( @@ -40,11 +40,11 @@ class LoadingInfoText extends StatelessWidget { child: Tooltip( message: tooltipText ?? '', child: const Padding( - padding: EdgeInsets.only(top: 1.0), + padding: EdgeInsets.only(top: 1), child: Icon( Icons.help, color: AppColors.subtitleColor, - size: 14.0, + size: 14, ), ), ), diff --git a/lib/widgets/reusable_widgets/loading_widget.dart b/lib/widgets/reusable_widgets/loading_widget.dart index 05241a56..a7f94bb9 100644 --- a/lib/widgets/reusable_widgets/loading_widget.dart +++ b/lib/widgets/reusable_widgets/loading_widget.dart @@ -2,9 +2,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; class SyriusLoadingWidget extends StatelessWidget { - final double size; - final double strokeWidth; - final double padding; const SyriusLoadingWidget({ this.size = 50.0, @@ -12,6 +9,9 @@ class SyriusLoadingWidget extends StatelessWidget { this.padding = 4.0, super.key, }); + final double size; + final double strokeWidth; + final double padding; @override Widget build(BuildContext context) { diff --git a/lib/widgets/reusable_widgets/modals/base_modal.dart b/lib/widgets/reusable_widgets/modals/base_modal.dart index 74721b84..ac0fee9a 100644 --- a/lib/widgets/reusable_widgets/modals/base_modal.dart +++ b/lib/widgets/reusable_widgets/modals/base_modal.dart @@ -2,16 +2,14 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; class BaseModal extends StatelessWidget { - final String title; - final String subtitle; - final Widget child; const BaseModal({ - super.key, - required this.title, - required this.child, + required this.title, required this.child, super.key, this.subtitle = '', }); + final String title; + final String subtitle; + final Widget child; @override Widget build(BuildContext context) { @@ -25,10 +23,10 @@ class BaseModal extends StatelessWidget { duration: const Duration(milliseconds: 100), curve: Curves.easeInOut, child: Container( - width: 570.0, + width: 570, color: Theme.of(context).colorScheme.primaryContainer, child: Padding( - padding: const EdgeInsets.all(25.0), + padding: const EdgeInsets.all(25), child: Column( mainAxisSize: MainAxisSize.min, children: [ @@ -40,13 +38,13 @@ class BaseModal extends StatelessWidget { Text( title, style: const TextStyle( - fontSize: 18.0, + fontSize: 18, ), ), Visibility( visible: subtitle.isNotEmpty, child: const SizedBox( - height: 3.0, + height: 3, ), ), Visibility( @@ -62,13 +60,13 @@ class BaseModal extends StatelessWidget { child: const Icon( Icons.clear, color: AppColors.lightSecondary, - size: 22.0, + size: 22, ), ), ), ], ), - child + child, ], ), ), diff --git a/lib/widgets/reusable_widgets/notification_widget.dart b/lib/widgets/reusable_widgets/notification_widget.dart index b331c6b0..24b3f1df 100644 --- a/lib/widgets/reusable_widgets/notification_widget.dart +++ b/lib/widgets/reusable_widgets/notification_widget.dart @@ -6,10 +6,6 @@ import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class NotificationWidget extends StatefulWidget { - final VoidCallback? onSeeMorePressed; - final VoidCallback? onDismissPressed; - final VoidCallback? onNewNotificationCallback; - final bool popBeforeSeeMoreIsPressed; const NotificationWidget({ this.onSeeMorePressed, @@ -18,6 +14,10 @@ class NotificationWidget extends StatefulWidget { this.popBeforeSeeMoreIsPressed = true, super.key, }); + final VoidCallback? onSeeMorePressed; + final VoidCallback? onDismissPressed; + final VoidCallback? onNewNotificationCallback; + final bool popBeforeSeeMoreIsPressed; @override State createState() => _NotificationWidgetState(); @@ -37,19 +37,18 @@ class _NotificationWidgetState extends State { return _shouldShowNotification() ? Padding( padding: const EdgeInsets.only( - bottom: 15.0, + bottom: 15, ), child: WidgetAnimator( - curve: Curves.linear, child: Container( decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(10), color: Theme.of(context).colorScheme.primary, ), child: Padding( padding: const EdgeInsets.symmetric( - vertical: 15.0, - horizontal: 50.0, + vertical: 15, + horizontal: 50, ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -88,7 +87,7 @@ class _NotificationWidgetState extends State { children: [ notification.getIcon(), const SizedBox( - width: 15.0, + width: 15, ), Text( notification.title!, @@ -107,7 +106,7 @@ class _NotificationWidgetState extends State { materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, constraints: const BoxConstraints.tightFor(), padding: const EdgeInsets.all( - 4.0, + 4, ), onPressed: _navigateToNotification, child: Text( @@ -119,13 +118,13 @@ class _NotificationWidgetState extends State { ), ), const SizedBox( - width: 15.0, + width: 15, ), RawMaterialButton( materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, constraints: const BoxConstraints.tightFor(), padding: const EdgeInsets.all( - 4.0, + 4, ), onPressed: _dismissNotification, child: Text( diff --git a/lib/widgets/reusable_widgets/number_animation.dart b/lib/widgets/reusable_widgets/number_animation.dart index 56faaf46..dbc3a4f3 100644 --- a/lib/widgets/reusable_widgets/number_animation.dart +++ b/lib/widgets/reusable_widgets/number_animation.dart @@ -1,6 +1,31 @@ import 'package:flutter/material.dart'; class NumberAnimation extends StatefulWidget { + + /// constructor + NumberAnimation({ + super.key, + this.start = 0.0, + this.end, + this.isInt = false, + this.style, + this.textAlign, + this.strutStyle, + this.duration = const Duration(milliseconds: 1000), + this.decimalPoint = 2, + this.before = '', + this.after = '', + this.isLoading = false, + this.loadingPlaceHolder = '', + }) { + if (isLoading == false) { + assert(end != null); + if (isInt) { + assert(start.toInt() == start); + assert(end!.toInt() == end); + } + } + } /// start number final num start; @@ -37,31 +62,6 @@ class NumberAnimation extends StatefulWidget { /// loading placeholder final String loadingPlaceHolder; - /// constructor - NumberAnimation({ - super.key, - this.start = 0.0, - this.end, - this.isInt = false, - this.style, - this.textAlign, - this.strutStyle, - this.duration = const Duration(milliseconds: 1000), - this.decimalPoint = 2, - this.before = '', - this.after = '', - this.isLoading = false, - this.loadingPlaceHolder = '', - }) { - if (isLoading == false) { - assert(end != null); - if (isInt) { - assert(start.toInt() == start); - assert(end!.toInt() == end); - } - } - } - /// create state @override State createState() => _NumberAnimationState(); @@ -82,8 +82,8 @@ class _NumberAnimationState extends State controller = AnimationController(duration: widget.duration, vsync: this); _curve = CurvedAnimation(parent: controller!, curve: Curves.easeOut); if (widget.isLoading == false) { - Animation animation = Tween( - begin: widget.start.toDouble(), end: widget.end!.toDouble()) + final animation = Tween( + begin: widget.start.toDouble(), end: widget.end!.toDouble(),) .animate(_curve as Animation); _animation = animation; controller!.forward(); @@ -107,11 +107,11 @@ class _NumberAnimationState extends State if (oldWidget.end == widget.end && _hasShowNumber == true) { return; } - Animation animation = Tween( + final animation = Tween( begin: _animation != null ? _animation!.value : widget.start.toDouble(), - end: widget.end!.toDouble()) + end: widget.end!.toDouble(),) .animate(_curve as Animation); _animation = animation; controller! @@ -124,9 +124,9 @@ class _NumberAnimationState extends State /// build @override Widget build(BuildContext context) { - TextStyle? style = widget.style; - TextAlign? textAlign = widget.textAlign; - StrutStyle? strutStyle = widget.strutStyle; + final style = widget.style; + final textAlign = widget.textAlign; + final strutStyle = widget.strutStyle; if (widget.isLoading == true) { return Text( widget.loadingPlaceHolder, @@ -148,7 +148,7 @@ class _NumberAnimationState extends State } if (widget.isInt) { return Text( - '${widget.before}${_animation!.value.toInt().toString()}${widget.after}', + '${widget.before}${_animation!.value.toInt()}${widget.after}', style: style, textAlign: textAlign, strutStyle: strutStyle, diff --git a/lib/widgets/reusable_widgets/plasma_icon.dart b/lib/widgets/reusable_widgets/plasma_icon.dart index fb57bfe6..86a69dbd 100644 --- a/lib/widgets/reusable_widgets/plasma_icon.dart +++ b/lib/widgets/reusable_widgets/plasma_icon.dart @@ -4,24 +4,24 @@ import 'package:zenon_syrius_wallet_flutter/utils/widget_utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PlasmaIcon extends StatelessWidget { - final PlasmaInfo? plasmaInfo; const PlasmaIcon( this.plasmaInfo, { super.key, }); + final PlasmaInfo? plasmaInfo; @override Widget build(BuildContext context) { return Tooltip( message: WidgetUtils.getPlasmaToolTipMessage(plasmaInfo!), child: Container( - height: 20.0, - width: 20.0, + height: 20, + width: 20, decoration: BoxDecoration( shape: BoxShape.circle, border: Border.all( - width: 3.0, + width: 3, color: ColorUtils.getPlasmaColor(plasmaInfo!), ), ), diff --git a/lib/widgets/reusable_widgets/progress_bars.dart b/lib/widgets/reusable_widgets/progress_bars.dart index 9740d3dd..9ffb6d93 100644 --- a/lib/widgets/reusable_widgets/progress_bars.dart +++ b/lib/widgets/reusable_widgets/progress_bars.dart @@ -5,14 +5,14 @@ import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; class PasswordProgressBar extends StatefulWidget { - final String password; - final GlobalKey passwordKey; const PasswordProgressBar({ required this.password, required this.passwordKey, super.key, }); + final String password; + final GlobalKey passwordKey; @override State createState() => _PasswordProgressBarState(); @@ -33,7 +33,7 @@ class _PasswordProgressBarState extends State { width: kPasswordInputFieldWidth, child: Padding( padding: const EdgeInsets.symmetric( - horizontal: 5.0, + horizontal: 5, ), child: Row( mainAxisAlignment: MainAxisAlignment.center, @@ -56,7 +56,7 @@ class _PasswordProgressBarState extends State { Expanded _getPasswordProgressBar(Color color) { return Expanded( child: Container( - height: 5.0, + height: 5, color: color, ), ); @@ -64,7 +64,7 @@ class _PasswordProgressBarState extends State { SizedBox _getSpacer() { return const SizedBox( - width: 10.0, + width: 10, ); } @@ -93,20 +93,19 @@ class _PasswordProgressBarState extends State { } class ProgressBar extends StatelessWidget { - final int currentLevel; - final int numLevels; const ProgressBar({ required this.currentLevel, this.numLevels = 5, super.key, }); + final int currentLevel; + final int numLevels; @override Widget build(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, children: _getProgressBars().zip(_getSpacers()), ); } @@ -123,8 +122,8 @@ class ProgressBar extends StatelessWidget { Container _getProgressBar(int level) { return Container( - width: 125.0, - height: 5.0, + width: 125, + height: 5, color: currentLevel >= level ? AppColors.znnColor : AppColors.accessWalletContainersGray, @@ -133,15 +132,12 @@ class ProgressBar extends StatelessWidget { SizedBox _getSpacer() { return const SizedBox( - width: 25.0, + width: 25, ); } } class AcceleratorProgressBarSpan extends StatelessWidget { - final double value; - final Color color; - final String tooltipMessage; const AcceleratorProgressBarSpan({ required this.value, @@ -149,6 +145,9 @@ class AcceleratorProgressBarSpan extends StatelessWidget { required this.tooltipMessage, super.key, }); + final double value; + final Color color; + final String tooltipMessage; @override Widget build(BuildContext context) { @@ -166,16 +165,16 @@ class AcceleratorProgressBarSpan extends StatelessWidget { } class AcceleratorProgressBar extends StatelessWidget { - final Widget child; - final BuildContext context; const AcceleratorProgressBar( - {required this.child, required this.context, super.key}); + {required this.child, required this.context, super.key,}); + final Widget child; + final BuildContext context; @override Widget build(BuildContext context) { return ClipRRect( - borderRadius: BorderRadius.circular(20.0), + borderRadius: BorderRadius.circular(20), child: Container( width: kAcceleratorProgressBarSize.width, height: kAcceleratorProgressBarSize.height, diff --git a/lib/widgets/reusable_widgets/receive_qr_image.dart b/lib/widgets/reusable_widgets/receive_qr_image.dart index 76e07759..140bb78b 100644 --- a/lib/widgets/reusable_widgets/receive_qr_image.dart +++ b/lib/widgets/reusable_widgets/receive_qr_image.dart @@ -1,6 +1,5 @@ import 'dart:io'; import 'dart:typed_data'; -import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; @@ -15,6 +14,14 @@ import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/context_men import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ReceiveQrImage extends StatelessWidget { + + const ReceiveQrImage({ + required this.data, + required this.size, + required this.tokenStandard, + required this.context, + super.key, + }); final String data; final int size; final TokenStandard tokenStandard; @@ -24,28 +31,19 @@ class ReceiveQrImage extends StatelessWidget { scale: 0.3, padding: EdgeInsets.only(top: 10, bottom: 10), image: AssetImage('assets/images/qr_code_child_image_znn.png'), - position: PrettyQrDecorationImagePosition.embedded, ); - const ReceiveQrImage({ - required this.data, - required this.size, - required this.tokenStandard, - required this.context, - super.key, - }); - @override Widget build(BuildContext context) { return ClipRRect( borderRadius: BorderRadius.circular( - 15.0, + 15, ), child: Container( height: size + 20, width: size + 20, padding: const EdgeInsets.all( - 10.0, + 10, ), color: Theme.of(context).colorScheme.surface, child: ContextMenuRegion( @@ -77,8 +75,8 @@ class ReceiveQrImage extends StatelessWidget { AdaptiveTextSelectionToolbar.getButtonLabel( context, ContextMenuButtonItem( - label: 'Share QR', onPressed: () {})), - style: Theme.of(context).textTheme.bodyMedium), + label: 'Share QR', onPressed: () {},),), + style: Theme.of(context).textTheme.bodyMedium,), ), ), ), @@ -88,7 +86,6 @@ class ReceiveQrImage extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.end, children: [ Expanded( - flex: 1, child: Directionality( textDirection: TextDirection.rtl, child: TextButton.icon( @@ -108,8 +105,8 @@ class ReceiveQrImage extends StatelessWidget { AdaptiveTextSelectionToolbar.getButtonLabel( context, ContextMenuButtonItem( - label: 'Save QR', onPressed: () {})), - style: Theme.of(context).textTheme.bodyMedium), + label: 'Save QR', onPressed: () {},),), + style: Theme.of(context).textTheme.bodyMedium,), ), ), ), @@ -125,18 +122,18 @@ class ReceiveQrImage extends StatelessWidget { roundFactor: 0, color: ColorUtils.getTokenColor(tokenStandard), ), - image: decorationImage), + image: decorationImage,), errorCorrectLevel: QrErrorCorrectLevel.M, errorBuilder: (context, error, stack) => Center( child: Padding( - padding: const EdgeInsets.all(5.0), + padding: const EdgeInsets.all(5), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Lottie.asset( 'assets/lottie/ic_anim_no_data.json', - width: 32.0, - height: 32.0, + width: 32, + height: 32, ), Tooltip( message: error.toString(), @@ -144,11 +141,11 @@ class ReceiveQrImage extends StatelessWidget { 'Failed to create QR code', textAlign: TextAlign.center, style: Theme.of(context).textTheme.bodyMedium, - )), + ),), ], ), ), - ))), + ),),), ), ); } @@ -157,40 +154,39 @@ class ReceiveQrImage extends StatelessWidget { final qr = QrImage(QrCode.fromData( data: data, errorCorrectLevel: QrErrorCorrectLevel.M, - )); + ),); final b = await qr.toImageAsBytes( size: size, - format: ImageByteFormat.png, decoration: PrettyQrDecoration( shape: PrettyQrSmoothSymbol( roundFactor: 0, color: ColorUtils.getTokenColor(tokenStandard), ), - image: decorationImage)); + image: decorationImage,),); if (b != null) return b.buffer.asUint8List(); return null; } - void _saveQR() async { + Future _saveQR() async { final imageData = await _getQRImageData(); if (imageData != null) { - String fileName = DateTime.now().millisecondsSinceEpoch.toString(); + final fileName = DateTime.now().millisecondsSinceEpoch.toString(); final imagePath = await File( - '${znnDefaultPaths.cache.path}${path.separator}$fileName.png') + '${znnDefaultPaths.cache.path}${path.separator}$fileName.png',) .create(); await imagePath.writeAsBytes(imageData); await OpenFilex.open(imagePath.path); } } - void _shareQR() async { + Future _shareQR() async { final imageData = await _getQRImageData(); if (imageData != null) { - String fileName = DateTime.now().millisecondsSinceEpoch.toString(); + final fileName = DateTime.now().millisecondsSinceEpoch.toString(); final imagePath = await File( - '${znnDefaultPaths.cache.path}${path.separator}$fileName.png') + '${znnDefaultPaths.cache.path}${path.separator}$fileName.png',) .create(); await imagePath.writeAsBytes(imageData); await Share.shareXFiles([XFile(imagePath.path)]); diff --git a/lib/widgets/reusable_widgets/reusable_widgets.dart b/lib/widgets/reusable_widgets/reusable_widgets.dart index 85559c6b..30b39aa0 100644 --- a/lib/widgets/reusable_widgets/reusable_widgets.dart +++ b/lib/widgets/reusable_widgets/reusable_widgets.dart @@ -1,23 +1,23 @@ -export 'buttons/buttons.dart'; -export 'chart/chart.dart'; -export 'dropdown/dropdown.dart'; -export 'icons/icons.dart'; -export 'input_fields/input_fields.dart'; -export 'layout_scaffold/layout_scaffold.dart'; export 'accelerator_project_details.dart'; export 'access_wallet_fluid_cell.dart'; export 'amount_info_column.dart'; export 'available_balance.dart'; +export 'buttons/buttons.dart'; export 'cancel_timer.dart'; +export 'chart/chart.dart'; export 'custom_expandable_panel.dart'; export 'custom_material_stepper.dart'; export 'custom_slider.dart'; export 'custom_table.dart'; export 'dialogs.dart'; export 'dotted_border_info_widget.dart'; +export 'dropdown/dropdown.dart'; export 'error_widget.dart'; export 'formatted_amount_with_tooltip.dart'; +export 'icons/icons.dart'; export 'infinite_scroll_table.dart'; +export 'input_fields/input_fields.dart'; +export 'layout_scaffold/layout_scaffold.dart'; export 'loading_widget.dart'; export 'modals/base_modal.dart'; export 'notification_widget.dart'; @@ -31,6 +31,6 @@ export 'select_file_widget.dart'; export 'settings_address.dart'; export 'settings_node.dart'; export 'stepper_utils.dart'; +export 'syrius_checkbox.dart'; export 'tag_widget.dart'; export 'transfer_icon_legend.dart'; -export 'syrius_checkbox.dart'; diff --git a/lib/widgets/reusable_widgets/seed/seed_choice.dart b/lib/widgets/reusable_widgets/seed/seed_choice.dart index 964fdcc4..697ad55b 100644 --- a/lib/widgets/reusable_widgets/seed/seed_choice.dart +++ b/lib/widgets/reusable_widgets/seed/seed_choice.dart @@ -3,9 +3,6 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; class SeedChoice extends StatefulWidget { - final VoidCallback onSeed24Selected; - final VoidCallback onSeed12Selected; - final bool isSeed12Selected; const SeedChoice({ required this.onSeed24Selected, @@ -13,6 +10,9 @@ class SeedChoice extends StatefulWidget { required this.isSeed12Selected, super.key, }); + final VoidCallback onSeed24Selected; + final VoidCallback onSeed12Selected; + final bool isSeed12Selected; @override State createState() => _SeedChoiceState(); @@ -26,12 +26,12 @@ class _SeedChoiceState extends State { Widget build(BuildContext context) { return Container( padding: const EdgeInsets.symmetric( - vertical: 8.0, - horizontal: 20.0, + vertical: 8, + horizontal: 20, ), decoration: BoxDecoration( color: Theme.of(context).colorScheme.secondaryContainer, - borderRadius: BorderRadius.circular(30.0), + borderRadius: BorderRadius.circular(30), ), child: Row( mainAxisSize: MainAxisSize.min, @@ -57,17 +57,17 @@ class _SeedChoiceState extends State { }, child: Container( padding: const EdgeInsets.symmetric( - vertical: 5.0, - horizontal: 15.0, + vertical: 5, + horizontal: 15, ), margin: const EdgeInsets.symmetric( - horizontal: 5.0, + horizontal: 5, ), decoration: BoxDecoration( color: widget.isSeed12Selected ? Colors.transparent : AppColors.znnColor, - borderRadius: BorderRadius.circular(30.0), + borderRadius: BorderRadius.circular(30), ), child: SvgPicture.asset( 'assets/svg/ic_seed_24.svg', @@ -75,7 +75,7 @@ class _SeedChoiceState extends State { widget.isSeed12Selected ? _seed24Color : AppColors.selectedSeedChoiceColor, - BlendMode.srcIn), + BlendMode.srcIn,), ), ), ), @@ -101,17 +101,17 @@ class _SeedChoiceState extends State { }, child: Container( padding: const EdgeInsets.symmetric( - vertical: 5.0, - horizontal: 15.0, + vertical: 5, + horizontal: 15, ), margin: const EdgeInsets.symmetric( - horizontal: 5.0, + horizontal: 5, ), decoration: BoxDecoration( color: widget.isSeed12Selected ? AppColors.znnColor : Colors.transparent, - borderRadius: BorderRadius.circular(30.0), + borderRadius: BorderRadius.circular(30), ), child: SvgPicture.asset( 'assets/svg/ic_seed_12.svg', @@ -119,7 +119,7 @@ class _SeedChoiceState extends State { widget.isSeed12Selected ? AppColors.selectedSeedChoiceColor : _seed12Color, - BlendMode.srcIn), + BlendMode.srcIn,), ), ), ), diff --git a/lib/widgets/reusable_widgets/seed/seed_grid.dart b/lib/widgets/reusable_widgets/seed/seed_grid.dart index 594a2ac4..689d7bc5 100644 --- a/lib/widgets/reusable_widgets/seed/seed_grid.dart +++ b/lib/widgets/reusable_widgets/seed/seed_grid.dart @@ -6,10 +6,6 @@ import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart' show Mnemonic; class SeedGrid extends StatefulWidget { - final List seedWords; - final bool isContinueButtonDisabled; - final bool enableSeedInputFields; - final VoidCallback? onTextFieldChangedCallback; const SeedGrid( this.seedWords, { @@ -18,6 +14,10 @@ class SeedGrid extends StatefulWidget { this.onTextFieldChangedCallback, super.key, }); + final List seedWords; + final bool isContinueButtonDisabled; + final bool enableSeedInputFields; + final VoidCallback? onTextFieldChangedCallback; @override State createState() { @@ -61,11 +61,11 @@ class SeedGridState extends State { } Widget _getSeedInputWidgetsGrid() { - int divider = widget.seedWords.length ~/ kSeedGridNumOfRows; + final divider = widget.seedWords.length ~/ kSeedGridNumOfRows; - List columnChildren = []; + var columnChildren = []; - for (int i = 0; i <= widget.seedWords.length / divider - 1; i++) { + for (var i = 0; i <= widget.seedWords.length / divider - 1; i++) { columnChildren.add( _getSeedRow( List.generate( @@ -80,7 +80,7 @@ class SeedGridState extends State { List.generate( kSeedGridNumOfRows - 1, (index) => const SizedBox( - height: 10.0, + height: 10, ), ), ); @@ -93,14 +93,14 @@ class SeedGridState extends State { } Widget _getSeedRow(List rangeIndexes) { - List children = rangeIndexes.fold>( + final children = rangeIndexes.fold>( [], (previousValue, index) { previousValue.add(_seedWordWidget(index)); if (rangeIndexes.last != index) { previousValue.add(const SizedBox( - width: 10.0, - )); + width: 10, + ),); } return previousValue; }, @@ -112,9 +112,9 @@ class SeedGridState extends State { } Widget _seedWordWidget(int seedWordIndex) { - String seedWord = _seedGridElements[seedWordIndex].word; + final seedWord = _seedGridElements[seedWordIndex].word; - final TextEditingController controller = TextEditingController(); + final controller = TextEditingController(); controller.text = seedWord; if (_textCursor == seedWordIndex) { @@ -124,7 +124,7 @@ class SeedGridState extends State { } return SizedBox( width: kSeedWordCellWidth, - height: 30.0, + height: 30, child: Row( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, @@ -148,11 +148,11 @@ class SeedGridState extends State { } }, child: Container( - width: 30.0, - height: 30.0, + width: 30, + height: 30, decoration: BoxDecoration( border: Border.all( - width: 2.0, + width: 2, color: _getSeedNumberBorderColor(seedWordIndex, seedWord), ), color: _getSeedNumberColor(seedWordIndex, seedWord), @@ -170,7 +170,7 @@ class SeedGridState extends State { ), ), const SizedBox( - width: 10.0, + width: 10, ), Expanded( child: FocusableActionDetector( @@ -214,7 +214,7 @@ class SeedGridState extends State { _onHoverText == seedWordIndex ? Colors.white : getIndicatorColor(seedWord), - fontSize: 12.0, + fontSize: 12, ), decoration: InputDecoration( filled: true, @@ -282,14 +282,14 @@ class SeedGridState extends State { return const UnderlineInputBorder( borderSide: BorderSide( color: AppColors.seedUnderlineBorderColor, - width: 3.0, + width: 3, ), ); } else if (Mnemonic.isValidWord(seedValue)) { return const UnderlineInputBorder( borderSide: BorderSide( color: AppColors.znnColor, - width: 3.0, + width: 3, ), ); } else if (Mnemonic.isValidWord(seedValue) == false && seedValue != '' || @@ -297,14 +297,14 @@ class SeedGridState extends State { return const UnderlineInputBorder( borderSide: BorderSide( color: AppColors.errorColor, - width: 3.0, + width: 3, ), ); } else { return const UnderlineInputBorder( borderSide: BorderSide( color: AppColors.seedUnderlineBorderColor, - width: 3.0, + width: 3, ), ); } @@ -343,7 +343,7 @@ class SeedGridState extends State { ); void _changeFocusToNextNode() { - int indexOfFocusedNode = _focusNodes.indexOf( + final indexOfFocusedNode = _focusNodes.indexOf( _focusNodes.firstWhere( (node) => node.hasFocus, ), @@ -356,7 +356,7 @@ class SeedGridState extends State { } void _initSeedGridElements(List seed) { - for (var word in seed) { + for (final word in seed) { _seedGridElements.add( SeedGridElement( word: word, @@ -369,7 +369,7 @@ class SeedGridState extends State { @override void dispose() { - for (var focusNode in _focusNodes) { + for (final focusNode in _focusNodes) { focusNode.dispose(); } super.dispose(); @@ -377,13 +377,13 @@ class SeedGridState extends State { } class SeedGridElement { - String word; - bool isValid; - bool isShown; SeedGridElement({ required this.word, required this.isValid, required this.isShown, }); + String word; + bool isValid; + bool isShown; } diff --git a/lib/widgets/reusable_widgets/select_file_widget.dart b/lib/widgets/reusable_widgets/select_file_widget.dart index e0ad85d5..9d0627f9 100644 --- a/lib/widgets/reusable_widgets/select_file_widget.dart +++ b/lib/widgets/reusable_widgets/select_file_widget.dart @@ -8,9 +8,6 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; const String _kInitialMessage = 'Click to browse or drag and drop a file'; class SelectFileWidget extends StatefulWidget { - final void Function(String) onPathFoundCallback; - final String? fileExtension; - final TextStyle? textStyle; const SelectFileWidget({ required this.onPathFoundCallback, @@ -18,6 +15,9 @@ class SelectFileWidget extends StatefulWidget { this.textStyle, super.key, }); + final void Function(String) onPathFoundCallback; + final String? fileExtension; + final TextStyle? textStyle; @override SelectFileWidgetState createState() => SelectFileWidgetState(); @@ -33,7 +33,7 @@ class SelectFileWidgetState extends State { Widget build(BuildContext context) { return DropTarget( onDragDone: (detail) { - String walletFilePath = detail.files.first.path; + final walletFilePath = detail.files.first.path; if (walletFilePath.contains(widget.fileExtension ?? '')) { setState(() { widget.onPathFoundCallback(walletFilePath); @@ -92,17 +92,17 @@ class SelectFileWidgetState extends State { color: _browseButtonHover ? AppColors.znnColor : Theme.of(context).textTheme.headlineSmall!.color!, - strokeWidth: 2.0, + strokeWidth: 2, dashPattern: const [8.0, 5.0], - radius: const Radius.circular(10.0), + radius: const Radius.circular(10), child: Container( - height: 100.0, + height: 100, decoration: BoxDecoration( color: _dragging ? Colors.blue.withOpacity(0.4) : Theme.of(context).colorScheme.primary, borderRadius: const BorderRadius.all( - Radius.circular(10.0), + Radius.circular(10), ), ), child: Row( @@ -117,7 +117,7 @@ class SelectFileWidgetState extends State { softWrap: true, textAlign: TextAlign.center, ), - ) + ), ], ), ), diff --git a/lib/widgets/reusable_widgets/settings_address.dart b/lib/widgets/reusable_widgets/settings_address.dart index fe9a5557..2d13b009 100644 --- a/lib/widgets/reusable_widgets/settings_address.dart +++ b/lib/widgets/reusable_widgets/settings_address.dart @@ -7,14 +7,14 @@ import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class SettingsAddress extends StatefulWidget { - final String? address; - final void Function(String?) onAddressLabelPressed; const SettingsAddress({ required this.address, required this.onAddressLabelPressed, super.key, }); + final String? address; + final void Function(String?) onAddressLabelPressed; @override State createState() => _SettingsAddressState(); @@ -41,7 +41,7 @@ class _SettingsAddressState extends State { Widget build(BuildContext context) { return Container( margin: const EdgeInsets.symmetric( - vertical: 5.0, + vertical: 5, ), child: _editable ? _getAddressLabelInputField() : _getAddressLabel(context), @@ -54,12 +54,12 @@ class _SettingsAddressState extends State { Expanded( child: InkWell( borderRadius: BorderRadius.circular( - 10.0, + 10, ), onTap: () => widget.onAddressLabelPressed(widget.address), child: Padding( padding: - const EdgeInsets.symmetric(horizontal: 5.0, vertical: 5.0), + const EdgeInsets.symmetric(horizontal: 5, vertical: 5), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -80,10 +80,10 @@ class _SettingsAddressState extends State { ), ), const SizedBox( - width: 5.0, + width: 5, ), MaterialIconButton( - size: 15.0, + size: 15, iconData: Icons.edit, onPressed: () { setState(() { @@ -93,14 +93,14 @@ class _SettingsAddressState extends State { materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, ), const SizedBox( - width: 5.0, + width: 5, ), CopyToClipboardIcon( widget.address, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, ), const SizedBox( - width: 5.0, + width: 5, ), ], ); @@ -114,7 +114,7 @@ class _SettingsAddressState extends State { children: [ Expanded( child: SizedBox( - height: 40.0, + height: 40, child: InputField( controller: _labelController, onSubmitted: (value) { @@ -132,38 +132,38 @@ class _SettingsAddressState extends State { ), enabledBorder: OutlineInputBorder( borderSide: BorderSide.none, - borderRadius: BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(10), ), - contentLeftPadding: 5.0, + contentLeftPadding: 5, disabledBorder: OutlineInputBorder( borderSide: BorderSide( color: Colors.white.withOpacity(0.1), ), - borderRadius: BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(10), ), focusedBorder: OutlineInputBorder( borderSide: const BorderSide(color: AppColors.znnColor), - borderRadius: BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(10), ), errorBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(10), borderSide: const BorderSide( color: AppColors.errorColor, - width: 2.0, + width: 2, ), ), focusedErrorBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(10), borderSide: const BorderSide( color: AppColors.errorColor, - width: 2.0, + width: 2, ), ), ), ), ), const SizedBox( - width: 15.0, + width: 15, ), SettingsButton( onPressed: @@ -174,7 +174,7 @@ class _SettingsAddressState extends State { key: _changeButtonKey, ), MaterialIconButton( - size: 15.0, + size: 15, onPressed: () { setState(() { _labelController.text = kAddressLabelMap[widget.address]!; @@ -197,7 +197,7 @@ class _SettingsAddressState extends State { ); } - void _onChangeButtonPressed() async { + Future _onChangeButtonPressed() async { try { _changeButtonKey.currentState!.showLoadingIndicator(true); if (_labelController.text.isNotEmpty && @@ -213,8 +213,8 @@ class _SettingsAddressState extends State { }); } else if (_labelController.text.isEmpty) { await NotificationUtils.sendNotificationError( - 'Label can\'t be empty', - 'Label can\'t be empty', + "Label can't be empty", + "Label can't be empty", ); } else if (_labelController.text.length > kAddressLabelMaxLength) { await NotificationUtils.sendNotificationError( diff --git a/lib/widgets/reusable_widgets/settings_node.dart b/lib/widgets/reusable_widgets/settings_node.dart index 7eb1dc50..a8f55dff 100644 --- a/lib/widgets/reusable_widgets/settings_node.dart +++ b/lib/widgets/reusable_widgets/settings_node.dart @@ -11,10 +11,6 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class SettingsNode extends StatefulWidget { - final String node; - final void Function(String?) onNodePressed; - final VoidCallback onChangedOrDeletedNode; - final String currentNode; const SettingsNode({ required this.node, @@ -23,6 +19,10 @@ class SettingsNode extends StatefulWidget { required this.currentNode, super.key, }); + final String node; + final void Function(String?) onNodePressed; + final VoidCallback onChangedOrDeletedNode; + final String currentNode; @override State createState() => _SettingsNodeState(); @@ -54,7 +54,7 @@ class _SettingsNodeState extends State { Widget build(BuildContext context) { return Container( margin: const EdgeInsets.symmetric( - vertical: 5.0, + vertical: 5, ), child: _editable ? _getNodeInputField() : _getNode(context), ); @@ -64,15 +64,14 @@ class _SettingsNodeState extends State { return Row( children: [ Expanded( - flex: 1, child: InkWell( borderRadius: BorderRadius.circular( - 10.0, + 10, ), onTap: () => widget.onNodePressed(widget.node), child: Padding( padding: - const EdgeInsets.symmetric(horizontal: 5.0, vertical: 5.0), + const EdgeInsets.symmetric(horizontal: 5, vertical: 5), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -95,16 +94,16 @@ class _SettingsNodeState extends State { visible: widget.currentNode.contains(widget.node), child: StandardTooltipIcon( (connectedNodeChainIdentifier == getChainIdentifier()) - ? 'Client chain identifier: ${getChainIdentifier().toString()}\n' + ? 'Client chain identifier: ${getChainIdentifier()}\n' 'Node chain identifier: $connectedNodeChainIdentifier' : 'Chain identifier mismatch\n' - 'Client chain identifier: ${getChainIdentifier().toString()}\n' + 'Client chain identifier: ${getChainIdentifier()}\n' 'Node chain identifier: $connectedNodeChainIdentifier', MaterialCommunityIcons.identifier, iconColor: (getChainIdentifier() == connectedNodeChainIdentifier) ? AppColors.znnColor - : AppColors.errorColor)), + : AppColors.errorColor,),), Visibility( visible: widget.node.contains('wss://'), child: const StandardTooltipIcon('Encrypted connection', Icons.lock), @@ -146,9 +145,9 @@ class _SettingsNodeState extends State { !kDefaultCommunityNodes.contains(widget.node), child: IconButton( hoverColor: Colors.transparent, - padding: const EdgeInsets.all(4.0), + padding: const EdgeInsets.all(4), constraints: const BoxConstraints(), - iconSize: 15.0, + iconSize: 15, icon: const Icon( Icons.edit, color: AppColors.znnColor, @@ -159,15 +158,15 @@ class _SettingsNodeState extends State { }); }, tooltip: 'Edit node', - )), + ),), Visibility( visible: !kDefaultNodes.contains(widget.node) && !kDefaultCommunityNodes.contains(widget.node), child: IconButton( hoverColor: Colors.transparent, - padding: const EdgeInsets.all(4.0), + padding: const EdgeInsets.all(4), constraints: const BoxConstraints(), - iconSize: 15.0, + iconSize: 15, icon: const Icon( Icons.delete_forever, color: AppColors.znnColor, @@ -178,13 +177,13 @@ class _SettingsNodeState extends State { title: 'Node Management', description: 'Are you sure you want to delete ' '${widget.node} from the list of nodes? This action ' - 'can\'t be undone.', + "can't be undone.", onYesButtonPressed: () { _deleteNodeFromDb(widget.node); }, ), tooltip: 'Delete node', - )), + ),), ], ); } @@ -217,12 +216,12 @@ class _SettingsNodeState extends State { } }, validator: (value) => - InputValidators.node(value) ?? _nodeError), + InputValidators.node(value) ?? _nodeError,), ), ), ), const SizedBox( - width: 15.0, + width: 15, ), SettingsButton( onPressed: @@ -233,7 +232,7 @@ class _SettingsNodeState extends State { key: _changeButtonKey, ), MaterialIconButton( - size: 15.0, + size: 15, onPressed: () { setState(() { _nodeController.text = widget.node; @@ -252,7 +251,7 @@ class _SettingsNodeState extends State { bool _ifUserInputValid() => InputValidators.node(_nodeController.text) == null; - void _onChangeButtonPressed() async { + Future _onChangeButtonPressed() async { try { _changeButtonKey.currentState!.showLoadingIndicator(true); if (_nodeController.text.isNotEmpty && @@ -262,8 +261,8 @@ class _SettingsNodeState extends State { if (!Hive.isBoxOpen(kNodesBox)) { await Hive.openBox(kNodesBox); } - Box nodesBox = Hive.box(kNodesBox); - var nodeKey = nodesBox.keys.firstWhere( + final nodesBox = Hive.box(kNodesBox); + final nodeKey = nodesBox.keys.firstWhere( (key) => nodesBox.get(key) == widget.node, ); await nodesBox.put(nodeKey, _nodeController.text); @@ -276,7 +275,7 @@ class _SettingsNodeState extends State { widget.onChangedOrDeletedNode(); } else if (_nodeController.text.isEmpty) { setState(() { - _nodeError = 'Node address can\'t be empty'; + _nodeError = "Node address can't be empty"; }); } else if (_nodeController.text.length > kAddressLabelMaxLength) { setState(() { @@ -303,8 +302,8 @@ class _SettingsNodeState extends State { if (!Hive.isBoxOpen(kNodesBox)) { await Hive.openBox(kNodesBox); } - Box nodesBox = Hive.box(kNodesBox); - var nodeKey = nodesBox.keys.firstWhere( + final nodesBox = Hive.box(kNodesBox); + final nodeKey = nodesBox.keys.firstWhere( (key) => nodesBox.get(key) == node, ); await nodesBox.delete(nodeKey); diff --git a/lib/widgets/reusable_widgets/stepper_utils.dart b/lib/widgets/reusable_widgets/stepper_utils.dart index 928174b4..09e57717 100644 --- a/lib/widgets/reusable_widgets/stepper_utils.dart +++ b/lib/widgets/reusable_widgets/stepper_utils.dart @@ -27,21 +27,21 @@ class StepperUtils { Text( stepSubtitle, style: Theme.of(context).textTheme.bodyLarge!.copyWith( - fontSize: 12.0, + fontSize: 12, color: stepSubtitleColor, ), ), if (stepSubtitleIconData != null) Icon( stepSubtitleIconData, - size: 15.0, + size: 15, color: stepSubtitleColor, ), ], ) : null, content: Container( - margin: const EdgeInsets.only(left: 37.0), + margin: const EdgeInsets.only(left: 37), child: Row( children: [ Expanded( @@ -59,7 +59,7 @@ class StepperUtils { } static custom_material_stepper.StepState getStepState( - int currentStepIndex, int? completedStepIndex) { + int currentStepIndex, int? completedStepIndex,) { return currentStepIndex <= (completedStepIndex ?? -1) ? custom_material_stepper.StepState.complete : custom_material_stepper.StepState.indexed; @@ -71,7 +71,7 @@ class StepperUtils { Expanded( child: Padding( - padding: const EdgeInsets.only(left: 20.0, top: 10.0, bottom: 10.0), + padding: const EdgeInsets.only(left: 20, top: 10, bottom: 10), child: AvailableBalance( token, accountInfo, diff --git a/lib/widgets/reusable_widgets/syrius_checkbox.dart b/lib/widgets/reusable_widgets/syrius_checkbox.dart index 4ababfc1..3440ed70 100644 --- a/lib/widgets/reusable_widgets/syrius_checkbox.dart +++ b/lib/widgets/reusable_widgets/syrius_checkbox.dart @@ -3,10 +3,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; class SyriusCheckbox extends Checkbox { SyriusCheckbox({ - super.key, - required Function(bool?) super.onChanged, - required super.value, - required BuildContext context, + required Function(bool?) super.onChanged, required super.value, required BuildContext context, super.key, }) : super( checkColor: Theme.of(context).scaffoldBackgroundColor, activeColor: AppColors.znnColor, diff --git a/lib/widgets/reusable_widgets/tag_widget.dart b/lib/widgets/reusable_widgets/tag_widget.dart index f8a8d397..c2ef4bf3 100644 --- a/lib/widgets/reusable_widgets/tag_widget.dart +++ b/lib/widgets/reusable_widgets/tag_widget.dart @@ -3,11 +3,6 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_theme.dart'; import 'package:zenon_syrius_wallet_flutter/utils/color_utils.dart'; class TagWidget extends StatelessWidget { - final IconData? iconData; - final VoidCallback? onPressed; - final String text; - final String? hexColorCode; - final Color? textColor; const TagWidget({ required this.text, @@ -17,6 +12,11 @@ class TagWidget extends StatelessWidget { this.textColor, super.key, }); + final IconData? iconData; + final VoidCallback? onPressed; + final String text; + final String? hexColorCode; + final Color? textColor; @override Widget build(BuildContext context) { @@ -24,13 +24,13 @@ class TagWidget extends StatelessWidget { children: [ InkWell( onTap: onPressed, - borderRadius: BorderRadius.circular(50.0), + borderRadius: BorderRadius.circular(50), child: Container( - padding: const EdgeInsets.symmetric(horizontal: 15.0), - height: 25.0, + padding: const EdgeInsets.symmetric(horizontal: 15), + height: 25, alignment: Alignment.center, decoration: BoxDecoration( - borderRadius: BorderRadius.circular(50.0), + borderRadius: BorderRadius.circular(50), color: hexColorCode != null ? ColorUtils.getColorFromHexCode(hexColorCode!) : Theme.of(context).colorScheme.secondary, @@ -43,10 +43,10 @@ class TagWidget extends StatelessWidget { Icon( iconData, color: Colors.white, - size: 15.0, + size: 15, ), const SizedBox( - width: 5.0, + width: 5, ), ], ), @@ -61,7 +61,7 @@ class TagWidget extends StatelessWidget { ), ), const SizedBox( - width: 10.0, + width: 10, ), ], ); diff --git a/lib/widgets/reusable_widgets/transfer_icon_legend.dart b/lib/widgets/reusable_widgets/transfer_icon_legend.dart index d32217e0..6e3ae8f1 100644 --- a/lib/widgets/reusable_widgets/transfer_icon_legend.dart +++ b/lib/widgets/reusable_widgets/transfer_icon_legend.dart @@ -1,29 +1,28 @@ import 'package:flutter/material.dart'; class TransferIconLegend extends StatelessWidget { - final String legendText; const TransferIconLegend({ required this.legendText, super.key, }); + final String legendText; @override Widget build(BuildContext context) { return Container( - width: 80.0, + width: 80, padding: const EdgeInsets.symmetric( - vertical: 5.0, + vertical: 5, ), decoration: BoxDecoration( color: Colors.black12, borderRadius: BorderRadius.circular( - 10.0, + 10, ), ), child: Row( mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( legendText, diff --git a/lib/widgets/tab_children_widgets/accelerator_tab_child.dart b/lib/widgets/tab_children_widgets/accelerator_tab_child.dart index cb162e8a..b6eac97c 100644 --- a/lib/widgets/tab_children_widgets/accelerator_tab_child.dart +++ b/lib/widgets/tab_children_widgets/accelerator_tab_child.dart @@ -8,12 +8,12 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class AcceleratorTabChild extends StatelessWidget { - final VoidCallback onStepperNotificationSeeMorePressed; const AcceleratorTabChild({ required this.onStepperNotificationSeeMorePressed, super.key, }); + final VoidCallback onStepperNotificationSeeMorePressed; @override Widget build(BuildContext context) { @@ -25,7 +25,7 @@ class AcceleratorTabChild extends StatelessWidget { return SyriusErrorWidget(snapshot.error.toString()); } else if (snapshot.hasData) { return _getLayout( - context, snapshot.data!.isNotEmpty ? snapshot.data!.first : null); + context, snapshot.data!.isNotEmpty ? snapshot.data!.first : null,); } return const SyriusLoadingWidget(); }, diff --git a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart index da5b75cf..e3e52845 100644 --- a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart +++ b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart @@ -6,14 +6,14 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class DashboardTabChild extends StatefulWidget { + + const DashboardTabChild({super.key, this.changePage}); final void Function( Tabs, { bool redirectWithSendContainerLarge, bool redirectWithReceiveContainerLarge, })? changePage; - const DashboardTabChild({super.key, this.changePage}); - @override State createState() => _DashboardTabChildState(); } @@ -31,7 +31,7 @@ class _DashboardTabChildState extends State { } Widget _getFluidLayout() { - final int defaultCellWidth = context.layout.value( + final defaultCellWidth = context.layout.value( xl: kStaggeredNumOfColumns ~/ 6, lg: kStaggeredNumOfColumns ~/ 6, md: kStaggeredNumOfColumns ~/ 6, @@ -39,7 +39,7 @@ class _DashboardTabChildState extends State { xs: kStaggeredNumOfColumns ~/ 2, ); - final List children = [ + final children = [ const FluidCell( child: DualCoinStatsCard(), ), @@ -89,7 +89,6 @@ class _DashboardTabChildState extends State { return StandardFluidLayout( defaultCellWidth: defaultCellWidth, - defaultCellHeight: kStaggeredNumOfColumns / 4, children: children, ); } diff --git a/lib/widgets/tab_children_widgets/lock_tab_child.dart b/lib/widgets/tab_children_widgets/lock_tab_child.dart index 7bd8fb03..19f5a281 100644 --- a/lib/widgets/tab_children_widgets/lock_tab_child.dart +++ b/lib/widgets/tab_children_widgets/lock_tab_child.dart @@ -9,19 +9,19 @@ import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/init_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/wallet_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/wallet_utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_ledger_dart/znn_ledger_dart.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class LockTabChild extends StatefulWidget { - final Future Function(String) afterUnlockCallback; - final Function() afterInitCallback; const LockTabChild(this.afterUnlockCallback, this.afterInitCallback, - {super.key}); + {super.key,}); + final Future Function(String) afterUnlockCallback; + final Function() afterInitCallback; @override State createState() => _LockTabChildState(); @@ -47,30 +47,29 @@ class _LockTabChildState extends State { return Container( color: Theme.of(context).colorScheme.primary, child: Column( - crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ const Icon( Fontisto.locked, color: AppColors.znnColor, - size: 50.0, + size: 50, ), const SizedBox( - height: 40.0, + height: 40, ), Text( 'Welcome Back', style: Theme.of(context).textTheme.headlineMedium, ), const SizedBox( - height: 20.0, + height: 20, ), Text( 'Enter the password to access the wallet', style: Theme.of(context).textTheme.headlineSmall, ), const SizedBox( - height: 40.0, + height: 40, ), Row( mainAxisAlignment: MainAxisAlignment.center, @@ -83,13 +82,13 @@ class _LockTabChildState extends State { }, ), const SizedBox( - width: 10.0, + width: 10, ), _actionButton!, ], ), const SizedBox( - height: 30.0, + height: 30, ), Visibility( visible: _messageToUser.isEmpty, @@ -109,7 +108,7 @@ class _LockTabChildState extends State { Visibility( visible: _messageToUser.isNotEmpty, child: Padding( - padding: const EdgeInsets.only(top: 30.0), + padding: const EdgeInsets.only(top: 30), child: Text( _messageToUser, style: Theme.of(context).textTheme.bodyLarge, @@ -128,7 +127,7 @@ class _LockTabChildState extends State { icon: const Icon( AntDesign.arrowright, color: AppColors.znnColor, - size: 25.0, + size: 25, ), ); } @@ -168,7 +167,7 @@ class _LockTabChildState extends State { _messageToUser = 'Initializing wallet, please wait'; }); await InitUtils.initWalletAfterDecryption( - Crypto.digest(utf8.encode(_passwordController.text))); + Crypto.digest(utf8.encode(_passwordController.text)),); widget.afterInitCallback(); } else { await widget.afterUnlockCallback(_passwordController.text); @@ -195,9 +194,7 @@ class _LockTabChildState extends State { } void _resetScreenState() { - setState(() { - _cleanScreen(); - }); + setState(_cleanScreen); } void _cleanScreen() { diff --git a/lib/widgets/tab_children_widgets/notifications_tab_child.dart b/lib/widgets/tab_children_widgets/notifications_tab_child.dart index 936b415f..7a0df739 100644 --- a/lib/widgets/tab_children_widgets/notifications_tab_child.dart +++ b/lib/widgets/tab_children_widgets/notifications_tab_child.dart @@ -23,7 +23,6 @@ class _NotificationsTabChildState extends State { _loadNotifications(); return WidgetAnimator( - curve: Curves.linear, child: _getNotificationsContainer(), ); } @@ -43,12 +42,12 @@ class _NotificationsTabChildState extends State { columnName: '', ), ], - generateRowCells: _rowCellsGenerator), + generateRowCells: _rowCellsGenerator,), ); } ExpandablePanel _getNotificationExpandablePanel( - WalletNotification notification) { + WalletNotification notification,) { return ExpandablePanel( collapsed: Container(), theme: ExpandableThemeData( @@ -60,7 +59,7 @@ class _NotificationsTabChildState extends State { children: [ notification.getIcon(), const SizedBox( - width: 10.0, + width: 10, ), Expanded( child: Text( @@ -71,7 +70,7 @@ class _NotificationsTabChildState extends State { ], ), expanded: Padding( - padding: const EdgeInsets.only(left: 14.0, top: 5.0, bottom: 5.0), + padding: const EdgeInsets.only(left: 14, top: 5, bottom: 5), child: Row( children: [ Expanded( @@ -96,8 +95,8 @@ class _NotificationsTabChildState extends State { List _getNotificationsFromDb() { try { - Box notificationsBox = Hive.box(kNotificationsBox); - List keys = notificationsBox.keys.toList(); + final notificationsBox = Hive.box(kNotificationsBox); + final keys = notificationsBox.keys.toList(); if (keys.length >= kNotificationsResultLimit) { return List.from( notificationsBox.valuesBetween( @@ -117,9 +116,9 @@ class _NotificationsTabChildState extends State { } Future _deleteNotification(int? notificationTimestamp) async { - Box notificationsBox = Hive.box(kNotificationsBox); + final notificationsBox = Hive.box(kNotificationsBox); - var notificationKey = notificationsBox.keys.firstWhere( + final notificationKey = notificationsBox.keys.firstWhere( (key) => notificationsBox.get(key).timestamp == notificationTimestamp, ); @@ -151,7 +150,7 @@ class _NotificationsTabChildState extends State { CustomTableCell.withText( context, FormatUtils.formatDate(notification.timestamp, - dateFormat: kNotificationsTimeFormat), + dateFormat: kNotificationsTimeFormat,), flex: 2, ), CustomTableCell(_getClearIcon(notification)), diff --git a/lib/widgets/tab_children_widgets/p2p_swap_tab_child.dart b/lib/widgets/tab_children_widgets/p2p_swap_tab_child.dart index 54500604..5b8a9b8c 100644 --- a/lib/widgets/tab_children_widgets/p2p_swap_tab_child.dart +++ b/lib/widgets/tab_children_widgets/p2p_swap_tab_child.dart @@ -2,17 +2,17 @@ import 'package:flutter/material.dart'; import 'package:layout/layout.dart'; import 'package:provider/provider.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_card.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_card.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_card.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class P2pSwapTabChild extends StatefulWidget { - final VoidCallback onStepperNotificationSeeMorePressed; const P2pSwapTabChild({ required this.onStepperNotificationSeeMorePressed, super.key, }); + final VoidCallback onStepperNotificationSeeMorePressed; @override State createState() => P2pSwapTabChildState(); diff --git a/lib/widgets/tab_children_widgets/pillars_tab_child.dart b/lib/widgets/tab_children_widgets/pillars_tab_child.dart index 07b2f4d6..b503cb05 100644 --- a/lib/widgets/tab_children_widgets/pillars_tab_child.dart +++ b/lib/widgets/tab_children_widgets/pillars_tab_child.dart @@ -4,12 +4,12 @@ import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class PillarsTabChild extends StatefulWidget { - final VoidCallback onStepperNotificationSeeMorePressed; const PillarsTabChild({ required this.onStepperNotificationSeeMorePressed, super.key, }); + final VoidCallback onStepperNotificationSeeMorePressed; @override State createState() => _PillarsTabChildState(); @@ -21,7 +21,7 @@ class _PillarsTabChildState extends State { @override Widget build(BuildContext context) { - final List children = [ + final children = [ FluidCell( child: PillarRewards( pillarRewardsHistoryBloc: _pillarRewardsHistoryBloc, diff --git a/lib/widgets/tab_children_widgets/sentinels_tab_child.dart b/lib/widgets/tab_children_widgets/sentinels_tab_child.dart index 0165c80d..0688a939 100644 --- a/lib/widgets/tab_children_widgets/sentinels_tab_child.dart +++ b/lib/widgets/tab_children_widgets/sentinels_tab_child.dart @@ -4,12 +4,12 @@ import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class SentinelsTabChild extends StatefulWidget { - final VoidCallback onStepperNotificationSeeMorePressed; const SentinelsTabChild({ required this.onStepperNotificationSeeMorePressed, super.key, }); + final VoidCallback onStepperNotificationSeeMorePressed; @override State createState() => _SentinelsTabChildState(); @@ -21,7 +21,7 @@ class _SentinelsTabChildState extends State { @override Widget build(BuildContext context) { - final List children = [ + final children = [ FluidCell( child: SentinelRewards( sentinelRewardsHistoryBloc: _sentinelRewardsHistoryBloc, diff --git a/lib/widgets/tab_children_widgets/settings_tab_child.dart b/lib/widgets/tab_children_widgets/settings_tab_child.dart index 492dd307..0b595a15 100644 --- a/lib/widgets/tab_children_widgets/settings_tab_child.dart +++ b/lib/widgets/tab_children_widgets/settings_tab_child.dart @@ -4,9 +4,6 @@ import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class SettingsTabChild extends StatefulWidget { - final VoidCallback _onChangeAutoLockTime; - final VoidCallback onStepperNotificationSeeMorePressed; - final VoidCallback onNodeChangedCallback; const SettingsTabChild( this._onChangeAutoLockTime, { @@ -14,6 +11,9 @@ class SettingsTabChild extends StatefulWidget { required this.onNodeChangedCallback, super.key, }); + final VoidCallback _onChangeAutoLockTime; + final VoidCallback onStepperNotificationSeeMorePressed; + final VoidCallback onNodeChangedCallback; @override State createState() => _SettingsTabChildState(); @@ -79,7 +79,7 @@ class _SettingsTabChildState extends State { onStepperNotificationSeeMorePressed: widget.onStepperNotificationSeeMorePressed, ), - height: kStaggeredNumOfColumns / 2 + height: kStaggeredNumOfColumns / 2, ), FluidCell( width: context.layout.value( @@ -90,7 +90,7 @@ class _SettingsTabChildState extends State { xs: kStaggeredNumOfColumns, ), child: const DisplayWidget(), - height: kStaggeredNumOfColumns / 2 + height: kStaggeredNumOfColumns / 2, ), FluidCell( child: const WalletOptions(), diff --git a/lib/widgets/tab_children_widgets/staking_tab_child.dart b/lib/widgets/tab_children_widgets/staking_tab_child.dart index 6f6c5407..833f0a17 100644 --- a/lib/widgets/tab_children_widgets/staking_tab_child.dart +++ b/lib/widgets/tab_children_widgets/staking_tab_child.dart @@ -25,7 +25,7 @@ class _StakingTabChildState extends State { } Widget _getFluidLayout() { - final List children = [ + final children = [ FluidCell( child: StakingRewards( stakingRewardsHistoryBloc: _stakingRewardsHistoryBloc, diff --git a/lib/widgets/tab_children_widgets/tab_children_widgets.dart b/lib/widgets/tab_children_widgets/tab_children_widgets.dart index ef80719d..b69ee3e5 100644 --- a/lib/widgets/tab_children_widgets/tab_children_widgets.dart +++ b/lib/widgets/tab_children_widgets/tab_children_widgets.dart @@ -3,9 +3,9 @@ export 'dashboard_tab_child.dart'; export 'help_tab_child.dart'; export 'lock_tab_child.dart'; export 'notifications_tab_child.dart'; +export 'p2p_swap_tab_child.dart'; export 'pillars_tab_child.dart'; export 'plasma_tab_child.dart'; -export 'p2p_swap_tab_child.dart'; export 'sentinels_tab_child.dart'; export 'settings_tab_child.dart'; export 'staking_tab_child.dart'; diff --git a/lib/widgets/tab_children_widgets/tokens_tab_child.dart b/lib/widgets/tab_children_widgets/tokens_tab_child.dart index 61cb149b..d9c167e3 100644 --- a/lib/widgets/tab_children_widgets/tokens_tab_child.dart +++ b/lib/widgets/tab_children_widgets/tokens_tab_child.dart @@ -3,12 +3,12 @@ import 'package:layout/layout.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class TokensTabChild extends StatelessWidget { - final VoidCallback onStepperNotificationSeeMorePressed; const TokensTabChild({ required this.onStepperNotificationSeeMorePressed, super.key, }); + final VoidCallback onStepperNotificationSeeMorePressed; @override Widget build(BuildContext context) { diff --git a/lib/widgets/tab_children_widgets/transfer_tab_child.dart b/lib/widgets/tab_children_widgets/transfer_tab_child.dart index b30023c7..70d32460 100644 --- a/lib/widgets/tab_children_widgets/transfer_tab_child.dart +++ b/lib/widgets/tab_children_widgets/transfer_tab_child.dart @@ -5,14 +5,14 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; enum DimensionCard { small, medium, large } class TransferTabChild extends StatefulWidget { - DimensionCard sendCard; - DimensionCard receiveCard; TransferTabChild({ super.key, this.sendCard = DimensionCard.medium, this.receiveCard = DimensionCard.medium, }); + DimensionCard sendCard; + DimensionCard receiveCard; @override State createState() => _TransferTabChildState(); diff --git a/pubspec.lock b/pubspec.lock index 66869214..0aeb8419 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1746,6 +1746,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.2" + very_good_analysis: + dependency: "direct dev" + description: + name: very_good_analysis + sha256: "1fb637c0022034b1f19ea2acb42a3603cbd8314a470646a59a2fb01f5f3a8629" + url: "https://pub.dev" + source: hosted + version: "6.0.0" vm_service: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 06343af7..170b3c09 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -93,6 +93,7 @@ dev_dependencies: bloc_test: ^9.0.0 flutter_test: sdk: flutter + very_good_analysis: ^6.0.0 flutter: diff --git a/test/delegation/cubit/delegation_cubit_test.dart b/test/delegation/cubit/delegation_cubit_test.dart index 533cca69..b4755e0c 100644 --- a/test/delegation/cubit/delegation_cubit_test.dart +++ b/test/delegation/cubit/delegation_cubit_test.dart @@ -1,7 +1,7 @@ // ignore_for_file: prefer_const_constructors -import 'package:flutter_test/flutter_test.dart'; import 'package:bloc_test/bloc_test.dart'; +import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -65,7 +65,7 @@ void main() { verify: (_) { verify(() => mockZenon.embedded.pillar.getDelegatedPillar( emptyAddress, - )).called(1); + ),).called(1); }, ); From c47311a1f5eb2e22b3eeb3bc5ed2270b7d4c07d1 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Fri, 18 Oct 2024 20:04:59 +0300 Subject: [PATCH 017/102] feat: Add localization --- l10n.yaml | 3 +++ lib/l10n/app_en.arb | 3 +++ lib/main.dart | 4 ++++ lib/utils/extensions.dart | 6 ++++++ pubspec.lock | 5 +++++ pubspec.yaml | 6 ++++-- 6 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 l10n.yaml create mode 100644 lib/l10n/app_en.arb diff --git a/l10n.yaml b/l10n.yaml new file mode 100644 index 00000000..4e6692e5 --- /dev/null +++ b/l10n.yaml @@ -0,0 +1,3 @@ +arb-dir: lib/l10n +template-arb-file: app_en.arb +output-localization-file: app_localizations.dart \ No newline at end of file diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb new file mode 100644 index 00000000..34c8f71a --- /dev/null +++ b/lib/l10n/app_en.arb @@ -0,0 +1,3 @@ +{ + "balance": "Balance" +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index b957e990..f9e71409 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,6 +2,8 @@ import 'dart:async'; import 'dart:io'; import 'dart:isolate'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter/foundation.dart' show kDebugMode; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; @@ -321,6 +323,8 @@ class _MyAppState extends State with WindowListener, TrayListener { themeMode: appThemeNotifier.currentThemeMode, initialRoute: SplashScreen.route, scrollBehavior: RemoveOverscrollEffect(), + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, routes: { AccessWalletScreen.route: (context) => const AccessWalletScreen(), diff --git a/lib/utils/extensions.dart b/lib/utils/extensions.dart index c9ab2217..c9aa2172 100644 --- a/lib/utils/extensions.dart +++ b/lib/utils/extensions.dart @@ -1,6 +1,8 @@ import 'dart:math' show pow; import 'package:big_decimal/big_decimal.dart'; +import 'package:flutter/material.dart'; import 'package:znn_ledger_dart/znn_ledger_dart.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; extension StringExtensions on String { String capitalize() { @@ -120,3 +122,7 @@ extension LedgerErrorExtensions on LedgerError { } } } + +extension BuildContextL10n on BuildContext { + AppLocalizations get l10n => AppLocalizations.of(this)!; +} diff --git a/pubspec.lock b/pubspec.lock index 0aeb8419..b955105e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -603,6 +603,11 @@ packages: url: "https://pub.dev" source: hosted version: "5.0.0" + flutter_localizations: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" flutter_plugin_android_lifecycle: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 170b3c09..f922e434 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -8,7 +8,8 @@ environment: dependencies: flutter: sdk: flutter - + flutter_localizations: + sdk: flutter fl_chart: ^0.69.0 overlay_support: ^2.1.0 lottie: ^3.1.2 @@ -29,7 +30,7 @@ dependencies: hive: ^2.0.5 url_launcher: ^6.1.12 provider: ^6.0.2 - intl: ^0.19.0 + intl: any package_info_plus: ^8.0.2 device_info_plus: ^10.1.2 infinite_scroll_pagination: ^4.0.0 @@ -97,6 +98,7 @@ dev_dependencies: flutter: + generate: true uses-material-design: true assets: From 23cc37b4e92f7837a294d9a539c04d9aa5c73e23 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Sat, 19 Oct 2024 13:11:57 +0300 Subject: [PATCH 018/102] feat: Exemplify how to use AppLocalizations --- lib/l10n/app_en.arb | 4 +++- .../dashboard/balance/view/balance_card.dart | 2 +- .../dashboard/delegation/view/delegation_card.dart | 2 +- .../dual_coin_stats/view/dual_coin_stats_card.dart | 2 +- lib/utils/card/card_type.dart | 12 ++++++++---- .../card_scaffold_without_listener.dart | 8 ++++---- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 34c8f71a..fb032025 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -1,3 +1,5 @@ { - "balance": "Balance" + "balance": "Balance", + "dualCoinStats": "Dual Coin Stats", + "delegationStats": "Delegation Stats" } \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/balance/view/balance_card.dart b/lib/rearchitecture/dashboard/balance/view/balance_card.dart index 5d3a4452..fa5b8ab6 100644 --- a/lib/rearchitecture/dashboard/balance/view/balance_card.dart +++ b/lib/rearchitecture/dashboard/balance/view/balance_card.dart @@ -35,7 +35,7 @@ class BalanceCard extends StatelessWidget { return cubit; }, child: CardScaffoldWithoutListener( - type: CardType.balance, + data: CardType.balance.getData(context: context), body: BlocBuilder( builder: (context, state) { // Uses a `switch` statement to display different widgets based on diff --git a/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart b/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart index d12db9d4..6a91713b 100644 --- a/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart +++ b/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart @@ -23,7 +23,7 @@ class DelegationCard extends StatelessWidget { return cubit; }, child: CardScaffoldWithoutListener( - type: CardType.delegationStats, + data: CardType.delegationStats.getData(context: context), body: BlocBuilder( builder: (context, state) { return switch (state.status) { diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart b/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart index 23909aaf..de0dbbb2 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart @@ -21,7 +21,7 @@ class DualCoinStatsCard extends StatelessWidget { return cubit; }, child: CardScaffoldWithoutListener( - type: CardType.dualCoinStats, + data: CardType.dualCoinStats.getData(context: context), body: BlocBuilder( builder: (context, state) { return switch (state.status) { diff --git a/lib/utils/card/card_type.dart b/lib/utils/card/card_type.dart index 23e378a8..c41cc325 100644 --- a/lib/utils/card/card_type.dart +++ b/lib/utils/card/card_type.dart @@ -1,4 +1,6 @@ +import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/card/card_data.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; enum CardType { @@ -6,20 +8,22 @@ enum CardType { delegationStats, dualCoinStats; - CardData get data { + CardData getData({ + required BuildContext context, + }) { return switch (this) { CardType.balance => CardData( - title: 'Balance', + title: context.l10n.balance, description: 'This card displays the current ${kZnnCoin.symbol} ' 'and ${kQsrCoin.symbol} amounts for the selected address', ), CardType.delegationStats => CardData( - title: 'Delegation Stats', + title: context.l10n.delegationStats, description: 'This card displays the amount of ${kZnnCoin.symbol} ' 'and the name of the Pillar that you delegated to', ), CardType.dualCoinStats => CardData( - title: 'Dual Coin Stats', + title: context.l10n.dualCoinStats, description: 'This card displays the circulating ${kZnnCoin.symbol} ' 'and ${kQsrCoin.symbol} supply from the network', ), diff --git a/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart b/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart index 8314325c..77b94930 100644 --- a/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart +++ b/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart @@ -13,12 +13,12 @@ class CardScaffoldWithoutListener extends StatefulWidget { const CardScaffoldWithoutListener({ required this.body, - required this.type, + required this.data, this.onRefreshPressed, super.key, }); final Widget body; - final CardType type; + final CardData data; final VoidCallback? onRefreshPressed; @override @@ -38,8 +38,8 @@ class _CardScaffoldWithoutListenerState extends State widget.type.data.title; - String get _description => widget.type.data.description; + String get _title => widget.data.title; + String get _description => widget.data.description; @override void initState() { From 1367354a8e2e8ef9569793cac948c07c1f4a4a59 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Sat, 19 Oct 2024 17:48:16 +0300 Subject: [PATCH 019/102] feat: Enable l10n for the dev entry point also --- lib/main_dev.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/main_dev.dart b/lib/main_dev.dart index b5c61356..78cceddc 100644 --- a/lib/main_dev.dart +++ b/lib/main_dev.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:io'; import 'dart:isolate'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter/foundation.dart' show kDebugMode; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; @@ -314,6 +315,8 @@ class _MyAppState extends State with WindowListener, TrayListener { themeMode: appThemeNotifier.currentThemeMode, initialRoute: DevelopmentInitializationScreen.route, scrollBehavior: RemoveOverscrollEffect(), + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, routes: { AccessWalletScreen.route: (context) => const AccessWalletScreen(), From bfc08361306fe4e34f502116e2e6dc5ad1e60db5 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Sat, 19 Oct 2024 17:50:04 +0300 Subject: [PATCH 020/102] fix: Regenerate the windows folder --- .metadata | 14 ++-- test/widget_test.dart | 30 +++++++++ windows/CMakeLists.txt | 68 ++++++------------- windows/CreateGitMetadata.ps1 | 18 ----- windows/flutter/CMakeLists.txt | 3 +- windows/runner/CMakeLists.txt | 25 ++++++- windows/runner/Runner.rc | 18 ++--- windows/runner/flutter_window.cpp | 10 +++ windows/runner/main.cpp | 2 +- windows/runner/resources/app_icon.ico | Bin 178939 -> 33772 bytes windows/runner/runner.exe.manifest | 6 -- windows/runner/utils.cpp | 15 +++-- windows/runner/win32_window.cpp | 92 +++++++++++++------------- windows/runner/win32_window.h | 25 ++++--- 14 files changed, 172 insertions(+), 154 deletions(-) create mode 100644 test/widget_test.dart delete mode 100644 windows/CreateGitMetadata.ps1 diff --git a/.metadata b/.metadata index 0b303072..ea59ad0b 100644 --- a/.metadata +++ b/.metadata @@ -1,11 +1,11 @@ # This file tracks properties of this Flutter project. # Used by Flutter tool to assess capabilities and perform upgrades etc. # -# This file should be version controlled. +# This file should be version controlled and should not be manually edited. version: - revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf - channel: stable + revision: "2663184aa79047d0a33a14a3b607954f8fdd8730" + channel: "stable" project_type: app @@ -13,11 +13,11 @@ project_type: app migration: platforms: - platform: root - create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf - base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 - platform: windows - create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf - base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 # User provided section diff --git a/test/widget_test.dart b/test/widget_test.dart new file mode 100644 index 00000000..b6d1dcea --- /dev/null +++ b/test/widget_test.dart @@ -0,0 +1,30 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:syrius/main.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // Verify that our counter starts at 0. + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +} diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt index 3313166a..1fd0da6a 100644 --- a/windows/CMakeLists.txt +++ b/windows/CMakeLists.txt @@ -1,14 +1,16 @@ -cmake_minimum_required(VERSION 3.15) +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) project(syrius LANGUAGES CXX) +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. set(BINARY_NAME "syrius") -set(APPLICATION_ID "network.zenon.syrius") -cmake_policy(SET CMP0063 NEW) +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(VERSION 3.14...3.25) -set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") - -# Configure build options. +# Define build configuration option. get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(IS_MULTICONFIG) set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" @@ -21,7 +23,7 @@ else() "Debug" "Profile" "Release") endif() endif() - +# Define settings for the Profile build mode. set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") @@ -31,6 +33,10 @@ set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") add_definitions(-DUNICODE -D_UNICODE) # Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_17) target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") @@ -39,14 +45,14 @@ function(APPLY_STANDARD_SETTINGS TARGET) target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") endfunction() -set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") - # Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) -# Application build +# Application build; see runner/CMakeLists.txt. add_subdirectory("runner") + # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) @@ -81,6 +87,12 @@ if(PLUGIN_BUNDLED_LIBRARIES) COMPONENT Runtime) endif() +# Copy the native assets provided by the build.dart from all packages. +set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") +install(DIRECTORY "${NATIVE_ASSETS_DIR}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") @@ -94,39 +106,3 @@ install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) - -# Bundle required ZNN libraries for Syrius -set(SYRIUS_PROJECT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/..") - -# Leveraging flutter to identify dependency locations -file(STRINGS "${SYRIUS_PROJECT_DIRECTORY}/.dart_tool/package_config.json" - ZNN_SDK_DART_PATH REGEX "(file:).*(znn_sdk_dart).*\\/\"" ) - -string(REPLACE "\"rootUri\": \"file:///" "" ZNN_SDK_DART_PATH "${ZNN_SDK_DART_PATH}") -string(REPLACE "/\"," "" ZNN_SDK_DART_PATH "${ZNN_SDK_DART_PATH}") -string(STRIP "${ZNN_SDK_DART_PATH}" ZNN_SDK_DART_PATH) - -file(STRINGS "${SYRIUS_PROJECT_DIRECTORY}/.dart_tool/package_config.json" - ZNN_LEDGER_DART_PATH REGEX "(file:).*(znn_ledger_dart).*\\/\"" ) - -string(REPLACE "\"rootUri\": \"file:///" "" ZNN_LEDGER_DART_PATH "${ZNN_LEDGER_DART_PATH}") -string(REPLACE "/\"," "" ZNN_LEDGER_DART_PATH "${ZNN_LEDGER_DART_PATH}") -string(STRIP "${ZNN_LEDGER_DART_PATH}" ZNN_LEDGER_DART_PATH) - -list(APPEND SYRIUS_LIBRARIES - "${SYRIUS_PROJECT_DIRECTORY}/lib/embedded_node/blobs/libznn.dll" - "${ZNN_SDK_DART_PATH}/lib/src/argon2/blobs/argon2_ffi_plugin.dll" - "${ZNN_SDK_DART_PATH}/lib/src/pow/blobs/libpow_links.dll" - "${ZNN_LEDGER_DART_PATH}/lib/src/ledger/blobs/libledger_ffi.dll" -) - -foreach(znn_library ${SYRIUS_LIBRARIES}) - install(FILES "${znn_library}" - DESTINATION "${CMAKE_INSTALL_PREFIX}" - COMPONENT Runtime) - message(STATUS "Copy ZNN library: \"${znn_library}\"") -endforeach(znn_library) - -find_program(POWERSHELL_PATH NAMES powershell) -add_custom_target("git_metadata" ALL - COMMAND ${POWERSHELL_PATH} -ExecutionPolicy Bypass "${CMAKE_HOME_DIRECTORY}/CreateGitMetadata.ps1") \ No newline at end of file diff --git a/windows/CreateGitMetadata.ps1 b/windows/CreateGitMetadata.ps1 deleted file mode 100644 index c0de1182..00000000 --- a/windows/CreateGitMetadata.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -Function Escape($String) { - Return $String.Replace("'", "'`"'`"r'"); -} - -$GIT_BRANCH_NAME = git rev-parse --abbrev-ref HEAD -$GIT_COMMIT_HASH = git rev-parse HEAD -$GIT_COMMIT_MESSAGE = git log -1 --pretty=%s -$GIT_COMMIT_DATE = git --no-pager log -1 --format="%as" -$GIT_ORIGIN_URL = git config --get remote.origin.url -$GIT_COMMIT_FILE = "${PSScriptRoot}\..\lib\utils\metadata.dart" - -Clear-Content $GIT_COMMIT_FILE -Force - -Add-Content $GIT_COMMIT_FILE "const String gitBranchName = r'$(Escape $GIT_BRANCH_NAME)';" -Add-Content $GIT_COMMIT_FILE "const String gitCommitHash = r'$GIT_COMMIT_HASH';" -Add-Content $GIT_COMMIT_FILE "const String gitCommitMessage = r'$(Escape $GIT_COMMIT_MESSAGE)';" -Add-Content $GIT_COMMIT_FILE "const String gitCommitDate = r'$GIT_COMMIT_DATE';" -Add-Content $GIT_COMMIT_FILE "const String gitOriginUrl = r'$(Escape $GIT_ORIGIN_URL)';" \ No newline at end of file diff --git a/windows/flutter/CMakeLists.txt b/windows/flutter/CMakeLists.txt index 86edc67b..903f4899 100644 --- a/windows/flutter/CMakeLists.txt +++ b/windows/flutter/CMakeLists.txt @@ -1,4 +1,5 @@ -cmake_minimum_required(VERSION 3.15) +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") diff --git a/windows/runner/CMakeLists.txt b/windows/runner/CMakeLists.txt index 0b899a0b..394917c0 100644 --- a/windows/runner/CMakeLists.txt +++ b/windows/runner/CMakeLists.txt @@ -1,6 +1,11 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. add_executable(${BINARY_NAME} WIN32 "flutter_window.cpp" "main.cpp" @@ -10,8 +15,26 @@ add_executable(${BINARY_NAME} WIN32 "Runner.rc" "runner.exe.manifest" ) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. apply_standard_settings(${BINARY_NAME}) + +# Add preprocessor definitions for the build version. +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") + +# Disable Windows macros that collide with C++ standard library functions. target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + +# Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/windows/runner/Runner.rc b/windows/runner/Runner.rc index e9a8f39a..8989787c 100644 --- a/windows/runner/Runner.rc +++ b/windows/runner/Runner.rc @@ -60,16 +60,16 @@ IDI_APP_ICON ICON "resources\\app_icon.ico" // Version // -#ifdef FLUTTER_BUILD_NUMBER -#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER +#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) +#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD #else -#define VERSION_AS_NUMBER 0,2,1 +#define VERSION_AS_NUMBER 1,0,0,0 #endif -#ifdef FLUTTER_BUILD_NAME -#define VERSION_AS_STRING #FLUTTER_BUILD_NAME +#if defined(FLUTTER_VERSION) +#define VERSION_AS_STRING FLUTTER_VERSION #else -#define VERSION_AS_STRING "v0.2.1-alphanet" +#define VERSION_AS_STRING "1.0.0" #endif VS_VERSION_INFO VERSIONINFO @@ -89,11 +89,11 @@ BEGIN BEGIN BLOCK "040904e4" BEGIN - VALUE "CompanyName", "network.zenon.syrius" "\0" - VALUE "FileDescription", "s y r i u s (" VERSION_AS_STRING ")" "\0" + VALUE "CompanyName", "com.example" "\0" + VALUE "FileDescription", "syrius" "\0" VALUE "FileVersion", VERSION_AS_STRING "\0" VALUE "InternalName", "syrius" "\0" - VALUE "LegalCopyright", "(C) 2024 Zenon Network" "\0" + VALUE "LegalCopyright", "Copyright (C) 2024 com.example. All rights reserved." "\0" VALUE "OriginalFilename", "syrius.exe" "\0" VALUE "ProductName", "syrius" "\0" VALUE "ProductVersion", VERSION_AS_STRING "\0" diff --git a/windows/runner/flutter_window.cpp b/windows/runner/flutter_window.cpp index b43b9095..955ee303 100644 --- a/windows/runner/flutter_window.cpp +++ b/windows/runner/flutter_window.cpp @@ -26,6 +26,16 @@ bool FlutterWindow::OnCreate() { } RegisterPlugins(flutter_controller_->engine()); SetChildContent(flutter_controller_->view()->GetNativeWindow()); + + flutter_controller_->engine()->SetNextFrameCallback([&]() { + this->Show(); + }); + + // Flutter can complete the first frame before the "show window" callback is + // registered. The following call ensures a frame is pending to ensure the + // window is shown. It is a no-op if the first frame hasn't completed yet. + flutter_controller_->ForceRedraw(); + return true; } diff --git a/windows/runner/main.cpp b/windows/runner/main.cpp index 25f090a9..f8a406ce 100644 --- a/windows/runner/main.cpp +++ b/windows/runner/main.cpp @@ -27,7 +27,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, FlutterWindow window(project); Win32Window::Point origin(10, 10); Win32Window::Size size(1280, 720); - if (!window.CreateAndShow(L"s y r i u s", origin, size)) { + if (!window.Create(L"syrius", origin, size)) { return EXIT_FAILURE; } window.SetQuitOnClose(true); diff --git a/windows/runner/resources/app_icon.ico b/windows/runner/resources/app_icon.ico index 8100ac249ddf6a2feb97ab5cb5e1810ebb1596e5..c04e20caf6370ebb9253ad831cc31de4a9c965f6 100644 GIT binary patch literal 33772 zcmeHQc|26z|35SKE&G-*mXah&B~fFkXr)DEO&hIfqby^T&>|8^_Ub8Vp#`BLl3lbZ zvPO!8k!2X>cg~Elr=IVxo~J*a`+9wR=A83c-k-DFd(XM&UI1VKCqM@V;DDtJ09WB} zRaHKiW(GT00brH|0EeTeKVbpbGZg?nK6-j827q-+NFM34gXjqWxJ*a#{b_apGN<-L_m3#8Z26atkEn& ze87Bvv^6vVmM+p+cQ~{u%=NJF>#(d;8{7Q{^rWKWNtf14H}>#&y7$lqmY6xmZryI& z($uy?c5-+cPnt2%)R&(KIWEXww>Cnz{OUpT>W$CbO$h1= z#4BPMkFG1Y)x}Ui+WXr?Z!w!t_hjRq8qTaWpu}FH{MsHlU{>;08goVLm{V<&`itk~ zE_Ys=D(hjiy+5=?=$HGii=Y5)jMe9|wWoD_K07(}edAxh`~LBorOJ!Cf@f{_gNCC| z%{*04ViE!#>@hc1t5bb+NO>ncf@@Dv01K!NxH$3Eg1%)|wLyMDF8^d44lV!_Sr}iEWefOaL z8f?ud3Q%Sen39u|%00W<#!E=-RpGa+H8}{ulxVl4mwpjaU+%2pzmi{3HM)%8vb*~-M9rPUAfGCSos8GUXp02|o~0BTV2l#`>>aFV&_P$ejS;nGwSVP8 zMbOaG7<7eKD>c12VdGH;?2@q7535sa7MN*L@&!m?L`ASG%boY7(&L5imY#EQ$KrBB z4@_tfP5m50(T--qv1BJcD&aiH#b-QC>8#7Fx@3yXlonJI#aEIi=8&ChiVpc#N=5le zM*?rDIdcpawoc5kizv$GEjnveyrp3sY>+5_R5;>`>erS%JolimF=A^EIsAK zsPoVyyUHCgf0aYr&alx`<)eb6Be$m&`JYSuBu=p8j%QlNNp$-5C{b4#RubPb|CAIS zGE=9OFLP7?Hgc{?k45)84biT0k&-C6C%Q}aI~q<(7BL`C#<6HyxaR%!dFx7*o^laG z=!GBF^cwK$IA(sn9y6>60Rw{mYRYkp%$jH z*xQM~+bp)G$_RhtFPYx2HTsWk80+p(uqv9@I9)y{b$7NK53rYL$ezbmRjdXS?V}fj zWxX_feWoLFNm3MG7pMUuFPs$qrQWO9!l2B(SIuy2}S|lHNbHzoE+M2|Zxhjq9+Ws8c{*}x^VAib7SbxJ*Q3EnY5lgI9 z=U^f3IW6T=TWaVj+2N%K3<%Un;CF(wUp`TC&Y|ZjyFu6co^uqDDB#EP?DV5v_dw~E zIRK*BoY9y-G_ToU2V_XCX4nJ32~`czdjT!zwme zGgJ0nOk3U4@IE5JwtM}pwimLjk{ln^*4HMU%Fl4~n(cnsLB}Ja-jUM>xIB%aY;Nq8 z)Fp8dv1tkqKanv<68o@cN|%thj$+f;zGSO7H#b+eMAV8xH$hLggtt?O?;oYEgbq@= zV(u9bbd12^%;?nyk6&$GPI%|+<_mEpJGNfl*`!KV;VfmZWw{n{rnZ51?}FDh8we_L z8OI9nE31skDqJ5Oa_ybn7|5@ui>aC`s34p4ZEu6-s!%{uU45$Zd1=p$^^dZBh zu<*pDDPLW+c>iWO$&Z_*{VSQKg7=YEpS3PssPn1U!lSm6eZIho*{@&20e4Y_lRklKDTUCKI%o4Pc<|G^Xgu$J^Q|B87U;`c1zGwf^-zH*VQ^x+i^OUWE0yd z;{FJq)2w!%`x7yg@>uGFFf-XJl4H`YtUG%0slGKOlXV`q?RP>AEWg#x!b{0RicxGhS!3$p7 zij;{gm!_u@D4$Ox%>>bPtLJ> zwKtYz?T_DR1jN>DkkfGU^<#6sGz|~p*I{y`aZ>^Di#TC|Z!7j_O1=Wo8thuit?WxR zh9_S>kw^{V^|g}HRUF=dcq>?q(pHxw!8rx4dC6vbQVmIhmICF#zU!HkHpQ>9S%Uo( zMw{eC+`&pb=GZRou|3;Po1}m46H6NGd$t<2mQh}kaK-WFfmj_66_17BX0|j-E2fe3Jat}ijpc53 zJV$$;PC<5aW`{*^Z6e5##^`Ed#a0nwJDT#Qq~^e8^JTA=z^Kl>La|(UQ!bI@#ge{Dzz@61p-I)kc2?ZxFt^QQ}f%ldLjO*GPj(5)V9IyuUakJX=~GnTgZ4$5!3E=V#t`yOG4U z(gphZB6u2zsj=qNFLYShhg$}lNpO`P9xOSnO*$@@UdMYES*{jJVj|9z-}F^riksLK zbsU+4-{281P9e2UjY6tse^&a)WM1MFw;p#_dHhWI7p&U*9TR0zKdVuQed%6{otTsq z$f~S!;wg#Bd9kez=Br{m|66Wv z#g1xMup<0)H;c2ZO6su_ii&m8j&+jJz4iKnGZ&wxoQX|5a>v&_e#6WA!MB_4asTxLRGQCC5cI(em z%$ZfeqP>!*q5kU>a+BO&ln=4Jm>Ef(QE8o&RgLkk%2}4Tf}U%IFP&uS7}&|Q-)`5< z+e>;s#4cJ-z%&-^&!xsYx777Wt(wZY9(3(avmr|gRe4cD+a8&!LY`1^T?7x{E<=kdY9NYw>A;FtTvQ=Y&1M%lyZPl$ss1oY^Sl8we}n}Aob#6 zl4jERwnt9BlSoWb@3HxYgga(752Vu6Y)k4yk9u~Kw>cA5&LHcrvn1Y-HoIuFWg~}4 zEw4bR`mXZQIyOAzo)FYqg?$5W<;^+XX%Uz61{-L6@eP|lLH%|w?g=rFc;OvEW;^qh z&iYXGhVt(G-q<+_j}CTbPS_=K>RKN0&;dubh0NxJyDOHFF;<1k!{k#7b{|Qok9hac z;gHz}6>H6C6RnB`Tt#oaSrX0p-j-oRJ;_WvS-qS--P*8}V943RT6kou-G=A+7QPGQ z!ze^UGxtW3FC0$|(lY9^L!Lx^?Q8cny(rR`es5U;-xBhphF%_WNu|aO<+e9%6LuZq zt(0PoagJG<%hyuf;te}n+qIl_Ej;czWdc{LX^pS>77s9t*2b4s5dvP_!L^3cwlc)E!(!kGrg~FescVT zZCLeua3f4;d;Tk4iXzt}g}O@nlK3?_o91_~@UMIl?@77Qc$IAlLE95#Z=TES>2E%z zxUKpK{_HvGF;5%Q7n&vA?`{%8ohlYT_?(3A$cZSi)MvIJygXD}TS-3UwyUxGLGiJP znblO~G|*uA^|ac8E-w#}uBtg|s_~s&t>-g0X%zIZ@;o_wNMr_;{KDg^O=rg`fhDZu zFp(VKd1Edj%F zWHPl+)FGj%J1BO3bOHVfH^3d1F{)*PL&sRX`~(-Zy3&9UQX)Z;c51tvaI2E*E7!)q zcz|{vpK7bjxix(k&6=OEIBJC!9lTkUbgg?4-yE{9+pFS)$Ar@vrIf`D0Bnsed(Cf? zObt2CJ>BKOl>q8PyFO6w)+6Iz`LW%T5^R`U_NIW0r1dWv6OY=TVF?N=EfA(k(~7VBW(S;Tu5m4Lg8emDG-(mOSSs=M9Q&N8jc^Y4&9RqIsk(yO_P(mcCr}rCs%1MW1VBrn=0-oQN(Xj!k%iKV zb%ricBF3G4S1;+8lzg5PbZ|$Se$)I=PwiK=cDpHYdov2QO1_a-*dL4KUi|g&oh>(* zq$<`dQ^fat`+VW?m)?_KLn&mp^-@d=&7yGDt<=XwZZC=1scwxO2^RRI7n@g-1o8ps z)&+et_~)vr8aIF1VY1Qrq~Xe``KJrQSnAZ{CSq3yP;V*JC;mmCT6oRLSs7=GA?@6g zUooM}@tKtx(^|aKK8vbaHlUQqwE0}>j&~YlN3H#vKGm@u)xxS?n9XrOWUfCRa< z`20Fld2f&;gg7zpo{Adh+mqNntMc-D$N^yWZAZRI+u1T1zWHPxk{+?vcS1D>08>@6 zLhE@`gt1Y9mAK6Z4p|u(5I%EkfU7rKFSM=E4?VG9tI;a*@?6!ey{lzN5=Y-!$WFSe z&2dtO>^0@V4WRc#L&P%R(?@KfSblMS+N+?xUN$u3K4Ys%OmEh+tq}fnU}i>6YHM?< zlnL2gl~sF!j!Y4E;j3eIU-lfa`RsOL*Tt<%EFC0gPzoHfNWAfKFIKZN8}w~(Yi~=q z>=VNLO2|CjkxP}RkutxjV#4fWYR1KNrPYq5ha9Wl+u>ipsk*I(HS@iLnmGH9MFlTU zaFZ*KSR0px>o+pL7BbhB2EC1%PJ{67_ z#kY&#O4@P=OV#-79y_W>Gv2dxL*@G7%LksNSqgId9v;2xJ zrh8uR!F-eU$NMx@S*+sk=C~Dxr9Qn7TfWnTupuHKuQ$;gGiBcU>GF5sWx(~4IP3`f zWE;YFO*?jGwYh%C3X<>RKHC-DZ!*r;cIr}GLOno^3U4tFSSoJp%oHPiSa%nh=Zgn% z14+8v@ygy0>UgEN1bczD6wK45%M>psM)y^)IfG*>3ItX|TzV*0i%@>L(VN!zdKb8S?Qf7BhjNpziA zR}?={-eu>9JDcl*R=OP9B8N$IcCETXah9SUDhr{yrld{G;PnCWRsPD7!eOOFBTWUQ=LrA_~)mFf&!zJX!Oc-_=kT<}m|K52 z)M=G#;p;Rdb@~h5D{q^K;^fX-m5V}L%!wVC2iZ1uu401Ll}#rocTeK|7FAeBRhNdQ zCc2d^aQnQp=MpOmak60N$OgS}a;p(l9CL`o4r(e-nN}mQ?M&isv-P&d$!8|1D1I(3-z!wi zTgoo)*Mv`gC?~bm?S|@}I|m-E2yqPEvYybiD5azInexpK8?9q*$9Yy9-t%5jU8~ym zgZDx>!@ujQ=|HJnwp^wv-FdD{RtzO9SnyfB{mH_(c!jHL*$>0o-(h(eqe*ZwF6Lvu z{7rkk%PEqaA>o+f{H02tzZ@TWy&su?VNw43! z-X+rN`6llvpUms3ZiSt)JMeztB~>9{J8SPmYs&qohxdYFi!ra8KR$35Zp9oR)eFC4 zE;P31#3V)n`w$fZ|4X-|%MX`xZDM~gJyl2W;O$H25*=+1S#%|53>|LyH za@yh+;325%Gq3;J&a)?%7X%t@WXcWL*BaaR*7UEZad4I8iDt7^R_Fd`XeUo256;sAo2F!HcIQKk;h})QxEsPE5BcKc7WyerTchgKmrfRX z!x#H_%cL#B9TWAqkA4I$R^8{%do3Y*&(;WFmJ zU7Dih{t1<{($VtJRl9|&EB?|cJ)xse!;}>6mSO$o5XIx@V|AA8ZcoD88ZM?C*;{|f zZVmf94_l1OmaICt`2sTyG!$^UeTHx9YuUP!omj(r|7zpm5475|yXI=rR>>fteLI+| z)MoiGho0oEt=*J(;?VY0QzwCqw@cVm?d7Y!z0A@u#H?sCJ*ecvyhj& z-F77lO;SH^dmf?L>3i>?Z*U}Em4ZYV_CjgfvzYsRZ+1B!Uo6H6mbS<-FFL`ytqvb& zE7+)2ahv-~dz(Hs+f})z{*4|{)b=2!RZK;PWwOnO=hG7xG`JU5>bAvUbdYd_CjvtHBHgtGdlO+s^9ca^Bv3`t@VRX2_AD$Ckg36OcQRF zXD6QtGfHdw*hx~V(MV-;;ZZF#dJ-piEF+s27z4X1qi5$!o~xBnvf=uopcn7ftfsZc zy@(PuOk`4GL_n(H9(E2)VUjqRCk9kR?w)v@xO6Jm_Mx})&WGEl=GS0#)0FAq^J*o! zAClhvoTsNP*-b~rN{8Yym3g{01}Ep^^Omf=SKqvN?{Q*C4HNNAcrowIa^mf+3PRy! z*_G-|3i8a;+q;iP@~Of_$(vtFkB8yOyWt2*K)vAn9El>=D;A$CEx6b*XF@4y_6M+2 zpeW`RHoI_p(B{%(&jTHI->hmNmZjHUj<@;7w0mx3&koy!2$@cfX{sN19Y}euYJFn& z1?)+?HCkD0MRI$~uB2UWri})0bru_B;klFdwsLc!ne4YUE;t41JqfG# zZJq6%vbsdx!wYeE<~?>o4V`A3?lN%MnKQ`z=uUivQN^vzJ|C;sdQ37Qn?;lpzg})y z)_2~rUdH}zNwX;Tp0tJ78+&I=IwOQ-fl30R79O8@?Ub8IIA(6I`yHn%lARVL`%b8+ z4$8D-|MZZWxc_)vu6@VZN!HsI$*2NOV&uMxBNzIbRgy%ob_ zhwEH{J9r$!dEix9XM7n&c{S(h>nGm?el;gaX0@|QnzFD@bne`el^CO$yXC?BDJ|Qg z+y$GRoR`?ST1z^e*>;!IS@5Ovb7*RlN>BV_UC!7E_F;N#ky%1J{+iixp(dUJj93aK zzHNN>R-oN7>kykHClPnoPTIj7zc6KM(Pnlb(|s??)SMb)4!sMHU^-ntJwY5Big7xv zb1Ew`Xj;|D2kzGja*C$eS44(d&RMU~c_Y14V9_TLTz0J#uHlsx`S6{nhsA0dWZ#cG zJ?`fO50E>*X4TQLv#nl%3GOk*UkAgt=IY+u0LNXqeln3Z zv$~&Li`ZJOKkFuS)dJRA>)b_Da%Q~axwA_8zNK{BH{#}#m}zGcuckz}riDE-z_Ms> zR8-EqAMcfyGJCtvTpaUVQtajhUS%c@Yj}&6Zz;-M7MZzqv3kA7{SuW$oW#=0az2wQ zg-WG@Vb4|D`pl~Il54N7Hmsauc_ne-a!o5#j3WaBBh@Wuefb!QJIOn5;d)%A#s+5% zuD$H=VNux9bE-}1&bcYGZ+>1Fo;3Z@e&zX^n!?JK*adSbONm$XW9z;Q^L>9U!}Toj2WdafJ%oL#h|yWWwyAGxzfrAWdDTtaKl zK4`5tDpPg5>z$MNv=X0LZ0d6l%D{(D8oT@+w0?ce$DZ6pv>{1&Ok67Ix1 zH}3=IEhPJEhItCC8E=`T`N5(k?G=B4+xzZ?<4!~ ze~z6Wk9!CHTI(0rLJ4{JU?E-puc;xusR?>G?;4vt;q~iI9=kDL=z0Rr%O$vU`30X$ zDZRFyZ`(omOy@u|i6h;wtJlP;+}$|Ak|k2dea7n?U1*$T!sXqqOjq^NxLPMmk~&qI zYg0W?yK8T(6+Ea+$YyspKK?kP$+B`~t3^Pib_`!6xCs32!i@pqXfFV6PmBIR<-QW= zN8L{pt0Vap0x`Gzn#E@zh@H)0FfVfA_Iu4fjYZ+umO1LXIbVc$pY+E234u)ttcrl$ z>s92z4vT%n6cMb>=XT6;l0+9e(|CZG)$@C7t7Z7Ez@a)h)!hyuV&B5K%%)P5?Lk|C zZZSVzdXp{@OXSP0hoU-gF8s8Um(#xzjP2Vem zec#-^JqTa&Y#QJ>-FBxd7tf`XB6e^JPUgagB8iBSEps;92KG`!#mvVcPQ5yNC-GEG zTiHEDYfH+0O15}r^+ z#jxj=@x8iNHWALe!P3R67TwmhItn**0JwnzSV2O&KE8KcT+0hWH^OPD1pwiuyx=b@ zNf5Jh0{9X)8;~Es)$t@%(3!OnbY+`@?i{mGX7Yy}8T_*0a6g;kaFPq;*=px5EhO{Cp%1kI<0?*|h8v!6WnO3cCJRF2-CRrU3JiLJnj@6;L)!0kWYAc_}F{2P))3HmCrz zQ&N&gE70;`!6*eJ4^1IR{f6j4(-l&X!tjHxkbHA^Zhrnhr9g{exN|xrS`5Pq=#Xf& zG%P=#ra-TyVFfgW%cZo5OSIwFL9WtXAlFOa+ubmI5t*3=g#Y zF%;70p5;{ZeFL}&}yOY1N1*Q;*<(kTB!7vM$QokF)yr2FlIU@$Ph58$Bz z0J?xQG=MlS4L6jA22eS42g|9*9pX@$#*sUeM(z+t?hr@r5J&D1rx}2pW&m*_`VDCW zUYY@v-;bAO0HqoAgbbiGGC<=ryf96}3pouhy3XJrX+!!u*O_>Si38V{uJmQ&USptX zKp#l(?>%^7;2%h(q@YWS#9;a!JhKlkR#Vd)ERILlgu!Hr@jA@V;sk4BJ-H#p*4EqC zDGjC*tl=@3Oi6)Bn^QwFpul18fpkbpg0+peH$xyPBqb%`$OUhPKyWb32o7clB*9Z< zN=i~NLjavrLtwgJ01bufP+>p-jR2I95|TpmKpQL2!oV>g(4RvS2pK4*ou%m(h6r3A zX#s&`9LU1ZG&;{CkOK!4fLDTnBys`M!vuz>Q&9OZ0hGQl!~!jSDg|~s*w52opC{sB ze|Cf2luD(*G13LcOAGA!s2FjSK8&IE5#W%J25w!vM0^VyQM!t)inj&RTiJ!wXzFgz z3^IqzB7I0L$llljsGq})thBy9UOyjtFO_*hYM_sgcMk>44jeH0V1FDyELc{S1F-;A zS;T^k^~4biG&V*Irq}O;e}j$$+E_#G?HKIn05iP3j|87TkGK~SqG!-KBg5+mN(aLm z8ybhIM`%C19UX$H$KY6JgXbY$0AT%rEpHC;u`rQ$Y=rxUdsc5*Kvc8jaYaO$^)cI6){P6K0r)I6DY4Wr4&B zLQUBraey#0HV|&c4v7PVo3n$zHj99(TZO^3?Ly%C4nYvJTL9eLBLHsM3WKKD>5!B` zQ=BsR3aR6PD(Fa>327E2HAu5TM~Wusc!)>~(gM)+3~m;92Jd;FnSib=M5d6;;5{%R zb4V7DEJ0V!CP-F*oU?gkc>ksUtAYP&V4ND5J>J2^jt*vcFflQWCrB&fLdT%O59PVJ zhid#toR=FNgD!q3&r8#wEBr`!wzvQu5zX?Q>nlSJ4i@WC*CN*-xU66F^V5crWevQ9gsq$I@z1o(a=k7LL~ z7m_~`o;_Ozha1$8Q}{WBehvAlO4EL60y5}8GDrZ< zXh&F}71JbW2A~8KfEWj&UWV#4+Z4p`b{uAj4&WC zha`}X@3~+Iz^WRlOHU&KngK>#j}+_o@LdBC1H-`gT+krWX3-;!)6?{FBp~%20a}FL zFP9%Emqcwa#(`=G>BBZ0qZDQhmZKJg_g8<=bBFKWr!dyg(YkpE+|R*SGpDVU!+VlU zFC54^DLv}`qa%49T>nNiA9Q7Ips#!Xx90tCU2gvK`(F+GPcL=J^>No{)~we#o@&mUb6c$ zCc*<|NJBk-#+{j9xkQ&ujB zI~`#kN~7W!f*-}wkG~Ld!JqZ@tK}eeSnsS5J1fMFXm|`LJx&}5`@dK3W^7#Wnm+_P zBZkp&j1fa2Y=eIjJ0}gh85jt43kaIXXv?xmo@eHrka!Z|vQv12HN#+!I5E z`(fbuW>gFiJL|uXJ!vKt#z3e3HlVdboH7;e#i3(2<)Fg-I@BR!qY#eof3MFZ&*Y@l zI|KJf&ge@p2Dq09Vu$$Qxb7!}{m-iRk@!)%KL)txi3;~Z4Pb}u@GsW;ELiWeG9V51 znX#}B&4Y2E7-H=OpNE@q{%hFLxwIpBF2t{vPREa8_{linXT;#1vMRWjOzLOP$-hf( z>=?$0;~~PnkqY;~K{EM6Vo-T(0K{A0}VUGmu*hR z{tw3hvBN%N3G3Yw`X5Te+F{J`(3w1s3-+1EbnFQKcrgrX1Jqvs@ADGe%M0s$EbK$$ zK)=y=upBc6SjGYAACCcI=Y*6Fi8_jgwZlLxD26fnQfJmb8^gHRN5(TemhX@0e=vr> zg`W}6U>x6VhoA3DqsGGD9uL1DhB3!OXO=k}59TqD@(0Nb{)Ut_luTioK_>7wjc!5C zIr@w}b`Fez3)0wQfKl&bae7;PcTA7%?f2xucM0G)wt_KO!Ewx>F~;=BI0j=Fb4>pp zv}0R^xM4eti~+^+gE$6b81p(kwzuDti(-K9bc|?+pJEl@H+jSYuxZQV8rl8 zjp@M{#%qItIUFN~KcO9Hed*`$5A-2~pAo~K&<-Q+`9`$CK>rzqAI4w~$F%vs9s{~x zg4BP%Gy*@m?;D6=SRX?888Q6peF@_4Z->8wAH~Cn!R$|Hhq2cIzFYqT_+cDourHbY z0qroxJnrZ4Gh+Ay+F`_c%+KRT>y3qw{)89?=hJ@=KO=@ep)aBJ$c!JHfBMJpsP*3G za7|)VJJ8B;4?n{~ldJF7%jmb`-ftIvNd~ekoufG(`K(3=LNc;HBY& z(lp#q8XAD#cIf}k49zX_i`*fO+#!zKA&%T3j@%)R+#yag067CU%yUEe47>wzGU8^` z1EXFT^@I!{J!F8!X?S6ph8J=gUi5tl93*W>7}_uR<2N2~e}FaG?}KPyugQ=-OGEZs z!GBoyYY+H*ANn4?Z)X4l+7H%`17i5~zRlRIX?t)6_eu=g2Q`3WBhxSUeea+M-S?RL zX9oBGKn%a!H+*hx4d2(I!gsi+@SQK%<{X22M~2tMulJoa)0*+z9=-YO+;DFEm5eE1U9b^B(Z}2^9!Qk`!A$wUE z7$Ar5?NRg2&G!AZqnmE64eh^Anss3i!{}%6@Et+4rr!=}!SBF8eZ2*J3ujCWbl;3; z48H~goPSv(8X61fKKdpP!Z7$88NL^Z?j`!^*I?-P4X^pMxyWz~@$(UeAcTSDd(`vO z{~rc;9|GfMJcApU3k}22a!&)k4{CU!e_ny^Y3cO;tOvOMKEyWz!vG(Kp*;hB?d|R3`2X~=5a6#^o5@qn?J-bI8Ppip{-yG z!k|VcGsq!jF~}7DMr49Wap-s&>o=U^T0!Lcy}!(bhtYsPQy z4|EJe{12QL#=c(suQ89Mhw9<`bui%nx7Nep`C&*M3~vMEACmcRYYRGtANq$F%zh&V zc)cEVeHz*Z1N)L7k-(k3np#{GcDh2Q@ya0YHl*n7fl*ZPAsbU-a94MYYtA#&!c`xGIaV;yzsmrjfieTEtqB_WgZp2*NplHx=$O{M~2#i_vJ{ps-NgK zQsxKK_CBM2PP_je+Xft`(vYfXXgIUr{=PA=7a8`2EHk)Ym2QKIforz# tySWtj{oF3N9@_;i*Fv5S)9x^z=nlWP>jpp-9)52ZmLVA=i*%6g{{fxOO~wEK literal 178939 zcmeF42Vh&*b^gIUF^I{%_YjvTQHvraYD<VM@1HZ7cJB^-KQYQQ=Y3Ho{nO`vm)~#u z$7oYI?|Bqgg4a2iOr&G*Us_t43FLqefvKXtYR&;4tEcI-amj3fHR+MNt5L3k|p^A$;16#)Ad>K{xg2BX--d* zlpm#t?e`W*%NsTy|9-~r^|$6Uv2C|W+S?Av@5mOnJRkb^`k6aT5^hM9xbJeFiQG=fEc`yh|DL><#V&K2R;g6I0Y?*TW^GH3=D zfp-JF=h>j&*#hifusIm@d$lu|IuqtBV1EKPz~&A9(`SVc&9Mro+^z;%{zn7-&1Ikw z!~x^JdQ1Ty1N%V_P`fe~^zyp{;0wS3jAy)`bLAskhtBu>bKEZms2zQHB=@$tZDLCw zvOElxmRGoEbqJcLp}uqK8hW36NwOrpBk9z&v;XEK_goEXz`5^F+7rGUF9|=47hCRt z9Xi{yI=Jte5#67(TN|)D_a}<^8SLCj>JGIxXHWmg@6Wx=|6mdG5sP>_9pe6i<6QUF z&qsED>Ws8SHnHrpiPP(nLSLQ~AIK5s25gspHhdn2zrWg@kiB)bVVCc52{nu4`g3K0 zf37r3t&}{KEAES(f;9*}=S*8QFo5@QFoa?hr<>!q1+a26@8@Bg<6U6!$by8PmAkBFad{y?r6f8e^-g_@6Yhh$#k zk=(noB-5Xc^gUwp7fXU~xy1Re60`praXr{B&UfWWS{3qfa$kOXHu;2o7W^*y;V7|- z{U&tZpCB<_>Rsx4Q{N^@yroraHJ)JodHQ{gXAGVGQ~U(Kr+QRI+5KaJm^#d2I$kO< z4>XFUfqQG)X7KkmVzQWC%8=v_W(=0aP|q3p{WbqpX%hSEB#GW* z5$ht#ZzSyldC>Mx@~2WH@p{^wS;MwF!t-#S5rEM9b{?)d_2Jk!Z0@y!B zyu|Oc|Do-U!EFeARw^h0rDKHlja1%7x(7FhBK}_6VfmmHXg@IUryal{{=(D6c`V2V z+D4cYLF99^!>M9FY7^I9%1z;@ zIT+jX$-8ZpRZ?DN+@mv1GP>Q8cQQj<@1$-&ciSOc2BUwz-oF&?Z?%clYZrIFM+&|9 zQXz#>@I__Pe0f9=b-c&2-~P23-~is$!E$vm9FGjjs{4joI&_vcAnf0?w??^xg4 zBJKV*`cR8yEYm=ixZml=b3Z@) z`{;!o9ddlwCdnQ2>HP5$P5C$V)`3+L)wxBI{qdjAHS#66TKrngeX^m>*=JzXm1mB@T# z`98nrYZ|Z*DW9Xy`)rb!p0-QEP3ep&bA5QOjc0}*$CiJ6KKZm=Y?J7_=zHIrBIduL z-#T)+8)+E(^U0^Z%r5cYNtBqMB}f`Je?p&+4D1fOnE%NlDW9hekj?W)CwrBFk$>$& z-ZV@ZHDq<>QDwmRjD0T8R!&Bbd-#q1X&>M^-~*$(kLG#wyc^H>_t3NT`A%@_sGmRD z^q%_u<2ib`Veqf|A(nmk{z8@?B;mPyvL42QkeI2|LXq(@7 zUZ6J~{yywn`-hQ4RM@=(&)0|V*5QFk`qO9YIEBs??F0kk6vezb%irL940^BmoJb6C zIVc^&=3vnGv=6!t{1f;u@WlznfAhTE;Brt5PScaYnc#CHzdE<}SKtAl<8qNMtE0W2 z+Km^%r@jyvi2(^&62k-z)sp!Dll)psJEcCE)p-+md19G)Pp;bkG0_s>Q;{k9C|pL6K% zM4nT%E31K_L$#bAjp%deQziUOg2a9%Hn6@Z!aQgheOFle>o`9SA|oqw##+w0nD0eP z)bFDtbydpwv4lCKSoK+{n3*2k;Ku=GYyyC!Pmzx{fsLl{wuok z7-KAt$4Syp62&(9amc~x9sGWL(yzKxW|jEgvi9Qn1WA5ANz6|$mb;d@?9uh32d8)N z`|(LXX*6#(llDYOel1xnuhS1aXc60|NPnctSMWaLlYZ<@%JnIde3<_G+h(yJwu$E? zYe?>5%<9y7yh!9F^6A&{hb2}?emYfBPa^M=j2U(~CA-_hSa`ZP-h+J`d%tvWo+F!n zt!Fb?SMx2_lk~8jw41Tc9+zbGX0XO1hcQgXcpqXsrXi#3^W2)<^&OZ;4Nk8e(@k{4>IUZuX%Fj3|^9XJq zYhhS_RO7Fb`ThoJV%)frvF4J#97+EQdB{8OJe*(pRp#isvzT%DPdmkP*uyw;y0}=o z;{jRzEGb3i3w(^e``cxuf2qtRFLPKWRM}rBIp0T@nkX;I!`QeOefmRb4ve9*4k+_# zhh*RGk*uCf)*R`&qabt+r3k&L^Ono9{`s<{f0b-veeW{=0%?YeMsiUnRZ_aIK+-?# z5>^9uHen-3#TSzBXCqYm*k{Vw%avTwaajqPCy83f8t|{-0AEJJG2+z?$GdKF-d| zxzkVD-MMzjSxdSh|LT}hJiMe6HaHnGn+>loxY z)317xdu^H|F_#_nQ34iH)ObO|)LH^BM%ma2c z%R=vR%JF*Ay^%DpNAjzHuE%3e%3m#I%q68CNt5_zc-Dg^iT+bG^9j^{I(MKtaAw_o z&h+c=vRTjQ`PWo2-<%+cjEh@duu3{<&+TX4h&1N=SzE6?oZ~g*jQAU1GI{dWTB#HePDH88Tm#G7yy$xdOUk)}&RR85%yIK+-UoDo+*`$SZ zpWQ}=r+4uA==3K%-Gk4OonsDl&>u**#2{z-yPr?Yw=1901m-O39=)3=c zdF(gg;Wg%RUvZ1+)dGoryhJR^SpTl&baZ+$-1j4&euIO5wy`#v^s~1?=b=r{Wl|qy zj%6--xU}o_@kzgygXMOKyAS=Rtzr6$S)v|xh~?e1GskXghRVnIq#v7Vr(Q_@4!U!9 zoS6QYC~>!0#lCnwS*~OqAfYLxpX6~LmkI2{pgUR z-6?TDiI=Ef#7Nq^ko~#a14E_pY}dvw{iM}V;E>eo8OQoTqBxddcOt9%ny>Km>m2)m z2-&p(nJEX3E%fJUzef1pI;VFfFvkC_oc}4p&j`vq@^V*M90c{iNWUI+o;T8R8n65P zjI<^VN`DUTbq&RMJu_1GRoS;2X&*HIyNv5PR~)HlMfyG`NSl^hU7Hlpok8i>YfHf& z!RXfwjc>l6Cr#G^ohuzkyQW|NjBBBz&JXMS*ss7-;FU?j3p`h4xf@h~fpi8_eft05 zpNGy9Ic9^BNkRe7)qUdw>DKde{SE&9RC+%+?fdmYg2@y(#+Xcd^*t+>cI$EWZ_EZ&QC)95I3Y_a+)AjS$$lFpQzeD8z zoqVSLW~OWYMv`vrBbrqP#-E-8wUgSW9?3nX^LLJs$D#U}EnGh`q50P_jPV)AI2S*< z=6b*mhR*+vqpp8E*KZ^Cxw+mfDQ)=q8M!Z{NIhF^ocf3e6ahVgPk>0>|Lpf+9MM{2 zm6-owPW>lQlCpYS)`6Za4O+K5G~fECN3a{5?KhG844v0Jn|{OEg}o+8_(=Rv`)wol zyfgEq<6)DRf7awAe296tyG#;wca+55%vxsFc8GS$4cr&l!3_2;SHB>WfK|`YZOFmrPh0n4J8h`?f-SeEmF85?&_n`^mTZ z<9IDqY|pU1=c0(OX=|Hli9!L@Eo2(@}XcgCCWb<#V2S-09 zpbSh-{#j3(`q>modK+ITZ>Ngoutn@g@L6$;b(0;et-Y7EQdN|J@oy7OeE!LkZ9Z$z zA13c7&0;xDK3Nm(>R`=cr(1G*(j}L*==S$TY#qwk^k`!9Pr28%tCs&V;|szp=1!~F zx>$|Y?UeK$59>8q%g%b)BG&h2Kj0Rdu5}$>9hlhsYhLhYVt$=9{C)Vs>18cOFKe^= z@RQPyuMlspl(1g4ly$--tQmG+PdU&&fy!-s>cff4KY6#eu;1<>_5gT;djQhw7Ex71GEaf_eBQYGfULCF^6$Sa(|RCjOD$jSL*)B7^bGe@JiLtS?W$m;B;; zN#Ou4zph7ReLU+>i^*$)zgCv|7s?8M3v1x#Nv*#O85FRmqCkq?%ogWAP!_TxZV$#M z|60z0vnWlnK8#OUe4wZMGsy2Lq~i}t_h1yTw!0cXt&7-)vCg+#w)!{7I{z}((KoUm zqgv|Gi&`|H@??=@egj`I&FF%$uJ!!wLgezVY0-5}wB6mT8P2}WDY?I+Y@cB5v5!^L zzHIVqfIShM=VRx}eMQpft(4aOCfU&6CfoYg$i?`>ZTBrg22HHVuV)`YEo<^?qz+k> z?8_6+zp&PB9&+%Y5878!d5=vNW6!@nPoX@!Sf5OubGJGq=QH3=mt?+$&#xXZRZ3e=y{zqSmW|y@WMls_S`l}CBf3}0So?1r)fZSL`JdNY5!gqvva?ZEcg>eI{Y%-8v|L)j zBK(uh$0jt%A|x;$U1$jCg6=7);`fEeu_KSuj`$XSzurT?VPSB6W1zk~w@!>Y|LS8c zuZ4IBA7S6)*YGd?<5-EkJzC=KkC#;XF80?Q;yH?4>mu*H8dr(u-fY zBeW^@$4mSp(UNcn>9`TUhJVE#yK}FJ99{mArze}df6^+^-(k$^X7F>yZf=i~gume9 z`XziC9`ewJ&z2nZ`=)zu@clLv_bP)T@?Qr3HNBNGue(kblJ^BY?0;e}*F5ZCqg+f* zHOE}JxIlAADwn9-Kbp!pT_@@~|{0nJeEXlNov9#Z^F0t*L>k>zo zf7)OU%6h?-)MqykljDc@(Y%%M3)a!5>?3Byn{LVMgmc}y<1JwS4j_+1?cdS->t{vy z7%%UG%icz*?p-WZeeINq4N~FXiiTfGJ7^o&LOr;V9c^pS`DI`sZKZlC!4BkfvbW?- z#*v<8P5VPp_|}S+_+Q71^>eK0#n;t2Y{97WujNYZU1kM)eJ;kI!_}u?HwecJLcw zcHk$k7rNF|19#K?!)IG`=IRT zy~Vc$pMX2qpR-Hsz|CHwOy1|Ur)aWmobL^q${wely^1?#W9wIIPdXh$2PNlw2 z^sQze)i#MH&++V|O7UMOR*nwdd(ejr_O)dkUm?!lRF36%ys!EGGYz>=D|< z-mGgS8Cd++&|kP*(jHtQ)^||e)o-uvu^D^2$LLQ+KL3U+LOS6r#6J8#r)0dXd(TL- z-y%ewU>}!-eB0SGmq|YH!S8EePgJXzDE}t!rJV1OSnp2cf`7^`{A7N&L9C6sM}d3j zy^ZIb-*No%Z=?&3?D(Ga;Ahvtew|cyuO<4at9ixxQ^>cIJ#2aGU8`YV)dH{rznB}@ z8%8yF`PXzRU$mQ?^kY*G<9Ec*{x=_c$h_=7>9>;K zO!mN)v8Rl^eBCWzHMkhxpqq%XLf&&jx*nN4hwIM7yYAcmcl=*>MF;oL^^pH= ze1S6VXX+?m4_!5w4=4v6*uq=t@RKtxyc;r@xcsXOv@GD?IOX^FAMJ+!ljQ$6^Pk5Y zVmit`yd$OT$zw0!(FGFq)Li@m>7FXMk38?jJtsE*nh&k3F11PQtK|JKIK*DQgX}|m zGhIvv(1ABAK%FFfmVK12h}t?M&*8_3&p)=no@{u*uL z;eBeHZ+-{=ep2)AnCFzFUs48cr9JSwSc$nkiLrikKXUEc!TBBhe)9599vxZCg?tga z_bb{0zlfH^pQegq(S+%~%3|{JuVnxkIN#;M7dc}$KQ@Vt`94SPxa^s_i(H)#BU39&38fU5l7&4lGBja`W&zeBHXXHtJDF^n0gsuO~)tsUSq~ibeF(7}-wkw+-%OE#m%Q8v0(Bn8)ADY-(d!|oZQKmBo}AD<5j-!_GS~f! zp8_M=2g&yg8R#(=XuIHU@HWu$qq3aJ(EVG-f%;AV5?BCKrw8(7@IBly{JWuZ-77F3 zXuY9(#59h=RD`B&7gz!Ez^L*)SRVX-KxWhZd~n`o-v=ci!NVs4egjOVyko)l*8Ra_ z!rtI9CUlJ29eh9dIN;YI^!e=jpqwU34pDnUyo8Q1`-AUeLVP9|{Q85}mrCeQU1MT|_zUNGQ{~Y;T2ZohV*k@{M zZU8e;4rj~LGvv9+ki%dd3SHN_={-Ql%FcGLnflo+JaZ0YIjt>CNJ+g&#IWrG^DZnGgO}qDqlJV z{qkg{P2&})kAex@k3SR_I_{`Gs|@iN`m=y*Iu19~Z^ri;I%CbVO58saOXJHilG>U& z*?ROpL&#?#*VI0ZuPlbTKl8dN?W}9K#U!Rbm?ZwA6Yke!aGr0NQu1LfY{Cav@3IH^ z+-Z`Sn_|RL$=)U8HYt1s+kb=0*W~DrmM!%ObYrYU-OGNKd!i-g&S**5IN`p5!nv3_ z`h$+7u1J+=WD@frdyhce!?BX|N#Y(&oZpmi+35Mykq`DL=|hPU^B8go#kWk{hmVn; zCW^Im!u+aCP5Dr^bS-`S_u?h)*^u9vXNaal49(O>**kR+`vxb+22Bn9A@7!DW{H20 z*rNNih#{DNxKB@;T zRDN~GZ0>_6bXLe*XljVcWu~(DF zTaZsb_NO2F+wWkXH9p3?#Fa%~)bCJv!0%8QaXw4gTVKe&dv>h9k}kH(@GCJ><%4V- zRrnEhx`&%_{;G@Q$u{?+CYrsImoCSza^?ixz7+I_>z!} z#<#3ZT=~*`ARE_Qd>Z`NAe7P4L=}*T$!6~ReC-rlrevQ<(PbK@h zo7vaB(zjGD#+S)O_-<%bUp4{1M&*H6(>3@>C^?WP?oT>`zF*azMP8T2Pd=Jf(j1UW z3$c{H5}2YFAIK;)W20m2zstQkW@Bh_-?7k?@^1lN!EGW57xs!XA8(H{hp9}t0Kz(+*TKZeHkuEH-$Q-77T_BP1c-bJ#xcbRNq zZ~S`iGHEBK@e+SCGHSv%P9raTrlCy@cu1){TqL=_%3v=E`w5yTcNrmlI=`}a-tq~= zQAaN7KPIyp9~qZ8q~PB<-i|Ms=kNh|l=9SpSB!3AZujFqhj`fmzd`CdDC9p#y@seK zkz(Xi-Cu&=B>ZM|*UGA{xw4)Z)*E_T(52=0P;0}N+EVP&VtgkpL`LdADkvw_r#dWC zWhcHlo+cLj&D4>9M|-jb`=tIuLi#+)GB|em@I05tE_n_3%GiP*mEHId`X0Vu|HPQY zlk_k5(?@s<`5dE65sy5p2id4krD1$Z~BCmJr%MPze+1Qu|dQrUxk02mA++x zIOR)-dA|_BHonF>C{sQ7 zS?O2V1br?I<#$P=Sr^mhsX~7mi9Ngs`LuP^OB?cO>sx|-ZbuqxWFdZL@Wh2gRw0|^ z$Ym*5h;*9JpIX{V<@g}NHy=LEJcq23`VwPGPvFD*0en#HNs!cUnz2>v=|?+g2OIKHT^al``riSo6et4S7gFOp{bvd#0arT)?w@fRbDjmTmH(oo-2D}cs}Ux4m3BA+UJIN|>X z-!G20EWx<(52>H?;GBrgij6q&Yx|@&v)wdAeSS#_3MQnKdfT>@sWc*@TI0pTLUCs9| zr(JmociV`aTP~g_YsG$jwph2>#abDfzgKyTPA1{9i9(ktNq=i@IQBaNipj(_=#%NSFBjQ%@5$83J)ZUlepypqUqBJzsI?^rD3 zJ~7@pe2p!}7u70&4)t%x7nk}TyE@=|Ea}aSlDfNCY>dy2ork zcc?I*6YxofFH?z^7(esN_$7-9_$8~tSJgbwhM%srU^BkSE|nPdP4?P)Nq$dm&p+L_ zS7|!A1gya4*D6W)?~;j}=b1eDz`go?vwguV(H+R96LcV-6K3S##P?Ya{?5>$BXc<7 z`|VhZ#N1IMmKw@acYIPy7yPoTrBA3J2nH(G|6-a?1o z!Y|rEZ1w(nNycBsIQxYgET_qpkID!=vVF)VF$eIKq<+(g8)JGM--)l`JMcC9roCDu zrZ=eXf09pZo#6M!(H>7d`KS&x;s^MC^hSN_?Z>a&i!PV5nXe9lIfxR$c+C1*r)RO6Yxe;h(Sx~FjOq{$~#&I0xM zf_y0`LQ40#yx(PQYE z`px<`px>JgTt_;M50UR85Rk_Z^3m(6TfYa9e)d$q-$C-c6`Ua(Lr%tL9BaXSV5;XS zQt5k}yj}+e`~w*>2|x0=QO@+J_5CkFKZsO1rs92GB7au{^)oxH?ig}1z7smCj~n%g zv=7WQIca(N7SMgS>UU&7Hw;+}cMSh-=(lRK{s#OAsJ|%nBk;;J#8agCHt-*y1tfz3 zx#;<5{s#Y+_v%kd?RO=pnubuG1OB@?j#(~4$#C%fX2ScS@;Q5LbP|xDBSi-9Os0?z zMbjrZ_l9nh$1&t<(PZU(f9QHb*m(@+dqda5&!f1uJ9K^aJSd1+IZVDB_J--Cajts1 zKXg6(T=m@0e?1TR8x52Nqr5ETy6ojYT#afuGJKHgx%wg93HE{kKcwoEboOuBOJF9{ zq2rZ@@gjGa^d@m#|I&eu0WG~ipl#?fp#J|YAPz*d-5Ac}pnJ#jz6R_7H-bmNo8Txo zb^$^CvuYn$$BaG+Rs-#W4Db*x!?B!)--~k{!&4pCK9u&SE_8o{f(*iOlK0xj)bSd% z2j|U0*gbTP;)6it9{$YP^E2hqiHy`=bSoIq*w9dAgWnqb6?6VQ&!oLz=b+*aK8Gcb;SF?h&kZ9hTiKK=}q8#({Q2xUOBkTkn3Q5 zAN)S_y#$V0r_Z#p>B-Ustv4G&vK=h)f%nGe9G8IuV6xIX6QBEC9XXF4{o z-<^pvn9Mw>9oiC-@qo@7C&qP-tHA4EGSfO!pZ#s*s{Lg{>;p%=26VpeQ(&g%f3oxS zDzcpm&S;N@u4Quk9hmHNj_momUQE}4Pwu+0k)<^#Q*FoVxXp0#S8kM}(cE*=zH2SO zUjY8LZRr!TH#1WC{37zz_T_->(Gz_SwB0lH+nngUWsXJSK7k*bFGow#6-m>HgWn)y zv&uXCPv3(TAW}S!-+l1KlXx9_n|{ka-8)PY{jF#**G-zw=h5c#PGlTd>oA1;+o!zz zvGvwMtHgem{Vw?aQTa#R%HD-7$wEZh(aK^nzQ1=`%OBg5x;Ry$e#VsRUSzMhGfLwA zH7;m_rhfUI-tt%5vy1(d$UN#Ud_3J19f<7^`(t8XRO1tSR{rBE16z(w;=W2ujr)-O zee5Z_kJu3p5F_DFv68$!XpY*PzV7!#ak^SRw68|_c9-fGoB=*54|0FSJgS1aJbvc-}@>hTU313YJ z`1p%|3b{WWFNx0}_fYJSl!x%jbQ!)ZCvX4eNO+%~^4C7s0%Drn7BBHHBKzkPB=Lnr zNq!OksxK1TWIsMlUnW+?zY^obGo|~((^mc|?@W<+bUxwbL`ek6uONG3%2-|v#+9+- zAJmFZ1#9i3#0D9O?(27^pZw`_*>bIt^pzw@IDqV5Pm<)HWPboZn#8TKzh%XL zE_=#fAg;s~`odFpOm6zgAKPPHVv)pqk^P}$Nj{h&siC+ywnNCCm_aU$jdRo?=|}MY z{-5Tc4Vs#D@br^Eeh|$cOp(Mlkv;yjQVtV$2Uw5b!}=((ACBRl{WyLSPvWz_(=F}? z;cG57Xlj;$=_P-)JvGFG+LI(n$5JKbII=&Eoj*<;djdZ?CyDKI693D@J<9I#;OjSC za!+`~`ccZj|S3NMj6fp%c)J00TgLiXKm$yT}d zW=MWtCO)2t*KnUxtP7@OJv@Enul=YNif)&_e{Hj1 z^Bq^9x6d=b>$L~seOWc;m&Uas=9klpzie*?zUPS*huq72#l#{gBVI!V(D+{^f!Ix2 z21+O!&YR$_iu-Aqn*28D)Rlio_O2boYS~A-ClpJ}irmw}Vv4za#J8c2%_n|MIsWbE z5F?|(Uqd{NIRVteLlrR=%J6@$92E6riR;^NKs#y*a43P!m(9fWSp^r1iQUsg{HF$Z zs3XSF97@3)DdjiB6?>3ae($u3HIK3|@nhAKFaMC%;Yc8>_BHqiyj#p2-{E@fDM^RmO66+_u)-HwbcS_-J+>-Ma z@jqz8Yg;nQOI$(PG{Ja!M3W&tN¨GCAmdq1LJBa1C*rn)<7yh4?wE`WDK@zGbql zZrSj??&qZNyYjTht5>^N@ZcQLP#R@%1zwVU^7BmPygmIpY2@@j_O@1FuXd_39cd6Sd)g~VX{yh{r2b4%s{jkSjCyRqlQ9oATV+4P%K#%CZ9 z-$&yg(UzgjQ{gR=y8bem-&Z9|d+TInPm`?gStu8Gx5y^qXI<=Vm$g2PZ`eZozD3jz z3*cZrF~^#S!PW>2E^0WdlsWySQu=C+Wc=JIj=x9tt?*DrznOM$z&?e_YlP~G36Z}O zALaS;h?%sDc!2+bzTf7MtY?XD^BR5EL-bvb5eujT*%K!*ii3w7{UdX-j}oi>=~S`2M4k>XW_FkumB-QjP#nhWeq^t)7(+2CPnY@W z@51HZOkBp6?m4o&t6o-hG|DPCSWRrkRsF5RXIxI3sGS(7?dbn<+NW(YUzQ?yjnTM} zQZPSI5`u9WYpA0ukbkjMGKNuxJ&H+ z#O0q`@07BuTrvk=#`!m!CHY6JP53qIqV6C@-`%m2i2r%>v*d*skIsXt`}Chw_TA`O zZ%Fnb-5)B}qrrei8`J)7IrgU({hvqN$HiSWvaGXC+B+IJHp+5h__b^OOB};iS&iw_rQjt!;*$-;*&IIBX1M${=BCQOy01(ch%4Dl+|8EGdRa=` z&6ckD)W;h4S7UFkM$6YB;SI=rJyKqWyw@P_m0&qCUkVn3`AA=D<~e~_oR!q=rP#te z<`bN6nI+`~;ypgjTCcyb&iCHnddKKJ(USbf6mfo#{^7`D2O52i$jP5}LggmWaXhI{6}i~@v+2Hakk5Bi|4Y5a zQbGM&(_2mK(^{F|g(ed>w;9_%pLS4_Zw+nE4cK;#?YRm0DvTJP>yY&-&<-@t=OV^0 z=7G9EU%G;^BOOD{KIsteH?ngaJUhW5XkuP2I%X(ka?Iy8)6}wxGKkm_$fyl`} zr2obL#(2&56D0me#N5G;dekq`m*1=HiIXI3zx74tXWw!MVuWUQW9Ny5sc}M8?iwdF zU*li~(#6810>qn3`@;Chnu--T3 zPcf2wTZ%Z|N2~#j(=fVvAY$@2+GB-HE~(f>Tj%4%Y5gv-U~ebR*qyA6(pbY!V=rH2 zUi@fgFg`17jC@dl3=0?^C}3gF&sGAz48F1=N#8-g3q^Yp~UgV1bnMwGwM| z71uW~|Fwm7(xr?z5SJ7b%XXrA5}y<<%HW_J4$A2#m(ypi@V9YXM4w_V_nSk^#!_Or z=8BUxf`zz5iO(fT^rJBn^%gt?n}%%9atPIo!|l6-L-PN%(=Cdm&m_x7_CF@KaXqjk(l)G{`xI&Ypj z?H{8YXuSAf98lsB5(6Zw79NOSP<=y&l-7EmYEi|6fPu|J$i98J5J|AF?;3dV>u4i~ZC0(M?) z{pjqCQSTbZi0i*0|1*xEbZQ*U>^g@O?es|5m$RhuLB{R7ir|5=!2bojv~77RmM#6U zP%K+&>cA^-h4BcDX`7DSa?@US`s#@FyFe`TbyIw6iEX=un5|cWYlzKxEwM|lBaUe> zzO9RE9yrLLTx4OJvWWwnOBu+e4CM4J70(M*V!t^@tnVl8X&buEI`;uNpP#%9xf{oc zlYiLQZoo!SW}P0!ndcIt`tLkaac7Q{bYjl~(pSAV>^G#hdcja8kYPht5vkIyDW{sZYXY!v-@H+{*1e;`)z zL(F9{1`&u;jASzXNZLKEq#|s>Rt0Cl`#@qR+x6` z7{hJETwW85z3e4EHF1Tby;n(W|4xbb?u3JDB)MZ7V{>p*cBgWj_TN$T&g0UB5pXiT6 z=IrlwWTPZ}5!sha zy6mT}{u{PPkIKP2SgY_x5_K!G_p#U1N8jJeo?kEHe0{{N>?7tf>q<;L#l)ztCT4dd z(AeF}z-q8TqPjOpROiJKcN1-;a%4X-^{b)h!yTut{u>-n4(#dF2_GjO_%VDuXgu&f zMGQKQ{CkKu+fCeb=8R3WUrillpq7~6#Fy{D4s|RCaBy;+#NIwfEDfQuW!!&qk5ga% zDj#&!Q9?ie2kbZPW?Zia`FA7#E?o9^5Uceh@qQVjG#w}I_;Jd>aq59%4FEet>~YhH zc8S_IPf{4C57f1jEA#NOFg@gNaIn@c$xkxA-G%KriTqEX|HqO4G30*~8+0U-80Q6m zGH|#CP!}IwK%DbtiT}5(spuDF`p927pf0d~ig@X7GY)(d`5z`0=3)E~yiHuygTw?s zNKEjza*3s01S-HB;?2`1xU-D?l2gX!Pfz_<`D7|Xm395X)Ui88TBeu&BR{*FIq%P=Nz5DAp4X87 ztJDGPJ2kzG4chMj9*`}jm#{-Gm*SJ4K&%T#JuhO&XS|QoPX0O`=2+>FlzrHom#{<3 z$(o+W20hRF=V%8#M;UmIw$QWG#m^T=$_>P!&6<+BuiQ>Q`Rn*ZIqPP>pC(Z+p#SW_ zHa&$6+D94KXA#qr)B{h_7TT8~u}@`-^@>T2k$kT5GyUWrss|kZ>|{P1y?+c29>oSR zw`_WpGVlm?=n?GDV{S>hEnV#Mm>1MBFj_9GN?CZ$iGT`!L~i#`GX%-~r0O z1H8W<4(_)~^keLKyxt@B+$n4Or?32J2kCkz+Yhio51{||0M^RO}Br>*lF#v@o`YWfu% z{EGFazeyI)-?Fb|YRi6l+aF|WPj`sthwV`xl!~86i{-bpQCaUkEB|qB_t6({ zZ}5ouR@$6DWK0x9{Wx0O|Cb?-+%c_3n`q9aul-TmqVlhEi~WCT@2mV-Z=Lw7B=P)B zhS=GIFwOOU>id7z@i;eoI6j&o3BRV@!+PtqU-EwWly7$$x^XuD&u!?>)Q|H;``)vh zl`3D#5X%i#$@s@Capq0wF$Y8TdOVx|^IATCZW@%~Kz^KstW~MP7G+@fr+&M~NaKH! z*5UmBXYkptr%hh4MFVRzr-%GC{>3%GqzL~DUDJ4lp9Th3v&YEF;ssLXV_^Jd_81vi96_d+hGaZg^nv%rXB@R1^ahxf zedJ`Iu{2Y_8MZ&1jL_$C9Cw4MAB!h)@)=KE+lMUYg=8Bp?laDf?{IX3?||`4*M)Fz ztxLCqv+BJ;gz>%5v6$n}!EF5BvFYJ!$nGi-14bl&<-z!F=$OaxMxgP{F9dy!R35b- zdnFi?g#YyzIkAfDHO^y1b{pqW;x|rBrcZ>OFZG_fo_FljxpkQHg#D+!6BB;EH|%=Y zIbk*j{$|gEqL`J#tQCOq5V zeYTuWuHI|8n@~OAd0L;(miNi!eXxz&11I@oD9WSy3C~blKls_R@27@L)E2jniqKJf znR|a@miuX;`#VQL>xjNO%l)+AJ=_jQOb6gz`yAo-o;{x)@~9h8;Xcck;9c8#vwTla z8N38{wzJTC){peJK<_cj|MZo?H_l4(Sw4jK*|z@lV#o4kyFWz%2i?<&)Rr*IRif)_VYV z;A`|3CQ-eZ;krM|Km5o32fmg60QVt8?ScQjQIdFd;w=BP31@N{uomK9nEKvyXAn_$ z5`*xMQ4;;9D2e$>%q;&iod1CBhi}te@P0SE-%b2a5OXi_C~w8z_sp&XE_nMN_xV_f z`ZL^v=s&}|;=UM(y+20c{v0cbI}&EH4Y;8BSKA+bE4)7d=MPfeK`e;-ORU5{6ekG} z6BGD`*jfH(#(4J`Jf>_&4wm_c;r)@=0OB~tKMMDc#Y^JjMC1NLtf-#M&^FKoUH;?$ zBTix-hx^Cj9>hH!C-G0jO9DuIGC`8}B}(!W06m%Ie`bw;+cIs$tcLr2@V*b;pMrOg z_;i9Kf#hcrC50Gx=I4?n@k=wd4RFDh|I`&J5=(r;xM$)1S-5{LK@y)!l%(e=@5KB} zeIZ%QFQ$m)r4&iNCvm3M0T(R)Ngqp)IO4m;gM=61{zbTd3GQEl`~7hLa*9}ANfq0x zW=Y#`o~d=f1w#=o2(2`?u~B1n2ANm5=(mef~M#0;#j!~N@Ku^+IA^G&NH z-!LP`0xwAZ%_~zR{&~264enn{k|dD)I^4ej_iv<%^#Eo5O^evyvWoMdP27jl#C%`! zOsoSgNd8lHCrZMBBuRV|?%yPy=$k2$3e0c8{abK<5bh7b{oBMqJ8YNqBgEZ$gL$Hh zW?Vnug5%#-WR=AGsqYUaOVS~@KLq!OQpJ48ES5tSvAt~-`(c|nkHGy=xIgZYjN?wp zI_VPgjkEku_kOVDD*AJj`J}_N>kp?&%3-sZkHGyAi&&4q{ZY6-W)~OmoN!7eyk~W| zC8yIPu4ipxo{N2$Ipbj$R{5vhm+~9R{?QakItKU0;Qp9JEXS;3J#Le<ClNK?bg!_{=v7IE| zW(VAN!aclaz7`!c1lKTAB%&=#CIHsHeHpR%92hxT3veR+`50rwqN zv2?(FC){`1#o6T)cb7}jyWt+*b9ypPDTV(s$rZ<)^cAov(_9B;KL1&8^auKQz1aT{%)M!1?X`=o&ms0cr#SoIzRx2W z{TY%?9iK;eFZAZYeZG|X3Z%@JFJ=BbkQ?A$`7i0smZZ;2`?lbW=ihlFb2!*}b06)t z5Ul-h-%l**ey2G4UE=C@OS(5hvb@TDt`zv-KEQjCRQgJ!($CRf7(lt|0sJfS52s7g z_G!IOU`F%r{zo(8IoNslws--@0QX+F_rkr`B~Gtf+}?D_@MTI4_PxkgNSQB&_fo0x zmrJd`5>$XPnd2{&D)b;+2hyK+NXn{d+ZLFy{HOmDW4K2s=WwmChM?zZKBw4yaPNbA zpGVSt*nPOq$Ih4fOQhPTd{;?>zeXCt+`zF~>d=R3e=+=1AB1dx9s@eCdRpqhjO0J_ zpDp5I%wEg5avctPhNk)6>O;T@L`Bm1}1R2Jc$#gWP9Iwm(}6u;~@l?{)ra%6g-;!ud*ntE~1flXd=f zS>bO%ADX0z&*x|zfgLaqXd4RcLn)A)S3Q#S_tU0LI3xJaTA3zAe|9o%mo6UKavu0s zX!#C@a_*tLEAMLawcO_fxX+{P7fOw}Wr=T|tnjtS2LDRg>|ZBa{Tt*W&R6&s z59mMxc0!?Tf;mzeK#i10jnF>m$d}ZwC5xqI%I_bX*8FRkFaMlF@(<94qwk*X%?yIJ zd^-G|jv(hj-ZLdDoO}9u+Rtn7Rm(zegDmqckTt$G+2mUzm-#Q2EBsqzlYh0WMkkh0 zCoBrI3+k{1+CHq7dP;u1R7f4Dr8cOgby$l|cpi61(vB%@3#KLiPIxbUw^K?VaZ6?g zyfQbF(NB4%|DNd!0e-c74@MT{T@keTlzaMn74-M!Q1+X=HL}FpD9ihsWv#bWHhWje zW#092xp$*%K^N9>ZG~?kZGw5S*guzcVFPV~I+;u9Z=~cmi0VRB0ICah=tAYmB1!uN zW6tZQWdC4V@tl=`z?$=uTK%1j!909H3U_zPSA=-DxId;%*ga1tU&tkkjoB0{-!{_My%phdz`>BtE8o8jx6tPkX2oCWo_3y+0eN_HgqqNi+Wor z|LwBY*AD+}@ZX9J&_2OpbYKxWumBxs#tzJf|DYZ;2J`@XKs%vfKnG|m`sh0_w@}FV zvGYEwm_MH?mMydusn;ghE=(Ezvn!p_^v+Ca`k_b4{=zz(N13C43c0+%Jlm_hf0H@7 zx0$CoM%h1!-S5QicVq9FpUv)vd-ykaSDr`mQu}Z4-_Tbk%{`UU(hdJz^|G=H8_tOJq%dEA2w%e>v^IHrfGgv;*4Ue<^*&B|@tJ{ujc2GnhwxFc&lg>jiW` z?LeTvKwGogS0ELnyA&NR>ZBcWfI8u6)|`KZ{9cY8s@{y1g71Ma)vzK3!j;GPm4R`y52 zy?!U0|Hj@jSrFjAM%udSWJM=7pkuDA>}Zr#Jqu-3UyH1w{kPJ$T-yCB7!zuz?6<>x zJ7Y!5;lGWN-wNw3=)hu_UjXmTpedjM4YUpF(SbVJ19O;LsKy3VGRIhk{VHO8S&ptZ zWbLuz)g-a77s>K8?Zq3(_b!*%^X%hg7bcwlVmM#@$$VM%^GvC{)g}o)i4oJ!@VD}7 z_F>;1EwO)!m4pY_fA=`+v7e(XyiD0Ypk?1p*$?Bsn{wZ)-HZqHx6t-qCa^DUvWl|5nzFwd?pI;^SHk@Y zxL*$2ZE(L7EP?xl0Ue;1fDSZJ8`Q!-<45#0s=dXuJ!pUGIs^F6KFWGyU3;$kP}q}} z@I_xXcZ4u9%*t`#CienDr*^z5IP8k2`xemGLhxE68hOey~@wM`8@ICND zp#1*^9}KrgN$lPDTzH7RmumZ8WZ$)x{kKA8{{;1Y7rgi61i5E@MlNM2m-$-5_UmyZ zv?8u(VM0_||V9JX7*60is~!~I;f06@o(D=Gga@L!1jG3VHmF4?RzcfLuU_p=x2 z8TKPTivO9vnAo3=Z2koPV4`fqiRDqNWPdX^QaUhU{I~DUmBg=6*1rbd-vHkMH-jGm zd~KP23+^C~_rU)n?7@2m+fUiIzoBJc?LIcYQ_FlV>vQ0}AI=T#$H0GKi2pM9uYmuW zz6z=Dt(JMz|BE{7(1Au-(n*cpy+9WC(#E6jr)7Pie+{;NJ#GDqDC--+Mew}=j@N^= zFuWS9gy-d;6|{hbU_PaPu37*zpo+0$`T~q0>s&%1>&-H;|7q+$N@hP|?338ShvEJK za1Y$8Zz5z9@KJ`GlJ8BC^eZwVp#u}ff7=aNV)`n1_&WF|xCwk8{1p5O;CoMfZpGaf zCrOVncKQNq@n5G*9K`M)MLs8K=l8&SAG`;+&zC&f?}}jg588l{lzsh90dm(h9wqQ! z)?X@>@LvP}4L!B!K)uYP?LQyx=hFwAN87)te+6U1YndCmh_?L2)a9FCax;ADQL&Np z4RE_2tl@kWXa}ue30Oe6ZvyqKE2v=}v7GsaV&f~` zGq>AUBXfG|q_&50+Ot6FdX`Wxw91^m6;j*3hI)Gg<#sdtZJ`8T!l-W$RkD@$TNwS@ z#Bn3X^H^ILN z{!PmN9uUUA^BLAI)JCKoFk$6i+bk{b$&nR5&ywm}(Y2^hmu=uO?9Jso?Mh~QuVB{q@&Jm^gCf-n|5kKj6S#U|*1QNEng{pwl=~|76qT~CFpn`U>hgn5vAk-d{>KJ984v&JlPXqHo=g?T zcWD2<%Om#ui1!00g?~d2^r+)L&5Qvo_-UpzJVF2NSqFV!@_UH&m?v{6_sX&IU5tE7 zLMRUDfWbdJ4&tAd!oX`-y@3Bb_|Jp?9B&ov$vX6{2`pq>VJYKEDk{sFI3{2RP89tb-@1jl<%(*x@NT=>ty zo@B#+7IVKD-g@Sb=dp%hF=!JP^M7{lMXVp&DmLGCvHGu)H2+Sq`>zqZ>=Kt;gHG&3 zAFgIjaR+lwS8&hm*oSTC!WPoF5v&8Nuv^POixhYlu%~FQWOvPxjFaWq{z6H6*(1q! zGT!+w)O}kS2hN$0vA;>P|KXeuckX81r|NQ#G~Jjj^A57+wukbs+y|hxAgBWd_d)Bg z+y^;lgn%;xdhOJU76p9ef_&zOi&*uJaUUp?)V-_^_y~IwmZgT5$%#ClQssX*UC=qevh8k}`-3d0J6wPcs4h?^@Cx#; zC3`UU^cTed;|76uj2UyJRS93&fVLO*!$n`*$+(;y{;j@dG5eNEvTvm%(%z4!9LKxMxRR3qX)E=Y{A7VdP_O(=Nc{ezRW!8CR`qSZ?BVfgV zu**l-?EzPr@Sa2YEr7pLu`woRVJ$~0eY9lCe*)z-9^PW%FbY0RlL| z3=CUf3)q6Ix#te|wvqj-;tH_dliWe>mquoqHjx=U~aE-Kd=VVcHMVz@vb5T9v{sPr;iDyr;u^7QE-dd$E`qk4a&DZxUlP z3AEGVe9I*U`yY+{H^HTey4@780YM#zqx>fXbl^I4;9Bmni+gF?U^tHtEo2)2UDzz%Q?*Ud;#%y* zE=lFO#kZ4o18qd#m0~@-S`t2wZ-L?|?K^hb+5f@(>w5?7<{g?@u~=8gP( z=C@HMnL`%*yYOO0Q7DaY&VCKPn~csR(H2a=2E_X+;l3Vj=fm+*iSn%w6a7Dv+5q1+ zfDQ0oB~jj;663u_;y{9T7do&D9k>P^xEdX}3ctZ~Bzfz!@DVU0_&0PS_gaVKz0G`) zU%6M_VcX9OiZl%Gxcxa zd<#cxKtFB4{ww+XYKiT?TH?`#1ds%hySGdHo?@}gp$`|iIok2O*Noy{WuCF#E_qKd zZUXN%KjSEV*!DBFD6A;~j5G>fe&L*PHoq0vvGpF11EcIx|%m+)v)V&-~4|K2R{lya1gAVkd13i~Y zOve_ucTPv{RS#w?|EdG&m*d~#FqYp-Ob;*fDL%OO!M#@j|NYFf^re6_ICsNsHXIiM zYyji4Cf0zOx)y?^fO?>d{y^7yiR#)2HcNE(R*Al&V7l4-3!?lh|B8&ici`_Up1L}U zIvd^qY`piWGz|21_`4|KEwbfAN_K*u_X z>bOXvo~W5lZM|^bjq@2@{s(m6hYpGBj;7v*dqqz)h=X(Z?}GnM_{aC3iFFtz<{V8Y zumLCjKYQ;171gq>3wJl&q$cM~lXDOxiev;81W|HUGLo~TCMzIGC5a>@sN^g;h@gOg zph%7aO3s=7i~Ha6?mqjS|BiFtJNLim>}`)R$Li|Ut5((gzM6BcwPw`$;1AY;g@F8P$QtkgYrqDqf;e!64G0$y5DTt= zSa1bg53B$?umbErFX~^}=l_;Re;WMHIY8M2Z2SiB{Tl%Pb%6gGz<(7N2m!zqya#ld z90LJ4hmfBj4*UUZzz=pHJU|41fLP!sumcNX7(AE%@p*f{#qj^;`=1Mc6$%XQGQfKU z;J*y;{|W5DPf!MH0z-a)7+?|DfJI7xF^B^fKpe2Z0)!I?;J^alz=ALa-pTZ@dad`j zc=D&h|J(*pH3J*J1n^%1_%8zd7eEZK0AfJ!t{2EW2?jC;_JcKCAafuN069pIS>Ole z00-v4eZg5i41wc6&D`z3h39|uw?7^J)OW!B{sl1R=K=n60RLHlKbUg`nE^gv8u$Q^ zdkUEXHeedW0aL&ROaVVI1voIx1>O?|#y-#gZ@F3jRV@Ec{{N@L|KH+(F@Wz3z<&zh zKM7)h3BU)CcMBN@K42X9fH4pUi~}1m2K>Mn;J_H*z&JaG7~JPOKmHFSe@gu6p8?xG z4(|Vfxi%2+?mq~4*CS*E_y92f8UpgqAt28lG7LB}OalaP;2R?bJ_gqB(EdYQ^Zk~; ze@gtRu2O+_{DHAP4DkO7@CWaDg?s@%UOW+@7@AlAkh#|X z40!*(4S#C<8J{y_Ag$nDPz&HdGvGiI;6M}LKr`S#GvGioJ_Z5CKdt>AGWI*?!k-#{ zIwLSAqYL=^dcc8tz=67R0X(P&9H;{vsKdpOe*O&z#N*)}I0RpGyV6zx-SP2P(iibPY%h zgZ)2jt)+iP9{s89|M~c5vPWU?n}H7iYmh-o00)YJlmHHZwMi&H)Bcfd|F7{6@Fz!s zcRYUq_xK9|{^x6v{hI&|yn$g*mF)kFWA-1}ra%4oKeqv>muwiwD}epEoUcg+1g8=g zgYpGyw}btEVEKhVz?a#c1%p!#?*E>zM|m!}5DaxMm>(`g^+(43yl=no|92liKLG9p zoUciEE?{j+mIjVLI`+Tt|BY>DOW?v#f_dav1#k>QKQo5Wi1`=(kpK4s>_p!m*a!YE zoM|qDHAB=HFjPW+$Y(wOtDnEY68-NG|EC-9|IFVU^SA2x_1kZ3$-j`U%>Ps1|9vOu zkNLk)pMG)i@8=@w@5CSV3;#ddbztA$gZ*Fr1MqMD#eqK*2VDMw?ccKn*#GhYf4^P* zSMWh3e-G}z{SV;4)Gr(Ghp+*ezs2?M{SL6#`i1|$JpStd!~gQw{|iUJu_eDa@Gs4Q z|B~PT3+{i}o^uDtIfwogeB7@#{xwb|f5GwpW(%+v{>6cRIsTvD!~H+D`@iQ4sOwiO z@YiGOpV`*@L$Uu07XSz3f7yY5dOPsng8gqeaPAAv&+*U9|37QnN&qhZFq{7u%zwW< zKL?PwUmWTQ`Ir1dbZ~BC&-JMV1ogM{{_D42 z8u+DwUmEzOfnOT_@#kg8u)uOfcdX~{-fHU^Mj}Vql|T4{*NLA0*WWUEz4mr z2fr;7V=x=PE#v%Ebr1-su;sV=p%@JMw`FjGzbZn4&i?bV++Q^Z0{MNJ`FH!7|EjqV z$nVR-YZcuN($52J=@90RHi>92_YAwgTWD|Iwd^S~pY)@#*kEs|l~F zDQiO@Q1BHB!Nmp}W48k9^OCdMjoZ+^9Pcy;MA7W3vchej(bdL7ceblZi~GJz5Vegi z^@Xd}){G{qn%*i+TzmM~8&Md*!E?|F;Wzj^+nzCJIu_^0$X zN;FlSQwT!3rYYy+6Q&B8zWFqjUF$3t0fiSsNY;E3{!WH-OtEmVSxq_NoPT>6glF~ ze?RSk-h~Mle`q#5fY=9iuckV`<;<6P z#g%zFcN+f487*5CF9g*?8?|Vp!CfAuK~SXfZHKHREwWYpnyeucTNjRf%4rz)bA;Mi zYt^XanSBrkEE^`%o(=J49ms$&#FA=fCN65GVP+#Qa17D48PbgKCpw`$AUVMG3FC@$ zZ%0-^Ze(vJZ^8nxO1@8JU4=+&v}MK%cbED^PxCcQ2jTid{DZlI8K-GwO@$+UeNW=P0?IoeP}tb+SM6cW}d?cF7ys2 zd1YHD$?P5BwD<;=4DH@WWo8V5BLkUiCvRa!Yi<;`kvFIaClF-htHd`x(EPf- zpWir)y^#sUFmA{}F@zg>K8j233dqM~WTp_fGpTV0Uo-Qxz^s+Ov}-btV5_;Xj}y+O zF`l`jW0Al~2=TZHViF!mbRw`}HvMp#(x1IqmFz6cnOWK=xEXuAHNR%=C<(@_%syUcG zt`T$xxlyuVh{2!aRZ~+-i6!!68JCuo-Gi8^?-&aNJ1d_zpT^Borow>+f3P!qJo!ZonQZC4L<=U0`fThw4yaa=p1{;A zsQ@dC*f%z*WtbP9mbkb+9nGNl5|iu`B*(%sv-~2|8%yy~kC*QuN0aU}{fvVFq*M8L z3UOv511)qfyH7|)W=-jMJ*y9XeLD9ogdBHTTDA@2-4cXo&=5H$C(Ga>$bb~jQZAGG ztIm*GJ#QI)h>#(M3AgN{F@%|mnjDRIctY5%WVlLh6q$^+wJ@O=2&eMtu}?6Demdx# z5%g6s7t2gX>$KIq)Vj=Ryh(g5$!8ocoUj!0Bj;)N6AZrDs`p_-^YgGUXQ(1x+4Kau zeXE>hGoJ-rLjMwJ6Uz!G$)crY=^7d*ksks6uSSXbGB(cv3LV@#>hcu(hLvNqxtUx!BoDLxh^@Be}5Jd8k-}$#KmUdojF$VZ-~~64wAw zL1B1f^era-@*8+ug_lS&e5l}gzRxZeUt*cbu|UXaW9rkjW&5r{^fm%9%j{EN(BxRq z3Y`S0G}==+I5^zm^2|(vC~mA{H%-YoX{xKK)zav9khi=N*cl{~CuTNjP`RAV4m5Np zJ1!2|@R6r`OY=G;z#nZ9`tp#ROpvz?_bjVGPg3DM_&NF@B$H6PX6i)V$f!*Q#jixA zJ0$znP!0(#e9VtN49;*fYvX6-UK#UQ4&c3EgiG<>e~R4zQW2f?Lsa;3a4hPIJf(m< zQl;pq^W~>lgDWnG8kBPjO`Wr4H z$nbi2+hA;b>8Lpy4zvS1(p)?ng;ZROYBiQfAq>85{s@6%&EEBxz+1C)jEM2cS9#Eo zq~XOoP<~~h6sr9cF-dur`a4S)57O<+*|oQXjcG1OGTezNt*ldau8%%5AkCz~&J7UET+m|}(Izow2x!51B#-cL_@_q%2JyFfBs<=;y< zuZ04huE(v`mwb}upjdYALp?&!o!m~&^7yubA5r~Eyu&AQd2Mp{Xi(Dwl2bF09n;k; zZ}YDB))^8T2Uz@uzJHThHz#UXC+aDKuEKGY2Zt4Gf#TuVBB?^bv0`-si$r#Ox_`>t z5IH&wVqSUm?JL*$#9RCnT{XqlICmi{Al0sklUBjuUX(nHOSv&=UW$IrY3oP zHY9Z=k_~P#^NCgFQ~%9a#=J?iuTnW=fixGHbvb-Fs=m0kxc!yx&7jn*)ArogcT^GL zeDRN-5T@7wcHYP)s>IogXrFLdf;8V_*FZ209}VkKF7l7MyIfCDeJQ2o9;FO%$Ndpv zaG{Hi;tfJYP8AtBpAg@fhk1D&VdAo+5jm-Cb{&|Hw@R#NUq#9jQIB=YCBFFmD=|@| zH=avu)9#?qMT?_Rv#UUhOjdQ0mREQnCS;r#+2h)-$C{ zgKK?(TSl!?ma=y361eNQXfjHFwj}Jq14oc6ZuhZvIR+D!nk-+!^j|<`S!`VoXe@^h z-6XhTp5@M^Bu*%;ebEYQ0hYM-EwBMCOirT_9TSzcMnw4GA@)Nxl~27r>Yp=`+#KSmn>IH|@YEPVOZ{8-aC*vH zbhrhLqHfCnir=!#%9`Z=7bk%t*ak+#TWQP@}9>vFPj(W4cJ z?E)*Pv(tU2<40fUovNEap%LL$IB^tscR5#mgOu%x)79eql9}4FB8W~c_(@@fsLnV<&+I!sP zP=A@3Dl%)LhmZv*ZC6f8IMhk~!JHxkR2ah&&Zz`AxDO*oTu$EOuCm z6@0akJ7pQ$NnxOdf>ZTT(t_W1+3KP$CHfX_3(%sTeodDEmYwl|G0%W!Fc--&@5aCHehds0Wm~EuuZ9Yma&iP?i?e+`LxpD z!o9GRCx{2hNLzi_l~#(ba+Ej0xM=As7q!znc%tFTkP3p1dxVc;aq{Tw4m# zB@qFc3z;f~E0ek|C916Px-sw2y2z8A(W5!%K=+=5S)?mW!W* zq>B&VSi#}&j$+C3VMgo0?0rNA`;Sbqm)2PZiUq6dcy1Fdj$O{*DIDIK!7Y32@||F0 z_RFZr;kxG0Q9^~H<45u~Uk3c@vyQ7(1o_eePUDhXWP$JC&)zx>mVloMQb^!Obuj2G zPK0P>$`$P-TfdVt?t))OO>(ZT?>s%LQ!=aic8PW`yG1l~en=?YCHou$5`Rp0i)PE| z?SSpLgICSu0T|oescZe;Q)pT$Ga!bHA@alW)hqo*NiS-Ug>5hE;Q9jG>>W^j< zb8i#|)qYu6tBdB4-B<=7N=aj`G0o^AcRR``JoD&HQJHZ=;r z@4KeVy5bZ8?PdFn(G%ibNx|*h-YG6Dpx0FKhh5FZp~q!+f-K7%sJO_lY+redjty5I zI3nkTc3ulH8dIdMdt<&P86n3*!w6Nq{4M$D10FTmLx`YA2ucWVTx{bqchmCrS@F7k zt3Bav%2zC5@e?J((abLV2U}-Pbx^nNV8I%RYL`p5VmoBXBlh{7G~=^TvC1%Nit|b+ zN>O_7L*Izw+}zq{kA=P$xOO7HT;Pjf0b#BupX&|HD zH-!b~X48ckMHbQ)73Ka>#_95`66Dcc)y>!r(`|>{r>;RlRgMC33d@~N3S(25)_7rs z^52-rTiLH?jfH-BGi~b4(BQyBgop?sDyJZ6$Wnv5+?6P)J3Y3V5nRd%0REq3fVj&tCp$wrW zj7omZ5nLZ~{K`CNf!nm|+jXlNv-CN>%-gy9`TApAxd*Y0L22unjBEu=T>WO@RqNbt zwq<5iwZU0tG(Oha0WApNI-XvctcQKC(jq4@ zea+Y^r;!n4Sc$1^Ln-j)EO}0U#7`N1Ix|J}jVb0#gW8*2E#oJaAQ>6dm;zpu5o|2B z5vve{zvqY8i&YU_bX+N2P%WJ8{CeUvDO2{n<~v5>HPooM^o z>2_(o9Ssp&obYAVbhrX&8aj(qR3Qlwpwn-Lzei2wJ($Coxt=VtMD2fS9iSFPU9-5jY&2anYGUZ32 ztgHbC0inRmYu!7%dlGlP;w-s5@+w%PqEv5> z@TE?q866q4L7jV=f=YD$i{RE{qLXBp+--fKew}DbbKwH}4(itKeT3X9M^M@Y2)O~Y z7n142+JCie1uLR=acKw2BGQ4#vU5FXCx5A6Fe?x&Vc~mqq|SQ8L=PJiZz1cwT|rqZ+uhL%aZP-K;S3V@39yEi}pxdxF%G|lU-S36T8;9LMOpN}91G(G^AHuNm zX4BY>eX+X`v4@uGSC0qSgHa`$PjWT}=q_Jl<=+k8HHrw#yC=Y-xn`Jg`hpG9((fD3 zVwcf^1ko3Da8|mgc`ND-b}@aAcYT-8r4(<(WVwq53mix>Q5SA7Ro}bQ@ua@r?O;y70L~R{Qr}i6=^+?xpMDz3IVMX#?JIijL zptjUBe=;6I4Pq4`*wYf{czVY9BBli!lOAG(?-a3;owFoCT^A^lDxR^kY3O2-Hss1n>=&nxJ_IsW0!k0k5ibvK1}M)Q>r-W z*UsPa*EzVMD2SQAlZpPuVJjRLcC95I|6V6FEr-U4r1yA?r%gLuB|l#I*3$A_f=;7m z!{a0Umx@_q7mS;%mjpa&-MY)RlfI8c#)eMu?XiWvwK12tMqNE6e12jV-PxWW@DaVelRek(@>Q3#-0M=@MIZB%2B$^%gA8Vy@l@_1 z>l`N8Xt68-@2u6u>vI^_r`S$y3A|0YJ{AN0Milpx8QrjYJeLZ2RrOlWRLY1MoN&H% z+92_1OBmH&y702YB#|NGQbl}+y3$?uiMOv1Z%+u0>=TSEM-^VOEJ8Oas=j$wdu6oF zHR)PF_IE$A7?|CZtpVgwNY=L{CkLO)UeSz>*|KX7bs}P(Ve&`Pp5nV^lvHZm)(XDS z>2jzY7rxG&EO=>e%4;Riz-7Z#VG~-b8NQ+r;j5cR@L0vg8iW}U`h&OZS7J9uo1Ei0 zLX9t^7%|R&AsQJo=^3LP8N+rTR4jqq+tp@?kr02!9Q#(ovz}JV;pk+u>BIdR@ncOY zO}mGdenBgA>V6BZA!e7jHRw4Qo;Q2^G%Fhxv((G-zWQU5ds^I*-o@kA2WRAw)KXsi zY6ufVDLw(kwrLhrAB##*!g>hdWT86auI1um>?uObI}vXi#;tgU`ZAUiMjBV8bW0UN zChF7{C5M{?zA9iHHTVt|I?D`x3@tUew#ysJHJ^Z@)HQ<6ekjHBlALba-wY zZGYnBIv)6W)hEc`Ku(tv*GfZLLqOK_fH3qkky&pp#GY~Vr zV07W&2oEs8p}Isn!NFb3(|C!>7kfc0+kGrCsJJ#Vix?45Q2JsC;(@Lqi1;94J2$2Q z(Q@$R?lTJI_r9bHS5O&-A(9o5l z?Gb4h23Ig@-?NUkJDIRC<3;W3`6>6945=%c{GqCdL#)WtYXgxeqY#-W{?HbaO}%{q z_F!imXr)-=1Lo#0z40AA5{vx!{CMRsx1zal%#Gv~rwHGU_(smIG?hBU9sbp;RMK9# z{(O0vMrQelK;wPQSelChXh~arW}Q=NJfGzZmrMtmA55ImIbONJH)@Lsr-HP}M9!3p zT2L7@Ftf-Qg&L%Ro@?@xacOC#Xes!FjwLdxgu>fwAQDC#tf7+0OMp&j>FOk)31Qai zKhj=Ir)Xk?LpD?AZh0dadq!a+M`Yz?=zAXVgzFf!NrN~RLSa~mkg>2Nb_nibxxZ`@?5RU{xH<_KS zFVw@c9$yU5bvRNnH}L10tP*rGi64ua^mMs3z(=$ir{(^@n(gIWKfw@944ty*kX6;{ z$Wd7%kD1>HHT|4#*jzYYHGz7&815$e=!<NMI1I)NkBL z|HL|m!a4<#Q^c0iL9}2GREel4Lytik7fO>=DXuHs+vgeW8?cJxKTvC=i1PTT!0-tf zb2 zV+af~5>{pnuyAOV~8fyi-M8+NdH4ML%CJ_vye&H2)2}PDe(&5eYo^c z-6wNwVIw#??x0IMZjD~=gQ=Oqx^*pI(w&(HIqqr+ms|I)EafOY4-HnjM8$zK*XvJ8 zk}sK0!?pX6#4Kt5c%xh?2K65KC`M(SlO(uuozGbVJRu6I^zfv8lx($1a1A@;!^Dhd&p0p`HM|w7o4J$;|A`#DHbGZk*gWKvQ7=}ysp7?gEGJP zXq5*mTC&4HHDi%NC72)AO-WdfVB{Gs<8Zd$Hx@t3cp<{IyBz^DE^!R^H_8L&oMTg2 zAwPVWr|$9RID3^kht@kbre+d;m|*ceBXEfGUwn?Bh3dw~NT&%+$J~j*BwWBQWX+=r zY?d0*&TISV&U1UFtM;v|>5#kA)KFOWX2|opx*(YjU7Q~jQwW>0b}4>v{^429k6NK_c<3kkh^EB`G2IN20RrLXQw zIf})#&#rk@tso63cZfq`FIEN{`}AN#;e$c1uJ5l=?yM5MkcjPaUeQ`2brMpofT;$v z;iNOW-YRc=pnJvy`w3Y-NpEs{`H05l25+}~VNfie(k*SG;;b#9e1?Uv%0N*U%C(ZV zpM8h*iA!$jke{gvyE0iHWNWBpFl2_`G0StiZONojVWS?O&z#bN8w{tbHUsBE1aHBc z9Tj|XU;@cn!x5C6RvG=7$YLw#(3d!J($l3lk+Q#9 z|Dz#Vp4`*IT~c0P_=2-1>$ROrOvj#IFT}ssE1bR(JF`ZDuRpob$ad6YvA?T`l8mWkCmXRD&5_?rf%KwNCK`$l9cH5j!+c5$MVvw%zzxBjDZf_5I=5 zw5!G1fy`OnS7K%JELOo5Mp??R?1;l7HeyVulht@)o9vWbo6G(IC0ltMd!VD?u2^eSoI&w zbSQ@i1s-}__?~xGlToc`Usc5q-E94SkAER!5qTY`kAm3~|S5wZbc!_f+|M{noCbsD|(R#(!KV z9+j(xeeA3w@qYM@n?{<|@DWxCe#FP#+eZ^Y)K$|GMZtAgWjyb6ESpXr-;T>X8+?Sr zGrN!9d{rH0y3t{od%^roUGUN}J%$m%-cFtMu>XVf&eFi;rMA3vzW$jG357wm31$PxVjecYG5ZH46L0Ymj77&$ble#VA-| zn@Tk#$voHHVK0(m>GwL0@Sve=D6P3Ve0iJ4u*t~qen}Kz!|itjG~WF05b^@6atl;L z;>Cj^B;a{T2aggnGL^sWF%-Ca%y&hVhza(1J{1F*Df z9Idah1+BDMwYT-kUiU6(Eh6$7xs!Z_Vua=G+Ho67j|%&#VPIiN$>$SKEiH9Ns9FJM z^e4+leU*5&@d^x9vHqRZTc^T2l*2?O!?fr*#>wg3$gL%jXcDW-V-KYs@!8R>o5~v6 zYun=Ae`B0%_k^{#bGbG??k)BJqbIQe0~U7?y4(y^i{08NnwmY>yHrQ?yglZgkWv%b z0sc-#j?uNITP@@&-X3{hMbo8Vkp5FrFXu3sF5zUV3*Z_vSi$R3%A5DZoBAFp#b%=) zy{KIRq6Hz$3xb7AJY_a7?H`6Bi|ZLB`|`ta+T zs;B02jsn&>8b$k3s#Clh&L_-v+vK*`A zEMe-0zA>oO)(3LLmbh+k5t8zR&9uNL1DCsm<3tb0c90zbKl(ePE|&(Tbj8@7p;Ot> zS}`SGXZ9kOlBwzgmd4QahJv35vg^NQ`|Z+=U##_vG~q67B&~MW7sIj3r8@aQR)(Iu^UlBpB-0^!fKu6Oc;U%=%(bAEQ^yntm8zBV(Zl1}N4PN`Dq*(KVNY`^?L zc$jd3ET!qr{b?%devaK}?+2^~28zZ4v)O@JVQD`J9Q0xDlB;aFEm$;v>MQZ52rVnW zf+ZyAI#XAW=n$%%>f1fITB&-sOi)VcO`KT()+4N}PsrMzUZq(bF1 zyC|i!dY~>42E2tX^9;qkmfP@_fd1nsSwymf0oliS$M?d|;3RCaNT_myRjGtB4r1>E z>DJo=D9iOgd9{7}$jKwhZ(T0l^3M9>v$)BGH${~LaBluE`%1?4^eT^MS~J;_Jl!U5 z(@nQh4)Vn*;oHogQmzmTi@6~`_Khr*j7s6|?mF7pVna=;B*ur+RV7Wjx?8e;j&!lm zF}#Q>S?6YuE-zhG@)aRiO##SJzH1;13P> zS&@BL_&TGdBWXnyTIQqh*t8SAn@WOCe^YQSQ=z0YEq~J2;4mH!AHEmayASx$YHEu3 zq>k@lrY@+`P1%HNh40+%)X6Zd8k{B9?$FNqSab8?d%s)oGw~xSme_^~7gyayW;J4N z8}%6Bf8r@F{Wd-uLF7H}5=m8KV^Jc%$8e9&O*7%xoM|>6TaLmfB9r3fkX_4rYDu{i zVpvMpg>K0D95MgiCaIHLq#rB@mV^+bZQkfSB6G`+Y`D{J6eY@bkv_*7V(3K|0m)2~ zE&ZA}gB7GxDif779658-KF>Vq#s^OI6XTeChB+K{X;m(}wJ3s%+9$zXA(v2j*@JU# zIggSOnr1MnYYGRouDzHtxJ$@F9MJ?hx{5+os-uF`slLV0a3?r4GD-$A0?(*3=?9YR4%03lXOwawRW%>@LTqhh{Q@4gna$R!+8*pg|FFQu+QD;NLj0a^DOEf>{*B} zdnwo12G*rdWqFwqhn(m+lDgdxE8)soF07qW^fAsx#=*_I0pVhy2J5WeR0(>bwQovI zTfQ?qB~7Eut(uB~ysKgV9N~Ib)-8S*&TS1$?x7(ZLZ#43udBBXcP=2P52^szq@6XV2!>OIZj$@F@0^=2sc+p zUXR7WuTFWu{bAS!e=9nLdp@jFOvle%Q<%7|MYBlMGPilXsv+~St#A{ebUDo5;)!m_ zMB&n#{N;3Y$mVJq0hb|s_EyCWMse@j?2a{~D8}oXl3YQOS+&V?O{FeVt(++W3QY8J zi*l8xf!D=OFZy4?o0hD^IWth%M;g20jw#KP2U7-%ZAM2m45&;lwJf&?Ad@4^@qgyF zDsKROM>lc-RF5}kh(AM zWoIxR7xkXK8yxh7Rb>9VZ@QW3 zP4lJxPBuyYejx&5k*+Hd4I?T|!%9uWZo_wU-7K>S_*8Fsz87)rbVJ{0klytCXmr=~ zZRP9L>u*r8Ymv)WxWnb%VKq=@)~XmWd%T zNTj7nFDpoQzWejLDbX&{z-&#fs}-4~pcT>8o>};+UvUVTk(MEo>jz6)UN{p_U-H^# zEE4dy^NYRLZ`(;0w|cfcs}8tN*SEPZZif==c8sLuBHT{9IM#=Ae2q+4Tac8_VZlDu zshcci9$qPSCQ14(vn%`C_?>;^ikHIKm-vBB)p_QHB^;tdhVmi;sVDXY4qJ=OOk`01 zTX01e{679QA=NH6to2a;{LnKG=%EGmwr=ovX+Ph|4lOE*Aj4(Lez{J)K|-1KCB=J5 zq@j2X>DL)i&-`1v_`5L}pB7a|(ppZ$P>xU)Wec1YeSfxCJl1C%0Vxf)D)sAHs(>D@ zN7Tw0%qw*<;nppN-cRgS_na`f%?>-@w9WK?8=6lP5LLn)RM>SBX9UYjVUoo1vXbDX zm&-ptw5iVpTgQ#sN<~(!F&W*iz#k1ymD?@Mc%KQMa5i$1zqLIa zTKg=sAmMX2<6eKF9G%F?%7cMptQBWBALeo)(H_yz6iIvENv@U^Hqw@DW&TDYAMLE> zOJO*)doKtMZ$=z06Ky5kDV{IY*UWqc&u)d=l#try9lx~K7QLB@ZfE@|043$A@)O?9 z&Hkbkug&Y`LfBdoK6U5C@oB}Vvb=|fMs$l5#}uR6PBPZke#DY9qyK!@n#~5>62+6U z4~xg0_GRM?&Tg}gT{C2+_Q@0eiRuHlliiT|ZfYea)!vEI5|?f59tMyXmo*Dcy5>@v zcmHV4qx|fyX26;MosHqi9VU3w8Q;f%s?tb(B}c4EIR)IU5vAw=ZQ&!2mL+f1Z&Qn1 ze%S6)-itTmFPCwB)*9-}7(Hrm!O{0LvqHwFHflnDFo_m2XYmKpZAZ9Iaymg2yv zsJcp?u2c|=@V(iaefSBlkMSYIlzo=md&wW~XZ5xcdrT`Mt%sR#37(rq0*9?N)~HQ@ zXxP^q&>J`Ku*1Xx*+iSi^`32&E#&7!%0sgBjX6$cK0AxELf*%Y>20fY$bP*kBhb}M zlh`bW!t9cqWmz&?r7#Yr7d{TdgoAX1?g-v{1_%2}I~Ea6p8c7$J@rj*)uf9&%#|`& zVUh~moE#*}+AI=RAjQUB?P6h5%5V~F-@1?UaYB4BlIQnjW(o>DDR9`f`mRu5ywJy0 z9saCc?d2(4D*ONT^p*b|*G@uPAXGKVP@yQ;^p#Bs^fcbY;}JCt@yjpYJI?kFjO>p@)u9C~8m!w|wMNl-;&YazX25FafrV{V; zep7EW01qm+(bL@z_ZhYVV`B+)MJ?GkiWR;xj=Fv!8`szr%pNqOdvKq4RP*)hnoeGG z@#q^H0=25!wkBLOFz;#wh!vfyB3U_M(M3%B>=cnJ#_|F)Zn@*nhQPM#ASY^DKK>2t zn_#E;&PS`ab>CTE4x>442ohSCa|rV=^%v69)WF;B(C@O|nOk*tg_gQ$SLZ}jQPn^8 zo5A$r?rTz=y=*daM)CA}-vAHeGPrLUm6vQZg(tMzMGzpi?*?Zms?zEe&4uXca3|ln zWM`-Nd}FZ9t|Ot@7L;*b87@~KQMt*L zAD66now6z3I2`;?B1eXf{-`!20NFdetdn)D^4UEz*C$Ts6Chu#whtf6YE|5mIygDZ z&t1T%BG);3gKmO>#EPnh%T~r8iye8G$9oHu2ZJt+VhyM;m=RC<@ke~-#CsSWz-Xuo zkLZkGVF{!%&kDJEw=VY0_O?s-{a%b+_o8MRrVZq?smQmJapOdId=XN0xf-w1VGK2} zMFs`TU8It4-^Yu=IRYfIByRN zXpf6I+*_&N3dxuq8QfJVR^{+15GGwd~sm*2!l3~U8JUIK>mbr2L9#GfJdGlEH zVVacNd?)te4k3cbg}kGg7ld~Fk9M?MR5&|eGNTqsk!Cx}Ll^fVO%weFKIn|i&w6b(KUrE_#sZVB60>cjmk{(o)NuIEz_(d7P0w_In`kDG2ji3UI#)98y z!-{C1IZM!mj~PxmHMpHHeZF6!o0@QIrA1q&tE{d_CRl6vqkEm#-BQc&e|5tJ@UB_hy(ql+I#ARKjgOE@GZJE`AF4`M$`! zfyl9t2uL!7STfI(n^TU{hnSM~2%HSf;5!ab$>kL`7@Adc7#bzXpVr#(rAbWSzM`70 z)I@H{5tjvhyuchf^6^9|aiO^s&@zD(E`(F@qP8zs4zJF>Uj-RJlZi{?d1}Xpls6U} zkHxRlz*q~(%Mj=&RbF_>_E<)tK!uP^2=E!cM9hc+RDZ}6U#oYur75aI6vY(6A1z1AFm5~^}q&lp52E1 z4QHFBlweI`nl6wuQKg7%w=5zv1yRrda~yX%I1{iPF-9c_4e0Bvwj>0JygS>*-KI_H zOf^g3B5er=CdEMh!9twBe0*Q)sX;$|)3tall=8%ru>zb2NL()B6}!olNwt0wf6wXk zJ0P=86>$_Cs%r3jU9$=EZ%2n>WrQ>cHHlASyQE(Gc4wqWk2ALDV9x_;cUdU$$mglR zu42(o`o|OsNL5!YEt#$vER{2|)U&I{eQ?lwI=H1-yk_e-$+#KbeWe7DCio09io5g3 z07iLZ?FTdS&Ws5}qICWl+lq~pe_l%D`@YNSaA8r9z<3?k`T){{)f&LLqz7AuNl^ai z#CkiH)@VmMbcw5n-hP;@^Eko&(A|5wG&8m|NU)2E&QdeJQg%umxPij#6-r^htY;zq zytSSRNt7nw`B@c9=%~xI=Xgyf)v1ktGsHgNP02)AttP+!O8oPJ4vE7v(NK^Ph>uf_ z+rQ z=I{^(+y!JXp+XQY9d_h9KAOR%k*%d%B7z|-mAU-^YhjZ9gcsjFxb7q8ug42uohMbJ zfUv&qxYBYD|GuWnSjZZmHEkt1(y<~ybCgPfXPWMEQyLHV5S+9zot}FwyCdLxS2cWu z4YU;Gc~{^=dC)c?_n`ZTwGc0P>4QX*qN;$wcxNx9?pfP~Q)O77VglAgO|6i?QF!PC zKR5~`&sPxWQQ=&soEKFX4#>|Ed`iZsv#t?`c=A9ja5~}v#qEy^togMjIGNH1#xtcJ zQi*$+SI?7y53*&O1gA4vE-RSn$z7!}V;WDV(U)~J%r*Nq%)~`OfVV5qy!I;G4@K;M zO#~0K0>&^uTNI)z4@Hcaz!9K`d9qe7-XUk}lTaXz;-wWFgz}E6Bcp;${Is$z5&5#G zFa{f^btVem0?03utYfD*D%8O1aire~@shpAbU2}v7XrdQ@}_t_j6170L5@X@Y`$t9 z+7TTC|L-nH3xjXN$Jv5S`d^f*NIE289p^u>B!T(OIfnGATTqM-X6I;9F!8J$?>~xT zv)BVEwM^y;vGDEN=GXfjPijj!AdZGm^3V5g-NhPkgzjj~G__&vYRFkkgW;13T&Hg^ zVh?_(9ZwicsdBuV4q?9t5C73r^eOA}{yuqlw^Y#g?boRae)yT8{!oU*uplCEhFFv; zYM;<;D!YWc@a9)6t*2PJSZyz9r<3uTf~+JZwHBvSS@&CIVysWNdM*MUkVk;4+$E*f zhW#(Q4^WXhA$x`e9Fw|l9TJE-9 z7AbWeU{S02x~CPlQLG(g0dv`r{<8d#3(j~r%k0bAH7IiA{1_oj475f3paQB%xKI{q z6B5Dtoc}fMlZY8+!Xtu`FCVdSm*i*4+SvTlSyV8K*dSXRk7{1)#xMDy*<+tr?cC0PUTiPoT3ISwrj_YVnQ=$rP(kmD(z$2wvXAA=wL`&ce0- z__{SfrHN#oFPJTHqmLAHm7YS9tS70}QF^DY?b_S&%&(Ne7WOCsJ=1nNl+|jpbogaq zVglnUT}??U_G*lao~$PPxSom3$) zan0^l=9xw^YbKBtFQGYMa zU4GS)fbP!DynuR!t@y*4?CdRw#C?@hC_KQWkahR8pi!mSC#~X`^b;h@tF5Js}NAylYDcE345yu zW|L5|(3e_ui4*S0YmJ#MzA(WywhxLHIsmCF4_jBRyg6g&hTJ(y3b!69rBt6SHg;Z_7bKVA@$@) z3ePe%kNAs-|!r*)~;-OW@Rs=JnBkdd9gbmke~#_aH44pe-X3n5a1h>%Tv^ zaiF18{j_zXK~A|X8dy%>D_`hQmc%0E$M2u*lu4Q4HHQei!R)~+QZ1PB7czZS@nN4X zDT7W<`~!3Pp2)!Bb4e< zXF+@}RMe>F*cA^%=*@}LC+JJ#;#NBQMa&Q086g2!)RH%?ZxKw7p-H~^{bW0~9y^#e z729Ag`9X}T&rG=7^RsN~;hqg?{@M2%%djV#^I@sVJk!?0{f7;qg50xk?=Od+TpEdMh!U7h6ZS(~}^^hj*yfFLUkCUE+sSRKZuEcup?9q7d(MbwGDZWRqV)20q0|Lr-+bdL4%?5^pC#or-DfzPN znU{OwPc6^-B;8JEl1+Yc7<0~6!iC}0-9zJmuhh`!XZphqXWuCfWENhZTzEejO;U+!~~n=bsczB>G{1d0yNHdamjVf z)pMPSkfi$idF8 z9^Q_#%sev(>HL2JF9p#0rti;U0o=!10ME|*6DA}iOhkzOKf-4KPORNIZ44mCv&m+8 zxz7m&1_=oXFCD>B|BO>w>St*NviLP;zry<$w}GYe{=^9h2^IE%56f*o?A+PenfipY z_5$n!e+E8^-yk6&;X>dU@TYRyJRD)ARnc2?+@ma(v$Z6V4E< zKdS|>i)WWV0FOy=fP{pLfROk947i7n)8(gm;#mn`SiaF;%IyJZYFt9XdE)@@mcNg; z0#4nz`*r34IK1}%BiBKo4+aAUg8}`1 z)dXnqLf-{$0+)bQVBx&Kk%WYA2^3$Q`yYURkGBAx#t#?_PVU?LCR2eeUi<$)cuQgp zPXY-E2`?70>Hq%%{}JE&e`b8svEWbf%(Du-g`XC5Cno!eKJkTClQn*U$pQ+}V|)9{Uj+s-Qd z@C^xIf+Y~f5rv?H;Dvt?Un7u~B1=d(J;EfeUjhF&@c-e3e~(D`zmDb)crFWkOtAzW z<8zY*-VL})8YiBRa9TLvQ{ew9w|}Ib^z)51f53AgfMYCyU3^@iz*_^Ia!YZ6goMc$ z;Faf}@f!c{@xuQVE#dzrnm^#VF7Y+N63Fq5Lz{S0W*=WRe3?W72?=eC@a??61O9is z@V|#Ags~NVzNzrTb0&Z(mcS8yK*0{aZ&~mb!3fW0!74~d_%_1fHTxsH*8eT=55T{{ zSK02+8t(BtG=IPgS>$tqB@mV?-oe)|e?dL7Y^B_iHIVRaM406JAMk;`zsH;Y!Q>z7 zvVC5{4=-5g*4EZ0?aqL8;D^AEfgb^H;AaY4!IQxvDPxc@pUClo{R|%@e}J#+{|#Q_ z|CuQRch6Gee_EV}>22{o&2R8g&VRrYz`MW?fbZf7V&xo;Eg|7W!r`m;KBu1E`_K5I zo~L+Hc&RIIy%e*1iX{+WfDODw@B`p&;4VIGcnQDuKp$@vEaK}5UWn_GknkMf@LGO^ zkLVBZaj-+YkZ7M=)RD=#pj(QCjfcmlYACxB31 z9JUVLl1PEXgqI12&uE2hfUnZq#S8itUg*EV7x8Ry%z`>EL*ut`5iEd7uy~dn;%f;0 zNL^06fF}rpZ#IevAz1|pFB2oYz=v&sCxYMt45?j!11{hQ{R^crPhlCfkx>&s>NQAs znGn1{@8eDRGcT2Q9vZ)mi)sO!7Gc5CeUb~1@bVE{fK#o)a}hC<0`oO2g@lBchKr!t uPm5$SCnO{!BqSsxBqSsxBqV%0@c#p-Lh0^@m+)W!0000 - - - - - - diff --git a/windows/runner/utils.cpp b/windows/runner/utils.cpp index d19bdbbc..3a0b4651 100644 --- a/windows/runner/utils.cpp +++ b/windows/runner/utils.cpp @@ -45,18 +45,19 @@ std::string Utf8FromUtf16(const wchar_t* utf16_string) { if (utf16_string == nullptr) { return std::string(); } - int target_length = ::WideCharToMultiByte( + unsigned int target_length = ::WideCharToMultiByte( CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, - -1, nullptr, 0, nullptr, nullptr); - if (target_length == 0) { - return std::string(); - } + -1, nullptr, 0, nullptr, nullptr) + -1; // remove the trailing null character + int input_length = (int)wcslen(utf16_string); std::string utf8_string; + if (target_length == 0 || target_length > utf8_string.max_size()) { + return utf8_string; + } utf8_string.resize(target_length); int converted_length = ::WideCharToMultiByte( CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, - -1, utf8_string.data(), - target_length, nullptr, nullptr); + input_length, utf8_string.data(), target_length, nullptr, nullptr); if (converted_length == 0) { return std::string(); } diff --git a/windows/runner/win32_window.cpp b/windows/runner/win32_window.cpp index 10a458a3..60608d0f 100644 --- a/windows/runner/win32_window.cpp +++ b/windows/runner/win32_window.cpp @@ -1,15 +1,31 @@ #include "win32_window.h" +#include #include #include "resource.h" -#include "app_links/app_links_plugin_c_api.h" - namespace { +/// Window attribute that enables dark mode window decorations. +/// +/// Redefined in case the developer's machine has a Windows SDK older than +/// version 10.0.22000.0. +/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute +#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE +#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +#endif + constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; +/// Registry key for app theme preference. +/// +/// A value of 0 indicates apps should use dark mode. A non-zero or missing +/// value indicates apps should use light mode. +constexpr const wchar_t kGetPreferredBrightnessRegKey[] = + L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; +constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; + // The number of Win32Window objects that currently exist. static int g_active_window_count = 0; @@ -33,8 +49,8 @@ void EnableFullDpiSupportIfAvailable(HWND hwnd) { GetProcAddress(user32_module, "EnableNonClientDpiScaling")); if (enable_non_client_dpi_scaling != nullptr) { enable_non_client_dpi_scaling(hwnd); - FreeLibrary(user32_module); } + FreeLibrary(user32_module); } } // namespace @@ -44,7 +60,7 @@ class WindowClassRegistrar { public: ~WindowClassRegistrar() = default; - // Returns the singleton registar instance. + // Returns the singleton registrar instance. static WindowClassRegistrar* GetInstance() { if (!instance_) { instance_ = new WindowClassRegistrar(); @@ -104,13 +120,9 @@ Win32Window::~Win32Window() { Destroy(); } -bool Win32Window::CreateAndShow(const std::wstring& title, - const Point& origin, - const Size& size) { - if (SendAppLinkToInstance(title)) { - return false; - } - +bool Win32Window::Create(const std::wstring& title, + const Point& origin, + const Size& size) { Destroy(); const wchar_t* window_class = @@ -123,7 +135,7 @@ bool Win32Window::CreateAndShow(const std::wstring& title, double scale_factor = dpi / 96.0; HWND window = CreateWindow( - window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, + window_class, title.c_str(), WS_OVERLAPPEDWINDOW, Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), Scale(size.width, scale_factor), Scale(size.height, scale_factor), nullptr, nullptr, GetModuleHandle(nullptr), this); @@ -132,44 +144,15 @@ bool Win32Window::CreateAndShow(const std::wstring& title, return false; } + UpdateTheme(window); + return OnCreate(); } -bool Win32Window::SendAppLinkToInstance(const std::wstring& title) { - // Find our exact window - HWND hwnd = ::FindWindow(kWindowClassName, title.c_str()); - - if (hwnd) { - // Dispatch new link to current window - SendAppLink(hwnd); - - // (Optional) Restore our window to front in same state - WINDOWPLACEMENT place = { sizeof(WINDOWPLACEMENT) }; - GetWindowPlacement(hwnd, &place); - - switch (place.showCmd) { - case SW_SHOWMAXIMIZED: - ShowWindow(hwnd, SW_SHOWMAXIMIZED); - break; - case SW_SHOWMINIMIZED: - ShowWindow(hwnd, SW_RESTORE); - break; - default: - ShowWindow(hwnd, SW_NORMAL); - break; - } - - SetWindowPos(0, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE); - SetForegroundWindow(hwnd); - - // Window has been found, don't create another one. - return true; - } - - return false; +bool Win32Window::Show() { + return ShowWindow(window_handle_, SW_SHOWNORMAL); } - // static LRESULT CALLBACK Win32Window::WndProc(HWND const window, UINT const message, @@ -229,6 +212,10 @@ Win32Window::MessageHandler(HWND hwnd, SetFocus(child_content_); } return 0; + + case WM_DWMCOLORIZATIONCOLORCHANGED: + UpdateTheme(hwnd); + return 0; } return DefWindowProc(window_handle_, message, wparam, lparam); @@ -284,3 +271,18 @@ bool Win32Window::OnCreate() { void Win32Window::OnDestroy() { // No-op; provided for subclasses. } + +void Win32Window::UpdateTheme(HWND const window) { + DWORD light_mode; + DWORD light_mode_size = sizeof(light_mode); + LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, + kGetPreferredBrightnessRegValue, + RRF_RT_REG_DWORD, nullptr, &light_mode, + &light_mode_size); + + if (result == ERROR_SUCCESS) { + BOOL enable_dark_mode = light_mode == 0; + DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, + &enable_dark_mode, sizeof(enable_dark_mode)); + } +} diff --git a/windows/runner/win32_window.h b/windows/runner/win32_window.h index 9cfea10a..e901dde6 100644 --- a/windows/runner/win32_window.h +++ b/windows/runner/win32_window.h @@ -28,15 +28,16 @@ class Win32Window { Win32Window(); virtual ~Win32Window(); - // Creates and shows a win32 window with |title| and position and size using + // Creates a win32 window with |title| that is positioned and sized using // |origin| and |size|. New windows are created on the default monitor. Window // sizes are specified to the OS in physical pixels, hence to ensure a - // consistent size to will treat the width height passed in to this function - // as logical pixels and scale to appropriate for the default monitor. Returns - // true if the window was created successfully. - bool CreateAndShow(const std::wstring& title, - const Point& origin, - const Size& size); + // consistent size this function will scale the inputted width and height as + // as appropriate for the default monitor. The window is invisible until + // |Show| is called. Returns true if the window was created successfully. + bool Create(const std::wstring& title, const Point& origin, const Size& size); + + // Show the current window. Returns true if the window was successfully shown. + bool Show(); // Release OS resources associated with window. void Destroy(); @@ -76,7 +77,7 @@ class Win32Window { // OS callback called by message pump. Handles the WM_NCCREATE message which // is passed when the non-client area is being created and enables automatic // non-client DPI scaling so that the non-client area automatically - // responsponds to changes in DPI. All other messages are handled by + // responds to changes in DPI. All other messages are handled by // MessageHandler. static LRESULT CALLBACK WndProc(HWND const window, UINT const message, @@ -86,6 +87,9 @@ class Win32Window { // Retrieves a class instance pointer for |window| static Win32Window* GetThisFromHandle(HWND const window) noexcept; + // Update the window frame's theme to match the system theme. + static void UpdateTheme(HWND const window); + bool quit_on_close_ = false; // window handle for top level window. @@ -93,11 +97,6 @@ class Win32Window { // window handle for hosted content. HWND child_content_ = nullptr; - - // Dispatches link if any. - // This method enables our app to be with a single instance too. - // This is mandatory if you want to catch further links in same app. - bool SendAppLinkToInstance(const std::wstring& title); }; #endif // RUNNER_WIN32_WINDOW_H_ From 594c597004641dfb0f35d227ff942b792c92665c Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Sat, 19 Oct 2024 18:27:09 +0300 Subject: [PATCH 021/102] refactor: Delete unused widgets --- .../dashboard_widgets/balance.dart | 225 ------------------ .../dashboard_widgets/dashboard_widgets.dart | 3 - .../dashboard_widgets/delegation_stats.dart | 77 ------ .../dashboard_widgets/dual_coin_stats.dart | 119 --------- 4 files changed, 424 deletions(-) delete mode 100644 lib/widgets/modular_widgets/dashboard_widgets/balance.dart delete mode 100644 lib/widgets/modular_widgets/dashboard_widgets/delegation_stats.dart delete mode 100644 lib/widgets/modular_widgets/dashboard_widgets/dual_coin_stats.dart diff --git a/lib/widgets/modular_widgets/dashboard_widgets/balance.dart b/lib/widgets/modular_widgets/dashboard_widgets/balance.dart deleted file mode 100644 index 941b5069..00000000 --- a/lib/widgets/modular_widgets/dashboard_widgets/balance.dart +++ /dev/null @@ -1,225 +0,0 @@ -import 'package:auto_size_text/auto_size_text.dart'; -import 'package:fl_chart/fl_chart.dart'; -import 'package:flutter/material.dart'; -import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; - -const String _kWidgetTitle = 'Balance'; -final String _kWidgetDescription = 'This card displays the current ' - '${kZnnCoin.symbol} and ${kQsrCoin.symbol} amounts for the selected address'; - -class BalanceWidget extends StatefulWidget { - const BalanceWidget({ - super.key, - }); - - @override - State createState() => _BalanceWidgetState(); -} - -class _BalanceWidgetState extends State { - String? _touchedTokenStandard; - Color? _backgroundAddressColor; - Color? _colorAddressPrefixSuffix; - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - _colorAddressPrefixSuffix ??= Theme.of(context).hintColor; - _backgroundAddressColor ??= Theme.of(context).colorScheme.surface; - } - - @override - Widget build(BuildContext context) { - return ViewModelBuilder.reactive( - viewModelBuilder: BalanceDashboardBloc.new, - onViewModelReady: (model) { - model.getDataPeriodically(); - }, - builder: (_, model, __) => CardScaffold( - description: _kWidgetDescription, - childStream: model.stream, - onCompletedStatusCallback: _widgetBody, - title: _kWidgetTitle, - ), - ); - } - - Widget _widgetBody(AccountInfo accountInfo) { - return Column( - children: [ - kVerticalSpacing, - Expanded( - child: Stack( - alignment: Alignment.center, - children: [ - AspectRatio( - aspectRatio: 1, - child: StandardPieChart( - sections: _getChartSection(accountInfo), - onChartSectionTouched: (pieChartSection) { - setState(() { - _touchedTokenStandard = - pieChartSection?.touchedSection?.title; - }); - },), - ), - if (_touchedTokenStandard != null) _getBalance(accountInfo) else Container(), - ], - ), - ), - FocusableActionDetector( - onShowHoverHighlight: (x) { - if (x) { - setState(() { - _colorAddressPrefixSuffix = AppColors.znnColor; - }); - } else { - setState(() { - _colorAddressPrefixSuffix = Theme.of(context).hintColor; - }); - } - }, - child: Container( - decoration: BoxDecoration( - color: _backgroundAddressColor, - border: Border.all(color: _backgroundAddressColor!), - borderRadius: BorderRadius.circular(15), - ), - padding: const EdgeInsets.symmetric( - vertical: 4, - horizontal: 8, - ), - margin: const EdgeInsets.only( - bottom: 12, - top: 12, - ), - child: AutoSizeText.rich( - TextSpan( - children: [ - TextSpan( - text: kSelectedAddress!.substring(0, 3), - style: TextStyle(color: _colorAddressPrefixSuffix), - ), - TextSpan( - text: kSelectedAddress!.substring( - 3, - kSelectedAddress!.length - 6, - ), - style: TextStyle( - color: Theme.of(context).hintColor, - ), - ), - TextSpan( - text: kSelectedAddress!.substring( - kSelectedAddress!.length - 6, - kSelectedAddress!.length, - ), - style: TextStyle( - color: _colorAddressPrefixSuffix, - ), - ), - ], - ), - ), - ), - ), - const Divider(), - Padding( - padding: const EdgeInsets.all(8), - child: Row( - children: [ - Expanded( - child: _getCoinBalanceInfo(kZnnCoin, accountInfo), - ), - Expanded( - child: _getCoinBalanceInfo(kQsrCoin, accountInfo), - ), - ], - ), - ), - ], - ); - } - - FormattedAmountWithTooltip _getCoinBalanceInfo( - Token coin, - AccountInfo accountInfo, - ) { - return FormattedAmountWithTooltip( - amount: accountInfo - .getBalance( - coin.tokenStandard, - ) - .addDecimals(coin.decimals), - tokenSymbol: coin.symbol, - builder: (amount, tokenSymbol) => AmountInfoColumn( - context: context, - amount: amount, - tokenSymbol: tokenSymbol, - ), - ); - } - - List _getChartSection(AccountInfo accountInfo) { - final sections = []; - if (accountInfo.znn()! > BigInt.zero) { - sections.add( - _getBalanceChartSection( - accountInfo.findTokenByTokenStandard(kZnnCoin.tokenStandard)!, - accountInfo, - ), - ); - } - if (accountInfo.qsr()! > BigInt.zero) { - sections.add( - _getBalanceChartSection( - accountInfo.findTokenByTokenStandard(kQsrCoin.tokenStandard)!, - accountInfo, - ), - ); - } - - return sections; - } - - Widget _getBalance(AccountInfo accountInfo) { - final tokenStandard = TokenStandard.parse(_touchedTokenStandard!); - - return SizedBox( - width: 120, - child: AutoSizeText( - '${accountInfo.getBalance( - tokenStandard, - ).addDecimals(coinDecimals)} ${_touchedTokenStandard == kZnnCoin.tokenStandard.toString() ? kZnnCoin.symbol : kQsrCoin.symbol}', - textAlign: TextAlign.center, - style: Theme.of(context).textTheme.headlineMedium!.copyWith( - color: ColorUtils.getTokenColor(tokenStandard), - fontWeight: FontWeight.bold, - ), - ), - ); - } - - PieChartSectionData _getBalanceChartSection( - Token token, - AccountInfo accountInfo, - ) { - final isTouched = token.symbol == _touchedTokenStandard; - final opacity = isTouched ? 1.0 : 0.7; - - final value = accountInfo.getBalance(token.tokenStandard) / - (accountInfo.znn()! + accountInfo.qsr()!); - - return PieChartSectionData( - title: token.tokenStandard.toString(), - showTitle: false, - radius: 7, - color: ColorUtils.getTokenColor(token.tokenStandard).withOpacity(opacity), - value: value, - ); - } -} diff --git a/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart b/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart index d6c30b75..0d8b3f6a 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart @@ -1,6 +1,3 @@ -export 'balance.dart'; -export 'delegation_stats.dart'; -export 'dual_coin_stats.dart'; export 'pillars.dart'; export 'plasma_stats.dart'; export 'realtime_statistics.dart'; diff --git a/lib/widgets/modular_widgets/dashboard_widgets/delegation_stats.dart b/lib/widgets/modular_widgets/dashboard_widgets/delegation_stats.dart deleted file mode 100644 index 9aeb1239..00000000 --- a/lib/widgets/modular_widgets/dashboard_widgets/delegation_stats.dart +++ /dev/null @@ -1,77 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_vector_icons/flutter_vector_icons.dart'; -import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; - -const String _kWidgetTitle = 'Delegation Stats'; -final String _kWidgetDescription = 'This card displays the amount of ' - '${kZnnCoin.symbol} and the name of the Pillar that you delegated to'; - -class DelegationStats extends StatefulWidget { - const DelegationStats({super.key}); - - @override - State createState() => _DelegationStatsState(); -} - -class _DelegationStatsState extends State { - @override - Widget build(BuildContext context) { - return ViewModelBuilder.reactive( - viewModelBuilder: DelegationBloc.new, - onViewModelReady: (model) { - model.getDataPeriodically(); - }, - builder: (_, model, __) => CardScaffold( - childStream: model.stream, - onCompletedStatusCallback: _getWidgetBody, - title: _kWidgetTitle, - description: _kWidgetDescription, - ), - ); - } - - Widget _getWidgetBody(DelegationInfo delegationInfo) { - return Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - padding: const EdgeInsets.all(8), - width: 36, - height: 36, - decoration: BoxDecoration( - shape: BoxShape.circle, - border: Border.all( - color: delegationInfo.status == 1 - ? AppColors.znnColor - : AppColors.errorColor, - ), - ), - child: Icon( - SimpleLineIcons.trophy, - size: 12, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - Container(width: 16), - Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - delegationInfo.name, - style: Theme.of(context).textTheme.bodyMedium, - ), - Text( - '${delegationInfo.weight.addDecimals(coinDecimals)} ${kZnnCoin.symbol}', - style: Theme.of(context).textTheme.titleMedium, - ), - ], - ), - ], - ); - } -} diff --git a/lib/widgets/modular_widgets/dashboard_widgets/dual_coin_stats.dart b/lib/widgets/modular_widgets/dashboard_widgets/dual_coin_stats.dart deleted file mode 100644 index cf9e89d0..00000000 --- a/lib/widgets/modular_widgets/dashboard_widgets/dual_coin_stats.dart +++ /dev/null @@ -1,119 +0,0 @@ -import 'package:fl_chart/fl_chart.dart'; -import 'package:flutter/material.dart'; -import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/color_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; - -const String _kWidgetTitle = 'Dual Coin Stats'; -final String _kWidgetDescription = 'This card displays the circulating ' - '${kZnnCoin.symbol} and ${kQsrCoin.symbol} supply from the network'; - -class DualCoinStats extends StatefulWidget { - const DualCoinStats({ - super.key, - }); - - @override - State createState() => _DualCoinStatsState(); -} - -class _DualCoinStatsState extends State - with SingleTickerProviderStateMixin { - int? _touchedIndex; - - @override - Widget build(BuildContext context) { - return ViewModelBuilder.reactive( - viewModelBuilder: DualCoinStatsBloc.new, - onViewModelReady: (model) { - model.getDataPeriodically(); - }, - builder: (_, model, __) => CardScaffold>( - description: _kWidgetDescription, - childStream: model.stream, - onCompletedStatusCallback: _getWidgetBody, - title: _kWidgetTitle, - ), - ); - } - - Widget _getWidgetBody(List tokenList) { - return Column( - children: [ - Expanded( - child: AspectRatio( - aspectRatio: 1, - child: StandardPieChart( - sectionsSpace: 4, - centerSpaceRadius: 0, - sections: showingSections(tokenList), - onChartSectionTouched: (pieTouchedSection) { - setState(() { - _touchedIndex = pieTouchedSection?.touchedSectionIndex; - }); - }, - ), - ), - ), - const Divider(), - Padding( - padding: const EdgeInsets.all(8), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Expanded( - child: _getTokenSupplyInfoWidget(tokenList[0]!), - ), - Expanded( - child: _getTokenSupplyInfoWidget(tokenList[1]!), - ), - ], - ), - ), - ], - ); - } - - FormattedAmountWithTooltip _getTokenSupplyInfoWidget(Token token) { - return FormattedAmountWithTooltip( - amount: token.totalSupply.addDecimals( - token.decimals, - ), - tokenSymbol: token.symbol, - builder: (amount, symbol) => AmountInfoColumn( - amount: amount, - tokenSymbol: symbol, - context: context, - ), - ); - } - - List showingSections(List tokenList) { - final totalSupply = tokenList.fold( - BigInt.zero, - (previousValue, element) => previousValue + element!.totalSupply, - ); - return List.generate( - tokenList.length, - (i) { - final currentTokenInfo = tokenList[i]!; - final isTouched = i == _touchedIndex; - final opacity = isTouched ? 1.0 : 0.5; - return PieChartSectionData( - color: ColorUtils.getTokenColor(currentTokenInfo.tokenStandard) - .withOpacity(opacity), - value: currentTokenInfo.totalSupply / totalSupply, - title: currentTokenInfo.symbol, - radius: 60, - titleStyle: Theme.of(context).textTheme.titleSmall!.copyWith( - color: Colors.white, - ), - ); - }, - ); - } -} From cfa9e266095ae119609d9cc8d9ac3ca73399eda2 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Sat, 19 Oct 2024 20:36:10 +0300 Subject: [PATCH 022/102] feat: Add documentation of public members inside the dual_coin_stats folder --- .../cubit/dual_coin_stats_cubit.dart | 20 +++++++++++-------- .../cubit/dual_coin_stats_state.dart | 18 +++++++++++------ .../dual_coin_stats/dual_coin_stats.dart | 2 +- .../view/dual_coin_stats_card.dart | 8 ++++++-- .../widgets/dual_coin_stats_chart.dart | 6 +++++- .../widgets/dual_coin_stats_chart_legend.dart | 1 + .../dual_coin_stats_chart_legend_item.dart | 5 +++++ .../widgets/dual_coin_stats_empty.dart | 2 +- .../widgets/dual_coin_stats_error.dart | 2 ++ .../widgets/dual_coin_stats_loading.dart | 1 + .../widgets/dual_coin_stats_populated.dart | 3 +++ .../dual_coin_stats/widgets/widgets.dart | 2 +- 12 files changed, 50 insertions(+), 20 deletions(-) diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart index a3666381..c1e93214 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart @@ -7,19 +7,23 @@ part 'dual_coin_stats_state.dart'; /// for ZNN and QSR tokens. /// /// This cubit extends [DashboardCubit], using a list of `Token` objects to -/// represent the statistics for the ZNN and QSR tokens fetched from the Zenon network. -class DualCoinStatsCubit extends DashboardCubit, DualCoinStatsState> { - /// Constructs a `DualCoinStatsCubit`, passing the `zenon` client and the initial state - /// to the parent class. +/// represent the statistics for the ZNN and QSR tokens fetched from the Zenon +/// network. +class DualCoinStatsCubit + extends DashboardCubit, DualCoinStatsState> { + /// Constructs a `DualCoinStatsCubit`, passing the `zenon` client and the + /// initial state to the parent class. /// - /// The `zenon` client is used to interact with the Zenon network to retrieve token information. + /// The `zenon` client is used to interact with the Zenon network to retrieve + /// token information. DualCoinStatsCubit(super.zenon, super.initialState); /// Fetches the statistics for both ZNN and QSR tokens. /// - /// This method retrieves token data using the Zenon SDK's `getByZts()` method for each token, - /// executing the requests concurrently using `Future.wait()`. It returns a list containing - /// the fetched token data for ZNN and QSR. + /// This method retrieves token data using the Zenon SDK's 'getByZts()' + /// method for each token, executing the requests concurrently using + /// `Future.wait()`. It returns a list containing the fetched token data for + /// ZNN and QSR. /// /// Throws: /// - An error if any exception occurs during the fetching of token data. diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart index bae99b9c..172d1d85 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart @@ -1,13 +1,17 @@ part of 'dual_coin_stats_cubit.dart'; -/// The state class for the `DualCoinStatsCubit`, extending `DashboardState` to manage data related to ZNN and QSR. +/// The state class for the `DualCoinStatsCubit`, extending `DashboardState` to +/// manage data related to ZNN and QSR. /// -/// `DualCoinStatsState` stores a list of `Token?` objects representing data for two tokens. -/// This state is used by the `DualCoinStatsCubit` to track and update the state of both tokens. +/// `DualCoinStatsState` stores a list of `Token?` objects representing data +/// for two tokens. +/// This state is used by the `DualCoinStatsCubit` to track and update the +/// state of both tokens. class DualCoinStatsState extends DashboardState> { /// Constructs a new `DualCoinStatsState`. /// - /// This state is initialized with default `status`, `data`, and `error` values from the parent `DashboardState` class. + /// This state is initialized with default `status`, `data`, and `error` + /// values from the parent `DashboardState` class. /// It manages a list of `Token?` objects that represent the two tokens' data. const DualCoinStatsState({ super.status, @@ -15,13 +19,15 @@ class DualCoinStatsState extends DashboardState> { super.error, }); - /// Creates a copy of the current `DualCoinStatsState` with optional new values for `status`, `data`, and `error`. + /// Creates a copy of the current `DualCoinStatsState` with optional new + /// values for `status`, `data`, and `error`. /// /// This method is used to create a new state with updated fields if provided, /// otherwise retaining the existing values. /// /// Returns: - /// - A new instance of `DualCoinStatsState` with the updated values or the existing ones if none are provided. + /// - A new instance of `DualCoinStatsState` with the updated values or the + /// existing ones if none are provided. @override DashboardState> copyWith({ CubitStatus? status, diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/dual_coin_stats.dart b/lib/rearchitecture/dashboard/dual_coin_stats/dual_coin_stats.dart index ae28e4b1..3f05c0c3 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/dual_coin_stats.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/dual_coin_stats.dart @@ -1,3 +1,3 @@ export 'cubit/dual_coin_stats_cubit.dart'; export 'view/dual_coin_stats_card.dart'; -export 'widgets/widgets.dart'; \ No newline at end of file +export 'widgets/widgets.dart'; diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart b/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart index de0dbbb2..eaebb344 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart @@ -6,7 +6,12 @@ import 'package:zenon_syrius_wallet_flutter/utils/card/card.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart'; +/// Widget connected to the [DualCoinStatsCubit] that receives the state +/// - [DualCoinStatsState] - updates and rebuilds the UI according to the +/// state's status - [CubitStatus] class DualCoinStatsCard extends StatelessWidget { + + /// Create a DualCoinStatsCard. const DualCoinStatsCard({super.key}); @override @@ -16,8 +21,7 @@ class DualCoinStatsCard extends StatelessWidget { final cubit = DualCoinStatsCubit( zenon!, const DualCoinStatsState(), - ); - cubit.fetchDataPeriodically(); + )..fetchDataPeriodically(); return cubit; }, child: CardScaffoldWithoutListener( diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart.dart index 3f16735a..23b2b02c 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart.dart @@ -9,15 +9,19 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// /// When the cursor hovers over a section, that respective section is /// highlighted - class DualCoinStatsChart extends StatelessWidget { + /// Create a DualCoinStatsChart const DualCoinStatsChart({ required this.tokenList, required this.touchedSectionIndexNotifier, super.key, }); + + /// List of [Token] that will provide data for the chart final List tokenList; + /// ValueNotifier used for rebuilding the widget tree when a section of the + /// chart is being hovered over final ValueNotifier touchedSectionIndexNotifier; @override diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart index 781881c1..f7dc3e0b 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart @@ -9,6 +9,7 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class DualCoinStatsChartLegend extends StatelessWidget { + /// Creates a DualCoinStatsLegend const DualCoinStatsChartLegend({ required this.tokens, super.key, diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend_item.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend_item.dart index ec336084..1f60bb3a 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend_item.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend_item.dart @@ -3,9 +3,14 @@ import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +/// Generic legend item that takes a [token] and customizes +/// a [FormattedAmountWithTooltip] widget class DualCoinStatsChartLegendItem extends StatelessWidget { + /// Creates a DualCoinStatsCharLegendItem const DualCoinStatsChartLegendItem({required this.token, super.key}); + /// Provides the needed take that will be displayed final Token token; @override diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart index 9853b04f..0559c03c 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart @@ -4,8 +4,8 @@ import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_wi /// A widget associated with the [DualCoinStatsState] when it's status is /// [CubitStatus.initial] that uses the [SyriusErrorWidget] to display a message - class DualCoinStatsEmpty extends StatelessWidget { + /// Creates a DualCoinStatsEmpty const DualCoinStatsEmpty({super.key}); @override diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart index aab1654d..f904371f 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart @@ -8,7 +8,9 @@ import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widge class DualCoinStatsError extends StatelessWidget { + /// Creates a DualCoinStatsError object const DualCoinStatsError({required this.error, super.key}); + /// Holds the data that will be displayed final Object error; @override diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart index 4dee5716..ff9cc512 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart @@ -7,6 +7,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_wid /// loading indicator class DualCoinStatsLoading extends StatelessWidget { + /// Creates a DualCoinStatsLoading object const DualCoinStatsLoading({super.key}); @override diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart index 51816828..35034ee5 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart @@ -8,10 +8,13 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class DualCoinStatsPopulated extends StatefulWidget { + /// Creates a DualCoinStatsPopulated widget const DualCoinStatsPopulated({ required this.tokens, super.key, }); + + /// The list of [Token] that will provide data for the chart final List tokens; @override diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/widgets.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/widgets.dart index d0927a23..63eee441 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/widgets.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/widgets.dart @@ -4,4 +4,4 @@ export 'dual_coin_stats_chart_legend_item.dart'; export 'dual_coin_stats_empty.dart'; export 'dual_coin_stats_error.dart'; export 'dual_coin_stats_loading.dart'; -export 'dual_coin_stats_populated.dart'; \ No newline at end of file +export 'dual_coin_stats_populated.dart'; From 6acd44dd92d21aa0dddd5e36a3ec8cbc2da5baab Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Sat, 19 Oct 2024 21:06:29 +0300 Subject: [PATCH 023/102] feat: Replace Pillars with PillarsCard --- .../pillars/cubit/pillars_cubit.dart | 11 ++-- .../pillars/cubit/pillars_state.dart | 21 ++++--- .../dashboard/pillars/view/pillars_card.dart | 17 +++-- .../pillars/widgets/pillars_empty.dart | 9 ++- .../pillars/widgets/pillars_error.dart | 10 ++- .../pillars/widgets/pillars_loading.dart | 8 ++- .../pillars/widgets/pillars_populated.dart | 39 ++++++++++-- lib/utils/card/card_type.dart | 8 ++- .../dashboard_widgets/dashboard_widgets.dart | 1 - .../dashboard_widgets/pillars.dart | 63 ------------------- .../dashboard_tab_child.dart | 2 +- 11 files changed, 95 insertions(+), 94 deletions(-) delete mode 100644 lib/widgets/modular_widgets/dashboard_widgets/pillars.dart diff --git a/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart b/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart index e2e1f7cc..fa5765b0 100644 --- a/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart +++ b/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart @@ -7,16 +7,17 @@ part 'pillars_state.dart'; /// This cubit extends `DashboardCubit`, using an integer to represent the /// total number of pillars fetched from the Zenon network. class PillarsCubit extends DashboardCubit { - /// Constructs a `PillarsCubit`, passing the `zenon` client and the initial state - /// to the parent class. + /// Constructs a `PillarsCubit`, passing the `zenon` client and the initial + /// state to the parent class. /// - /// The `zenon` client is used to interact with the Zenon network to retrieve pillar information. + /// The `zenon` client is used to interact with the Zenon network to retrieve + /// pillar information. PillarsCubit(super.zenon, super.initialState); /// Fetches the total count of pillars from the Zenon network. /// - /// This method retrieves all pillar information using the Zenon SDK's `getAll()` method - /// and returns the total number of pillars as an integer. + /// This method retrieves all pillar information using the Zenon SDK's + /// `getAll()` method and returns the total number of pillars as an integer. /// /// Throws: /// - An error if any exception occurs during the fetching of pillar data. diff --git a/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart b/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart index da2d2e3c..8ab7cb7e 100644 --- a/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart +++ b/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart @@ -1,27 +1,34 @@ part of 'pillars_cubit.dart'; -/// The state class for the `PillarsCubit`, extending `DashboardState` to manage the data related to pillars. +/// The state class for the `PillarsCubit`, extending `DashboardState` to +/// manage the data related to pillars. /// -/// `PillarsState` stores an integer value representing the number of pillars retrieved from the Zenon network. -/// This state is used by the `PillarsCubit` to track and update the number of active pillars. +/// `PillarsState` stores an integer value representing the number of pillars +/// retrieved from the Zenon network. +/// This state is used by the `PillarsCubit` to track and update the number of +/// active pillars. class PillarsState extends DashboardState { /// Constructs a new `PillarsState`. /// - /// This state is initialized with the default `status`, `data`, and `error` values from the parent `DashboardState` class. - /// The `data` field in this case represents the count of active pillars on the Zenon network. + /// This state is initialized with the default `status`, `data`, and `error` + /// values from the parent `DashboardState` class. + /// The `data` field in this case represents the count of active pillars on + /// the Zenon network. const PillarsState({ super.status, super.data, super.error, }); - /// Creates a copy of the current `PillarsState` with optional new values for `status`, `data`, and `error`. + /// Creates a copy of the current `PillarsState` with optional new values for + /// `status`, `data`, and `error`. /// /// This method is used to create a new state with updated fields if provided, /// otherwise retaining the existing values. /// /// Returns: - /// - A new instance of `PillarsState` with the updated values or the existing ones if none are provided. + /// - A new instance of `PillarsState` with the updated values or the + /// existing ones if none are provided. @override DashboardState copyWith({ CubitStatus? status, diff --git a/lib/rearchitecture/dashboard/pillars/view/pillars_card.dart b/lib/rearchitecture/dashboard/pillars/view/pillars_card.dart index eb023942..09b16465 100644 --- a/lib/rearchitecture/dashboard/pillars/view/pillars_card.dart +++ b/lib/rearchitecture/dashboard/pillars/view/pillars_card.dart @@ -2,9 +2,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/card/card.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart'; - +/// Widget connected to the [PillarsCubit] that receives the state +/// - [PillarsState] - updates and rebuilds the UI according to the +/// state's status - [CubitStatus] class PillarsCard extends StatelessWidget { + /// Creates a PillarsCard const PillarsCard({super.key}); @override @@ -14,12 +19,12 @@ class PillarsCard extends StatelessWidget { final cubit = PillarsCubit( zenon!, const PillarsState(), - ); - cubit.fetchDataPeriodically(); + )..fetchDataPeriodically(); return cubit; }, - child: Scaffold( - body: BlocBuilder( + child: CardScaffoldWithoutListener( + data: CardType.pillars.getData(context: context), + body: BlocBuilder( builder: (context, state) { return switch (state.status) { CubitStatus.initial => const PillarsEmpty(), @@ -28,7 +33,7 @@ class PillarsCard extends StatelessWidget { error: state.error!, ), CubitStatus.success => PillarsPopulated( - data: state.data, + numberOfPillars: state.data!, ), }; }, diff --git a/lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart b/lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart index c19b43b2..4805f94a 100644 --- a/lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart +++ b/lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart @@ -1,10 +1,15 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; +/// A widget associated with the [PillarsState] when it's status is +/// [CubitStatus.initial] that uses the [SyriusErrorWidget] to display a message class PillarsEmpty extends StatelessWidget { + /// Creates a PillarsEmpty instance const PillarsEmpty({super.key}); @override Widget build(BuildContext context) { - return const Text('empty'); + return const SyriusErrorWidget('No data available'); } -} \ No newline at end of file +} diff --git a/lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart b/lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart index f650ed29..3a7af02a 100644 --- a/lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart +++ b/lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart @@ -1,12 +1,18 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; +/// A widget associated with the [PillarsState] when it's status is +/// [CubitStatus.failure] that uses the [SyriusErrorWidget] to display the +/// error message class PillarsError extends StatelessWidget { - + ///Creates a PillarsError object const PillarsError({required this.error, super.key}); + /// Holds the data that will be displayed final Object error; @override Widget build(BuildContext context) { - return Text(error.toString()); + return SyriusErrorWidget(error); } } diff --git a/lib/rearchitecture/dashboard/pillars/widgets/pillars_loading.dart b/lib/rearchitecture/dashboard/pillars/widgets/pillars_loading.dart index d2ee3aea..d0ede481 100644 --- a/lib/rearchitecture/dashboard/pillars/widgets/pillars_loading.dart +++ b/lib/rearchitecture/dashboard/pillars/widgets/pillars_loading.dart @@ -1,10 +1,16 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; +/// A widget associated with the [PillarsState] when it's status is +/// [CubitStatus.loading] that uses the [SyriusLoadingWidget] to display a +/// loading indicator class PillarsLoading extends StatelessWidget { + /// Creates a PillarsLoading object const PillarsLoading({super.key}); @override Widget build(BuildContext context) { - return const Text('loading'); + return const SyriusLoadingWidget(); } } \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/pillars/widgets/pillars_populated.dart b/lib/rearchitecture/dashboard/pillars/widgets/pillars_populated.dart index 5c5a0062..78c8c922 100644 --- a/lib/rearchitecture/dashboard/pillars/widgets/pillars_populated.dart +++ b/lib/rearchitecture/dashboard/pillars/widgets/pillars_populated.dart @@ -1,12 +1,41 @@ import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; +/// A widget associated with the [PillarsState] when it's status is +/// [CubitStatus.success] that displays the number of pillars class PillarsPopulated extends StatelessWidget { - - const PillarsPopulated({required this.data, super.key}); - final int? data; + /// Creates a PillarsPopulated object + const PillarsPopulated({required this.numberOfPillars, super.key}); + /// Number of pillars in the network + final int numberOfPillars; @override Widget build(BuildContext context) { - return Text(data.toString()); + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SvgPicture.asset( + 'assets/svg/ic_pillars_dashboard.svg', + width: 65, + ), + Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + NumberAnimation( + end: numberOfPillars, + isInt: true, + style: Theme.of(context).textTheme.headlineMedium, + ), + Text( + 'Active Pillars', + style: Theme.of(context).textTheme.titleMedium, + ), + ], + ), + ], + ); } -} \ No newline at end of file +} diff --git a/lib/utils/card/card_type.dart b/lib/utils/card/card_type.dart index c41cc325..6448cd05 100644 --- a/lib/utils/card/card_type.dart +++ b/lib/utils/card/card_type.dart @@ -6,7 +6,8 @@ import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; enum CardType { balance, delegationStats, - dualCoinStats; + dualCoinStats, + pillars; CardData getData({ required BuildContext context, @@ -27,6 +28,11 @@ enum CardType { description: 'This card displays the circulating ${kZnnCoin.symbol} ' 'and ${kQsrCoin.symbol} supply from the network', ), + CardType.pillars => CardData( + title: 'Pillars', + description: 'This card displays the number of active ' + 'Pillars in the network', + ), }; } } diff --git a/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart b/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart index 0d8b3f6a..1459a8d8 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart @@ -1,4 +1,3 @@ -export 'pillars.dart'; export 'plasma_stats.dart'; export 'realtime_statistics.dart'; export 'sentinels.dart'; diff --git a/lib/widgets/modular_widgets/dashboard_widgets/pillars.dart b/lib/widgets/modular_widgets/dashboard_widgets/pillars.dart deleted file mode 100644 index fd885a33..00000000 --- a/lib/widgets/modular_widgets/dashboard_widgets/pillars.dart +++ /dev/null @@ -1,63 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; - -const String _kWidgetTitle = 'Pillars'; -const String _kWidgetDescription = 'This card displays the number of active ' - 'Pillars in the network'; - -class Pillars extends StatefulWidget { - const Pillars({ - super.key, - }); - - @override - State createState() => _PillarsState(); -} - -class _PillarsState extends State { - @override - Widget build(BuildContext context) { - return ViewModelBuilder.reactive( - viewModelBuilder: PillarsBloc.new, - onViewModelReady: (model) { - model.getDataPeriodically(); - }, - builder: (_, model, __) => CardScaffold( - childStream: model.stream, - onCompletedStatusCallback: _widgetBody, - title: _kWidgetTitle, - description: _kWidgetDescription, - ), - ); - } - - Row _widgetBody(int numOfPillars) { - return Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SvgPicture.asset( - 'assets/svg/ic_pillars_dashboard.svg', - width: 65, - ), - Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - NumberAnimation( - end: numOfPillars, - isInt: true, - style: Theme.of(context).textTheme.headlineMedium, - ), - Text( - 'Active Pillars', - style: Theme.of(context).textTheme.titleMedium, - ), - ], - ), - ], - ); - } -} diff --git a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart index e3e52845..0cbef9fd 100644 --- a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart +++ b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart @@ -56,7 +56,7 @@ class _DashboardTabChildState extends State { height: kStaggeredNumOfColumns / 4, ), const FluidCell( - child: Pillars(), + child: PillarsCard(), height: kStaggeredNumOfColumns / 8, ), const FluidCell( From 95746e1fa02416af1853591068fd0b3c4d6ba5fe Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Sun, 20 Oct 2024 09:28:45 +0300 Subject: [PATCH 024/102] feat: Replace RealtimeStatistics with RealtimeStatisticsCard --- .../cubit/realtime_statistics_cubit.dart | 47 +++++++------ .../cubit/realtime_statistics_state.dart | 21 ++++-- .../view/realtime_statistics_card.dart | 14 ++-- .../widgets/realtime_statistics_empty.dart | 5 +- .../widgets/realtime_statistics_error.dart | 5 +- .../widgets/realtime_statistics_loading.dart | 3 +- .../realtime_statistics_populated.dart | 41 ++++++++++-- .../widgets}/realtime_txs_chart.dart | 5 +- lib/utils/card/card_type.dart | 15 ++++- lib/utils/exceptions/exceptions.dart | 1 + .../no_blocks_available_exception.dart | 8 +++ lib/utils/utils.dart | 1 + .../dashboard_widgets/dashboard_widgets.dart | 1 - .../realtime_statistics.dart | 66 ------------------- .../dashboard_tab_child.dart | 2 +- lib/widgets/widgets.dart | 2 +- 16 files changed, 123 insertions(+), 114 deletions(-) rename lib/{widgets/charts => rearchitecture/dashboard/realtime_statistics/widgets}/realtime_txs_chart.dart (95%) create mode 100644 lib/utils/exceptions/exceptions.dart create mode 100644 lib/utils/exceptions/no_blocks_available_exception.dart delete mode 100644 lib/widgets/modular_widgets/dashboard_widgets/realtime_statistics.dart diff --git a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart index 04a7847b..ed730a50 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart @@ -1,5 +1,6 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/exceptions/exceptions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -9,28 +10,34 @@ part 'realtime_statistics_state.dart'; /// account block statistics for a specific address. /// /// This cubit extends `DashboardCubit>`, using a list of -/// `AccountBlock` objects to represent the account blocks fetched from the Zenon network. -class RealtimeStatisticsCubit extends DashboardCubit, RealtimeStatisticsState> { - /// Constructs a `RealtimeStatisticsCubit`, passing the `zenon` client and the initial state - /// to the parent class. +/// `AccountBlock` objects to represent the account blocks fetched from the +/// Zenon network. +class RealtimeStatisticsCubit + extends DashboardCubit, RealtimeStatisticsState> { + /// Constructs a `RealtimeStatisticsCubit`, passing the `zenon` client and + /// the initial state to the parent class. /// - /// The `zenon` client is used to interact with the Zenon network to retrieve account block information. + /// The `zenon` client is used to interact with the Zenon network to retrieve + /// account block information. RealtimeStatisticsCubit(super.zenon, super.initialState); - /// Fetches a list of account blocks for the specified address over the past week. + /// Fetches a list of account blocks for the specified address over the past + /// week. /// /// This method retrieves the account blocks by: /// - Determining the chain height using the `getFrontierMomentum()` method. /// - Calculating the starting height based on the momentums per week. - /// - Fetching account blocks page by page until there are no more blocks to retrieve. - /// - The loop continues until either the blocks are exhausted or the last block's momentum height - /// is less than the calculated height. + /// - Fetching account blocks page by page until there are no more blocks to + /// retrieve. + /// - The loop continues until either the blocks are exhausted or the last + /// block's momentum height is less than the calculated height. /// /// Returns: - /// - A list of `AccountBlock` objects representing the account blocks fetched from the network. + /// - A list of `AccountBlock` objects representing the account blocks + /// fetched from the network. /// /// Throws: - /// - An error if no data is available or if any exception occurs during the fetching process. + /// - An [NoBlocksAvailableException] if no data is available @override Future> fetch() async { try { @@ -43,19 +50,19 @@ class RealtimeStatisticsCubit extends DashboardCubit, Realtim var pageIndex = 0; // Start from the first page const pageSize = 10; // Number of blocks to fetch per page var isLastPage = false; // Flag to determine if it's the last page - final blockList = []; // List to store fetched account blocks + final blockList = + []; // List to store fetched account blocks // Fetch account blocks until the last page is reached while (!isLastPage) { // Fetch account blocks for the current page - final response = - (await zenon.ledger.getAccountBlocksByPage( + final response = (await zenon.ledger.getAccountBlocksByPage( Address.parse(kSelectedAddress!), pageIndex: pageIndex, pageSize: pageSize, )) .list ?? // Default to an empty list if no blocks are found - []; + []; if (response.isEmpty) { break; // Exit the loop if no more blocks are found @@ -63,22 +70,24 @@ class RealtimeStatisticsCubit extends DashboardCubit, Realtim blockList.addAll(response); // Add the fetched blocks to the list - // Check if the last block's momentum height is less than the calculated height + // Check if the last block's momentum height is less than the + // calculated height if (response.last.confirmationDetail!.momentumHeight <= height) { break; // Exit if we've fetched enough data } pageIndex += 1; // Increment the page index for the next fetch - isLastPage = response.length < pageSize; // Check if this is the last page + isLastPage = + response.length < pageSize; // Check if this is the last page } if (blockList.isNotEmpty) { return blockList; // Return the list of fetched blocks if available } else { - throw 'No available data'; // Throw an error if no data is found + throw NoBlocksAvailableException(); } } catch (e) { rethrow; } } -} \ No newline at end of file +} diff --git a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart index 9bbff3b1..2dfcdc70 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart @@ -1,26 +1,33 @@ part of 'realtime_statistics_cubit.dart'; -/// The state class for `RealtimeStatisticsCubit`, which extends `DashboardState` to handle real-time statistics data. +/// The state class for [RealtimeStatisticsCubit], which extends +/// [DashboardState] to handle real-time statistics data. /// -/// This class manages a list of `AccountBlock` objects representing real-time blockchain data, such as recent transactions. -/// It's used to track the state of the data loading process in the `RealtimeStatisticsCubit`. +/// This class manages a list of `AccountBlock` objects representing real-time +/// blockchain data, such as recent transactions. +/// It's used to track the state of the data loading process in the +/// `RealtimeStatisticsCubit`. class RealtimeStatisticsState extends DashboardState> { - /// Constructs a new `RealtimeStatisticsState` with optional values for `status`, `data`, and `error`. + /// Constructs a new `RealtimeStatisticsState` with optional values for + /// `status`, `data`, and `error`. /// - /// The `data` field stores a list of `AccountBlock` objects that represent real-time blockchain statistics. + /// The `data` field stores a list of `AccountBlock` objects that represent + /// real-time blockchain statistics. const RealtimeStatisticsState({ super.status, super.data, super.error, }); - /// Creates a copy of the current `RealtimeStatisticsState` with updated values for `status`, `data`, or `error`. + /// Creates a copy of the current `RealtimeStatisticsState` with updated + /// values for `status`, `data`, or `error`. /// /// This method is used to create a new state with updated fields if provided, /// otherwise retaining the existing values. /// /// Returns: - /// - A new instance of `RealtimeStatisticsState` with the updated values or the existing ones if none are provided. + /// - A new instance of `RealtimeStatisticsState` with the updated values or + /// the existing ones if none are provided. @override DashboardState> copyWith({ CubitStatus? status, diff --git a/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart b/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart index c38c61b3..d95e9319 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart @@ -2,8 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; - - +import 'package:zenon_syrius_wallet_flutter/utils/card/card.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart'; class RealtimeStatisticsCard extends StatelessWidget { const RealtimeStatisticsCard({super.key}); @@ -15,12 +15,12 @@ class RealtimeStatisticsCard extends StatelessWidget { final cubit = RealtimeStatisticsCubit( zenon!, const RealtimeStatisticsState(), - ); - cubit.fetchDataPeriodically(); + )..fetchDataPeriodically(); return cubit; }, - child: Scaffold( - body: BlocBuilder( + child: CardScaffoldWithoutListener( + data: CardType.realtimeStatistics.getData(context: context), + body: BlocBuilder( builder: (context, state) { return switch (state.status) { CubitStatus.initial => const RealtimeStatisticsEmpty(), @@ -29,7 +29,7 @@ class RealtimeStatisticsCard extends StatelessWidget { error: state.error!, ), CubitStatus.success => RealtimeStatisticsPopulated( - data: state.data!, + accountBlocks: state.data!, ), }; }, diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_empty.dart b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_empty.dart index 9bc76ffd..bb2fe790 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_empty.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_empty.dart @@ -1,10 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; class RealtimeStatisticsEmpty extends StatelessWidget { const RealtimeStatisticsEmpty({super.key}); @override Widget build(BuildContext context) { - return const Text('empty'); + return const SyriusErrorWidget('No data available'); } -} \ No newline at end of file +} diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart index e6689e63..c0bbb54e 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; class RealtimeStatisticsError extends StatelessWidget { @@ -7,6 +8,6 @@ class RealtimeStatisticsError extends StatelessWidget { @override Widget build(BuildContext context) { - return Text(error.toString()); + return SyriusErrorWidget(error); } -} \ No newline at end of file +} diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_loading.dart b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_loading.dart index 8c6d61db..a79724bb 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_loading.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_loading.dart @@ -1,10 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; class RealtimeStatisticsLoading extends StatelessWidget { const RealtimeStatisticsLoading({super.key}); @override Widget build(BuildContext context) { - return const Text('loading'); + return const SyriusLoadingWidget(); } } \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart index 35f598a1..030c6186 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart @@ -1,13 +1,46 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; +/// A widget associated with the [RealtimeStatisticsState] when it's status is +/// [CubitStatus.success] +/// +/// Displays a chart highlighting the number of blocks in QSR and ZNN signed +/// with a particular address in the last seven days class RealtimeStatisticsPopulated extends StatelessWidget { + const RealtimeStatisticsPopulated({required this.accountBlocks, super.key}); - const RealtimeStatisticsPopulated({required this.data, super.key}); - final List data; + final List accountBlocks; @override Widget build(BuildContext context) { - return Text(data.toString()); + return Padding( + padding: const EdgeInsets.all(16), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ChartLegend( + dotColor: ColorUtils.getTokenColor(kQsrCoin.tokenStandard), + mainText: '${kQsrCoin.symbol} ' + 'transactions', + ), + const SizedBox( + width: 10, + ), + ChartLegend( + dotColor: ColorUtils.getTokenColor(kZnnCoin.tokenStandard), + mainText: '${kZnnCoin.symbol} ' + 'transactions', + ), + ], + ), + Expanded(child: RealtimeTxsChart(accountBlocks)), + ], + ), + ); } -} \ No newline at end of file +} diff --git a/lib/widgets/charts/realtime_txs_chart.dart b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_txs_chart.dart similarity index 95% rename from lib/widgets/charts/realtime_txs_chart.dart rename to lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_txs_chart.dart index 18817c50..e8a0e8dc 100644 --- a/lib/widgets/charts/realtime_txs_chart.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_txs_chart.dart @@ -8,6 +8,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; +/// Shows a chart based on the provided [transactions] class RealtimeTxsChart extends StatefulWidget { const RealtimeTxsChart( @@ -17,10 +18,10 @@ class RealtimeTxsChart extends StatefulWidget { final List transactions; @override - State createState() => RealtimeTxsChartState(); + State createState() => _RealtimeTxsChartState(); } -class RealtimeTxsChartState extends State { +class _RealtimeTxsChartState extends State { double _maxTransactionsPerDay = 0; List? _znnSpots; diff --git a/lib/utils/card/card_type.dart b/lib/utils/card/card_type.dart index 6448cd05..5d8f35e6 100644 --- a/lib/utils/card/card_type.dart +++ b/lib/utils/card/card_type.dart @@ -7,8 +7,12 @@ enum CardType { balance, delegationStats, dualCoinStats, - pillars; + pillars, + realtimeStatistics; + /// Returns the [CardData] assigned to a specific [CardType] value. + /// + /// The parameter [context] is used to retrieve the localized strings CardData getData({ required BuildContext context, }) { @@ -33,6 +37,15 @@ enum CardType { description: 'This card displays the number of active ' 'Pillars in the network', ), + CardType.realtimeStatistics => CardData( + title: 'Realtime Stats', + description: + 'This card displays the number of ${kZnnCoin.symbol} and ' + '${kQsrCoin.symbol} transactions. For example, a delegation is ' + "considered a ${kZnnCoin.symbol} transaction from the network's " + 'perspective. Every interaction with the network embedded ' + 'contracts is internally considered a transaction', + ), }; } } diff --git a/lib/utils/exceptions/exceptions.dart b/lib/utils/exceptions/exceptions.dart new file mode 100644 index 00000000..062f575d --- /dev/null +++ b/lib/utils/exceptions/exceptions.dart @@ -0,0 +1 @@ +export 'no_blocks_available_exception.dart'; diff --git a/lib/utils/exceptions/no_blocks_available_exception.dart b/lib/utils/exceptions/no_blocks_available_exception.dart new file mode 100644 index 00000000..0a3a10df --- /dev/null +++ b/lib/utils/exceptions/no_blocks_available_exception.dart @@ -0,0 +1,8 @@ +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; + +/// Custom [Exception] to be used with [RealtimeStatisticsCubit] when there are +/// no account blocks available on the network +class NoBlocksAvailableException implements Exception { + @override + String toString() => 'No account blocks available'; +} diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 8cff3ac2..27080864 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -8,6 +8,7 @@ export 'color_utils.dart'; export 'constants.dart'; export 'date_time_utils.dart'; export 'device_utils.dart'; +export 'exceptions/exceptions.dart'; export 'extensions.dart'; export 'file_utils.dart'; export 'format_utils.dart'; diff --git a/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart b/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart index 1459a8d8..1f14c066 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart @@ -1,5 +1,4 @@ export 'plasma_stats.dart'; -export 'realtime_statistics.dart'; export 'sentinels.dart'; export 'staking.dart'; export 'total_hourly_transactions.dart'; diff --git a/lib/widgets/modular_widgets/dashboard_widgets/realtime_statistics.dart b/lib/widgets/modular_widgets/dashboard_widgets/realtime_statistics.dart deleted file mode 100644 index 7d5411f0..00000000 --- a/lib/widgets/modular_widgets/dashboard_widgets/realtime_statistics.dart +++ /dev/null @@ -1,66 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/color_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; - -const String _kWidgetTitle = 'Realtime Stats'; -final String _kWidgetDescription = - 'This card displays the number of ${kZnnCoin.symbol} and ' - '${kQsrCoin.symbol} transactions. For example, a delegation is considered a ' - "${kZnnCoin.symbol} transaction from the network's perspective. Every interaction " - 'with the network embedded contracts is internally considered a transaction'; - -class RealtimeStatistics extends StatefulWidget { - const RealtimeStatistics({super.key}); - - @override - State createState() => _RealtimeStatisticsState(); -} - -class _RealtimeStatisticsState extends State { - @override - Widget build(BuildContext context) { - return ViewModelBuilder.reactive( - viewModelBuilder: RealtimeStatisticsBloc.new, - onViewModelReady: (model) { - model.getDataPeriodically(); - }, - builder: (_, model, __) => CardScaffold>( - childStream: model.stream, - title: _kWidgetTitle, - description: _kWidgetDescription, - onCompletedStatusCallback: _widgetBody, - ), - ); - } - - Widget _widgetBody(List list) { - return Padding( - padding: const EdgeInsets.all(16), - child: Column(children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - ChartLegend( - dotColor: ColorUtils.getTokenColor(kQsrCoin.tokenStandard), - mainText: '${kQsrCoin.symbol} ' - 'transactions', - ), - const SizedBox( - width: 10, - ), - ChartLegend( - dotColor: ColorUtils.getTokenColor(kZnnCoin.tokenStandard), - mainText: '${kZnnCoin.symbol} ' - 'transactions', - ), - ], - ), - Expanded(child: RealtimeTxsChart(list)), - ],), - ); - } -} diff --git a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart index 0cbef9fd..9d8fa5e4 100644 --- a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart +++ b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart @@ -76,7 +76,7 @@ class _DashboardTabChildState extends State { width: defaultCellWidth * 2, ), FluidCell( - child: const RealtimeStatistics(), + child: const RealtimeStatisticsCard(), width: defaultCellWidth * 2, ), FluidCell( diff --git a/lib/widgets/widgets.dart b/lib/widgets/widgets.dart index 7a7c38dc..a3ce88fa 100644 --- a/lib/widgets/widgets.dart +++ b/lib/widgets/widgets.dart @@ -1,5 +1,5 @@ export 'charts/pillar_rewards_chart.dart'; -export 'charts/realtime_txs_chart.dart'; +export '../rearchitecture/dashboard/realtime_statistics/widgets/realtime_txs_chart.dart'; export 'charts/sentinel_rewards_chart.dart'; export 'charts/staking_rewards_chart.dart'; export 'main_app_container.dart'; From bebc154a260221cb9478fc799999b12064fa5879 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Wed, 23 Oct 2024 12:37:29 +0300 Subject: [PATCH 025/102] feat: Fill up the sentinels widgets --- .../sentinels/cubit/sentinels_cubit.dart | 18 ++--- .../sentinels/cubit/sentinels_state.dart | 18 +++-- .../sentinels/view/sentinels_card.dart | 16 +++-- .../sentinels/widgets/sentinels_empty.dart | 9 ++- .../sentinels/widgets/sentinels_error.dart | 8 ++- .../sentinels/widgets/sentinels_loading.dart | 9 ++- .../widgets/sentinels_populated.dart | 37 ++++++++++- lib/utils/card/card_type.dart | 8 ++- lib/widgets/main_app_container.dart | 2 +- .../dashboard_widgets/dashboard_widgets.dart | 1 - .../dashboard_widgets/sentinels.dart | 65 ------------------- .../dashboard_tab_child.dart | 2 +- 12 files changed, 96 insertions(+), 97 deletions(-) delete mode 100644 lib/widgets/modular_widgets/dashboard_widgets/sentinels.dart diff --git a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart index b40bd782..094ecca8 100644 --- a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart +++ b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart @@ -6,19 +6,22 @@ part 'sentinels_state.dart'; /// `SentinelsCubit` manages the fetching and state of sentinel information. /// -/// This cubit extends `DashboardCubit`, using a `SentinelInfoList` -/// object to represent the list of active sentinels fetched from the Zenon network. +/// This cubit extends `DashboardCubit`, using a +/// `SentinelInfoList` object to represent the list of active sentinels +/// fetched from the Zenon network. class SentinelsCubit extends DashboardCubit { - /// Constructs a `SentinelsCubit`, passing the `zenon` client and the initial state - /// to the parent class. + /// Constructs a `SentinelsCubit`, passing the `zenon` client and the initial + /// state to the parent class. /// - /// The `zenon` client is used to interact with the Zenon network to retrieve sentinel information. + /// The `zenon` client is used to interact with the Zenon network to retrieve + /// sentinel information. SentinelsCubit(super.zenon, super.initialState); /// Fetches a list of active sentinels from the Zenon network. /// - /// This method calls the Zenon SDK's `getAllActive()` method to retrieve the list of active - /// sentinels. The fetched data is returned as a `SentinelInfoList`. + /// This method calls the Zenon SDK's `getAllActive()` method to retrieve the + /// list of active sentinels. The fetched data is returned as a + /// `SentinelInfoList`. /// /// Throws: /// - An error if any exception occurs during the fetching process. @@ -33,4 +36,3 @@ class SentinelsCubit extends DashboardCubit { } } } - diff --git a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart index 24b799dd..4f696d8a 100644 --- a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart +++ b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart @@ -1,26 +1,32 @@ part of 'sentinels_cubit.dart'; -/// The state class for `SentinelsCubit`, which extends `DashboardState` to manage sentinel-related data. +/// The state class for `SentinelsCubit`, which extends `DashboardState` to +/// manage sentinel-related data. /// -/// This class manages a `SentinelInfoList` object representing information about active sentinels. It is used to track +/// This class manages a `SentinelInfoList` object representing information +/// about active sentinels. It is used to track /// the state of sentinel data loading within the `SentinelsCubit`. class SentinelsState extends DashboardState { - /// Constructs a new `SentinelsState` with optional values for `status`, `data`, and `error`. + /// Constructs a new `SentinelsState` with optional values for `status`, + /// `data`, and `error`. /// - /// The `data` field stores a `SentinelInfoList` object, which contains the details of all active sentinels on the network. + /// The `data` field stores a `SentinelInfoList` object, which contains the + /// details of all active sentinels on the network. const SentinelsState({ super.status, super.data, super.error, }); - /// Creates a copy of the current `SentinelsState` with updated values for `status`, `data`, or `error`. + /// Creates a copy of the current `SentinelsState` with updated values for + /// `status`, `data`, or `error`. /// /// This method is used to create a new state with updated fields if provided, /// otherwise retaining the existing values. /// /// Returns: - /// - A new instance of `SentinelsState` with the updated values or the existing ones if none are provided. + /// - A new instance of `SentinelsState` with the updated values or the + /// existing ones if none are provided. @override DashboardState copyWith({ CubitStatus? status, diff --git a/lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart b/lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart index d3eedfe1..c888cec2 100644 --- a/lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart +++ b/lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart @@ -2,8 +2,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/card/card.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart'; +/// Widget connected to the [SentinelsCubit] that receives the state +/// - [SentinelsState] - updates and rebuilds the UI according to the +/// state's status - [CubitStatus] class SentinelsCard extends StatelessWidget { + /// Creates a SentinelsCard object. const SentinelsCard({super.key}); @override @@ -13,12 +19,12 @@ class SentinelsCard extends StatelessWidget { final cubit = SentinelsCubit( zenon!, const SentinelsState(), - ); - cubit.fetchDataPeriodically(); + )..fetchDataPeriodically(); return cubit; }, - child: Scaffold( - body: BlocBuilder( + child: CardScaffoldWithoutListener( + data: CardType.sentinels.getData(context: context), + body: BlocBuilder( builder: (context, state) { return switch (state.status) { CubitStatus.initial => const SentinelsEmpty(), @@ -27,7 +33,7 @@ class SentinelsCard extends StatelessWidget { error: state.error!, ), CubitStatus.success => SentinelsPopulated( - data: state.data, + sentinelInfoList: state.data!, ), }; }, diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart index 6cbb891f..db558e68 100644 --- a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart +++ b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart @@ -1,10 +1,15 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; +/// A widget associated with the [SentinelsState] when it's status is +/// [CubitStatus.initial] that uses the [SyriusErrorWidget] to display a message class SentinelsEmpty extends StatelessWidget { + /// Creates a SentinelsEmpty object const SentinelsEmpty({super.key}); @override Widget build(BuildContext context) { - return const Text('empty'); + return const SyriusErrorWidget('No data available'); } -} \ No newline at end of file +} diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart index 4eca8fe8..5922f7b6 100644 --- a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart +++ b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart @@ -1,5 +1,9 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; +/// A widget associated with the [SentinelsState] when it's status is +/// [CubitStatus.error] that uses the [SyriusErrorWidget] to display a message class SentinelsError extends StatelessWidget { const SentinelsError({required this.error, super.key}); @@ -7,6 +11,6 @@ class SentinelsError extends StatelessWidget { @override Widget build(BuildContext context) { - return Text(error.toString()); + return SyriusErrorWidget(error); } -} \ No newline at end of file +} diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_loading.dart b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_loading.dart index 8b012138..e5e50f7f 100644 --- a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_loading.dart +++ b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_loading.dart @@ -1,10 +1,15 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; +/// A widget associated with the [SentinelsState] when it's status is +/// [CubitStatus.loading] that uses the [SyriusErrorWidget] to display a message class SentinelsLoading extends StatelessWidget { + /// Creates a SentinelsLoading object. const SentinelsLoading({super.key}); @override Widget build(BuildContext context) { - return const Text('loading'); + return const SyriusLoadingWidget(); } -} \ No newline at end of file +} diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart index 7e257919..fda97b26 100644 --- a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart +++ b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart @@ -1,13 +1,44 @@ import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; +/// A widget associated with the [SentinelsState] when it's status is +/// [CubitStatus.success] that displays the current number of sentinels class SentinelsPopulated extends StatelessWidget { - const SentinelsPopulated({required this.data, super.key}); - final SentinelInfoList? data; + const SentinelsPopulated({required this.sentinelInfoList, super.key}); + final SentinelInfoList sentinelInfoList; @override Widget build(BuildContext context) { - return Text(data.toString()); + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(12), + child: SvgPicture.asset( + 'assets/svg/ic_sentinels_dashboard.svg', + width: 42, + ), + ), + Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + NumberAnimation( + end: sentinelInfoList.count, + isInt: true, + style: Theme.of(context).textTheme.headlineMedium, + ), + Text( + 'Active Sentinels', + style: Theme.of(context).textTheme.titleMedium, + ), + ], + ), + ], + ); } } \ No newline at end of file diff --git a/lib/utils/card/card_type.dart b/lib/utils/card/card_type.dart index 5d8f35e6..63141192 100644 --- a/lib/utils/card/card_type.dart +++ b/lib/utils/card/card_type.dart @@ -8,7 +8,8 @@ enum CardType { delegationStats, dualCoinStats, pillars, - realtimeStatistics; + realtimeStatistics, + sentinels; /// Returns the [CardData] assigned to a specific [CardType] value. /// @@ -46,6 +47,11 @@ enum CardType { 'perspective. Every interaction with the network embedded ' 'contracts is internally considered a transaction', ), + CardType.sentinels => CardData( + title: 'Sentinels', + description: 'This card displays the number of active ' + 'Sentinels in the network', + ), }; } } diff --git a/lib/widgets/main_app_container.dart b/lib/widgets/main_app_container.dart index 9c5bf5e9..bac3e9a9 100644 --- a/lib/widgets/main_app_container.dart +++ b/lib/widgets/main_app_container.dart @@ -99,7 +99,7 @@ class _MainAppContainerState extends State duration: const Duration(milliseconds: 500), ); _animationController.repeat(reverse: true); - _animation = Tween(begin: 1, end: 3).animate(_animationController); + _animation = Tween(begin: 1, end: 3).animate(_animationController); kCurrentPage = kWalletInitCompleted ? Tabs.dashboard : Tabs.lock; _initLockBlock(); _handleIncomingLinks(); diff --git a/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart b/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart index 1f14c066..7edabc2d 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart @@ -1,5 +1,4 @@ export 'plasma_stats.dart'; -export 'sentinels.dart'; export 'staking.dart'; export 'total_hourly_transactions.dart'; export 'transfer.dart'; diff --git a/lib/widgets/modular_widgets/dashboard_widgets/sentinels.dart b/lib/widgets/modular_widgets/dashboard_widgets/sentinels.dart deleted file mode 100644 index f9edb63d..00000000 --- a/lib/widgets/modular_widgets/dashboard_widgets/sentinels.dart +++ /dev/null @@ -1,65 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_svg/svg.dart'; -import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; - -const String _kWidgetTitle = 'Sentinels'; -const String _kWidgetDescription = 'This card displays the number of active ' - 'Sentinels in the network'; - -class Sentinels extends StatefulWidget { - const Sentinels({super.key}); - - @override - State createState() => _SentinelsState(); -} - -class _SentinelsState extends State { - @override - Widget build(BuildContext context) { - return ViewModelBuilder.reactive( - viewModelBuilder: SentinelsBloc.new, - onViewModelReady: (model) { - model.getDataPeriodically(); - }, - builder: (_, model, __) => CardScaffold>( - childStream: model.stream, - onCompletedStatusCallback: _getWidgetBody, - title: _kWidgetTitle, - description: _kWidgetDescription, - ), - ); - } - - Widget _getWidgetBody(List sentinelsByCycle) { - return Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.all(12), - child: SvgPicture.asset( - 'assets/svg/ic_sentinels_dashboard.svg', - width: 42, - ), - ), - Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - NumberAnimation( - end: sentinelsByCycle.length, - isInt: true, - style: Theme.of(context).textTheme.headlineMedium, - ), - Text( - 'Active Sentinels', - style: Theme.of(context).textTheme.titleMedium, - ), - ], - ), - ], - ); - } -} diff --git a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart index 9d8fa5e4..5596f282 100644 --- a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart +++ b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart @@ -68,7 +68,7 @@ class _DashboardTabChildState extends State { height: kStaggeredNumOfColumns / 8, ), const FluidCell( - child: Sentinels(), + child: SentinelsCard(), height: kStaggeredNumOfColumns / 8, ), FluidCell( From c6fff16f2480892319f0723b8a8a87028c1b7b98 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Wed, 23 Oct 2024 13:53:27 +0300 Subject: [PATCH 026/102] refactor: Change fields' order --- lib/utils/card/card_data.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/utils/card/card_data.dart b/lib/utils/card/card_data.dart index da278356..15db8ef4 100644 --- a/lib/utils/card/card_data.dart +++ b/lib/utils/card/card_data.dart @@ -1,6 +1,6 @@ class CardData { - CardData({required this.title, required this.description}); - final String title; + CardData({required this.description, required this.title}); final String description; + final String title; } \ No newline at end of file From 3e12e56def051f7980bcc1ddf79e84e2ad33f454 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Wed, 23 Oct 2024 14:13:01 +0300 Subject: [PATCH 027/102] fix: Documentation --- .../dashboard/sentinels/widgets/sentinels_error.dart | 4 ++-- .../dashboard/sentinels/widgets/sentinels_loading.dart | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart index 5922f7b6..7186efe4 100644 --- a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart +++ b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart @@ -3,9 +3,9 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [SentinelsState] when it's status is -/// [CubitStatus.error] that uses the [SyriusErrorWidget] to display a message +/// [CubitStatus.error] that uses the [SyriusErrorWidget] to display an error. class SentinelsError extends StatelessWidget { - + /// Creates a SentinelsError objects. const SentinelsError({required this.error, super.key}); final Object error; diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_loading.dart b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_loading.dart index e5e50f7f..711cd6ea 100644 --- a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_loading.dart +++ b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_loading.dart @@ -3,7 +3,8 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [SentinelsState] when it's status is -/// [CubitStatus.loading] that uses the [SyriusErrorWidget] to display a message +/// [CubitStatus.loading] that uses the [SyriusLoadingWidget] to display a +/// loading indicator. class SentinelsLoading extends StatelessWidget { /// Creates a SentinelsLoading object. const SentinelsLoading({super.key}); From 63ec7ce4a3e7430c75d4c62b58a7e4575021e185 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Wed, 23 Oct 2024 15:10:25 +0300 Subject: [PATCH 028/102] feat: Fill the staking widgets --- lib/blocs/dashboard/dashboard.dart | 1 - lib/blocs/dashboard/staking_bloc.dart | 36 --------- .../staking/cubit/staking_cubit.dart | 27 ++++--- .../staking/cubit/staking_state.dart | 21 +++-- .../dashboard/staking/staking.dart | 2 +- .../dashboard/staking/view/staking_card.dart | 16 ++-- .../staking/widgets/staking_empty.dart | 8 +- .../staking/widgets/staking_error.dart | 10 ++- .../staking/widgets/staking_loading.dart | 10 ++- .../staking/widgets/staking_populated.dart | 57 +++++++++++++- .../dashboard/staking/widgets/widgets.dart | 2 +- lib/utils/card/card_type.dart | 17 +++-- lib/utils/exceptions/exceptions.dart | 1 + .../no_active_skaking_entries_exception.dart | 8 ++ .../dashboard_widgets/dashboard_widgets.dart | 1 - .../dashboard_widgets/staking.dart | 76 ------------------- .../dashboard_tab_child.dart | 2 +- 17 files changed, 140 insertions(+), 155 deletions(-) delete mode 100644 lib/blocs/dashboard/staking_bloc.dart create mode 100644 lib/utils/exceptions/no_active_skaking_entries_exception.dart delete mode 100644 lib/widgets/modular_widgets/dashboard_widgets/staking.dart diff --git a/lib/blocs/dashboard/dashboard.dart b/lib/blocs/dashboard/dashboard.dart index 43f0cef9..2d520467 100644 --- a/lib/blocs/dashboard/dashboard.dart +++ b/lib/blocs/dashboard/dashboard.dart @@ -7,5 +7,4 @@ export 'dual_coin_stats_bloc.dart'; export 'pillars_bloc.dart'; export 'realtime_statistics_bloc.dart'; export 'sentinels_bloc.dart'; -export 'staking_bloc.dart'; export 'total_hourly_transactions_bloc.dart'; diff --git a/lib/blocs/dashboard/staking_bloc.dart b/lib/blocs/dashboard/staking_bloc.dart deleted file mode 100644 index 80a232d9..00000000 --- a/lib/blocs/dashboard/staking_bloc.dart +++ /dev/null @@ -1,36 +0,0 @@ -import 'dart:async'; - -import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; -import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; - -class StakingStatsModel { - - StakingStatsModel( - this.numActiveStakingEntries, - this.totalZnnStakingAmount, - ); - int numActiveStakingEntries; - BigInt totalZnnStakingAmount; -} - -class StakingBloc extends DashboardBaseBloc { - @override - Future makeAsyncCall() async { - final stakeList = await _getStakeList(); - if (stakeList.list.isNotEmpty) { - return StakingStatsModel( - stakeList.list.length, - stakeList.totalAmount, - ); - } else { - throw 'No active staking entries'; - } - } - - Future _getStakeList() async => - zenon!.embedded.stake.getEntriesByAddress( - Address.parse(kSelectedAddress!), - ); -} diff --git a/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart b/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart index 3fcdba98..d7701f7d 100644 --- a/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart +++ b/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart @@ -1,4 +1,5 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/exceptions/exceptions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -7,21 +8,26 @@ part 'staking_state.dart'; /// `StakingCubit` manages the fetching and state of staking information. /// /// This cubit extends `DashboardCubit`, using a `StakeList` object -/// to represent the list of staking entries for a specific address fetched from the Zenon network. +/// to represent the list of staking entries for a specific address fetched +/// from the Zenon network. class StakingCubit extends DashboardCubit { - /// Constructs a `StakingCubit`, passing the `zenon` client and the initial state - /// to the parent class. + /// Constructs a `StakingCubit`, passing the `zenon` client and the initial + /// state to the parent class. /// - /// The `zenon` client is used to interact with the Zenon network to retrieve staking information. + /// The `zenon` client is used to interact with the Zenon network to retrieve + /// staking information. StakingCubit(super.zenon, super.initialState); - /// Fetches a list of staking entries for a specific address from the Zenon network. + /// Fetches a list of staking entries for a specific address from the Zenon + /// network. /// - /// This method retrieves the staking list by calling the internal `_getStakeList()` method. + /// This method retrieves the staking list by calling the internal + /// `_getStakeList()` method. /// It checks if the list of stakes is not empty and returns the data. /// /// Throws: - /// - An error if no active staking entries are found or if any exception occurs during the fetching process. + /// - An error if no active staking entries are found or if any exception + /// occurs during the fetching process. @override Future fetch() async { try { @@ -30,7 +36,7 @@ class StakingCubit extends DashboardCubit { if (data.list.isNotEmpty) { return data; // Return the fetched stake data if not empty } else { - throw 'No active staking entries'; // Throw an error if no entries are found + throw NoActiveStakingEntriesException(); } } catch (e) { rethrow; @@ -39,8 +45,9 @@ class StakingCubit extends DashboardCubit { /// Retrieves the staking entries for a specific address. /// - /// This method fetches the staking entries by calling the Zenon SDK's `getEntriesByAddress()` - /// method, using the account address and a specified page index. + /// This method fetches the staking entries by calling the Zenon SDK's + /// `getEntriesByAddress()` method, using the account address and a + /// specified page index. /// /// Returns: /// - A `StakeList` containing the staking entries for the specified address. diff --git a/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart b/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart index 7a6297d7..efe7a13f 100644 --- a/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart +++ b/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart @@ -1,26 +1,33 @@ part of 'staking_cubit.dart'; -/// The state class for `StakingCubit`, which extends `DashboardState` to manage staking-related data. +/// The state class for `StakingCubit`, which extends `DashboardState` to +/// manage staking-related data. /// -/// This class manages a `StakeList` object representing the list of active staking entries. -/// It tracks the loading, success, or failure of fetching staking data within the `StakingCubit`. +/// This class manages a `StakeList` object representing the list of active +/// staking entries. +/// It tracks the loading, success, or failure of fetching staking data within +/// the `StakingCubit`. class StakingState extends DashboardState { - /// Constructs a new `StakingState` with optional values for `status`, `data`, and `error`. + /// Constructs a new `StakingState` with optional values for `status`, + /// `data`, and `error`. /// - /// The `data` field holds a `StakeList` object, which contains the list of active staking entries for a particular address. + /// The `data` field holds a `StakeList` object, which contains the list of + /// active staking entries for a particular address. const StakingState({ super.status, super.data, super.error, }); - /// Creates a copy of the current `StakingState` with updated values for `status`, `data`, or `error`. + /// Creates a copy of the current `StakingState` with updated values for + /// `status`, `data`, or `error`. /// /// This method is used to create a new state with updated fields if provided, /// otherwise retaining the existing values. /// /// Returns: - /// - A new instance of `StakingState`with the updated values or the existing ones if none are provided. + /// - A new instance of `StakingState`with the updated values or the + /// existing ones if none are provided. @override DashboardState copyWith({ CubitStatus? status, diff --git a/lib/rearchitecture/dashboard/staking/staking.dart b/lib/rearchitecture/dashboard/staking/staking.dart index bdd14754..c4288449 100644 --- a/lib/rearchitecture/dashboard/staking/staking.dart +++ b/lib/rearchitecture/dashboard/staking/staking.dart @@ -1,3 +1,3 @@ export 'cubit/staking_cubit.dart'; export 'view/staking_card.dart'; -export 'widgets/widgets.dart'; \ No newline at end of file +export 'widgets/widgets.dart'; diff --git a/lib/rearchitecture/dashboard/staking/view/staking_card.dart b/lib/rearchitecture/dashboard/staking/view/staking_card.dart index 0942ca68..d5960a3d 100644 --- a/lib/rearchitecture/dashboard/staking/view/staking_card.dart +++ b/lib/rearchitecture/dashboard/staking/view/staking_card.dart @@ -2,8 +2,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/card/card.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart'; +/// A widget connected to the [StakingCubit] that receives the state +/// - [StakingState] - updates and rebuilds the UI according to the +/// state's status - [CubitStatus] class StakingCard extends StatelessWidget { + /// Creates a StakingCard object. const StakingCard({super.key}); @override @@ -13,12 +19,12 @@ class StakingCard extends StatelessWidget { final cubit = StakingCubit( zenon!, const StakingState(), - ); - cubit.fetchDataPeriodically(); + )..fetchDataPeriodically(); return cubit; }, - child: Scaffold( - body: BlocBuilder( + child: CardScaffoldWithoutListener( + data: CardType.staking.getData(context: context), + body: BlocBuilder( builder: (context, state) { return switch (state.status) { CubitStatus.initial => const StakingEmpty(), @@ -27,7 +33,7 @@ class StakingCard extends StatelessWidget { error: state.error!, ), CubitStatus.success => StakingPopulated( - data: state.data, + stakingList: state.data!, ), }; }, diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart b/lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart index 5e186deb..fc20a414 100644 --- a/lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart +++ b/lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart @@ -1,10 +1,14 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; +/// A widget associated with the [StakingState] when it's status is +/// [CubitStatus.initial] that uses the [SyriusErrorWidget] to display a message class StakingEmpty extends StatelessWidget { const StakingEmpty({super.key}); @override Widget build(BuildContext context) { - return const Text('empty'); + return const SyriusErrorWidget('No data available'); } -} \ No newline at end of file +} diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart b/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart index 9b5a0e1b..747165f7 100644 --- a/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart +++ b/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart @@ -1,12 +1,16 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; +/// A widget associated with the [StakingState] when it's status is +/// [CubitStatus.error] that uses the [SyriusErrorWidget] to display the error. class StakingError extends StatelessWidget { - + /// Creates a StakingError object. const StakingError({required this.error, super.key}); final Object error; @override Widget build(BuildContext context) { - return Text(error.toString()); + return SyriusErrorWidget(error); } -} \ No newline at end of file +} diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_loading.dart b/lib/rearchitecture/dashboard/staking/widgets/staking_loading.dart index d57fd356..d27b92b5 100644 --- a/lib/rearchitecture/dashboard/staking/widgets/staking_loading.dart +++ b/lib/rearchitecture/dashboard/staking/widgets/staking_loading.dart @@ -1,10 +1,16 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; +/// A widget associated with the [StakingState] when it's status is +/// [CubitStatus.loading] that uses the [SyriusLoadingWidget] to display a +/// loading indicator. class StakingLoading extends StatelessWidget { + /// Creates a StakingLoading object. const StakingLoading({super.key}); @override Widget build(BuildContext context) { - return const Text('loading'); + return const SyriusLoadingWidget(); } -} \ No newline at end of file +} diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart b/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart index 27074ff2..d085f1c1 100644 --- a/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart +++ b/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart @@ -1,13 +1,62 @@ import 'package:flutter/material.dart'; +import 'package:flutter_vector_icons/flutter_vector_icons.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; +/// A widget associated with the [StakingState] when it's status is +/// [CubitStatus.success] that displays class StakingPopulated extends StatelessWidget { + /// Creates a StakingPopulated object + const StakingPopulated({required this.stakingList, super.key}); - const StakingPopulated({required this.data, super.key}); - final StakeList? data; + final StakeList stakingList; @override Widget build(BuildContext context) { - return Text(data.toString()); + final int numActiveStakingEntries = stakingList.list.length; + final BigInt totalStakedAmount = stakingList.totalAmount; + final String totalStakedAmountWithDecimals = totalStakedAmount.addDecimals( + coinDecimals, + ); + + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + padding: const EdgeInsets.all(8), + width: 36, + height: 36, + decoration: BoxDecoration( + shape: BoxShape.circle, + border: Border.all( + color: AppColors.znnColor, + ), + ), + child: Icon( + SimpleLineIcons.energy, + size: 12, + color: Theme.of(context).textTheme.bodyLarge!.color, + ), + ), + Container(width: 16), + Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + NumberAnimation( + end: numActiveStakingEntries, + isInt: true, + style: Theme.of(context).textTheme.headlineMedium, + ), + Text( + '$totalStakedAmountWithDecimals ${kZnnCoin.symbol}', + style: Theme.of(context).textTheme.titleMedium, + ), + ], + ), + ], + ); } -} \ No newline at end of file +} diff --git a/lib/rearchitecture/dashboard/staking/widgets/widgets.dart b/lib/rearchitecture/dashboard/staking/widgets/widgets.dart index 5826ca55..74fcab9a 100644 --- a/lib/rearchitecture/dashboard/staking/widgets/widgets.dart +++ b/lib/rearchitecture/dashboard/staking/widgets/widgets.dart @@ -1,4 +1,4 @@ export 'staking_empty.dart'; export 'staking_error.dart'; export 'staking_loading.dart'; -export 'staking_populated.dart'; \ No newline at end of file +export 'staking_populated.dart'; diff --git a/lib/utils/card/card_type.dart b/lib/utils/card/card_type.dart index 63141192..255cf35d 100644 --- a/lib/utils/card/card_type.dart +++ b/lib/utils/card/card_type.dart @@ -9,7 +9,8 @@ enum CardType { dualCoinStats, pillars, realtimeStatistics, - sentinels; + sentinels, + staking; /// Returns the [CardData] assigned to a specific [CardType] value. /// @@ -48,10 +49,16 @@ enum CardType { 'contracts is internally considered a transaction', ), CardType.sentinels => CardData( - title: 'Sentinels', - description: 'This card displays the number of active ' - 'Sentinels in the network', - ), + title: 'Sentinels', + description: 'This card displays the number of active ' + 'Sentinels in the network', + ), + CardType.staking => CardData( + description: 'This card displays the number of staking ' + 'entries and the total ${kZnnCoin.symbol} that you are currently ' + 'staking', + title: 'Staking Stats', + ), }; } } diff --git a/lib/utils/exceptions/exceptions.dart b/lib/utils/exceptions/exceptions.dart index 062f575d..682d3e02 100644 --- a/lib/utils/exceptions/exceptions.dart +++ b/lib/utils/exceptions/exceptions.dart @@ -1 +1,2 @@ +export 'no_active_skaking_entries_exception.dart'; export 'no_blocks_available_exception.dart'; diff --git a/lib/utils/exceptions/no_active_skaking_entries_exception.dart b/lib/utils/exceptions/no_active_skaking_entries_exception.dart new file mode 100644 index 00000000..303661d3 --- /dev/null +++ b/lib/utils/exceptions/no_active_skaking_entries_exception.dart @@ -0,0 +1,8 @@ +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; + +/// Custom [Exception] to be used with [StakingCubit] when there are +/// no active staking entries found on an address +class NoActiveStakingEntriesException implements Exception { + @override + String toString() => 'No active staking entries'; +} diff --git a/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart b/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart index 7edabc2d..fa8b7bd8 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart @@ -1,4 +1,3 @@ export 'plasma_stats.dart'; -export 'staking.dart'; export 'total_hourly_transactions.dart'; export 'transfer.dart'; diff --git a/lib/widgets/modular_widgets/dashboard_widgets/staking.dart b/lib/widgets/modular_widgets/dashboard_widgets/staking.dart deleted file mode 100644 index c68a7a7a..00000000 --- a/lib/widgets/modular_widgets/dashboard_widgets/staking.dart +++ /dev/null @@ -1,76 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_vector_icons/flutter_vector_icons.dart'; -import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; - -const String _kWidgetTitle = 'Staking Stats'; -final String _kWidgetDescription = 'This card displays the number of staking ' - 'entries and the total ${kZnnCoin.symbol} that you are currently staking'; - -class Staking extends StatefulWidget { - const Staking({super.key}); - - @override - State createState() => _StakingState(); -} - -class _StakingState extends State { - @override - Widget build(BuildContext context) { - return ViewModelBuilder.reactive( - viewModelBuilder: StakingBloc.new, - onViewModelReady: (model) { - model.getDataPeriodically(); - }, - builder: (_, model, __) => CardScaffold( - childStream: model.stream, - onCompletedStatusCallback: _widgetBody, - title: _kWidgetTitle, - description: _kWidgetDescription, - ), - ); - } - - Widget _widgetBody(StakingStatsModel stake) { - return Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - padding: const EdgeInsets.all(8), - width: 36, - height: 36, - decoration: BoxDecoration( - shape: BoxShape.circle, - border: Border.all( - color: AppColors.znnColor, - ), - ), - child: Icon( - SimpleLineIcons.energy, - size: 12, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - Container(width: 16), - Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - NumberAnimation( - end: stake.numActiveStakingEntries, - isInt: true, - style: Theme.of(context).textTheme.headlineMedium, - ), - Text( - '${stake.totalZnnStakingAmount.addDecimals(coinDecimals)} ${kZnnCoin.symbol}', - style: Theme.of(context).textTheme.titleMedium, - ), - ], - ), - ], - ); - } -} diff --git a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart index 5596f282..cc64a66f 100644 --- a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart +++ b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart @@ -60,7 +60,7 @@ class _DashboardTabChildState extends State { height: kStaggeredNumOfColumns / 8, ), const FluidCell( - child: Staking(), + child: StakingCard(), height: kStaggeredNumOfColumns / 8, ), const FluidCell( From 8588dc5aba4d4181bf90f4757fa9686d5b8cfc69 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Wed, 23 Oct 2024 15:44:21 +0300 Subject: [PATCH 029/102] fix: Documentation --- .../dashboard/staking/widgets/staking_populated.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart b/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart index d085f1c1..2ca394ba 100644 --- a/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart +++ b/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart @@ -6,7 +6,8 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// A widget associated with the [StakingState] when it's status is -/// [CubitStatus.success] that displays +/// [CubitStatus.success] that displays the number of active staking entries +/// and the total staked amount class StakingPopulated extends StatelessWidget { /// Creates a StakingPopulated object const StakingPopulated({required this.stakingList, super.key}); From 714ddc4838c104092a233f1a918c5ac7d7043bf6 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Wed, 23 Oct 2024 15:57:09 +0300 Subject: [PATCH 030/102] feat: Fill up the total hourly transactions widgets --- lib/blocs/dashboard/dashboard.dart | 1 - .../total_hourly_transactions_bloc.dart | 37 ------------- .../total_hourly_transactions_cubit.dart | 43 ++++++++------- .../total_hourly_transactions_state.dart | 28 ++++++---- .../total_hourly_transactions.dart | 2 +- .../view/total_hourly_transactions_card.dart | 17 ++++-- .../total_hourly_transactions_empty.dart | 10 +++- .../total_hourly_transactions_error.dart | 9 +++- .../total_hourly_transactions_loading.dart | 8 ++- .../total_hourly_transactions_populated.dart | 28 ++++++++-- .../widgets/widgets.dart | 2 +- lib/utils/card/card_type.dart | 8 ++- lib/utils/exceptions/exceptions.dart | 1 + .../not_enough_momentums_exception.dart | 8 +++ .../dashboard_widgets/dashboard_widgets.dart | 1 - .../total_hourly_transactions.dart | 52 ------------------- .../dashboard_tab_child.dart | 2 +- 17 files changed, 118 insertions(+), 139 deletions(-) delete mode 100644 lib/blocs/dashboard/total_hourly_transactions_bloc.dart create mode 100644 lib/utils/exceptions/not_enough_momentums_exception.dart delete mode 100644 lib/widgets/modular_widgets/dashboard_widgets/total_hourly_transactions.dart diff --git a/lib/blocs/dashboard/dashboard.dart b/lib/blocs/dashboard/dashboard.dart index 2d520467..70b3c607 100644 --- a/lib/blocs/dashboard/dashboard.dart +++ b/lib/blocs/dashboard/dashboard.dart @@ -7,4 +7,3 @@ export 'dual_coin_stats_bloc.dart'; export 'pillars_bloc.dart'; export 'realtime_statistics_bloc.dart'; export 'sentinels_bloc.dart'; -export 'total_hourly_transactions_bloc.dart'; diff --git a/lib/blocs/dashboard/total_hourly_transactions_bloc.dart b/lib/blocs/dashboard/total_hourly_transactions_bloc.dart deleted file mode 100644 index 7bd1c76b..00000000 --- a/lib/blocs/dashboard/total_hourly_transactions_bloc.dart +++ /dev/null @@ -1,37 +0,0 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; -import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; - -class TotalHourlyTransactionsBloc - extends DashboardBaseBloc> { - @override - Future> makeAsyncCall() async { - final chainHeight = await _ledgerGetMomentumLedgerHeight(); - if (chainHeight - kMomentumsPerHour > 0) { - final response = - (await zenon!.ledger.getDetailedMomentumsByHeight( - chainHeight - kMomentumsPerHour, - kMomentumsPerHour, - )) - .list ?? - []; - return { - 'numAccountBlocks': response.fold( - 0, - (previousValue, element) => previousValue + element.blocks.length, - ), - 'timestamp': DateTime.now().millisecondsSinceEpoch, - }; - } else { - throw 'Not enough momentums'; - } - } - - Future _ledgerGetMomentumLedgerHeight() async { - try { - return (await zenon!.ledger.getFrontierMomentum()).height; - } catch (e) { - rethrow; - } - } -} diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart index 3f7dcdef..5a80717f 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart @@ -1,31 +1,39 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/exceptions/exceptions.dart'; part 'total_hourly_transactions_state.dart'; -/// `TotalHourlyTransactionsCubit` manages the fetching and state of total hourly transactions. +/// `TotalHourlyTransactionsCubit` manages the fetching and state of total +/// hourly transactions. /// -/// This cubit extends `DashboardCubit>`, using a map to represent the total -/// number of account blocks and the corresponding timestamp fetched from the Zenon network. +/// This cubit extends `DashboardCubit>`, using a map to +/// represent the total +/// number of account blocks and the corresponding timestamp fetched from the +/// Zenon network. class TotalHourlyTransactionsCubit - extends DashboardCubit, TotalHourlyTransactionsState> { - /// Constructs a `TotalHourlyTransactionsCubit`, passing the `zenon` client and the initial state - /// to the parent class. + extends DashboardCubit { + /// Constructs a `TotalHourlyTransactionsCubit`, passing the `zenon` client + /// and the initial state to the parent class. /// - /// The `zenon` client is used to interact with the Zenon network to retrieve transaction information. + /// The `zenon` client is used to interact with the Zenon network to retrieve + /// transaction information. TotalHourlyTransactionsCubit(super.zenon, super.initialState); - /// Fetches the total number of account blocks for the last hour from the Zenon network. + /// Fetches the total number of account blocks for the last hour from the + /// Zenon network. /// - /// This method retrieves the height of the chain, checks if there are enough momentums, - /// and fetches detailed momentums from the Zenon ledger. It calculates the total number of - /// account blocks and prepares a map containing the number of blocks and the current timestamp. + /// This method retrieves the height of the chain, checks if there are enough + /// momentums, and fetches detailed momentums from the Zenon ledger. It + /// calculates the total number of account blocks and prepares a map + /// containing the number of blocks and the current timestamp. /// /// Throws: - /// - An error if there are not enough momentums or if any exception occurs during the fetching process. + /// - An error if there are not enough momentums or if any exception occurs + /// during the fetching process. @override - Future> fetch() async { + Future fetch() async { try { // Retrieve the current chain height final chainHeight = await _ledgerGetMomentumLedgerHeight(); @@ -40,16 +48,13 @@ class TotalHourlyTransactionsCubit []; // Prepare the transaction summary - final transactions = { - 'numAccountBlocks': response.fold( + final transactions = response.fold( 0, (previousValue, element) => previousValue + element.blocks.length, - ), - 'timestamp': DateTime.now().millisecondsSinceEpoch, - }; + ); return transactions; // Return the summary of transactions } else { - throw 'Not enough momentums'; // Throw an error if there are not enough momentums + throw NotEnoughMomentumsException(); } } catch (e) { rethrow; diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart index 31c655d8..aa58de42 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart @@ -1,32 +1,37 @@ part of 'total_hourly_transactions_cubit.dart'; -/// The state class for `TotalHourlyTransactionsCubit`, which extends `DashboardState` to manage -/// the hourly transaction count data. +/// The state class for `TotalHourlyTransactionsCubit`, which extends +/// `DashboardState` to manage the hourly transaction count data. /// -/// This class manages a `Map` where the key-value pairs represent transaction statistics -/// (e.g., the number of account blocks and the timestamp) for the last hour. It tracks the state of fetching +/// This class manages a `Map` where the key-value pairs +/// represent transaction statistics (e.g., the number of account blocks and +/// the timestamp) for the last hour. It tracks the state of fetching /// hourly transaction data within `TotalHourlyTransactionsCubit`. -class TotalHourlyTransactionsState extends DashboardState> { - /// Constructs a new `TotalHourlyTransactionsState` with optional values for `status`, `data`, and `error`. +class TotalHourlyTransactionsState extends DashboardState { + /// Constructs a new `TotalHourlyTransactionsState` with optional values for + /// `status`, `data`, and `error`. /// - /// The `data` field holds a map containing the transaction statistics for the last hour. + /// The `data` field holds a map containing the transaction statistics for + /// the last hour. const TotalHourlyTransactionsState({ super.status, super.data, super.error, }); - /// Creates a copy of the current `TotalHourlyTransactionsState` with updated values for `status`, `data`, or `error`. + /// Creates a copy of the current `TotalHourlyTransactionsState` with updated + /// values for `status`, `data`, or `error`. /// /// This method is used to create a new state with updated fields if provided, /// otherwise retaining the existing values. /// /// Returns: - /// - A new instance of `TotalHourlyTransactionsState` with the updated values or the existing ones if none are provided. + /// - A new instance of `TotalHourlyTransactionsState` with the updated + /// values or the existing ones if none are provided. @override - DashboardState> copyWith({ + DashboardState copyWith({ CubitStatus? status, - Map? data, + int? data, Object? error, }) { return TotalHourlyTransactionsState( @@ -37,3 +42,4 @@ class TotalHourlyTransactionsState extends DashboardState> } } + diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/total_hourly_transactions.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/total_hourly_transactions.dart index c87c8130..0131c049 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/total_hourly_transactions.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/total_hourly_transactions.dart @@ -1,3 +1,3 @@ export 'cubit/total_hourly_transactions_cubit.dart'; export 'view/total_hourly_transactions_card.dart'; -export 'widgets/widgets.dart'; \ No newline at end of file +export 'widgets/widgets.dart'; diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart index 71c08953..fb57f9a5 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart @@ -2,8 +2,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/card/card.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart'; +/// A widget connected to the [TotalHourlyTransactionsCubit] that receives the +/// state - [TotalHourlyTransactionsState] - updates and rebuilds the UI +/// according to the state's status - [CubitStatus] class TotalHourlyTransactionsCard extends StatelessWidget { + /// Creates a TotalHourlyTransactionsCard object. const TotalHourlyTransactionsCard({super.key}); @override @@ -13,12 +19,13 @@ class TotalHourlyTransactionsCard extends StatelessWidget { final cubit = TotalHourlyTransactionsCubit( zenon!, const TotalHourlyTransactionsState(), - ); - cubit.fetchDataPeriodically(); + )..fetchDataPeriodically(); return cubit; }, - child: Scaffold( - body: BlocBuilder( + child: CardScaffoldWithoutListener( + data: CardType.totalHourlyTransactions.getData(context: context), + body: BlocBuilder( builder: (context, state) { return switch (state.status) { CubitStatus.initial => const TotalHourlyTransactionsEmpty(), @@ -27,7 +34,7 @@ class TotalHourlyTransactionsCard extends StatelessWidget { error: state.error!, ), CubitStatus.success => TotalHourlyTransactionsPopulated( - data: state.data, + count: state.data!, ), }; }, diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart index 156a0ec5..b848e760 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart @@ -1,10 +1,16 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; +/// A widget associated with the [TotalHourlyTransactionsState] when it's +/// status is [CubitStatus.initial] that uses the [SyriusErrorWidget] to +/// display a message class TotalHourlyTransactionsEmpty extends StatelessWidget { + /// Creates a TotalHourlyTransactionsEmpty object. const TotalHourlyTransactionsEmpty({super.key}); @override Widget build(BuildContext context) { - return const Text('empty'); + return const SyriusErrorWidget('No data available'); } -} \ No newline at end of file +} diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart index aa97c5fb..3b326ee4 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart @@ -1,12 +1,17 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; +/// A widget associated with the [TotalHourlyTransactionsState] when it's +/// status is [CubitStatus.failure] that uses the [SyriusErrorWidget] to +/// display the error. class TotalHourlyTransactionsError extends StatelessWidget { - + /// Creates a TotalHourlyTransactionError object. const TotalHourlyTransactionsError({required this.error, super.key}); final Object error; @override Widget build(BuildContext context) { - return Text(error.toString()); + return SyriusErrorWidget(error); } } diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart index 3c9d9e34..b5c21621 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart @@ -1,10 +1,16 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +/// A widget associated with the [TotalHourlyTransactionsState] when it's +/// status is [CubitStatus.loading] that uses the [SyriusLoadingWidget] to +/// display a loading indicator. class TotalHourlyTransactionsLoading extends StatelessWidget { + /// Creates a TotalHourlyTransactionsLoading object. const TotalHourlyTransactionsLoading({super.key}); @override Widget build(BuildContext context) { - return const Text('loading'); + return const SyriusLoadingWidget(); } } diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart index b69649d2..efacde42 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart @@ -1,12 +1,32 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; +/// A widget associated with the [TotalHourlyTransactionsState] when it's +/// status is [CubitStatus.success] that displays the number of transactions +/// confirmed in the last one hour class TotalHourlyTransactionsPopulated extends StatelessWidget { - - const TotalHourlyTransactionsPopulated({required this.data, super.key}); - final Map? data; + /// Creates a TotalHourlyTransactionsPopulated object. + const TotalHourlyTransactionsPopulated({required this.count, super.key}); + final int count; @override Widget build(BuildContext context) { - return Text(data.toString()); + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + NumberAnimation( + end: count, + isInt: true, + style: Theme.of(context).textTheme.headlineLarge!.copyWith( + fontSize: 30, + ), + ), + kVerticalSpacing, + const Text('transactions in the last hour'), + ], + ); + } } diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/widgets.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/widgets.dart index 8d717eec..4471a813 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/widgets.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/widgets.dart @@ -1,4 +1,4 @@ export 'total_hourly_transactions_empty.dart'; export 'total_hourly_transactions_error.dart'; export 'total_hourly_transactions_loading.dart'; -export 'total_hourly_transactions_populated.dart'; \ No newline at end of file +export 'total_hourly_transactions_populated.dart'; diff --git a/lib/utils/card/card_type.dart b/lib/utils/card/card_type.dart index 255cf35d..a553fc8a 100644 --- a/lib/utils/card/card_type.dart +++ b/lib/utils/card/card_type.dart @@ -10,7 +10,8 @@ enum CardType { pillars, realtimeStatistics, sentinels, - staking; + staking, + totalHourlyTransactions; /// Returns the [CardData] assigned to a specific [CardType] value. /// @@ -59,6 +60,11 @@ enum CardType { 'staking', title: 'Staking Stats', ), + CardType.totalHourlyTransactions => CardData( + description: 'This card displays the total number of ' + 'transactions settled in the last hour across the network', + title: 'Transactions', + ), }; } } diff --git a/lib/utils/exceptions/exceptions.dart b/lib/utils/exceptions/exceptions.dart index 682d3e02..f10689d4 100644 --- a/lib/utils/exceptions/exceptions.dart +++ b/lib/utils/exceptions/exceptions.dart @@ -1,2 +1,3 @@ export 'no_active_skaking_entries_exception.dart'; export 'no_blocks_available_exception.dart'; +export 'not_enough_momentums_exception.dart'; diff --git a/lib/utils/exceptions/not_enough_momentums_exception.dart b/lib/utils/exceptions/not_enough_momentums_exception.dart new file mode 100644 index 00000000..b053e931 --- /dev/null +++ b/lib/utils/exceptions/not_enough_momentums_exception.dart @@ -0,0 +1,8 @@ +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; + +/// Custom [Exception] to be used with [TotalHourlyTransactionsCubit] when +/// the network is less than one hour old +class NotEnoughMomentumsException implements Exception { + @override + String toString() => 'Not enough momentums'; +} diff --git a/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart b/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart index fa8b7bd8..5e26a9ec 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart @@ -1,3 +1,2 @@ export 'plasma_stats.dart'; -export 'total_hourly_transactions.dart'; export 'transfer.dart'; diff --git a/lib/widgets/modular_widgets/dashboard_widgets/total_hourly_transactions.dart b/lib/widgets/modular_widgets/dashboard_widgets/total_hourly_transactions.dart deleted file mode 100644 index fa554bb5..00000000 --- a/lib/widgets/modular_widgets/dashboard_widgets/total_hourly_transactions.dart +++ /dev/null @@ -1,52 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; - -const String _kWidgetTitle = 'Transactions'; -const String _kWidgetDescription = 'This card displays the total number of ' - 'transactions settled in the last hour across the network'; - -class TotalHourlyTransactions extends StatefulWidget { - const TotalHourlyTransactions({super.key}); - - @override - State createState() => - _TotalHourlyTransactionsState(); -} - -class _TotalHourlyTransactionsState extends State { - @override - Widget build(BuildContext context) { - return ViewModelBuilder.reactive( - viewModelBuilder: TotalHourlyTransactionsBloc.new, - onViewModelReady: (model) { - model.getDataPeriodically(); - }, - builder: (_, model, __) => CardScaffold>( - childStream: model.stream, - onCompletedStatusCallback: _getWidgetBody, - title: _kWidgetTitle, - description: _kWidgetDescription, - ), - ); - } - - Widget _getWidgetBody(Map widgetData) { - return Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - NumberAnimation( - end: widgetData['numAccountBlocks'], - isInt: true, - style: Theme.of(context).textTheme.headlineLarge!.copyWith( - fontSize: 30, - ), - ), - kVerticalSpacing, - const Text('transactions in the last hour'), - ], - ); - } -} diff --git a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart index cc64a66f..3e75d89f 100644 --- a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart +++ b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart @@ -52,7 +52,7 @@ class _DashboardTabChildState extends State { ), ), const FluidCell( - child: TotalHourlyTransactions(), + child: TotalHourlyTransactionsCard(), height: kStaggeredNumOfColumns / 4, ), const FluidCell( From 5c209ae6eeff062aa0c34680e6bb03a02da506a6 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Wed, 23 Oct 2024 16:33:53 +0300 Subject: [PATCH 031/102] feat: Delete unused blocs --- lib/blocs/dashboard/dashboard.dart | 5 -- lib/blocs/dashboard/delegation_bloc.dart | 25 ---------- lib/blocs/dashboard/dual_coin_stats_bloc.dart | 20 -------- lib/blocs/dashboard/pillars_bloc.dart | 14 ------ .../dashboard/realtime_statistics_bloc.dart | 50 ------------------- lib/blocs/dashboard/sentinels_bloc.dart | 11 ---- 6 files changed, 125 deletions(-) delete mode 100644 lib/blocs/dashboard/delegation_bloc.dart delete mode 100644 lib/blocs/dashboard/dual_coin_stats_bloc.dart delete mode 100644 lib/blocs/dashboard/pillars_bloc.dart delete mode 100644 lib/blocs/dashboard/realtime_statistics_bloc.dart delete mode 100644 lib/blocs/dashboard/sentinels_bloc.dart diff --git a/lib/blocs/dashboard/dashboard.dart b/lib/blocs/dashboard/dashboard.dart index 70b3c607..6ce9e9fc 100644 --- a/lib/blocs/dashboard/dashboard.dart +++ b/lib/blocs/dashboard/dashboard.dart @@ -2,8 +2,3 @@ export 'balance_bloc.dart'; export 'balance_dashboard_bloc.dart'; export 'dashboard_base_bloc.dart'; -export 'delegation_bloc.dart'; -export 'dual_coin_stats_bloc.dart'; -export 'pillars_bloc.dart'; -export 'realtime_statistics_bloc.dart'; -export 'sentinels_bloc.dart'; diff --git a/lib/blocs/dashboard/delegation_bloc.dart b/lib/blocs/dashboard/delegation_bloc.dart deleted file mode 100644 index 5f986774..00000000 --- a/lib/blocs/dashboard/delegation_bloc.dart +++ /dev/null @@ -1,25 +0,0 @@ -import 'dart:async'; - -import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; -import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; - -class DelegationBloc extends DashboardBaseBloc { - @override - Future makeAsyncCall() async { - try { - final response = - await zenon!.embedded.pillar.getDelegatedPillar( - Address.parse(kSelectedAddress!), - ); - if (response != null) { - return response; - } else { - throw 'No delegation stats'; - } - } catch (e) { - rethrow; - } - } -} diff --git a/lib/blocs/dashboard/dual_coin_stats_bloc.dart b/lib/blocs/dashboard/dual_coin_stats_bloc.dart deleted file mode 100644 index f73435ce..00000000 --- a/lib/blocs/dashboard/dual_coin_stats_bloc.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'dart:async'; - -import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; -import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; - -class DualCoinStatsBloc extends DashboardBaseBloc> { - @override - Future> makeAsyncCall() async => Future.wait( - [ - zenon!.embedded.token.getByZts( - kZnnCoin.tokenStandard, - ), - zenon!.embedded.token.getByZts( - kQsrCoin.tokenStandard, - ), - ], - ); -} diff --git a/lib/blocs/dashboard/pillars_bloc.dart b/lib/blocs/dashboard/pillars_bloc.dart deleted file mode 100644 index 2ea6181d..00000000 --- a/lib/blocs/dashboard/pillars_bloc.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'dart:async'; - -import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; -import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; - -class PillarsBloc extends DashboardBaseBloc { - @override - Future makeAsyncCall() async { - final numOfPillars = (await zenon!.embedded.pillar.getAll()).list.length; - kNumOfPillars = numOfPillars; - return numOfPillars; - } -} diff --git a/lib/blocs/dashboard/realtime_statistics_bloc.dart b/lib/blocs/dashboard/realtime_statistics_bloc.dart deleted file mode 100644 index 95010c4d..00000000 --- a/lib/blocs/dashboard/realtime_statistics_bloc.dart +++ /dev/null @@ -1,50 +0,0 @@ -import 'dart:async'; - -import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; -import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; - -class RealtimeStatisticsBloc extends DashboardBaseBloc> { - @override - Future> makeAsyncCall() async { - final chainHeight = (await zenon!.ledger.getFrontierMomentum()).height; - final height = chainHeight - kMomentumsPerWeek > 0 - ? chainHeight - kMomentumsPerWeek - : 1; - var pageIndex = 0; - const pageSize = 10; - var isLastPage = false; - final blockList = []; - - while (!isLastPage) { - final response = (await zenon!.ledger.getAccountBlocksByPage( - Address.parse(kSelectedAddress!), - pageIndex: pageIndex, - pageSize: pageSize, - )) - .list ?? - []; - - if (response.isEmpty) { - break; - } - - blockList.addAll(response); - - if (response.last.confirmationDetail!.momentumHeight <= height) { - break; - } - - pageIndex += 1; - isLastPage = response.length < pageSize; - } - - if (blockList.isNotEmpty) { - return blockList; - } else { - throw 'No available data'; - } - } -} diff --git a/lib/blocs/dashboard/sentinels_bloc.dart b/lib/blocs/dashboard/sentinels_bloc.dart deleted file mode 100644 index 0217a02c..00000000 --- a/lib/blocs/dashboard/sentinels_bloc.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'dart:async'; - -import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; -import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; - -class SentinelsBloc extends DashboardBaseBloc> { - @override - Future> makeAsyncCall() async => - (await zenon!.embedded.sentinel.getAllActive()).list; -} From 991a0a69923bf7904bc12f5d6130bb33a3c68de6 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Wed, 23 Oct 2024 17:11:05 +0300 Subject: [PATCH 032/102] feat: Tweak balance features --- .../balance/cubit/balance_cubit.dart | 11 ++-- .../balance/cubit/balance_state.dart | 18 ++++-- .../dashboard/balance/view/balance_card.dart | 16 +---- .../balance_dashboard/balance_dashboard.dart | 2 - .../cubit/balance_dashboard_cubit.dart | 39 ++++++++---- .../cubit/balance_dashboard_state.dart | 18 ++++-- .../view/balance_dashboard_card.dart | 60 ------------------- .../widgets/balance_dashboard_empty.dart | 10 ---- .../widgets/balance_dashboard_error.dart | 12 ---- .../widgets/balance_dashboard_loading.dart | 10 ---- .../widgets/balance_dashboard_populated.dart | 13 ---- .../balance_dashboard/widgets/widgets.dart | 4 -- lib/utils/exceptions/exceptions.dart | 1 + .../exceptions/no_balance_exception.dart | 6 ++ 14 files changed, 64 insertions(+), 156 deletions(-) delete mode 100644 lib/rearchitecture/dashboard/balance_dashboard/view/balance_dashboard_card.dart delete mode 100644 lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_empty.dart delete mode 100644 lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_error.dart delete mode 100644 lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_loading.dart delete mode 100644 lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_populated.dart delete mode 100644 lib/rearchitecture/dashboard/balance_dashboard/widgets/widgets.dart create mode 100644 lib/utils/exceptions/no_balance_exception.dart diff --git a/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart b/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart index 86688667..5bad4a9c 100644 --- a/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart +++ b/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart @@ -1,9 +1,8 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/exceptions/exceptions.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; - - part 'balance_state.dart'; /// `BalanceCubit` is responsible for managing and fetching the account balances @@ -11,7 +10,8 @@ part 'balance_state.dart'; /// represented as a `Map` of addresses and their associated `AccountInfo`. class BalanceCubit extends DashboardCubit { - /// Constructs a `BalanceCubit` with the provided `zenon` client and initial state. + /// Constructs a `BalanceCubit` with the provided `zenon` client and initial + /// state. /// /// The [zenon] parameter provides access to the Zenon SDK for interacting with /// account information, and the [initialState] is a map of addresses to their @@ -25,7 +25,8 @@ class BalanceCubit extends DashboardCubit { /// The method interacts with the `zenon` client's ledger to get the /// `AccountInfo` for the provided [address]. /// - /// Returns an [AccountInfo] object containing the balance details for the given address. + /// Returns an [AccountInfo] object containing the balance details for the + /// given address. /// /// Throws an exception if the balance retrieval fails. @override @@ -36,7 +37,7 @@ class BalanceCubit extends DashboardCubit { (response.znn()! > BigInt.zero || response.qsr()! > BigInt.zero)) { return response; } else { - throw 'Empty balance on the selected address'; + throw NoBalanceException(); } } } diff --git a/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart b/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart index 0b9140c4..0a7b1b0e 100644 --- a/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart +++ b/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart @@ -1,13 +1,17 @@ part of 'balance_cubit.dart'; -/// The state class for the `BalanceCubit`, extending `DashboardState` and managing account balance data. +/// The state class for the `BalanceCubit`, extending `DashboardState` and +/// managing account balance data. /// -/// `BalanceState` holds a map of account addresses to their corresponding `AccountInfo` objects. -/// This state is used by the `BalanceCubit` to track the balance information for multiple addresses. +/// `BalanceState` holds a map of account addresses to their corresponding +/// `AccountInfo` objects. +/// This state is used by the `BalanceCubit` to track the balance information +/// for multiple addresses. class BalanceState extends DashboardState { /// Constructs a new `BalanceState`. /// - /// This state uses the default `status`, `data`, and `error` from the parent `DashboardState` class + /// This state uses the default `status`, `data`, and `error` from the parent + /// `DashboardState` class /// and initializes them for managing balance data. const BalanceState({ super.status, @@ -15,13 +19,15 @@ class BalanceState extends DashboardState { super.error, }); - /// Creates a copy of the current `BalanceState` with optional new values for `status`, `data`, and `error`. + /// Creates a copy of the current `BalanceState` with optional new values for + /// `status`, `data`, and `error`. /// /// This method is used to create a new state with updated fields if provided, /// otherwise retaining the existing values. /// /// Returns: - /// - A new instance of `BalanceState` with the updated values or the existing ones if none are provided. + /// - A new instance of `BalanceState` with the updated values or the + /// existing ones if none are provided. @override DashboardState copyWith({ CubitStatus? status, diff --git a/lib/rearchitecture/dashboard/balance/view/balance_card.dart b/lib/rearchitecture/dashboard/balance/view/balance_card.dart index fa5b8ab6..a94779ab 100644 --- a/lib/rearchitecture/dashboard/balance/view/balance_card.dart +++ b/lib/rearchitecture/dashboard/balance/view/balance_card.dart @@ -23,37 +23,23 @@ class BalanceCard extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (_) { - // Creates a `BalanceCubit` instance, passing in the `zenon` client - // and an initial `BalanceState`. The cubit immediately begins fetching - // balance data by calling `fetch()`. final cubit = BalanceCubit( Address.parse(kSelectedAddress!), zenon!, const BalanceState(), - ); - cubit.fetchDataPeriodically(); + )..fetchDataPeriodically(); return cubit; }, child: CardScaffoldWithoutListener( data: CardType.balance.getData(context: context), body: BlocBuilder( builder: (context, state) { - // Uses a `switch` statement to display different widgets based on - // the current cubit state. The state is managed by the `BalanceCubit` and - // is derived from `DashboardState`, with different widgets rendered for each status. return switch (state.status) { - // Displays an empty balance view when the cubit is in its initial state. CubitStatus.initial => const BalanceEmpty(), - - // Shows a loading indicator while the cubit is fetching balance data. CubitStatus.loading => const BalanceLoading(), - - // Displays an error message if fetching balance data fails. CubitStatus.failure => BalanceError( error: state.error!, ), - - // Shows the populated balance data when it is successfully fetched. CubitStatus.success => BalancePopulated( address: kSelectedAddress!, accountInfo: state.data!, diff --git a/lib/rearchitecture/dashboard/balance_dashboard/balance_dashboard.dart b/lib/rearchitecture/dashboard/balance_dashboard/balance_dashboard.dart index 18100cd0..2d356f30 100644 --- a/lib/rearchitecture/dashboard/balance_dashboard/balance_dashboard.dart +++ b/lib/rearchitecture/dashboard/balance_dashboard/balance_dashboard.dart @@ -1,3 +1 @@ export 'cubit/balance_dashboard_cubit.dart'; -export 'view/balance_dashboard_card.dart'; -export 'widgets/widgets.dart'; \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_cubit.dart b/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_cubit.dart index 56c07c37..131c096c 100644 --- a/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_cubit.dart +++ b/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_cubit.dart @@ -1,40 +1,53 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/exceptions/exceptions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'balance_dashboard_state.dart'; -/// A `BalanceDashboardCubit` that fetches and manages the account balance data for a single account. +/// A `BalanceDashboardCubit` that fetches and manages the account balance +/// data for a single account. /// -/// This cubit extends `DashboardCubit`, utilizing the `AccountInfo` data type to store -/// and manage the balance data for a specific account (identified by `kDemoAddress`). +/// This cubit extends `DashboardCubit`, utilizing the +/// `AccountInfo` data type to store and manage the balance data for a specific +/// account. /// It provides the logic for fetching and updating the balance. -class BalanceDashboardCubit extends DashboardCubit { - /// Constructs a `BalanceDashboardCubit`, passing the `zenon` client and the initial state to the parent class. +class BalanceDashboardCubit + extends DashboardCubit { + /// Constructs a `BalanceDashboardCubit`, passing the `zenon` client and the + /// initial state to the parent class. /// - /// The `zenon` client is used to interact with the Zenon ledger to retrieve account information. + /// The `zenon` client is used to interact with the Zenon ledger to retrieve + /// account information. BalanceDashboardCubit(super.zenon, super.initialState); /// Fetches the account balance data for the provided address. /// - /// This method retrieves account information using the Zenon SDK's `getAccountInfoByAddress()` method. + /// This method retrieves account information using the Zenon SDK's + /// `getAccountInfoByAddress()` method. /// It checks the balance and block count of the account: - /// - If the account has blocks and a non-zero balance (either ZNN or QSR), it returns the `AccountInfo`. - /// - If the balance is empty, it throws an error indicating that the balance is zero. + /// - If the account has blocks and a non-zero balance (either ZNN or QSR), + /// it returns the `AccountInfo`. + /// - If the balance is empty, it throws an error indicating that the balance + /// is zero. /// /// Throws: - /// - An error if the balance is empty or any exception occurs during data fetching. + /// - An error if the balance is empty or any exception occurs during data + /// fetching. @override Future fetch() async { try { - final response = await zenon.ledger - .getAccountInfoByAddress(Address.parse(kSelectedAddress!)); + final response = await zenon.ledger.getAccountInfoByAddress( + Address.parse( + kSelectedAddress!, + ), + ); if (response.blockCount! > 0 && (response.znn()! > BigInt.zero || response.qsr()! > BigInt.zero)) { return response; } else { - throw 'Empty balance on the selected address'; + throw NoBalanceException(); } } catch (e) { rethrow; diff --git a/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_state.dart b/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_state.dart index 6a75d5a7..1a6af645 100644 --- a/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_state.dart +++ b/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_state.dart @@ -1,13 +1,17 @@ part of 'balance_dashboard_cubit.dart'; -/// The state class for the `BalanceDashboardCubit`, extending `DashboardState` and managing detailed account balance data. +/// The state class for the `BalanceDashboardCubit`, extending `DashboardState` +/// and managing detailed account balance data. /// -/// `BalanceDashboardState` holds an `AccountInfo` object representing the balance information of a single account. -/// This state is used by the `BalanceDashboardCubit` to track detailed balance data. +/// `BalanceDashboardState` holds an `AccountInfo` object representing the +/// balance information of a single account. +/// This state is used by the `BalanceDashboardCubit` to track detailed balance +/// data. class BalanceDashboardState extends DashboardState { /// Constructs a new `BalanceDashboardState`. /// - /// This state uses the default `status`, `data`, and `error` from the parent `DashboardState` class, + /// This state uses the default `status`, `data`, and `error` from the parent + /// `DashboardState` class, /// and initializes them to manage the detailed account balance. const BalanceDashboardState({ super.status, @@ -15,13 +19,15 @@ class BalanceDashboardState extends DashboardState { super.error, }); - /// Creates a copy of the current `BalanceDashboardState` with optional new values for `status`, `data`, and `error`. + /// Creates a copy of the current `BalanceDashboardState` with optional new + /// values for `status`, `data`, and `error`. /// /// This method is used to create a new state with updated fields if provided, /// otherwise retaining the existing values. /// /// Returns: - /// - A new instance of `BalanceDashboardState` with updated values or the current ones if none are provided. + /// - A new instance of `BalanceDashboardState` with updated values or the + /// current ones if none are provided. @override DashboardState copyWith({ CubitStatus? status, diff --git a/lib/rearchitecture/dashboard/balance_dashboard/view/balance_dashboard_card.dart b/lib/rearchitecture/dashboard/balance_dashboard/view/balance_dashboard_card.dart deleted file mode 100644 index 4edb164c..00000000 --- a/lib/rearchitecture/dashboard/balance_dashboard/view/balance_dashboard_card.dart +++ /dev/null @@ -1,60 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; - - - -/// A `BalanceDashboardCard` widget that displays the account balance information -/// for a specific account. -/// -/// This widget utilizes the `BalanceDashboardCubit` to manage the state of the -/// balance data and presents different views based on the current status -/// (e.g., loading, success, failure). -class BalanceDashboardCard extends StatelessWidget { - /// Constructs a `BalanceDashboardCard` widget. - const BalanceDashboardCard({super.key}); - - @override - Widget build(BuildContext context) { - return BlocProvider( - create: (_) { - // Creates a `BalanceDashboardCubit` instance, passing in the `zenon` client - // and an initial `BalanceDashboardState`. The cubit immediately begins fetching - // the balance data by calling `fetch()`. - final cubit = BalanceDashboardCubit( - zenon!, - const BalanceDashboardState(), - ); - cubit.fetchDataPeriodically(); - return cubit; - }, - child: Scaffold( - body: BlocBuilder( - builder: (context, state) { - // Uses a `switch` statement to display different widgets based on - // the current cubit state. The state is managed by the `BalanceDashboardCubit` - // and derived from `DashboardState`, with different widgets rendered for each status. - return switch (state.status) { - // Displays an empty balance view when the cubit is in its initial state. - CubitStatus.initial => const BalanceDashboardEmpty(), - - // Shows a loading indicator while the cubit is fetching balance data. - CubitStatus.loading => const BalanceDashboardLoading(), - - // Displays an error message if fetching balance data fails. - CubitStatus.failure => BalanceDashboardError( - error: state.error!, - ), - - // Shows the populated balance data when it is successfully fetched. - CubitStatus.success => BalanceDashboardPopulated( - data: state.data, - ), - }; - }, - ), - ), - ); - } -} diff --git a/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_empty.dart b/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_empty.dart deleted file mode 100644 index 0f900286..00000000 --- a/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_empty.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:flutter/material.dart'; - -class BalanceDashboardEmpty extends StatelessWidget { - const BalanceDashboardEmpty({super.key}); - - @override - Widget build(BuildContext context) { - return const Text('empty'); - } -} \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_error.dart b/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_error.dart deleted file mode 100644 index 3f28792a..00000000 --- a/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_error.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:flutter/material.dart'; - -class BalanceDashboardError extends StatelessWidget { - - const BalanceDashboardError({required this.error, super.key}); - final Object error; - - @override - Widget build(BuildContext context) { - return Text(error.toString()); - } -} diff --git a/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_loading.dart b/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_loading.dart deleted file mode 100644 index 09664a7e..00000000 --- a/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_loading.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:flutter/material.dart'; - -class BalanceDashboardLoading extends StatelessWidget { - const BalanceDashboardLoading({super.key}); - - @override - Widget build(BuildContext context) { - return const Text('loading'); - } -} diff --git a/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_populated.dart b/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_populated.dart deleted file mode 100644 index 0a3ca203..00000000 --- a/lib/rearchitecture/dashboard/balance_dashboard/widgets/balance_dashboard_populated.dart +++ /dev/null @@ -1,13 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; - -class BalanceDashboardPopulated extends StatelessWidget { - - const BalanceDashboardPopulated({required this.data, super.key}); - final AccountInfo? data; - - @override - Widget build(BuildContext context) { - return Text(data.toString()); - } -} diff --git a/lib/rearchitecture/dashboard/balance_dashboard/widgets/widgets.dart b/lib/rearchitecture/dashboard/balance_dashboard/widgets/widgets.dart deleted file mode 100644 index df368d4b..00000000 --- a/lib/rearchitecture/dashboard/balance_dashboard/widgets/widgets.dart +++ /dev/null @@ -1,4 +0,0 @@ -export 'balance_dashboard_empty.dart'; -export 'balance_dashboard_error.dart'; -export 'balance_dashboard_loading.dart'; -export 'balance_dashboard_populated.dart'; \ No newline at end of file diff --git a/lib/utils/exceptions/exceptions.dart b/lib/utils/exceptions/exceptions.dart index f10689d4..966d3f29 100644 --- a/lib/utils/exceptions/exceptions.dart +++ b/lib/utils/exceptions/exceptions.dart @@ -1,3 +1,4 @@ export 'no_active_skaking_entries_exception.dart'; +export 'no_balance_exception.dart'; export 'no_blocks_available_exception.dart'; export 'not_enough_momentums_exception.dart'; diff --git a/lib/utils/exceptions/no_balance_exception.dart b/lib/utils/exceptions/no_balance_exception.dart new file mode 100644 index 00000000..df626d5f --- /dev/null +++ b/lib/utils/exceptions/no_balance_exception.dart @@ -0,0 +1,6 @@ +/// Custom [Exception] used when there is no balance available on a specific +/// address +class NoBalanceException implements Exception { + @override + String toString() => 'Empty balance on the selected address'; +} From 74991c346d4aa0fd316493426515197e6ec51cb5 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Wed, 23 Oct 2024 17:12:36 +0300 Subject: [PATCH 033/102] refactor: Delete unused bloc --- .../dashboard/balance_dashboard_bloc.dart | 20 ------------------- lib/blocs/dashboard/dashboard.dart | 1 - 2 files changed, 21 deletions(-) delete mode 100644 lib/blocs/dashboard/balance_dashboard_bloc.dart diff --git a/lib/blocs/dashboard/balance_dashboard_bloc.dart b/lib/blocs/dashboard/balance_dashboard_bloc.dart deleted file mode 100644 index 782967eb..00000000 --- a/lib/blocs/dashboard/balance_dashboard_bloc.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'dart:async'; - -import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; -import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; - -class BalanceDashboardBloc extends DashboardBaseBloc { - @override - Future makeAsyncCall() async { - final response = await zenon!.ledger - .getAccountInfoByAddress(Address.parse(kSelectedAddress!)); - if (response.blockCount! > 0 && - (response.znn()! > BigInt.zero || response.qsr()! > BigInt.zero)) { - return response; - } else { - throw 'Empty balance on the selected address'; - } - } -} diff --git a/lib/blocs/dashboard/dashboard.dart b/lib/blocs/dashboard/dashboard.dart index 6ce9e9fc..75cdfc91 100644 --- a/lib/blocs/dashboard/dashboard.dart +++ b/lib/blocs/dashboard/dashboard.dart @@ -1,4 +1,3 @@ export 'balance_bloc.dart'; -export 'balance_dashboard_bloc.dart'; export 'dashboard_base_bloc.dart'; From ddd3306fac6ef725b7814d9e523b760067ef1e2f Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Thu, 24 Oct 2024 11:21:09 +0300 Subject: [PATCH 034/102] feat: Create the node sync status feature --- lib/blocs/blocs.dart | 1 - lib/blocs/node_sync_status_bloc.dart | 37 - .../cubit/node_sync_status_cubit.dart | 55 ++ .../cubit/node_sync_status_state.dart | 25 + .../node_sync_status/node_sync_status.dart | 3 + .../view/node_sync_status_icon.dart | 27 + .../widgets/node_sync_status_empty.dart | 21 + .../widgets/node_sync_status_error.dart | 24 + .../widgets/node_sync_status_loading.dart | 28 + .../widgets/node_sync_status_populated.dart | 149 ++++ .../node_sync_status/widgets/widgets.dart | 4 + lib/utils/extensions.dart | 13 + lib/widgets/main_app_container.dart | 648 +++++++----------- 13 files changed, 605 insertions(+), 430 deletions(-) delete mode 100644 lib/blocs/node_sync_status_bloc.dart create mode 100644 lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart create mode 100644 lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart create mode 100644 lib/rearchitecture/node_sync_status/node_sync_status.dart create mode 100644 lib/rearchitecture/node_sync_status/view/node_sync_status_icon.dart create mode 100644 lib/rearchitecture/node_sync_status/widgets/node_sync_status_empty.dart create mode 100644 lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart create mode 100644 lib/rearchitecture/node_sync_status/widgets/node_sync_status_loading.dart create mode 100644 lib/rearchitecture/node_sync_status/widgets/node_sync_status_populated.dart create mode 100644 lib/rearchitecture/node_sync_status/widgets/widgets.dart diff --git a/lib/blocs/blocs.dart b/lib/blocs/blocs.dart index af395b05..cc499f11 100644 --- a/lib/blocs/blocs.dart +++ b/lib/blocs/blocs.dart @@ -11,7 +11,6 @@ export 'infinite_scroll_bloc.dart'; export 'key_store_file_bloc.dart'; export 'ledger_wallet_file_bloc.dart'; export 'lock_bloc.dart'; -export 'node_sync_status_bloc.dart'; export 'notifications_bloc.dart'; export 'pillars/pillars.dart'; export 'plasma/plasma.dart'; diff --git a/lib/blocs/node_sync_status_bloc.dart b/lib/blocs/node_sync_status_bloc.dart deleted file mode 100644 index b6ccb900..00000000 --- a/lib/blocs/node_sync_status_bloc.dart +++ /dev/null @@ -1,37 +0,0 @@ -import 'dart:async'; - -import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; -import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/node_utils.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; - -class NodeSyncStatusBloc extends DashboardBaseBloc { - SyncState lastSyncState = SyncState.unknown; - - @override - Future makeAsyncCall() async { - if (zenon!.wsClient.status() == WebsocketStatus.running) { - final syncInfo = await zenon!.stats.syncInfo(); - if (lastSyncState != syncInfo.state && - (syncInfo.state == SyncState.syncDone || - (syncInfo.targetHeight > 0 && - syncInfo.currentHeight > 0 && - (syncInfo.targetHeight - syncInfo.currentHeight) > 3))) { - lastSyncState = syncInfo.state; - if (syncInfo.state == SyncState.syncDone) { - Future.delayed(const Duration(seconds: 5)).then((value) { - NodeUtils.getUnreceivedTransactions().then((value) { - sl().autoReceive(); - }); - }); - } - } - return syncInfo; - } - return SyncInfo.fromJson({ - 'state': 0, - 'currentHeight': 0, - 'targetHeight': 0, - }); - } -} diff --git a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart new file mode 100644 index 00000000..89de45b8 --- /dev/null +++ b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart @@ -0,0 +1,55 @@ +import 'dart:async'; + +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/main.dart' hide zenon; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node_sync_status.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +part 'node_sync_status_state.dart'; + +/// Cubit responsible for fetching the sync state - [SyncState] - and sending +/// the states update - [NodeSyncStatusState] - back to the widget +/// +/// [SyncState] is not related to [NodeSyncStatusState], doesn't handle UI updates +/// +/// [NodeSyncStatusState] along with [CubitStatus] updates the UI of the +/// [NodeSyncStatusIcon] widget +class NodeSyncStatusCubit + extends DashboardCubit, NodeSyncStatusState> { + NodeSyncStatusCubit(super.zenon, super.initialState); + + SyncState _lastSyncState = SyncState.unknown; + + @override + Future> fetch() async { + if (zenon.wsClient.status() == WebsocketStatus.running) { + final syncInfo = await zenon.stats.syncInfo(); + if (_lastSyncState != syncInfo.state && + (syncInfo.state == SyncState.syncDone || + (syncInfo.targetHeight > 0 && + syncInfo.currentHeight > 0 && + (syncInfo.targetHeight - syncInfo.currentHeight) > 3))) { + _lastSyncState = syncInfo.state; + if (syncInfo.state == SyncState.syncDone) { + unawaited( + Future.delayed(const Duration(seconds: 5)).then((_) { + NodeUtils.getUnreceivedTransactions().then((_) { + sl().autoReceive(); + }); + }), + ); + } + } + return Pair(_lastSyncState, syncInfo); + } + + final placeholderSyncInfo = SyncInfo.fromJson({ + 'state': 0, + 'currentHeight': 0, + 'targetHeight': 0, + }); + return Pair(_lastSyncState, placeholderSyncInfo); + } +} diff --git a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart new file mode 100644 index 00000000..c685efb6 --- /dev/null +++ b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart @@ -0,0 +1,25 @@ +part of 'node_sync_status_cubit.dart'; + +/// Class used by [NodeSyncStatusCubit] to send state updates to the +/// connected view +class NodeSyncStatusState extends DashboardState> { + + const NodeSyncStatusState({ + super.status, + super.data, + super.error, + }); + + @override + DashboardState> copyWith({ + CubitStatus? status, + Pair? data, + Object? error, + }) { + return NodeSyncStatusState( + status: status ?? this.status, + data: data ?? this.data, + error: error ?? this.error, + ); + } +} diff --git a/lib/rearchitecture/node_sync_status/node_sync_status.dart b/lib/rearchitecture/node_sync_status/node_sync_status.dart new file mode 100644 index 00000000..61881f8c --- /dev/null +++ b/lib/rearchitecture/node_sync_status/node_sync_status.dart @@ -0,0 +1,3 @@ +export 'cubit/node_sync_status_cubit.dart'; +export 'view/node_sync_status_icon.dart'; +export 'widgets/widgets.dart'; diff --git a/lib/rearchitecture/node_sync_status/view/node_sync_status_icon.dart b/lib/rearchitecture/node_sync_status/view/node_sync_status_icon.dart new file mode 100644 index 00000000..7281961a --- /dev/null +++ b/lib/rearchitecture/node_sync_status/view/node_sync_status_icon.dart @@ -0,0 +1,27 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node_sync_status.dart'; + +/// A widget connected to the [NodeSyncStatusCubit] that receives the state +/// - [NodeSyncStatusState] - updates and rebuilds the UI according to the +/// state's status - [CubitStatus] +class NodeSyncStatusIcon extends StatelessWidget { + const NodeSyncStatusIcon({super.key}); + + @override + Widget build(BuildContext context) { + return BlocBuilder( + builder: (context, state) { + return switch (state.status) { + CubitStatus.initial => const NodeSyncStatusEmpty(), + CubitStatus.failure => NodeSyncStatusError( + error: state.error!, + ), + CubitStatus.loading => const NodeSyncStatusLoading(), + CubitStatus.success => NodeSyncPopulated(data: state.data!), + }; + }, + ); + } +} diff --git a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_empty.dart b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_empty.dart new file mode 100644 index 00000000..8026a415 --- /dev/null +++ b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_empty.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node_sync_status.dart'; + +/// A widget associated with the [NodeSyncStatusState] when it's status is +/// [CubitStatus.initial] that displays an icon with a tooltip message +class NodeSyncStatusEmpty extends StatelessWidget { + const NodeSyncStatusEmpty({super.key}); + + @override + Widget build(BuildContext context) { + return Tooltip( + message: 'Not ready', + child: Icon( + Icons.sync_disabled, + size: 24, + color: Theme.of(context).iconTheme.color, + ), + ); + } +} diff --git a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart new file mode 100644 index 00000000..bbdbed79 --- /dev/null +++ b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart @@ -0,0 +1,24 @@ +import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node_sync_status.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; + +/// A widget associated with the [NodeSyncStatusState] when it's status is +/// [CubitStatus.failure] that displays an icon with a tooltip message +class NodeSyncStatusError extends StatelessWidget { + const NodeSyncStatusError({required this.error, super.key}); + + final Object error; + + @override + Widget build(BuildContext context) { + return Tooltip( + message: error.toString(), + child: const Icon( + Icons.sync_problem, + size: 24, + color: AppColors.errorColor, + ), + ); + } +} diff --git a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_loading.dart b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_loading.dart new file mode 100644 index 00000000..6d9bc32f --- /dev/null +++ b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_loading.dart @@ -0,0 +1,28 @@ +import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node_sync_status.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; + +/// A widget associated with the [NodeSyncStatusState] when it's status is +/// [CubitStatus.loading] that displays a loading indicator with a tooltip +class NodeSyncStatusLoading extends StatelessWidget { + const NodeSyncStatusLoading({super.key}); + + @override + Widget build(BuildContext context) { + return Tooltip( + message: 'Loading status', + child: SizedBox( + height: 18, + width: 18, + child: Center( + child: CircularProgressIndicator( + backgroundColor: Theme.of(context).iconTheme.color, + color: AppColors.znnColor, + strokeWidth: 3, + ), + ), + ), + ); + } +} diff --git a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_populated.dart b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_populated.dart new file mode 100644 index 00000000..80a3a3a0 --- /dev/null +++ b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_populated.dart @@ -0,0 +1,149 @@ +import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node_sync_status.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +/// A widget associated with the [NodeSyncStatusState] when it's status is +/// [CubitStatus.success] that returns a corresponding icon depending on the +/// [SyncInfo] and [SyncState] data +class NodeSyncPopulated extends StatelessWidget { + const NodeSyncPopulated({required this.data, super.key}); + + final Pair data; + + @override + Widget build(BuildContext context) { + var (syncState, syncInfo) = (data.first, data.second); + + var message = ''; + + if (syncState == SyncState.unknown) { + message = 'Not ready'; + return Tooltip( + message: message, + child: Icon( + Icons.sync_disabled, + size: 24, + color: syncState.getColor(context: context), + ), + ); + } else if (syncState == SyncState.syncing) { + if (syncInfo.targetHeight > 0 && + syncInfo.currentHeight > 0 && + (syncInfo.targetHeight - syncInfo.currentHeight) < 3) { + message = 'Connected and synced'; + syncState = SyncState.syncDone; + return Tooltip( + message: message, + child: Icon( + Icons.radio_button_unchecked, + size: 24, + color: syncState.getColor(context: context), + ), + ); + } else if (syncInfo.targetHeight == 0 || syncInfo.currentHeight == 0) { + message = 'Started syncing with the network, please wait'; + syncState = SyncState.syncing; + return Tooltip( + message: message, + child: Icon( + Icons.sync, + size: 24, + color: syncState.getColor(context: context), + ), + ); + } else { + message = + 'Sync progress: momentum ${syncInfo.currentHeight} of ' + '${syncInfo.targetHeight}'; + return Tooltip( + message: message, + child: SizedBox( + height: 18, + width: 18, + child: Center( + child: CircularProgressIndicator( + backgroundColor: Theme.of(context).iconTheme.color, + color: syncState.getColor(context: context), + value: syncInfo.currentHeight / syncInfo.targetHeight, + strokeWidth: 3, + ), + ), + ), + ); + } + } else if (syncState == SyncState.notEnoughPeers) { + if (syncInfo.targetHeight > 0 && + syncInfo.currentHeight > 0 && + (syncInfo.targetHeight - syncInfo.currentHeight) < 20) { + message = 'Connecting to peers'; + syncState = SyncState.syncing; + return Tooltip( + message: message, + child: SizedBox( + height: 18, + width: 18, + child: Center( + child: CircularProgressIndicator( + backgroundColor: Theme.of(context).iconTheme.color, + color: syncState.getColor(context: context), + value: syncInfo.currentHeight / syncInfo.targetHeight, + strokeWidth: 3, + ), + ), + ), + ); + } else if (syncInfo.targetHeight == 0 || syncInfo.currentHeight == 0) { + message = 'Connecting to peers, please wait'; + syncState = SyncState.syncing; + return Tooltip( + message: message, + child: Icon( + Icons.sync, + size: 24, + color: syncState.getColor(context: context), + ), + ); + } else { + message = 'Sync progress: momentum ${syncInfo.currentHeight} of ' + '${syncInfo.targetHeight}'; + syncState = SyncState.syncing; + return Tooltip( + message: message, + child: SizedBox( + height: 18, + width: 18, + child: Center( + child: CircularProgressIndicator( + backgroundColor: Theme.of(context).iconTheme.color, + color: syncState.getColor(context: context), + value: syncInfo.currentHeight / syncInfo.targetHeight, + strokeWidth: 3, + ), + ), + ), + ); + } + } else { + message = 'Connected and synced'; + syncState = SyncState.syncDone; + } + + return Tooltip( + message: message, + child: SizedBox( + height: 18, + width: 18, + child: Center( + child: CircularProgressIndicator( + backgroundColor: Theme.of(context).iconTheme.color, + color: syncState.getColor(context: context), + value: 1, + strokeWidth: 2, + ), + ), + ), + ); + } +} diff --git a/lib/rearchitecture/node_sync_status/widgets/widgets.dart b/lib/rearchitecture/node_sync_status/widgets/widgets.dart new file mode 100644 index 00000000..cbde982c --- /dev/null +++ b/lib/rearchitecture/node_sync_status/widgets/widgets.dart @@ -0,0 +1,4 @@ +export 'node_sync_status_empty.dart'; +export 'node_sync_status_error.dart'; +export 'node_sync_status_loading.dart'; +export 'node_sync_status_populated.dart'; diff --git a/lib/utils/extensions.dart b/lib/utils/extensions.dart index c9aa2172..2f55be8a 100644 --- a/lib/utils/extensions.dart +++ b/lib/utils/extensions.dart @@ -1,8 +1,10 @@ import 'dart:math' show pow; import 'package:big_decimal/big_decimal.dart'; import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_ledger_dart/znn_ledger_dart.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; extension StringExtensions on String { String capitalize() { @@ -126,3 +128,14 @@ extension LedgerErrorExtensions on LedgerError { extension BuildContextL10n on BuildContext { AppLocalizations get l10n => AppLocalizations.of(this)!; } + +extension SyncStateExtension on SyncState { + Color? getColor({required BuildContext context}) { + return switch (this) { + SyncState.unknown => Theme.of(context).iconTheme.color, + SyncState.syncing => Colors.orange, + SyncState.syncDone => AppColors.znnColor, + SyncState.notEnoughPeers => AppColors.errorColor, + }; + } +} diff --git a/lib/widgets/main_app_container.dart b/lib/widgets/main_app_container.dart index bac3e9a9..32be6331 100644 --- a/lib/widgets/main_app_container.dart +++ b/lib/widgets/main_app_container.dart @@ -6,6 +6,7 @@ import 'package:clipboard_watcher/clipboard_watcher.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/svg.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:logging/logging.dart'; @@ -17,6 +18,7 @@ import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/handlers/htlc_swaps_handler.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/model/model.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node_sync_status.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/clipboard_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; @@ -50,11 +52,11 @@ enum Tabs { } class MainAppContainer extends StatefulWidget { - const MainAppContainer({ super.key, this.redirectedFromWalletSuccess = false, }); + final bool redirectedFromWalletSuccess; static const String route = 'main-app-container'; @@ -76,12 +78,15 @@ class _MainAppContainerState extends State TransferTabChild? _transferTabChild; bool _initialUriIsHandled = false; - final NodeSyncStatusBloc _netSyncStatusBloc = NodeSyncStatusBloc(); final _appLinks = AppLinks(); final FocusNode _focusNode = FocusNode( skipTraversal: true, canRequestFocus: false, ); + final NodeSyncStatusCubit _nodeSyncStatusCubit = NodeSyncStatusCubit( + zenon!, + const NodeSyncStatusState(), + ); @override void initState() { @@ -90,8 +95,6 @@ class _MainAppContainerState extends State ClipboardUtils.toggleClipboardWatcherStatus(); - _netSyncStatusBloc.getDataPeriodically(); - _transferTabChild = TransferTabChild(); _initTabController(); _animationController = AnimationController( @@ -113,7 +116,8 @@ class _MainAppContainerState extends State return Consumer( builder: (context, textScalingNotifier, child) => MediaQuery( data: MediaQuery.of(context).copyWith( - textScaler: TextScaler.linear(textScalingNotifier.getTextScaleFactor(context)), + textScaler: TextScaler.linear( + textScalingNotifier.getTextScaleFactor(context)), ), child: Scaffold( body: Container( @@ -282,7 +286,8 @@ class _MainAppContainerState extends State (e) => e == Tabs.p2pSwap ? const Tab(text: 'P2P Swap') : Tab( - text: FormatUtils.extractNameFromEnum(e).capitalize(),), + text: FormatUtils.extractNameFromEnum(e).capitalize(), + ), ) .toList(); } @@ -298,7 +303,9 @@ class _MainAppContainerState extends State colorFilter: _isTabSelected(Tabs.walletConnect) ? const ColorFilter.mode(AppColors.znnColor, BlendMode.srcIn) : ColorFilter.mode( - Theme.of(context).iconTheme.color!, BlendMode.srcIn,), + Theme.of(context).iconTheme.color!, + BlendMode.srcIn, + ), ), ), Tab( @@ -341,7 +348,10 @@ class _MainAppContainerState extends State child: _getGenerationStatus(), ), Tab( - child: _getSyncStatus(), + child: BlocProvider.value( + value: _nodeSyncStatusCubit, + child: const NodeSyncStatusIcon(), + ), ), Tab( child: _isTabSelected(Tabs.lock) @@ -361,21 +371,6 @@ class _MainAppContainerState extends State ]; } - Widget _getSyncStatus() { - return StreamBuilder( - stream: _netSyncStatusBloc.stream, - builder: (_, snapshot) { - if (snapshot.hasError) { - return _getSyncingStatusIcon(SyncState.unknown); - } else if (snapshot.hasData) { - return _getSyncingStatusIcon(snapshot.data!.state, snapshot.data); - } else { - return _getSyncingStatusIcon(SyncState.unknown); - } - }, - ); - } - Widget _getGenerationStatus() { return StreamBuilder( stream: sl.get().stream, @@ -402,143 +397,6 @@ class _MainAppContainerState extends State ); } - Widget _getSyncingStatusIcon(SyncState syncState, [SyncInfo? syncInfo]) { - var message = 'Connected and synced'; - - if (syncState != SyncState.notEnoughPeers && - syncState != SyncState.syncDone && - syncState != SyncState.syncing && - syncState != SyncState.unknown) { - syncState = SyncState.unknown; - } - - if (syncState == SyncState.unknown) { - message = 'Not ready'; - return Tooltip( - message: message, - child: Icon( - Icons.sync_disabled, - size: 24, - color: _getSyncIconColor(syncState), - ),); - } else if (syncState == SyncState.syncing) { - if (syncInfo != null) { - if (syncInfo.targetHeight > 0 && - syncInfo.currentHeight > 0 && - (syncInfo.targetHeight - syncInfo.currentHeight) < 3) { - message = 'Connected and synced'; - syncState = SyncState.syncDone; - return Tooltip( - message: message, - child: Icon( - Icons.radio_button_unchecked, - size: 24, - color: _getSyncIconColor(syncState), - ),); - } else if (syncInfo.targetHeight == 0 || syncInfo.currentHeight == 0) { - message = 'Started syncing with the network, please wait'; - syncState = SyncState.syncing; - return Tooltip( - message: message, - child: Icon(Icons.sync, - size: 24, color: _getSyncIconColor(syncState),),); - } else { - message = - 'Sync progress: momentum ${syncInfo.currentHeight} of ${syncInfo.targetHeight}'; - return Tooltip( - message: message, - child: SizedBox( - height: 18, - width: 18, - child: Center( - child: CircularProgressIndicator( - backgroundColor: Theme.of(context).iconTheme.color, - color: _getSyncIconColor(syncState), - value: syncInfo.currentHeight / syncInfo.targetHeight, - strokeWidth: 3, - ),), - ), - ); - } - } else { - message = 'Syncing momentums'; - return Tooltip( - message: message, - child: Icon(Icons.sync, - size: 24, color: _getSyncIconColor(syncState),),); - } - } else if (syncState == SyncState.notEnoughPeers) { - if (syncInfo != null) { - if (syncInfo.targetHeight > 0 && - syncInfo.currentHeight > 0 && - (syncInfo.targetHeight - syncInfo.currentHeight) < 20) { - message = 'Connecting to peers'; - syncState = SyncState.syncing; - return Tooltip( - message: message, - child: SizedBox( - height: 18, - width: 18, - child: Center( - child: CircularProgressIndicator( - backgroundColor: Theme.of(context).iconTheme.color, - color: _getSyncIconColor(syncState), - value: syncInfo.currentHeight / syncInfo.targetHeight, - strokeWidth: 3, - ),),),); - } else if (syncInfo.targetHeight == 0 || syncInfo.currentHeight == 0) { - message = 'Connecting to peers, please wait'; - syncState = SyncState.syncing; - return Tooltip( - message: message, - child: Icon(Icons.sync, - size: 24, color: _getSyncIconColor(syncState),),); - } else { - message = - 'Sync progress: momentum ${syncInfo.currentHeight} of ${syncInfo.targetHeight}'; - syncState = SyncState.syncing; - return Tooltip( - message: message, - child: SizedBox( - height: 18, - width: 18, - child: Center( - child: CircularProgressIndicator( - backgroundColor: Theme.of(context).iconTheme.color, - color: _getSyncIconColor(syncState), - value: syncInfo.currentHeight / syncInfo.targetHeight, - strokeWidth: 3, - ),),),); - } - } else { - message = 'Connecting to peers'; - syncState = SyncState.syncing; - return Tooltip( - message: message, - child: Icon(Icons.sync_problem, - size: 24, color: _getSyncIconColor(syncState),),); - } - } else { - message = 'Connected and synced'; - syncState = SyncState.syncDone; - } - - return Tooltip( - message: message, - child: SizedBox( - height: 18, - width: 18, - child: Center( - child: CircularProgressIndicator( - backgroundColor: Theme.of(context).iconTheme.color, - color: _getSyncIconColor(syncState), - value: 1, - strokeWidth: 2, - ),), - ), - ); - } - Widget _getCurrentPageContainer() { return TabBarView( physics: const NeverScrollableScrollPhysics(), @@ -599,9 +457,8 @@ class _MainAppContainerState extends State @override void dispose() { windowManager.removeListener(this); - + _nodeSyncStatusCubit.close(); _animationController.dispose(); - _netSyncStatusBloc.dispose(); _navigateToLockTimer?.cancel(); _lockBlockStreamSubscription.cancel(); _incomingLinkSubscription.cancel(); @@ -623,6 +480,7 @@ class _MainAppContainerState extends State } void _afterAppInitCallback() { + _nodeSyncStatusCubit.fetchDataPeriodically(); _navigateToLockTimer = _createAutoLockTimer(); if (kLastWalletConnectUriNotifier.value != null) { _tabController!.animateTo(_getTabChildIndex(Tabs.walletConnect)); @@ -648,19 +506,6 @@ class _MainAppContainerState extends State int _getTabChildIndex(Tabs page) => kTabs.indexOf(page); - Color? _getSyncIconColor(SyncState syncState) { - if (syncState == SyncState.syncDone) { - return AppColors.znnColor; - } - if (syncState == SyncState.unknown) { - return Theme.of(context).iconTheme.color; - } - if (syncState == SyncState.syncing) { - return Colors.orange; - } - return AppColors.errorColor; - } - void _navigateTo( Tabs page, { bool redirectWithSendContainerLarge = false, @@ -747,261 +592,273 @@ class _MainAppContainerState extends State Future _handleIncomingLinks() async { if (!kIsWeb && !Platform.isLinux) { - _incomingLinkSubscription = - _appLinks.uriLinkStream.listen((Uri? uri) async { - if (!await windowManager.isFocused() || - !await windowManager.isVisible()) { - windowManager.show(); - } + _incomingLinkSubscription = _appLinks.uriLinkStream.listen( + (Uri? uri) async { + if (!await windowManager.isFocused() || + !await windowManager.isVisible()) { + windowManager.show(); + } - if (uri != null) { - var uriRaw = uri.toString(); + if (uri != null) { + var uriRaw = uri.toString(); - Logger('MainAppContainer') - .log(Level.INFO, '_handleIncomingLinks $uriRaw'); + Logger('MainAppContainer') + .log(Level.INFO, '_handleIncomingLinks $uriRaw'); - if (context.mounted) { - if (uriRaw.contains('wc')) { - if (Platform.isWindows) { - uriRaw = uriRaw.replaceAll('/?', '?'); + if (context.mounted) { + if (uriRaw.contains('wc')) { + if (Platform.isWindows) { + uriRaw = uriRaw.replaceAll('/?', '?'); + } + final wcUri = Uri.decodeFull(uriRaw.split('wc?uri=').last); + if (WalletConnectUri.tryParse(wcUri) != null) { + await _updateWalletConnectUri(wcUri); + } + return; } - final wcUri = Uri.decodeFull(uriRaw.split('wc?uri=').last); - if (WalletConnectUri.tryParse(wcUri) != null) { - await _updateWalletConnectUri(wcUri); + + // Deep link query parameters + var queryAddress = ''; + var queryAmount = ''; // with decimals + var queryDuration = 0; // in months + var queryZTS = ''; + var queryPillarName = ''; + Token? token; + + if (uri.hasQuery) { + uri.queryParametersAll.forEach((key, value) async { + if (key == 'amount') { + queryAmount = value.first; + } else if (key == 'zts') { + queryZTS = value.first; + } else if (key == 'address') { + queryAddress = value.first; + } else if (key == 'duration') { + queryDuration = int.parse(value.first); + } else if (key == 'pillar') { + queryPillarName = value.first; + } + }); } - return; - } - // Deep link query parameters - var queryAddress = ''; - var queryAmount = ''; // with decimals - var queryDuration = 0; // in months - var queryZTS = ''; - var queryPillarName = ''; - Token? token; - - if (uri.hasQuery) { - uri.queryParametersAll.forEach((key, value) async { - if (key == 'amount') { - queryAmount = value.first; - } else if (key == 'zts') { - queryZTS = value.first; - } else if (key == 'address') { - queryAddress = value.first; - } else if (key == 'duration') { - queryDuration = int.parse(value.first); - } else if (key == 'pillar') { - queryPillarName = value.first; + if (queryZTS.isNotEmpty) { + if (queryZTS == 'znn' || queryZTS == 'ZNN') { + token = kZnnCoin; + } else if (queryZTS == 'qsr' || queryZTS == 'QSR') { + token = kQsrCoin; + } else { + token = await zenon!.embedded.token + .getByZts(TokenStandard.parse(queryZTS)); } - }); - } - - if (queryZTS.isNotEmpty) { - if (queryZTS == 'znn' || queryZTS == 'ZNN') { - token = kZnnCoin; - } else if (queryZTS == 'qsr' || queryZTS == 'QSR') { - token = kQsrCoin; - } else { - token = await zenon!.embedded.token - .getByZts(TokenStandard.parse(queryZTS)); } - } - final sendPaymentBloc = SendPaymentBloc(); - final stakingOptionsBloc = StakingOptionsBloc(); - final delegateButtonBloc = DelegateButtonBloc(); - final plasmaOptionsBloc = PlasmaOptionsBloc(); + final sendPaymentBloc = SendPaymentBloc(); + final stakingOptionsBloc = StakingOptionsBloc(); + final delegateButtonBloc = DelegateButtonBloc(); + final plasmaOptionsBloc = PlasmaOptionsBloc(); + + if (context.mounted) { + switch (uri.host) { + case 'transfer': + await sl().addNotification( + WalletNotification( + title: 'Transfer action detected', + timestamp: DateTime.now().millisecondsSinceEpoch, + details: 'Deep link: $uriRaw', + type: NotificationType.paymentReceived, + ), + ); - if (context.mounted) { - switch (uri.host) { - case 'transfer': - await sl().addNotification( - WalletNotification( - title: 'Transfer action detected', - timestamp: DateTime.now().millisecondsSinceEpoch, - details: 'Deep link: $uriRaw', - type: NotificationType.paymentReceived, - ), - ); + if (kCurrentPage != Tabs.lock) { + _navigateTo(Tabs.transfer); + + if (token != null) { + showDialogWithNoAndYesOptions( + context: context, + title: 'Transfer action', + isBarrierDismissible: true, + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + 'Are you sure you want transfer $queryAmount ${token.symbol} from $kSelectedAddress to $queryAddress?', + ), + ], + ), + onYesButtonPressed: () { + sendPaymentBloc.sendTransfer( + fromAddress: kSelectedAddress, + toAddress: queryAddress, + amount: + queryAmount.extractDecimals(token!.decimals), + token: token, + ); + }, + onNoButtonPressed: () {}, + ); + } + } - if (kCurrentPage != Tabs.lock) { - _navigateTo(Tabs.transfer); + case 'stake': + await sl().addNotification( + WalletNotification( + title: 'Stake action detected', + timestamp: DateTime.now().millisecondsSinceEpoch, + details: 'Deep link: $uriRaw', + type: NotificationType.paymentReceived, + ), + ); + + if (kCurrentPage != Tabs.lock) { + _navigateTo(Tabs.staking); - if (token != null) { showDialogWithNoAndYesOptions( context: context, - title: 'Transfer action', + title: 'Stake ${kZnnCoin.symbol} action', isBarrierDismissible: true, content: Column( mainAxisSize: MainAxisSize.min, children: [ Text( - 'Are you sure you want transfer $queryAmount ${token.symbol} from $kSelectedAddress to $queryAddress?',), + 'Are you sure you want stake $queryAmount ${kZnnCoin.symbol} for $queryDuration month(s)?', + ), ], ), onYesButtonPressed: () { - sendPaymentBloc.sendTransfer( - fromAddress: kSelectedAddress, - toAddress: queryAddress, - amount: - queryAmount.extractDecimals(token!.decimals), - token: token, + stakingOptionsBloc.stakeForQsr( + Duration(seconds: queryDuration * stakeTimeUnitSec), + queryAmount.extractDecimals(kZnnCoin.decimals), ); }, onNoButtonPressed: () {}, ); } - } - case 'stake': - await sl().addNotification( - WalletNotification( - title: 'Stake action detected', - timestamp: DateTime.now().millisecondsSinceEpoch, - details: 'Deep link: $uriRaw', - type: NotificationType.paymentReceived, - ), - ); - - if (kCurrentPage != Tabs.lock) { - _navigateTo(Tabs.staking); - - showDialogWithNoAndYesOptions( - context: context, - title: 'Stake ${kZnnCoin.symbol} action', - isBarrierDismissible: true, - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - 'Are you sure you want stake $queryAmount ${kZnnCoin.symbol} for $queryDuration month(s)?',), - ], + case 'delegate': + await sl().addNotification( + WalletNotification( + title: 'Delegate action detected', + timestamp: DateTime.now().millisecondsSinceEpoch, + details: 'Deep link: $uriRaw', + type: NotificationType.paymentReceived, ), - onYesButtonPressed: () { - stakingOptionsBloc.stakeForQsr( - Duration(seconds: queryDuration * stakeTimeUnitSec), - queryAmount.extractDecimals(kZnnCoin.decimals),); - }, - onNoButtonPressed: () {}, ); - } - case 'delegate': - await sl().addNotification( - WalletNotification( - title: 'Delegate action detected', - timestamp: DateTime.now().millisecondsSinceEpoch, - details: 'Deep link: $uriRaw', - type: NotificationType.paymentReceived, - ), - ); - - if (kCurrentPage != Tabs.lock) { - _navigateTo(Tabs.pillars); - - showDialogWithNoAndYesOptions( - context: context, - title: 'Delegate ${kZnnCoin.symbol} action', - isBarrierDismissible: true, - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - 'Are you sure you want delegate the ${kZnnCoin.symbol} from $kSelectedAddress to Pillar $queryPillarName?',), - ], + if (kCurrentPage != Tabs.lock) { + _navigateTo(Tabs.pillars); + + showDialogWithNoAndYesOptions( + context: context, + title: 'Delegate ${kZnnCoin.symbol} action', + isBarrierDismissible: true, + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + 'Are you sure you want delegate the ${kZnnCoin.symbol} from $kSelectedAddress to Pillar $queryPillarName?', + ), + ], + ), + onYesButtonPressed: () { + delegateButtonBloc.delegateToPillar(queryPillarName); + }, + onNoButtonPressed: () {}, + ); + } + + case 'fuse': + await sl().addNotification( + WalletNotification( + title: 'Fuse ${kQsrCoin.symbol} action detected', + timestamp: DateTime.now().millisecondsSinceEpoch, + details: 'Deep link: $uriRaw', + type: NotificationType.paymentReceived, ), - onYesButtonPressed: () { - delegateButtonBloc.delegateToPillar(queryPillarName); - }, - onNoButtonPressed: () {}, ); - } - case 'fuse': - await sl().addNotification( - WalletNotification( - title: 'Fuse ${kQsrCoin.symbol} action detected', - timestamp: DateTime.now().millisecondsSinceEpoch, - details: 'Deep link: $uriRaw', - type: NotificationType.paymentReceived, - ), - ); - - if (kCurrentPage != Tabs.lock) { - _navigateTo(Tabs.plasma); - - showDialogWithNoAndYesOptions( - context: context, - title: 'Fuse ${kQsrCoin.symbol} action', - isBarrierDismissible: true, - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - 'Are you sure you want fuse $queryAmount ${kQsrCoin.symbol} for address $queryAddress?',), - ], + if (kCurrentPage != Tabs.lock) { + _navigateTo(Tabs.plasma); + + showDialogWithNoAndYesOptions( + context: context, + title: 'Fuse ${kQsrCoin.symbol} action', + isBarrierDismissible: true, + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + 'Are you sure you want fuse $queryAmount ${kQsrCoin.symbol} for address $queryAddress?', + ), + ], + ), + onYesButtonPressed: () { + plasmaOptionsBloc.generatePlasma( + queryAddress, + queryAmount.extractDecimals(kZnnCoin.decimals), + ); + }, + onNoButtonPressed: () {}, + ); + } + + case 'sentinel': + await sl().addNotification( + WalletNotification( + title: 'Deploy Sentinel action detected', + timestamp: DateTime.now().millisecondsSinceEpoch, + details: 'Deep link: $uriRaw', + type: NotificationType.paymentReceived, ), - onYesButtonPressed: () { - plasmaOptionsBloc.generatePlasma(queryAddress, - queryAmount.extractDecimals(kZnnCoin.decimals),); - }, - onNoButtonPressed: () {}, ); - } - case 'sentinel': - await sl().addNotification( - WalletNotification( - title: 'Deploy Sentinel action detected', - timestamp: DateTime.now().millisecondsSinceEpoch, - details: 'Deep link: $uriRaw', - type: NotificationType.paymentReceived, - ), - ); - - if (kCurrentPage != Tabs.lock) { - _navigateTo(Tabs.sentinels); - } + if (kCurrentPage != Tabs.lock) { + _navigateTo(Tabs.sentinels); + } - case 'pillar': - await sl().addNotification( - WalletNotification( - title: 'Deploy Pillar action detected', - timestamp: DateTime.now().millisecondsSinceEpoch, - details: 'Deep link: $uriRaw', - type: NotificationType.paymentReceived, - ), - ); + case 'pillar': + await sl().addNotification( + WalletNotification( + title: 'Deploy Pillar action detected', + timestamp: DateTime.now().millisecondsSinceEpoch, + details: 'Deep link: $uriRaw', + type: NotificationType.paymentReceived, + ), + ); - if (kCurrentPage != Tabs.lock) { - _navigateTo(Tabs.pillars); - } + if (kCurrentPage != Tabs.lock) { + _navigateTo(Tabs.pillars); + } - default: - await sl().addNotification( - WalletNotification( - title: 'Incoming link detected', - timestamp: DateTime.now().millisecondsSinceEpoch, - details: 'Deep link: $uriRaw', - type: NotificationType.paymentReceived, - ), - ); - break; + default: + await sl().addNotification( + WalletNotification( + title: 'Incoming link detected', + timestamp: DateTime.now().millisecondsSinceEpoch, + details: 'Deep link: $uriRaw', + type: NotificationType.paymentReceived, + ), + ); + break; + } } + return; } - return; } - } - }, onDone: () { - Logger('MainAppContainer') - .log(Level.INFO, '_handleIncomingLinks', 'done'); - }, onError: (Object err) async { - await NotificationUtils.sendNotificationError( - err, 'Handle incoming link failed',); - Logger('MainAppContainer') - .log(Level.WARNING, '_handleIncomingLinks', err); - if (!mounted) return; - },); + }, + onDone: () { + Logger('MainAppContainer') + .log(Level.INFO, '_handleIncomingLinks', 'done'); + }, + onError: (Object err) async { + await NotificationUtils.sendNotificationError( + err, + 'Handle incoming link failed', + ); + Logger('MainAppContainer') + .log(Level.WARNING, '_handleIncomingLinks', err); + if (!mounted) return; + }, + ); } } @@ -1015,11 +872,19 @@ class _MainAppContainerState extends State } if (!mounted) return; } on PlatformException catch (e, stackTrace) { - Logger('MainAppContainer').log(Level.WARNING, - '_handleInitialUri PlatformException', e, stackTrace,); + Logger('MainAppContainer').log( + Level.WARNING, + '_handleInitialUri PlatformException', + e, + stackTrace, + ); } on FormatException catch (e, stackTrace) { Logger('MainAppContainer').log( - Level.WARNING, '_handleInitialUri FormatException', e, stackTrace,); + Level.WARNING, + '_handleInitialUri FormatException', + e, + stackTrace, + ); if (!mounted) return; } } @@ -1027,8 +892,7 @@ class _MainAppContainerState extends State @override Future onClipboardChanged() async { - final newClipboardData = - await Clipboard.getData(Clipboard.kTextPlain); + final newClipboardData = await Clipboard.getData(Clipboard.kTextPlain); final text = newClipboardData?.text ?? ''; if (text.isNotEmpty && WalletConnectUri.tryParse(text) != null) { // This check is needed because onClipboardChanged is called twice sometimes From 3ecac7e2552fc4be22411f94a60d5d98ebb9d00c Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Thu, 24 Oct 2024 12:19:03 +0300 Subject: [PATCH 035/102] feat: Delete unused class --- lib/blocs/dashboard/dashboard.dart | 1 - lib/blocs/dashboard/dashboard_base_bloc.dart | 48 -------------------- 2 files changed, 49 deletions(-) delete mode 100644 lib/blocs/dashboard/dashboard_base_bloc.dart diff --git a/lib/blocs/dashboard/dashboard.dart b/lib/blocs/dashboard/dashboard.dart index 75cdfc91..2324e8c8 100644 --- a/lib/blocs/dashboard/dashboard.dart +++ b/lib/blocs/dashboard/dashboard.dart @@ -1,3 +1,2 @@ export 'balance_bloc.dart'; -export 'dashboard_base_bloc.dart'; diff --git a/lib/blocs/dashboard/dashboard_base_bloc.dart b/lib/blocs/dashboard/dashboard_base_bloc.dart deleted file mode 100644 index dc43496a..00000000 --- a/lib/blocs/dashboard/dashboard_base_bloc.dart +++ /dev/null @@ -1,48 +0,0 @@ -import 'dart:async'; - -import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; -import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; - -abstract class DashboardBaseBloc extends BaseBloc with RefreshBlocMixin { - - DashboardBaseBloc() { - listenToWsRestart(getDataPeriodically); - } - Timer? _autoRefresher; - - Future makeAsyncCall(); - - Timer _getAutoRefreshTimer() => Timer( - kIntervalBetweenMomentums, - () { - _autoRefresher!.cancel(); - getDataPeriodically(); - }, - ); - - Future getDataPeriodically() async { - try { - if (!zenon!.wsClient.isClosed()) { - final data = await makeAsyncCall(); - addEvent(data); - } else { - throw noConnectionException; - } - } catch (e, stackTrace) { - addError(e, stackTrace); - } finally { - if (_autoRefresher == null) { - _autoRefresher = _getAutoRefreshTimer(); - } else if (!_autoRefresher!.isActive) { - _autoRefresher = _getAutoRefreshTimer(); - } - } - } - - @override - void dispose() { - _autoRefresher?.cancel(); - super.dispose(); - } -} From c48a47d0c3113dab5217f7e3db05483cc368fe6e Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Thu, 24 Oct 2024 13:00:02 +0300 Subject: [PATCH 036/102] feat: Adapt Transfer widget to the new architecture --- lib/rearchitecture/dashboard/dashboard.dart | 1 + .../dashboard/transfer/transfer.dart | 1 + .../transfer/view/transfer_card.dart | 71 ++++++++++++++++++ lib/utils/card/card_type.dart | 8 +- .../dashboard_widgets/dashboard_widgets.dart | 1 - .../dashboard_widgets/transfer.dart | 74 ------------------- .../dashboard_tab_child.dart | 2 +- 7 files changed, 81 insertions(+), 77 deletions(-) create mode 100644 lib/rearchitecture/dashboard/transfer/transfer.dart create mode 100644 lib/rearchitecture/dashboard/transfer/view/transfer_card.dart delete mode 100644 lib/widgets/modular_widgets/dashboard_widgets/transfer.dart diff --git a/lib/rearchitecture/dashboard/dashboard.dart b/lib/rearchitecture/dashboard/dashboard.dart index 382057e4..8c637140 100644 --- a/lib/rearchitecture/dashboard/dashboard.dart +++ b/lib/rearchitecture/dashboard/dashboard.dart @@ -9,3 +9,4 @@ export '../dashboard/sentinels/sentinels.dart'; export '../dashboard/staking/staking.dart'; export '../dashboard/total_hourly_transactions/total_hourly_transactions.dart'; export 'dashboard_cubit.dart'; +export 'transfer/transfer.dart'; diff --git a/lib/rearchitecture/dashboard/transfer/transfer.dart b/lib/rearchitecture/dashboard/transfer/transfer.dart new file mode 100644 index 00000000..c5de3cf7 --- /dev/null +++ b/lib/rearchitecture/dashboard/transfer/transfer.dart @@ -0,0 +1 @@ +export 'view/transfer_card.dart'; diff --git a/lib/rearchitecture/dashboard/transfer/view/transfer_card.dart b/lib/rearchitecture/dashboard/transfer/view/transfer_card.dart new file mode 100644 index 00000000..9f8c7e2b --- /dev/null +++ b/lib/rearchitecture/dashboard/transfer/view/transfer_card.dart @@ -0,0 +1,71 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_vector_icons/flutter_vector_icons.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/card/card.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; + +/// A card with two [IconButton] widgets that redirect to the Transfer tab +class TransferCard extends StatefulWidget { + /// Creates a Transfer object. + const TransferCard({ + super.key, + this.changePage, + }); + + final Function( + Tabs, { + bool redirectWithSendContainerLarge, + bool redirectWithReceiveContainerLarge, + })? changePage; + + @override + State createState() => _TransferCardState(); +} + +class _TransferCardState extends State { + @override + Widget build(BuildContext context) { + return CardScaffoldWithoutListener( + data: CardType.transfer.getData(context: context), + body: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + IconButton( + splashRadius: 30, + onPressed: () { + widget.changePage!( + Tabs.transfer, + redirectWithSendContainerLarge: true, + ); + }, + icon: const Icon( + SimpleLineIcons.arrow_up_circle, + ), + color: AppColors.darkHintTextColor, + iconSize: 48, + ), + const TransferIconLegend( + legendText: '● Send', + ), + IconButton( + splashRadius: 30, + onPressed: () { + widget.changePage!( + Tabs.transfer, + redirectWithReceiveContainerLarge: true, + ); + }, + icon: const Icon( + SimpleLineIcons.arrow_down_circle, + ), + iconSize: 48, + color: AppColors.lightHintTextColor, + ), + const TransferIconLegend( + legendText: '● Receive', + ), + ], + ), + ); + } +} diff --git a/lib/utils/card/card_type.dart b/lib/utils/card/card_type.dart index a553fc8a..7319b336 100644 --- a/lib/utils/card/card_type.dart +++ b/lib/utils/card/card_type.dart @@ -11,7 +11,8 @@ enum CardType { realtimeStatistics, sentinels, staking, - totalHourlyTransactions; + totalHourlyTransactions, + transfer; /// Returns the [CardData] assigned to a specific [CardType] value. /// @@ -65,6 +66,11 @@ enum CardType { 'transactions settled in the last hour across the network', title: 'Transactions', ), + CardType.transfer => CardData( + description: 'Redirects you to the Transfer tab where you ' + 'can manage sending and receiving funds', + title: 'Transfer', + ), }; } } diff --git a/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart b/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart index 5e26a9ec..1288765e 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart @@ -1,2 +1 @@ export 'plasma_stats.dart'; -export 'transfer.dart'; diff --git a/lib/widgets/modular_widgets/dashboard_widgets/transfer.dart b/lib/widgets/modular_widgets/dashboard_widgets/transfer.dart deleted file mode 100644 index 57d99ccc..00000000 --- a/lib/widgets/modular_widgets/dashboard_widgets/transfer.dart +++ /dev/null @@ -1,74 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_vector_icons/flutter_vector_icons.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; - -const String _kWidgetTitle = 'Transfer'; -const String _kWidgetDescription = - 'Redirects you to the Transfer tab where you ' - 'can manage sending and receiving funds'; - -class Transfer extends StatefulWidget { - - const Transfer({ - super.key, - this.changePage, - }); - final Function( - Tabs, { - bool redirectWithSendContainerLarge, - bool redirectWithReceiveContainerLarge, - })? changePage; - - @override - State createState() => _TransferState(); -} - -class _TransferState extends State { - @override - Widget build(BuildContext context) { - return CardScaffold( - title: _kWidgetTitle, - description: _kWidgetDescription, - childBuilder: _getTransferButtons, - ); - } - - Column _getTransferButtons() { - return Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - IconButton( - splashRadius: 30, - onPressed: () { - widget.changePage!(Tabs.transfer, - redirectWithSendContainerLarge: true,); - }, - icon: const Icon( - SimpleLineIcons.arrow_up_circle, - ), - color: AppColors.darkHintTextColor, - iconSize: 48, - ), - const TransferIconLegend( - legendText: '● Send', - ), - IconButton( - splashRadius: 30, - onPressed: () { - widget.changePage!(Tabs.transfer, - redirectWithReceiveContainerLarge: true,); - }, - icon: const Icon( - SimpleLineIcons.arrow_down_circle, - ), - iconSize: 48, - color: AppColors.lightHintTextColor, - ), - const TransferIconLegend( - legendText: '● Receive', - ), - ], - ); - } -} diff --git a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart index 3e75d89f..b8bede97 100644 --- a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart +++ b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart @@ -47,7 +47,7 @@ class _DashboardTabChildState extends State { child: PlasmaStats(), ), FluidCell( - child: Transfer( + child: TransferCard( changePage: widget.changePage, ), ), From 0d7c7db7eb8af706f8b99232d3384ac72382ec24 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Thu, 24 Oct 2024 13:02:12 +0300 Subject: [PATCH 037/102] chore: Redo dashboard.dart exports --- lib/rearchitecture/dashboard/dashboard.dart | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/rearchitecture/dashboard/dashboard.dart b/lib/rearchitecture/dashboard/dashboard.dart index 8c637140..827fa703 100644 --- a/lib/rearchitecture/dashboard/dashboard.dart +++ b/lib/rearchitecture/dashboard/dashboard.dart @@ -1,12 +1,11 @@ - -export '../dashboard/balance/balance.dart'; -export '../dashboard/balance_dashboard/balance_dashboard.dart'; -export '../dashboard/delegation/delegation.dart'; -export '../dashboard/dual_coin_stats/dual_coin_stats.dart'; -export '../dashboard/pillars/pillars.dart'; -export '../dashboard/realtime_statistics/realtime_statistics.dart'; -export '../dashboard/sentinels/sentinels.dart'; -export '../dashboard/staking/staking.dart'; -export '../dashboard/total_hourly_transactions/total_hourly_transactions.dart'; +export 'balance/balance.dart'; +export 'balance_dashboard/balance_dashboard.dart'; export 'dashboard_cubit.dart'; +export 'delegation/delegation.dart'; +export 'dual_coin_stats/dual_coin_stats.dart'; +export 'pillars/pillars.dart'; +export 'realtime_statistics/realtime_statistics.dart'; +export 'sentinels/sentinels.dart'; +export 'staking/staking.dart'; +export 'total_hourly_transactions/total_hourly_transactions.dart'; export 'transfer/transfer.dart'; From ef8a24a05d8f9e0f60ad7c61c23a831b60fa848a Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Thu, 24 Oct 2024 19:02:01 +0300 Subject: [PATCH 038/102] chore: Delete unused feature balance_dashboard --- .../balance_dashboard/balance_dashboard.dart | 1 - .../cubit/balance_dashboard_cubit.dart | 56 ------------------- .../cubit/balance_dashboard_state.dart | 43 -------------- lib/rearchitecture/dashboard/dashboard.dart | 1 - 4 files changed, 101 deletions(-) delete mode 100644 lib/rearchitecture/dashboard/balance_dashboard/balance_dashboard.dart delete mode 100644 lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_cubit.dart delete mode 100644 lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_state.dart diff --git a/lib/rearchitecture/dashboard/balance_dashboard/balance_dashboard.dart b/lib/rearchitecture/dashboard/balance_dashboard/balance_dashboard.dart deleted file mode 100644 index 2d356f30..00000000 --- a/lib/rearchitecture/dashboard/balance_dashboard/balance_dashboard.dart +++ /dev/null @@ -1 +0,0 @@ -export 'cubit/balance_dashboard_cubit.dart'; diff --git a/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_cubit.dart b/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_cubit.dart deleted file mode 100644 index 131c096c..00000000 --- a/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_cubit.dart +++ /dev/null @@ -1,56 +0,0 @@ -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/exceptions/exceptions.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; - -part 'balance_dashboard_state.dart'; - -/// A `BalanceDashboardCubit` that fetches and manages the account balance -/// data for a single account. -/// -/// This cubit extends `DashboardCubit`, utilizing the -/// `AccountInfo` data type to store and manage the balance data for a specific -/// account. -/// It provides the logic for fetching and updating the balance. -class BalanceDashboardCubit - extends DashboardCubit { - /// Constructs a `BalanceDashboardCubit`, passing the `zenon` client and the - /// initial state to the parent class. - /// - /// The `zenon` client is used to interact with the Zenon ledger to retrieve - /// account information. - BalanceDashboardCubit(super.zenon, super.initialState); - - /// Fetches the account balance data for the provided address. - /// - /// This method retrieves account information using the Zenon SDK's - /// `getAccountInfoByAddress()` method. - /// It checks the balance and block count of the account: - /// - If the account has blocks and a non-zero balance (either ZNN or QSR), - /// it returns the `AccountInfo`. - /// - If the balance is empty, it throws an error indicating that the balance - /// is zero. - /// - /// Throws: - /// - An error if the balance is empty or any exception occurs during data - /// fetching. - @override - Future fetch() async { - try { - final response = await zenon.ledger.getAccountInfoByAddress( - Address.parse( - kSelectedAddress!, - ), - ); - - if (response.blockCount! > 0 && - (response.znn()! > BigInt.zero || response.qsr()! > BigInt.zero)) { - return response; - } else { - throw NoBalanceException(); - } - } catch (e) { - rethrow; - } - } -} diff --git a/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_state.dart b/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_state.dart deleted file mode 100644 index 1a6af645..00000000 --- a/lib/rearchitecture/dashboard/balance_dashboard/cubit/balance_dashboard_state.dart +++ /dev/null @@ -1,43 +0,0 @@ -part of 'balance_dashboard_cubit.dart'; - -/// The state class for the `BalanceDashboardCubit`, extending `DashboardState` -/// and managing detailed account balance data. -/// -/// `BalanceDashboardState` holds an `AccountInfo` object representing the -/// balance information of a single account. -/// This state is used by the `BalanceDashboardCubit` to track detailed balance -/// data. -class BalanceDashboardState extends DashboardState { - /// Constructs a new `BalanceDashboardState`. - /// - /// This state uses the default `status`, `data`, and `error` from the parent - /// `DashboardState` class, - /// and initializes them to manage the detailed account balance. - const BalanceDashboardState({ - super.status, - super.data, - super.error, - }); - - /// Creates a copy of the current `BalanceDashboardState` with optional new - /// values for `status`, `data`, and `error`. - /// - /// This method is used to create a new state with updated fields if provided, - /// otherwise retaining the existing values. - /// - /// Returns: - /// - A new instance of `BalanceDashboardState` with updated values or the - /// current ones if none are provided. - @override - DashboardState copyWith({ - CubitStatus? status, - AccountInfo? data, - Object? error, - }) { - return BalanceDashboardState( - status: status ?? this.status, - data: data ?? this.data, - error: error ?? this.error, - ); - } -} diff --git a/lib/rearchitecture/dashboard/dashboard.dart b/lib/rearchitecture/dashboard/dashboard.dart index 827fa703..467bc29b 100644 --- a/lib/rearchitecture/dashboard/dashboard.dart +++ b/lib/rearchitecture/dashboard/dashboard.dart @@ -1,5 +1,4 @@ export 'balance/balance.dart'; -export 'balance_dashboard/balance_dashboard.dart'; export 'dashboard_cubit.dart'; export 'delegation/delegation.dart'; export 'dual_coin_stats/dual_coin_stats.dart'; From 5b37f1934c7ff2e452363375efc19f785b3f8f65 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Thu, 24 Oct 2024 19:36:14 +0300 Subject: [PATCH 039/102] feat: Use localization version strings for generating CardData objects --- lib/l10n/app_en.arb | 17 +++++++++++- lib/utils/card/card_type.dart | 51 +++++++++++++++-------------------- 2 files changed, 38 insertions(+), 30 deletions(-) diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index fb032025..0ffbc88f 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -1,5 +1,20 @@ { "balance": "Balance", + "currentAmounts": "This card displays the current {kZnnCoinSymbol} and {kQsrCoinSymbol} amounts for the selected address", + "delegationStats": "Delegation Stats", + "delegationStatsDescription": "This card displays the amount of {kZnnCoinSymbol} and the name of the Pillar that you delegated to", "dualCoinStats": "Dual Coin Stats", - "delegationStats": "Delegation Stats" + "dualCoinStatsDescription": "This card displays the circulating {kZnnCoinSymbol} and {kQsrCoinSymbol} supply from the network", + "pillars": "Pillars", + "pillarsDescription": "This card displays the number of active Pillars in the network", + "realtimeStats": "Realtime Stats", + "realtimeStatsDescription": "This card displays the number of {kZnnCoinSymbol} and {kQsrCoinSymbol} transactions. For example, a delegation is considered a {kZnnCoinSymbol} transaction from the network's perspective. Every interaction with the network embedded contracts is internally considered a transaction", + "sentinels": "Sentinels", + "sentinelsDescription": "This card displays the number of active Sentinels in the network", + "stakingStats": "Staking Stats", + "stakingStatsDescription": "This card displays the number of staking entries and the total {kZnnCoinSymbol} that you are currently staking", + "transactions": "Transactions", + "transactionsDescription": "This card displays the total number of transactions settled in the last hour across the network", + "transfer": "Transfer", + "transferDescription": "Redirects you to the Transfer tab where you can manage sending and receiving funds" } \ No newline at end of file diff --git a/lib/utils/card/card_type.dart b/lib/utils/card/card_type.dart index 7319b336..c58caf59 100644 --- a/lib/utils/card/card_type.dart +++ b/lib/utils/card/card_type.dart @@ -23,53 +23,46 @@ enum CardType { return switch (this) { CardType.balance => CardData( title: context.l10n.balance, - description: 'This card displays the current ${kZnnCoin.symbol} ' - 'and ${kQsrCoin.symbol} amounts for the selected address', + description: context.l10n.currentAmounts( + kQsrCoin.symbol, + kZnnCoin.symbol, + ), ), CardType.delegationStats => CardData( title: context.l10n.delegationStats, - description: 'This card displays the amount of ${kZnnCoin.symbol} ' - 'and the name of the Pillar that you delegated to', + description: context.l10n.delegationStatsDescription(kZnnCoin.symbol), ), CardType.dualCoinStats => CardData( title: context.l10n.dualCoinStats, - description: 'This card displays the circulating ${kZnnCoin.symbol} ' - 'and ${kQsrCoin.symbol} supply from the network', + description: context.l10n.dualCoinStatsDescription( + kQsrCoin.symbol, + kZnnCoin.symbol, + ), ), CardType.pillars => CardData( - title: 'Pillars', - description: 'This card displays the number of active ' - 'Pillars in the network', + title: context.l10n.pillars, + description: context.l10n.pillarsDescription, ), CardType.realtimeStatistics => CardData( - title: 'Realtime Stats', - description: - 'This card displays the number of ${kZnnCoin.symbol} and ' - '${kQsrCoin.symbol} transactions. For example, a delegation is ' - "considered a ${kZnnCoin.symbol} transaction from the network's " - 'perspective. Every interaction with the network embedded ' - 'contracts is internally considered a transaction', + title: context.l10n.realtimeStats, + description: context.l10n + .realtimeStatsDescription(kQsrCoin.symbol, kZnnCoin.symbol), ), CardType.sentinels => CardData( - title: 'Sentinels', - description: 'This card displays the number of active ' - 'Sentinels in the network', + title: context.l10n.sentinels, + description: context.l10n.sentinelsDescription, ), CardType.staking => CardData( - description: 'This card displays the number of staking ' - 'entries and the total ${kZnnCoin.symbol} that you are currently ' - 'staking', - title: 'Staking Stats', + description: context.l10n.stakingStatsDescription(kZnnCoin.symbol), + title: context.l10n.stakingStats, ), CardType.totalHourlyTransactions => CardData( - description: 'This card displays the total number of ' - 'transactions settled in the last hour across the network', - title: 'Transactions', + description: context.l10n.transactionsDescription, + title: context.l10n.transactions, ), CardType.transfer => CardData( - description: 'Redirects you to the Transfer tab where you ' - 'can manage sending and receiving funds', - title: 'Transfer', + description: context.l10n.transferDescription, + title: context.l10n.transfer, ), }; } From 8b4ea0e3fc9b7ef3a9bea297cd8f4de6a8c73fb2 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Fri, 25 Oct 2024 11:37:55 +0300 Subject: [PATCH 040/102] chore: Improve documentation --- .../balance/cubit/balance_cubit.dart | 15 +++------ .../balance/cubit/balance_state.dart | 24 +++++++------- .../dashboard/dashboard_cubit.dart | 16 ++++++---- .../dashboard/dashboard_state.dart | 32 ++++++++++++------- 4 files changed, 46 insertions(+), 41 deletions(-) diff --git a/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart b/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart index 5bad4a9c..0bf8e07c 100644 --- a/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart +++ b/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart @@ -1,23 +1,18 @@ - import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/utils/exceptions/exceptions.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'balance_state.dart'; -/// `BalanceCubit` is responsible for managing and fetching the account balances -/// of multiple addresses. It extends the `DashboardCubit` with a state -/// represented as a `Map` of addresses and their associated `AccountInfo`. +/// A cubit that is responsible for managing and fetching the account balance +/// of the provided [address]. class BalanceCubit extends DashboardCubit { - /// Constructs a `BalanceCubit` with the provided `zenon` client and initial - /// state. - /// - /// The [zenon] parameter provides access to the Zenon SDK for interacting with - /// account information, and the [initialState] is a map of addresses to their - /// respective balances at the time the cubit is initialized. + /// Constructs a BalanceCubit with the provided [zenon] client, [address] and + /// [initialState]. BalanceCubit(this.address, super.zenon, super.initialState); + /// The address for which the balance will be retrieved final Address address; /// Fetches the balance information for a single address. diff --git a/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart b/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart index 0a7b1b0e..0d3be3a9 100644 --- a/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart +++ b/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart @@ -1,32 +1,30 @@ part of 'balance_cubit.dart'; -/// The state class for the `BalanceCubit`, extending `DashboardState` and -/// managing account balance data. +/// The class used by the [BalanceCubit] to send state updates to the +/// listening widgets. /// -/// `BalanceState` holds a map of account addresses to their corresponding -/// `AccountInfo` objects. -/// This state is used by the `BalanceCubit` to track the balance information -/// for multiple addresses. +/// The data hold, when the status is [CubitStatus.success] is of type +/// [AccountInfo]. + class BalanceState extends DashboardState { - /// Constructs a new `BalanceState`. + /// Constructs a new BalanceState. /// - /// This state uses the default `status`, `data`, and `error` from the parent - /// `DashboardState` class - /// and initializes them for managing balance data. + /// This state uses the default [status], [data], and [error] from the parent + /// [DashboardState] class const BalanceState({ super.status, super.data, super.error, }); - /// Creates a copy of the current `BalanceState` with optional new values for - /// `status`, `data`, and `error`. + /// Creates a copy of the current [BalanceState] with optional new values for + /// [status], [data], and [error]. /// /// This method is used to create a new state with updated fields if provided, /// otherwise retaining the existing values. /// /// Returns: - /// - A new instance of `BalanceState` with the updated values or the + /// - A new instance of [BalanceState] with the updated values or the /// existing ones if none are provided. @override DashboardState copyWith({ diff --git a/lib/rearchitecture/dashboard/dashboard_cubit.dart b/lib/rearchitecture/dashboard/dashboard_cubit.dart index 26cd066a..320bbfed 100644 --- a/lib/rearchitecture/dashboard/dashboard_cubit.dart +++ b/lib/rearchitecture/dashboard/dashboard_cubit.dart @@ -16,7 +16,8 @@ part 'dashboard_state.dart'; /// [S] extends [DashboardState] abstract class DashboardCubit> extends Cubit { - /// Constructs a `DashboardCubit` with the provided [zenon] client and initial state. + /// Constructs a `DashboardCubit` with the provided [zenon] client and initial + /// state. /// /// The auto-refresh functionality is initialized upon the cubit's creation. DashboardCubit( @@ -29,6 +30,7 @@ abstract class DashboardCubit> extends Cubit { /// The Zenon client used to fetch data from the Zenon ledger. final Zenon zenon; + /// The interval at which to fetch the data again. final Duration refreshInterval; /// Fetches data of type [T] that is managed by the cubit. @@ -52,10 +54,12 @@ abstract class DashboardCubit> extends Cubit { }, ); - /// Periodically fetches data and updates the state with either success or failure. + /// Periodically fetches data and updates the state with either success or + /// failure. /// - /// This method fetches new data by calling [fetch], emits a loading state while - /// fetching, and updates the state with success or failure based on the outcome. + /// This method fetches new data by calling [fetch], emits a loading state + /// while fetching, and updates the state with success or failure based on + /// the outcome. /// If the WebSocket client is closed, it throws a [noConnectionException]. Future fetchDataPeriodically() async { try { @@ -86,8 +90,8 @@ abstract class DashboardCubit> extends Cubit { /// Cancels the auto-refresh timer and closes the cubit. /// - /// This method is called when the cubit is closed, ensuring that no background - /// tasks remain active after the cubit is disposed. + /// This method is called when the cubit is closed, ensuring that no + /// background tasks remain active after the cubit is disposed. @override Future close() { _autoRefresher?.cancel(); diff --git a/lib/rearchitecture/dashboard/dashboard_state.dart b/lib/rearchitecture/dashboard/dashboard_state.dart index 11425070..8593bdc0 100644 --- a/lib/rearchitecture/dashboard/dashboard_state.dart +++ b/lib/rearchitecture/dashboard/dashboard_state.dart @@ -3,14 +3,14 @@ part of 'dashboard_cubit.dart'; /// Represents the various statuses a cubit can have during its lifecycle. /// /// This enum is used to track and emit different states: -/// - [failure]: Indicates that the cubit has encountered an error. -/// - [initial]: The initial state before any data has been loaded. -/// - [loading]: Data is currently being fetched. -/// - [success]: Data has been successfully loaded. enum CubitStatus { + /// Indicates that the cubit has encountered an error. failure, + /// The initial state before any data has been loaded. initial, + /// Data is currently being fetched. loading, + /// Data has been successfully loaded. success, } @@ -22,36 +22,44 @@ enum CubitStatus { /// handle specific data types. /// /// The state includes: -/// - [status]: A [CubitStatus] that indicates the current state (loading, success, etc.). +/// - [status]: A [CubitStatus] that indicates the current state (loading, +/// success, etc.). /// - [data]: The data of type [T] that is managed by the cubit. -/// - [error]: An optional [error] object that contains error details if the cubit is in a failure state. +/// - [error]: An optional [error] object that contains error details if the +/// cubit is in a failure state. abstract class DashboardState extends Equatable { - /// Constructs a [DashboardState] with an optional [status], [data], and [error]. + /// Constructs a [DashboardState] with an [status], [data], and + /// [error]. /// /// - The [status] defaults to [CubitStatus.initial] if not provided. - /// - The [data] and [error] can be null, indicating that either no data has been fetched yet, or an error has occurred. + /// - The [data] and [error] can be null, indicating that either no data has + /// been fetched yet, or an error has occurred. const DashboardState({ this.status = CubitStatus.initial, this.data, this.error, }); - /// Represents the current status of the cubit, such as loading, success, or failure. + /// Represents the current status of the cubit, such as loading, success, or + /// failure. final CubitStatus status; - /// The data of type [T] managed by the cubit, which can be null if no data has been loaded or if there was an error. + /// The data of type [T] managed by the cubit, which can be null if no data + /// has been loaded or if there was an error. final T? data; /// An optional error object that holds error details in case of failure. final Object? error; - /// Creates a copy of the current state with the option to modify specific fields. + /// Creates a copy of the current state with the option to modify specific + /// fields. /// /// - [status]: The new status of the cubit (e.g., loading, success). /// - [data]: The new data of type [T], if it has changed. /// - [error]: The new error, if any occurred. /// - /// Returns a new [DashboardState] with the updated fields. Subclasses (like `BalanceState`) will implement this to + /// Returns a new [DashboardState] with the updated fields. Subclasses + /// (like `BalanceState`) will implement this to /// ensure type safety and return the appropriate state class. DashboardState copyWith({ CubitStatus? status, From 2141f6a4e991856628e97cd4a683162c7a28d9cd Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Fri, 25 Oct 2024 11:41:50 +0300 Subject: [PATCH 041/102] chore: Rename CubitStatus class to DashboardStatus --- .../dashboard/balance/cubit/balance_state.dart | 4 ++-- .../dashboard/balance/view/balance_card.dart | 8 ++++---- .../dashboard/dashboard_cubit.dart | 6 +++--- .../dashboard/dashboard_state.dart | 16 ++++++++-------- .../delegation/cubit/delegation_state.dart | 2 +- .../delegation/view/delegation_card.dart | 8 ++++---- .../cubit/dual_coin_stats_state.dart | 2 +- .../view/dual_coin_stats_card.dart | 10 +++++----- .../widgets/dual_coin_stats_empty.dart | 2 +- .../widgets/dual_coin_stats_error.dart | 2 +- .../widgets/dual_coin_stats_loading.dart | 2 +- .../widgets/dual_coin_stats_populated.dart | 2 +- .../dashboard/pillars/cubit/pillars_state.dart | 2 +- .../dashboard/pillars/view/pillars_card.dart | 10 +++++----- .../dashboard/pillars/widgets/pillars_empty.dart | 2 +- .../dashboard/pillars/widgets/pillars_error.dart | 2 +- .../pillars/widgets/pillars_loading.dart | 2 +- .../pillars/widgets/pillars_populated.dart | 2 +- .../cubit/realtime_statistics_state.dart | 2 +- .../view/realtime_statistics_card.dart | 8 ++++---- .../widgets/realtime_statistics_populated.dart | 2 +- .../sentinels/cubit/sentinels_state.dart | 2 +- .../dashboard/sentinels/view/sentinels_card.dart | 10 +++++----- .../sentinels/widgets/sentinels_empty.dart | 2 +- .../sentinels/widgets/sentinels_error.dart | 2 +- .../sentinels/widgets/sentinels_loading.dart | 2 +- .../sentinels/widgets/sentinels_populated.dart | 2 +- .../dashboard/staking/cubit/staking_state.dart | 2 +- .../dashboard/staking/view/staking_card.dart | 10 +++++----- .../dashboard/staking/widgets/staking_empty.dart | 2 +- .../dashboard/staking/widgets/staking_error.dart | 2 +- .../staking/widgets/staking_loading.dart | 2 +- .../staking/widgets/staking_populated.dart | 2 +- .../cubit/total_hourly_transactions_state.dart | 2 +- .../view/total_hourly_transactions_card.dart | 10 +++++----- .../widgets/total_hourly_transactions_empty.dart | 2 +- .../widgets/total_hourly_transactions_error.dart | 2 +- .../total_hourly_transactions_loading.dart | 2 +- .../total_hourly_transactions_populated.dart | 2 +- .../cubit/node_sync_status_cubit.dart | 2 +- .../cubit/node_sync_status_state.dart | 2 +- .../view/node_sync_status_icon.dart | 10 +++++----- .../widgets/node_sync_status_empty.dart | 2 +- .../widgets/node_sync_status_error.dart | 2 +- .../widgets/node_sync_status_loading.dart | 2 +- .../widgets/node_sync_status_populated.dart | 2 +- test/delegation/cubit/delegation_cubit_test.dart | 10 +++++----- 47 files changed, 94 insertions(+), 94 deletions(-) diff --git a/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart b/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart index 0d3be3a9..0fdcfa50 100644 --- a/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart +++ b/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart @@ -3,7 +3,7 @@ part of 'balance_cubit.dart'; /// The class used by the [BalanceCubit] to send state updates to the /// listening widgets. /// -/// The data hold, when the status is [CubitStatus.success] is of type +/// The data hold, when the status is [DashboardStatus.success] is of type /// [AccountInfo]. class BalanceState extends DashboardState { @@ -28,7 +28,7 @@ class BalanceState extends DashboardState { /// existing ones if none are provided. @override DashboardState copyWith({ - CubitStatus? status, + DashboardStatus? status, AccountInfo? data, Object? error, }) { diff --git a/lib/rearchitecture/dashboard/balance/view/balance_card.dart b/lib/rearchitecture/dashboard/balance/view/balance_card.dart index a94779ab..dc15825a 100644 --- a/lib/rearchitecture/dashboard/balance/view/balance_card.dart +++ b/lib/rearchitecture/dashboard/balance/view/balance_card.dart @@ -35,12 +35,12 @@ class BalanceCard extends StatelessWidget { body: BlocBuilder( builder: (context, state) { return switch (state.status) { - CubitStatus.initial => const BalanceEmpty(), - CubitStatus.loading => const BalanceLoading(), - CubitStatus.failure => BalanceError( + DashboardStatus.initial => const BalanceEmpty(), + DashboardStatus.loading => const BalanceLoading(), + DashboardStatus.failure => BalanceError( error: state.error!, ), - CubitStatus.success => BalancePopulated( + DashboardStatus.success => BalancePopulated( address: kSelectedAddress!, accountInfo: state.data!, ), diff --git a/lib/rearchitecture/dashboard/dashboard_cubit.dart b/lib/rearchitecture/dashboard/dashboard_cubit.dart index 320bbfed..f3b04367 100644 --- a/lib/rearchitecture/dashboard/dashboard_cubit.dart +++ b/lib/rearchitecture/dashboard/dashboard_cubit.dart @@ -63,15 +63,15 @@ abstract class DashboardCubit> extends Cubit { /// If the WebSocket client is closed, it throws a [noConnectionException]. Future fetchDataPeriodically() async { try { - emit(state.copyWith(status: CubitStatus.loading) as S); + emit(state.copyWith(status: DashboardStatus.loading) as S); if (!zenon.wsClient.isClosed()) { final data = await fetch(); - emit(state.copyWith(data: data, status: CubitStatus.success) as S); + emit(state.copyWith(data: data, status: DashboardStatus.success) as S); } else { throw noConnectionException; } } catch (e) { - emit(state.copyWith(status: CubitStatus.failure, error: e) as S); + emit(state.copyWith(status: DashboardStatus.failure, error: e) as S); } finally { /// Ensure that the auto-refresher is restarted if it's not active. if (!isTimerActive) { diff --git a/lib/rearchitecture/dashboard/dashboard_state.dart b/lib/rearchitecture/dashboard/dashboard_state.dart index 8593bdc0..c06d5817 100644 --- a/lib/rearchitecture/dashboard/dashboard_state.dart +++ b/lib/rearchitecture/dashboard/dashboard_state.dart @@ -1,9 +1,9 @@ part of 'dashboard_cubit.dart'; -/// Represents the various statuses a cubit can have during its lifecycle. +/// Represents the various statuses a cubit's request can have. /// -/// This enum is used to track and emit different states: -enum CubitStatus { +/// This enum is used to track and emit states with different statuses. +enum DashboardStatus { /// Indicates that the cubit has encountered an error. failure, /// The initial state before any data has been loaded. @@ -22,7 +22,7 @@ enum CubitStatus { /// handle specific data types. /// /// The state includes: -/// - [status]: A [CubitStatus] that indicates the current state (loading, +/// - [status]: A [DashboardStatus] that indicates the current state (loading, /// success, etc.). /// - [data]: The data of type [T] that is managed by the cubit. /// - [error]: An optional [error] object that contains error details if the @@ -32,17 +32,17 @@ abstract class DashboardState extends Equatable { /// Constructs a [DashboardState] with an [status], [data], and /// [error]. /// - /// - The [status] defaults to [CubitStatus.initial] if not provided. + /// - The [status] defaults to [DashboardStatus.initial] if not provided. /// - The [data] and [error] can be null, indicating that either no data has /// been fetched yet, or an error has occurred. const DashboardState({ - this.status = CubitStatus.initial, + this.status = DashboardStatus.initial, this.data, this.error, }); /// Represents the current status of the cubit, such as loading, success, or /// failure. - final CubitStatus status; + final DashboardStatus status; /// The data of type [T] managed by the cubit, which can be null if no data /// has been loaded or if there was an error. @@ -62,7 +62,7 @@ abstract class DashboardState extends Equatable { /// (like `BalanceState`) will implement this to /// ensure type safety and return the appropriate state class. DashboardState copyWith({ - CubitStatus? status, + DashboardStatus? status, T? data, Object? error, }); diff --git a/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart b/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart index cc353f9e..8802e59b 100644 --- a/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart +++ b/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart @@ -24,7 +24,7 @@ class DelegationState extends DashboardState { /// - A new instance of `DelegationState` with the updated values or the existing ones if none are provided. @override DashboardState copyWith({ - CubitStatus? status, + DashboardStatus? status, DelegationInfo? data, Object? error, }) { diff --git a/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart b/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart index 6a91713b..2b508fb4 100644 --- a/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart +++ b/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart @@ -27,12 +27,12 @@ class DelegationCard extends StatelessWidget { body: BlocBuilder( builder: (context, state) { return switch (state.status) { - CubitStatus.initial => const DelegationEmpty(), - CubitStatus.loading => const DelegationLoading(), - CubitStatus.failure => DelegationError( + DashboardStatus.initial => const DelegationEmpty(), + DashboardStatus.loading => const DelegationLoading(), + DashboardStatus.failure => DelegationError( error: state.error!, ), - CubitStatus.success => DelegationPopulated( + DashboardStatus.success => DelegationPopulated( data: state.data!, ), }; diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart index 172d1d85..d21ec98a 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart @@ -30,7 +30,7 @@ class DualCoinStatsState extends DashboardState> { /// existing ones if none are provided. @override DashboardState> copyWith({ - CubitStatus? status, + DashboardStatus? status, List? data, Object? error, }) { diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart b/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart index eaebb344..f032f828 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart @@ -8,7 +8,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaf /// Widget connected to the [DualCoinStatsCubit] that receives the state /// - [DualCoinStatsState] - updates and rebuilds the UI according to the -/// state's status - [CubitStatus] +/// state's status - [DashboardStatus] class DualCoinStatsCard extends StatelessWidget { /// Create a DualCoinStatsCard. @@ -29,12 +29,12 @@ class DualCoinStatsCard extends StatelessWidget { body: BlocBuilder( builder: (context, state) { return switch (state.status) { - CubitStatus.initial => const DualCoinStatsEmpty(), - CubitStatus.loading => const DualCoinStatsLoading(), - CubitStatus.failure => DualCoinStatsError( + DashboardStatus.initial => const DualCoinStatsEmpty(), + DashboardStatus.loading => const DualCoinStatsLoading(), + DashboardStatus.failure => DualCoinStatsError( error: state.error!, ), - CubitStatus.success => DualCoinStatsPopulated( + DashboardStatus.success => DualCoinStatsPopulated( tokens: state.data!, ), }; diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart index 0559c03c..1c473258 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart @@ -3,7 +3,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A widget associated with the [DualCoinStatsState] when it's status is -/// [CubitStatus.initial] that uses the [SyriusErrorWidget] to display a message +/// [DashboardStatus.initial] that uses the [SyriusErrorWidget] to display a message class DualCoinStatsEmpty extends StatelessWidget { /// Creates a DualCoinStatsEmpty const DualCoinStatsEmpty({super.key}); diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart index f904371f..a47f6b7a 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart @@ -3,7 +3,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; /// A widget associated with the [DualCoinStatsState] when it's status is -/// [CubitStatus.failure] that uses the [SyriusErrorWidget] to display the +/// [DashboardStatus.failure] that uses the [SyriusErrorWidget] to display the /// error message class DualCoinStatsError extends StatelessWidget { diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart index ff9cc512..c4e349c3 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart @@ -3,7 +3,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; /// A widget associated with the [DualCoinStatsState] when it's status is -/// [CubitStatus.loading] that uses the [SyriusLoadingWidget] to display a +/// [DashboardStatus.loading] that uses the [SyriusLoadingWidget] to display a /// loading indicator class DualCoinStatsLoading extends StatelessWidget { diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart index 35034ee5..856d68e0 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart @@ -3,7 +3,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// A widget associated with the [DualCoinStatsState] when it's status is -/// [CubitStatus.success] that displays the data provided using a chart +/// [DashboardStatus.success] that displays the data provided using a chart /// - [DualCoinStatsChart] - and a legend - [DualCoinStatsChartLegend] class DualCoinStatsPopulated extends StatefulWidget { diff --git a/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart b/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart index 8ab7cb7e..d8716e34 100644 --- a/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart +++ b/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart @@ -31,7 +31,7 @@ class PillarsState extends DashboardState { /// existing ones if none are provided. @override DashboardState copyWith({ - CubitStatus? status, + DashboardStatus? status, int? data, Object? error, }) { diff --git a/lib/rearchitecture/dashboard/pillars/view/pillars_card.dart b/lib/rearchitecture/dashboard/pillars/view/pillars_card.dart index 09b16465..01616d9c 100644 --- a/lib/rearchitecture/dashboard/pillars/view/pillars_card.dart +++ b/lib/rearchitecture/dashboard/pillars/view/pillars_card.dart @@ -7,7 +7,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaf /// Widget connected to the [PillarsCubit] that receives the state /// - [PillarsState] - updates and rebuilds the UI according to the -/// state's status - [CubitStatus] +/// state's status - [DashboardStatus] class PillarsCard extends StatelessWidget { /// Creates a PillarsCard const PillarsCard({super.key}); @@ -27,12 +27,12 @@ class PillarsCard extends StatelessWidget { body: BlocBuilder( builder: (context, state) { return switch (state.status) { - CubitStatus.initial => const PillarsEmpty(), - CubitStatus.loading => const PillarsLoading(), - CubitStatus.failure => PillarsError( + DashboardStatus.initial => const PillarsEmpty(), + DashboardStatus.loading => const PillarsLoading(), + DashboardStatus.failure => PillarsError( error: state.error!, ), - CubitStatus.success => PillarsPopulated( + DashboardStatus.success => PillarsPopulated( numberOfPillars: state.data!, ), }; diff --git a/lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart b/lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart index 4805f94a..05175f53 100644 --- a/lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart +++ b/lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart @@ -3,7 +3,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A widget associated with the [PillarsState] when it's status is -/// [CubitStatus.initial] that uses the [SyriusErrorWidget] to display a message +/// [DashboardStatus.initial] that uses the [SyriusErrorWidget] to display a message class PillarsEmpty extends StatelessWidget { /// Creates a PillarsEmpty instance const PillarsEmpty({super.key}); diff --git a/lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart b/lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart index 3a7af02a..71a906db 100644 --- a/lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart +++ b/lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart @@ -3,7 +3,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A widget associated with the [PillarsState] when it's status is -/// [CubitStatus.failure] that uses the [SyriusErrorWidget] to display the +/// [DashboardStatus.failure] that uses the [SyriusErrorWidget] to display the /// error message class PillarsError extends StatelessWidget { ///Creates a PillarsError object diff --git a/lib/rearchitecture/dashboard/pillars/widgets/pillars_loading.dart b/lib/rearchitecture/dashboard/pillars/widgets/pillars_loading.dart index d0ede481..46e1e9db 100644 --- a/lib/rearchitecture/dashboard/pillars/widgets/pillars_loading.dart +++ b/lib/rearchitecture/dashboard/pillars/widgets/pillars_loading.dart @@ -3,7 +3,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A widget associated with the [PillarsState] when it's status is -/// [CubitStatus.loading] that uses the [SyriusLoadingWidget] to display a +/// [DashboardStatus.loading] that uses the [SyriusLoadingWidget] to display a /// loading indicator class PillarsLoading extends StatelessWidget { /// Creates a PillarsLoading object diff --git a/lib/rearchitecture/dashboard/pillars/widgets/pillars_populated.dart b/lib/rearchitecture/dashboard/pillars/widgets/pillars_populated.dart index 78c8c922..09c5e74c 100644 --- a/lib/rearchitecture/dashboard/pillars/widgets/pillars_populated.dart +++ b/lib/rearchitecture/dashboard/pillars/widgets/pillars_populated.dart @@ -4,7 +4,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A widget associated with the [PillarsState] when it's status is -/// [CubitStatus.success] that displays the number of pillars +/// [DashboardStatus.success] that displays the number of pillars class PillarsPopulated extends StatelessWidget { /// Creates a PillarsPopulated object const PillarsPopulated({required this.numberOfPillars, super.key}); diff --git a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart index 2dfcdc70..6b35f4c4 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart @@ -30,7 +30,7 @@ class RealtimeStatisticsState extends DashboardState> { /// the existing ones if none are provided. @override DashboardState> copyWith({ - CubitStatus? status, + DashboardStatus? status, List? data, Object? error, }) { diff --git a/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart b/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart index d95e9319..a4f9f68b 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart @@ -23,12 +23,12 @@ class RealtimeStatisticsCard extends StatelessWidget { body: BlocBuilder( builder: (context, state) { return switch (state.status) { - CubitStatus.initial => const RealtimeStatisticsEmpty(), - CubitStatus.loading => const RealtimeStatisticsLoading(), - CubitStatus.failure => RealtimeStatisticsError( + DashboardStatus.initial => const RealtimeStatisticsEmpty(), + DashboardStatus.loading => const RealtimeStatisticsLoading(), + DashboardStatus.failure => RealtimeStatisticsError( error: state.error!, ), - CubitStatus.success => RealtimeStatisticsPopulated( + DashboardStatus.success => RealtimeStatisticsPopulated( accountBlocks: state.data!, ), }; diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart index 030c6186..abe43e2c 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart @@ -5,7 +5,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// A widget associated with the [RealtimeStatisticsState] when it's status is -/// [CubitStatus.success] +/// [DashboardStatus.success] /// /// Displays a chart highlighting the number of blocks in QSR and ZNN signed /// with a particular address in the last seven days diff --git a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart index 4f696d8a..06930f22 100644 --- a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart +++ b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart @@ -29,7 +29,7 @@ class SentinelsState extends DashboardState { /// existing ones if none are provided. @override DashboardState copyWith({ - CubitStatus? status, + DashboardStatus? status, SentinelInfoList? data, Object? error, }) { diff --git a/lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart b/lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart index c888cec2..93e4dd00 100644 --- a/lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart +++ b/lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart @@ -7,7 +7,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaf /// Widget connected to the [SentinelsCubit] that receives the state /// - [SentinelsState] - updates and rebuilds the UI according to the -/// state's status - [CubitStatus] +/// state's status - [DashboardStatus] class SentinelsCard extends StatelessWidget { /// Creates a SentinelsCard object. const SentinelsCard({super.key}); @@ -27,12 +27,12 @@ class SentinelsCard extends StatelessWidget { body: BlocBuilder( builder: (context, state) { return switch (state.status) { - CubitStatus.initial => const SentinelsEmpty(), - CubitStatus.loading => const SentinelsLoading(), - CubitStatus.failure => SentinelsError( + DashboardStatus.initial => const SentinelsEmpty(), + DashboardStatus.loading => const SentinelsLoading(), + DashboardStatus.failure => SentinelsError( error: state.error!, ), - CubitStatus.success => SentinelsPopulated( + DashboardStatus.success => SentinelsPopulated( sentinelInfoList: state.data!, ), }; diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart index db558e68..2de31451 100644 --- a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart +++ b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart @@ -3,7 +3,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [SentinelsState] when it's status is -/// [CubitStatus.initial] that uses the [SyriusErrorWidget] to display a message +/// [DashboardStatus.initial] that uses the [SyriusErrorWidget] to display a message class SentinelsEmpty extends StatelessWidget { /// Creates a SentinelsEmpty object const SentinelsEmpty({super.key}); diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart index 7186efe4..d3bfb027 100644 --- a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart +++ b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart @@ -3,7 +3,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [SentinelsState] when it's status is -/// [CubitStatus.error] that uses the [SyriusErrorWidget] to display an error. +/// [DashboardStatus.error] that uses the [SyriusErrorWidget] to display an error. class SentinelsError extends StatelessWidget { /// Creates a SentinelsError objects. const SentinelsError({required this.error, super.key}); diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_loading.dart b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_loading.dart index 711cd6ea..05e9ac3f 100644 --- a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_loading.dart +++ b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_loading.dart @@ -3,7 +3,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [SentinelsState] when it's status is -/// [CubitStatus.loading] that uses the [SyriusLoadingWidget] to display a +/// [DashboardStatus.loading] that uses the [SyriusLoadingWidget] to display a /// loading indicator. class SentinelsLoading extends StatelessWidget { /// Creates a SentinelsLoading object. diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart index fda97b26..c3c6f56a 100644 --- a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart +++ b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart @@ -5,7 +5,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// A widget associated with the [SentinelsState] when it's status is -/// [CubitStatus.success] that displays the current number of sentinels +/// [DashboardStatus.success] that displays the current number of sentinels class SentinelsPopulated extends StatelessWidget { const SentinelsPopulated({required this.sentinelInfoList, super.key}); diff --git a/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart b/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart index efe7a13f..6eb85dac 100644 --- a/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart +++ b/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart @@ -30,7 +30,7 @@ class StakingState extends DashboardState { /// existing ones if none are provided. @override DashboardState copyWith({ - CubitStatus? status, + DashboardStatus? status, StakeList? data, Object? error, }) { diff --git a/lib/rearchitecture/dashboard/staking/view/staking_card.dart b/lib/rearchitecture/dashboard/staking/view/staking_card.dart index d5960a3d..e0aac169 100644 --- a/lib/rearchitecture/dashboard/staking/view/staking_card.dart +++ b/lib/rearchitecture/dashboard/staking/view/staking_card.dart @@ -7,7 +7,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaf /// A widget connected to the [StakingCubit] that receives the state /// - [StakingState] - updates and rebuilds the UI according to the -/// state's status - [CubitStatus] +/// state's status - [DashboardStatus] class StakingCard extends StatelessWidget { /// Creates a StakingCard object. const StakingCard({super.key}); @@ -27,12 +27,12 @@ class StakingCard extends StatelessWidget { body: BlocBuilder( builder: (context, state) { return switch (state.status) { - CubitStatus.initial => const StakingEmpty(), - CubitStatus.loading => const StakingLoading(), - CubitStatus.failure => StakingError( + DashboardStatus.initial => const StakingEmpty(), + DashboardStatus.loading => const StakingLoading(), + DashboardStatus.failure => StakingError( error: state.error!, ), - CubitStatus.success => StakingPopulated( + DashboardStatus.success => StakingPopulated( stakingList: state.data!, ), }; diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart b/lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart index fc20a414..6b414ff5 100644 --- a/lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart +++ b/lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart @@ -3,7 +3,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [StakingState] when it's status is -/// [CubitStatus.initial] that uses the [SyriusErrorWidget] to display a message +/// [DashboardStatus.initial] that uses the [SyriusErrorWidget] to display a message class StakingEmpty extends StatelessWidget { const StakingEmpty({super.key}); diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart b/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart index 747165f7..bcd01e1d 100644 --- a/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart +++ b/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart @@ -3,7 +3,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; /// A widget associated with the [StakingState] when it's status is -/// [CubitStatus.error] that uses the [SyriusErrorWidget] to display the error. +/// [DashboardStatus.error] that uses the [SyriusErrorWidget] to display the error. class StakingError extends StatelessWidget { /// Creates a StakingError object. const StakingError({required this.error, super.key}); diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_loading.dart b/lib/rearchitecture/dashboard/staking/widgets/staking_loading.dart index d27b92b5..14bb555c 100644 --- a/lib/rearchitecture/dashboard/staking/widgets/staking_loading.dart +++ b/lib/rearchitecture/dashboard/staking/widgets/staking_loading.dart @@ -3,7 +3,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [StakingState] when it's status is -/// [CubitStatus.loading] that uses the [SyriusLoadingWidget] to display a +/// [DashboardStatus.loading] that uses the [SyriusLoadingWidget] to display a /// loading indicator. class StakingLoading extends StatelessWidget { /// Creates a StakingLoading object. diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart b/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart index 2ca394ba..6162747f 100644 --- a/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart +++ b/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart @@ -6,7 +6,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// A widget associated with the [StakingState] when it's status is -/// [CubitStatus.success] that displays the number of active staking entries +/// [DashboardStatus.success] that displays the number of active staking entries /// and the total staked amount class StakingPopulated extends StatelessWidget { /// Creates a StakingPopulated object diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart index aa58de42..c8535b70 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart @@ -30,7 +30,7 @@ class TotalHourlyTransactionsState extends DashboardState { /// values or the existing ones if none are provided. @override DashboardState copyWith({ - CubitStatus? status, + DashboardStatus? status, int? data, Object? error, }) { diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart index fb57f9a5..2a533914 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart @@ -7,7 +7,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaf /// A widget connected to the [TotalHourlyTransactionsCubit] that receives the /// state - [TotalHourlyTransactionsState] - updates and rebuilds the UI -/// according to the state's status - [CubitStatus] +/// according to the state's status - [DashboardStatus] class TotalHourlyTransactionsCard extends StatelessWidget { /// Creates a TotalHourlyTransactionsCard object. const TotalHourlyTransactionsCard({super.key}); @@ -28,12 +28,12 @@ class TotalHourlyTransactionsCard extends StatelessWidget { TotalHourlyTransactionsState>( builder: (context, state) { return switch (state.status) { - CubitStatus.initial => const TotalHourlyTransactionsEmpty(), - CubitStatus.loading => const TotalHourlyTransactionsLoading(), - CubitStatus.failure => TotalHourlyTransactionsError( + DashboardStatus.initial => const TotalHourlyTransactionsEmpty(), + DashboardStatus.loading => const TotalHourlyTransactionsLoading(), + DashboardStatus.failure => TotalHourlyTransactionsError( error: state.error!, ), - CubitStatus.success => TotalHourlyTransactionsPopulated( + DashboardStatus.success => TotalHourlyTransactionsPopulated( count: state.data!, ), }; diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart index b848e760..bfe3d1c5 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart @@ -3,7 +3,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [TotalHourlyTransactionsState] when it's -/// status is [CubitStatus.initial] that uses the [SyriusErrorWidget] to +/// status is [DashboardStatus.initial] that uses the [SyriusErrorWidget] to /// display a message class TotalHourlyTransactionsEmpty extends StatelessWidget { /// Creates a TotalHourlyTransactionsEmpty object. diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart index 3b326ee4..54cfb638 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart @@ -3,7 +3,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; /// A widget associated with the [TotalHourlyTransactionsState] when it's -/// status is [CubitStatus.failure] that uses the [SyriusErrorWidget] to +/// status is [DashboardStatus.failure] that uses the [SyriusErrorWidget] to /// display the error. class TotalHourlyTransactionsError extends StatelessWidget { /// Creates a TotalHourlyTransactionError object. diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart index b5c21621..cfa4dc37 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart @@ -3,7 +3,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; /// A widget associated with the [TotalHourlyTransactionsState] when it's -/// status is [CubitStatus.loading] that uses the [SyriusLoadingWidget] to +/// status is [DashboardStatus.loading] that uses the [SyriusLoadingWidget] to /// display a loading indicator. class TotalHourlyTransactionsLoading extends StatelessWidget { /// Creates a TotalHourlyTransactionsLoading object. diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart index efacde42..a0eb57c2 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart @@ -4,7 +4,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [TotalHourlyTransactionsState] when it's -/// status is [CubitStatus.success] that displays the number of transactions +/// status is [DashboardStatus.success] that displays the number of transactions /// confirmed in the last one hour class TotalHourlyTransactionsPopulated extends StatelessWidget { /// Creates a TotalHourlyTransactionsPopulated object. diff --git a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart index 89de45b8..ecc1cb39 100644 --- a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart +++ b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart @@ -14,7 +14,7 @@ part 'node_sync_status_state.dart'; /// /// [SyncState] is not related to [NodeSyncStatusState], doesn't handle UI updates /// -/// [NodeSyncStatusState] along with [CubitStatus] updates the UI of the +/// [NodeSyncStatusState] along with [DashboardStatus] updates the UI of the /// [NodeSyncStatusIcon] widget class NodeSyncStatusCubit extends DashboardCubit, NodeSyncStatusState> { diff --git a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart index c685efb6..6dfff0c9 100644 --- a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart +++ b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart @@ -12,7 +12,7 @@ class NodeSyncStatusState extends DashboardState> { @override DashboardState> copyWith({ - CubitStatus? status, + DashboardStatus? status, Pair? data, Object? error, }) { diff --git a/lib/rearchitecture/node_sync_status/view/node_sync_status_icon.dart b/lib/rearchitecture/node_sync_status/view/node_sync_status_icon.dart index 7281961a..82e79a6c 100644 --- a/lib/rearchitecture/node_sync_status/view/node_sync_status_icon.dart +++ b/lib/rearchitecture/node_sync_status/view/node_sync_status_icon.dart @@ -5,7 +5,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node /// A widget connected to the [NodeSyncStatusCubit] that receives the state /// - [NodeSyncStatusState] - updates and rebuilds the UI according to the -/// state's status - [CubitStatus] +/// state's status - [DashboardStatus] class NodeSyncStatusIcon extends StatelessWidget { const NodeSyncStatusIcon({super.key}); @@ -14,12 +14,12 @@ class NodeSyncStatusIcon extends StatelessWidget { return BlocBuilder( builder: (context, state) { return switch (state.status) { - CubitStatus.initial => const NodeSyncStatusEmpty(), - CubitStatus.failure => NodeSyncStatusError( + DashboardStatus.initial => const NodeSyncStatusEmpty(), + DashboardStatus.failure => NodeSyncStatusError( error: state.error!, ), - CubitStatus.loading => const NodeSyncStatusLoading(), - CubitStatus.success => NodeSyncPopulated(data: state.data!), + DashboardStatus.loading => const NodeSyncStatusLoading(), + DashboardStatus.success => NodeSyncPopulated(data: state.data!), }; }, ); diff --git a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_empty.dart b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_empty.dart index 8026a415..6f3d1aca 100644 --- a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_empty.dart +++ b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_empty.dart @@ -3,7 +3,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node_sync_status.dart'; /// A widget associated with the [NodeSyncStatusState] when it's status is -/// [CubitStatus.initial] that displays an icon with a tooltip message +/// [DashboardStatus.initial] that displays an icon with a tooltip message class NodeSyncStatusEmpty extends StatelessWidget { const NodeSyncStatusEmpty({super.key}); diff --git a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart index bbdbed79..3a24a0fa 100644 --- a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart +++ b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart @@ -4,7 +4,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; /// A widget associated with the [NodeSyncStatusState] when it's status is -/// [CubitStatus.failure] that displays an icon with a tooltip message +/// [DashboardStatus.failure] that displays an icon with a tooltip message class NodeSyncStatusError extends StatelessWidget { const NodeSyncStatusError({required this.error, super.key}); diff --git a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_loading.dart b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_loading.dart index 6d9bc32f..6de4166a 100644 --- a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_loading.dart +++ b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_loading.dart @@ -4,7 +4,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; /// A widget associated with the [NodeSyncStatusState] when it's status is -/// [CubitStatus.loading] that displays a loading indicator with a tooltip +/// [DashboardStatus.loading] that displays a loading indicator with a tooltip class NodeSyncStatusLoading extends StatelessWidget { const NodeSyncStatusLoading({super.key}); diff --git a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_populated.dart b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_populated.dart index 80a3a3a0..d91265d6 100644 --- a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_populated.dart +++ b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_populated.dart @@ -5,7 +5,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// A widget associated with the [NodeSyncStatusState] when it's status is -/// [CubitStatus.success] that returns a corresponding icon depending on the +/// [DashboardStatus.success] that returns a corresponding icon depending on the /// [SyncInfo] and [SyncState] data class NodeSyncPopulated extends StatelessWidget { const NodeSyncPopulated({required this.data, super.key}); diff --git a/test/delegation/cubit/delegation_cubit_test.dart b/test/delegation/cubit/delegation_cubit_test.dart index b4755e0c..54bfe8bc 100644 --- a/test/delegation/cubit/delegation_cubit_test.dart +++ b/test/delegation/cubit/delegation_cubit_test.dart @@ -54,7 +54,7 @@ void main() { }); test('initial status is correct', () { - expect(delegationCubit.state.status, CubitStatus.initial); + expect(delegationCubit.state.status, DashboardStatus.initial); }); group('fetchDataPeriodically', () { @@ -81,9 +81,9 @@ void main() { build: () => delegationCubit, act: (cubit) => cubit.fetchDataPeriodically(), expect: () => [ - DelegationState(status: CubitStatus.loading), + DelegationState(status: DashboardStatus.loading), DelegationState( - status: CubitStatus.failure, + status: DashboardStatus.failure, error: delegationException, ), ], @@ -95,9 +95,9 @@ void main() { build: () => delegationCubit, act: (cubit) => cubit.fetchDataPeriodically(), expect: () => [ - DelegationState(status: CubitStatus.loading), + DelegationState(status: DashboardStatus.loading), isA() - .having((state) => state.status, 'status', CubitStatus.success), + .having((state) => state.status, 'status', DashboardStatus.success), ], ); }); From 7c131cf92ad49d5d54a4c5d819f5b7e0aaf7350e Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Fri, 25 Oct 2024 12:42:02 +0300 Subject: [PATCH 042/102] chore: Improve documentation of the balance feature --- lib/rearchitecture/dashboard/balance/balance.dart | 2 +- .../dashboard/balance/widgets/balance_address.dart | 4 +++- .../dashboard/balance/widgets/balance_chart.dart | 13 +++++++------ .../balance/widgets/balance_chart_legend.dart | 4 ++-- .../dashboard/balance/widgets/balance_empty.dart | 8 +++++--- .../dashboard/balance/widgets/balance_error.dart | 5 +++-- .../dashboard/balance/widgets/balance_loading.dart | 11 +++++++---- .../balance/widgets/balance_populated.dart | 9 +++++---- .../dashboard/balance/widgets/widgets.dart | 2 +- 9 files changed, 34 insertions(+), 24 deletions(-) diff --git a/lib/rearchitecture/dashboard/balance/balance.dart b/lib/rearchitecture/dashboard/balance/balance.dart index aa75b9f8..0ae87fa7 100644 --- a/lib/rearchitecture/dashboard/balance/balance.dart +++ b/lib/rearchitecture/dashboard/balance/balance.dart @@ -1,3 +1,3 @@ export 'cubit/balance_cubit.dart'; export 'view/balance_card.dart'; -export 'widgets/widgets.dart'; \ No newline at end of file +export 'widgets/widgets.dart'; diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_address.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_address.dart index cb5f2ff2..8a997419 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_address.dart +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_address.dart @@ -10,13 +10,15 @@ import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; /// and changes the value of the [edgesColorNotifier] class BalanceAddress extends StatelessWidget { - + /// Creates a BalanceAddress object. const BalanceAddress({ required this.address, required this.edgesColorNotifier, super.key, }); + /// The address that will be displayed final String address; + /// A notifier used to rebuild the widget final ValueNotifier edgesColorNotifier; @override diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_chart.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_chart.dart index ac55612b..bf2ca0e0 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_chart.dart +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_chart.dart @@ -9,23 +9,24 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// /// Hovering over the sections of the chart will trigger the balance - in a /// readable format - to appear in the center of the chart - class BalanceChart extends StatelessWidget { - + /// Creates a BalanceChart objects const BalanceChart({ required this.accountInfo, - required this.touchedSectionId, + required this.hoveredSectionId, super.key, }); + /// Data needed for the chart final AccountInfo accountInfo; - final ValueNotifier touchedSectionId; + /// Notifier that holds id of the hovered chart section + final ValueNotifier hoveredSectionId; @override Widget build(BuildContext context) { return StandardPieChart( sections: _getChartSection(accountInfo), onChartSectionTouched: (pieChartSection) { - touchedSectionId.value = pieChartSection?.touchedSection?.title; + hoveredSectionId.value = pieChartSection?.touchedSection?.title; }, ); } @@ -57,7 +58,7 @@ class BalanceChart extends StatelessWidget { AccountInfo accountInfo, ) { final isTouched = - token.tokenStandard.toString() == touchedSectionId.value; + token.tokenStandard.toString() == hoveredSectionId.value; final opacity = isTouched ? 1.0 : 0.7; final value = accountInfo.getBalance(token.tokenStandard) / diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_chart_legend.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_chart_legend.dart index 81cd0e52..86d644d3 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_chart_legend.dart +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_chart_legend.dart @@ -7,10 +7,10 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// Adds a legend to the [BalanceChart] consisting of widgets with a tooltip /// than will show the exact balance - including decimals - available in a /// certain coin (QSR or ZNN) - class BalanceChartLegend extends StatelessWidget { - + /// Creates a BalanceChartLegend object. const BalanceChartLegend({required this.accountInfo, super.key}); + /// Data used for the legend final AccountInfo accountInfo; @override diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart index 507a3593..eae47a5c 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart @@ -1,12 +1,14 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/balance/balance.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; -/// A `BalanceEmpty` widget that displays a simple message indicating that there +/// A [BalanceEmpty] widget that displays a simple message indicating that there /// is no balance data available. /// -/// This widget is displayed when the `BalanceCubit` is in its initial state, meaning -/// no data has been loaded yet or the balance data is empty. +/// This widget is displayed when the [BalanceCubit] is in its initial state, +/// meaning no data has been loaded yet or the balance data is empty. class BalanceEmpty extends StatelessWidget { + /// Creates a BalanceEmpty objects. const BalanceEmpty({super.key}); @override diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_error.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_error.dart index 478e10fb..fc559fd3 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_error.dart +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_error.dart @@ -1,14 +1,15 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -/// A `BalanceError` widget that displays an error message when the balance +/// A [BalanceError] widget that displays an error message when the balance /// data fetching fails. /// /// This widget is displayed when the `BalanceCubit` encounters an error /// while trying to load the balance data. class BalanceError extends StatelessWidget { - + /// Creates a BalanceError object. const BalanceError({required this.error, super.key}); + /// The object used to display an error message. final Object error; @override diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_loading.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_loading.dart index 80e26e3e..84239dc9 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_loading.dart +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_loading.dart @@ -1,12 +1,15 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -/// A `BalanceLoading` widget that displays a loading message while the balance -/// data is being fetched. +/// A widget that displays a loading message while the balance data is being +/// fetched. /// -/// This widget is shown when the `BalanceCubit` is in the `loading` state, -/// indicating that the balance data is currently being loaded. +/// This widget is shown when the [BalanceCubit] sends a [BalanceState] update +/// with a status of [DashboardStatus.loading], indicating that the balance +/// data is currently being loaded. class BalanceLoading extends StatelessWidget { + /// Creates a BalanceLoading object. const BalanceLoading({super.key}); @override diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_populated.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_populated.dart index 460e6674..fa10f093 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_populated.dart +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_populated.dart @@ -10,7 +10,7 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// This widget is displayed when the `BalanceCubit` is in the `success` state, /// and the balance data is available for rendering. class BalancePopulated extends StatefulWidget { - + /// Creates a BalancePopulated object. const BalancePopulated({ required this.address, required this.accountInfo, @@ -18,8 +18,9 @@ class BalancePopulated extends StatefulWidget { }); /// The balance data that has been successfully fetched. /// - /// The data is a map where the key is a string (representing the account address), - /// and the value is an `AccountInfo` object containing the balance details. + /// The data is a map where the key is a string (representing the account + /// address), and the value is an `AccountInfo` object containing the balance + /// details. final AccountInfo accountInfo; /// The address for which the [accountInfo] was retrieved. @@ -54,7 +55,7 @@ class _BalancePopulatedState extends State { children: [ BalanceChart( accountInfo: widget.accountInfo, - touchedSectionId: _touchedSectionId, + hoveredSectionId: _touchedSectionId, ), ValueListenableBuilder( valueListenable: _touchedSectionId, diff --git a/lib/rearchitecture/dashboard/balance/widgets/widgets.dart b/lib/rearchitecture/dashboard/balance/widgets/widgets.dart index 687296c4..4d81c39e 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/widgets.dart +++ b/lib/rearchitecture/dashboard/balance/widgets/widgets.dart @@ -4,4 +4,4 @@ export 'balance_chart_legend.dart'; export 'balance_empty.dart'; export 'balance_error.dart'; export 'balance_loading.dart'; -export 'balance_populated.dart'; \ No newline at end of file +export 'balance_populated.dart'; From a9482eeb31824dc6193be30e61bf47ded6a33dcb Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Fri, 25 Oct 2024 14:24:35 +0300 Subject: [PATCH 043/102] chore: Improve documentation and solve linter issues --- .../delegation/cubit/delegation_cubit.dart | 46 ++++++++----------- .../delegation/cubit/delegation_state.dart | 17 ++++--- .../dashboard/delegation/delegation.dart | 3 +- .../delegation/exceptions/exceptions.dart | 1 + .../no_delegation_stats_exception.dart | 5 ++ .../delegation/view/delegation_card.dart | 8 ++-- .../delegation/widgets/delegation_empty.dart | 4 +- .../delegation/widgets/delegation_error.dart | 4 +- .../widgets/delegation_loading.dart | 2 + .../widgets/delegation_populated.dart | 18 +++++--- .../dashboard/delegation/widgets/widgets.dart | 2 +- .../widgets/dual_coin_stats_chart_legend.dart | 3 +- .../widgets/dual_coin_stats_empty.dart | 3 +- .../dashboard/pillars/pillars.dart | 2 +- .../pillars/widgets/pillars_empty.dart | 3 +- .../pillars/widgets/pillars_loading.dart | 2 +- .../dashboard/pillars/widgets/widgets.dart | 2 +- .../realtime_statistics.dart | 2 +- .../view/realtime_statistics_card.dart | 4 ++ .../widgets/realtime_statistics_empty.dart | 2 + .../widgets/realtime_statistics_error.dart | 4 +- .../widgets/realtime_statistics_loading.dart | 4 +- .../realtime_statistics_populated.dart | 3 +- .../widgets/realtime_txs_chart.dart | 3 +- .../realtime_statistics/widgets/widgets.dart | 2 +- .../dashboard/sentinels/sentinels.dart | 2 +- .../sentinels/widgets/sentinels_empty.dart | 3 +- .../sentinels/widgets/sentinels_error.dart | 4 +- .../widgets/sentinels_populated.dart | 5 +- .../dashboard/sentinels/widgets/widgets.dart | 2 +- .../staking/widgets/staking_empty.dart | 4 +- .../staking/widgets/staking_error.dart | 4 +- .../staking/widgets/staking_populated.dart | 2 +- .../total_hourly_transactions_state.dart | 2 - .../total_hourly_transactions_error.dart | 1 + .../total_hourly_transactions_populated.dart | 2 +- .../transfer/view/transfer_card.dart | 2 +- .../cubit/node_sync_status_cubit.dart | 4 +- .../cubit/node_sync_status_state.dart | 2 +- .../view/node_sync_status_icon.dart | 1 + .../widgets/node_sync_status_empty.dart | 1 + .../widgets/node_sync_status_error.dart | 3 +- .../widgets/node_sync_status_loading.dart | 1 + .../widgets/node_sync_status_populated.dart | 3 +- 44 files changed, 118 insertions(+), 79 deletions(-) create mode 100644 lib/rearchitecture/dashboard/delegation/exceptions/exceptions.dart create mode 100644 lib/rearchitecture/dashboard/delegation/exceptions/no_delegation_stats_exception.dart diff --git a/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart b/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart index a6925f17..364ccc99 100644 --- a/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart +++ b/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart @@ -3,44 +3,36 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'delegation_state.dart'; -/// `DelegationCubit` manages the fetching and state of delegation information +/// A cubit that manages the fetching and state of delegation information /// for a specific account. -/// -/// This cubit extends `DashboardCubit`, using the `DelegationInfo` data type -/// to store and manage delegation stats for the account identified by `kDemoAddress`. class DelegationCubit extends DashboardCubit { - /// Constructs a `DelegationCubit`, passing the `zenon` client and the initial state - /// to the parent class. + /// Constructs a DelegationCubit object, passing the [zenon] client and the + /// initial state to the parent class. /// - /// The `zenon` client is used to interact with the Zenon network to retrieve delegation information. + /// The [zenon] client is used to interact with the Zenon network to retrieve + /// delegation information. DelegationCubit(this.address, super.zenon, super.initialState); - + /// The address for which the [DelegationInfo] will be fetched final Address address; - /// Fetches the delegation information for the account identified by its address. + /// Fetches the delegation information for the account identified by its + /// address. /// - /// This method retrieves delegation stats using the Zenon SDK's `getDelegatedPillar()` method. + /// This method retrieves delegation stats /// It checks if the delegation information is available: - /// - If available, it returns the `DelegationInfo`. - /// - If not available, it throws an error indicating that no delegation stats are available. - /// - /// Throws: - /// - An error if the delegation information is unavailable or any exception occurs during data fetching. + /// - If available, it returns the [DelegationInfo]. + /// - If not available, it throws an exception @override Future fetch() async { - try { - final delegationInfo = await zenon.embedded.pillar.getDelegatedPillar( - address, - ); + final delegationInfo = await zenon.embedded.pillar.getDelegatedPillar( + address, + ); - // Check if delegation information is available - if (delegationInfo != null) { - return delegationInfo; - } else { - throw 'No delegation stats available'; - } - } catch (e) { - rethrow; + // Check if delegation information is available + if (delegationInfo != null) { + return delegationInfo; + } else { + throw NoDelegationStatsException(); } } } diff --git a/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart b/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart index 8802e59b..ec90cda0 100644 --- a/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart +++ b/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart @@ -1,13 +1,14 @@ part of 'delegation_cubit.dart'; -/// The state class for the `DelegationCubit`, extending `DashboardState` and managing delegation information. +/// The state class for the [DelegationCubit]. /// -/// `DelegationState` holds a `DelegationInfo` object that represents the current delegation details. -/// This state is used by the `DelegationCubit` to manage and track delegation-related data. +/// It holds a [DelegationInfo] object that represents the retrieved delegation +/// details. class DelegationState extends DashboardState { - /// Constructs a new `DelegationState`. + /// Constructs a new DelegationState object. /// - /// This state is initialized with default `status`, `data`, and `error` values from the parent `DashboardState` class. + /// This state is initialized with default [status], [data], and [error] + /// values from the parent class. /// It manages delegation information for an account. const DelegationState({ super.status, @@ -15,13 +16,11 @@ class DelegationState extends DashboardState { super.error, }); - /// Creates a copy of the current `DelegationState` with optional new values for `status`, `data`, and `error`. + /// Creates a copy of the current [DelegationState] with optional new values + /// for [status], [data], and [error]. /// /// This method is used to create a new state with updated fields if provided, /// otherwise retaining the existing values. - /// - /// Returns: - /// - A new instance of `DelegationState` with the updated values or the existing ones if none are provided. @override DashboardState copyWith({ DashboardStatus? status, diff --git a/lib/rearchitecture/dashboard/delegation/delegation.dart b/lib/rearchitecture/dashboard/delegation/delegation.dart index 39ba6686..f26173df 100644 --- a/lib/rearchitecture/dashboard/delegation/delegation.dart +++ b/lib/rearchitecture/dashboard/delegation/delegation.dart @@ -1,3 +1,4 @@ export 'cubit/delegation_cubit.dart'; +export 'exceptions/exceptions.dart'; export 'view/delegation_card.dart'; -export 'widgets/widgets.dart'; \ No newline at end of file +export 'widgets/widgets.dart'; diff --git a/lib/rearchitecture/dashboard/delegation/exceptions/exceptions.dart b/lib/rearchitecture/dashboard/delegation/exceptions/exceptions.dart new file mode 100644 index 00000000..7cb12e34 --- /dev/null +++ b/lib/rearchitecture/dashboard/delegation/exceptions/exceptions.dart @@ -0,0 +1 @@ +export 'no_delegation_stats_exception.dart'; diff --git a/lib/rearchitecture/dashboard/delegation/exceptions/no_delegation_stats_exception.dart b/lib/rearchitecture/dashboard/delegation/exceptions/no_delegation_stats_exception.dart new file mode 100644 index 00000000..419a6a4f --- /dev/null +++ b/lib/rearchitecture/dashboard/delegation/exceptions/no_delegation_stats_exception.dart @@ -0,0 +1,5 @@ +/// Custom [Exception] used when there are no delegation info available +class NoDelegationStatsException implements Exception { + @override + String toString() => 'No delegation stats available'; +} diff --git a/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart b/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart index 2b508fb4..c12d70ef 100644 --- a/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart +++ b/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart @@ -7,7 +7,10 @@ import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; +/// A card that receives [DelegationState] updates from the [DelegationCubit] +/// and changes the UI according to the request status - [DashboardStatus] class DelegationCard extends StatelessWidget { + /// Creates a DelegationCard object. const DelegationCard({super.key}); @override @@ -18,8 +21,7 @@ class DelegationCard extends StatelessWidget { Address.parse(kSelectedAddress!), zenon!, const DelegationState(), - ); - cubit.fetchDataPeriodically(); + )..fetchDataPeriodically(); return cubit; }, child: CardScaffoldWithoutListener( @@ -33,7 +35,7 @@ class DelegationCard extends StatelessWidget { error: state.error!, ), DashboardStatus.success => DelegationPopulated( - data: state.data!, + delegationInfo: state.data!, ), }; }, diff --git a/lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart b/lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart index b6a509cd..fd355529 100644 --- a/lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart +++ b/lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart @@ -1,11 +1,13 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; +/// A widget that displays a hardcoded error message class DelegationEmpty extends StatelessWidget { + /// Creates a DelegationEmpty object. const DelegationEmpty({super.key}); @override Widget build(BuildContext context) { return const SyriusErrorWidget('No data available'); } -} \ No newline at end of file +} diff --git a/lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart b/lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart index fc73e34e..08cff849 100644 --- a/lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart +++ b/lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart @@ -1,9 +1,11 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; +/// A widget that display the [error] message class DelegationError extends StatelessWidget { - + /// Creates a DelegationError object. const DelegationError({required this.error, super.key}); + /// The object that holds the representation of the error final Object error; @override diff --git a/lib/rearchitecture/dashboard/delegation/widgets/delegation_loading.dart b/lib/rearchitecture/dashboard/delegation/widgets/delegation_loading.dart index fc4d21d4..d85318e2 100644 --- a/lib/rearchitecture/dashboard/delegation/widgets/delegation_loading.dart +++ b/lib/rearchitecture/dashboard/delegation/widgets/delegation_loading.dart @@ -1,7 +1,9 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +/// A widget that displays the apps loading indicator class DelegationLoading extends StatelessWidget { + /// Creates a DelegationLoading object. const DelegationLoading({super.key}); @override diff --git a/lib/rearchitecture/dashboard/delegation/widgets/delegation_populated.dart b/lib/rearchitecture/dashboard/delegation/widgets/delegation_populated.dart index 6f61d048..28c431c7 100644 --- a/lib/rearchitecture/dashboard/delegation/widgets/delegation_populated.dart +++ b/lib/rearchitecture/dashboard/delegation/widgets/delegation_populated.dart @@ -3,13 +3,19 @@ import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; +/// A widget that displays the delegation amount and to which pillar the amount +/// was delegated to. class DelegationPopulated extends StatelessWidget { - - const DelegationPopulated({required this.data, super.key}); - final DelegationInfo data; + /// Creates a DelegationPopulated object. + const DelegationPopulated({required this.delegationInfo, super.key}); + /// Field that holds the needed details + final DelegationInfo delegationInfo; @override Widget build(BuildContext context) { + final String pillarName = delegationInfo.name; + final BigInt weight = delegationInfo.weight; + return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -20,7 +26,7 @@ class DelegationPopulated extends StatelessWidget { decoration: BoxDecoration( shape: BoxShape.circle, border: Border.all( - color: data.status == 1 + color: delegationInfo.status == 1 ? AppColors.znnColor : AppColors.errorColor, ), @@ -37,11 +43,11 @@ class DelegationPopulated extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - data.name, + pillarName, style: Theme.of(context).textTheme.bodyMedium, ), Text( - '${data.weight.addDecimals(coinDecimals)} ${kZnnCoin.symbol}', + '${weight.addDecimals(coinDecimals)} ${kZnnCoin.symbol}', style: Theme.of(context).textTheme.titleMedium, ), ], diff --git a/lib/rearchitecture/dashboard/delegation/widgets/widgets.dart b/lib/rearchitecture/dashboard/delegation/widgets/widgets.dart index f7196852..6a53cbde 100644 --- a/lib/rearchitecture/dashboard/delegation/widgets/widgets.dart +++ b/lib/rearchitecture/dashboard/delegation/widgets/widgets.dart @@ -1,4 +1,4 @@ export 'delegation_empty.dart'; export 'delegation_error.dart'; export 'delegation_loading.dart'; -export 'delegation_populated.dart'; \ No newline at end of file +export 'delegation_populated.dart'; diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart index f7dc3e0b..82c4dbd1 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart @@ -6,14 +6,13 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// /// It shows the token symbol, the amount in a shortened format - it has a /// tooltip for showing the exact amount, including the decimals - class DualCoinStatsChartLegend extends StatelessWidget { - /// Creates a DualCoinStatsLegend const DualCoinStatsChartLegend({ required this.tokens, super.key, }); + /// Data used final List tokens; @override diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart index 1c473258..f7a444b2 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart @@ -3,7 +3,8 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A widget associated with the [DualCoinStatsState] when it's status is -/// [DashboardStatus.initial] that uses the [SyriusErrorWidget] to display a message +/// [DashboardStatus.initial] that uses the [SyriusErrorWidget] to display a +/// message class DualCoinStatsEmpty extends StatelessWidget { /// Creates a DualCoinStatsEmpty const DualCoinStatsEmpty({super.key}); diff --git a/lib/rearchitecture/dashboard/pillars/pillars.dart b/lib/rearchitecture/dashboard/pillars/pillars.dart index cd3b579a..fcf6c70f 100644 --- a/lib/rearchitecture/dashboard/pillars/pillars.dart +++ b/lib/rearchitecture/dashboard/pillars/pillars.dart @@ -1,3 +1,3 @@ export 'cubit/pillars_cubit.dart'; export 'view/pillars_card.dart'; -export 'widgets/widgets.dart'; \ No newline at end of file +export 'widgets/widgets.dart'; diff --git a/lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart b/lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart index 05175f53..83306b61 100644 --- a/lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart +++ b/lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart @@ -3,7 +3,8 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A widget associated with the [PillarsState] when it's status is -/// [DashboardStatus.initial] that uses the [SyriusErrorWidget] to display a message +/// [DashboardStatus.initial] that uses the [SyriusErrorWidget] to display a +/// message class PillarsEmpty extends StatelessWidget { /// Creates a PillarsEmpty instance const PillarsEmpty({super.key}); diff --git a/lib/rearchitecture/dashboard/pillars/widgets/pillars_loading.dart b/lib/rearchitecture/dashboard/pillars/widgets/pillars_loading.dart index 46e1e9db..04db1421 100644 --- a/lib/rearchitecture/dashboard/pillars/widgets/pillars_loading.dart +++ b/lib/rearchitecture/dashboard/pillars/widgets/pillars_loading.dart @@ -13,4 +13,4 @@ class PillarsLoading extends StatelessWidget { Widget build(BuildContext context) { return const SyriusLoadingWidget(); } -} \ No newline at end of file +} diff --git a/lib/rearchitecture/dashboard/pillars/widgets/widgets.dart b/lib/rearchitecture/dashboard/pillars/widgets/widgets.dart index 0b0d5e3a..58cf2d1c 100644 --- a/lib/rearchitecture/dashboard/pillars/widgets/widgets.dart +++ b/lib/rearchitecture/dashboard/pillars/widgets/widgets.dart @@ -1,4 +1,4 @@ export 'pillars_empty.dart'; export 'pillars_error.dart'; export 'pillars_loading.dart'; -export 'pillars_populated.dart'; \ No newline at end of file +export 'pillars_populated.dart'; diff --git a/lib/rearchitecture/dashboard/realtime_statistics/realtime_statistics.dart b/lib/rearchitecture/dashboard/realtime_statistics/realtime_statistics.dart index 02ab7917..8dc61e43 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/realtime_statistics.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/realtime_statistics.dart @@ -1,3 +1,3 @@ export 'cubit/realtime_statistics_cubit.dart'; export 'view/realtime_statistics_card.dart'; -export 'widgets/widgets.dart'; \ No newline at end of file +export 'widgets/widgets.dart'; diff --git a/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart b/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart index a4f9f68b..605605f8 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart @@ -5,7 +5,11 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/utils/card/card.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart'; +/// A card that receives [RealtimeStatisticsState] updates from the +/// [RealtimeStatisticsCubit] and changes the UI according to the request +/// status - [DashboardStatus] class RealtimeStatisticsCard extends StatelessWidget { + /// Creates a RealtimeStatisticsCard object. const RealtimeStatisticsCard({super.key}); @override diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_empty.dart b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_empty.dart index bb2fe790..06ff5816 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_empty.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_empty.dart @@ -1,7 +1,9 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; +/// A widget that displays a hardcoded error message class RealtimeStatisticsEmpty extends StatelessWidget { + /// Creates a RealtimeStatisticsEmpty object. const RealtimeStatisticsEmpty({super.key}); @override diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart index c0bbb54e..f5c44121 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart @@ -1,9 +1,11 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; +/// A widget that displays an error message class RealtimeStatisticsError extends StatelessWidget { - + /// Creates a RealtimeStatisticsError object const RealtimeStatisticsError({required this.error, super.key}); + /// The data that holds the message that will be displayed final Object error; @override diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_loading.dart b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_loading.dart index a79724bb..3ef323d9 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_loading.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_loading.dart @@ -1,11 +1,13 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; +/// A widget that displays a loading indicator class RealtimeStatisticsLoading extends StatelessWidget { + /// Creates a RealtimeStatisticsLoading object. const RealtimeStatisticsLoading({super.key}); @override Widget build(BuildContext context) { return const SyriusLoadingWidget(); } -} \ No newline at end of file +} diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart index abe43e2c..c464a302 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart @@ -10,8 +10,9 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// Displays a chart highlighting the number of blocks in QSR and ZNN signed /// with a particular address in the last seven days class RealtimeStatisticsPopulated extends StatelessWidget { + /// Creates a RealtimeStatisticsPopulated object. const RealtimeStatisticsPopulated({required this.accountBlocks, super.key}); - + /// List of account blocks containing the ZNN and QSR transactions final List accountBlocks; @override diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_txs_chart.dart b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_txs_chart.dart index e8a0e8dc..3ad0caaa 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_txs_chart.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_txs_chart.dart @@ -10,11 +10,12 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// Shows a chart based on the provided [transactions] class RealtimeTxsChart extends StatefulWidget { - + /// Creates a RealtimeTxsChart object. const RealtimeTxsChart( this.transactions, { super.key, }); + /// The data needed to generate the chart final List transactions; @override diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/widgets.dart b/lib/rearchitecture/dashboard/realtime_statistics/widgets/widgets.dart index 3e2d66a8..ed96407e 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/widgets/widgets.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/widgets/widgets.dart @@ -1,4 +1,4 @@ export 'realtime_statistics_empty.dart'; export 'realtime_statistics_error.dart'; export 'realtime_statistics_loading.dart'; -export 'realtime_statistics_populated.dart'; \ No newline at end of file +export 'realtime_statistics_populated.dart'; diff --git a/lib/rearchitecture/dashboard/sentinels/sentinels.dart b/lib/rearchitecture/dashboard/sentinels/sentinels.dart index ed5c0c5f..3651698d 100644 --- a/lib/rearchitecture/dashboard/sentinels/sentinels.dart +++ b/lib/rearchitecture/dashboard/sentinels/sentinels.dart @@ -1,3 +1,3 @@ export 'cubit/sentinels_cubit.dart'; export 'view/sentinels_card.dart'; -export 'widgets/widgets.dart'; \ No newline at end of file +export 'widgets/widgets.dart'; diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart index 2de31451..4d432c02 100644 --- a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart +++ b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart @@ -3,7 +3,8 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [SentinelsState] when it's status is -/// [DashboardStatus.initial] that uses the [SyriusErrorWidget] to display a message +/// [DashboardStatus.initial] that uses the [SyriusErrorWidget] to display a +/// message class SentinelsEmpty extends StatelessWidget { /// Creates a SentinelsEmpty object const SentinelsEmpty({super.key}); diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart index d3bfb027..bad085c3 100644 --- a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart +++ b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart @@ -3,10 +3,12 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [SentinelsState] when it's status is -/// [DashboardStatus.error] that uses the [SyriusErrorWidget] to display an error. +/// [DashboardStatus.failure] that uses the [SyriusErrorWidget] to display an +/// error. class SentinelsError extends StatelessWidget { /// Creates a SentinelsError objects. const SentinelsError({required this.error, super.key}); + /// The object that holds the representation of the error final Object error; @override diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart index c3c6f56a..4a44757b 100644 --- a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart +++ b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart @@ -7,8 +7,9 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// A widget associated with the [SentinelsState] when it's status is /// [DashboardStatus.success] that displays the current number of sentinels class SentinelsPopulated extends StatelessWidget { - + /// Creates a SentinelsPopulated object. const SentinelsPopulated({required this.sentinelInfoList, super.key}); + /// The data needed to display the current number of sentinels final SentinelInfoList sentinelInfoList; @override @@ -41,4 +42,4 @@ class SentinelsPopulated extends StatelessWidget { ], ); } -} \ No newline at end of file +} diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/widgets.dart b/lib/rearchitecture/dashboard/sentinels/widgets/widgets.dart index 080d8cb5..7a94c0ca 100644 --- a/lib/rearchitecture/dashboard/sentinels/widgets/widgets.dart +++ b/lib/rearchitecture/dashboard/sentinels/widgets/widgets.dart @@ -1,4 +1,4 @@ export 'sentinels_empty.dart'; export 'sentinels_error.dart'; export 'sentinels_loading.dart'; -export 'sentinels_populated.dart'; \ No newline at end of file +export 'sentinels_populated.dart'; diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart b/lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart index 6b414ff5..63eaa5a7 100644 --- a/lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart +++ b/lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart @@ -3,8 +3,10 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [StakingState] when it's status is -/// [DashboardStatus.initial] that uses the [SyriusErrorWidget] to display a message +/// [DashboardStatus.initial] that uses the [SyriusErrorWidget] to display a +/// message class StakingEmpty extends StatelessWidget { + /// Creates a StakingEmpty object. const StakingEmpty({super.key}); @override diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart b/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart index bcd01e1d..2f024ce1 100644 --- a/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart +++ b/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart @@ -3,10 +3,12 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.d import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; /// A widget associated with the [StakingState] when it's status is -/// [DashboardStatus.error] that uses the [SyriusErrorWidget] to display the error. +/// [DashboardStatus.failure] that uses the [SyriusErrorWidget] to display the +/// error. class StakingError extends StatelessWidget { /// Creates a StakingError object. const StakingError({required this.error, super.key}); + /// Error containing the message that will be displayed. final Object error; @override diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart b/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart index 6162747f..68db0801 100644 --- a/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart +++ b/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart @@ -11,7 +11,7 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class StakingPopulated extends StatelessWidget { /// Creates a StakingPopulated object const StakingPopulated({required this.stakingList, super.key}); - + /// Field containing the data that will be displayed final StakeList stakingList; @override diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart index c8535b70..5e336d64 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart @@ -41,5 +41,3 @@ class TotalHourlyTransactionsState extends DashboardState { ); } } - - diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart index 54cfb638..aafb2343 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart @@ -8,6 +8,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widge class TotalHourlyTransactionsError extends StatelessWidget { /// Creates a TotalHourlyTransactionError object. const TotalHourlyTransactionsError({required this.error, super.key}); + /// Error containing the message that will be displayed. final Object error; @override diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart index a0eb57c2..13aa32f7 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart @@ -9,6 +9,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class TotalHourlyTransactionsPopulated extends StatelessWidget { /// Creates a TotalHourlyTransactionsPopulated object. const TotalHourlyTransactionsPopulated({required this.count, super.key}); + /// The number of confirmed transactions in the last one hour final int count; @override @@ -27,6 +28,5 @@ class TotalHourlyTransactionsPopulated extends StatelessWidget { const Text('transactions in the last hour'), ], ); - } } diff --git a/lib/rearchitecture/dashboard/transfer/view/transfer_card.dart b/lib/rearchitecture/dashboard/transfer/view/transfer_card.dart index 9f8c7e2b..63f51a36 100644 --- a/lib/rearchitecture/dashboard/transfer/view/transfer_card.dart +++ b/lib/rearchitecture/dashboard/transfer/view/transfer_card.dart @@ -11,7 +11,7 @@ class TransferCard extends StatefulWidget { super.key, this.changePage, }); - + /// Function that triggers the redirect to the Transfer tab final Function( Tabs, { bool redirectWithSendContainerLarge, diff --git a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart index ecc1cb39..d18efcde 100644 --- a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart +++ b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart @@ -12,12 +12,14 @@ part 'node_sync_status_state.dart'; /// Cubit responsible for fetching the sync state - [SyncState] - and sending /// the states update - [NodeSyncStatusState] - back to the widget /// -/// [SyncState] is not related to [NodeSyncStatusState], doesn't handle UI updates +/// [SyncState] is not related to [NodeSyncStatusState], doesn't handle UI +/// updates. /// /// [NodeSyncStatusState] along with [DashboardStatus] updates the UI of the /// [NodeSyncStatusIcon] widget class NodeSyncStatusCubit extends DashboardCubit, NodeSyncStatusState> { + /// Creates a NodeSyncStatusCubit using the super-initializer parameters NodeSyncStatusCubit(super.zenon, super.initialState); SyncState _lastSyncState = SyncState.unknown; diff --git a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart index 6dfff0c9..4a4f6b16 100644 --- a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart +++ b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart @@ -3,7 +3,7 @@ part of 'node_sync_status_cubit.dart'; /// Class used by [NodeSyncStatusCubit] to send state updates to the /// connected view class NodeSyncStatusState extends DashboardState> { - + /// Creates a NodeSyncStatusState object. const NodeSyncStatusState({ super.status, super.data, diff --git a/lib/rearchitecture/node_sync_status/view/node_sync_status_icon.dart b/lib/rearchitecture/node_sync_status/view/node_sync_status_icon.dart index 82e79a6c..8515eb3c 100644 --- a/lib/rearchitecture/node_sync_status/view/node_sync_status_icon.dart +++ b/lib/rearchitecture/node_sync_status/view/node_sync_status_icon.dart @@ -7,6 +7,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node /// - [NodeSyncStatusState] - updates and rebuilds the UI according to the /// state's status - [DashboardStatus] class NodeSyncStatusIcon extends StatelessWidget { + /// Creates a NodeSyncStatusIcon object. const NodeSyncStatusIcon({super.key}); @override diff --git a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_empty.dart b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_empty.dart index 6f3d1aca..09180dc8 100644 --- a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_empty.dart +++ b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_empty.dart @@ -5,6 +5,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node /// A widget associated with the [NodeSyncStatusState] when it's status is /// [DashboardStatus.initial] that displays an icon with a tooltip message class NodeSyncStatusEmpty extends StatelessWidget { + /// Creates a NodeSyncStatusEmpty object. const NodeSyncStatusEmpty({super.key}); @override diff --git a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart index 3a24a0fa..01563252 100644 --- a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart +++ b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart @@ -6,8 +6,9 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; /// A widget associated with the [NodeSyncStatusState] when it's status is /// [DashboardStatus.failure] that displays an icon with a tooltip message class NodeSyncStatusError extends StatelessWidget { + /// Creates a NodeSyncStatusError object. const NodeSyncStatusError({required this.error, super.key}); - + /// Error that holds the message used in the [Tooltip] final Object error; @override diff --git a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_loading.dart b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_loading.dart index 6de4166a..5da924ab 100644 --- a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_loading.dart +++ b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_loading.dart @@ -6,6 +6,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; /// A widget associated with the [NodeSyncStatusState] when it's status is /// [DashboardStatus.loading] that displays a loading indicator with a tooltip class NodeSyncStatusLoading extends StatelessWidget { + /// Creates a NodeSyncStatusLoading object. const NodeSyncStatusLoading({super.key}); @override diff --git a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_populated.dart b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_populated.dart index d91265d6..d6b4aee9 100644 --- a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_populated.dart +++ b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_populated.dart @@ -8,8 +8,9 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// [DashboardStatus.success] that returns a corresponding icon depending on the /// [SyncInfo] and [SyncState] data class NodeSyncPopulated extends StatelessWidget { + /// Creates a NodeSyncPopulated object. const NodeSyncPopulated({required this.data, super.key}); - + /// A Pair holding detailed info about the sync stage final Pair data; @override From c81841f16cef60026a66cc2b8fb8e376ac6914ee Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Sat, 26 Oct 2024 15:02:25 +0300 Subject: [PATCH 044/102] feat: Make the DashboardCubit a HydratedCubit --- lib/main.dart | 14 +++-- lib/main_dev.dart | 11 +++- .../balance/cubit/balance_cubit.dart | 14 ++++- .../balance/cubit/balance_cubit.g.dart | 30 +++++++++ .../balance/cubit/balance_state.dart | 9 ++- .../dashboard/dashboard_cubit.dart | 5 +- .../delegation/cubit/delegation_cubit.dart | 12 ++++ .../delegation/cubit/delegation_cubit.g.dart | 31 ++++++++++ .../delegation/cubit/delegation_state.dart | 9 +++ .../no_delegation_stats_exception.dart | 16 +++++ .../no_delegation_stats_exception.g.dart | 15 +++++ .../cubit/dual_coin_stats_cubit.dart | 61 +++++++++---------- .../cubit/dual_coin_stats_cubit.g.dart | 31 ++++++++++ .../cubit/dual_coin_stats_state.dart | 8 +++ .../pillars/cubit/pillars_cubit.dart | 10 +++ .../pillars/cubit/pillars_cubit.g.dart | 28 +++++++++ .../pillars/cubit/pillars_state.dart | 8 +++ .../cubit/realtime_statistics_cubit.dart | 12 ++++ .../cubit/realtime_statistics_cubit.g.dart | 33 ++++++++++ .../cubit/realtime_statistics_state.dart | 8 +++ .../sentinels/cubit/sentinels_cubit.dart | 13 +++- .../sentinels/cubit/sentinels_cubit.g.dart | 31 ++++++++++ .../sentinels/cubit/sentinels_state.dart | 8 +++ .../staking/cubit/staking_cubit.dart | 11 ++++ .../staking/cubit/staking_cubit.g.dart | 30 +++++++++ .../staking/cubit/staking_state.dart | 8 +++ .../total_hourly_transactions_cubit.dart | 25 +++++--- .../total_hourly_transactions_cubit.g.dart | 31 ++++++++++ .../total_hourly_transactions_state.dart | 8 +++ .../cubit/node_sync_status_cubit.dart | 12 ++++ .../cubit/node_sync_status_cubit.g.dart | 45 ++++++++++++++ .../cubit/node_sync_status_state.dart | 8 +++ lib/utils/pair.dart | 24 +++++++- pubspec.lock | 28 ++++++++- pubspec.yaml | 3 + 35 files changed, 597 insertions(+), 53 deletions(-) create mode 100644 lib/rearchitecture/dashboard/balance/cubit/balance_cubit.g.dart create mode 100644 lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.g.dart create mode 100644 lib/rearchitecture/dashboard/delegation/exceptions/no_delegation_stats_exception.g.dart create mode 100644 lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.g.dart create mode 100644 lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.g.dart create mode 100644 lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.g.dart create mode 100644 lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.g.dart create mode 100644 lib/rearchitecture/dashboard/staking/cubit/staking_cubit.g.dart create mode 100644 lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.g.dart create mode 100644 lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.g.dart diff --git a/lib/main.dart b/lib/main.dart index f9e71409..042a60f0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,18 +2,19 @@ import 'dart:async'; import 'dart:io'; import 'dart:isolate'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; -import 'package:flutter_localizations/flutter_localizations.dart'; -import 'package:flutter/foundation.dart' show kDebugMode; +import 'package:flutter/foundation.dart' show kDebugMode, kIsWeb; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:get_it/get_it.dart'; import 'package:hive/hive.dart'; +import 'package:hydrated_bloc/hydrated_bloc.dart'; import 'package:layout/layout.dart'; import 'package:local_notifier/local_notifier.dart'; import 'package:logging/logging.dart'; import 'package:overlay_support/overlay_support.dart'; import 'package:path/path.dart' as path; +import 'package:path_provider/path_provider.dart'; import 'package:provider/provider.dart'; import 'package:retry/retry.dart'; import 'package:tray_manager/tray_manager.dart'; @@ -47,7 +48,12 @@ final globalNavigatorKey = GlobalKey(); main() async { WidgetsFlutterBinding.ensureInitialized(); - + // Init hydrated bloc storage + HydratedBloc.storage = await HydratedStorage.build( + storageDirectory: kIsWeb + ? HydratedStorage.webStorageDirectory + : await getApplicationDocumentsDirectory(), + ); Provider.debugCheckInvalidValueType = null; ensureDirectoriesExist(); diff --git a/lib/main_dev.dart b/lib/main_dev.dart index 78cceddc..44ba7c50 100644 --- a/lib/main_dev.dart +++ b/lib/main_dev.dart @@ -3,15 +3,17 @@ import 'dart:io'; import 'dart:isolate'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; -import 'package:flutter/foundation.dart' show kDebugMode; +import 'package:flutter/foundation.dart' show kDebugMode, kIsWeb; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; +import 'package:hydrated_bloc/hydrated_bloc.dart'; import 'package:layout/layout.dart'; import 'package:local_notifier/local_notifier.dart'; import 'package:logging/logging.dart'; import 'package:overlay_support/overlay_support.dart'; import 'package:path/path.dart' as path; +import 'package:path_provider/path_provider.dart'; import 'package:provider/provider.dart'; import 'package:retry/retry.dart'; import 'package:tray_manager/tray_manager.dart'; @@ -39,7 +41,12 @@ const String p = String.fromEnvironment('PASSWORD'); main() async { WidgetsFlutterBinding.ensureInitialized(); - + // Init hydrated bloc storage + HydratedBloc.storage = await HydratedStorage.build( + storageDirectory: kIsWeb + ? HydratedStorage.webStorageDirectory + : await getApplicationDocumentsDirectory(), + ); Provider.debugCheckInvalidValueType = null; ensureDirectoriesExist(); diff --git a/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart b/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart index 0bf8e07c..a92fca68 100644 --- a/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart +++ b/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart @@ -1,7 +1,10 @@ +import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/utils/exceptions/exceptions.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; +part 'balance_cubit.g.dart'; + part 'balance_state.dart'; /// A cubit that is responsible for managing and fetching the account balance @@ -26,8 +29,7 @@ class BalanceCubit extends DashboardCubit { /// Throws an exception if the balance retrieval fails. @override Future fetch() async { - final response = await zenon.ledger - .getAccountInfoByAddress(address); + final response = await zenon.ledger.getAccountInfoByAddress(address); if (response.blockCount! > 0 && (response.znn()! > BigInt.zero || response.qsr()! > BigInt.zero)) { return response; @@ -35,4 +37,12 @@ class BalanceCubit extends DashboardCubit { throw NoBalanceException(); } } + + @override + BalanceState? fromJson(Map json) => BalanceState.fromJson( + json, + ); + + @override + Map? toJson(BalanceState state) => state.toJson(); } diff --git a/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.g.dart b/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.g.dart new file mode 100644 index 00000000..aa26e513 --- /dev/null +++ b/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.g.dart @@ -0,0 +1,30 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'balance_cubit.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +BalanceState _$BalanceStateFromJson(Map json) => BalanceState( + status: $enumDecodeNullable(_$DashboardStatusEnumMap, json['status']) ?? + DashboardStatus.initial, + data: json['data'] == null + ? null + : AccountInfo.fromJson(json['data'] as Map), + error: json['error'], + ); + +Map _$BalanceStateToJson(BalanceState instance) => + { + 'status': _$DashboardStatusEnumMap[instance.status]!, + 'data': instance.data, + 'error': instance.error, + }; + +const _$DashboardStatusEnumMap = { + DashboardStatus.failure: 'failure', + DashboardStatus.initial: 'initial', + DashboardStatus.loading: 'loading', + DashboardStatus.success: 'success', +}; diff --git a/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart b/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart index 0fdcfa50..61a23483 100644 --- a/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart +++ b/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart @@ -5,7 +5,7 @@ part of 'balance_cubit.dart'; /// /// The data hold, when the status is [DashboardStatus.success] is of type /// [AccountInfo]. - +@JsonSerializable() class BalanceState extends DashboardState { /// Constructs a new BalanceState. /// @@ -17,6 +17,10 @@ class BalanceState extends DashboardState { super.error, }); + /// Creates a [BalanceState] instance from a JSON map. + factory BalanceState.fromJson(Map json) => + _$BalanceStateFromJson(json); + /// Creates a copy of the current [BalanceState] with optional new values for /// [status], [data], and [error]. /// @@ -38,4 +42,7 @@ class BalanceState extends DashboardState { error: error ?? this.error, ); } + + /// Converts this [BalanceState] instance to a JSON map. + Map toJson() => _$BalanceStateToJson(this); } diff --git a/lib/rearchitecture/dashboard/dashboard_cubit.dart b/lib/rearchitecture/dashboard/dashboard_cubit.dart index f3b04367..a2d3e939 100644 --- a/lib/rearchitecture/dashboard/dashboard_cubit.dart +++ b/lib/rearchitecture/dashboard/dashboard_cubit.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; +import 'package:hydrated_bloc/hydrated_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -14,7 +14,8 @@ part 'dashboard_state.dart'; /// /// The generic type [S] represents the type of the states emitted by the cubit. /// [S] extends [DashboardState] -abstract class DashboardCubit> extends Cubit { +abstract class DashboardCubit> extends +HydratedCubit { /// Constructs a `DashboardCubit` with the provided [zenon] client and initial /// state. diff --git a/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart b/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart index 364ccc99..5221e599 100644 --- a/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart +++ b/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart @@ -1,6 +1,8 @@ +import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; +part 'delegation_cubit.g.dart'; part 'delegation_state.dart'; /// A cubit that manages the fetching and state of delegation information @@ -12,6 +14,7 @@ class DelegationCubit extends DashboardCubit { /// The [zenon] client is used to interact with the Zenon network to retrieve /// delegation information. DelegationCubit(this.address, super.zenon, super.initialState); + /// The address for which the [DelegationInfo] will be fetched final Address address; @@ -35,4 +38,13 @@ class DelegationCubit extends DashboardCubit { throw NoDelegationStatsException(); } } + + @override + DelegationState? fromJson(Map json) => + DelegationState.fromJson( + json, + ); + + @override + Map? toJson(DelegationState state) => state.toJson(); } diff --git a/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.g.dart b/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.g.dart new file mode 100644 index 00000000..aef4a723 --- /dev/null +++ b/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.g.dart @@ -0,0 +1,31 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'delegation_cubit.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +DelegationState _$DelegationStateFromJson(Map json) => + DelegationState( + status: $enumDecodeNullable(_$DashboardStatusEnumMap, json['status']) ?? + DashboardStatus.initial, + data: json['data'] == null + ? null + : DelegationInfo.fromJson(json['data'] as Map), + error: json['error'], + ); + +Map _$DelegationStateToJson(DelegationState instance) => + { + 'status': _$DashboardStatusEnumMap[instance.status]!, + 'data': instance.data, + 'error': instance.error, + }; + +const _$DashboardStatusEnumMap = { + DashboardStatus.failure: 'failure', + DashboardStatus.initial: 'initial', + DashboardStatus.loading: 'loading', + DashboardStatus.success: 'success', +}; diff --git a/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart b/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart index ec90cda0..db4ee885 100644 --- a/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart +++ b/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart @@ -4,6 +4,8 @@ part of 'delegation_cubit.dart'; /// /// It holds a [DelegationInfo] object that represents the retrieved delegation /// details. + +@JsonSerializable() class DelegationState extends DashboardState { /// Constructs a new DelegationState object. /// @@ -16,6 +18,10 @@ class DelegationState extends DashboardState { super.error, }); + /// Creates a [DelegationState] instance from a JSON map. + factory DelegationState.fromJson(Map json) => + _$DelegationStateFromJson(json); + /// Creates a copy of the current [DelegationState] with optional new values /// for [status], [data], and [error]. /// @@ -33,4 +39,7 @@ class DelegationState extends DashboardState { error: error ?? this.error, ); } + + /// Converts this [DelegationState] instance to a JSON map. + Map toJson() => _$DelegationStateToJson(this); } diff --git a/lib/rearchitecture/dashboard/delegation/exceptions/no_delegation_stats_exception.dart b/lib/rearchitecture/dashboard/delegation/exceptions/no_delegation_stats_exception.dart index 419a6a4f..ebb0ee9c 100644 --- a/lib/rearchitecture/dashboard/delegation/exceptions/no_delegation_stats_exception.dart +++ b/lib/rearchitecture/dashboard/delegation/exceptions/no_delegation_stats_exception.dart @@ -1,5 +1,21 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'no_delegation_stats_exception.g.dart'; + /// Custom [Exception] used when there are no delegation info available +@JsonSerializable() class NoDelegationStatsException implements Exception { + /// Creates a [NoDelegationStatsException] instance + NoDelegationStatsException(); + + /// Creates a [NoDelegationStatsException] instance from a JSON map. + factory NoDelegationStatsException.fromJson(Map json) => + _$NoDelegationStatsExceptionFromJson(json); + + + /// Converts this [NoDelegationStatsException] instance to a JSON map. + Map toJson() => _$NoDelegationStatsExceptionToJson(this); + @override String toString() => 'No delegation stats available'; } diff --git a/lib/rearchitecture/dashboard/delegation/exceptions/no_delegation_stats_exception.g.dart b/lib/rearchitecture/dashboard/delegation/exceptions/no_delegation_stats_exception.g.dart new file mode 100644 index 00000000..308d6fb7 --- /dev/null +++ b/lib/rearchitecture/dashboard/delegation/exceptions/no_delegation_stats_exception.g.dart @@ -0,0 +1,15 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'no_delegation_stats_exception.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +NoDelegationStatsException _$NoDelegationStatsExceptionFromJson( + Map json) => + NoDelegationStatsException(); + +Map _$NoDelegationStatsExceptionToJson( + NoDelegationStatsException instance) => + {}; diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart index c1e93214..58162704 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart @@ -1,53 +1,52 @@ +import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; +part 'dual_coin_stats_cubit.g.dart'; + part 'dual_coin_stats_state.dart'; -/// `DualCoinStatsCubit` manages the fetching and state of dual coin statistics +/// A cubit that manages the fetching and state of dual coin statistics /// for ZNN and QSR tokens. /// -/// This cubit extends [DashboardCubit], using a list of `Token` objects to +/// This cubit extends [DashboardCubit], using a list of [Token] objects to /// represent the statistics for the ZNN and QSR tokens fetched from the Zenon /// network. class DualCoinStatsCubit extends DashboardCubit, DualCoinStatsState> { - /// Constructs a `DualCoinStatsCubit`, passing the `zenon` client and the + /// Constructs a [DualCoinStatsCubit], passing the [zenon] client and the /// initial state to the parent class. /// - /// The `zenon` client is used to interact with the Zenon network to retrieve + /// The [zenon] client is used to interact with the Zenon network to retrieve /// token information. DualCoinStatsCubit(super.zenon, super.initialState); /// Fetches the statistics for both ZNN and QSR tokens. /// - /// This method retrieves token data using the Zenon SDK's 'getByZts()' - /// method for each token, executing the requests concurrently using - /// `Future.wait()`. It returns a list containing the fetched token data for - /// ZNN and QSR. - /// - /// Throws: - /// - An error if any exception occurs during the fetching of token data. + /// It returns a list containing the fetched token data for ZNN and QSR. @override Future> fetch() async { - try { - final data = await Future.wait( - [ - zenon.embedded.token.getByZts( - znnZts, // Fetches the ZNN token statistics - ), - zenon.embedded.token.getByZts( - qsrZts, // Fetches the QSR token statistics - ), - ], - ); - - // For ZNN and QSR, the network will return non-nullable data - final nonNullableData = data.map((token) => token!).toList(); - - // The list has only two elements - return nonNullableData; - } catch (e) { - rethrow; - } + final data = await Future.wait( + [ + zenon.embedded.token.getByZts( + znnZts, // Fetches the ZNN token statistics + ), + zenon.embedded.token.getByZts( + qsrZts, // Fetches the QSR token statistics + ), + ], + ); + + // For ZNN and QSR, the network will return non-nullable data + final nonNullableData = data.map((token) => token!).toList(); + + return nonNullableData; } + + @override + DualCoinStatsState? fromJson(Map json) => + DualCoinStatsState.fromJson(json); + + @override + Map? toJson(DualCoinStatsState state) => state.toJson(); } diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.g.dart b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.g.dart new file mode 100644 index 00000000..651b6a45 --- /dev/null +++ b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.g.dart @@ -0,0 +1,31 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'dual_coin_stats_cubit.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +DualCoinStatsState _$DualCoinStatsStateFromJson(Map json) => + DualCoinStatsState( + status: $enumDecodeNullable(_$DashboardStatusEnumMap, json['status']) ?? + DashboardStatus.initial, + data: (json['data'] as List?) + ?.map((e) => Token.fromJson(e as Map)) + .toList(), + error: json['error'], + ); + +Map _$DualCoinStatsStateToJson(DualCoinStatsState instance) => + { + 'status': _$DashboardStatusEnumMap[instance.status]!, + 'data': instance.data, + 'error': instance.error, + }; + +const _$DashboardStatusEnumMap = { + DashboardStatus.failure: 'failure', + DashboardStatus.initial: 'initial', + DashboardStatus.loading: 'loading', + DashboardStatus.success: 'success', +}; diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart index d21ec98a..86bfeab2 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart @@ -7,6 +7,7 @@ part of 'dual_coin_stats_cubit.dart'; /// for two tokens. /// This state is used by the `DualCoinStatsCubit` to track and update the /// state of both tokens. +@JsonSerializable() class DualCoinStatsState extends DashboardState> { /// Constructs a new `DualCoinStatsState`. /// @@ -19,6 +20,10 @@ class DualCoinStatsState extends DashboardState> { super.error, }); + /// Creates a [DualCoinStatsState] instance from a JSON map. + factory DualCoinStatsState.fromJson(Map json) => + _$DualCoinStatsStateFromJson(json); + /// Creates a copy of the current `DualCoinStatsState` with optional new /// values for `status`, `data`, and `error`. /// @@ -40,4 +45,7 @@ class DualCoinStatsState extends DashboardState> { error: error ?? this.error, ); } + + /// Converts this [DualCoinStatsState] instance to a JSON map. + Map toJson() => _$DualCoinStatsStateToJson(this); } diff --git a/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart b/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart index fa5765b0..c8680b66 100644 --- a/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart +++ b/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart @@ -1,5 +1,8 @@ +import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +part 'pillars_cubit.g.dart'; + part 'pillars_state.dart'; /// `PillarsCubit` manages the fetching and state of pillar statistics. @@ -32,4 +35,11 @@ class PillarsCubit extends DashboardCubit { rethrow; } } + + @override + PillarsState? fromJson(Map json) => + PillarsState.fromJson(json); + + @override + Map? toJson(PillarsState state) => state.toJson(); } diff --git a/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.g.dart b/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.g.dart new file mode 100644 index 00000000..c64bb66d --- /dev/null +++ b/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.g.dart @@ -0,0 +1,28 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'pillars_cubit.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +PillarsState _$PillarsStateFromJson(Map json) => PillarsState( + status: $enumDecodeNullable(_$DashboardStatusEnumMap, json['status']) ?? + DashboardStatus.initial, + data: (json['data'] as num?)?.toInt(), + error: json['error'], + ); + +Map _$PillarsStateToJson(PillarsState instance) => + { + 'status': _$DashboardStatusEnumMap[instance.status]!, + 'data': instance.data, + 'error': instance.error, + }; + +const _$DashboardStatusEnumMap = { + DashboardStatus.failure: 'failure', + DashboardStatus.initial: 'initial', + DashboardStatus.loading: 'loading', + DashboardStatus.success: 'success', +}; diff --git a/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart b/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart index d8716e34..4a388560 100644 --- a/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart +++ b/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart @@ -7,6 +7,7 @@ part of 'pillars_cubit.dart'; /// retrieved from the Zenon network. /// This state is used by the `PillarsCubit` to track and update the number of /// active pillars. +@JsonSerializable() class PillarsState extends DashboardState { /// Constructs a new `PillarsState`. /// @@ -20,6 +21,10 @@ class PillarsState extends DashboardState { super.error, }); + /// Creates a [PillarsState] instance from a JSON map. + factory PillarsState.fromJson(Map json) => + _$PillarsStateFromJson(json); + /// Creates a copy of the current `PillarsState` with optional new values for /// `status`, `data`, and `error`. /// @@ -41,4 +46,7 @@ class PillarsState extends DashboardState { error: error ?? this.error, ); } + + /// Converts this [PillarsState] instance to a JSON map. + Map toJson() => _$PillarsStateToJson(this); } diff --git a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart index ed730a50..8454276a 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart @@ -1,9 +1,12 @@ +import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/exceptions/exceptions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; +part 'realtime_statistics_cubit.g.dart'; + part 'realtime_statistics_state.dart'; /// `RealtimeStatisticsCubit` manages the fetching and state of real-time @@ -90,4 +93,13 @@ class RealtimeStatisticsCubit rethrow; } } + + @override + RealtimeStatisticsState? fromJson(Map json) => + RealtimeStatisticsState.fromJson( + json, + ); + + @override + Map? toJson(RealtimeStatisticsState state) => state.toJson(); } diff --git a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.g.dart b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.g.dart new file mode 100644 index 00000000..e5668f94 --- /dev/null +++ b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.g.dart @@ -0,0 +1,33 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'realtime_statistics_cubit.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +RealtimeStatisticsState _$RealtimeStatisticsStateFromJson( + Map json) => + RealtimeStatisticsState( + status: $enumDecodeNullable(_$DashboardStatusEnumMap, json['status']) ?? + DashboardStatus.initial, + data: (json['data'] as List?) + ?.map((e) => AccountBlock.fromJson(e as Map)) + .toList(), + error: json['error'], + ); + +Map _$RealtimeStatisticsStateToJson( + RealtimeStatisticsState instance) => + { + 'status': _$DashboardStatusEnumMap[instance.status]!, + 'data': instance.data, + 'error': instance.error, + }; + +const _$DashboardStatusEnumMap = { + DashboardStatus.failure: 'failure', + DashboardStatus.initial: 'initial', + DashboardStatus.loading: 'loading', + DashboardStatus.success: 'success', +}; diff --git a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart index 6b35f4c4..954293d7 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart @@ -7,6 +7,7 @@ part of 'realtime_statistics_cubit.dart'; /// blockchain data, such as recent transactions. /// It's used to track the state of the data loading process in the /// `RealtimeStatisticsCubit`. +@JsonSerializable() class RealtimeStatisticsState extends DashboardState> { /// Constructs a new `RealtimeStatisticsState` with optional values for /// `status`, `data`, and `error`. @@ -19,6 +20,10 @@ class RealtimeStatisticsState extends DashboardState> { super.error, }); + /// Creates a [RealtimeStatisticsState] instance from a JSON map. + factory RealtimeStatisticsState.fromJson(Map json) => + _$RealtimeStatisticsStateFromJson(json); + /// Creates a copy of the current `RealtimeStatisticsState` with updated /// values for `status`, `data`, or `error`. /// @@ -40,4 +45,7 @@ class RealtimeStatisticsState extends DashboardState> { error: error ?? this.error, ); } + + /// Converts this [RealtimeStatisticsState] instance to a JSON map. + Map toJson() => _$RealtimeStatisticsStateToJson(this); } diff --git a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart index 094ecca8..bba8f796 100644 --- a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart +++ b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart @@ -1,7 +1,9 @@ - +import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; +part 'sentinels_cubit.g.dart'; + part 'sentinels_state.dart'; /// `SentinelsCubit` manages the fetching and state of sentinel information. @@ -35,4 +37,13 @@ class SentinelsCubit extends DashboardCubit { rethrow; } } + + @override + SentinelsState? fromJson(Map json) => + SentinelsState.fromJson( + json, + ); + + @override + Map? toJson(SentinelsState state) => state.toJson(); } diff --git a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.g.dart b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.g.dart new file mode 100644 index 00000000..8579636c --- /dev/null +++ b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.g.dart @@ -0,0 +1,31 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'sentinels_cubit.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +SentinelsState _$SentinelsStateFromJson(Map json) => + SentinelsState( + status: $enumDecodeNullable(_$DashboardStatusEnumMap, json['status']) ?? + DashboardStatus.initial, + data: json['data'] == null + ? null + : SentinelInfoList.fromJson(json['data'] as Map), + error: json['error'], + ); + +Map _$SentinelsStateToJson(SentinelsState instance) => + { + 'status': _$DashboardStatusEnumMap[instance.status]!, + 'data': instance.data, + 'error': instance.error, + }; + +const _$DashboardStatusEnumMap = { + DashboardStatus.failure: 'failure', + DashboardStatus.initial: 'initial', + DashboardStatus.loading: 'loading', + DashboardStatus.success: 'success', +}; diff --git a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart index 06930f22..2dddd0bc 100644 --- a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart +++ b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart @@ -6,6 +6,7 @@ part of 'sentinels_cubit.dart'; /// This class manages a `SentinelInfoList` object representing information /// about active sentinels. It is used to track /// the state of sentinel data loading within the `SentinelsCubit`. +@JsonSerializable() class SentinelsState extends DashboardState { /// Constructs a new `SentinelsState` with optional values for `status`, /// `data`, and `error`. @@ -18,6 +19,10 @@ class SentinelsState extends DashboardState { super.error, }); + /// Creates a [SentinelsState] instance from a JSON map. + factory SentinelsState.fromJson(Map json) => + _$SentinelsStateFromJson(json); + /// Creates a copy of the current `SentinelsState` with updated values for /// `status`, `data`, or `error`. /// @@ -39,4 +44,7 @@ class SentinelsState extends DashboardState { error: error ?? this.error, ); } + + /// Converts this [SentinelsState] instance to a JSON map. + Map toJson() => _$SentinelsStateToJson(this); } diff --git a/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart b/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart index d7701f7d..871c1c28 100644 --- a/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart +++ b/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart @@ -1,8 +1,11 @@ +import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/utils/exceptions/exceptions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; +part 'staking_cubit.g.dart'; + part 'staking_state.dart'; /// `StakingCubit` manages the fetching and state of staking information. @@ -56,4 +59,12 @@ class StakingCubit extends DashboardCubit { Address.parse(kSelectedAddress!), ); } + + @override + StakingState? fromJson(Map json) => StakingState.fromJson( + json, + ); + + @override + Map? toJson(StakingState state) => state.toJson(); } diff --git a/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.g.dart b/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.g.dart new file mode 100644 index 00000000..4f05225b --- /dev/null +++ b/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.g.dart @@ -0,0 +1,30 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'staking_cubit.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +StakingState _$StakingStateFromJson(Map json) => StakingState( + status: $enumDecodeNullable(_$DashboardStatusEnumMap, json['status']) ?? + DashboardStatus.initial, + data: json['data'] == null + ? null + : StakeList.fromJson(json['data'] as Map), + error: json['error'], + ); + +Map _$StakingStateToJson(StakingState instance) => + { + 'status': _$DashboardStatusEnumMap[instance.status]!, + 'data': instance.data, + 'error': instance.error, + }; + +const _$DashboardStatusEnumMap = { + DashboardStatus.failure: 'failure', + DashboardStatus.initial: 'initial', + DashboardStatus.loading: 'loading', + DashboardStatus.success: 'success', +}; diff --git a/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart b/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart index 6eb85dac..5691a14a 100644 --- a/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart +++ b/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart @@ -7,6 +7,7 @@ part of 'staking_cubit.dart'; /// staking entries. /// It tracks the loading, success, or failure of fetching staking data within /// the `StakingCubit`. +@JsonSerializable() class StakingState extends DashboardState { /// Constructs a new `StakingState` with optional values for `status`, /// `data`, and `error`. @@ -19,6 +20,10 @@ class StakingState extends DashboardState { super.error, }); + /// Creates a [StakingState] instance from a JSON map. + factory StakingState.fromJson(Map json) => + _$StakingStateFromJson(json); + /// Creates a copy of the current `StakingState` with updated values for /// `status`, `data`, or `error`. /// @@ -40,4 +45,7 @@ class StakingState extends DashboardState { error: error ?? this.error, ); } + + /// Converts this [StakingState] instance to a JSON map. + Map toJson() => _$StakingStateToJson(this); } diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart index 5a80717f..f32d518b 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart @@ -1,7 +1,10 @@ +import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/exceptions/exceptions.dart'; +part 'total_hourly_transactions_cubit.g.dart'; + part 'total_hourly_transactions_state.dart'; /// `TotalHourlyTransactionsCubit` manages the fetching and state of total @@ -41,17 +44,17 @@ class TotalHourlyTransactionsCubit // Fetch detailed momentums for the past hour final response = (await zenon.ledger.getDetailedMomentumsByHeight( - chainHeight - kMomentumsPerHour, - kMomentumsPerHour, - )) - .list ?? + chainHeight - kMomentumsPerHour, + kMomentumsPerHour, + )) + .list ?? []; // Prepare the transaction summary final transactions = response.fold( - 0, - (previousValue, element) => previousValue + element.blocks.length, - ); + 0, + (previousValue, element) => previousValue + element.blocks.length, + ); return transactions; // Return the summary of transactions } else { throw NotEnoughMomentumsException(); @@ -74,4 +77,12 @@ class TotalHourlyTransactionsCubit rethrow; } } + + @override + TotalHourlyTransactionsState? fromJson(Map json) => + TotalHourlyTransactionsState.fromJson(json); + + @override + Map? toJson(TotalHourlyTransactionsState state) => + state.toJson(); } diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.g.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.g.dart new file mode 100644 index 00000000..9de22e99 --- /dev/null +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.g.dart @@ -0,0 +1,31 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'total_hourly_transactions_cubit.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +TotalHourlyTransactionsState _$TotalHourlyTransactionsStateFromJson( + Map json) => + TotalHourlyTransactionsState( + status: $enumDecodeNullable(_$DashboardStatusEnumMap, json['status']) ?? + DashboardStatus.initial, + data: (json['data'] as num?)?.toInt(), + error: json['error'], + ); + +Map _$TotalHourlyTransactionsStateToJson( + TotalHourlyTransactionsState instance) => + { + 'status': _$DashboardStatusEnumMap[instance.status]!, + 'data': instance.data, + 'error': instance.error, + }; + +const _$DashboardStatusEnumMap = { + DashboardStatus.failure: 'failure', + DashboardStatus.initial: 'initial', + DashboardStatus.loading: 'loading', + DashboardStatus.success: 'success', +}; diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart index 5e336d64..70732494 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart @@ -7,6 +7,7 @@ part of 'total_hourly_transactions_cubit.dart'; /// represent transaction statistics (e.g., the number of account blocks and /// the timestamp) for the last hour. It tracks the state of fetching /// hourly transaction data within `TotalHourlyTransactionsCubit`. +@JsonSerializable() class TotalHourlyTransactionsState extends DashboardState { /// Constructs a new `TotalHourlyTransactionsState` with optional values for /// `status`, `data`, and `error`. @@ -19,6 +20,10 @@ class TotalHourlyTransactionsState extends DashboardState { super.error, }); + /// Creates a [TotalHourlyTransactionsState] instance from a JSON map. + factory TotalHourlyTransactionsState.fromJson(Map json) => + _$TotalHourlyTransactionsStateFromJson(json); + /// Creates a copy of the current `TotalHourlyTransactionsState` with updated /// values for `status`, `data`, or `error`. /// @@ -40,4 +45,7 @@ class TotalHourlyTransactionsState extends DashboardState { error: error ?? this.error, ); } + + /// Converts this [TotalHourlyTransactionsState] instance to a JSON map. + Map toJson() => _$TotalHourlyTransactionsStateToJson(this); } diff --git a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart index d18efcde..b54ad7c6 100644 --- a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart +++ b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart' hide zenon; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; @@ -7,6 +8,8 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; +part 'node_sync_status_cubit.g.dart'; + part 'node_sync_status_state.dart'; /// Cubit responsible for fetching the sync state - [SyncState] - and sending @@ -54,4 +57,13 @@ class NodeSyncStatusCubit }); return Pair(_lastSyncState, placeholderSyncInfo); } + + @override + NodeSyncStatusState? fromJson(Map json) => + NodeSyncStatusState.fromJson( + json, + ); + + @override + Map? toJson(NodeSyncStatusState state) => state.toJson(); } diff --git a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.g.dart b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.g.dart new file mode 100644 index 00000000..05e799f2 --- /dev/null +++ b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.g.dart @@ -0,0 +1,45 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'node_sync_status_cubit.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +NodeSyncStatusState _$NodeSyncStatusStateFromJson(Map json) => + NodeSyncStatusState( + status: $enumDecodeNullable(_$DashboardStatusEnumMap, json['status']) ?? + DashboardStatus.initial, + data: json['data'] == null + ? null + : Pair.fromJson( + json['data'] as Map, + (value) => $enumDecode(_$SyncStateEnumMap, value), + (value) => SyncInfo.fromJson(value as Map)), + error: json['error'], + ); + +Map _$NodeSyncStatusStateToJson( + NodeSyncStatusState instance) => + { + 'status': _$DashboardStatusEnumMap[instance.status]!, + 'data': instance.data?.toJson( + (value) => _$SyncStateEnumMap[value]!, + (value) => value, + ), + 'error': instance.error, + }; + +const _$DashboardStatusEnumMap = { + DashboardStatus.failure: 'failure', + DashboardStatus.initial: 'initial', + DashboardStatus.loading: 'loading', + DashboardStatus.success: 'success', +}; + +const _$SyncStateEnumMap = { + SyncState.unknown: 'unknown', + SyncState.syncing: 'syncing', + SyncState.syncDone: 'syncDone', + SyncState.notEnoughPeers: 'notEnoughPeers', +}; diff --git a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart index 4a4f6b16..3c5ccddf 100644 --- a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart +++ b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart @@ -2,6 +2,7 @@ part of 'node_sync_status_cubit.dart'; /// Class used by [NodeSyncStatusCubit] to send state updates to the /// connected view +@JsonSerializable() class NodeSyncStatusState extends DashboardState> { /// Creates a NodeSyncStatusState object. const NodeSyncStatusState({ @@ -10,6 +11,10 @@ class NodeSyncStatusState extends DashboardState> { super.error, }); + /// Creates a [NodeSyncStatusState] instance from a JSON map. + factory NodeSyncStatusState.fromJson(Map json) => + _$NodeSyncStatusStateFromJson(json); + @override DashboardState> copyWith({ DashboardStatus? status, @@ -22,4 +27,7 @@ class NodeSyncStatusState extends DashboardState> { error: error ?? this.error, ); } + + /// Converts this [NodeSyncStatusState] instance to a JSON map. + Map toJson() => _$NodeSyncStatusStateToJson(this); } diff --git a/lib/utils/pair.dart b/lib/utils/pair.dart index 82dfd7e6..f370ebd6 100644 --- a/lib/utils/pair.dart +++ b/lib/utils/pair.dart @@ -1,6 +1,28 @@ class Pair { - + /// Creates a [Pair] instance Pair(this.first, this.second); + + /// `fromJson` factory to specify deserialization methods for generic types + factory Pair.fromJson( + Map json, + T1 Function(Object? json) fromJsonT1, + T2 Function(Object? json) fromJsonT2, + ) => + Pair( + fromJsonT1(json['first']), + fromJsonT2(json['second']), + ); + final T1 first; final T2 second; + + /// `toJson` function to serialize generic types + Map toJson( + Object? Function(T1 value) toJsonT1, + Object? Function(T2 value) toJsonT2, + ) => + { + 'first': toJsonT1(first), + 'second': toJsonT2(second), + }; } diff --git a/pubspec.lock b/pubspec.lock index b955105e..a44d9fbe 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -754,6 +754,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" + hydrated_bloc: + dependency: "direct main" + description: + name: hydrated_bloc + sha256: af35b357739fe41728df10bec03aad422cdc725a1e702e03af9d2a41ea05160c + url: "https://pub.dev" + source: hosted + version: "9.1.5" image: dependency: "direct main" description: @@ -859,7 +867,7 @@ packages: source: hosted version: "0.6.7" json_annotation: - dependency: transitive + dependency: "direct main" description: name: json_annotation sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" @@ -874,6 +882,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.2" + json_serializable: + dependency: "direct dev" + description: + name: json_serializable + sha256: ea1432d167339ea9b5bb153f0571d0039607a873d6e04e0117af043f14a1fd4b + url: "https://pub.dev" + source: hosted + version: "6.8.0" launch_at_startup: dependency: "direct main" description: @@ -1567,6 +1583,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" + synchronized: + dependency: transitive + description: + name: synchronized + sha256: "69fe30f3a8b04a0be0c15ae6490fc859a78ef4c43ae2dd5e8a623d45bfcf9225" + url: "https://pub.dev" + source: hosted + version: "3.3.0+3" term_glyph: dependency: transitive description: @@ -1917,7 +1941,7 @@ packages: description: path: "." ref: refactor - resolved-ref: "4fadee2fcbe2fb5feb2c1f66ba06fc28c6eda7e6" + resolved-ref: "7c8728d611d97c7bbd3cfe007127e1e069cc2f75" url: "https://github.com/maznnwell/znn_sdk_dart.git" source: git version: "0.0.7" diff --git a/pubspec.yaml b/pubspec.yaml index f922e434..cab68634 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -77,6 +77,8 @@ dependencies: flutter_bloc: ^8.1.6 bloc: ^8.1.4 equatable: ^2.0.5 + hydrated_bloc: ^9.1.5 + json_annotation: ^4.9.0 dependency_overrides: @@ -95,6 +97,7 @@ dev_dependencies: flutter_test: sdk: flutter very_good_analysis: ^6.0.0 + json_serializable: ^6.8.0 flutter: From ac00b71c986b196578d48a5d72e9657020c7c54c Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Sat, 26 Oct 2024 16:41:14 +0300 Subject: [PATCH 045/102] feat: Make custom exceptions serializable and move them to separated feature folders --- .../dashboard/balance/balance.dart | 1 + .../balance/cubit/balance_cubit.dart | 1 - .../balance/exceptions/exceptions.dart | 1 + .../exceptions/no_balance_exception.dart | 21 +++++++++++++++++ .../exceptions/no_balance_exception.g.dart | 13 +++++++++++ .../cubit/realtime_statistics_cubit.dart | 1 - .../exceptions/exceptions.dart | 1 + .../no_blocks_available_exception.dart | 23 +++++++++++++++++++ .../no_blocks_available_exception.g.dart | 15 ++++++++++++ .../realtime_statistics.dart | 1 + .../staking/cubit/staking_cubit.dart | 1 - .../staking/exceptions/exceptions.dart | 1 + .../no_active_skaking_entries_exception.dart | 23 +++++++++++++++++++ ...no_active_skaking_entries_exception.g.dart | 15 ++++++++++++ .../dashboard/staking/staking.dart | 1 + .../total_hourly_transactions_cubit.dart | 1 - .../exceptions/exceptions.dart | 1 + .../not_enough_momentums_exception.dart | 23 +++++++++++++++++++ .../not_enough_momentums_exception.g.dart | 15 ++++++++++++ .../total_hourly_transactions.dart | 1 + lib/utils/exceptions/exceptions.dart | 4 ---- .../no_active_skaking_entries_exception.dart | 8 ------- .../exceptions/no_balance_exception.dart | 6 ----- .../no_blocks_available_exception.dart | 8 ------- .../not_enough_momentums_exception.dart | 8 ------- lib/utils/utils.dart | 1 - 26 files changed, 156 insertions(+), 39 deletions(-) create mode 100644 lib/rearchitecture/dashboard/balance/exceptions/exceptions.dart create mode 100644 lib/rearchitecture/dashboard/balance/exceptions/no_balance_exception.dart create mode 100644 lib/rearchitecture/dashboard/balance/exceptions/no_balance_exception.g.dart create mode 100644 lib/rearchitecture/dashboard/realtime_statistics/exceptions/exceptions.dart create mode 100644 lib/rearchitecture/dashboard/realtime_statistics/exceptions/no_blocks_available_exception.dart create mode 100644 lib/rearchitecture/dashboard/realtime_statistics/exceptions/no_blocks_available_exception.g.dart create mode 100644 lib/rearchitecture/dashboard/staking/exceptions/exceptions.dart create mode 100644 lib/rearchitecture/dashboard/staking/exceptions/no_active_skaking_entries_exception.dart create mode 100644 lib/rearchitecture/dashboard/staking/exceptions/no_active_skaking_entries_exception.g.dart create mode 100644 lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/exceptions.dart create mode 100644 lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/not_enough_momentums_exception.dart create mode 100644 lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/not_enough_momentums_exception.g.dart delete mode 100644 lib/utils/exceptions/exceptions.dart delete mode 100644 lib/utils/exceptions/no_active_skaking_entries_exception.dart delete mode 100644 lib/utils/exceptions/no_balance_exception.dart delete mode 100644 lib/utils/exceptions/no_blocks_available_exception.dart delete mode 100644 lib/utils/exceptions/not_enough_momentums_exception.dart diff --git a/lib/rearchitecture/dashboard/balance/balance.dart b/lib/rearchitecture/dashboard/balance/balance.dart index 0ae87fa7..f08482a9 100644 --- a/lib/rearchitecture/dashboard/balance/balance.dart +++ b/lib/rearchitecture/dashboard/balance/balance.dart @@ -1,3 +1,4 @@ export 'cubit/balance_cubit.dart'; +export 'exceptions/exceptions.dart'; export 'view/balance_card.dart'; export 'widgets/widgets.dart'; diff --git a/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart b/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart index a92fca68..17dbffb1 100644 --- a/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart +++ b/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart @@ -1,6 +1,5 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/exceptions/exceptions.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'balance_cubit.g.dart'; diff --git a/lib/rearchitecture/dashboard/balance/exceptions/exceptions.dart b/lib/rearchitecture/dashboard/balance/exceptions/exceptions.dart new file mode 100644 index 00000000..d49c2b3b --- /dev/null +++ b/lib/rearchitecture/dashboard/balance/exceptions/exceptions.dart @@ -0,0 +1 @@ +export 'no_balance_exception.dart'; diff --git a/lib/rearchitecture/dashboard/balance/exceptions/no_balance_exception.dart b/lib/rearchitecture/dashboard/balance/exceptions/no_balance_exception.dart new file mode 100644 index 00000000..662358d8 --- /dev/null +++ b/lib/rearchitecture/dashboard/balance/exceptions/no_balance_exception.dart @@ -0,0 +1,21 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'no_balance_exception.g.dart'; + +/// Custom [Exception] used when there is no balance available on a specific +/// address +@JsonSerializable() +class NoBalanceException implements Exception { + /// Creates a [NoBalanceException] instance + NoBalanceException(); + + /// Creates a [NoBalanceException] instance from a JSON map. + factory NoBalanceException.fromJson(Map json) => + _$NoBalanceExceptionFromJson(json); + + + /// Converts this [NoBalanceException] instance to a JSON map. + Map toJson() => _$NoBalanceExceptionToJson(this); + @override + String toString() => 'Empty balance on the selected address'; +} diff --git a/lib/rearchitecture/dashboard/balance/exceptions/no_balance_exception.g.dart b/lib/rearchitecture/dashboard/balance/exceptions/no_balance_exception.g.dart new file mode 100644 index 00000000..e64cd39c --- /dev/null +++ b/lib/rearchitecture/dashboard/balance/exceptions/no_balance_exception.g.dart @@ -0,0 +1,13 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'no_balance_exception.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +NoBalanceException _$NoBalanceExceptionFromJson(Map json) => + NoBalanceException(); + +Map _$NoBalanceExceptionToJson(NoBalanceException instance) => + {}; diff --git a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart index 8454276a..cc559aeb 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart @@ -1,7 +1,6 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/exceptions/exceptions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/rearchitecture/dashboard/realtime_statistics/exceptions/exceptions.dart b/lib/rearchitecture/dashboard/realtime_statistics/exceptions/exceptions.dart new file mode 100644 index 00000000..062f575d --- /dev/null +++ b/lib/rearchitecture/dashboard/realtime_statistics/exceptions/exceptions.dart @@ -0,0 +1 @@ +export 'no_blocks_available_exception.dart'; diff --git a/lib/rearchitecture/dashboard/realtime_statistics/exceptions/no_blocks_available_exception.dart b/lib/rearchitecture/dashboard/realtime_statistics/exceptions/no_blocks_available_exception.dart new file mode 100644 index 00000000..74574852 --- /dev/null +++ b/lib/rearchitecture/dashboard/realtime_statistics/exceptions/no_blocks_available_exception.dart @@ -0,0 +1,23 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; + +part 'no_blocks_available_exception.g.dart'; + +/// Custom [Exception] to be used with [RealtimeStatisticsCubit] when there are +/// no account blocks available on the network +@JsonSerializable() +class NoBlocksAvailableException implements Exception { + /// Creates a [NoBlocksAvailableException] instance + NoBlocksAvailableException(); + + /// Creates a [NoBlocksAvailableException] instance from a JSON map. + factory NoBlocksAvailableException.fromJson(Map json) => + _$NoBlocksAvailableExceptionFromJson(json); + + + /// Converts this [NoBlocksAvailableException] instance to a JSON map. + Map toJson() => _$NoBlocksAvailableExceptionToJson(this); + + @override + String toString() => 'No account blocks available'; +} diff --git a/lib/rearchitecture/dashboard/realtime_statistics/exceptions/no_blocks_available_exception.g.dart b/lib/rearchitecture/dashboard/realtime_statistics/exceptions/no_blocks_available_exception.g.dart new file mode 100644 index 00000000..d94f1cda --- /dev/null +++ b/lib/rearchitecture/dashboard/realtime_statistics/exceptions/no_blocks_available_exception.g.dart @@ -0,0 +1,15 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'no_blocks_available_exception.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +NoBlocksAvailableException _$NoBlocksAvailableExceptionFromJson( + Map json) => + NoBlocksAvailableException(); + +Map _$NoBlocksAvailableExceptionToJson( + NoBlocksAvailableException instance) => + {}; diff --git a/lib/rearchitecture/dashboard/realtime_statistics/realtime_statistics.dart b/lib/rearchitecture/dashboard/realtime_statistics/realtime_statistics.dart index 8dc61e43..e1f1bbe7 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/realtime_statistics.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/realtime_statistics.dart @@ -1,3 +1,4 @@ export 'cubit/realtime_statistics_cubit.dart'; +export 'exceptions/exceptions.dart'; export 'view/realtime_statistics_card.dart'; export 'widgets/widgets.dart'; diff --git a/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart b/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart index 871c1c28..c458baa6 100644 --- a/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart +++ b/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart @@ -1,6 +1,5 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/exceptions/exceptions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/rearchitecture/dashboard/staking/exceptions/exceptions.dart b/lib/rearchitecture/dashboard/staking/exceptions/exceptions.dart new file mode 100644 index 00000000..9d859e4a --- /dev/null +++ b/lib/rearchitecture/dashboard/staking/exceptions/exceptions.dart @@ -0,0 +1 @@ +export 'no_active_skaking_entries_exception.dart'; diff --git a/lib/rearchitecture/dashboard/staking/exceptions/no_active_skaking_entries_exception.dart b/lib/rearchitecture/dashboard/staking/exceptions/no_active_skaking_entries_exception.dart new file mode 100644 index 00000000..607b6f07 --- /dev/null +++ b/lib/rearchitecture/dashboard/staking/exceptions/no_active_skaking_entries_exception.dart @@ -0,0 +1,23 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; + +part 'no_active_skaking_entries_exception.g.dart'; + +/// Custom [Exception] to be used with [StakingCubit] when there are +/// no active staking entries found on an address +@JsonSerializable() +class NoActiveStakingEntriesException implements Exception { + /// Creates a [NoActiveStakingEntriesException] instance + NoActiveStakingEntriesException(); + + /// Creates a [NoActiveStakingEntriesException] instance from a JSON map. + factory NoActiveStakingEntriesException.fromJson(Map json) => + _$NoActiveStakingEntriesExceptionFromJson(json); + + + /// Converts this [NoActiveStakingEntriesException] instance to a JSON map. + Map toJson() => _$NoActiveStakingEntriesExceptionToJson(this); + + @override + String toString() => 'No active staking entries'; +} diff --git a/lib/rearchitecture/dashboard/staking/exceptions/no_active_skaking_entries_exception.g.dart b/lib/rearchitecture/dashboard/staking/exceptions/no_active_skaking_entries_exception.g.dart new file mode 100644 index 00000000..701cc825 --- /dev/null +++ b/lib/rearchitecture/dashboard/staking/exceptions/no_active_skaking_entries_exception.g.dart @@ -0,0 +1,15 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'no_active_skaking_entries_exception.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +NoActiveStakingEntriesException _$NoActiveStakingEntriesExceptionFromJson( + Map json) => + NoActiveStakingEntriesException(); + +Map _$NoActiveStakingEntriesExceptionToJson( + NoActiveStakingEntriesException instance) => + {}; diff --git a/lib/rearchitecture/dashboard/staking/staking.dart b/lib/rearchitecture/dashboard/staking/staking.dart index c4288449..272c685c 100644 --- a/lib/rearchitecture/dashboard/staking/staking.dart +++ b/lib/rearchitecture/dashboard/staking/staking.dart @@ -1,3 +1,4 @@ export 'cubit/staking_cubit.dart'; +export 'exceptions/exceptions.dart'; export 'view/staking_card.dart'; export 'widgets/widgets.dart'; diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart index f32d518b..dc972d37 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart @@ -1,7 +1,6 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/exceptions/exceptions.dart'; part 'total_hourly_transactions_cubit.g.dart'; diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/exceptions.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/exceptions.dart new file mode 100644 index 00000000..d4116f2f --- /dev/null +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/exceptions.dart @@ -0,0 +1 @@ +export 'not_enough_momentums_exception.dart'; diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/not_enough_momentums_exception.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/not_enough_momentums_exception.dart new file mode 100644 index 00000000..687212e6 --- /dev/null +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/not_enough_momentums_exception.dart @@ -0,0 +1,23 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; + +part 'not_enough_momentums_exception.g.dart'; + +/// Custom [Exception] to be used with [TotalHourlyTransactionsCubit] when +/// the network is less than one hour old +@JsonSerializable() +class NotEnoughMomentumsException implements Exception { + /// Creates a [NotEnoughMomentumsException] instance + NotEnoughMomentumsException(); + + /// Creates a [NotEnoughMomentumsException] instance from a JSON map. + factory NotEnoughMomentumsException.fromJson(Map json) => + _$NotEnoughMomentumsExceptionFromJson(json); + + + /// Converts this [NotEnoughMomentumsException] instance to a JSON map. + Map toJson() => _$NotEnoughMomentumsExceptionToJson(this); + + @override + String toString() => 'Not enough momentums'; +} diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/not_enough_momentums_exception.g.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/not_enough_momentums_exception.g.dart new file mode 100644 index 00000000..e2413dcb --- /dev/null +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/not_enough_momentums_exception.g.dart @@ -0,0 +1,15 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'not_enough_momentums_exception.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +NotEnoughMomentumsException _$NotEnoughMomentumsExceptionFromJson( + Map json) => + NotEnoughMomentumsException(); + +Map _$NotEnoughMomentumsExceptionToJson( + NotEnoughMomentumsException instance) => + {}; diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/total_hourly_transactions.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/total_hourly_transactions.dart index 0131c049..6e55e599 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/total_hourly_transactions.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/total_hourly_transactions.dart @@ -1,3 +1,4 @@ export 'cubit/total_hourly_transactions_cubit.dart'; +export 'exceptions/exceptions.dart'; export 'view/total_hourly_transactions_card.dart'; export 'widgets/widgets.dart'; diff --git a/lib/utils/exceptions/exceptions.dart b/lib/utils/exceptions/exceptions.dart deleted file mode 100644 index 966d3f29..00000000 --- a/lib/utils/exceptions/exceptions.dart +++ /dev/null @@ -1,4 +0,0 @@ -export 'no_active_skaking_entries_exception.dart'; -export 'no_balance_exception.dart'; -export 'no_blocks_available_exception.dart'; -export 'not_enough_momentums_exception.dart'; diff --git a/lib/utils/exceptions/no_active_skaking_entries_exception.dart b/lib/utils/exceptions/no_active_skaking_entries_exception.dart deleted file mode 100644 index 303661d3..00000000 --- a/lib/utils/exceptions/no_active_skaking_entries_exception.dart +++ /dev/null @@ -1,8 +0,0 @@ -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; - -/// Custom [Exception] to be used with [StakingCubit] when there are -/// no active staking entries found on an address -class NoActiveStakingEntriesException implements Exception { - @override - String toString() => 'No active staking entries'; -} diff --git a/lib/utils/exceptions/no_balance_exception.dart b/lib/utils/exceptions/no_balance_exception.dart deleted file mode 100644 index df626d5f..00000000 --- a/lib/utils/exceptions/no_balance_exception.dart +++ /dev/null @@ -1,6 +0,0 @@ -/// Custom [Exception] used when there is no balance available on a specific -/// address -class NoBalanceException implements Exception { - @override - String toString() => 'Empty balance on the selected address'; -} diff --git a/lib/utils/exceptions/no_blocks_available_exception.dart b/lib/utils/exceptions/no_blocks_available_exception.dart deleted file mode 100644 index 0a3a10df..00000000 --- a/lib/utils/exceptions/no_blocks_available_exception.dart +++ /dev/null @@ -1,8 +0,0 @@ -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; - -/// Custom [Exception] to be used with [RealtimeStatisticsCubit] when there are -/// no account blocks available on the network -class NoBlocksAvailableException implements Exception { - @override - String toString() => 'No account blocks available'; -} diff --git a/lib/utils/exceptions/not_enough_momentums_exception.dart b/lib/utils/exceptions/not_enough_momentums_exception.dart deleted file mode 100644 index b053e931..00000000 --- a/lib/utils/exceptions/not_enough_momentums_exception.dart +++ /dev/null @@ -1,8 +0,0 @@ -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; - -/// Custom [Exception] to be used with [TotalHourlyTransactionsCubit] when -/// the network is less than one hour old -class NotEnoughMomentumsException implements Exception { - @override - String toString() => 'Not enough momentums'; -} diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 27080864..8cff3ac2 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -8,7 +8,6 @@ export 'color_utils.dart'; export 'constants.dart'; export 'date_time_utils.dart'; export 'device_utils.dart'; -export 'exceptions/exceptions.dart'; export 'extensions.dart'; export 'file_utils.dart'; export 'format_utils.dart'; From 2babef90a67fdd4235cdd970359668a1efb4baa6 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Sun, 27 Oct 2024 14:19:20 +0200 Subject: [PATCH 046/102] feat: Structure the error handling mechanism --- .../balance/cubit/balance_cubit.dart | 1 + .../balance/cubit/balance_state.dart | 2 +- .../balance/widgets/balance_error.dart | 3 ++- lib/rearchitecture/dashboard/dashboard.dart | 1 + .../dashboard/dashboard_cubit.dart | 20 +++++++++++++++---- .../dashboard/dashboard_cubit_exception.dart | 10 ++++++++++ .../dashboard/dashboard_state.dart | 6 +++--- .../delegation/cubit/delegation_cubit.dart | 1 + .../delegation/cubit/delegation_state.dart | 2 +- .../no_delegation_stats_exception.dart | 8 +++----- .../delegation/widgets/delegation_error.dart | 3 ++- .../cubit/dual_coin_stats_cubit.dart | 1 + .../cubit/dual_coin_stats_state.dart | 2 +- .../widgets/dual_coin_stats_error.dart | 3 ++- .../pillars/cubit/pillars_cubit.dart | 1 + .../pillars/cubit/pillars_state.dart | 2 +- .../pillars/widgets/pillars_error.dart | 3 ++- .../cubit/realtime_statistics_cubit.dart | 1 + .../cubit/realtime_statistics_state.dart | 2 +- .../widgets/realtime_statistics_error.dart | 3 ++- .../sentinels/cubit/sentinels_cubit.dart | 1 + .../sentinels/cubit/sentinels_state.dart | 2 +- .../sentinels/widgets/sentinels_error.dart | 3 ++- .../staking/cubit/staking_cubit.dart | 1 + .../staking/cubit/staking_state.dart | 2 +- .../staking/widgets/staking_error.dart | 3 ++- .../total_hourly_transactions_cubit.dart | 2 ++ .../total_hourly_transactions_state.dart | 2 +- .../total_hourly_transactions_error.dart | 3 ++- .../cubit/node_sync_status_state.dart | 2 +- .../widgets/node_sync_status_error.dart | 3 ++- .../exceptions/cubit_failure_exception.dart | 20 +++++++++++++++++++ .../exceptions/cubit_failure_exception.g.dart | 15 ++++++++++++++ lib/utils/exceptions/exceptions.dart | 2 ++ lib/utils/exceptions/syrius_exception.dart | 11 ++++++++++ lib/utils/utils.dart | 1 + 36 files changed, 118 insertions(+), 30 deletions(-) create mode 100644 lib/rearchitecture/dashboard/dashboard_cubit_exception.dart create mode 100644 lib/utils/exceptions/cubit_failure_exception.dart create mode 100644 lib/utils/exceptions/cubit_failure_exception.g.dart create mode 100644 lib/utils/exceptions/exceptions.dart create mode 100644 lib/utils/exceptions/syrius_exception.dart diff --git a/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart b/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart index 17dbffb1..18569b25 100644 --- a/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart +++ b/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart @@ -1,5 +1,6 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'balance_cubit.g.dart'; diff --git a/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart b/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart index 61a23483..f697a65c 100644 --- a/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart +++ b/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart @@ -34,7 +34,7 @@ class BalanceState extends DashboardState { DashboardState copyWith({ DashboardStatus? status, AccountInfo? data, - Object? error, + SyriusException? error, }) { return BalanceState( status: status ?? this.status, diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_error.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_error.dart index fc559fd3..dfb83f58 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_error.dart +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_error.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/exceptions/exceptions.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; /// A [BalanceError] widget that displays an error message when the balance @@ -10,7 +11,7 @@ class BalanceError extends StatelessWidget { /// Creates a BalanceError object. const BalanceError({required this.error, super.key}); /// The object used to display an error message. - final Object error; + final SyriusException error; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/dashboard.dart b/lib/rearchitecture/dashboard/dashboard.dart index 467bc29b..939584e4 100644 --- a/lib/rearchitecture/dashboard/dashboard.dart +++ b/lib/rearchitecture/dashboard/dashboard.dart @@ -1,5 +1,6 @@ export 'balance/balance.dart'; export 'dashboard_cubit.dart'; +export 'dashboard_cubit_exception.dart'; export 'delegation/delegation.dart'; export 'dual_coin_stats/dual_coin_stats.dart'; export 'pillars/pillars.dart'; diff --git a/lib/rearchitecture/dashboard/dashboard_cubit.dart b/lib/rearchitecture/dashboard/dashboard_cubit.dart index a2d3e939..5a8c69c3 100644 --- a/lib/rearchitecture/dashboard/dashboard_cubit.dart +++ b/lib/rearchitecture/dashboard/dashboard_cubit.dart @@ -1,7 +1,11 @@ import 'dart:async'; + import 'package:equatable/equatable.dart'; import 'package:hydrated_bloc/hydrated_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/exceptions/cubit_failure_exception.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/exceptions/exceptions.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'dashboard_state.dart'; @@ -14,9 +18,8 @@ part 'dashboard_state.dart'; /// /// The generic type [S] represents the type of the states emitted by the cubit. /// [S] extends [DashboardState] -abstract class DashboardCubit> extends -HydratedCubit { - +abstract class DashboardCubit> + extends HydratedCubit { /// Constructs a `DashboardCubit` with the provided [zenon] client and initial /// state. /// @@ -26,11 +29,13 @@ HydratedCubit { super.initialState, { this.refreshInterval = kDashboardRefreshInterval, }); + /// A timer that handles the auto-refreshing of data. Timer? _autoRefresher; /// The Zenon client used to fetch data from the Zenon ledger. final Zenon zenon; + /// The interval at which to fetch the data again. final Duration refreshInterval; @@ -71,8 +76,15 @@ HydratedCubit { } else { throw noConnectionException; } - } catch (e) { + } on DashboardCubitException catch (e) { emit(state.copyWith(status: DashboardStatus.failure, error: e) as S); + } catch (e) { + emit( + state.copyWith( + status: DashboardStatus.failure, + error: CubitFailureException(), + ) as S, + ); } finally { /// Ensure that the auto-refresher is restarted if it's not active. if (!isTimerActive) { diff --git a/lib/rearchitecture/dashboard/dashboard_cubit_exception.dart b/lib/rearchitecture/dashboard/dashboard_cubit_exception.dart new file mode 100644 index 00000000..5619db8a --- /dev/null +++ b/lib/rearchitecture/dashboard/dashboard_cubit_exception.dart @@ -0,0 +1,10 @@ +import 'package:zenon_syrius_wallet_flutter/utils/exceptions/exceptions.dart'; + +/// A custom exception that displays only the message when printed. +/// +/// To be used to create custom exceptions in a specific case that we +/// are aware about - so that we can add a corresponding message +abstract class DashboardCubitException extends SyriusException { + /// Creates a [DashboardCubitException] with a required message. + DashboardCubitException(super.message); +} diff --git a/lib/rearchitecture/dashboard/dashboard_state.dart b/lib/rearchitecture/dashboard/dashboard_state.dart index c06d5817..5edd02d1 100644 --- a/lib/rearchitecture/dashboard/dashboard_state.dart +++ b/lib/rearchitecture/dashboard/dashboard_state.dart @@ -48,8 +48,8 @@ abstract class DashboardState extends Equatable { /// has been loaded or if there was an error. final T? data; - /// An optional error object that holds error details in case of failure. - final Object? error; + /// An optional error object that holds a message to be presented to the user. + final SyriusException? error; /// Creates a copy of the current state with the option to modify specific /// fields. @@ -64,7 +64,7 @@ abstract class DashboardState extends Equatable { DashboardState copyWith({ DashboardStatus? status, T? data, - Object? error, + SyriusException? error, }); @override diff --git a/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart b/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart index 5221e599..30ab6e67 100644 --- a/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart +++ b/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart @@ -1,5 +1,6 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'delegation_cubit.g.dart'; diff --git a/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart b/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart index db4ee885..e6a9cf03 100644 --- a/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart +++ b/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart @@ -31,7 +31,7 @@ class DelegationState extends DashboardState { DashboardState copyWith({ DashboardStatus? status, DelegationInfo? data, - Object? error, + SyriusException? error, }) { return DelegationState( status: status ?? this.status, diff --git a/lib/rearchitecture/dashboard/delegation/exceptions/no_delegation_stats_exception.dart b/lib/rearchitecture/dashboard/delegation/exceptions/no_delegation_stats_exception.dart index ebb0ee9c..105f28a0 100644 --- a/lib/rearchitecture/dashboard/delegation/exceptions/no_delegation_stats_exception.dart +++ b/lib/rearchitecture/dashboard/delegation/exceptions/no_delegation_stats_exception.dart @@ -1,12 +1,13 @@ import 'package:json_annotation/json_annotation.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard_cubit_exception.dart'; part 'no_delegation_stats_exception.g.dart'; /// Custom [Exception] used when there are no delegation info available @JsonSerializable() -class NoDelegationStatsException implements Exception { +class NoDelegationStatsException extends DashboardCubitException { /// Creates a [NoDelegationStatsException] instance - NoDelegationStatsException(); + NoDelegationStatsException(): super('No delegation stats available'); /// Creates a [NoDelegationStatsException] instance from a JSON map. factory NoDelegationStatsException.fromJson(Map json) => @@ -15,7 +16,4 @@ class NoDelegationStatsException implements Exception { /// Converts this [NoDelegationStatsException] instance to a JSON map. Map toJson() => _$NoDelegationStatsExceptionToJson(this); - - @override - String toString() => 'No delegation stats available'; } diff --git a/lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart b/lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart index 08cff849..6f2a9c07 100644 --- a/lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart +++ b/lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; /// A widget that display the [error] message @@ -6,7 +7,7 @@ class DelegationError extends StatelessWidget { /// Creates a DelegationError object. const DelegationError({required this.error, super.key}); /// The object that holds the representation of the error - final Object error; + final SyriusException error; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart index 58162704..acba6ac3 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart @@ -1,5 +1,6 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'dual_coin_stats_cubit.g.dart'; diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart index 86bfeab2..1e4c898c 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart @@ -37,7 +37,7 @@ class DualCoinStatsState extends DashboardState> { DashboardState> copyWith({ DashboardStatus? status, List? data, - Object? error, + SyriusException? error, }) { return DualCoinStatsState( status: status ?? this.status, diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart index a47f6b7a..34318ea8 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; /// A widget associated with the [DualCoinStatsState] when it's status is @@ -11,7 +12,7 @@ class DualCoinStatsError extends StatelessWidget { /// Creates a DualCoinStatsError object const DualCoinStatsError({required this.error, super.key}); /// Holds the data that will be displayed - final Object error; + final SyriusException error; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart b/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart index c8680b66..336d7efc 100644 --- a/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart +++ b/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart @@ -1,5 +1,6 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; part 'pillars_cubit.g.dart'; diff --git a/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart b/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart index 4a388560..5741e84f 100644 --- a/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart +++ b/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart @@ -38,7 +38,7 @@ class PillarsState extends DashboardState { DashboardState copyWith({ DashboardStatus? status, int? data, - Object? error, + SyriusException? error, }) { return PillarsState( status: status ?? this.status, diff --git a/lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart b/lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart index 71a906db..beeaaab5 100644 --- a/lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart +++ b/lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A widget associated with the [PillarsState] when it's status is @@ -9,7 +10,7 @@ class PillarsError extends StatelessWidget { ///Creates a PillarsError object const PillarsError({required this.error, super.key}); /// Holds the data that will be displayed - final Object error; + final SyriusException error; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart index cc559aeb..8d9a5d60 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart @@ -2,6 +2,7 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'realtime_statistics_cubit.g.dart'; diff --git a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart index 954293d7..3cff2c52 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart @@ -37,7 +37,7 @@ class RealtimeStatisticsState extends DashboardState> { DashboardState> copyWith({ DashboardStatus? status, List? data, - Object? error, + SyriusException? error, }) { return RealtimeStatisticsState( status: status ?? this.status, diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart index f5c44121..c230d1dd 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A widget that displays an error message @@ -6,7 +7,7 @@ class RealtimeStatisticsError extends StatelessWidget { /// Creates a RealtimeStatisticsError object const RealtimeStatisticsError({required this.error, super.key}); /// The data that holds the message that will be displayed - final Object error; + final SyriusException error; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart index bba8f796..489793f9 100644 --- a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart +++ b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart @@ -1,5 +1,6 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'sentinels_cubit.g.dart'; diff --git a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart index 2dddd0bc..d80a39b4 100644 --- a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart +++ b/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart @@ -36,7 +36,7 @@ class SentinelsState extends DashboardState { DashboardState copyWith({ DashboardStatus? status, SentinelInfoList? data, - Object? error, + SyriusException? error, }) { return SentinelsState( status: status ?? this.status, diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart index bad085c3..ec620301 100644 --- a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart +++ b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [SentinelsState] when it's status is @@ -9,7 +10,7 @@ class SentinelsError extends StatelessWidget { /// Creates a SentinelsError objects. const SentinelsError({required this.error, super.key}); /// The object that holds the representation of the error - final Object error; + final SyriusException error; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart b/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart index c458baa6..62dfa756 100644 --- a/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart +++ b/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart @@ -1,6 +1,7 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'staking_cubit.g.dart'; diff --git a/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart b/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart index 5691a14a..8e77a957 100644 --- a/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart +++ b/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart @@ -37,7 +37,7 @@ class StakingState extends DashboardState { DashboardState copyWith({ DashboardStatus? status, StakeList? data, - Object? error, + SyriusException? error, }) { return StakingState( status: status ?? this.status, diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart b/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart index 2f024ce1..c4dce3e2 100644 --- a/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart +++ b/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; /// A widget associated with the [StakingState] when it's status is @@ -9,7 +10,7 @@ class StakingError extends StatelessWidget { /// Creates a StakingError object. const StakingError({required this.error, super.key}); /// Error containing the message that will be displayed. - final Object error; + final SyriusException error; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart index dc972d37..cde2ee10 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart @@ -2,6 +2,8 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; +import '../../../../utils/utils.dart'; + part 'total_hourly_transactions_cubit.g.dart'; part 'total_hourly_transactions_state.dart'; diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart index 70732494..3bfd564d 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart @@ -37,7 +37,7 @@ class TotalHourlyTransactionsState extends DashboardState { DashboardState copyWith({ DashboardStatus? status, int? data, - Object? error, + SyriusException? error, }) { return TotalHourlyTransactionsState( status: status ?? this.status, diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart index aafb2343..1cf0eba9 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; /// A widget associated with the [TotalHourlyTransactionsState] when it's @@ -9,7 +10,7 @@ class TotalHourlyTransactionsError extends StatelessWidget { /// Creates a TotalHourlyTransactionError object. const TotalHourlyTransactionsError({required this.error, super.key}); /// Error containing the message that will be displayed. - final Object error; + final SyriusException error; @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart index 3c5ccddf..f546c706 100644 --- a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart +++ b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart @@ -19,7 +19,7 @@ class NodeSyncStatusState extends DashboardState> { DashboardState> copyWith({ DashboardStatus? status, Pair? data, - Object? error, + SyriusException? error, }) { return NodeSyncStatusState( status: status ?? this.status, diff --git a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart index 01563252..a63c46cf 100644 --- a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart +++ b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node_sync_status.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; /// A widget associated with the [NodeSyncStatusState] when it's status is /// [DashboardStatus.failure] that displays an icon with a tooltip message @@ -9,7 +10,7 @@ class NodeSyncStatusError extends StatelessWidget { /// Creates a NodeSyncStatusError object. const NodeSyncStatusError({required this.error, super.key}); /// Error that holds the message used in the [Tooltip] - final Object error; + final SyriusException error; @override Widget build(BuildContext context) { diff --git a/lib/utils/exceptions/cubit_failure_exception.dart b/lib/utils/exceptions/cubit_failure_exception.dart new file mode 100644 index 00000000..b6dbd5b9 --- /dev/null +++ b/lib/utils/exceptions/cubit_failure_exception.dart @@ -0,0 +1,20 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; + +part 'cubit_failure_exception.g.dart'; + +/// A class to be used as a generic exception when something unexpected goes +/// wrong inside a cubit. +@JsonSerializable() +class CubitFailureException extends SyriusException { + /// Creates a [CubitFailureException] instance. + CubitFailureException(): super('Something went wrong'); + + /// Creates a [CubitFailureException] instance from a JSON map. + factory CubitFailureException.fromJson(Map json) => + _$CubitFailureExceptionFromJson(json); + + + /// Converts this [CubitFailureException] instance to a JSON map. + Map toJson() => _$CubitFailureExceptionToJson(this); +} diff --git a/lib/utils/exceptions/cubit_failure_exception.g.dart b/lib/utils/exceptions/cubit_failure_exception.g.dart new file mode 100644 index 00000000..df57454c --- /dev/null +++ b/lib/utils/exceptions/cubit_failure_exception.g.dart @@ -0,0 +1,15 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'cubit_failure_exception.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +CubitFailureException _$CubitFailureExceptionFromJson( + Map json) => + CubitFailureException(); + +Map _$CubitFailureExceptionToJson( + CubitFailureException instance) => + {}; diff --git a/lib/utils/exceptions/exceptions.dart b/lib/utils/exceptions/exceptions.dart new file mode 100644 index 00000000..f99c26b0 --- /dev/null +++ b/lib/utils/exceptions/exceptions.dart @@ -0,0 +1,2 @@ +export 'cubit_failure_exception.dart'; +export 'syrius_exception.dart'; diff --git a/lib/utils/exceptions/syrius_exception.dart b/lib/utils/exceptions/syrius_exception.dart new file mode 100644 index 00000000..6c2afc4c --- /dev/null +++ b/lib/utils/exceptions/syrius_exception.dart @@ -0,0 +1,11 @@ +/// A custom exception that displays only the message when printed. +abstract class SyriusException implements Exception { + /// Creates a [SyriusException] with a required message. + SyriusException(this.message); + /// The exception message + final String message; + + /// Returns the exception message without the 'Exception:' prefix. + @override + String toString() => message; +} diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 8cff3ac2..27080864 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -8,6 +8,7 @@ export 'color_utils.dart'; export 'constants.dart'; export 'date_time_utils.dart'; export 'device_utils.dart'; +export 'exceptions/exceptions.dart'; export 'extensions.dart'; export 'file_utils.dart'; export 'format_utils.dart'; From 8f7a1771b45d9371e0979aae8837e001fee50a0a Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Sun, 27 Oct 2024 14:56:54 +0200 Subject: [PATCH 047/102] feat: Localize some strings --- lib/l10n/app_en.arb | 4 +++- .../dashboard/balance/widgets/balance_empty.dart | 3 ++- .../dashboard/delegation/widgets/delegation_empty.dart | 3 ++- .../dual_coin_stats/widgets/dual_coin_stats_empty.dart | 3 ++- .../dashboard/pillars/widgets/pillars_empty.dart | 3 ++- .../widgets/realtime_statistics_empty.dart | 3 ++- .../dashboard/sentinels/widgets/sentinels_empty.dart | 3 ++- .../dashboard/staking/widgets/staking_empty.dart | 3 ++- .../widgets/total_hourly_transactions_empty.dart | 3 ++- .../widgets/total_hourly_transactions_populated.dart | 4 ++-- 10 files changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 0ffbc88f..0cc8b9cd 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -15,6 +15,8 @@ "stakingStatsDescription": "This card displays the number of staking entries and the total {kZnnCoinSymbol} that you are currently staking", "transactions": "Transactions", "transactionsDescription": "This card displays the total number of transactions settled in the last hour across the network", + "transactionsLastHour": "transactions in the last hour", "transfer": "Transfer", - "transferDescription": "Redirects you to the Transfer tab where you can manage sending and receiving funds" + "transferDescription": "Redirects you to the Transfer tab where you can manage sending and receiving funds", + "waitingForDataFetching": "Waiting for data fetching" } \ No newline at end of file diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart b/lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart index eae47a5c..f394fe0d 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart +++ b/lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/balance/balance.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A [BalanceEmpty] widget that displays a simple message indicating that there @@ -13,6 +14,6 @@ class BalanceEmpty extends StatelessWidget { @override Widget build(BuildContext context) { - return const SyriusErrorWidget('No data available'); + return SyriusErrorWidget(context.l10n.waitingForDataFetching); } } diff --git a/lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart b/lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart index fd355529..bcafe9f8 100644 --- a/lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart +++ b/lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; /// A widget that displays a hardcoded error message @@ -8,6 +9,6 @@ class DelegationEmpty extends StatelessWidget { @override Widget build(BuildContext context) { - return const SyriusErrorWidget('No data available'); + return SyriusErrorWidget(context.l10n.waitingForDataFetching); } } diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart index f7a444b2..68839f79 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart +++ b/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A widget associated with the [DualCoinStatsState] when it's status is @@ -11,6 +12,6 @@ class DualCoinStatsEmpty extends StatelessWidget { @override Widget build(BuildContext context) { - return const SyriusErrorWidget('No data available'); + return SyriusErrorWidget(context.l10n.waitingForDataFetching); } } diff --git a/lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart b/lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart index 83306b61..6559290b 100644 --- a/lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart +++ b/lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A widget associated with the [PillarsState] when it's status is @@ -11,6 +12,6 @@ class PillarsEmpty extends StatelessWidget { @override Widget build(BuildContext context) { - return const SyriusErrorWidget('No data available'); + return SyriusErrorWidget(context.l10n.waitingForDataFetching); } } diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_empty.dart b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_empty.dart index 06ff5816..eb4c1acd 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_empty.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_empty.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A widget that displays a hardcoded error message @@ -8,6 +9,6 @@ class RealtimeStatisticsEmpty extends StatelessWidget { @override Widget build(BuildContext context) { - return const SyriusErrorWidget('No data available'); + return SyriusErrorWidget(context.l10n.waitingForDataFetching); } } diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart index 4d432c02..d7fb654d 100644 --- a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart +++ b/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [SentinelsState] when it's status is @@ -11,6 +12,6 @@ class SentinelsEmpty extends StatelessWidget { @override Widget build(BuildContext context) { - return const SyriusErrorWidget('No data available'); + return SyriusErrorWidget(context.l10n.waitingForDataFetching); } } diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart b/lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart index 63eaa5a7..75b13158 100644 --- a/lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart +++ b/lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [StakingState] when it's status is @@ -11,6 +12,6 @@ class StakingEmpty extends StatelessWidget { @override Widget build(BuildContext context) { - return const SyriusErrorWidget('No data available'); + return SyriusErrorWidget(context.l10n.waitingForDataFetching); } } diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart index bfe3d1c5..d18cb4ea 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [TotalHourlyTransactionsState] when it's @@ -11,6 +12,6 @@ class TotalHourlyTransactionsEmpty extends StatelessWidget { @override Widget build(BuildContext context) { - return const SyriusErrorWidget('No data available'); + return SyriusErrorWidget(context.l10n.waitingForDataFetching); } } diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart index 13aa32f7..ba3049c8 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [TotalHourlyTransactionsState] when it's @@ -25,7 +25,7 @@ class TotalHourlyTransactionsPopulated extends StatelessWidget { ), ), kVerticalSpacing, - const Text('transactions in the last hour'), + Text(context.l10n.transactionsLastHour), ], ); } From 26dc9b4e2f73c02c1a8d734bed1e4b68b62f8bb5 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Sun, 27 Oct 2024 15:01:08 +0200 Subject: [PATCH 048/102] refactor: Make custom exceptions extend from DashboardCubitException --- .../balance/exceptions/no_balance_exception.dart | 7 +++---- .../exceptions/no_blocks_available_exception.dart | 7 ++----- .../no_active_skaking_entries_exception.dart | 11 ++++------- .../exceptions/not_enough_momentums_exception.dart | 7 ++----- 4 files changed, 11 insertions(+), 21 deletions(-) diff --git a/lib/rearchitecture/dashboard/balance/exceptions/no_balance_exception.dart b/lib/rearchitecture/dashboard/balance/exceptions/no_balance_exception.dart index 662358d8..aa51746a 100644 --- a/lib/rearchitecture/dashboard/balance/exceptions/no_balance_exception.dart +++ b/lib/rearchitecture/dashboard/balance/exceptions/no_balance_exception.dart @@ -1,13 +1,14 @@ import 'package:json_annotation/json_annotation.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; part 'no_balance_exception.g.dart'; /// Custom [Exception] used when there is no balance available on a specific /// address @JsonSerializable() -class NoBalanceException implements Exception { +class NoBalanceException extends DashboardCubitException { /// Creates a [NoBalanceException] instance - NoBalanceException(); + NoBalanceException(): super('Empty balance on the selected address'); /// Creates a [NoBalanceException] instance from a JSON map. factory NoBalanceException.fromJson(Map json) => @@ -16,6 +17,4 @@ class NoBalanceException implements Exception { /// Converts this [NoBalanceException] instance to a JSON map. Map toJson() => _$NoBalanceExceptionToJson(this); - @override - String toString() => 'Empty balance on the selected address'; } diff --git a/lib/rearchitecture/dashboard/realtime_statistics/exceptions/no_blocks_available_exception.dart b/lib/rearchitecture/dashboard/realtime_statistics/exceptions/no_blocks_available_exception.dart index 74574852..c64855be 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/exceptions/no_blocks_available_exception.dart +++ b/lib/rearchitecture/dashboard/realtime_statistics/exceptions/no_blocks_available_exception.dart @@ -6,9 +6,9 @@ part 'no_blocks_available_exception.g.dart'; /// Custom [Exception] to be used with [RealtimeStatisticsCubit] when there are /// no account blocks available on the network @JsonSerializable() -class NoBlocksAvailableException implements Exception { +class NoBlocksAvailableException extends DashboardCubitException { /// Creates a [NoBlocksAvailableException] instance - NoBlocksAvailableException(); + NoBlocksAvailableException(): super('No account blocks available'); /// Creates a [NoBlocksAvailableException] instance from a JSON map. factory NoBlocksAvailableException.fromJson(Map json) => @@ -17,7 +17,4 @@ class NoBlocksAvailableException implements Exception { /// Converts this [NoBlocksAvailableException] instance to a JSON map. Map toJson() => _$NoBlocksAvailableExceptionToJson(this); - - @override - String toString() => 'No account blocks available'; } diff --git a/lib/rearchitecture/dashboard/staking/exceptions/no_active_skaking_entries_exception.dart b/lib/rearchitecture/dashboard/staking/exceptions/no_active_skaking_entries_exception.dart index 607b6f07..6eadbad9 100644 --- a/lib/rearchitecture/dashboard/staking/exceptions/no_active_skaking_entries_exception.dart +++ b/lib/rearchitecture/dashboard/staking/exceptions/no_active_skaking_entries_exception.dart @@ -6,18 +6,15 @@ part 'no_active_skaking_entries_exception.g.dart'; /// Custom [Exception] to be used with [StakingCubit] when there are /// no active staking entries found on an address @JsonSerializable() -class NoActiveStakingEntriesException implements Exception { +class NoActiveStakingEntriesException extends DashboardCubitException { /// Creates a [NoActiveStakingEntriesException] instance - NoActiveStakingEntriesException(); + NoActiveStakingEntriesException() : super('No active staking entries'); /// Creates a [NoActiveStakingEntriesException] instance from a JSON map. factory NoActiveStakingEntriesException.fromJson(Map json) => _$NoActiveStakingEntriesExceptionFromJson(json); - /// Converts this [NoActiveStakingEntriesException] instance to a JSON map. - Map toJson() => _$NoActiveStakingEntriesExceptionToJson(this); - - @override - String toString() => 'No active staking entries'; + Map toJson() => + _$NoActiveStakingEntriesExceptionToJson(this); } diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/not_enough_momentums_exception.dart b/lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/not_enough_momentums_exception.dart index 687212e6..716c1a1c 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/not_enough_momentums_exception.dart +++ b/lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/not_enough_momentums_exception.dart @@ -6,9 +6,9 @@ part 'not_enough_momentums_exception.g.dart'; /// Custom [Exception] to be used with [TotalHourlyTransactionsCubit] when /// the network is less than one hour old @JsonSerializable() -class NotEnoughMomentumsException implements Exception { +class NotEnoughMomentumsException extends DashboardCubitException { /// Creates a [NotEnoughMomentumsException] instance - NotEnoughMomentumsException(); + NotEnoughMomentumsException(): super('Not enough momentums'); /// Creates a [NotEnoughMomentumsException] instance from a JSON map. factory NotEnoughMomentumsException.fromJson(Map json) => @@ -17,7 +17,4 @@ class NotEnoughMomentumsException implements Exception { /// Converts this [NotEnoughMomentumsException] instance to a JSON map. Map toJson() => _$NotEnoughMomentumsExceptionToJson(this); - - @override - String toString() => 'Not enough momentums'; } From 3d30b3b796971a705a2c159a17d3ba91119cc56f Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Sun, 27 Oct 2024 17:55:12 +0200 Subject: [PATCH 049/102] refactor: Restructure new code in a single folder --- .../dashboard/dashboard_cubit_exception.dart | 10 ------- .../balance/balance.dart | 0 .../balance/cubit/balance_cubit.dart | 7 +++-- .../balance/cubit/balance_cubit.g.dart | 20 +++++++------- .../balance/cubit/balance_state.dart | 10 +++---- .../balance/exceptions/exceptions.dart | 0 .../exceptions/no_balance_exception.dart | 4 +-- .../exceptions/no_balance_exception.g.dart | 0 .../balance/view/balance_card.dart | 15 ++++++----- .../balance/widgets/balance_address.dart | 0 .../balance/widgets/balance_chart.dart | 0 .../balance/widgets/balance_chart_legend.dart | 1 - .../balance/widgets/balance_empty.dart | 4 +-- .../balance/widgets/balance_error.dart | 2 +- .../balance/widgets/balance_loading.dart | 4 +-- .../balance/widgets/balance_populated.dart | 2 +- .../balance/widgets/widgets.dart | 0 .../delegation/cubit/delegation_cubit.dart | 6 ++--- .../delegation/cubit/delegation_cubit.g.dart | 20 +++++++------- .../delegation/cubit/delegation_state.dart | 6 ++--- .../delegation/delegation.dart | 0 .../delegation/exceptions/exceptions.dart | 0 .../no_delegation_stats_exception.dart | 4 +-- .../no_delegation_stats_exception.g.dart | 0 .../delegation/view/delegation_card.dart | 15 +++++------ .../delegation/widgets/delegation_empty.dart | 2 +- .../delegation/widgets/delegation_error.dart | 2 +- .../widgets/delegation_loading.dart | 0 .../widgets/delegation_populated.dart | 0 .../delegation/widgets/widgets.dart | 0 .../cubit/dual_coin_stats_cubit.dart | 7 +++-- .../cubit/dual_coin_stats_cubit.g.dart | 20 +++++++------- .../cubit/dual_coin_stats_state.dart | 6 ++--- .../dual_coin_stats/dual_coin_stats.dart | 0 .../view/dual_coin_stats_card.dart | 17 ++++++------ .../widgets/dual_coin_stats_chart.dart | 0 .../widgets/dual_coin_stats_chart_legend.dart | 2 +- .../dual_coin_stats_chart_legend_item.dart | 0 .../widgets/dual_coin_stats_empty.dart | 6 ++--- .../widgets/dual_coin_stats_error.dart | 6 ++--- .../widgets/dual_coin_stats_loading.dart | 4 +-- .../widgets/dual_coin_stats_populated.dart | 4 +-- .../dual_coin_stats/widgets/widgets.dart | 0 .../dashboard.dart => features/features.dart} | 2 -- .../pillars/cubit/pillars_cubit.dart | 5 ++-- .../pillars/cubit/pillars_cubit.g.dart | 20 +++++++------- .../pillars/cubit/pillars_state.dart | 6 ++--- .../pillars/pillars.dart | 0 .../pillars/view/pillars_card.dart | 17 ++++++------ .../pillars/widgets/pillars_empty.dart | 6 ++--- .../pillars/widgets/pillars_error.dart | 6 ++--- .../pillars/widgets/pillars_loading.dart | 4 +-- .../pillars/widgets/pillars_populated.dart | 4 +-- .../pillars/widgets/widgets.dart | 0 .../cubit/realtime_statistics_cubit.dart | 6 ++--- .../cubit/realtime_statistics_cubit.g.dart | 20 +++++++------- .../cubit/realtime_statistics_state.dart | 8 +++--- .../exceptions/exceptions.dart | 0 .../no_blocks_available_exception.dart | 5 ++-- .../no_blocks_available_exception.g.dart | 0 .../realtime_statistics.dart | 0 .../view/realtime_statistics_card.dart | 17 ++++++------ .../widgets/realtime_statistics_empty.dart | 2 +- .../widgets/realtime_statistics_error.dart | 2 +- .../widgets/realtime_statistics_loading.dart | 0 .../realtime_statistics_populated.dart | 6 +++-- .../widgets/realtime_txs_chart.dart | 0 .../realtime_statistics/widgets/widgets.dart | 0 .../sentinels/cubit/sentinels_cubit.dart | 5 ++-- .../sentinels/cubit/sentinels_cubit.g.dart | 20 +++++++------- .../sentinels/cubit/sentinels_state.dart | 6 ++--- .../sentinels/sentinels.dart | 0 .../sentinels/view/sentinels_card.dart | 17 ++++++------ .../sentinels/widgets/sentinels_empty.dart | 6 ++--- .../sentinels/widgets/sentinels_error.dart | 6 ++--- .../sentinels/widgets/sentinels_loading.dart | 4 +-- .../widgets/sentinels_populated.dart | 4 +-- .../sentinels/widgets/widgets.dart | 0 .../staking/cubit/staking_cubit.dart | 6 ++--- .../staking/cubit/staking_cubit.g.dart | 20 +++++++------- .../staking/cubit/staking_state.dart | 6 ++--- .../staking/exceptions/exceptions.dart | 0 .../no_active_skaking_entries_exception.dart | 5 ++-- ...no_active_skaking_entries_exception.g.dart | 0 .../staking/staking.dart | 0 .../staking/view/staking_card.dart | 17 ++++++------ .../staking/widgets/staking_empty.dart | 6 ++--- .../staking/widgets/staking_error.dart | 6 ++--- .../staking/widgets/staking_loading.dart | 4 +-- .../staking/widgets/staking_populated.dart | 5 ++-- .../staking/widgets/widgets.dart | 0 .../total_hourly_transactions_cubit.dart | 9 ++++--- .../total_hourly_transactions_cubit.g.dart | 20 +++++++------- .../total_hourly_transactions_state.dart | 6 ++--- .../exceptions/exceptions.dart | 0 .../not_enough_momentums_exception.dart | 5 ++-- .../not_enough_momentums_exception.g.dart | 0 .../total_hourly_transactions.dart | 0 .../view/total_hourly_transactions_card.dart | 17 ++++++------ .../total_hourly_transactions_empty.dart | 6 ++--- .../total_hourly_transactions_error.dart | 6 ++--- .../total_hourly_transactions_loading.dart | 4 +-- .../total_hourly_transactions_populated.dart | 6 +++-- .../widgets/widgets.dart | 0 .../transfer/transfer.dart | 0 .../transfer/view/transfer_card.dart | 2 +- .../cubit/node_sync_status_cubit.dart | 6 ++--- .../cubit/node_sync_status_cubit.g.dart | 20 +++++++------- .../cubit/node_sync_status_state.dart | 6 ++--- .../view/node_sync_status_icon.dart | 12 ++++----- .../widgets/node_sync_status_empty.dart | 3 +-- .../widgets/node_sync_status_error.dart | 5 ++-- .../widgets/node_sync_status_loading.dart | 3 +-- .../widgets/node_sync_status_populated.dart | 4 +-- lib/rearchitecture/rearchitecture.dart | 2 ++ lib/rearchitecture/utils/cubits/cubits.dart | 1 + .../cubits/timer_cubit.dart} | 22 +++++++--------- .../cubits/timer_state.dart} | 26 +++++++++---------- .../utils/exceptions/cubit_exception.dart | 10 +++++++ .../exceptions/cubit_failure_exception.dart | 2 +- .../exceptions/cubit_failure_exception.g.dart | 0 .../utils/exceptions/exceptions.dart | 1 + .../utils/exceptions/syrius_exception.dart | 24 +++++++++++++++++ .../utils/exceptions/syrius_exception.g.dart | 17 ++++++++++++ .../extensions/buildcontext_extension.dart | 8 ++++++ .../utils/extensions/extensions.dart | 2 ++ .../extensions/sync_state_extension.dart | 16 ++++++++++++ .../utils/models}/card/card.dart | 0 .../utils/models}/card/card_data.dart | 0 .../utils/models}/card/card_type.dart | 4 +-- lib/rearchitecture/utils/models/models.dart | 1 + lib/rearchitecture/utils/utils.dart | 5 ++++ .../card_scaffold_without_listener.dart | 1 + lib/rearchitecture/utils/widgets/widgets.dart | 1 + lib/utils/exceptions/syrius_exception.dart | 11 -------- lib/utils/extensions.dart | 21 +-------------- lib/utils/utils.dart | 2 -- .../layout_scaffold/layout_scaffold.dart | 1 - .../dashboard_tab_child.dart | 2 +- lib/widgets/widgets.dart | 1 - .../cubit/delegation_cubit_test.dart | 8 +++--- 141 files changed, 440 insertions(+), 374 deletions(-) delete mode 100644 lib/rearchitecture/dashboard/dashboard_cubit_exception.dart rename lib/rearchitecture/{dashboard => features}/balance/balance.dart (100%) rename lib/rearchitecture/{dashboard => features}/balance/cubit/balance_cubit.dart (85%) rename lib/rearchitecture/{dashboard => features}/balance/cubit/balance_cubit.g.dart (57%) rename lib/rearchitecture/{dashboard => features}/balance/cubit/balance_state.dart (84%) rename lib/rearchitecture/{dashboard => features}/balance/exceptions/exceptions.dart (100%) rename lib/rearchitecture/{dashboard => features}/balance/exceptions/no_balance_exception.dart (81%) rename lib/rearchitecture/{dashboard => features}/balance/exceptions/no_balance_exception.g.dart (100%) rename lib/rearchitecture/{dashboard => features}/balance/view/balance_card.dart (72%) rename lib/rearchitecture/{dashboard => features}/balance/widgets/balance_address.dart (100%) rename lib/rearchitecture/{dashboard => features}/balance/widgets/balance_chart.dart (100%) rename lib/rearchitecture/{dashboard => features}/balance/widgets/balance_chart_legend.dart (93%) rename lib/rearchitecture/{dashboard => features}/balance/widgets/balance_empty.dart (79%) rename lib/rearchitecture/{dashboard => features}/balance/widgets/balance_error.dart (87%) rename lib/rearchitecture/{dashboard => features}/balance/widgets/balance_loading.dart (77%) rename lib/rearchitecture/{dashboard => features}/balance/widgets/balance_populated.dart (97%) rename lib/rearchitecture/{dashboard => features}/balance/widgets/widgets.dart (100%) rename lib/rearchitecture/{dashboard => features}/delegation/cubit/delegation_cubit.dart (86%) rename lib/rearchitecture/{dashboard => features}/delegation/cubit/delegation_cubit.g.dart (58%) rename lib/rearchitecture/{dashboard => features}/delegation/cubit/delegation_state.dart (90%) rename lib/rearchitecture/{dashboard => features}/delegation/delegation.dart (100%) rename lib/rearchitecture/{dashboard => features}/delegation/exceptions/exceptions.dart (100%) rename lib/rearchitecture/{dashboard => features}/delegation/exceptions/no_delegation_stats_exception.dart (79%) rename lib/rearchitecture/{dashboard => features}/delegation/exceptions/no_delegation_stats_exception.g.dart (100%) rename lib/rearchitecture/{dashboard => features}/delegation/view/delegation_card.dart (68%) rename lib/rearchitecture/{dashboard => features}/delegation/widgets/delegation_empty.dart (84%) rename lib/rearchitecture/{dashboard => features}/delegation/widgets/delegation_error.dart (86%) rename lib/rearchitecture/{dashboard => features}/delegation/widgets/delegation_loading.dart (100%) rename lib/rearchitecture/{dashboard => features}/delegation/widgets/delegation_populated.dart (100%) rename lib/rearchitecture/{dashboard => features}/delegation/widgets/widgets.dart (100%) rename lib/rearchitecture/{dashboard => features}/dual_coin_stats/cubit/dual_coin_stats_cubit.dart (84%) rename lib/rearchitecture/{dashboard => features}/dual_coin_stats/cubit/dual_coin_stats_cubit.g.dart (59%) rename lib/rearchitecture/{dashboard => features}/dual_coin_stats/cubit/dual_coin_stats_state.dart (92%) rename lib/rearchitecture/{dashboard => features}/dual_coin_stats/dual_coin_stats.dart (100%) rename lib/rearchitecture/{dashboard => features}/dual_coin_stats/view/dual_coin_stats_card.dart (63%) rename lib/rearchitecture/{dashboard => features}/dual_coin_stats/widgets/dual_coin_stats_chart.dart (100%) rename lib/rearchitecture/{dashboard => features}/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart (91%) rename lib/rearchitecture/{dashboard => features}/dual_coin_stats/widgets/dual_coin_stats_chart_legend_item.dart (100%) rename lib/rearchitecture/{dashboard => features}/dual_coin_stats/widgets/dual_coin_stats_empty.dart (66%) rename lib/rearchitecture/{dashboard => features}/dual_coin_stats/widgets/dual_coin_stats_error.dart (69%) rename lib/rearchitecture/{dashboard => features}/dual_coin_stats/widgets/dual_coin_stats_loading.dart (73%) rename lib/rearchitecture/{dashboard => features}/dual_coin_stats/widgets/dual_coin_stats_populated.dart (88%) rename lib/rearchitecture/{dashboard => features}/dual_coin_stats/widgets/widgets.dart (100%) rename lib/rearchitecture/{dashboard/dashboard.dart => features/features.dart} (83%) rename lib/rearchitecture/{dashboard => features}/pillars/cubit/pillars_cubit.dart (87%) rename lib/rearchitecture/{dashboard => features}/pillars/cubit/pillars_cubit.g.dart (54%) rename lib/rearchitecture/{dashboard => features}/pillars/cubit/pillars_state.dart (93%) rename lib/rearchitecture/{dashboard => features}/pillars/pillars.dart (100%) rename lib/rearchitecture/{dashboard => features}/pillars/view/pillars_card.dart (62%) rename lib/rearchitecture/{dashboard => features}/pillars/widgets/pillars_empty.dart (66%) rename lib/rearchitecture/{dashboard => features}/pillars/widgets/pillars_error.dart (68%) rename lib/rearchitecture/{dashboard => features}/pillars/widgets/pillars_loading.dart (72%) rename lib/rearchitecture/{dashboard => features}/pillars/widgets/pillars_populated.dart (88%) rename lib/rearchitecture/{dashboard => features}/pillars/widgets/widgets.dart (100%) rename lib/rearchitecture/{dashboard => features}/realtime_statistics/cubit/realtime_statistics_cubit.dart (94%) rename lib/rearchitecture/{dashboard => features}/realtime_statistics/cubit/realtime_statistics_cubit.g.dart (61%) rename lib/rearchitecture/{dashboard => features}/realtime_statistics/cubit/realtime_statistics_state.dart (88%) rename lib/rearchitecture/{dashboard => features}/realtime_statistics/exceptions/exceptions.dart (100%) rename lib/rearchitecture/{dashboard => features}/realtime_statistics/exceptions/no_blocks_available_exception.dart (75%) rename lib/rearchitecture/{dashboard => features}/realtime_statistics/exceptions/no_blocks_available_exception.g.dart (100%) rename lib/rearchitecture/{dashboard => features}/realtime_statistics/realtime_statistics.dart (100%) rename lib/rearchitecture/{dashboard => features}/realtime_statistics/view/realtime_statistics_card.dart (63%) rename lib/rearchitecture/{dashboard => features}/realtime_statistics/widgets/realtime_statistics_empty.dart (85%) rename lib/rearchitecture/{dashboard => features}/realtime_statistics/widgets/realtime_statistics_error.dart (87%) rename lib/rearchitecture/{dashboard => features}/realtime_statistics/widgets/realtime_statistics_loading.dart (100%) rename lib/rearchitecture/{dashboard => features}/realtime_statistics/widgets/realtime_statistics_populated.dart (83%) rename lib/rearchitecture/{dashboard => features}/realtime_statistics/widgets/realtime_txs_chart.dart (100%) rename lib/rearchitecture/{dashboard => features}/realtime_statistics/widgets/widgets.dart (100%) rename lib/rearchitecture/{dashboard => features}/sentinels/cubit/sentinels_cubit.dart (87%) rename lib/rearchitecture/{dashboard => features}/sentinels/cubit/sentinels_cubit.g.dart (58%) rename lib/rearchitecture/{dashboard => features}/sentinels/cubit/sentinels_state.dart (91%) rename lib/rearchitecture/{dashboard => features}/sentinels/sentinels.dart (100%) rename lib/rearchitecture/{dashboard => features}/sentinels/view/sentinels_card.dart (63%) rename lib/rearchitecture/{dashboard => features}/sentinels/widgets/sentinels_empty.dart (65%) rename lib/rearchitecture/{dashboard => features}/sentinels/widgets/sentinels_error.dart (68%) rename lib/rearchitecture/{dashboard => features}/sentinels/widgets/sentinels_loading.dart (72%) rename lib/rearchitecture/{dashboard => features}/sentinels/widgets/sentinels_populated.dart (89%) rename lib/rearchitecture/{dashboard => features}/sentinels/widgets/widgets.dart (100%) rename lib/rearchitecture/{dashboard => features}/staking/cubit/staking_cubit.dart (90%) rename lib/rearchitecture/{dashboard => features}/staking/cubit/staking_cubit.g.dart (57%) rename lib/rearchitecture/{dashboard => features}/staking/cubit/staking_state.dart (92%) rename lib/rearchitecture/{dashboard => features}/staking/exceptions/exceptions.dart (100%) rename lib/rearchitecture/{dashboard => features}/staking/exceptions/no_active_skaking_entries_exception.dart (75%) rename lib/rearchitecture/{dashboard => features}/staking/exceptions/no_active_skaking_entries_exception.g.dart (100%) rename lib/rearchitecture/{dashboard => features}/staking/staking.dart (100%) rename lib/rearchitecture/{dashboard => features}/staking/view/staking_card.dart (63%) rename lib/rearchitecture/{dashboard => features}/staking/widgets/staking_empty.dart (64%) rename lib/rearchitecture/{dashboard => features}/staking/widgets/staking_error.dart (69%) rename lib/rearchitecture/{dashboard => features}/staking/widgets/staking_loading.dart (71%) rename lib/rearchitecture/{dashboard => features}/staking/widgets/staking_populated.dart (89%) rename lib/rearchitecture/{dashboard => features}/staking/widgets/widgets.dart (100%) rename lib/rearchitecture/{dashboard => features}/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart (88%) rename lib/rearchitecture/{dashboard => features}/total_hourly_transactions/cubit/total_hourly_transactions_cubit.g.dart (59%) rename lib/rearchitecture/{dashboard => features}/total_hourly_transactions/cubit/total_hourly_transactions_state.dart (93%) rename lib/rearchitecture/{dashboard => features}/total_hourly_transactions/exceptions/exceptions.dart (100%) rename lib/rearchitecture/{dashboard => features}/total_hourly_transactions/exceptions/not_enough_momentums_exception.dart (75%) rename lib/rearchitecture/{dashboard => features}/total_hourly_transactions/exceptions/not_enough_momentums_exception.g.dart (100%) rename lib/rearchitecture/{dashboard => features}/total_hourly_transactions/total_hourly_transactions.dart (100%) rename lib/rearchitecture/{dashboard => features}/total_hourly_transactions/view/total_hourly_transactions_card.dart (63%) rename lib/rearchitecture/{dashboard => features}/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart (67%) rename lib/rearchitecture/{dashboard => features}/total_hourly_transactions/widgets/total_hourly_transactions_error.dart (71%) rename lib/rearchitecture/{dashboard => features}/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart (75%) rename lib/rearchitecture/{dashboard => features}/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart (76%) rename lib/rearchitecture/{dashboard => features}/total_hourly_transactions/widgets/widgets.dart (100%) rename lib/rearchitecture/{dashboard => features}/transfer/transfer.dart (100%) rename lib/rearchitecture/{dashboard => features}/transfer/view/transfer_card.dart (96%) create mode 100644 lib/rearchitecture/rearchitecture.dart create mode 100644 lib/rearchitecture/utils/cubits/cubits.dart rename lib/rearchitecture/{dashboard/dashboard_cubit.dart => utils/cubits/timer_cubit.dart} (82%) rename lib/rearchitecture/{dashboard/dashboard_state.dart => utils/cubits/timer_state.dart} (75%) create mode 100644 lib/rearchitecture/utils/exceptions/cubit_exception.dart rename lib/{ => rearchitecture}/utils/exceptions/cubit_failure_exception.dart (90%) rename lib/{ => rearchitecture}/utils/exceptions/cubit_failure_exception.g.dart (100%) rename lib/{ => rearchitecture}/utils/exceptions/exceptions.dart (69%) create mode 100644 lib/rearchitecture/utils/exceptions/syrius_exception.dart create mode 100644 lib/rearchitecture/utils/exceptions/syrius_exception.g.dart create mode 100644 lib/rearchitecture/utils/extensions/buildcontext_extension.dart create mode 100644 lib/rearchitecture/utils/extensions/extensions.dart create mode 100644 lib/rearchitecture/utils/extensions/sync_state_extension.dart rename lib/{utils => rearchitecture/utils/models}/card/card.dart (100%) rename lib/{utils => rearchitecture/utils/models}/card/card_data.dart (100%) rename lib/{utils => rearchitecture/utils/models}/card/card_type.dart (92%) create mode 100644 lib/rearchitecture/utils/models/models.dart create mode 100644 lib/rearchitecture/utils/utils.dart rename lib/{widgets/reusable_widgets/layout_scaffold => rearchitecture/utils/widgets}/card_scaffold_without_listener.dart (99%) create mode 100644 lib/rearchitecture/utils/widgets/widgets.dart delete mode 100644 lib/utils/exceptions/syrius_exception.dart diff --git a/lib/rearchitecture/dashboard/dashboard_cubit_exception.dart b/lib/rearchitecture/dashboard/dashboard_cubit_exception.dart deleted file mode 100644 index 5619db8a..00000000 --- a/lib/rearchitecture/dashboard/dashboard_cubit_exception.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:zenon_syrius_wallet_flutter/utils/exceptions/exceptions.dart'; - -/// A custom exception that displays only the message when printed. -/// -/// To be used to create custom exceptions in a specific case that we -/// are aware about - so that we can add a corresponding message -abstract class DashboardCubitException extends SyriusException { - /// Creates a [DashboardCubitException] with a required message. - DashboardCubitException(super.message); -} diff --git a/lib/rearchitecture/dashboard/balance/balance.dart b/lib/rearchitecture/features/balance/balance.dart similarity index 100% rename from lib/rearchitecture/dashboard/balance/balance.dart rename to lib/rearchitecture/features/balance/balance.dart diff --git a/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart b/lib/rearchitecture/features/balance/cubit/balance_cubit.dart similarity index 85% rename from lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart rename to lib/rearchitecture/features/balance/cubit/balance_cubit.dart index 18569b25..fac5cf85 100644 --- a/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.dart +++ b/lib/rearchitecture/features/balance/cubit/balance_cubit.dart @@ -1,16 +1,15 @@ import 'package:json_annotation/json_annotation.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'balance_cubit.g.dart'; - part 'balance_state.dart'; /// A cubit that is responsible for managing and fetching the account balance /// of the provided [address]. -class BalanceCubit extends DashboardCubit { +class BalanceCubit extends TimerCubit { /// Constructs a BalanceCubit with the provided [zenon] client, [address] and /// [initialState]. BalanceCubit(this.address, super.zenon, super.initialState); diff --git a/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.g.dart b/lib/rearchitecture/features/balance/cubit/balance_cubit.g.dart similarity index 57% rename from lib/rearchitecture/dashboard/balance/cubit/balance_cubit.g.dart rename to lib/rearchitecture/features/balance/cubit/balance_cubit.g.dart index aa26e513..135e1114 100644 --- a/lib/rearchitecture/dashboard/balance/cubit/balance_cubit.g.dart +++ b/lib/rearchitecture/features/balance/cubit/balance_cubit.g.dart @@ -7,24 +7,26 @@ part of 'balance_cubit.dart'; // ************************************************************************** BalanceState _$BalanceStateFromJson(Map json) => BalanceState( - status: $enumDecodeNullable(_$DashboardStatusEnumMap, json['status']) ?? - DashboardStatus.initial, + status: $enumDecodeNullable(_$TimerStatusEnumMap, json['status']) ?? + TimerStatus.initial, data: json['data'] == null ? null : AccountInfo.fromJson(json['data'] as Map), - error: json['error'], + error: json['error'] == null + ? null + : SyriusException.fromJson(json['error'] as Map), ); Map _$BalanceStateToJson(BalanceState instance) => { - 'status': _$DashboardStatusEnumMap[instance.status]!, + 'status': _$TimerStatusEnumMap[instance.status]!, 'data': instance.data, 'error': instance.error, }; -const _$DashboardStatusEnumMap = { - DashboardStatus.failure: 'failure', - DashboardStatus.initial: 'initial', - DashboardStatus.loading: 'loading', - DashboardStatus.success: 'success', +const _$TimerStatusEnumMap = { + TimerStatus.failure: 'failure', + TimerStatus.initial: 'initial', + TimerStatus.loading: 'loading', + TimerStatus.success: 'success', }; diff --git a/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart b/lib/rearchitecture/features/balance/cubit/balance_state.dart similarity index 84% rename from lib/rearchitecture/dashboard/balance/cubit/balance_state.dart rename to lib/rearchitecture/features/balance/cubit/balance_state.dart index f697a65c..73f8b979 100644 --- a/lib/rearchitecture/dashboard/balance/cubit/balance_state.dart +++ b/lib/rearchitecture/features/balance/cubit/balance_state.dart @@ -3,14 +3,14 @@ part of 'balance_cubit.dart'; /// The class used by the [BalanceCubit] to send state updates to the /// listening widgets. /// -/// The data hold, when the status is [DashboardStatus.success] is of type +/// The data hold, when the status is [TimerStatus.success] is of type /// [AccountInfo]. @JsonSerializable() -class BalanceState extends DashboardState { +class BalanceState extends TimerState { /// Constructs a new BalanceState. /// /// This state uses the default [status], [data], and [error] from the parent - /// [DashboardState] class + /// [TimerState] class const BalanceState({ super.status, super.data, @@ -31,8 +31,8 @@ class BalanceState extends DashboardState { /// - A new instance of [BalanceState] with the updated values or the /// existing ones if none are provided. @override - DashboardState copyWith({ - DashboardStatus? status, + TimerState copyWith({ + TimerStatus? status, AccountInfo? data, SyriusException? error, }) { diff --git a/lib/rearchitecture/dashboard/balance/exceptions/exceptions.dart b/lib/rearchitecture/features/balance/exceptions/exceptions.dart similarity index 100% rename from lib/rearchitecture/dashboard/balance/exceptions/exceptions.dart rename to lib/rearchitecture/features/balance/exceptions/exceptions.dart diff --git a/lib/rearchitecture/dashboard/balance/exceptions/no_balance_exception.dart b/lib/rearchitecture/features/balance/exceptions/no_balance_exception.dart similarity index 81% rename from lib/rearchitecture/dashboard/balance/exceptions/no_balance_exception.dart rename to lib/rearchitecture/features/balance/exceptions/no_balance_exception.dart index aa51746a..51a18278 100644 --- a/lib/rearchitecture/dashboard/balance/exceptions/no_balance_exception.dart +++ b/lib/rearchitecture/features/balance/exceptions/no_balance_exception.dart @@ -1,12 +1,12 @@ import 'package:json_annotation/json_annotation.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/exceptions/exceptions.dart'; part 'no_balance_exception.g.dart'; /// Custom [Exception] used when there is no balance available on a specific /// address @JsonSerializable() -class NoBalanceException extends DashboardCubitException { +class NoBalanceException extends CubitException { /// Creates a [NoBalanceException] instance NoBalanceException(): super('Empty balance on the selected address'); diff --git a/lib/rearchitecture/dashboard/balance/exceptions/no_balance_exception.g.dart b/lib/rearchitecture/features/balance/exceptions/no_balance_exception.g.dart similarity index 100% rename from lib/rearchitecture/dashboard/balance/exceptions/no_balance_exception.g.dart rename to lib/rearchitecture/features/balance/exceptions/no_balance_exception.g.dart diff --git a/lib/rearchitecture/dashboard/balance/view/balance_card.dart b/lib/rearchitecture/features/balance/view/balance_card.dart similarity index 72% rename from lib/rearchitecture/dashboard/balance/view/balance_card.dart rename to lib/rearchitecture/features/balance/view/balance_card.dart index dc15825a..2c0d9b69 100644 --- a/lib/rearchitecture/dashboard/balance/view/balance_card.dart +++ b/lib/rearchitecture/features/balance/view/balance_card.dart @@ -1,10 +1,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/card/card.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/widgets/card_scaffold_without_listener.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// A `BalanceCard` widget that displays balance information for a user. @@ -35,12 +36,12 @@ class BalanceCard extends StatelessWidget { body: BlocBuilder( builder: (context, state) { return switch (state.status) { - DashboardStatus.initial => const BalanceEmpty(), - DashboardStatus.loading => const BalanceLoading(), - DashboardStatus.failure => BalanceError( + TimerStatus.initial => const BalanceEmpty(), + TimerStatus.loading => const BalanceLoading(), + TimerStatus.failure => BalanceError( error: state.error!, ), - DashboardStatus.success => BalancePopulated( + TimerStatus.success => BalancePopulated( address: kSelectedAddress!, accountInfo: state.data!, ), diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_address.dart b/lib/rearchitecture/features/balance/widgets/balance_address.dart similarity index 100% rename from lib/rearchitecture/dashboard/balance/widgets/balance_address.dart rename to lib/rearchitecture/features/balance/widgets/balance_address.dart diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_chart.dart b/lib/rearchitecture/features/balance/widgets/balance_chart.dart similarity index 100% rename from lib/rearchitecture/dashboard/balance/widgets/balance_chart.dart rename to lib/rearchitecture/features/balance/widgets/balance_chart.dart diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_chart_legend.dart b/lib/rearchitecture/features/balance/widgets/balance_chart_legend.dart similarity index 93% rename from lib/rearchitecture/dashboard/balance/widgets/balance_chart_legend.dart rename to lib/rearchitecture/features/balance/widgets/balance_chart_legend.dart index 86d644d3..443b03d3 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_chart_legend.dart +++ b/lib/rearchitecture/features/balance/widgets/balance_chart_legend.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/balance/widgets/balance_chart.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart b/lib/rearchitecture/features/balance/widgets/balance_empty.dart similarity index 79% rename from lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart rename to lib/rearchitecture/features/balance/widgets/balance_empty.dart index f394fe0d..d72abdd4 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_empty.dart +++ b/lib/rearchitecture/features/balance/widgets/balance_empty.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/balance/balance.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/balance/balance.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A [BalanceEmpty] widget that displays a simple message indicating that there diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_error.dart b/lib/rearchitecture/features/balance/widgets/balance_error.dart similarity index 87% rename from lib/rearchitecture/dashboard/balance/widgets/balance_error.dart rename to lib/rearchitecture/features/balance/widgets/balance_error.dart index dfb83f58..110a4f80 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_error.dart +++ b/lib/rearchitecture/features/balance/widgets/balance_error.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/exceptions/exceptions.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/exceptions/exceptions.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; /// A [BalanceError] widget that displays an error message when the balance diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_loading.dart b/lib/rearchitecture/features/balance/widgets/balance_loading.dart similarity index 77% rename from lib/rearchitecture/dashboard/balance/widgets/balance_loading.dart rename to lib/rearchitecture/features/balance/widgets/balance_loading.dart index 84239dc9..1858ef33 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_loading.dart +++ b/lib/rearchitecture/features/balance/widgets/balance_loading.dart @@ -1,12 +1,12 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; /// A widget that displays a loading message while the balance data is being /// fetched. /// /// This widget is shown when the [BalanceCubit] sends a [BalanceState] update -/// with a status of [DashboardStatus.loading], indicating that the balance +/// with a status of [TimerStatus.loading], indicating that the balance /// data is currently being loaded. class BalanceLoading extends StatelessWidget { /// Creates a BalanceLoading object. diff --git a/lib/rearchitecture/dashboard/balance/widgets/balance_populated.dart b/lib/rearchitecture/features/balance/widgets/balance_populated.dart similarity index 97% rename from lib/rearchitecture/dashboard/balance/widgets/balance_populated.dart rename to lib/rearchitecture/features/balance/widgets/balance_populated.dart index fa10f093..226d62f3 100644 --- a/lib/rearchitecture/dashboard/balance/widgets/balance_populated.dart +++ b/lib/rearchitecture/features/balance/widgets/balance_populated.dart @@ -1,6 +1,6 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/balance/balance.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/balance/balance.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/rearchitecture/dashboard/balance/widgets/widgets.dart b/lib/rearchitecture/features/balance/widgets/widgets.dart similarity index 100% rename from lib/rearchitecture/dashboard/balance/widgets/widgets.dart rename to lib/rearchitecture/features/balance/widgets/widgets.dart diff --git a/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart b/lib/rearchitecture/features/delegation/cubit/delegation_cubit.dart similarity index 86% rename from lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart rename to lib/rearchitecture/features/delegation/cubit/delegation_cubit.dart index 30ab6e67..9bcd10d2 100644 --- a/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.dart +++ b/lib/rearchitecture/features/delegation/cubit/delegation_cubit.dart @@ -1,6 +1,6 @@ import 'package:json_annotation/json_annotation.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'delegation_cubit.g.dart'; @@ -8,7 +8,7 @@ part 'delegation_state.dart'; /// A cubit that manages the fetching and state of delegation information /// for a specific account. -class DelegationCubit extends DashboardCubit { +class DelegationCubit extends TimerCubit { /// Constructs a DelegationCubit object, passing the [zenon] client and the /// initial state to the parent class. /// diff --git a/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.g.dart b/lib/rearchitecture/features/delegation/cubit/delegation_cubit.g.dart similarity index 58% rename from lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.g.dart rename to lib/rearchitecture/features/delegation/cubit/delegation_cubit.g.dart index aef4a723..fb3938f9 100644 --- a/lib/rearchitecture/dashboard/delegation/cubit/delegation_cubit.g.dart +++ b/lib/rearchitecture/features/delegation/cubit/delegation_cubit.g.dart @@ -8,24 +8,26 @@ part of 'delegation_cubit.dart'; DelegationState _$DelegationStateFromJson(Map json) => DelegationState( - status: $enumDecodeNullable(_$DashboardStatusEnumMap, json['status']) ?? - DashboardStatus.initial, + status: $enumDecodeNullable(_$TimerStatusEnumMap, json['status']) ?? + TimerStatus.initial, data: json['data'] == null ? null : DelegationInfo.fromJson(json['data'] as Map), - error: json['error'], + error: json['error'] == null + ? null + : SyriusException.fromJson(json['error'] as Map), ); Map _$DelegationStateToJson(DelegationState instance) => { - 'status': _$DashboardStatusEnumMap[instance.status]!, + 'status': _$TimerStatusEnumMap[instance.status]!, 'data': instance.data, 'error': instance.error, }; -const _$DashboardStatusEnumMap = { - DashboardStatus.failure: 'failure', - DashboardStatus.initial: 'initial', - DashboardStatus.loading: 'loading', - DashboardStatus.success: 'success', +const _$TimerStatusEnumMap = { + TimerStatus.failure: 'failure', + TimerStatus.initial: 'initial', + TimerStatus.loading: 'loading', + TimerStatus.success: 'success', }; diff --git a/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart b/lib/rearchitecture/features/delegation/cubit/delegation_state.dart similarity index 90% rename from lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart rename to lib/rearchitecture/features/delegation/cubit/delegation_state.dart index e6a9cf03..05183d75 100644 --- a/lib/rearchitecture/dashboard/delegation/cubit/delegation_state.dart +++ b/lib/rearchitecture/features/delegation/cubit/delegation_state.dart @@ -6,7 +6,7 @@ part of 'delegation_cubit.dart'; /// details. @JsonSerializable() -class DelegationState extends DashboardState { +class DelegationState extends TimerState { /// Constructs a new DelegationState object. /// /// This state is initialized with default [status], [data], and [error] @@ -28,8 +28,8 @@ class DelegationState extends DashboardState { /// This method is used to create a new state with updated fields if provided, /// otherwise retaining the existing values. @override - DashboardState copyWith({ - DashboardStatus? status, + TimerState copyWith({ + TimerStatus? status, DelegationInfo? data, SyriusException? error, }) { diff --git a/lib/rearchitecture/dashboard/delegation/delegation.dart b/lib/rearchitecture/features/delegation/delegation.dart similarity index 100% rename from lib/rearchitecture/dashboard/delegation/delegation.dart rename to lib/rearchitecture/features/delegation/delegation.dart diff --git a/lib/rearchitecture/dashboard/delegation/exceptions/exceptions.dart b/lib/rearchitecture/features/delegation/exceptions/exceptions.dart similarity index 100% rename from lib/rearchitecture/dashboard/delegation/exceptions/exceptions.dart rename to lib/rearchitecture/features/delegation/exceptions/exceptions.dart diff --git a/lib/rearchitecture/dashboard/delegation/exceptions/no_delegation_stats_exception.dart b/lib/rearchitecture/features/delegation/exceptions/no_delegation_stats_exception.dart similarity index 79% rename from lib/rearchitecture/dashboard/delegation/exceptions/no_delegation_stats_exception.dart rename to lib/rearchitecture/features/delegation/exceptions/no_delegation_stats_exception.dart index 105f28a0..7b4543c7 100644 --- a/lib/rearchitecture/dashboard/delegation/exceptions/no_delegation_stats_exception.dart +++ b/lib/rearchitecture/features/delegation/exceptions/no_delegation_stats_exception.dart @@ -1,11 +1,11 @@ import 'package:json_annotation/json_annotation.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard_cubit_exception.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; part 'no_delegation_stats_exception.g.dart'; /// Custom [Exception] used when there are no delegation info available @JsonSerializable() -class NoDelegationStatsException extends DashboardCubitException { +class NoDelegationStatsException extends CubitException { /// Creates a [NoDelegationStatsException] instance NoDelegationStatsException(): super('No delegation stats available'); diff --git a/lib/rearchitecture/dashboard/delegation/exceptions/no_delegation_stats_exception.g.dart b/lib/rearchitecture/features/delegation/exceptions/no_delegation_stats_exception.g.dart similarity index 100% rename from lib/rearchitecture/dashboard/delegation/exceptions/no_delegation_stats_exception.g.dart rename to lib/rearchitecture/features/delegation/exceptions/no_delegation_stats_exception.g.dart diff --git a/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart b/lib/rearchitecture/features/delegation/view/delegation_card.dart similarity index 68% rename from lib/rearchitecture/dashboard/delegation/view/delegation_card.dart rename to lib/rearchitecture/features/delegation/view/delegation_card.dart index c12d70ef..aef9f67f 100644 --- a/lib/rearchitecture/dashboard/delegation/view/delegation_card.dart +++ b/lib/rearchitecture/features/delegation/view/delegation_card.dart @@ -1,14 +1,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/card/card.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// A card that receives [DelegationState] updates from the [DelegationCubit] -/// and changes the UI according to the request status - [DashboardStatus] +/// and changes the UI according to the request status - [TimerStatus] class DelegationCard extends StatelessWidget { /// Creates a DelegationCard object. const DelegationCard({super.key}); @@ -29,12 +28,12 @@ class DelegationCard extends StatelessWidget { body: BlocBuilder( builder: (context, state) { return switch (state.status) { - DashboardStatus.initial => const DelegationEmpty(), - DashboardStatus.loading => const DelegationLoading(), - DashboardStatus.failure => DelegationError( + TimerStatus.initial => const DelegationEmpty(), + TimerStatus.loading => const DelegationLoading(), + TimerStatus.failure => DelegationError( error: state.error!, ), - DashboardStatus.success => DelegationPopulated( + TimerStatus.success => DelegationPopulated( delegationInfo: state.data!, ), }; diff --git a/lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart b/lib/rearchitecture/features/delegation/widgets/delegation_empty.dart similarity index 84% rename from lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart rename to lib/rearchitecture/features/delegation/widgets/delegation_empty.dart index bcafe9f8..6c3fe667 100644 --- a/lib/rearchitecture/dashboard/delegation/widgets/delegation_empty.dart +++ b/lib/rearchitecture/features/delegation/widgets/delegation_empty.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; /// A widget that displays a hardcoded error message diff --git a/lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart b/lib/rearchitecture/features/delegation/widgets/delegation_error.dart similarity index 86% rename from lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart rename to lib/rearchitecture/features/delegation/widgets/delegation_error.dart index 6f2a9c07..ea41e042 100644 --- a/lib/rearchitecture/dashboard/delegation/widgets/delegation_error.dart +++ b/lib/rearchitecture/features/delegation/widgets/delegation_error.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; /// A widget that display the [error] message diff --git a/lib/rearchitecture/dashboard/delegation/widgets/delegation_loading.dart b/lib/rearchitecture/features/delegation/widgets/delegation_loading.dart similarity index 100% rename from lib/rearchitecture/dashboard/delegation/widgets/delegation_loading.dart rename to lib/rearchitecture/features/delegation/widgets/delegation_loading.dart diff --git a/lib/rearchitecture/dashboard/delegation/widgets/delegation_populated.dart b/lib/rearchitecture/features/delegation/widgets/delegation_populated.dart similarity index 100% rename from lib/rearchitecture/dashboard/delegation/widgets/delegation_populated.dart rename to lib/rearchitecture/features/delegation/widgets/delegation_populated.dart diff --git a/lib/rearchitecture/dashboard/delegation/widgets/widgets.dart b/lib/rearchitecture/features/delegation/widgets/widgets.dart similarity index 100% rename from lib/rearchitecture/dashboard/delegation/widgets/widgets.dart rename to lib/rearchitecture/features/delegation/widgets/widgets.dart diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart b/lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_cubit.dart similarity index 84% rename from lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart rename to lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_cubit.dart index acba6ac3..0862df9a 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.dart +++ b/lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_cubit.dart @@ -1,6 +1,5 @@ import 'package:json_annotation/json_annotation.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'dual_coin_stats_cubit.g.dart'; @@ -10,11 +9,11 @@ part 'dual_coin_stats_state.dart'; /// A cubit that manages the fetching and state of dual coin statistics /// for ZNN and QSR tokens. /// -/// This cubit extends [DashboardCubit], using a list of [Token] objects to +/// This cubit extends [TimerCubit], using a list of [Token] objects to /// represent the statistics for the ZNN and QSR tokens fetched from the Zenon /// network. class DualCoinStatsCubit - extends DashboardCubit, DualCoinStatsState> { + extends TimerCubit, DualCoinStatsState> { /// Constructs a [DualCoinStatsCubit], passing the [zenon] client and the /// initial state to the parent class. /// diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.g.dart b/lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_cubit.g.dart similarity index 59% rename from lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.g.dart rename to lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_cubit.g.dart index 651b6a45..ec159c20 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_cubit.g.dart +++ b/lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_cubit.g.dart @@ -8,24 +8,26 @@ part of 'dual_coin_stats_cubit.dart'; DualCoinStatsState _$DualCoinStatsStateFromJson(Map json) => DualCoinStatsState( - status: $enumDecodeNullable(_$DashboardStatusEnumMap, json['status']) ?? - DashboardStatus.initial, + status: $enumDecodeNullable(_$TimerStatusEnumMap, json['status']) ?? + TimerStatus.initial, data: (json['data'] as List?) ?.map((e) => Token.fromJson(e as Map)) .toList(), - error: json['error'], + error: json['error'] == null + ? null + : SyriusException.fromJson(json['error'] as Map), ); Map _$DualCoinStatsStateToJson(DualCoinStatsState instance) => { - 'status': _$DashboardStatusEnumMap[instance.status]!, + 'status': _$TimerStatusEnumMap[instance.status]!, 'data': instance.data, 'error': instance.error, }; -const _$DashboardStatusEnumMap = { - DashboardStatus.failure: 'failure', - DashboardStatus.initial: 'initial', - DashboardStatus.loading: 'loading', - DashboardStatus.success: 'success', +const _$TimerStatusEnumMap = { + TimerStatus.failure: 'failure', + TimerStatus.initial: 'initial', + TimerStatus.loading: 'loading', + TimerStatus.success: 'success', }; diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart b/lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_state.dart similarity index 92% rename from lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart rename to lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_state.dart index 1e4c898c..9c311a00 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/cubit/dual_coin_stats_state.dart +++ b/lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_state.dart @@ -8,7 +8,7 @@ part of 'dual_coin_stats_cubit.dart'; /// This state is used by the `DualCoinStatsCubit` to track and update the /// state of both tokens. @JsonSerializable() -class DualCoinStatsState extends DashboardState> { +class DualCoinStatsState extends TimerState> { /// Constructs a new `DualCoinStatsState`. /// /// This state is initialized with default `status`, `data`, and `error` @@ -34,8 +34,8 @@ class DualCoinStatsState extends DashboardState> { /// - A new instance of `DualCoinStatsState` with the updated values or the /// existing ones if none are provided. @override - DashboardState> copyWith({ - DashboardStatus? status, + TimerState> copyWith({ + TimerStatus? status, List? data, SyriusException? error, }) { diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/dual_coin_stats.dart b/lib/rearchitecture/features/dual_coin_stats/dual_coin_stats.dart similarity index 100% rename from lib/rearchitecture/dashboard/dual_coin_stats/dual_coin_stats.dart rename to lib/rearchitecture/features/dual_coin_stats/dual_coin_stats.dart diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart b/lib/rearchitecture/features/dual_coin_stats/view/dual_coin_stats_card.dart similarity index 63% rename from lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart rename to lib/rearchitecture/features/dual_coin_stats/view/dual_coin_stats_card.dart index f032f828..f5128af9 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/view/dual_coin_stats_card.dart +++ b/lib/rearchitecture/features/dual_coin_stats/view/dual_coin_stats_card.dart @@ -1,14 +1,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/card/card.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/widgets/card_scaffold_without_listener.dart'; /// Widget connected to the [DualCoinStatsCubit] that receives the state /// - [DualCoinStatsState] - updates and rebuilds the UI according to the -/// state's status - [DashboardStatus] +/// state's status - [TimerStatus] class DualCoinStatsCard extends StatelessWidget { /// Create a DualCoinStatsCard. @@ -29,12 +30,12 @@ class DualCoinStatsCard extends StatelessWidget { body: BlocBuilder( builder: (context, state) { return switch (state.status) { - DashboardStatus.initial => const DualCoinStatsEmpty(), - DashboardStatus.loading => const DualCoinStatsLoading(), - DashboardStatus.failure => DualCoinStatsError( + TimerStatus.initial => const DualCoinStatsEmpty(), + TimerStatus.loading => const DualCoinStatsLoading(), + TimerStatus.failure => DualCoinStatsError( error: state.error!, ), - DashboardStatus.success => DualCoinStatsPopulated( + TimerStatus.success => DualCoinStatsPopulated( tokens: state.data!, ), }; diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart.dart b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart.dart similarity index 100% rename from lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart.dart rename to lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart.dart diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart similarity index 91% rename from lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart rename to lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart index 82c4dbd1..ec7f6f0c 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart +++ b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// A legend for [DualCoinStatsChartLegend] diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend_item.dart b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart_legend_item.dart similarity index 100% rename from lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_chart_legend_item.dart rename to lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart_legend_item.dart diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_empty.dart similarity index 66% rename from lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart rename to lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_empty.dart index 68839f79..e4b0bc48 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_empty.dart +++ b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_empty.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A widget associated with the [DualCoinStatsState] when it's status is -/// [DashboardStatus.initial] that uses the [SyriusErrorWidget] to display a +/// [TimerStatus.initial] that uses the [SyriusErrorWidget] to display a /// message class DualCoinStatsEmpty extends StatelessWidget { /// Creates a DualCoinStatsEmpty diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_error.dart similarity index 69% rename from lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart rename to lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_error.dart index 34318ea8..b296d771 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_error.dart +++ b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_error.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; /// A widget associated with the [DualCoinStatsState] when it's status is -/// [DashboardStatus.failure] that uses the [SyriusErrorWidget] to display the +/// [TimerStatus.failure] that uses the [SyriusErrorWidget] to display the /// error message class DualCoinStatsError extends StatelessWidget { diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_loading.dart similarity index 73% rename from lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart rename to lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_loading.dart index c4e349c3..cbde656c 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_loading.dart +++ b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_loading.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; /// A widget associated with the [DualCoinStatsState] when it's status is -/// [DashboardStatus.loading] that uses the [SyriusLoadingWidget] to display a +/// [TimerStatus.loading] that uses the [SyriusLoadingWidget] to display a /// loading indicator class DualCoinStatsLoading extends StatelessWidget { diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_populated.dart similarity index 88% rename from lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart rename to lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_populated.dart index 856d68e0..c6c82e7d 100644 --- a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/dual_coin_stats_populated.dart +++ b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_populated.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// A widget associated with the [DualCoinStatsState] when it's status is -/// [DashboardStatus.success] that displays the data provided using a chart +/// [TimerStatus.success] that displays the data provided using a chart /// - [DualCoinStatsChart] - and a legend - [DualCoinStatsChartLegend] class DualCoinStatsPopulated extends StatefulWidget { diff --git a/lib/rearchitecture/dashboard/dual_coin_stats/widgets/widgets.dart b/lib/rearchitecture/features/dual_coin_stats/widgets/widgets.dart similarity index 100% rename from lib/rearchitecture/dashboard/dual_coin_stats/widgets/widgets.dart rename to lib/rearchitecture/features/dual_coin_stats/widgets/widgets.dart diff --git a/lib/rearchitecture/dashboard/dashboard.dart b/lib/rearchitecture/features/features.dart similarity index 83% rename from lib/rearchitecture/dashboard/dashboard.dart rename to lib/rearchitecture/features/features.dart index 939584e4..2c0ac53d 100644 --- a/lib/rearchitecture/dashboard/dashboard.dart +++ b/lib/rearchitecture/features/features.dart @@ -1,6 +1,4 @@ export 'balance/balance.dart'; -export 'dashboard_cubit.dart'; -export 'dashboard_cubit_exception.dart'; export 'delegation/delegation.dart'; export 'dual_coin_stats/dual_coin_stats.dart'; export 'pillars/pillars.dart'; diff --git a/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart b/lib/rearchitecture/features/pillars/cubit/pillars_cubit.dart similarity index 87% rename from lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart rename to lib/rearchitecture/features/pillars/cubit/pillars_cubit.dart index 336d7efc..842dab7f 100644 --- a/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.dart +++ b/lib/rearchitecture/features/pillars/cubit/pillars_cubit.dart @@ -1,6 +1,5 @@ import 'package:json_annotation/json_annotation.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; part 'pillars_cubit.g.dart'; @@ -10,7 +9,7 @@ part 'pillars_state.dart'; /// /// This cubit extends `DashboardCubit`, using an integer to represent the /// total number of pillars fetched from the Zenon network. -class PillarsCubit extends DashboardCubit { +class PillarsCubit extends TimerCubit { /// Constructs a `PillarsCubit`, passing the `zenon` client and the initial /// state to the parent class. /// diff --git a/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.g.dart b/lib/rearchitecture/features/pillars/cubit/pillars_cubit.g.dart similarity index 54% rename from lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.g.dart rename to lib/rearchitecture/features/pillars/cubit/pillars_cubit.g.dart index c64bb66d..3d7b3b7e 100644 --- a/lib/rearchitecture/dashboard/pillars/cubit/pillars_cubit.g.dart +++ b/lib/rearchitecture/features/pillars/cubit/pillars_cubit.g.dart @@ -7,22 +7,24 @@ part of 'pillars_cubit.dart'; // ************************************************************************** PillarsState _$PillarsStateFromJson(Map json) => PillarsState( - status: $enumDecodeNullable(_$DashboardStatusEnumMap, json['status']) ?? - DashboardStatus.initial, + status: $enumDecodeNullable(_$TimerStatusEnumMap, json['status']) ?? + TimerStatus.initial, data: (json['data'] as num?)?.toInt(), - error: json['error'], + error: json['error'] == null + ? null + : SyriusException.fromJson(json['error'] as Map), ); Map _$PillarsStateToJson(PillarsState instance) => { - 'status': _$DashboardStatusEnumMap[instance.status]!, + 'status': _$TimerStatusEnumMap[instance.status]!, 'data': instance.data, 'error': instance.error, }; -const _$DashboardStatusEnumMap = { - DashboardStatus.failure: 'failure', - DashboardStatus.initial: 'initial', - DashboardStatus.loading: 'loading', - DashboardStatus.success: 'success', +const _$TimerStatusEnumMap = { + TimerStatus.failure: 'failure', + TimerStatus.initial: 'initial', + TimerStatus.loading: 'loading', + TimerStatus.success: 'success', }; diff --git a/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart b/lib/rearchitecture/features/pillars/cubit/pillars_state.dart similarity index 93% rename from lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart rename to lib/rearchitecture/features/pillars/cubit/pillars_state.dart index 5741e84f..49d47445 100644 --- a/lib/rearchitecture/dashboard/pillars/cubit/pillars_state.dart +++ b/lib/rearchitecture/features/pillars/cubit/pillars_state.dart @@ -8,7 +8,7 @@ part of 'pillars_cubit.dart'; /// This state is used by the `PillarsCubit` to track and update the number of /// active pillars. @JsonSerializable() -class PillarsState extends DashboardState { +class PillarsState extends TimerState { /// Constructs a new `PillarsState`. /// /// This state is initialized with the default `status`, `data`, and `error` @@ -35,8 +35,8 @@ class PillarsState extends DashboardState { /// - A new instance of `PillarsState` with the updated values or the /// existing ones if none are provided. @override - DashboardState copyWith({ - DashboardStatus? status, + TimerState copyWith({ + TimerStatus? status, int? data, SyriusException? error, }) { diff --git a/lib/rearchitecture/dashboard/pillars/pillars.dart b/lib/rearchitecture/features/pillars/pillars.dart similarity index 100% rename from lib/rearchitecture/dashboard/pillars/pillars.dart rename to lib/rearchitecture/features/pillars/pillars.dart diff --git a/lib/rearchitecture/dashboard/pillars/view/pillars_card.dart b/lib/rearchitecture/features/pillars/view/pillars_card.dart similarity index 62% rename from lib/rearchitecture/dashboard/pillars/view/pillars_card.dart rename to lib/rearchitecture/features/pillars/view/pillars_card.dart index 01616d9c..5770f666 100644 --- a/lib/rearchitecture/dashboard/pillars/view/pillars_card.dart +++ b/lib/rearchitecture/features/pillars/view/pillars_card.dart @@ -1,13 +1,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/card/card.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/widgets/card_scaffold_without_listener.dart'; /// Widget connected to the [PillarsCubit] that receives the state /// - [PillarsState] - updates and rebuilds the UI according to the -/// state's status - [DashboardStatus] +/// state's status - [TimerStatus] class PillarsCard extends StatelessWidget { /// Creates a PillarsCard const PillarsCard({super.key}); @@ -27,12 +28,12 @@ class PillarsCard extends StatelessWidget { body: BlocBuilder( builder: (context, state) { return switch (state.status) { - DashboardStatus.initial => const PillarsEmpty(), - DashboardStatus.loading => const PillarsLoading(), - DashboardStatus.failure => PillarsError( + TimerStatus.initial => const PillarsEmpty(), + TimerStatus.loading => const PillarsLoading(), + TimerStatus.failure => PillarsError( error: state.error!, ), - DashboardStatus.success => PillarsPopulated( + TimerStatus.success => PillarsPopulated( numberOfPillars: state.data!, ), }; diff --git a/lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart b/lib/rearchitecture/features/pillars/widgets/pillars_empty.dart similarity index 66% rename from lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart rename to lib/rearchitecture/features/pillars/widgets/pillars_empty.dart index 6559290b..321b914a 100644 --- a/lib/rearchitecture/dashboard/pillars/widgets/pillars_empty.dart +++ b/lib/rearchitecture/features/pillars/widgets/pillars_empty.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A widget associated with the [PillarsState] when it's status is -/// [DashboardStatus.initial] that uses the [SyriusErrorWidget] to display a +/// [TimerStatus.initial] that uses the [SyriusErrorWidget] to display a /// message class PillarsEmpty extends StatelessWidget { /// Creates a PillarsEmpty instance diff --git a/lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart b/lib/rearchitecture/features/pillars/widgets/pillars_error.dart similarity index 68% rename from lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart rename to lib/rearchitecture/features/pillars/widgets/pillars_error.dart index beeaaab5..85218223 100644 --- a/lib/rearchitecture/dashboard/pillars/widgets/pillars_error.dart +++ b/lib/rearchitecture/features/pillars/widgets/pillars_error.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A widget associated with the [PillarsState] when it's status is -/// [DashboardStatus.failure] that uses the [SyriusErrorWidget] to display the +/// [TimerStatus.failure] that uses the [SyriusErrorWidget] to display the /// error message class PillarsError extends StatelessWidget { ///Creates a PillarsError object diff --git a/lib/rearchitecture/dashboard/pillars/widgets/pillars_loading.dart b/lib/rearchitecture/features/pillars/widgets/pillars_loading.dart similarity index 72% rename from lib/rearchitecture/dashboard/pillars/widgets/pillars_loading.dart rename to lib/rearchitecture/features/pillars/widgets/pillars_loading.dart index 04db1421..b5034530 100644 --- a/lib/rearchitecture/dashboard/pillars/widgets/pillars_loading.dart +++ b/lib/rearchitecture/features/pillars/widgets/pillars_loading.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A widget associated with the [PillarsState] when it's status is -/// [DashboardStatus.loading] that uses the [SyriusLoadingWidget] to display a +/// [TimerStatus.loading] that uses the [SyriusLoadingWidget] to display a /// loading indicator class PillarsLoading extends StatelessWidget { /// Creates a PillarsLoading object diff --git a/lib/rearchitecture/dashboard/pillars/widgets/pillars_populated.dart b/lib/rearchitecture/features/pillars/widgets/pillars_populated.dart similarity index 88% rename from lib/rearchitecture/dashboard/pillars/widgets/pillars_populated.dart rename to lib/rearchitecture/features/pillars/widgets/pillars_populated.dart index 09c5e74c..554e306f 100644 --- a/lib/rearchitecture/dashboard/pillars/widgets/pillars_populated.dart +++ b/lib/rearchitecture/features/pillars/widgets/pillars_populated.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A widget associated with the [PillarsState] when it's status is -/// [DashboardStatus.success] that displays the number of pillars +/// [TimerStatus.success] that displays the number of pillars class PillarsPopulated extends StatelessWidget { /// Creates a PillarsPopulated object const PillarsPopulated({required this.numberOfPillars, super.key}); diff --git a/lib/rearchitecture/dashboard/pillars/widgets/widgets.dart b/lib/rearchitecture/features/pillars/widgets/widgets.dart similarity index 100% rename from lib/rearchitecture/dashboard/pillars/widgets/widgets.dart rename to lib/rearchitecture/features/pillars/widgets/widgets.dart diff --git a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart b/lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_cubit.dart similarity index 94% rename from lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart rename to lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_cubit.dart index 8d9a5d60..ce593d72 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.dart +++ b/lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_cubit.dart @@ -1,8 +1,8 @@ import 'package:json_annotation/json_annotation.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'realtime_statistics_cubit.g.dart'; @@ -16,7 +16,7 @@ part 'realtime_statistics_state.dart'; /// `AccountBlock` objects to represent the account blocks fetched from the /// Zenon network. class RealtimeStatisticsCubit - extends DashboardCubit, RealtimeStatisticsState> { + extends TimerCubit, RealtimeStatisticsState> { /// Constructs a `RealtimeStatisticsCubit`, passing the `zenon` client and /// the initial state to the parent class. /// diff --git a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.g.dart b/lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_cubit.g.dart similarity index 61% rename from lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.g.dart rename to lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_cubit.g.dart index e5668f94..66d284d7 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_cubit.g.dart +++ b/lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_cubit.g.dart @@ -9,25 +9,27 @@ part of 'realtime_statistics_cubit.dart'; RealtimeStatisticsState _$RealtimeStatisticsStateFromJson( Map json) => RealtimeStatisticsState( - status: $enumDecodeNullable(_$DashboardStatusEnumMap, json['status']) ?? - DashboardStatus.initial, + status: $enumDecodeNullable(_$TimerStatusEnumMap, json['status']) ?? + TimerStatus.initial, data: (json['data'] as List?) ?.map((e) => AccountBlock.fromJson(e as Map)) .toList(), - error: json['error'], + error: json['error'] == null + ? null + : SyriusException.fromJson(json['error'] as Map), ); Map _$RealtimeStatisticsStateToJson( RealtimeStatisticsState instance) => { - 'status': _$DashboardStatusEnumMap[instance.status]!, + 'status': _$TimerStatusEnumMap[instance.status]!, 'data': instance.data, 'error': instance.error, }; -const _$DashboardStatusEnumMap = { - DashboardStatus.failure: 'failure', - DashboardStatus.initial: 'initial', - DashboardStatus.loading: 'loading', - DashboardStatus.success: 'success', +const _$TimerStatusEnumMap = { + TimerStatus.failure: 'failure', + TimerStatus.initial: 'initial', + TimerStatus.loading: 'loading', + TimerStatus.success: 'success', }; diff --git a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart b/lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_state.dart similarity index 88% rename from lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart rename to lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_state.dart index 3cff2c52..8acb460f 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/cubit/realtime_statistics_state.dart +++ b/lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_state.dart @@ -1,14 +1,14 @@ part of 'realtime_statistics_cubit.dart'; /// The state class for [RealtimeStatisticsCubit], which extends -/// [DashboardState] to handle real-time statistics data. +/// [TimerState] to handle real-time statistics data. /// /// This class manages a list of `AccountBlock` objects representing real-time /// blockchain data, such as recent transactions. /// It's used to track the state of the data loading process in the /// `RealtimeStatisticsCubit`. @JsonSerializable() -class RealtimeStatisticsState extends DashboardState> { +class RealtimeStatisticsState extends TimerState> { /// Constructs a new `RealtimeStatisticsState` with optional values for /// `status`, `data`, and `error`. /// @@ -34,8 +34,8 @@ class RealtimeStatisticsState extends DashboardState> { /// - A new instance of `RealtimeStatisticsState` with the updated values or /// the existing ones if none are provided. @override - DashboardState> copyWith({ - DashboardStatus? status, + TimerState> copyWith({ + TimerStatus? status, List? data, SyriusException? error, }) { diff --git a/lib/rearchitecture/dashboard/realtime_statistics/exceptions/exceptions.dart b/lib/rearchitecture/features/realtime_statistics/exceptions/exceptions.dart similarity index 100% rename from lib/rearchitecture/dashboard/realtime_statistics/exceptions/exceptions.dart rename to lib/rearchitecture/features/realtime_statistics/exceptions/exceptions.dart diff --git a/lib/rearchitecture/dashboard/realtime_statistics/exceptions/no_blocks_available_exception.dart b/lib/rearchitecture/features/realtime_statistics/exceptions/no_blocks_available_exception.dart similarity index 75% rename from lib/rearchitecture/dashboard/realtime_statistics/exceptions/no_blocks_available_exception.dart rename to lib/rearchitecture/features/realtime_statistics/exceptions/no_blocks_available_exception.dart index c64855be..087cdcd4 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/exceptions/no_blocks_available_exception.dart +++ b/lib/rearchitecture/features/realtime_statistics/exceptions/no_blocks_available_exception.dart @@ -1,12 +1,13 @@ import 'package:json_annotation/json_annotation.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/exceptions/exceptions.dart'; part 'no_blocks_available_exception.g.dart'; /// Custom [Exception] to be used with [RealtimeStatisticsCubit] when there are /// no account blocks available on the network @JsonSerializable() -class NoBlocksAvailableException extends DashboardCubitException { +class NoBlocksAvailableException extends CubitException { /// Creates a [NoBlocksAvailableException] instance NoBlocksAvailableException(): super('No account blocks available'); diff --git a/lib/rearchitecture/dashboard/realtime_statistics/exceptions/no_blocks_available_exception.g.dart b/lib/rearchitecture/features/realtime_statistics/exceptions/no_blocks_available_exception.g.dart similarity index 100% rename from lib/rearchitecture/dashboard/realtime_statistics/exceptions/no_blocks_available_exception.g.dart rename to lib/rearchitecture/features/realtime_statistics/exceptions/no_blocks_available_exception.g.dart diff --git a/lib/rearchitecture/dashboard/realtime_statistics/realtime_statistics.dart b/lib/rearchitecture/features/realtime_statistics/realtime_statistics.dart similarity index 100% rename from lib/rearchitecture/dashboard/realtime_statistics/realtime_statistics.dart rename to lib/rearchitecture/features/realtime_statistics/realtime_statistics.dart diff --git a/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart b/lib/rearchitecture/features/realtime_statistics/view/realtime_statistics_card.dart similarity index 63% rename from lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart rename to lib/rearchitecture/features/realtime_statistics/view/realtime_statistics_card.dart index 605605f8..c5498234 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/view/realtime_statistics_card.dart +++ b/lib/rearchitecture/features/realtime_statistics/view/realtime_statistics_card.dart @@ -1,13 +1,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/card/card.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/widgets/card_scaffold_without_listener.dart'; /// A card that receives [RealtimeStatisticsState] updates from the /// [RealtimeStatisticsCubit] and changes the UI according to the request -/// status - [DashboardStatus] +/// status - [TimerStatus] class RealtimeStatisticsCard extends StatelessWidget { /// Creates a RealtimeStatisticsCard object. const RealtimeStatisticsCard({super.key}); @@ -27,12 +28,12 @@ class RealtimeStatisticsCard extends StatelessWidget { body: BlocBuilder( builder: (context, state) { return switch (state.status) { - DashboardStatus.initial => const RealtimeStatisticsEmpty(), - DashboardStatus.loading => const RealtimeStatisticsLoading(), - DashboardStatus.failure => RealtimeStatisticsError( + TimerStatus.initial => const RealtimeStatisticsEmpty(), + TimerStatus.loading => const RealtimeStatisticsLoading(), + TimerStatus.failure => RealtimeStatisticsError( error: state.error!, ), - DashboardStatus.success => RealtimeStatisticsPopulated( + TimerStatus.success => RealtimeStatisticsPopulated( accountBlocks: state.data!, ), }; diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_empty.dart b/lib/rearchitecture/features/realtime_statistics/widgets/realtime_statistics_empty.dart similarity index 85% rename from lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_empty.dart rename to lib/rearchitecture/features/realtime_statistics/widgets/realtime_statistics_empty.dart index eb4c1acd..53fa8be4 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_empty.dart +++ b/lib/rearchitecture/features/realtime_statistics/widgets/realtime_statistics_empty.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A widget that displays a hardcoded error message diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart b/lib/rearchitecture/features/realtime_statistics/widgets/realtime_statistics_error.dart similarity index 87% rename from lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart rename to lib/rearchitecture/features/realtime_statistics/widgets/realtime_statistics_error.dart index c230d1dd..32f4d8d8 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_error.dart +++ b/lib/rearchitecture/features/realtime_statistics/widgets/realtime_statistics_error.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A widget that displays an error message diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_loading.dart b/lib/rearchitecture/features/realtime_statistics/widgets/realtime_statistics_loading.dart similarity index 100% rename from lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_loading.dart rename to lib/rearchitecture/features/realtime_statistics/widgets/realtime_statistics_loading.dart diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart b/lib/rearchitecture/features/realtime_statistics/widgets/realtime_statistics_populated.dart similarity index 83% rename from lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart rename to lib/rearchitecture/features/realtime_statistics/widgets/realtime_statistics_populated.dart index c464a302..10d2f795 100644 --- a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_statistics_populated.dart +++ b/lib/rearchitecture/features/realtime_statistics/widgets/realtime_statistics_populated.dart @@ -1,11 +1,13 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/realtime_statistics/widgets/realtime_txs_chart.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// A widget associated with the [RealtimeStatisticsState] when it's status is -/// [DashboardStatus.success] +/// [TimerStatus.success] /// /// Displays a chart highlighting the number of blocks in QSR and ZNN signed /// with a particular address in the last seven days diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_txs_chart.dart b/lib/rearchitecture/features/realtime_statistics/widgets/realtime_txs_chart.dart similarity index 100% rename from lib/rearchitecture/dashboard/realtime_statistics/widgets/realtime_txs_chart.dart rename to lib/rearchitecture/features/realtime_statistics/widgets/realtime_txs_chart.dart diff --git a/lib/rearchitecture/dashboard/realtime_statistics/widgets/widgets.dart b/lib/rearchitecture/features/realtime_statistics/widgets/widgets.dart similarity index 100% rename from lib/rearchitecture/dashboard/realtime_statistics/widgets/widgets.dart rename to lib/rearchitecture/features/realtime_statistics/widgets/widgets.dart diff --git a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart b/lib/rearchitecture/features/sentinels/cubit/sentinels_cubit.dart similarity index 87% rename from lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart rename to lib/rearchitecture/features/sentinels/cubit/sentinels_cubit.dart index 489793f9..10aa45a9 100644 --- a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.dart +++ b/lib/rearchitecture/features/sentinels/cubit/sentinels_cubit.dart @@ -1,6 +1,5 @@ import 'package:json_annotation/json_annotation.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'sentinels_cubit.g.dart'; @@ -12,7 +11,7 @@ part 'sentinels_state.dart'; /// This cubit extends `DashboardCubit`, using a /// `SentinelInfoList` object to represent the list of active sentinels /// fetched from the Zenon network. -class SentinelsCubit extends DashboardCubit { +class SentinelsCubit extends TimerCubit { /// Constructs a `SentinelsCubit`, passing the `zenon` client and the initial /// state to the parent class. /// diff --git a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.g.dart b/lib/rearchitecture/features/sentinels/cubit/sentinels_cubit.g.dart similarity index 58% rename from lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.g.dart rename to lib/rearchitecture/features/sentinels/cubit/sentinels_cubit.g.dart index 8579636c..82b27743 100644 --- a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_cubit.g.dart +++ b/lib/rearchitecture/features/sentinels/cubit/sentinels_cubit.g.dart @@ -8,24 +8,26 @@ part of 'sentinels_cubit.dart'; SentinelsState _$SentinelsStateFromJson(Map json) => SentinelsState( - status: $enumDecodeNullable(_$DashboardStatusEnumMap, json['status']) ?? - DashboardStatus.initial, + status: $enumDecodeNullable(_$TimerStatusEnumMap, json['status']) ?? + TimerStatus.initial, data: json['data'] == null ? null : SentinelInfoList.fromJson(json['data'] as Map), - error: json['error'], + error: json['error'] == null + ? null + : SyriusException.fromJson(json['error'] as Map), ); Map _$SentinelsStateToJson(SentinelsState instance) => { - 'status': _$DashboardStatusEnumMap[instance.status]!, + 'status': _$TimerStatusEnumMap[instance.status]!, 'data': instance.data, 'error': instance.error, }; -const _$DashboardStatusEnumMap = { - DashboardStatus.failure: 'failure', - DashboardStatus.initial: 'initial', - DashboardStatus.loading: 'loading', - DashboardStatus.success: 'success', +const _$TimerStatusEnumMap = { + TimerStatus.failure: 'failure', + TimerStatus.initial: 'initial', + TimerStatus.loading: 'loading', + TimerStatus.success: 'success', }; diff --git a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart b/lib/rearchitecture/features/sentinels/cubit/sentinels_state.dart similarity index 91% rename from lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart rename to lib/rearchitecture/features/sentinels/cubit/sentinels_state.dart index d80a39b4..1ba049fc 100644 --- a/lib/rearchitecture/dashboard/sentinels/cubit/sentinels_state.dart +++ b/lib/rearchitecture/features/sentinels/cubit/sentinels_state.dart @@ -7,7 +7,7 @@ part of 'sentinels_cubit.dart'; /// about active sentinels. It is used to track /// the state of sentinel data loading within the `SentinelsCubit`. @JsonSerializable() -class SentinelsState extends DashboardState { +class SentinelsState extends TimerState { /// Constructs a new `SentinelsState` with optional values for `status`, /// `data`, and `error`. /// @@ -33,8 +33,8 @@ class SentinelsState extends DashboardState { /// - A new instance of `SentinelsState` with the updated values or the /// existing ones if none are provided. @override - DashboardState copyWith({ - DashboardStatus? status, + TimerState copyWith({ + TimerStatus? status, SentinelInfoList? data, SyriusException? error, }) { diff --git a/lib/rearchitecture/dashboard/sentinels/sentinels.dart b/lib/rearchitecture/features/sentinels/sentinels.dart similarity index 100% rename from lib/rearchitecture/dashboard/sentinels/sentinels.dart rename to lib/rearchitecture/features/sentinels/sentinels.dart diff --git a/lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart b/lib/rearchitecture/features/sentinels/view/sentinels_card.dart similarity index 63% rename from lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart rename to lib/rearchitecture/features/sentinels/view/sentinels_card.dart index 93e4dd00..1b9b6c06 100644 --- a/lib/rearchitecture/dashboard/sentinels/view/sentinels_card.dart +++ b/lib/rearchitecture/features/sentinels/view/sentinels_card.dart @@ -1,13 +1,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/card/card.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/widgets/card_scaffold_without_listener.dart'; /// Widget connected to the [SentinelsCubit] that receives the state /// - [SentinelsState] - updates and rebuilds the UI according to the -/// state's status - [DashboardStatus] +/// state's status - [TimerStatus] class SentinelsCard extends StatelessWidget { /// Creates a SentinelsCard object. const SentinelsCard({super.key}); @@ -27,12 +28,12 @@ class SentinelsCard extends StatelessWidget { body: BlocBuilder( builder: (context, state) { return switch (state.status) { - DashboardStatus.initial => const SentinelsEmpty(), - DashboardStatus.loading => const SentinelsLoading(), - DashboardStatus.failure => SentinelsError( + TimerStatus.initial => const SentinelsEmpty(), + TimerStatus.loading => const SentinelsLoading(), + TimerStatus.failure => SentinelsError( error: state.error!, ), - DashboardStatus.success => SentinelsPopulated( + TimerStatus.success => SentinelsPopulated( sentinelInfoList: state.data!, ), }; diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart b/lib/rearchitecture/features/sentinels/widgets/sentinels_empty.dart similarity index 65% rename from lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart rename to lib/rearchitecture/features/sentinels/widgets/sentinels_empty.dart index d7fb654d..9170dddd 100644 --- a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_empty.dart +++ b/lib/rearchitecture/features/sentinels/widgets/sentinels_empty.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [SentinelsState] when it's status is -/// [DashboardStatus.initial] that uses the [SyriusErrorWidget] to display a +/// [TimerStatus.initial] that uses the [SyriusErrorWidget] to display a /// message class SentinelsEmpty extends StatelessWidget { /// Creates a SentinelsEmpty object diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart b/lib/rearchitecture/features/sentinels/widgets/sentinels_error.dart similarity index 68% rename from lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart rename to lib/rearchitecture/features/sentinels/widgets/sentinels_error.dart index ec620301..07be2147 100644 --- a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_error.dart +++ b/lib/rearchitecture/features/sentinels/widgets/sentinels_error.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [SentinelsState] when it's status is -/// [DashboardStatus.failure] that uses the [SyriusErrorWidget] to display an +/// [TimerStatus.failure] that uses the [SyriusErrorWidget] to display an /// error. class SentinelsError extends StatelessWidget { /// Creates a SentinelsError objects. diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_loading.dart b/lib/rearchitecture/features/sentinels/widgets/sentinels_loading.dart similarity index 72% rename from lib/rearchitecture/dashboard/sentinels/widgets/sentinels_loading.dart rename to lib/rearchitecture/features/sentinels/widgets/sentinels_loading.dart index 05e9ac3f..ecca8c39 100644 --- a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_loading.dart +++ b/lib/rearchitecture/features/sentinels/widgets/sentinels_loading.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [SentinelsState] when it's status is -/// [DashboardStatus.loading] that uses the [SyriusLoadingWidget] to display a +/// [TimerStatus.loading] that uses the [SyriusLoadingWidget] to display a /// loading indicator. class SentinelsLoading extends StatelessWidget { /// Creates a SentinelsLoading object. diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart b/lib/rearchitecture/features/sentinels/widgets/sentinels_populated.dart similarity index 89% rename from lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart rename to lib/rearchitecture/features/sentinels/widgets/sentinels_populated.dart index 4a44757b..7dcf7013 100644 --- a/lib/rearchitecture/dashboard/sentinels/widgets/sentinels_populated.dart +++ b/lib/rearchitecture/features/sentinels/widgets/sentinels_populated.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// A widget associated with the [SentinelsState] when it's status is -/// [DashboardStatus.success] that displays the current number of sentinels +/// [TimerStatus.success] that displays the current number of sentinels class SentinelsPopulated extends StatelessWidget { /// Creates a SentinelsPopulated object. const SentinelsPopulated({required this.sentinelInfoList, super.key}); diff --git a/lib/rearchitecture/dashboard/sentinels/widgets/widgets.dart b/lib/rearchitecture/features/sentinels/widgets/widgets.dart similarity index 100% rename from lib/rearchitecture/dashboard/sentinels/widgets/widgets.dart rename to lib/rearchitecture/features/sentinels/widgets/widgets.dart diff --git a/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart b/lib/rearchitecture/features/staking/cubit/staking_cubit.dart similarity index 90% rename from lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart rename to lib/rearchitecture/features/staking/cubit/staking_cubit.dart index 62dfa756..287cbd38 100644 --- a/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.dart +++ b/lib/rearchitecture/features/staking/cubit/staking_cubit.dart @@ -1,7 +1,7 @@ import 'package:json_annotation/json_annotation.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'staking_cubit.g.dart'; @@ -13,7 +13,7 @@ part 'staking_state.dart'; /// This cubit extends `DashboardCubit`, using a `StakeList` object /// to represent the list of staking entries for a specific address fetched /// from the Zenon network. -class StakingCubit extends DashboardCubit { +class StakingCubit extends TimerCubit { /// Constructs a `StakingCubit`, passing the `zenon` client and the initial /// state to the parent class. /// diff --git a/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.g.dart b/lib/rearchitecture/features/staking/cubit/staking_cubit.g.dart similarity index 57% rename from lib/rearchitecture/dashboard/staking/cubit/staking_cubit.g.dart rename to lib/rearchitecture/features/staking/cubit/staking_cubit.g.dart index 4f05225b..a8b75f21 100644 --- a/lib/rearchitecture/dashboard/staking/cubit/staking_cubit.g.dart +++ b/lib/rearchitecture/features/staking/cubit/staking_cubit.g.dart @@ -7,24 +7,26 @@ part of 'staking_cubit.dart'; // ************************************************************************** StakingState _$StakingStateFromJson(Map json) => StakingState( - status: $enumDecodeNullable(_$DashboardStatusEnumMap, json['status']) ?? - DashboardStatus.initial, + status: $enumDecodeNullable(_$TimerStatusEnumMap, json['status']) ?? + TimerStatus.initial, data: json['data'] == null ? null : StakeList.fromJson(json['data'] as Map), - error: json['error'], + error: json['error'] == null + ? null + : SyriusException.fromJson(json['error'] as Map), ); Map _$StakingStateToJson(StakingState instance) => { - 'status': _$DashboardStatusEnumMap[instance.status]!, + 'status': _$TimerStatusEnumMap[instance.status]!, 'data': instance.data, 'error': instance.error, }; -const _$DashboardStatusEnumMap = { - DashboardStatus.failure: 'failure', - DashboardStatus.initial: 'initial', - DashboardStatus.loading: 'loading', - DashboardStatus.success: 'success', +const _$TimerStatusEnumMap = { + TimerStatus.failure: 'failure', + TimerStatus.initial: 'initial', + TimerStatus.loading: 'loading', + TimerStatus.success: 'success', }; diff --git a/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart b/lib/rearchitecture/features/staking/cubit/staking_state.dart similarity index 92% rename from lib/rearchitecture/dashboard/staking/cubit/staking_state.dart rename to lib/rearchitecture/features/staking/cubit/staking_state.dart index 8e77a957..cfa6cc83 100644 --- a/lib/rearchitecture/dashboard/staking/cubit/staking_state.dart +++ b/lib/rearchitecture/features/staking/cubit/staking_state.dart @@ -8,7 +8,7 @@ part of 'staking_cubit.dart'; /// It tracks the loading, success, or failure of fetching staking data within /// the `StakingCubit`. @JsonSerializable() -class StakingState extends DashboardState { +class StakingState extends TimerState { /// Constructs a new `StakingState` with optional values for `status`, /// `data`, and `error`. /// @@ -34,8 +34,8 @@ class StakingState extends DashboardState { /// - A new instance of `StakingState`with the updated values or the /// existing ones if none are provided. @override - DashboardState copyWith({ - DashboardStatus? status, + TimerState copyWith({ + TimerStatus? status, StakeList? data, SyriusException? error, }) { diff --git a/lib/rearchitecture/dashboard/staking/exceptions/exceptions.dart b/lib/rearchitecture/features/staking/exceptions/exceptions.dart similarity index 100% rename from lib/rearchitecture/dashboard/staking/exceptions/exceptions.dart rename to lib/rearchitecture/features/staking/exceptions/exceptions.dart diff --git a/lib/rearchitecture/dashboard/staking/exceptions/no_active_skaking_entries_exception.dart b/lib/rearchitecture/features/staking/exceptions/no_active_skaking_entries_exception.dart similarity index 75% rename from lib/rearchitecture/dashboard/staking/exceptions/no_active_skaking_entries_exception.dart rename to lib/rearchitecture/features/staking/exceptions/no_active_skaking_entries_exception.dart index 6eadbad9..268611fc 100644 --- a/lib/rearchitecture/dashboard/staking/exceptions/no_active_skaking_entries_exception.dart +++ b/lib/rearchitecture/features/staking/exceptions/no_active_skaking_entries_exception.dart @@ -1,12 +1,13 @@ import 'package:json_annotation/json_annotation.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/exceptions/exceptions.dart'; part 'no_active_skaking_entries_exception.g.dart'; /// Custom [Exception] to be used with [StakingCubit] when there are /// no active staking entries found on an address @JsonSerializable() -class NoActiveStakingEntriesException extends DashboardCubitException { +class NoActiveStakingEntriesException extends CubitException { /// Creates a [NoActiveStakingEntriesException] instance NoActiveStakingEntriesException() : super('No active staking entries'); diff --git a/lib/rearchitecture/dashboard/staking/exceptions/no_active_skaking_entries_exception.g.dart b/lib/rearchitecture/features/staking/exceptions/no_active_skaking_entries_exception.g.dart similarity index 100% rename from lib/rearchitecture/dashboard/staking/exceptions/no_active_skaking_entries_exception.g.dart rename to lib/rearchitecture/features/staking/exceptions/no_active_skaking_entries_exception.g.dart diff --git a/lib/rearchitecture/dashboard/staking/staking.dart b/lib/rearchitecture/features/staking/staking.dart similarity index 100% rename from lib/rearchitecture/dashboard/staking/staking.dart rename to lib/rearchitecture/features/staking/staking.dart diff --git a/lib/rearchitecture/dashboard/staking/view/staking_card.dart b/lib/rearchitecture/features/staking/view/staking_card.dart similarity index 63% rename from lib/rearchitecture/dashboard/staking/view/staking_card.dart rename to lib/rearchitecture/features/staking/view/staking_card.dart index e0aac169..6815f38b 100644 --- a/lib/rearchitecture/dashboard/staking/view/staking_card.dart +++ b/lib/rearchitecture/features/staking/view/staking_card.dart @@ -1,13 +1,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/card/card.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/widgets/card_scaffold_without_listener.dart'; /// A widget connected to the [StakingCubit] that receives the state /// - [StakingState] - updates and rebuilds the UI according to the -/// state's status - [DashboardStatus] +/// state's status - [TimerStatus] class StakingCard extends StatelessWidget { /// Creates a StakingCard object. const StakingCard({super.key}); @@ -27,12 +28,12 @@ class StakingCard extends StatelessWidget { body: BlocBuilder( builder: (context, state) { return switch (state.status) { - DashboardStatus.initial => const StakingEmpty(), - DashboardStatus.loading => const StakingLoading(), - DashboardStatus.failure => StakingError( + TimerStatus.initial => const StakingEmpty(), + TimerStatus.loading => const StakingLoading(), + TimerStatus.failure => StakingError( error: state.error!, ), - DashboardStatus.success => StakingPopulated( + TimerStatus.success => StakingPopulated( stakingList: state.data!, ), }; diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart b/lib/rearchitecture/features/staking/widgets/staking_empty.dart similarity index 64% rename from lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart rename to lib/rearchitecture/features/staking/widgets/staking_empty.dart index 75b13158..db7fbf01 100644 --- a/lib/rearchitecture/dashboard/staking/widgets/staking_empty.dart +++ b/lib/rearchitecture/features/staking/widgets/staking_empty.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [StakingState] when it's status is -/// [DashboardStatus.initial] that uses the [SyriusErrorWidget] to display a +/// [TimerStatus.initial] that uses the [SyriusErrorWidget] to display a /// message class StakingEmpty extends StatelessWidget { /// Creates a StakingEmpty object. diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart b/lib/rearchitecture/features/staking/widgets/staking_error.dart similarity index 69% rename from lib/rearchitecture/dashboard/staking/widgets/staking_error.dart rename to lib/rearchitecture/features/staking/widgets/staking_error.dart index c4dce3e2..79a14335 100644 --- a/lib/rearchitecture/dashboard/staking/widgets/staking_error.dart +++ b/lib/rearchitecture/features/staking/widgets/staking_error.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; /// A widget associated with the [StakingState] when it's status is -/// [DashboardStatus.failure] that uses the [SyriusErrorWidget] to display the +/// [TimerStatus.failure] that uses the [SyriusErrorWidget] to display the /// error. class StakingError extends StatelessWidget { /// Creates a StakingError object. diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_loading.dart b/lib/rearchitecture/features/staking/widgets/staking_loading.dart similarity index 71% rename from lib/rearchitecture/dashboard/staking/widgets/staking_loading.dart rename to lib/rearchitecture/features/staking/widgets/staking_loading.dart index 14bb555c..6abc082f 100644 --- a/lib/rearchitecture/dashboard/staking/widgets/staking_loading.dart +++ b/lib/rearchitecture/features/staking/widgets/staking_loading.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [StakingState] when it's status is -/// [DashboardStatus.loading] that uses the [SyriusLoadingWidget] to display a +/// [TimerStatus.loading] that uses the [SyriusLoadingWidget] to display a /// loading indicator. class StakingLoading extends StatelessWidget { /// Creates a StakingLoading object. diff --git a/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart b/lib/rearchitecture/features/staking/widgets/staking_populated.dart similarity index 89% rename from lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart rename to lib/rearchitecture/features/staking/widgets/staking_populated.dart index 68db0801..bd83b601 100644 --- a/lib/rearchitecture/dashboard/staking/widgets/staking_populated.dart +++ b/lib/rearchitecture/features/staking/widgets/staking_populated.dart @@ -1,12 +1,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// A widget associated with the [StakingState] when it's status is -/// [DashboardStatus.success] that displays the number of active staking entries +/// [TimerStatus.success] that displays the number of active staking entries /// and the total staked amount class StakingPopulated extends StatelessWidget { /// Creates a StakingPopulated object diff --git a/lib/rearchitecture/dashboard/staking/widgets/widgets.dart b/lib/rearchitecture/features/staking/widgets/widgets.dart similarity index 100% rename from lib/rearchitecture/dashboard/staking/widgets/widgets.dart rename to lib/rearchitecture/features/staking/widgets/widgets.dart diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart b/lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart similarity index 88% rename from lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart rename to lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart index cde2ee10..6211e606 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart +++ b/lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart @@ -1,8 +1,9 @@ import 'package:json_annotation/json_annotation.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/exceptions/exceptions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; - -import '../../../../utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; part 'total_hourly_transactions_cubit.g.dart'; @@ -16,7 +17,7 @@ part 'total_hourly_transactions_state.dart'; /// number of account blocks and the corresponding timestamp fetched from the /// Zenon network. class TotalHourlyTransactionsCubit - extends DashboardCubit { + extends TimerCubit { /// Constructs a `TotalHourlyTransactionsCubit`, passing the `zenon` client /// and the initial state to the parent class. /// diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.g.dart b/lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_cubit.g.dart similarity index 59% rename from lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.g.dart rename to lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_cubit.g.dart index 9de22e99..8c722a10 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_cubit.g.dart +++ b/lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_cubit.g.dart @@ -9,23 +9,25 @@ part of 'total_hourly_transactions_cubit.dart'; TotalHourlyTransactionsState _$TotalHourlyTransactionsStateFromJson( Map json) => TotalHourlyTransactionsState( - status: $enumDecodeNullable(_$DashboardStatusEnumMap, json['status']) ?? - DashboardStatus.initial, + status: $enumDecodeNullable(_$TimerStatusEnumMap, json['status']) ?? + TimerStatus.initial, data: (json['data'] as num?)?.toInt(), - error: json['error'], + error: json['error'] == null + ? null + : SyriusException.fromJson(json['error'] as Map), ); Map _$TotalHourlyTransactionsStateToJson( TotalHourlyTransactionsState instance) => { - 'status': _$DashboardStatusEnumMap[instance.status]!, + 'status': _$TimerStatusEnumMap[instance.status]!, 'data': instance.data, 'error': instance.error, }; -const _$DashboardStatusEnumMap = { - DashboardStatus.failure: 'failure', - DashboardStatus.initial: 'initial', - DashboardStatus.loading: 'loading', - DashboardStatus.success: 'success', +const _$TimerStatusEnumMap = { + TimerStatus.failure: 'failure', + TimerStatus.initial: 'initial', + TimerStatus.loading: 'loading', + TimerStatus.success: 'success', }; diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart b/lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_state.dart similarity index 93% rename from lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart rename to lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_state.dart index 3bfd564d..d59381e2 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/cubit/total_hourly_transactions_state.dart +++ b/lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_state.dart @@ -8,7 +8,7 @@ part of 'total_hourly_transactions_cubit.dart'; /// the timestamp) for the last hour. It tracks the state of fetching /// hourly transaction data within `TotalHourlyTransactionsCubit`. @JsonSerializable() -class TotalHourlyTransactionsState extends DashboardState { +class TotalHourlyTransactionsState extends TimerState { /// Constructs a new `TotalHourlyTransactionsState` with optional values for /// `status`, `data`, and `error`. /// @@ -34,8 +34,8 @@ class TotalHourlyTransactionsState extends DashboardState { /// - A new instance of `TotalHourlyTransactionsState` with the updated /// values or the existing ones if none are provided. @override - DashboardState copyWith({ - DashboardStatus? status, + TimerState copyWith({ + TimerStatus? status, int? data, SyriusException? error, }) { diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/exceptions.dart b/lib/rearchitecture/features/total_hourly_transactions/exceptions/exceptions.dart similarity index 100% rename from lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/exceptions.dart rename to lib/rearchitecture/features/total_hourly_transactions/exceptions/exceptions.dart diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/not_enough_momentums_exception.dart b/lib/rearchitecture/features/total_hourly_transactions/exceptions/not_enough_momentums_exception.dart similarity index 75% rename from lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/not_enough_momentums_exception.dart rename to lib/rearchitecture/features/total_hourly_transactions/exceptions/not_enough_momentums_exception.dart index 716c1a1c..72395ce2 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/not_enough_momentums_exception.dart +++ b/lib/rearchitecture/features/total_hourly_transactions/exceptions/not_enough_momentums_exception.dart @@ -1,12 +1,13 @@ import 'package:json_annotation/json_annotation.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/exceptions/exceptions.dart'; part 'not_enough_momentums_exception.g.dart'; /// Custom [Exception] to be used with [TotalHourlyTransactionsCubit] when /// the network is less than one hour old @JsonSerializable() -class NotEnoughMomentumsException extends DashboardCubitException { +class NotEnoughMomentumsException extends CubitException { /// Creates a [NotEnoughMomentumsException] instance NotEnoughMomentumsException(): super('Not enough momentums'); diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/not_enough_momentums_exception.g.dart b/lib/rearchitecture/features/total_hourly_transactions/exceptions/not_enough_momentums_exception.g.dart similarity index 100% rename from lib/rearchitecture/dashboard/total_hourly_transactions/exceptions/not_enough_momentums_exception.g.dart rename to lib/rearchitecture/features/total_hourly_transactions/exceptions/not_enough_momentums_exception.g.dart diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/total_hourly_transactions.dart b/lib/rearchitecture/features/total_hourly_transactions/total_hourly_transactions.dart similarity index 100% rename from lib/rearchitecture/dashboard/total_hourly_transactions/total_hourly_transactions.dart rename to lib/rearchitecture/features/total_hourly_transactions/total_hourly_transactions.dart diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart b/lib/rearchitecture/features/total_hourly_transactions/view/total_hourly_transactions_card.dart similarity index 63% rename from lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart rename to lib/rearchitecture/features/total_hourly_transactions/view/total_hourly_transactions_card.dart index 2a533914..b3c1df0d 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/view/total_hourly_transactions_card.dart +++ b/lib/rearchitecture/features/total_hourly_transactions/view/total_hourly_transactions_card.dart @@ -1,13 +1,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/card/card.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/widgets/card_scaffold_without_listener.dart'; /// A widget connected to the [TotalHourlyTransactionsCubit] that receives the /// state - [TotalHourlyTransactionsState] - updates and rebuilds the UI -/// according to the state's status - [DashboardStatus] +/// according to the state's status - [TimerStatus] class TotalHourlyTransactionsCard extends StatelessWidget { /// Creates a TotalHourlyTransactionsCard object. const TotalHourlyTransactionsCard({super.key}); @@ -28,12 +29,12 @@ class TotalHourlyTransactionsCard extends StatelessWidget { TotalHourlyTransactionsState>( builder: (context, state) { return switch (state.status) { - DashboardStatus.initial => const TotalHourlyTransactionsEmpty(), - DashboardStatus.loading => const TotalHourlyTransactionsLoading(), - DashboardStatus.failure => TotalHourlyTransactionsError( + TimerStatus.initial => const TotalHourlyTransactionsEmpty(), + TimerStatus.loading => const TotalHourlyTransactionsLoading(), + TimerStatus.failure => TotalHourlyTransactionsError( error: state.error!, ), - DashboardStatus.success => TotalHourlyTransactionsPopulated( + TimerStatus.success => TotalHourlyTransactionsPopulated( count: state.data!, ), }; diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart b/lib/rearchitecture/features/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart similarity index 67% rename from lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart rename to lib/rearchitecture/features/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart index d18cb4ea..54366453 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart +++ b/lib/rearchitecture/features/total_hourly_transactions/widgets/total_hourly_transactions_empty.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [TotalHourlyTransactionsState] when it's -/// status is [DashboardStatus.initial] that uses the [SyriusErrorWidget] to +/// status is [TimerStatus.initial] that uses the [SyriusErrorWidget] to /// display a message class TotalHourlyTransactionsEmpty extends StatelessWidget { /// Creates a TotalHourlyTransactionsEmpty object. diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart b/lib/rearchitecture/features/total_hourly_transactions/widgets/total_hourly_transactions_error.dart similarity index 71% rename from lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart rename to lib/rearchitecture/features/total_hourly_transactions/widgets/total_hourly_transactions_error.dart index 1cf0eba9..ee20097a 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_error.dart +++ b/lib/rearchitecture/features/total_hourly_transactions/widgets/total_hourly_transactions_error.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; /// A widget associated with the [TotalHourlyTransactionsState] when it's -/// status is [DashboardStatus.failure] that uses the [SyriusErrorWidget] to +/// status is [TimerStatus.failure] that uses the [SyriusErrorWidget] to /// display the error. class TotalHourlyTransactionsError extends StatelessWidget { /// Creates a TotalHourlyTransactionError object. diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart b/lib/rearchitecture/features/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart similarity index 75% rename from lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart rename to lib/rearchitecture/features/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart index cfa4dc37..5ece8fde 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart +++ b/lib/rearchitecture/features/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; /// A widget associated with the [TotalHourlyTransactionsState] when it's -/// status is [DashboardStatus.loading] that uses the [SyriusLoadingWidget] to +/// status is [TimerStatus.loading] that uses the [SyriusLoadingWidget] to /// display a loading indicator. class TotalHourlyTransactionsLoading extends StatelessWidget { /// Creates a TotalHourlyTransactionsLoading object. diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart b/lib/rearchitecture/features/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart similarity index 76% rename from lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart rename to lib/rearchitecture/features/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart index ba3049c8..e76a54c8 100644 --- a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart +++ b/lib/rearchitecture/features/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart @@ -1,10 +1,12 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [TotalHourlyTransactionsState] when it's -/// status is [DashboardStatus.success] that displays the number of transactions +/// status is [TimerStatus.success] that displays the number of transactions /// confirmed in the last one hour class TotalHourlyTransactionsPopulated extends StatelessWidget { /// Creates a TotalHourlyTransactionsPopulated object. diff --git a/lib/rearchitecture/dashboard/total_hourly_transactions/widgets/widgets.dart b/lib/rearchitecture/features/total_hourly_transactions/widgets/widgets.dart similarity index 100% rename from lib/rearchitecture/dashboard/total_hourly_transactions/widgets/widgets.dart rename to lib/rearchitecture/features/total_hourly_transactions/widgets/widgets.dart diff --git a/lib/rearchitecture/dashboard/transfer/transfer.dart b/lib/rearchitecture/features/transfer/transfer.dart similarity index 100% rename from lib/rearchitecture/dashboard/transfer/transfer.dart rename to lib/rearchitecture/features/transfer/transfer.dart diff --git a/lib/rearchitecture/dashboard/transfer/view/transfer_card.dart b/lib/rearchitecture/features/transfer/view/transfer_card.dart similarity index 96% rename from lib/rearchitecture/dashboard/transfer/view/transfer_card.dart rename to lib/rearchitecture/features/transfer/view/transfer_card.dart index 63f51a36..9b11e664 100644 --- a/lib/rearchitecture/dashboard/transfer/view/transfer_card.dart +++ b/lib/rearchitecture/features/transfer/view/transfer_card.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/card/card.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A card with two [IconButton] widgets that redirect to the Transfer tab diff --git a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart index b54ad7c6..1469cc3c 100644 --- a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart +++ b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart @@ -3,8 +3,8 @@ import 'dart:async'; import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart' hide zenon; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node_sync_status.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -18,10 +18,10 @@ part 'node_sync_status_state.dart'; /// [SyncState] is not related to [NodeSyncStatusState], doesn't handle UI /// updates. /// -/// [NodeSyncStatusState] along with [DashboardStatus] updates the UI of the +/// [NodeSyncStatusState] along with [TimerStatus] updates the UI of the /// [NodeSyncStatusIcon] widget class NodeSyncStatusCubit - extends DashboardCubit, NodeSyncStatusState> { + extends TimerCubit, NodeSyncStatusState> { /// Creates a NodeSyncStatusCubit using the super-initializer parameters NodeSyncStatusCubit(super.zenon, super.initialState); diff --git a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.g.dart b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.g.dart index 05e799f2..ee122e8a 100644 --- a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.g.dart +++ b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.g.dart @@ -8,21 +8,23 @@ part of 'node_sync_status_cubit.dart'; NodeSyncStatusState _$NodeSyncStatusStateFromJson(Map json) => NodeSyncStatusState( - status: $enumDecodeNullable(_$DashboardStatusEnumMap, json['status']) ?? - DashboardStatus.initial, + status: $enumDecodeNullable(_$TimerStatusEnumMap, json['status']) ?? + TimerStatus.initial, data: json['data'] == null ? null : Pair.fromJson( json['data'] as Map, (value) => $enumDecode(_$SyncStateEnumMap, value), (value) => SyncInfo.fromJson(value as Map)), - error: json['error'], + error: json['error'] == null + ? null + : SyriusException.fromJson(json['error'] as Map), ); Map _$NodeSyncStatusStateToJson( NodeSyncStatusState instance) => { - 'status': _$DashboardStatusEnumMap[instance.status]!, + 'status': _$TimerStatusEnumMap[instance.status]!, 'data': instance.data?.toJson( (value) => _$SyncStateEnumMap[value]!, (value) => value, @@ -30,11 +32,11 @@ Map _$NodeSyncStatusStateToJson( 'error': instance.error, }; -const _$DashboardStatusEnumMap = { - DashboardStatus.failure: 'failure', - DashboardStatus.initial: 'initial', - DashboardStatus.loading: 'loading', - DashboardStatus.success: 'success', +const _$TimerStatusEnumMap = { + TimerStatus.failure: 'failure', + TimerStatus.initial: 'initial', + TimerStatus.loading: 'loading', + TimerStatus.success: 'success', }; const _$SyncStateEnumMap = { diff --git a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart index f546c706..4a1b3ab6 100644 --- a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart +++ b/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart @@ -3,7 +3,7 @@ part of 'node_sync_status_cubit.dart'; /// Class used by [NodeSyncStatusCubit] to send state updates to the /// connected view @JsonSerializable() -class NodeSyncStatusState extends DashboardState> { +class NodeSyncStatusState extends TimerState> { /// Creates a NodeSyncStatusState object. const NodeSyncStatusState({ super.status, @@ -16,8 +16,8 @@ class NodeSyncStatusState extends DashboardState> { _$NodeSyncStatusStateFromJson(json); @override - DashboardState> copyWith({ - DashboardStatus? status, + TimerState> copyWith({ + TimerStatus? status, Pair? data, SyriusException? error, }) { diff --git a/lib/rearchitecture/node_sync_status/view/node_sync_status_icon.dart b/lib/rearchitecture/node_sync_status/view/node_sync_status_icon.dart index 8515eb3c..a0bf7858 100644 --- a/lib/rearchitecture/node_sync_status/view/node_sync_status_icon.dart +++ b/lib/rearchitecture/node_sync_status/view/node_sync_status_icon.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node_sync_status.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; /// A widget connected to the [NodeSyncStatusCubit] that receives the state /// - [NodeSyncStatusState] - updates and rebuilds the UI according to the -/// state's status - [DashboardStatus] +/// state's status - [TimerStatus] class NodeSyncStatusIcon extends StatelessWidget { /// Creates a NodeSyncStatusIcon object. const NodeSyncStatusIcon({super.key}); @@ -15,12 +15,12 @@ class NodeSyncStatusIcon extends StatelessWidget { return BlocBuilder( builder: (context, state) { return switch (state.status) { - DashboardStatus.initial => const NodeSyncStatusEmpty(), - DashboardStatus.failure => NodeSyncStatusError( + TimerStatus.initial => const NodeSyncStatusEmpty(), + TimerStatus.failure => NodeSyncStatusError( error: state.error!, ), - DashboardStatus.loading => const NodeSyncStatusLoading(), - DashboardStatus.success => NodeSyncPopulated(data: state.data!), + TimerStatus.loading => const NodeSyncStatusLoading(), + TimerStatus.success => NodeSyncPopulated(data: state.data!), }; }, ); diff --git a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_empty.dart b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_empty.dart index 09180dc8..0c28f86b 100644 --- a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_empty.dart +++ b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_empty.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node_sync_status.dart'; /// A widget associated with the [NodeSyncStatusState] when it's status is -/// [DashboardStatus.initial] that displays an icon with a tooltip message +/// [TimerStatus.initial] that displays an icon with a tooltip message class NodeSyncStatusEmpty extends StatelessWidget { /// Creates a NodeSyncStatusEmpty object. const NodeSyncStatusEmpty({super.key}); diff --git a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart index a63c46cf..758f138e 100644 --- a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart +++ b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart @@ -1,11 +1,10 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node_sync_status.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; /// A widget associated with the [NodeSyncStatusState] when it's status is -/// [DashboardStatus.failure] that displays an icon with a tooltip message +/// [TimerStatus.failure] that displays an icon with a tooltip message class NodeSyncStatusError extends StatelessWidget { /// Creates a NodeSyncStatusError object. const NodeSyncStatusError({required this.error, super.key}); diff --git a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_loading.dart b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_loading.dart index 5da924ab..28a5e76c 100644 --- a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_loading.dart +++ b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_loading.dart @@ -1,10 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node_sync_status.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; /// A widget associated with the [NodeSyncStatusState] when it's status is -/// [DashboardStatus.loading] that displays a loading indicator with a tooltip +/// [TimerStatus.loading] that displays a loading indicator with a tooltip class NodeSyncStatusLoading extends StatelessWidget { /// Creates a NodeSyncStatusLoading object. const NodeSyncStatusLoading({super.key}); diff --git a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_populated.dart b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_populated.dart index d6b4aee9..cf4565b1 100644 --- a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_populated.dart +++ b/lib/rearchitecture/node_sync_status/widgets/node_sync_status_populated.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node_sync_status.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// A widget associated with the [NodeSyncStatusState] when it's status is -/// [DashboardStatus.success] that returns a corresponding icon depending on the +/// [TimerStatus.success] that returns a corresponding icon depending on the /// [SyncInfo] and [SyncState] data class NodeSyncPopulated extends StatelessWidget { /// Creates a NodeSyncPopulated object. diff --git a/lib/rearchitecture/rearchitecture.dart b/lib/rearchitecture/rearchitecture.dart new file mode 100644 index 00000000..0fce4af0 --- /dev/null +++ b/lib/rearchitecture/rearchitecture.dart @@ -0,0 +1,2 @@ +export 'utils/cubits/timer_cubit.dart'; + diff --git a/lib/rearchitecture/utils/cubits/cubits.dart b/lib/rearchitecture/utils/cubits/cubits.dart new file mode 100644 index 00000000..fd81858e --- /dev/null +++ b/lib/rearchitecture/utils/cubits/cubits.dart @@ -0,0 +1 @@ +export 'timer_cubit.dart'; diff --git a/lib/rearchitecture/dashboard/dashboard_cubit.dart b/lib/rearchitecture/utils/cubits/timer_cubit.dart similarity index 82% rename from lib/rearchitecture/dashboard/dashboard_cubit.dart rename to lib/rearchitecture/utils/cubits/timer_cubit.dart index 5a8c69c3..5a8bcd20 100644 --- a/lib/rearchitecture/dashboard/dashboard_cubit.dart +++ b/lib/rearchitecture/utils/cubits/timer_cubit.dart @@ -2,13 +2,11 @@ import 'dart:async'; import 'package:equatable/equatable.dart'; import 'package:hydrated_bloc/hydrated_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/exceptions/cubit_failure_exception.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/exceptions/exceptions.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; -part 'dashboard_state.dart'; +part 'timer_state.dart'; /// An abstract `DashboardCubit` class that manages periodic data fetching for a /// dashboard feature. The cubit emits different states based on data loading, @@ -17,14 +15,14 @@ part 'dashboard_state.dart'; /// The generic type [T] represents the type of data managed by this cubit. /// /// The generic type [S] represents the type of the states emitted by the cubit. -/// [S] extends [DashboardState] -abstract class DashboardCubit> +/// [S] extends [TimerState] +abstract class TimerCubit> extends HydratedCubit { /// Constructs a `DashboardCubit` with the provided [zenon] client and initial /// state. /// /// The auto-refresh functionality is initialized upon the cubit's creation. - DashboardCubit( + TimerCubit( this.zenon, super.initialState, { this.refreshInterval = kDashboardRefreshInterval, @@ -69,19 +67,19 @@ abstract class DashboardCubit> /// If the WebSocket client is closed, it throws a [noConnectionException]. Future fetchDataPeriodically() async { try { - emit(state.copyWith(status: DashboardStatus.loading) as S); + emit(state.copyWith(status: TimerStatus.loading) as S); if (!zenon.wsClient.isClosed()) { final data = await fetch(); - emit(state.copyWith(data: data, status: DashboardStatus.success) as S); + emit(state.copyWith(data: data, status: TimerStatus.success) as S); } else { throw noConnectionException; } - } on DashboardCubitException catch (e) { - emit(state.copyWith(status: DashboardStatus.failure, error: e) as S); + } on CubitException catch (e) { + emit(state.copyWith(status: TimerStatus.failure, error: e) as S); } catch (e) { emit( state.copyWith( - status: DashboardStatus.failure, + status: TimerStatus.failure, error: CubitFailureException(), ) as S, ); diff --git a/lib/rearchitecture/dashboard/dashboard_state.dart b/lib/rearchitecture/utils/cubits/timer_state.dart similarity index 75% rename from lib/rearchitecture/dashboard/dashboard_state.dart rename to lib/rearchitecture/utils/cubits/timer_state.dart index 5edd02d1..35c65c02 100644 --- a/lib/rearchitecture/dashboard/dashboard_state.dart +++ b/lib/rearchitecture/utils/cubits/timer_state.dart @@ -1,9 +1,9 @@ -part of 'dashboard_cubit.dart'; +part of 'timer_cubit.dart'; /// Represents the various statuses a cubit's request can have. /// /// This enum is used to track and emit states with different statuses. -enum DashboardStatus { +enum TimerStatus { /// Indicates that the cubit has encountered an error. failure, /// The initial state before any data has been loaded. @@ -16,33 +16,33 @@ enum DashboardStatus { /// An abstract class that defines the common structure for all cubit states /// -/// The [DashboardState] is designed to be generic, with [T] representing the +/// The [TimerState] is designed to be generic, with [T] representing the /// type of data that is managed by each specific cubit state (e.g., balances, /// transactions, etc.). Subclasses like `BalanceState` extend this class to /// handle specific data types. /// /// The state includes: -/// - [status]: A [DashboardStatus] that indicates the current state (loading, +/// - [status]: A [TimerStatus] that indicates the current state (loading, /// success, etc.). /// - [data]: The data of type [T] that is managed by the cubit. /// - [error]: An optional [error] object that contains error details if the /// cubit is in a failure state. -abstract class DashboardState extends Equatable { +abstract class TimerState extends Equatable { - /// Constructs a [DashboardState] with an [status], [data], and + /// Constructs a [TimerState] with an [status], [data], and /// [error]. /// - /// - The [status] defaults to [DashboardStatus.initial] if not provided. + /// - The [status] defaults to [TimerStatus.initial] if not provided. /// - The [data] and [error] can be null, indicating that either no data has /// been fetched yet, or an error has occurred. - const DashboardState({ - this.status = DashboardStatus.initial, + const TimerState({ + this.status = TimerStatus.initial, this.data, this.error, }); /// Represents the current status of the cubit, such as loading, success, or /// failure. - final DashboardStatus status; + final TimerStatus status; /// The data of type [T] managed by the cubit, which can be null if no data /// has been loaded or if there was an error. @@ -58,11 +58,11 @@ abstract class DashboardState extends Equatable { /// - [data]: The new data of type [T], if it has changed. /// - [error]: The new error, if any occurred. /// - /// Returns a new [DashboardState] with the updated fields. Subclasses + /// Returns a new [TimerState] with the updated fields. Subclasses /// (like `BalanceState`) will implement this to /// ensure type safety and return the appropriate state class. - DashboardState copyWith({ - DashboardStatus? status, + TimerState copyWith({ + TimerStatus? status, T? data, SyriusException? error, }); diff --git a/lib/rearchitecture/utils/exceptions/cubit_exception.dart b/lib/rearchitecture/utils/exceptions/cubit_exception.dart new file mode 100644 index 00000000..12ff6b34 --- /dev/null +++ b/lib/rearchitecture/utils/exceptions/cubit_exception.dart @@ -0,0 +1,10 @@ +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; + +/// A custom exception that displays only the message when printed. +/// +/// To be used to create custom exceptions in a specific case that we +/// are aware about - so that we can add a corresponding message +abstract class CubitException extends SyriusException { + /// Creates a [CubitException] with a required message. + CubitException(super.message); +} diff --git a/lib/utils/exceptions/cubit_failure_exception.dart b/lib/rearchitecture/utils/exceptions/cubit_failure_exception.dart similarity index 90% rename from lib/utils/exceptions/cubit_failure_exception.dart rename to lib/rearchitecture/utils/exceptions/cubit_failure_exception.dart index b6dbd5b9..bfdc8438 100644 --- a/lib/utils/exceptions/cubit_failure_exception.dart +++ b/lib/rearchitecture/utils/exceptions/cubit_failure_exception.dart @@ -1,5 +1,5 @@ import 'package:json_annotation/json_annotation.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; part 'cubit_failure_exception.g.dart'; diff --git a/lib/utils/exceptions/cubit_failure_exception.g.dart b/lib/rearchitecture/utils/exceptions/cubit_failure_exception.g.dart similarity index 100% rename from lib/utils/exceptions/cubit_failure_exception.g.dart rename to lib/rearchitecture/utils/exceptions/cubit_failure_exception.g.dart diff --git a/lib/utils/exceptions/exceptions.dart b/lib/rearchitecture/utils/exceptions/exceptions.dart similarity index 69% rename from lib/utils/exceptions/exceptions.dart rename to lib/rearchitecture/utils/exceptions/exceptions.dart index f99c26b0..db37509e 100644 --- a/lib/utils/exceptions/exceptions.dart +++ b/lib/rearchitecture/utils/exceptions/exceptions.dart @@ -1,2 +1,3 @@ +export 'cubit_exception.dart'; export 'cubit_failure_exception.dart'; export 'syrius_exception.dart'; diff --git a/lib/rearchitecture/utils/exceptions/syrius_exception.dart b/lib/rearchitecture/utils/exceptions/syrius_exception.dart new file mode 100644 index 00000000..c947054a --- /dev/null +++ b/lib/rearchitecture/utils/exceptions/syrius_exception.dart @@ -0,0 +1,24 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'syrius_exception.g.dart'; + +/// A custom exception that displays only the message when printed. +@JsonSerializable() +class SyriusException implements Exception { + /// Creates a [SyriusException] with a required message. + SyriusException(this.message); + + /// Creates a [SyriusException] instance from a JSON map. + factory SyriusException.fromJson(Map json) => + _$SyriusExceptionFromJson(json); + + /// The exception message + final String message; + + /// Converts this [SyriusException] instance to a JSON map. + Map toJson() => _$SyriusExceptionToJson(this); + + /// Returns the exception message without the 'Exception:' prefix. + @override + String toString() => message; +} diff --git a/lib/rearchitecture/utils/exceptions/syrius_exception.g.dart b/lib/rearchitecture/utils/exceptions/syrius_exception.g.dart new file mode 100644 index 00000000..514a03b3 --- /dev/null +++ b/lib/rearchitecture/utils/exceptions/syrius_exception.g.dart @@ -0,0 +1,17 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'syrius_exception.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +SyriusException _$SyriusExceptionFromJson(Map json) => + SyriusException( + json['message'] as String, + ); + +Map _$SyriusExceptionToJson(SyriusException instance) => + { + 'message': instance.message, + }; diff --git a/lib/rearchitecture/utils/extensions/buildcontext_extension.dart b/lib/rearchitecture/utils/extensions/buildcontext_extension.dart new file mode 100644 index 00000000..1c5a3c3d --- /dev/null +++ b/lib/rearchitecture/utils/extensions/buildcontext_extension.dart @@ -0,0 +1,8 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +/// Extension on the [BuildContext] class +extension BuildContextExtensions on BuildContext { + /// Getter method for easier access to the [AppLocalizations] instance + AppLocalizations get l10n => AppLocalizations.of(this)!; +} diff --git a/lib/rearchitecture/utils/extensions/extensions.dart b/lib/rearchitecture/utils/extensions/extensions.dart new file mode 100644 index 00000000..97e02ab1 --- /dev/null +++ b/lib/rearchitecture/utils/extensions/extensions.dart @@ -0,0 +1,2 @@ +export 'buildcontext_extension.dart'; +export 'sync_state_extension.dart'; diff --git a/lib/rearchitecture/utils/extensions/sync_state_extension.dart b/lib/rearchitecture/utils/extensions/sync_state_extension.dart new file mode 100644 index 00000000..c05f9cbf --- /dev/null +++ b/lib/rearchitecture/utils/extensions/sync_state_extension.dart @@ -0,0 +1,16 @@ +import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +/// Extension on the [SyncState] class +extension SyncStateExtension on SyncState { + /// Returns a color, depending on the enum value + Color? getColor({required BuildContext context}) { + return switch (this) { + SyncState.unknown => Theme.of(context).iconTheme.color, + SyncState.syncing => Colors.orange, + SyncState.syncDone => AppColors.znnColor, + SyncState.notEnoughPeers => AppColors.errorColor, + }; + } +} diff --git a/lib/utils/card/card.dart b/lib/rearchitecture/utils/models/card/card.dart similarity index 100% rename from lib/utils/card/card.dart rename to lib/rearchitecture/utils/models/card/card.dart diff --git a/lib/utils/card/card_data.dart b/lib/rearchitecture/utils/models/card/card_data.dart similarity index 100% rename from lib/utils/card/card_data.dart rename to lib/rearchitecture/utils/models/card/card_data.dart diff --git a/lib/utils/card/card_type.dart b/lib/rearchitecture/utils/models/card/card_type.dart similarity index 92% rename from lib/utils/card/card_type.dart rename to lib/rearchitecture/utils/models/card/card_type.dart index c58caf59..9e871efa 100644 --- a/lib/utils/card/card_type.dart +++ b/lib/rearchitecture/utils/models/card/card_type.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/card/card_data.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/models/card/card.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; enum CardType { diff --git a/lib/rearchitecture/utils/models/models.dart b/lib/rearchitecture/utils/models/models.dart new file mode 100644 index 00000000..1cd32ceb --- /dev/null +++ b/lib/rearchitecture/utils/models/models.dart @@ -0,0 +1 @@ +export 'card/card.dart'; diff --git a/lib/rearchitecture/utils/utils.dart b/lib/rearchitecture/utils/utils.dart new file mode 100644 index 00000000..4d38bcd7 --- /dev/null +++ b/lib/rearchitecture/utils/utils.dart @@ -0,0 +1,5 @@ +export 'cubits/cubits.dart'; +export 'exceptions/exceptions.dart'; +export 'extensions/extensions.dart'; +export 'models/models.dart'; +export 'widgets/widgets.dart'; diff --git a/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart b/lib/rearchitecture/utils/widgets/card_scaffold_without_listener.dart similarity index 99% rename from lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart rename to lib/rearchitecture/utils/widgets/card_scaffold_without_listener.dart index 77b94930..be737657 100644 --- a/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold_without_listener.dart +++ b/lib/rearchitecture/utils/widgets/card_scaffold_without_listener.dart @@ -6,6 +6,7 @@ import 'package:lottie/lottie.dart'; import 'package:stacked/stacked.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; diff --git a/lib/rearchitecture/utils/widgets/widgets.dart b/lib/rearchitecture/utils/widgets/widgets.dart new file mode 100644 index 00000000..22d688ce --- /dev/null +++ b/lib/rearchitecture/utils/widgets/widgets.dart @@ -0,0 +1 @@ +export 'card_scaffold_without_listener.dart'; \ No newline at end of file diff --git a/lib/utils/exceptions/syrius_exception.dart b/lib/utils/exceptions/syrius_exception.dart deleted file mode 100644 index 6c2afc4c..00000000 --- a/lib/utils/exceptions/syrius_exception.dart +++ /dev/null @@ -1,11 +0,0 @@ -/// A custom exception that displays only the message when printed. -abstract class SyriusException implements Exception { - /// Creates a [SyriusException] with a required message. - SyriusException(this.message); - /// The exception message - final String message; - - /// Returns the exception message without the 'Exception:' prefix. - @override - String toString() => message; -} diff --git a/lib/utils/extensions.dart b/lib/utils/extensions.dart index 2f55be8a..8efa8afe 100644 --- a/lib/utils/extensions.dart +++ b/lib/utils/extensions.dart @@ -1,10 +1,6 @@ import 'dart:math' show pow; import 'package:big_decimal/big_decimal.dart'; -import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_ledger_dart/znn_ledger_dart.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; extension StringExtensions on String { String capitalize() { @@ -123,19 +119,4 @@ extension LedgerErrorExtensions on LedgerError { return 'Unknown error, please make sure the device is unlocked'; } } -} - -extension BuildContextL10n on BuildContext { - AppLocalizations get l10n => AppLocalizations.of(this)!; -} - -extension SyncStateExtension on SyncState { - Color? getColor({required BuildContext context}) { - return switch (this) { - SyncState.unknown => Theme.of(context).iconTheme.color, - SyncState.syncing => Colors.orange, - SyncState.syncDone => AppColors.znnColor, - SyncState.notEnoughPeers => AppColors.errorColor, - }; - } -} +} \ No newline at end of file diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 27080864..34ef0978 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -2,13 +2,11 @@ export 'account_block_utils.dart'; export 'address_utils.dart'; export 'app_colors.dart'; export 'app_theme.dart'; -export 'card/card.dart'; export 'clipboard_utils.dart'; export 'color_utils.dart'; export 'constants.dart'; export 'date_time_utils.dart'; export 'device_utils.dart'; -export 'exceptions/exceptions.dart'; export 'extensions.dart'; export 'file_utils.dart'; export 'format_utils.dart'; diff --git a/lib/widgets/reusable_widgets/layout_scaffold/layout_scaffold.dart b/lib/widgets/reusable_widgets/layout_scaffold/layout_scaffold.dart index a9b503c7..a254a06d 100644 --- a/lib/widgets/reusable_widgets/layout_scaffold/layout_scaffold.dart +++ b/lib/widgets/reusable_widgets/layout_scaffold/layout_scaffold.dart @@ -1,5 +1,4 @@ export 'card_scaffold.dart'; -export 'card_scaffold_without_listener.dart'; export 'overscroll_remover.dart'; export 'standard_fluid_layout.dart'; export 'widget_animator.dart'; diff --git a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart index b8bede97..8ed2038c 100644 --- a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart +++ b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:layout/layout.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class DashboardTabChild extends StatefulWidget { diff --git a/lib/widgets/widgets.dart b/lib/widgets/widgets.dart index a3ce88fa..f23b3668 100644 --- a/lib/widgets/widgets.dart +++ b/lib/widgets/widgets.dart @@ -1,5 +1,4 @@ export 'charts/pillar_rewards_chart.dart'; -export '../rearchitecture/dashboard/realtime_statistics/widgets/realtime_txs_chart.dart'; export 'charts/sentinel_rewards_chart.dart'; export 'charts/staking_rewards_chart.dart'; export 'main_app_container.dart'; diff --git a/test/delegation/cubit/delegation_cubit_test.dart b/test/delegation/cubit/delegation_cubit_test.dart index 54bfe8bc..10b48801 100644 --- a/test/delegation/cubit/delegation_cubit_test.dart +++ b/test/delegation/cubit/delegation_cubit_test.dart @@ -3,7 +3,7 @@ import 'package:bloc_test/bloc_test.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/dashboard.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/dashboard/features.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class MockZenon extends Mock implements Zenon {} @@ -58,7 +58,7 @@ void main() { }); group('fetchDataPeriodically', () { - blocTest( + blocTest( 'calls getDelegatedPillar once', build: () => delegationCubit, act: (cubit) => cubit.fetchDataPeriodically(), @@ -69,7 +69,7 @@ void main() { }, ); - blocTest( + blocTest( 'emits [loading, failure] when getDelegatedPillar throws', setUp: () { when( @@ -89,7 +89,7 @@ void main() { ], ); - blocTest( + blocTest( 'emits [loading, success] when getDelegatedPillar ' 'returns a DelegationInfo instance', build: () => delegationCubit, From 1608ca7d77dbe46ca985bcc53f1e50c03b1159b8 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Mon, 28 Oct 2024 10:12:42 +0200 Subject: [PATCH 050/102] chore: Move node_sync_status inside features folder --- lib/rearchitecture/features/features.dart | 1 + .../node_sync_status/cubit/node_sync_status_cubit.dart | 2 +- .../node_sync_status/cubit/node_sync_status_cubit.g.dart | 0 .../node_sync_status/cubit/node_sync_status_state.dart | 0 .../{ => features}/node_sync_status/node_sync_status.dart | 0 .../node_sync_status/view/node_sync_status_icon.dart | 2 +- .../node_sync_status/widgets/node_sync_status_empty.dart | 3 ++- .../node_sync_status/widgets/node_sync_status_error.dart | 4 ++-- .../node_sync_status/widgets/node_sync_status_loading.dart | 3 ++- .../node_sync_status/widgets/node_sync_status_populated.dart | 2 +- .../{ => features}/node_sync_status/widgets/widgets.dart | 0 lib/widgets/main_app_container.dart | 2 +- 12 files changed, 11 insertions(+), 8 deletions(-) rename lib/rearchitecture/{ => features}/node_sync_status/cubit/node_sync_status_cubit.dart (95%) rename lib/rearchitecture/{ => features}/node_sync_status/cubit/node_sync_status_cubit.g.dart (100%) rename lib/rearchitecture/{ => features}/node_sync_status/cubit/node_sync_status_state.dart (100%) rename lib/rearchitecture/{ => features}/node_sync_status/node_sync_status.dart (100%) rename lib/rearchitecture/{ => features}/node_sync_status/view/node_sync_status_icon.dart (91%) rename lib/rearchitecture/{ => features}/node_sync_status/widgets/node_sync_status_empty.dart (76%) rename lib/rearchitecture/{ => features}/node_sync_status/widgets/node_sync_status_error.dart (89%) rename lib/rearchitecture/{ => features}/node_sync_status/widgets/node_sync_status_loading.dart (82%) rename lib/rearchitecture/{ => features}/node_sync_status/widgets/node_sync_status_populated.dart (97%) rename lib/rearchitecture/{ => features}/node_sync_status/widgets/widgets.dart (100%) diff --git a/lib/rearchitecture/features/features.dart b/lib/rearchitecture/features/features.dart index 2c0ac53d..cb45f5aa 100644 --- a/lib/rearchitecture/features/features.dart +++ b/lib/rearchitecture/features/features.dart @@ -1,6 +1,7 @@ export 'balance/balance.dart'; export 'delegation/delegation.dart'; export 'dual_coin_stats/dual_coin_stats.dart'; +export 'node_sync_status/node_sync_status.dart'; export 'pillars/pillars.dart'; export 'realtime_statistics/realtime_statistics.dart'; export 'sentinels/sentinels.dart'; diff --git a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart b/lib/rearchitecture/features/node_sync_status/cubit/node_sync_status_cubit.dart similarity index 95% rename from lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart rename to lib/rearchitecture/features/node_sync_status/cubit/node_sync_status_cubit.dart index 1469cc3c..79ac1dc2 100644 --- a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.dart +++ b/lib/rearchitecture/features/node_sync_status/cubit/node_sync_status_cubit.dart @@ -3,7 +3,7 @@ import 'dart:async'; import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart' hide zenon; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node_sync_status.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.g.dart b/lib/rearchitecture/features/node_sync_status/cubit/node_sync_status_cubit.g.dart similarity index 100% rename from lib/rearchitecture/node_sync_status/cubit/node_sync_status_cubit.g.dart rename to lib/rearchitecture/features/node_sync_status/cubit/node_sync_status_cubit.g.dart diff --git a/lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart b/lib/rearchitecture/features/node_sync_status/cubit/node_sync_status_state.dart similarity index 100% rename from lib/rearchitecture/node_sync_status/cubit/node_sync_status_state.dart rename to lib/rearchitecture/features/node_sync_status/cubit/node_sync_status_state.dart diff --git a/lib/rearchitecture/node_sync_status/node_sync_status.dart b/lib/rearchitecture/features/node_sync_status/node_sync_status.dart similarity index 100% rename from lib/rearchitecture/node_sync_status/node_sync_status.dart rename to lib/rearchitecture/features/node_sync_status/node_sync_status.dart diff --git a/lib/rearchitecture/node_sync_status/view/node_sync_status_icon.dart b/lib/rearchitecture/features/node_sync_status/view/node_sync_status_icon.dart similarity index 91% rename from lib/rearchitecture/node_sync_status/view/node_sync_status_icon.dart rename to lib/rearchitecture/features/node_sync_status/view/node_sync_status_icon.dart index a0bf7858..9a997a75 100644 --- a/lib/rearchitecture/node_sync_status/view/node_sync_status_icon.dart +++ b/lib/rearchitecture/features/node_sync_status/view/node_sync_status_icon.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node_sync_status.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; /// A widget connected to the [NodeSyncStatusCubit] that receives the state diff --git a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_empty.dart b/lib/rearchitecture/features/node_sync_status/widgets/node_sync_status_empty.dart similarity index 76% rename from lib/rearchitecture/node_sync_status/widgets/node_sync_status_empty.dart rename to lib/rearchitecture/features/node_sync_status/widgets/node_sync_status_empty.dart index 0c28f86b..c65a3fb4 100644 --- a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_empty.dart +++ b/lib/rearchitecture/features/node_sync_status/widgets/node_sync_status_empty.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node_sync_status.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; /// A widget associated with the [NodeSyncStatusState] when it's status is /// [TimerStatus.initial] that displays an icon with a tooltip message diff --git a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart b/lib/rearchitecture/features/node_sync_status/widgets/node_sync_status_error.dart similarity index 89% rename from lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart rename to lib/rearchitecture/features/node_sync_status/widgets/node_sync_status_error.dart index 758f138e..6decba31 100644 --- a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_error.dart +++ b/lib/rearchitecture/features/node_sync_status/widgets/node_sync_status_error.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node_sync_status.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; /// A widget associated with the [NodeSyncStatusState] when it's status is /// [TimerStatus.failure] that displays an icon with a tooltip message diff --git a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_loading.dart b/lib/rearchitecture/features/node_sync_status/widgets/node_sync_status_loading.dart similarity index 82% rename from lib/rearchitecture/node_sync_status/widgets/node_sync_status_loading.dart rename to lib/rearchitecture/features/node_sync_status/widgets/node_sync_status_loading.dart index 28a5e76c..816e12a8 100644 --- a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_loading.dart +++ b/lib/rearchitecture/features/node_sync_status/widgets/node_sync_status_loading.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node_sync_status.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; /// A widget associated with the [NodeSyncStatusState] when it's status is diff --git a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_populated.dart b/lib/rearchitecture/features/node_sync_status/widgets/node_sync_status_populated.dart similarity index 97% rename from lib/rearchitecture/node_sync_status/widgets/node_sync_status_populated.dart rename to lib/rearchitecture/features/node_sync_status/widgets/node_sync_status_populated.dart index cf4565b1..bc516483 100644 --- a/lib/rearchitecture/node_sync_status/widgets/node_sync_status_populated.dart +++ b/lib/rearchitecture/features/node_sync_status/widgets/node_sync_status_populated.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node_sync_status.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/rearchitecture/node_sync_status/widgets/widgets.dart b/lib/rearchitecture/features/node_sync_status/widgets/widgets.dart similarity index 100% rename from lib/rearchitecture/node_sync_status/widgets/widgets.dart rename to lib/rearchitecture/features/node_sync_status/widgets/widgets.dart diff --git a/lib/widgets/main_app_container.dart b/lib/widgets/main_app_container.dart index 32be6331..03f49711 100644 --- a/lib/widgets/main_app_container.dart +++ b/lib/widgets/main_app_container.dart @@ -18,7 +18,7 @@ import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/handlers/htlc_swaps_handler.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/model/model.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/node_sync_status/node_sync_status.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/clipboard_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; From bdd9f03517db83a72b784c6cab4835cb53c51f36 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Mon, 28 Oct 2024 16:09:11 +0200 Subject: [PATCH 051/102] chore: Improve documentation --- analysis_options.yaml | 2 + .../features/balance/cubit/balance_cubit.dart | 4 +- .../features/balance/cubit/balance_state.dart | 6 +- .../exceptions/no_balance_exception.dart | 1 + .../features/balance/view/balance_card.dart | 13 ++-- .../balance/widgets/balance_chart_legend.dart | 1 + .../balance/widgets/balance_error.dart | 3 +- .../balance/widgets/balance_loading.dart | 1 + .../balance/widgets/balance_populated.dart | 10 +-- .../no_delegation_stats_exception.dart | 1 + .../cubit/dual_coin_stats_cubit.dart | 4 +- .../cubit/dual_coin_stats_state.dart | 22 +++---- .../view/dual_coin_stats_card.dart | 2 - .../widgets/dual_coin_stats_loading.dart | 1 + .../widgets/dual_coin_stats_populated.dart | 1 + .../features/pillars/cubit/pillars_cubit.dart | 20 ++---- .../features/pillars/cubit/pillars_state.dart | 23 +++---- .../features/pillars/view/pillars_card.dart | 2 - .../pillars/widgets/pillars_loading.dart | 1 + .../pillars/widgets/pillars_populated.dart | 1 + .../cubit/realtime_statistics_cubit.dart | 22 +++---- .../cubit/realtime_statistics_state.dart | 22 +++---- .../no_blocks_available_exception.dart | 1 + .../view/realtime_statistics_card.dart | 2 - .../sentinels/cubit/sentinels_cubit.dart | 28 +++------ .../sentinels/cubit/sentinels_state.dart | 24 +++----- .../sentinels/view/sentinels_card.dart | 2 - .../sentinels/widgets/sentinels_loading.dart | 1 + .../widgets/sentinels_populated.dart | 1 + .../features/staking/cubit/staking_cubit.dart | 42 ++++--------- .../features/staking/cubit/staking_state.dart | 18 +++--- .../no_active_skaking_entries_exception.dart | 1 + .../features/staking/view/staking_card.dart | 2 - .../staking/widgets/staking_loading.dart | 1 + .../total_hourly_transactions_cubit.dart | 61 +++++++------------ .../total_hourly_transactions_state.dart | 20 +++--- .../not_enough_momentums_exception.dart | 1 + .../view/total_hourly_transactions_card.dart | 2 - .../total_hourly_transactions_loading.dart | 1 + lib/rearchitecture/rearchitecture.dart | 1 - .../utils/cubits/timer_cubit.dart | 8 ++- .../utils/cubits/timer_state.dart | 4 +- .../exceptions/cubit_failure_exception.dart | 1 + .../utils/models/card/card.dart | 2 +- .../utils/models/card/card_data.dart | 8 ++- .../utils/models/card/card_type.dart | 12 +++- lib/rearchitecture/utils/widgets/widgets.dart | 2 +- lib/utils/pair.dart | 4 +- 48 files changed, 172 insertions(+), 241 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index ef928e17..77011475 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,6 +1,8 @@ include: package:very_good_analysis/analysis_options.yaml analyzer: + exclude: + - "**/*.g.dart" language: # I've disabled it so as to make the code compile without # strict type-checking diff --git a/lib/rearchitecture/features/balance/cubit/balance_cubit.dart b/lib/rearchitecture/features/balance/cubit/balance_cubit.dart index fac5cf85..a451b85c 100644 --- a/lib/rearchitecture/features/balance/cubit/balance_cubit.dart +++ b/lib/rearchitecture/features/balance/cubit/balance_cubit.dart @@ -19,8 +19,8 @@ class BalanceCubit extends TimerCubit { /// Fetches the balance information for a single address. /// - /// The method interacts with the `zenon` client's ledger to get the - /// `AccountInfo` for the provided [address]. + /// The method interacts with the [zenon] client's ledger to get the + /// [AccountInfo] for the provided [address]. /// /// Returns an [AccountInfo] object containing the balance details for the /// given address. diff --git a/lib/rearchitecture/features/balance/cubit/balance_state.dart b/lib/rearchitecture/features/balance/cubit/balance_state.dart index 73f8b979..0b1f0164 100644 --- a/lib/rearchitecture/features/balance/cubit/balance_state.dart +++ b/lib/rearchitecture/features/balance/cubit/balance_state.dart @@ -3,7 +3,7 @@ part of 'balance_cubit.dart'; /// The class used by the [BalanceCubit] to send state updates to the /// listening widgets. /// -/// The data hold, when the status is [TimerStatus.success] is of type +/// The data hold, when the status is [TimerStatus.success], is of type /// [AccountInfo]. @JsonSerializable() class BalanceState extends TimerState { @@ -26,10 +26,6 @@ class BalanceState extends TimerState { /// /// This method is used to create a new state with updated fields if provided, /// otherwise retaining the existing values. - /// - /// Returns: - /// - A new instance of [BalanceState] with the updated values or the - /// existing ones if none are provided. @override TimerState copyWith({ TimerStatus? status, diff --git a/lib/rearchitecture/features/balance/exceptions/no_balance_exception.dart b/lib/rearchitecture/features/balance/exceptions/no_balance_exception.dart index 51a18278..c021a7c4 100644 --- a/lib/rearchitecture/features/balance/exceptions/no_balance_exception.dart +++ b/lib/rearchitecture/features/balance/exceptions/no_balance_exception.dart @@ -16,5 +16,6 @@ class NoBalanceException extends CubitException { /// Converts this [NoBalanceException] instance to a JSON map. + @override Map toJson() => _$NoBalanceExceptionToJson(this); } diff --git a/lib/rearchitecture/features/balance/view/balance_card.dart b/lib/rearchitecture/features/balance/view/balance_card.dart index 2c0d9b69..c717ab94 100644 --- a/lib/rearchitecture/features/balance/view/balance_card.dart +++ b/lib/rearchitecture/features/balance/view/balance_card.dart @@ -2,22 +2,19 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/widgets/card_scaffold_without_listener.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; -/// A `BalanceCard` widget that displays balance information for a user. +/// A [BalanceCard] widget that displays balance information for a user. /// -/// The widget uses a `BalanceCubit` to fetch and manage account balance data +/// The widget uses a [BalanceCubit] to fetch and manage account balance data /// and presents the state in different views based on the current status /// (e.g., loading, success, failure). +/// +/// Expects a [BalanceCubit] to be provided via a [BlocProvider]. class BalanceCard extends StatelessWidget { - /// Constructs a `BalanceCard` widget. - /// - /// The widget is a stateless widget and expects a `BalanceCubit` to be - /// provided via a `BlocProvider`. + /// Constructs a [BalanceCard] widget. const BalanceCard({super.key}); @override diff --git a/lib/rearchitecture/features/balance/widgets/balance_chart_legend.dart b/lib/rearchitecture/features/balance/widgets/balance_chart_legend.dart index 443b03d3..49242a37 100644 --- a/lib/rearchitecture/features/balance/widgets/balance_chart_legend.dart +++ b/lib/rearchitecture/features/balance/widgets/balance_chart_legend.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/balance/balance.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/rearchitecture/features/balance/widgets/balance_error.dart b/lib/rearchitecture/features/balance/widgets/balance_error.dart index 110a4f80..9cc85e21 100644 --- a/lib/rearchitecture/features/balance/widgets/balance_error.dart +++ b/lib/rearchitecture/features/balance/widgets/balance_error.dart @@ -1,11 +1,12 @@ import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/balance/balance.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/exceptions/exceptions.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; /// A [BalanceError] widget that displays an error message when the balance /// data fetching fails. /// -/// This widget is displayed when the `BalanceCubit` encounters an error +/// This widget is displayed when the [BalanceCubit] encounters an error /// while trying to load the balance data. class BalanceError extends StatelessWidget { /// Creates a BalanceError object. diff --git a/lib/rearchitecture/features/balance/widgets/balance_loading.dart b/lib/rearchitecture/features/balance/widgets/balance_loading.dart index 1858ef33..e08eb82f 100644 --- a/lib/rearchitecture/features/balance/widgets/balance_loading.dart +++ b/lib/rearchitecture/features/balance/widgets/balance_loading.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; /// A widget that displays a loading message while the balance data is being diff --git a/lib/rearchitecture/features/balance/widgets/balance_populated.dart b/lib/rearchitecture/features/balance/widgets/balance_populated.dart index 226d62f3..cbfcba9c 100644 --- a/lib/rearchitecture/features/balance/widgets/balance_populated.dart +++ b/lib/rearchitecture/features/balance/widgets/balance_populated.dart @@ -1,14 +1,16 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/balance/balance.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; -/// A `BalancePopulated` widget that displays balance data once it has been +/// A [BalancePopulated] widget that displays balance data once it has been /// successfully fetched and populated. /// -/// This widget is displayed when the `BalanceCubit` is in the `success` state, -/// and the balance data is available for rendering. +/// This widget is displayed when the [BalanceCubit] is in the +/// [TimerStatus.success] state, and the balance data is available for +/// rendering. class BalancePopulated extends StatefulWidget { /// Creates a BalancePopulated object. const BalancePopulated({ @@ -19,7 +21,7 @@ class BalancePopulated extends StatefulWidget { /// The balance data that has been successfully fetched. /// /// The data is a map where the key is a string (representing the account - /// address), and the value is an `AccountInfo` object containing the balance + /// address), and the value is an [AccountInfo] object containing the balance /// details. final AccountInfo accountInfo; diff --git a/lib/rearchitecture/features/delegation/exceptions/no_delegation_stats_exception.dart b/lib/rearchitecture/features/delegation/exceptions/no_delegation_stats_exception.dart index 7b4543c7..1b2a0d74 100644 --- a/lib/rearchitecture/features/delegation/exceptions/no_delegation_stats_exception.dart +++ b/lib/rearchitecture/features/delegation/exceptions/no_delegation_stats_exception.dart @@ -15,5 +15,6 @@ class NoDelegationStatsException extends CubitException { /// Converts this [NoDelegationStatsException] instance to a JSON map. + @override Map toJson() => _$NoDelegationStatsExceptionToJson(this); } diff --git a/lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_cubit.dart b/lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_cubit.dart index 0862df9a..c1519e9d 100644 --- a/lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_cubit.dart +++ b/lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_cubit.dart @@ -6,8 +6,8 @@ part 'dual_coin_stats_cubit.g.dart'; part 'dual_coin_stats_state.dart'; -/// A cubit that manages the fetching and state of dual coin statistics -/// for ZNN and QSR tokens. +/// A cubit that manages the fetching and state of dual coin statistics - ZNN +/// and QSR. /// /// This cubit extends [TimerCubit], using a list of [Token] objects to /// represent the statistics for the ZNN and QSR tokens fetched from the Zenon diff --git a/lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_state.dart b/lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_state.dart index 9c311a00..92ed976e 100644 --- a/lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_state.dart +++ b/lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_state.dart @@ -1,19 +1,19 @@ part of 'dual_coin_stats_cubit.dart'; -/// The state class for the `DualCoinStatsCubit`, extending `DashboardState` to +/// The state class for the [DualCoinStatsCubit], extending [TimerState] to /// manage data related to ZNN and QSR. /// -/// `DualCoinStatsState` stores a list of `Token?` objects representing data +/// [DualCoinStatsState] stores a list of [Token] objects representing data /// for two tokens. -/// This state is used by the `DualCoinStatsCubit` to track and update the +/// This state is used by the [DualCoinStatsCubit] to track and update the /// state of both tokens. @JsonSerializable() class DualCoinStatsState extends TimerState> { - /// Constructs a new `DualCoinStatsState`. + /// Constructs a new [DualCoinStatsState]. /// - /// This state is initialized with default `status`, `data`, and `error` - /// values from the parent `DashboardState` class. - /// It manages a list of `Token?` objects that represent the two tokens' data. + /// This state is initialized with default [status], [data], and [error] + /// values from the parent [TimerState] class. + /// It manages a list of [Token] objects that represent the two coins' data. const DualCoinStatsState({ super.status, super.data, @@ -24,15 +24,11 @@ class DualCoinStatsState extends TimerState> { factory DualCoinStatsState.fromJson(Map json) => _$DualCoinStatsStateFromJson(json); - /// Creates a copy of the current `DualCoinStatsState` with optional new - /// values for `status`, `data`, and `error`. + /// Creates a copy of the current [DualCoinStatsState] with optional new + /// values for [status], [data], and [error]. /// /// This method is used to create a new state with updated fields if provided, /// otherwise retaining the existing values. - /// - /// Returns: - /// - A new instance of `DualCoinStatsState` with the updated values or the - /// existing ones if none are provided. @override TimerState> copyWith({ TimerStatus? status, diff --git a/lib/rearchitecture/features/dual_coin_stats/view/dual_coin_stats_card.dart b/lib/rearchitecture/features/dual_coin_stats/view/dual_coin_stats_card.dart index f5128af9..d7c87f79 100644 --- a/lib/rearchitecture/features/dual_coin_stats/view/dual_coin_stats_card.dart +++ b/lib/rearchitecture/features/dual_coin_stats/view/dual_coin_stats_card.dart @@ -2,9 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/widgets/card_scaffold_without_listener.dart'; /// Widget connected to the [DualCoinStatsCubit] that receives the state diff --git a/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_loading.dart b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_loading.dart index cbde656c..de0fae6b 100644 --- a/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_loading.dart +++ b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_loading.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; /// A widget associated with the [DualCoinStatsState] when it's status is diff --git a/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_populated.dart b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_populated.dart index c6c82e7d..911006f0 100644 --- a/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_populated.dart +++ b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_populated.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// A widget associated with the [DualCoinStatsState] when it's status is diff --git a/lib/rearchitecture/features/pillars/cubit/pillars_cubit.dart b/lib/rearchitecture/features/pillars/cubit/pillars_cubit.dart index 842dab7f..71437cee 100644 --- a/lib/rearchitecture/features/pillars/cubit/pillars_cubit.dart +++ b/lib/rearchitecture/features/pillars/cubit/pillars_cubit.dart @@ -5,35 +5,25 @@ part 'pillars_cubit.g.dart'; part 'pillars_state.dart'; -/// `PillarsCubit` manages the fetching and state of pillar statistics. +/// [PillarsCubit] manages the fetching and state of pillar statistics. /// -/// This cubit extends `DashboardCubit`, using an integer to represent the -/// total number of pillars fetched from the Zenon network. +/// It uses an integer to represent the total number of pillars fetched from +/// the Zenon network. class PillarsCubit extends TimerCubit { - /// Constructs a `PillarsCubit`, passing the `zenon` client and the initial + /// Constructs a [PillarsCubit], passing the [zenon] client and the initial /// state to the parent class. /// - /// The `zenon` client is used to interact with the Zenon network to retrieve + /// The [zenon] client is used to interact with the Zenon network to retrieve /// pillar information. PillarsCubit(super.zenon, super.initialState); /// Fetches the total count of pillars from the Zenon network. - /// - /// This method retrieves all pillar information using the Zenon SDK's - /// `getAll()` method and returns the total number of pillars as an integer. - /// - /// Throws: - /// - An error if any exception occurs during the fetching of pillar data. @override Future fetch() async { - try { // Fetches the list of all pillars from the Zenon network final pillarInfoList = await zenon.embedded.pillar.getAll(); final data = pillarInfoList.list.length; // Counts the number of pillars return data; // Returns the total number of pillars - } catch (e) { - rethrow; - } } @override diff --git a/lib/rearchitecture/features/pillars/cubit/pillars_state.dart b/lib/rearchitecture/features/pillars/cubit/pillars_state.dart index 49d47445..d27e40aa 100644 --- a/lib/rearchitecture/features/pillars/cubit/pillars_state.dart +++ b/lib/rearchitecture/features/pillars/cubit/pillars_state.dart @@ -1,19 +1,17 @@ part of 'pillars_cubit.dart'; -/// The state class for the `PillarsCubit`, extending `DashboardState` to -/// manage the data related to pillars. +/// This state is used by the [PillarsCubit] to track and update the number of +/// active pillars. /// -/// `PillarsState` stores an integer value representing the number of pillars +/// [PillarsState] stores an integer value representing the number of pillars /// retrieved from the Zenon network. -/// This state is used by the `PillarsCubit` to track and update the number of -/// active pillars. @JsonSerializable() class PillarsState extends TimerState { - /// Constructs a new `PillarsState`. + /// Constructs a new [PillarsState] object. /// - /// This state is initialized with the default `status`, `data`, and `error` - /// values from the parent `DashboardState` class. - /// The `data` field in this case represents the count of active pillars on + /// This state is initialized with the default [status], [data], and [error] + /// values from the parent [TimerState] class. + /// The [data] field in this case represents the count of active pillars on /// the Zenon network. const PillarsState({ super.status, @@ -25,15 +23,8 @@ class PillarsState extends TimerState { factory PillarsState.fromJson(Map json) => _$PillarsStateFromJson(json); - /// Creates a copy of the current `PillarsState` with optional new values for - /// `status`, `data`, and `error`. - /// /// This method is used to create a new state with updated fields if provided, /// otherwise retaining the existing values. - /// - /// Returns: - /// - A new instance of `PillarsState` with the updated values or the - /// existing ones if none are provided. @override TimerState copyWith({ TimerStatus? status, diff --git a/lib/rearchitecture/features/pillars/view/pillars_card.dart b/lib/rearchitecture/features/pillars/view/pillars_card.dart index 5770f666..4dc3eec3 100644 --- a/lib/rearchitecture/features/pillars/view/pillars_card.dart +++ b/lib/rearchitecture/features/pillars/view/pillars_card.dart @@ -2,9 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/widgets/card_scaffold_without_listener.dart'; /// Widget connected to the [PillarsCubit] that receives the state /// - [PillarsState] - updates and rebuilds the UI according to the diff --git a/lib/rearchitecture/features/pillars/widgets/pillars_loading.dart b/lib/rearchitecture/features/pillars/widgets/pillars_loading.dart index b5034530..b0bef239 100644 --- a/lib/rearchitecture/features/pillars/widgets/pillars_loading.dart +++ b/lib/rearchitecture/features/pillars/widgets/pillars_loading.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A widget associated with the [PillarsState] when it's status is diff --git a/lib/rearchitecture/features/pillars/widgets/pillars_populated.dart b/lib/rearchitecture/features/pillars/widgets/pillars_populated.dart index 554e306f..fa575c6d 100644 --- a/lib/rearchitecture/features/pillars/widgets/pillars_populated.dart +++ b/lib/rearchitecture/features/pillars/widgets/pillars_populated.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/reusable_widgets.dart'; /// A widget associated with the [PillarsState] when it's status is diff --git a/lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_cubit.dart b/lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_cubit.dart index ce593d72..5d97c5e1 100644 --- a/lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_cubit.dart +++ b/lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_cubit.dart @@ -1,26 +1,24 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'realtime_statistics_cubit.g.dart'; - part 'realtime_statistics_state.dart'; -/// `RealtimeStatisticsCubit` manages the fetching and state of real-time +/// [RealtimeStatisticsCubit] manages the fetching and state of real-time /// account block statistics for a specific address. /// -/// This cubit extends `DashboardCubit>`, using a list of -/// `AccountBlock` objects to represent the account blocks fetched from the -/// Zenon network. +/// It uses a list of [AccountBlock] objects to represent the account blocks +/// fetched from the Zenon network. class RealtimeStatisticsCubit extends TimerCubit, RealtimeStatisticsState> { - /// Constructs a `RealtimeStatisticsCubit`, passing the `zenon` client and + /// Constructs a [RealtimeStatisticsCubit], passing the [zenon] client and /// the initial state to the parent class. /// - /// The `zenon` client is used to interact with the Zenon network to retrieve + /// The [zenon] client is used to interact with the Zenon network to retrieve /// account block information. RealtimeStatisticsCubit(super.zenon, super.initialState); @@ -28,7 +26,7 @@ class RealtimeStatisticsCubit /// week. /// /// This method retrieves the account blocks by: - /// - Determining the chain height using the `getFrontierMomentum()` method. + /// - Determining the chain height. /// - Calculating the starting height based on the momentums per week. /// - Fetching account blocks page by page until there are no more blocks to /// retrieve. @@ -36,14 +34,13 @@ class RealtimeStatisticsCubit /// block's momentum height is less than the calculated height. /// /// Returns: - /// - A list of `AccountBlock` objects representing the account blocks + /// - A list of [AccountBlock] objects representing the account blocks /// fetched from the network. /// /// Throws: /// - An [NoBlocksAvailableException] if no data is available @override Future> fetch() async { - try { // Get the current chain height final chainHeight = (await zenon.ledger.getFrontierMomentum()).height; // Calculate the starting height for the block retrieval @@ -89,9 +86,6 @@ class RealtimeStatisticsCubit } else { throw NoBlocksAvailableException(); } - } catch (e) { - rethrow; - } } @override diff --git a/lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_state.dart b/lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_state.dart index 8acb460f..ef0315f1 100644 --- a/lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_state.dart +++ b/lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_state.dart @@ -3,16 +3,16 @@ part of 'realtime_statistics_cubit.dart'; /// The state class for [RealtimeStatisticsCubit], which extends /// [TimerState] to handle real-time statistics data. /// -/// This class manages a list of `AccountBlock` objects representing real-time +/// This class manages a list of [AccountBlock] objects representing real-time /// blockchain data, such as recent transactions. /// It's used to track the state of the data loading process in the -/// `RealtimeStatisticsCubit`. +/// [RealtimeStatisticsCubit]. @JsonSerializable() class RealtimeStatisticsState extends TimerState> { - /// Constructs a new `RealtimeStatisticsState` with optional values for - /// `status`, `data`, and `error`. + /// Constructs a new [RealtimeStatisticsState] with optional values for + /// [status], [data], and [error]. /// - /// The `data` field stores a list of `AccountBlock` objects that represent + /// The [data] field stores a list of [AccountBlock] objects that represent /// real-time blockchain statistics. const RealtimeStatisticsState({ super.status, @@ -24,15 +24,9 @@ class RealtimeStatisticsState extends TimerState> { factory RealtimeStatisticsState.fromJson(Map json) => _$RealtimeStatisticsStateFromJson(json); - /// Creates a copy of the current `RealtimeStatisticsState` with updated - /// values for `status`, `data`, or `error`. - /// - /// This method is used to create a new state with updated fields if provided, - /// otherwise retaining the existing values. - /// - /// Returns: - /// - A new instance of `RealtimeStatisticsState` with the updated values or - /// the existing ones if none are provided. + /// Creates a copy of the current [RealtimeStatisticsState] with updated + /// values for [status], [data], or [error] if provided, otherwise retaining + /// the existing values. @override TimerState> copyWith({ TimerStatus? status, diff --git a/lib/rearchitecture/features/realtime_statistics/exceptions/no_blocks_available_exception.dart b/lib/rearchitecture/features/realtime_statistics/exceptions/no_blocks_available_exception.dart index 087cdcd4..11b6ca1f 100644 --- a/lib/rearchitecture/features/realtime_statistics/exceptions/no_blocks_available_exception.dart +++ b/lib/rearchitecture/features/realtime_statistics/exceptions/no_blocks_available_exception.dart @@ -17,5 +17,6 @@ class NoBlocksAvailableException extends CubitException { /// Converts this [NoBlocksAvailableException] instance to a JSON map. + @override Map toJson() => _$NoBlocksAvailableExceptionToJson(this); } diff --git a/lib/rearchitecture/features/realtime_statistics/view/realtime_statistics_card.dart b/lib/rearchitecture/features/realtime_statistics/view/realtime_statistics_card.dart index c5498234..77b7ea99 100644 --- a/lib/rearchitecture/features/realtime_statistics/view/realtime_statistics_card.dart +++ b/lib/rearchitecture/features/realtime_statistics/view/realtime_statistics_card.dart @@ -2,9 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/widgets/card_scaffold_without_listener.dart'; /// A card that receives [RealtimeStatisticsState] updates from the /// [RealtimeStatisticsCubit] and changes the UI according to the request diff --git a/lib/rearchitecture/features/sentinels/cubit/sentinels_cubit.dart b/lib/rearchitecture/features/sentinels/cubit/sentinels_cubit.dart index 10aa45a9..f55aa63f 100644 --- a/lib/rearchitecture/features/sentinels/cubit/sentinels_cubit.dart +++ b/lib/rearchitecture/features/sentinels/cubit/sentinels_cubit.dart @@ -6,36 +6,24 @@ part 'sentinels_cubit.g.dart'; part 'sentinels_state.dart'; -/// `SentinelsCubit` manages the fetching and state of sentinel information. +/// [SentinelsCubit] manages the fetching and state of sentinel information. /// -/// This cubit extends `DashboardCubit`, using a -/// `SentinelInfoList` object to represent the list of active sentinels -/// fetched from the Zenon network. +/// It uses a [SentinelInfoList] object to represent the list of active +/// sentinels fetched from the Zenon network. class SentinelsCubit extends TimerCubit { - /// Constructs a `SentinelsCubit`, passing the `zenon` client and the initial + /// Constructs a [SentinelsCubit], passing the [zenon] client and the initial /// state to the parent class. /// - /// The `zenon` client is used to interact with the Zenon network to retrieve + /// The [zenon] client is used to interact with the Zenon network to retrieve /// sentinel information. SentinelsCubit(super.zenon, super.initialState); /// Fetches a list of active sentinels from the Zenon network. - /// - /// This method calls the Zenon SDK's `getAllActive()` method to retrieve the - /// list of active sentinels. The fetched data is returned as a - /// `SentinelInfoList`. - /// - /// Throws: - /// - An error if any exception occurs during the fetching process. @override Future fetch() async { - try { - // Fetches the list of all active sentinels from the Zenon network - final data = await zenon.embedded.sentinel.getAllActive(); - return data; // Returns the fetched sentinel information - } catch (e) { - rethrow; - } + // Fetches the list of all active sentinels from the Zenon network + final data = await zenon.embedded.sentinel.getAllActive(); + return data; // Returns the fetched sentinel information } @override diff --git a/lib/rearchitecture/features/sentinels/cubit/sentinels_state.dart b/lib/rearchitecture/features/sentinels/cubit/sentinels_state.dart index 1ba049fc..0ef7ebe3 100644 --- a/lib/rearchitecture/features/sentinels/cubit/sentinels_state.dart +++ b/lib/rearchitecture/features/sentinels/cubit/sentinels_state.dart @@ -1,17 +1,17 @@ part of 'sentinels_cubit.dart'; -/// The state class for `SentinelsCubit`, which extends `DashboardState` to +/// The state class for [SentinelsCubit], which extends [TimerState] to /// manage sentinel-related data. /// -/// This class manages a `SentinelInfoList` object representing information +/// This class manages a [SentinelInfoList] object representing information /// about active sentinels. It is used to track -/// the state of sentinel data loading within the `SentinelsCubit`. +/// the state of sentinel data loading within the [SentinelsCubit]. @JsonSerializable() class SentinelsState extends TimerState { - /// Constructs a new `SentinelsState` with optional values for `status`, - /// `data`, and `error`. + /// Constructs a new [SentinelsState] with optional values for [status], + /// [data], and [error]. /// - /// The `data` field stores a `SentinelInfoList` object, which contains the + /// The [data] field stores a [SentinelInfoList] object, which contains the /// details of all active sentinels on the network. const SentinelsState({ super.status, @@ -23,15 +23,9 @@ class SentinelsState extends TimerState { factory SentinelsState.fromJson(Map json) => _$SentinelsStateFromJson(json); - /// Creates a copy of the current `SentinelsState` with updated values for - /// `status`, `data`, or `error`. - /// - /// This method is used to create a new state with updated fields if provided, - /// otherwise retaining the existing values. - /// - /// Returns: - /// - A new instance of `SentinelsState` with the updated values or the - /// existing ones if none are provided. + /// Creates a copy of the current [SentinelsState] with updated values for + /// [status], [data], or [error] if provided, otherwise retaining the + /// existing values. @override TimerState copyWith({ TimerStatus? status, diff --git a/lib/rearchitecture/features/sentinels/view/sentinels_card.dart b/lib/rearchitecture/features/sentinels/view/sentinels_card.dart index 1b9b6c06..20dba17d 100644 --- a/lib/rearchitecture/features/sentinels/view/sentinels_card.dart +++ b/lib/rearchitecture/features/sentinels/view/sentinels_card.dart @@ -2,9 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/widgets/card_scaffold_without_listener.dart'; /// Widget connected to the [SentinelsCubit] that receives the state /// - [SentinelsState] - updates and rebuilds the UI according to the diff --git a/lib/rearchitecture/features/sentinels/widgets/sentinels_loading.dart b/lib/rearchitecture/features/sentinels/widgets/sentinels_loading.dart index ecca8c39..674910c4 100644 --- a/lib/rearchitecture/features/sentinels/widgets/sentinels_loading.dart +++ b/lib/rearchitecture/features/sentinels/widgets/sentinels_loading.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [SentinelsState] when it's status is diff --git a/lib/rearchitecture/features/sentinels/widgets/sentinels_populated.dart b/lib/rearchitecture/features/sentinels/widgets/sentinels_populated.dart index 7dcf7013..f2f6ccaa 100644 --- a/lib/rearchitecture/features/sentinels/widgets/sentinels_populated.dart +++ b/lib/rearchitecture/features/sentinels/widgets/sentinels_populated.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/rearchitecture/features/staking/cubit/staking_cubit.dart b/lib/rearchitecture/features/staking/cubit/staking_cubit.dart index 287cbd38..9448a94d 100644 --- a/lib/rearchitecture/features/staking/cubit/staking_cubit.dart +++ b/lib/rearchitecture/features/staking/cubit/staking_cubit.dart @@ -1,59 +1,43 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'staking_cubit.g.dart'; part 'staking_state.dart'; -/// `StakingCubit` manages the fetching and state of staking information. +/// [StakingCubit] manages the fetching and state of staking information. /// -/// This cubit extends `DashboardCubit`, using a `StakeList` object -/// to represent the list of staking entries for a specific address fetched -/// from the Zenon network. +/// It uses a [StakeList] object to represent the list of staking entries for a +/// specific address. class StakingCubit extends TimerCubit { - /// Constructs a `StakingCubit`, passing the `zenon` client and the initial + /// Constructs a [StakingCubit], passing the [zenon] client and the initial /// state to the parent class. /// - /// The `zenon` client is used to interact with the Zenon network to retrieve + /// The [zenon] client is used to interact with the Zenon network to retrieve /// staking information. StakingCubit(super.zenon, super.initialState); /// Fetches a list of staking entries for a specific address from the Zenon /// network. /// - /// This method retrieves the staking list by calling the internal - /// `_getStakeList()` method. - /// It checks if the list of stakes is not empty and returns the data. - /// /// Throws: /// - An error if no active staking entries are found or if any exception /// occurs during the fetching process. @override Future fetch() async { - try { - // Retrieve the list of staking entries for the demo address - final data = await _getStakeList(); - if (data.list.isNotEmpty) { - return data; // Return the fetched stake data if not empty - } else { - throw NoActiveStakingEntriesException(); - } - } catch (e) { - rethrow; + // Retrieve the list of staking entries for the demo address + final data = await _getStakeList(); + if (data.list.isNotEmpty) { + return data; // Return the fetched stake data if not empty + } else { + throw NoActiveStakingEntriesException(); } } - + // TODO(maznnwell): replace the global kSelectedAddress variable /// Retrieves the staking entries for a specific address. - /// - /// This method fetches the staking entries by calling the Zenon SDK's - /// `getEntriesByAddress()` method, using the account address and a - /// specified page index. - /// - /// Returns: - /// - A `StakeList` containing the staking entries for the specified address. Future _getStakeList() async { return zenon.embedded.stake.getEntriesByAddress( Address.parse(kSelectedAddress!), diff --git a/lib/rearchitecture/features/staking/cubit/staking_state.dart b/lib/rearchitecture/features/staking/cubit/staking_state.dart index cfa6cc83..93b373cc 100644 --- a/lib/rearchitecture/features/staking/cubit/staking_state.dart +++ b/lib/rearchitecture/features/staking/cubit/staking_state.dart @@ -1,18 +1,18 @@ part of 'staking_cubit.dart'; -/// The state class for `StakingCubit`, which extends `DashboardState` to +/// The state class for [StakingCubit], which extends [TimerState] to /// manage staking-related data. /// -/// This class manages a `StakeList` object representing the list of active +/// This class manages a [StakeList] object representing the list of active /// staking entries. /// It tracks the loading, success, or failure of fetching staking data within -/// the `StakingCubit`. +/// the [StakingCubit]. @JsonSerializable() class StakingState extends TimerState { - /// Constructs a new `StakingState` with optional values for `status`, - /// `data`, and `error`. + /// Constructs a new [StakingState] with optional values for [status], + /// [data], and [error]. /// - /// The `data` field holds a `StakeList` object, which contains the list of + /// The [data] field holds a [StakeList] object, which contains the list of /// active staking entries for a particular address. const StakingState({ super.status, @@ -24,14 +24,14 @@ class StakingState extends TimerState { factory StakingState.fromJson(Map json) => _$StakingStateFromJson(json); - /// Creates a copy of the current `StakingState` with updated values for - /// `status`, `data`, or `error`. + /// Creates a copy of the current [StakingState] with updated values for + /// [status], [data], or [error]. /// /// This method is used to create a new state with updated fields if provided, /// otherwise retaining the existing values. /// /// Returns: - /// - A new instance of `StakingState`with the updated values or the + /// - A new instance of [StakingState]with the updated values or the /// existing ones if none are provided. @override TimerState copyWith({ diff --git a/lib/rearchitecture/features/staking/exceptions/no_active_skaking_entries_exception.dart b/lib/rearchitecture/features/staking/exceptions/no_active_skaking_entries_exception.dart index 268611fc..b56ad3b1 100644 --- a/lib/rearchitecture/features/staking/exceptions/no_active_skaking_entries_exception.dart +++ b/lib/rearchitecture/features/staking/exceptions/no_active_skaking_entries_exception.dart @@ -16,6 +16,7 @@ class NoActiveStakingEntriesException extends CubitException { _$NoActiveStakingEntriesExceptionFromJson(json); /// Converts this [NoActiveStakingEntriesException] instance to a JSON map. + @override Map toJson() => _$NoActiveStakingEntriesExceptionToJson(this); } diff --git a/lib/rearchitecture/features/staking/view/staking_card.dart b/lib/rearchitecture/features/staking/view/staking_card.dart index 6815f38b..29b2124f 100644 --- a/lib/rearchitecture/features/staking/view/staking_card.dart +++ b/lib/rearchitecture/features/staking/view/staking_card.dart @@ -2,9 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/widgets/card_scaffold_without_listener.dart'; /// A widget connected to the [StakingCubit] that receives the state /// - [StakingState] - updates and rebuilds the UI according to the diff --git a/lib/rearchitecture/features/staking/widgets/staking_loading.dart b/lib/rearchitecture/features/staking/widgets/staking_loading.dart index 6abc082f..414883be 100644 --- a/lib/rearchitecture/features/staking/widgets/staking_loading.dart +++ b/lib/rearchitecture/features/staking/widgets/staking_loading.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; /// A widget associated with the [StakingState] when it's status is diff --git a/lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart b/lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart index 6211e606..d8a8a4ba 100644 --- a/lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart +++ b/lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart @@ -9,21 +9,15 @@ part 'total_hourly_transactions_cubit.g.dart'; part 'total_hourly_transactions_state.dart'; -/// `TotalHourlyTransactionsCubit` manages the fetching and state of total +/// [TotalHourlyTransactionsCubit] manages the fetching and state of total /// hourly transactions. -/// -/// This cubit extends `DashboardCubit>`, using a map to -/// represent the total -/// number of account blocks and the corresponding timestamp fetched from the -/// Zenon network. class TotalHourlyTransactionsCubit extends TimerCubit { - /// Constructs a `TotalHourlyTransactionsCubit`, passing the `zenon` client + /// Constructs a [TotalHourlyTransactionsCubit], passing the [zenon] client /// and the initial state to the parent class. /// - /// The `zenon` client is used to interact with the Zenon network to retrieve + /// The [zenon] client is used to interact with the Zenon network to retrieve /// transaction information. - TotalHourlyTransactionsCubit(super.zenon, super.initialState); /// Fetches the total number of account blocks for the last hour from the @@ -31,47 +25,36 @@ class TotalHourlyTransactionsCubit /// /// This method retrieves the height of the chain, checks if there are enough /// momentums, and fetches detailed momentums from the Zenon ledger. It - /// calculates the total number of account blocks and prepares a map - /// containing the number of blocks and the current timestamp. + /// calculates then the total number of account blocks /// /// Throws: /// - An error if there are not enough momentums or if any exception occurs /// during the fetching process. @override Future fetch() async { - try { - // Retrieve the current chain height - final chainHeight = await _ledgerGetMomentumLedgerHeight(); - if (chainHeight - kMomentumsPerHour > 0) { - // Fetch detailed momentums for the past hour - final response = - (await zenon.ledger.getDetailedMomentumsByHeight( - chainHeight - kMomentumsPerHour, - kMomentumsPerHour, - )) - .list ?? - []; + // Retrieve the current chain height + final chainHeight = await _ledgerGetMomentumLedgerHeight(); + if (chainHeight - kMomentumsPerHour > 0) { + // Fetch detailed momentums for the past hour + final response = (await zenon.ledger.getDetailedMomentumsByHeight( + chainHeight - kMomentumsPerHour, + kMomentumsPerHour, + )) + .list ?? + []; - // Prepare the transaction summary - final transactions = response.fold( - 0, - (previousValue, element) => previousValue + element.blocks.length, - ); - return transactions; // Return the summary of transactions - } else { - throw NotEnoughMomentumsException(); - } - } catch (e) { - rethrow; + // Prepare the transaction summary + final transactions = response.fold( + 0, + (previousValue, element) => previousValue + element.blocks.length, + ); + return transactions; // Return the summary of transactions + } else { + throw NotEnoughMomentumsException(); } } /// Retrieves the current momentum ledger height from the Zenon network. - /// - /// This method fetches the frontier momentum and returns its height. - /// - /// Returns: - /// - An integer representing the current height of the momentum ledger. Future _ledgerGetMomentumLedgerHeight() async { try { return (await zenon.ledger.getFrontierMomentum()).height; diff --git a/lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_state.dart b/lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_state.dart index d59381e2..4700532b 100644 --- a/lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_state.dart +++ b/lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_state.dart @@ -1,18 +1,18 @@ part of 'total_hourly_transactions_cubit.dart'; -/// The state class for `TotalHourlyTransactionsCubit`, which extends -/// `DashboardState` to manage the hourly transaction count data. +/// The state class for [TotalHourlyTransactionsCubit], which extends +/// [TimerState] to manage the hourly transaction count data. /// -/// This class manages a `Map` where the key-value pairs +/// This class manages a [Map] where the key-value pairs /// represent transaction statistics (e.g., the number of account blocks and /// the timestamp) for the last hour. It tracks the state of fetching -/// hourly transaction data within `TotalHourlyTransactionsCubit`. +/// hourly transaction data within [TotalHourlyTransactionsCubit]. @JsonSerializable() class TotalHourlyTransactionsState extends TimerState { - /// Constructs a new `TotalHourlyTransactionsState` with optional values for - /// `status`, `data`, and `error`. + /// Constructs a new [TotalHourlyTransactionsState] with optional values for + /// [status], [data], and [error]. /// - /// The `data` field holds a map containing the transaction statistics for + /// The [data] field holds a map containing the transaction statistics for /// the last hour. const TotalHourlyTransactionsState({ super.status, @@ -24,14 +24,14 @@ class TotalHourlyTransactionsState extends TimerState { factory TotalHourlyTransactionsState.fromJson(Map json) => _$TotalHourlyTransactionsStateFromJson(json); - /// Creates a copy of the current `TotalHourlyTransactionsState` with updated - /// values for `status`, `data`, or `error`. + /// Creates a copy of the current [TotalHourlyTransactionsState] with updated + /// values for [status], [data], or [error]. /// /// This method is used to create a new state with updated fields if provided, /// otherwise retaining the existing values. /// /// Returns: - /// - A new instance of `TotalHourlyTransactionsState` with the updated + /// - A new instance of [TotalHourlyTransactionsState] with the updated /// values or the existing ones if none are provided. @override TimerState copyWith({ diff --git a/lib/rearchitecture/features/total_hourly_transactions/exceptions/not_enough_momentums_exception.dart b/lib/rearchitecture/features/total_hourly_transactions/exceptions/not_enough_momentums_exception.dart index 72395ce2..0bfe79b1 100644 --- a/lib/rearchitecture/features/total_hourly_transactions/exceptions/not_enough_momentums_exception.dart +++ b/lib/rearchitecture/features/total_hourly_transactions/exceptions/not_enough_momentums_exception.dart @@ -17,5 +17,6 @@ class NotEnoughMomentumsException extends CubitException { /// Converts this [NotEnoughMomentumsException] instance to a JSON map. + @override Map toJson() => _$NotEnoughMomentumsExceptionToJson(this); } diff --git a/lib/rearchitecture/features/total_hourly_transactions/view/total_hourly_transactions_card.dart b/lib/rearchitecture/features/total_hourly_transactions/view/total_hourly_transactions_card.dart index b3c1df0d..46eff090 100644 --- a/lib/rearchitecture/features/total_hourly_transactions/view/total_hourly_transactions_card.dart +++ b/lib/rearchitecture/features/total_hourly_transactions/view/total_hourly_transactions_card.dart @@ -2,9 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/widgets/card_scaffold_without_listener.dart'; /// A widget connected to the [TotalHourlyTransactionsCubit] that receives the /// state - [TotalHourlyTransactionsState] - updates and rebuilds the UI diff --git a/lib/rearchitecture/features/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart b/lib/rearchitecture/features/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart index 5ece8fde..8787f3f5 100644 --- a/lib/rearchitecture/features/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart +++ b/lib/rearchitecture/features/total_hourly_transactions/widgets/total_hourly_transactions_loading.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/features.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cubit.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; /// A widget associated with the [TotalHourlyTransactionsState] when it's diff --git a/lib/rearchitecture/rearchitecture.dart b/lib/rearchitecture/rearchitecture.dart index 0fce4af0..6b3ea428 100644 --- a/lib/rearchitecture/rearchitecture.dart +++ b/lib/rearchitecture/rearchitecture.dart @@ -1,2 +1 @@ export 'utils/cubits/timer_cubit.dart'; - diff --git a/lib/rearchitecture/utils/cubits/timer_cubit.dart b/lib/rearchitecture/utils/cubits/timer_cubit.dart index 5a8bcd20..e300e010 100644 --- a/lib/rearchitecture/utils/cubits/timer_cubit.dart +++ b/lib/rearchitecture/utils/cubits/timer_cubit.dart @@ -2,14 +2,16 @@ import 'dart:async'; import 'package:equatable/equatable.dart'; import 'package:hydrated_bloc/hydrated_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/rearchitecture/features/balance/balance.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'timer_state.dart'; -/// An abstract `DashboardCubit` class that manages periodic data fetching for a -/// dashboard feature. The cubit emits different states based on data loading, +/// An abstract class that manages periodic data fetching for a +/// +/// The cubit emits different states based on data loading, /// success, or failure, and it periodically refreshes the data automatically. /// /// The generic type [T] represents the type of data managed by this cubit. @@ -18,7 +20,7 @@ part 'timer_state.dart'; /// [S] extends [TimerState] abstract class TimerCubit> extends HydratedCubit { - /// Constructs a `DashboardCubit` with the provided [zenon] client and initial + /// Constructs a [TimerCubit] with the provided [zenon] client and initial /// state. /// /// The auto-refresh functionality is initialized upon the cubit's creation. diff --git a/lib/rearchitecture/utils/cubits/timer_state.dart b/lib/rearchitecture/utils/cubits/timer_state.dart index 35c65c02..7e49fac8 100644 --- a/lib/rearchitecture/utils/cubits/timer_state.dart +++ b/lib/rearchitecture/utils/cubits/timer_state.dart @@ -18,7 +18,7 @@ enum TimerStatus { /// /// The [TimerState] is designed to be generic, with [T] representing the /// type of data that is managed by each specific cubit state (e.g., balances, -/// transactions, etc.). Subclasses like `BalanceState` extend this class to +/// transactions, etc.). Subclasses like [BalanceState] extend this class to /// handle specific data types. /// /// The state includes: @@ -59,7 +59,7 @@ abstract class TimerState extends Equatable { /// - [error]: The new error, if any occurred. /// /// Returns a new [TimerState] with the updated fields. Subclasses - /// (like `BalanceState`) will implement this to + /// (like [BalanceState]) will implement this to /// ensure type safety and return the appropriate state class. TimerState copyWith({ TimerStatus? status, diff --git a/lib/rearchitecture/utils/exceptions/cubit_failure_exception.dart b/lib/rearchitecture/utils/exceptions/cubit_failure_exception.dart index bfdc8438..51c48d3e 100644 --- a/lib/rearchitecture/utils/exceptions/cubit_failure_exception.dart +++ b/lib/rearchitecture/utils/exceptions/cubit_failure_exception.dart @@ -16,5 +16,6 @@ class CubitFailureException extends SyriusException { /// Converts this [CubitFailureException] instance to a JSON map. + @override Map toJson() => _$CubitFailureExceptionToJson(this); } diff --git a/lib/rearchitecture/utils/models/card/card.dart b/lib/rearchitecture/utils/models/card/card.dart index 0b6649b0..46ee2832 100644 --- a/lib/rearchitecture/utils/models/card/card.dart +++ b/lib/rearchitecture/utils/models/card/card.dart @@ -1,2 +1,2 @@ export 'card_data.dart'; -export 'card_type.dart'; \ No newline at end of file +export 'card_type.dart'; diff --git a/lib/rearchitecture/utils/models/card/card_data.dart b/lib/rearchitecture/utils/models/card/card_data.dart index 15db8ef4..e1d11930 100644 --- a/lib/rearchitecture/utils/models/card/card_data.dart +++ b/lib/rearchitecture/utils/models/card/card_data.dart @@ -1,6 +1,10 @@ +/// A class that holds data needed in a card, like the [description] and the +/// [title] class CardData { - + /// Creates a [CardData] instance. CardData({required this.description, required this.title}); + /// The description of a card. final String description; + /// The title of a card. final String title; -} \ No newline at end of file +} diff --git a/lib/rearchitecture/utils/models/card/card_type.dart b/lib/rearchitecture/utils/models/card/card_type.dart index 9e871efa..53455c6b 100644 --- a/lib/rearchitecture/utils/models/card/card_type.dart +++ b/lib/rearchitecture/utils/models/card/card_type.dart @@ -1,17 +1,27 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/models/card/card.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; +/// A class that helps distinguish between the card widgets enum CardType { + /// A type for a card displaying information related to balance balance, + /// A type for a card displaying information related to delegation delegationStats, + /// A type for a card displaying information related to ZNN and QSR dualCoinStats, + /// A type for a card displaying information related to pillars pillars, + /// A type for a card displaying information in realtime realtimeStatistics, + /// A type for a card displaying information related to sentinels sentinels, + /// A type for a card displaying information related to staking staking, + /// A type for a card displaying information related to transactions + /// confirmed in the last hour totalHourlyTransactions, + /// A type for a card that redirects to the Transfer tab transfer; /// Returns the [CardData] assigned to a specific [CardType] value. diff --git a/lib/rearchitecture/utils/widgets/widgets.dart b/lib/rearchitecture/utils/widgets/widgets.dart index 22d688ce..2fb21612 100644 --- a/lib/rearchitecture/utils/widgets/widgets.dart +++ b/lib/rearchitecture/utils/widgets/widgets.dart @@ -1 +1 @@ -export 'card_scaffold_without_listener.dart'; \ No newline at end of file +export 'card_scaffold_without_listener.dart'; diff --git a/lib/utils/pair.dart b/lib/utils/pair.dart index f370ebd6..c4436427 100644 --- a/lib/utils/pair.dart +++ b/lib/utils/pair.dart @@ -2,7 +2,7 @@ class Pair { /// Creates a [Pair] instance Pair(this.first, this.second); - /// `fromJson` factory to specify deserialization methods for generic types + /// Constructor to specify deserialization methods for generic types factory Pair.fromJson( Map json, T1 Function(Object? json) fromJsonT1, @@ -16,7 +16,7 @@ class Pair { final T1 first; final T2 second; - /// `toJson` function to serialize generic types + /// A function to serialize generic types Map toJson( Object? Function(T1 value) toJsonT1, Object? Function(T2 value) toJsonT2, From 7eadb626289bae97369c23566447b488e234bb2e Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Mon, 28 Oct 2024 19:41:26 +0200 Subject: [PATCH 052/102] feat: Add always_specify_types to the linter rules and run dart fix --- analysis_options.yaml | 10 ++ .../accelerator/accelerator_balance_bloc.dart | 2 +- lib/blocs/accelerator/create_phase_bloc.dart | 2 +- .../accelerator/create_project_bloc.dart | 4 +- lib/blocs/accelerator/project_list_bloc.dart | 70 ++++++------ .../project_vote_breakdown_bloc.dart | 4 +- .../accelerator/submit_donation_bloc.dart | 2 +- lib/blocs/accelerator/update_phase_bloc.dart | 2 +- lib/blocs/accelerator/vote_project_bloc.dart | 4 +- lib/blocs/auto_receive_tx_worker.dart | 16 +-- lib/blocs/auto_unlock_htlc_worker.dart | 15 +-- lib/blocs/dashboard/balance_bloc.dart | 8 +- lib/blocs/decrypt_wallet_file_bloc.dart | 2 +- lib/blocs/infinite_scroll_bloc.dart | 22 ++-- lib/blocs/notifications_bloc.dart | 4 +- .../htlc_swap/complete_htlc_swap_bloc.dart | 10 +- .../p2p_swap/htlc_swap/htlc_swap_bloc.dart | 2 +- .../htlc_swap/initial_htlc_for_swap_bloc.dart | 17 +-- .../htlc_swap/join_htlc_swap_bloc.dart | 8 +- .../reclaim_htlc_swap_funds_bloc.dart | 6 +- .../recover_htlc_swap_funds_bloc.dart | 2 +- .../htlc_swap/start_htlc_swap_bloc.dart | 18 +-- lib/blocs/p2p_swap/p2p_swaps_list_bloc.dart | 7 +- .../p2p_swap/periodic_p2p_swap_base_bloc.dart | 2 +- lib/blocs/pillars/delegate_button_bloc.dart | 4 +- .../pillars/disassemble_pillar_bloc.dart | 4 +- .../pillars/pillar_rewards_history_bloc.dart | 4 +- lib/blocs/pillars/pillars_deploy_bloc.dart | 4 +- .../pillars/pillars_deposit_qsr_bloc.dart | 4 +- lib/blocs/pillars/pillars_qsr_info_bloc.dart | 4 +- .../pillars/pillars_withdraw_qsr_bloc.dart | 4 +- lib/blocs/pillars/undelegate_button_bloc.dart | 4 +- lib/blocs/pillars/update_pillar_bloc.dart | 2 +- lib/blocs/plasma/cancel_plasma_bloc.dart | 4 +- lib/blocs/plasma/plasma_list_bloc.dart | 6 +- lib/blocs/plasma/plasma_options_bloc.dart | 4 +- lib/blocs/plasma/plasma_stats_bloc.dart | 6 +- lib/blocs/refresh_bloc_mixin.dart | 2 +- .../sentinels/disassemble_button_bloc.dart | 4 +- .../sentinels/sentinel_deposit_qsr_bloc.dart | 4 +- .../sentinels/sentinel_qsr_info_bloc.dart | 4 +- .../sentinels/sentinel_register_bloc.dart | 4 +- .../sentinel_rewards_history_bloc.dart | 4 +- .../sentinels/sentinel_withdraw_qsr_bloc.dart | 4 +- .../settings/account_chain_stats_bloc.dart | 18 +-- lib/blocs/settings/general_stats_bloc.dart | 2 +- lib/blocs/staking/cancel_stake_bloc.dart | 4 +- lib/blocs/staking/staking_options_bloc.dart | 4 +- .../staking/staking_rewards_history_bloc.dart | 4 +- lib/blocs/tokens/burn_token_bloc.dart | 4 +- lib/blocs/tokens/issue_token_bloc.dart | 4 +- lib/blocs/tokens/mint_token_bloc.dart | 4 +- lib/blocs/tokens/token_map_bloc.dart | 44 +++---- lib/blocs/tokens/tokens_bloc.dart | 2 +- lib/blocs/tokens/transfer_ownership_bloc.dart | 2 +- .../transfer/receive_transaction_bloc.dart | 2 +- lib/blocs/transfer/send_payment_bloc.dart | 4 +- .../transfer_widgets_balance_bloc.dart | 8 +- .../wallet_connect/chains/nom_service.dart | 50 ++++---- .../wallet_connect_sessions_bloc.dart | 6 +- lib/embedded_node/embedded_node.dart | 30 ++--- lib/handlers/htlc_swaps_handler.dart | 48 ++++---- lib/main.dart | 51 +++++---- lib/main_dev.dart | 49 ++++---- lib/model/p2p_swap/htlc_swap.dart | 2 +- lib/model/p2p_swap/p2p_swap.dart | 2 +- .../features/balance/cubit/balance_cubit.dart | 5 +- .../features/balance/view/balance_card.dart | 4 +- .../balance/widgets/balance_address.dart | 4 +- .../balance/widgets/balance_chart.dart | 10 +- .../balance/widgets/balance_chart_legend.dart | 2 +- .../balance/widgets/balance_populated.dart | 14 +-- .../delegation/cubit/delegation_cubit.dart | 2 +- .../delegation/view/delegation_card.dart | 4 +- .../cubit/dual_coin_stats_cubit.dart | 6 +- .../view/dual_coin_stats_card.dart | 4 +- .../widgets/dual_coin_stats_chart.dart | 14 +-- .../widgets/dual_coin_stats_chart_legend.dart | 6 +- .../dual_coin_stats_chart_legend_item.dart | 2 +- .../widgets/dual_coin_stats_populated.dart | 2 +- .../cubit/node_sync_status_cubit.dart | 10 +- .../view/node_sync_status_icon.dart | 2 +- .../widgets/node_sync_status_populated.dart | 4 +- .../features/pillars/cubit/pillars_cubit.dart | 5 +- .../features/pillars/view/pillars_card.dart | 4 +- .../cubit/realtime_statistics_cubit.dart | 16 +-- .../view/realtime_statistics_card.dart | 4 +- .../realtime_statistics_populated.dart | 4 +- .../widgets/realtime_txs_chart.dart | 12 +- .../sentinels/cubit/sentinels_cubit.dart | 2 +- .../sentinels/view/sentinels_card.dart | 4 +- .../features/staking/cubit/staking_cubit.dart | 2 +- .../features/staking/view/staking_card.dart | 4 +- .../total_hourly_transactions_cubit.dart | 11 +- .../view/total_hourly_transactions_card.dart | 4 +- .../total_hourly_transactions_populated.dart | 2 +- .../utils/cubits/timer_state.dart | 2 +- .../card_scaffold_without_listener.dart | 26 ++--- .../change_wallet_password_screen.dart | 21 ++-- .../development_intialization_screen.dart | 4 +- lib/screens/dump_mnemonic_screen.dart | 13 ++- .../export/export_wallet_info_screen.dart | 4 +- .../export/export_wallet_password_screen.dart | 18 +-- lib/screens/node_management_screen.dart | 28 ++--- .../onboarding/access_wallet_screen.dart | 4 +- .../onboarding/create_key_store_screen.dart | 4 +- .../onboarding/create_ledger_screen.dart | 4 +- .../hardware_wallet_device_choice_screen.dart | 38 +++--- .../hardware_wallet_password_screen.dart | 10 +- .../import_wallet_decrypt_screen.dart | 16 +-- .../import_wallet_password_screen.dart | 14 +-- .../import_wallet_seed_choice_screen.dart | 14 +-- .../new_wallet_confirm_seed_screen.dart | 66 +++++------ .../new_wallet_password_screen.dart | 10 +- .../new_wallet_seed_choice_screen.dart | 6 +- .../onboarding/wallet_success_screen.dart | 2 +- lib/screens/project_details_screen.dart | 12 +- lib/screens/reset_wallet_screen.dart | 2 +- lib/screens/splash_screen.dart | 11 +- lib/screens/stepper_screen.dart | 6 +- lib/services/htlc_swaps_service.dart | 26 ++--- lib/services/web3wallet_service.dart | 34 +++--- lib/utils/account_block_utils.dart | 40 +++---- lib/utils/address_utils.dart | 32 +++--- lib/utils/app_colors.dart | 54 ++++----- lib/utils/app_theme.dart | 4 +- lib/utils/clipboard_utils.dart | 2 +- lib/utils/color_utils.dart | 2 +- lib/utils/constants.dart | 14 +-- lib/utils/device_utils.dart | 16 +-- lib/utils/extensions.dart | 10 +- lib/utils/file_utils.dart | 4 +- lib/utils/format_utils.dart | 16 +-- lib/utils/functions.dart | 10 +- lib/utils/global.dart | 16 +-- lib/utils/init_utils.dart | 2 +- lib/utils/input_validators.dart | 8 +- lib/utils/navigation_utils.dart | 6 +- lib/utils/network_utils.dart | 12 +- lib/utils/node_utils.dart | 42 +++---- lib/utils/notification_utils.dart | 3 +- lib/utils/toast_utils.dart | 2 +- lib/utils/wallet_file.dart | 36 +++--- lib/utils/wallet_utils.dart | 4 +- lib/utils/widget_utils.dart | 16 +-- lib/utils/zts_utils.dart | 6 +- lib/widgets/charts/pillar_rewards_chart.dart | 6 +- .../charts/sentinel_rewards_chart.dart | 18 +-- lib/widgets/charts/staking_rewards_chart.dart | 8 +- lib/widgets/main_app_container.dart | 70 ++++++------ .../accelerator_donation_stepper.dart | 50 ++++---- .../accelerator_donations.dart | 6 +- .../accelerator_project_list.dart | 38 +++--- .../accelerator_project_list_item.dart | 70 ++++++------ .../accelerator_stats.dart | 22 ++-- .../accelerator_widgets/create_phase.dart | 6 +- .../accelerator_widgets/create_project.dart | 6 +- .../phase_creation_stepper.dart | 54 ++++----- .../project_creation_stepper.dart | 58 +++++----- .../accelerator_widgets/project_list.dart | 22 ++-- .../accelerator_widgets/projects_stats.dart | 34 +++--- .../update_phase_stepper.dart | 44 +++---- .../dashboard_widgets/plasma_stats.dart | 16 +-- .../help_widgets/about_card.dart | 10 +- .../help_widgets/community_card.dart | 12 +- .../help_widgets/update_card.dart | 2 +- .../p2p_swap_widgets/detail_row.dart | 4 +- .../p2p_swap_widgets/htlc_card.dart | 26 ++--- .../htlc_swap_details_widget.dart | 14 +-- .../modals/join_native_swap_modal.dart | 44 +++---- .../modals/native_p2p_swap_modal.dart | 54 ++++----- .../modals/p2p_swap_warning_modal.dart | 2 +- .../modals/recover_deposit_modal.dart | 16 +-- .../modals/start_native_swap_modal.dart | 24 ++-- .../p2p_swap_options_button.dart | 6 +- .../p2p_swap_options_card.dart | 10 +- .../p2p_swap_widgets/p2p_swaps_card.dart | 12 +- .../p2p_swap_widgets/p2p_swaps_list_item.dart | 14 +-- .../pillar_widgets/create_pillar.dart | 16 +-- .../pillar_widgets/pillar_collect.dart | 6 +- .../pillar_widgets/pillar_list_widget.dart | 80 ++++++------- .../pillar_widgets/pillar_rewards.dart | 2 +- .../pillar_stepper_container.dart | 108 +++++++++--------- .../pillar_widgets/pillar_update_stepper.dart | 36 +++--- .../plasma_list/plasma_list.dart | 36 +++--- .../plasma_options/plasma_options.dart | 36 +++--- .../sentinel_widgets/create_sentinel.dart | 8 +- .../sentinel_widgets/sentinel_collect.dart | 6 +- .../sentinel_list_widget.dart | 32 +++--- .../sentinel_widgets/sentinel_rewards.dart | 2 +- .../sentinel_stepper_container.dart | 76 ++++++------ .../settings_widgets/account_chain_stats.dart | 18 +-- .../settings_widgets/addresses.dart | 24 ++-- .../settings_widgets/backup.dart | 4 +- .../settings_widgets/display.dart | 22 ++-- .../settings_widgets/general.dart | 6 +- .../settings_widgets/node_management.dart | 40 +++---- .../settings_widgets/peers.dart | 20 ++-- .../settings_widgets/security.dart | 52 ++++----- .../settings_widgets/wallet_options.dart | 24 ++-- .../staking_widgets/stake_collect.dart | 6 +- .../staking_list/staking_list.dart | 46 ++++---- .../staking_options/staking_options.dart | 22 ++-- .../staking_widgets/staking_rewards.dart | 2 +- .../token_widgets/create_token.dart | 4 +- .../token_widgets/token_balance.dart | 20 ++-- .../token_widgets/token_card.dart | 80 ++++++------- .../token_widgets/token_favorite.dart | 2 +- .../token_widgets/token_map.dart | 10 +- .../token_widgets/token_stepper.dart | 74 ++++++------ .../latest_transactions.dart | 48 ++++---- .../latest_transactions_transfer_widget.dart | 52 ++++----- .../pending_transactions.dart | 42 +++---- .../receive/receive_large.dart | 16 +-- .../receive/receive_medium.dart | 18 +-- .../transfer_widgets/send/send_large.dart | 28 ++--- .../transfer_widgets/send/send_medium.dart | 24 ++-- .../wallet_connect_camera_card.dart | 23 ++-- .../wallet_connect_pairing_list_card.dart | 10 +- .../wallet_connect_qr_card.dart | 29 ++--- .../wallet_connect_session_list_card.dart | 10 +- .../wallet_connect_uri_card.dart | 15 +-- .../accelerator_project_details.dart | 20 ++-- .../reusable_widgets/amount_info_column.dart | 2 +- .../reusable_widgets/bullet_point_card.dart | 6 +- .../buttons/elevated_button.dart | 2 +- .../buttons/loading_button.dart | 6 +- .../buttons/outlined_button.dart | 4 +- .../buttons/stepper_button.dart | 2 +- .../transfer_toggle_card_size_button.dart | 2 +- .../reusable_widgets/cancel_timer.dart | 2 +- .../reusable_widgets/chart/chart_legend.dart | 2 +- .../chart/standard_chart.dart | 10 +- .../chart/standard_line_chart_bar_data.dart | 2 +- .../chart/standard_pie_chart.dart | 2 +- .../reusable_widgets/context_menu_region.dart | 2 +- .../custom_material_stepper.dart | 28 ++--- .../reusable_widgets/custom_slider.dart | 42 +++---- .../reusable_widgets/custom_table.dart | 28 ++--- lib/widgets/reusable_widgets/dialogs.dart | 14 +-- .../dotted_border_info_widget.dart | 2 +- .../dropdown/coin_dropdown.dart | 4 +- .../reusable_widgets/error_widget.dart | 2 +- .../exchange_rate_widget.dart | 10 +- .../icons/copy_to_clipboard_icon.dart | 2 +- .../important_text_container.dart | 2 +- .../infinite_scroll_table.dart | 32 +++--- .../input_fields/amount_input_field.dart | 14 +-- .../input_fields/amount_suffix_widgets.dart | 2 +- .../input_fields/input_field.dart | 6 +- .../input_fields/labeled_input_container.dart | 4 +- .../layout_scaffold/card_scaffold.dart | 28 ++--- .../standard_fluid_layout.dart | 16 +-- .../reusable_widgets/loading_info_text.dart | 2 +- .../reusable_widgets/modals/base_modal.dart | 6 +- .../reusable_widgets/notification_widget.dart | 8 +- .../reusable_widgets/number_animation.dart | 12 +- .../reusable_widgets/progress_bars.dart | 10 +- .../reusable_widgets/receive_qr_image.dart | 32 +++--- .../reusable_widgets/seed/seed_choice.dart | 4 +- .../reusable_widgets/seed/seed_grid.dart | 44 +++---- .../reusable_widgets/select_file_widget.dart | 14 +-- .../reusable_widgets/settings_address.dart | 12 +- .../reusable_widgets/settings_node.dart | 20 ++-- .../reusable_widgets/stepper_utils.dart | 6 +- lib/widgets/reusable_widgets/tag_widget.dart | 6 +- .../accelerator_tab_child.dart | 4 +- .../dashboard_tab_child.dart | 4 +- .../tab_children_widgets/help_tab_child.dart | 2 +- .../tab_children_widgets/lock_tab_child.dart | 2 +- .../notifications_tab_child.dart | 18 +-- .../p2p_swap_tab_child.dart | 2 +- .../pillars_tab_child.dart | 2 +- .../plasma_tab_child.dart | 6 +- .../sentinels_tab_child.dart | 2 +- .../settings_tab_child.dart | 2 +- .../staking_tab_child.dart | 4 +- .../tokens_tab_child.dart | 2 +- .../transfer_tab_child.dart | 2 +- .../wallet_connect_tab_child.dart | 2 +- .../cubit/delegation_cubit_test.dart | 10 +- 281 files changed, 2082 insertions(+), 2055 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 77011475..ed7808e3 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -9,3 +9,13 @@ analyzer: strict-casts: false strict-inference: false strict-raw-types: false + +linter: + rules: + # Always specifying types will make an unfamiliar codebase more readable for a new developer + # More details about the rule: + # https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c#file-analysis_options-yaml-L138 + always_specify_types: true + # This rule is in contradiction with always_specify_types, so it must be disabled if the other + # one is enabled + omit_local_variable_types: false \ No newline at end of file diff --git a/lib/blocs/accelerator/accelerator_balance_bloc.dart b/lib/blocs/accelerator/accelerator_balance_bloc.dart index 81617381..22a6c0c8 100644 --- a/lib/blocs/accelerator/accelerator_balance_bloc.dart +++ b/lib/blocs/accelerator/accelerator_balance_bloc.dart @@ -8,7 +8,7 @@ class AcceleratorBalanceBloc extends BaseBloc { Future getAcceleratorBalance() async { try { addEvent(null); - final accountInfo = await zenon!.ledger.getAccountInfoByAddress( + final AccountInfo accountInfo = await zenon!.ledger.getAccountInfoByAddress( acceleratorAddress, ); if (accountInfo.qsr()! > BigInt.zero || diff --git a/lib/blocs/accelerator/create_phase_bloc.dart b/lib/blocs/accelerator/create_phase_bloc.dart index 76b6d47e..d68e8bfc 100644 --- a/lib/blocs/accelerator/create_phase_bloc.dart +++ b/lib/blocs/accelerator/create_phase_bloc.dart @@ -14,7 +14,7 @@ class CreatePhaseBloc extends BaseBloc { ) async { try { addEvent(null); - final transactionParams = + final AccountBlockTemplate transactionParams = zenon!.embedded.accelerator.addPhase( id, name, diff --git a/lib/blocs/accelerator/create_project_bloc.dart b/lib/blocs/accelerator/create_project_bloc.dart index 0077921f..3c142198 100644 --- a/lib/blocs/accelerator/create_project_bloc.dart +++ b/lib/blocs/accelerator/create_project_bloc.dart @@ -15,7 +15,7 @@ class CreateProjectBloc extends BaseBloc { ) { try { addEvent(null); - final transactionParams = + final AccountBlockTemplate transactionParams = zenon!.embedded.accelerator.createProject( name, description, @@ -27,7 +27,7 @@ class CreateProjectBloc extends BaseBloc { transactionParams, 'creating project', ).then( - (block) { + (AccountBlockTemplate block) { ZenonAddressUtils.refreshBalance(); addEvent(block); }, diff --git a/lib/blocs/accelerator/project_list_bloc.dart b/lib/blocs/accelerator/project_list_bloc.dart index 31f2e7bd..bc491cc3 100644 --- a/lib/blocs/accelerator/project_list_bloc.dart +++ b/lib/blocs/accelerator/project_list_bloc.dart @@ -27,7 +27,7 @@ class ProjectListBloc with RefreshBlocMixin { } List? _allProjects; - final List selectedProjectsFilterTag = []; + final List selectedProjectsFilterTag = []; final PillarInfo? pillarInfo; @@ -42,11 +42,11 @@ class ProjectListBloc with RefreshBlocMixin { yield* _fetchList(0); } - static const _pageSize = 10; + static const int _pageSize = 10; - final _subscriptions = CompositeSubscription(); + final CompositeSubscription _subscriptions = CompositeSubscription(); - final _onNewListingStateController = + final BehaviorSubject> _onNewListingStateController = BehaviorSubject>.seeded( InfiniteScrollBlocListingState(), ); @@ -54,11 +54,11 @@ class ProjectListBloc with RefreshBlocMixin { Stream> get onNewListingState => _onNewListingStateController.stream; - final _onPageRequest = StreamController(); + final StreamController _onPageRequest = StreamController(); Sink get onPageRequestSink => _onPageRequest.sink; - final _onSearchInputChangedSubject = BehaviorSubject.seeded(null); + final BehaviorSubject _onSearchInputChangedSubject = BehaviorSubject.seeded(null); Sink get onRefreshResultsRequest => _onSearchInputChangedSubject.sink; @@ -73,13 +73,13 @@ class ProjectListBloc with RefreshBlocMixin { Stream> _fetchList( int pageKey,) async* { - final lastListingState = _onNewListingStateController.value; + final InfiniteScrollBlocListingState lastListingState = _onNewListingStateController.value; try { - final newItems = await getData(pageKey, _pageSize, _searchInputTerm); - final isLastPage = newItems.length < _pageSize; - final nextPageKey = isLastPage ? null : pageKey + 1; - final allItems = [ - ...lastListingState.itemList ?? [], + final List newItems = await getData(pageKey, _pageSize, _searchInputTerm); + final bool isLastPage = newItems.length < _pageSize; + final int? nextPageKey = isLastPage ? null : pageKey + 1; + final List allItems = [ + ...lastListingState.itemList ?? [], ...newItems, ]; yield InfiniteScrollBlocListingState( @@ -109,7 +109,7 @@ class ProjectListBloc with RefreshBlocMixin { String? searchTerm, ) async { _allProjects ??= (await zenon!.embedded.accelerator.getAll()).list; - var results = []; + List results = []; if (searchTerm != null && searchTerm.isNotEmpty) { results = _filterProjectsBySearchKeyWord(_allProjects!, searchTerm).toList(); @@ -133,13 +133,13 @@ class ProjectListBloc with RefreshBlocMixin { */ Future> _filterProjectsAccordingToPillarInfo( Set projectList,) async { - final isPillarAddress = pillarInfo != null; + final bool isPillarAddress = pillarInfo != null; if (isPillarAddress) { return projectList.toList(); } else { - final activeProjects = projectList + final List activeProjects = projectList .where( - (project) => + (Project project) => project.status == AcceleratorProjectStatus.active || kDefaultAddressList.contains(project.owner.toString()), ) @@ -154,10 +154,10 @@ class ProjectListBloc with RefreshBlocMixin { Set _filterProjectsBySearchKeyWord( List projects, String searchKeyWord,) { - final filteredProjects = {}; + final Set filteredProjects = {}; filteredProjects.addAll( projects.where( - (element) => + (Project element) => element.id.toString().toLowerCase().contains( searchKeyWord.toLowerCase(), ) && @@ -166,7 +166,7 @@ class ProjectListBloc with RefreshBlocMixin { ); filteredProjects.addAll( projects.where( - (element) => + (Project element) => element.owner.toString().toLowerCase().contains( searchKeyWord.toLowerCase(), ) && @@ -175,7 +175,7 @@ class ProjectListBloc with RefreshBlocMixin { ); filteredProjects.addAll( projects.where( - (element) => + (Project element) => element.name.toLowerCase().contains( searchKeyWord.toLowerCase(), ) && @@ -184,7 +184,7 @@ class ProjectListBloc with RefreshBlocMixin { ); filteredProjects.addAll( projects.where( - (element) => + (Project element) => element.description.toLowerCase().contains( searchKeyWord.toLowerCase(), ) && @@ -193,7 +193,7 @@ class ProjectListBloc with RefreshBlocMixin { ); filteredProjects.addAll( projects.where( - (element) => + (Project element) => element.url.toLowerCase().contains( searchKeyWord.toLowerCase(), ) && @@ -210,23 +210,23 @@ class ProjectListBloc with RefreshBlocMixin { Iterable filteredProjects = projects; if (selectedProjectsFilterTag.contains(AccProjectsFilterTag.myProjects)) { filteredProjects = filteredProjects.where( - (project) => kDefaultAddressList.contains(project.owner.toString()), + (Project project) => kDefaultAddressList.contains(project.owner.toString()), ); } if (selectedProjectsFilterTag .contains(AccProjectsFilterTag.onlyAccepted)) { filteredProjects = filteredProjects.where( - (project) => project.status == AcceleratorProjectStatus.active,); + (Project project) => project.status == AcceleratorProjectStatus.active,); } if (selectedProjectsFilterTag .contains(AccProjectsFilterTag.needsVoting)) { votedProjectIds ??= await _getVotedProjectIdsByPillar(filteredProjects); votedPhaseIds ??= await _getVotedPhaseIdsByPillar(filteredProjects); filteredProjects = filteredProjects.where( - (project) => + (Project project) => (project.status == AcceleratorProjectStatus.voting && !votedProjectIds!.contains(project.id)) || - project.phases.any((phase) => + project.phases.any((Phase phase) => phase.status == AcceleratorProjectStatus.voting && !votedPhaseIds!.contains(phase.id),), ); @@ -236,10 +236,10 @@ class ProjectListBloc with RefreshBlocMixin { votedProjectIds ??= await _getVotedProjectIdsByPillar(filteredProjects); votedPhaseIds ??= await _getVotedPhaseIdsByPillar(filteredProjects); filteredProjects = filteredProjects.where( - (project) => + (Project project) => (project.status == AcceleratorProjectStatus.voting && votedProjectIds!.contains(project.id)) || - project.phases.any((phase) => + project.phases.any((Phase phase) => phase.status == AcceleratorProjectStatus.voting && votedPhaseIds!.contains(phase.id),), ); @@ -252,22 +252,22 @@ class ProjectListBloc with RefreshBlocMixin { Future> _getVotedProjectIdsByPillar( Iterable projects,) async { - final pillarVotes = await zenon!.embedded.accelerator.getPillarVotes( + final List pillarVotes = await zenon!.embedded.accelerator.getPillarVotes( pillarInfo!.name, - projects.map((e) => e.id.toString()).toList(), + projects.map((Project e) => e.id.toString()).toList(), ); - return pillarVotes.where((e) => e != null).map((e) => e!.id); + return pillarVotes.where((PillarVote? e) => e != null).map((PillarVote? e) => e!.id); } Future> _getVotedPhaseIdsByPillar( Iterable projects,) async { - final pillarVotes = await zenon!.embedded.accelerator.getPillarVotes( + final List pillarVotes = await zenon!.embedded.accelerator.getPillarVotes( pillarInfo!.name, projects - .expand((project) => project.phaseIds) - .map((id) => id.toString()) + .expand((Project project) => project.phaseIds) + .map((Hash id) => id.toString()) .toList(), ); - return pillarVotes.where((e) => e != null).map((e) => e!.id); + return pillarVotes.where((PillarVote? e) => e != null).map((PillarVote? e) => e!.id); } } diff --git a/lib/blocs/accelerator/project_vote_breakdown_bloc.dart b/lib/blocs/accelerator/project_vote_breakdown_bloc.dart index f223e72a..0f97f0ef 100644 --- a/lib/blocs/accelerator/project_vote_breakdown_bloc.dart +++ b/lib/blocs/accelerator/project_vote_breakdown_bloc.dart @@ -8,7 +8,7 @@ class ProjectVoteBreakdownBloc Future getVoteBreakdown(String? pillarName, Hash projectId) async { try { addEvent(null); - final voteBreakdown = + final VoteBreakdown voteBreakdown = await zenon!.embedded.accelerator.getVoteBreakdown( projectId, ); @@ -16,7 +16,7 @@ class ProjectVoteBreakdownBloc if (pillarName != null) { pillarVoteList = await zenon!.embedded.accelerator.getPillarVotes( pillarName, - [ + [ projectId.toString(), ], ); diff --git a/lib/blocs/accelerator/submit_donation_bloc.dart b/lib/blocs/accelerator/submit_donation_bloc.dart index 88893755..4e6d1298 100644 --- a/lib/blocs/accelerator/submit_donation_bloc.dart +++ b/lib/blocs/accelerator/submit_donation_bloc.dart @@ -31,7 +31,7 @@ class SubmitDonationBloc extends BaseBloc { transactionParams, 'donate for accelerator', ).then( - (block) { + (AccountBlockTemplate block) { sl.get().getAcceleratorBalance(); addEvent(block); }, diff --git a/lib/blocs/accelerator/update_phase_bloc.dart b/lib/blocs/accelerator/update_phase_bloc.dart index dd03dc5b..a66b8d08 100644 --- a/lib/blocs/accelerator/update_phase_bloc.dart +++ b/lib/blocs/accelerator/update_phase_bloc.dart @@ -8,7 +8,7 @@ class UpdatePhaseBloc extends BaseBloc { BigInt znnFundsNeeded, BigInt qsrFundsNeeded,) { try { addEvent(null); - final transactionParams = + final AccountBlockTemplate transactionParams = zenon!.embedded.accelerator.updatePhase( id, name, diff --git a/lib/blocs/accelerator/vote_project_bloc.dart b/lib/blocs/accelerator/vote_project_bloc.dart index 70e510d0..8a9a8153 100644 --- a/lib/blocs/accelerator/vote_project_bloc.dart +++ b/lib/blocs/accelerator/vote_project_bloc.dart @@ -8,11 +8,11 @@ class VoteProjectBloc extends BaseBloc { Future voteProject(Hash id, AcceleratorProjectVote vote) async { try { addEvent(null); - final pillarInfo = (await zenon!.embedded.pillar.getByOwner( + final PillarInfo pillarInfo = (await zenon!.embedded.pillar.getByOwner( Address.parse(kSelectedAddress!), )) .first; - final transactionParams = + final AccountBlockTemplate transactionParams = zenon!.embedded.accelerator.voteByName( id, pillarInfo.name, diff --git a/lib/blocs/auto_receive_tx_worker.dart b/lib/blocs/auto_receive_tx_worker.dart index dd8c6df0..e90ab23b 100644 --- a/lib/blocs/auto_receive_tx_worker.dart +++ b/lib/blocs/auto_receive_tx_worker.dart @@ -27,12 +27,12 @@ class AutoReceiveTxWorker extends BaseBloc { if (!running) { running = true; try { - final toAddress = + final Address toAddress = (await zenon!.ledger.getAccountBlockByHash(currentHash))!.toAddress; - final transactionParams = AccountBlockTemplate.receive( + final AccountBlockTemplate transactionParams = AccountBlockTemplate.receive( currentHash, ); - final response = + final AccountBlockTemplate response = await AccountBlockUtils.createAccountBlock( transactionParams, 'receive transaction', @@ -64,14 +64,14 @@ class AutoReceiveTxWorker extends BaseBloc { // given priority to send transactions. if (pool.isNotEmpty && !running && !sl().running) { running = true; - final currentHash = pool.first; + final Hash currentHash = pool.first; try { - final toAddress = + final Address toAddress = (await zenon!.ledger.getAccountBlockByHash(currentHash))!.toAddress; - final transactionParams = AccountBlockTemplate.receive( + final AccountBlockTemplate transactionParams = AccountBlockTemplate.receive( currentHash, ); - final response = + final AccountBlockTemplate response = await AccountBlockUtils.createAccountBlock( transactionParams, 'receive transaction', @@ -105,7 +105,7 @@ class AutoReceiveTxWorker extends BaseBloc { } Future addHash(Hash hash) async { - zenon!.stats.syncInfo().then((syncInfo) { + zenon!.stats.syncInfo().then((SyncInfo syncInfo) { if (!pool.contains(hash) && (syncInfo.state == SyncState.syncDone || (syncInfo.targetHeight > 0 && diff --git a/lib/blocs/auto_unlock_htlc_worker.dart b/lib/blocs/auto_unlock_htlc_worker.dart index a5769975..abd56c67 100644 --- a/lib/blocs/auto_unlock_htlc_worker.dart +++ b/lib/blocs/auto_unlock_htlc_worker.dart @@ -7,6 +7,7 @@ import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; +import 'package:zenon_syrius_wallet_flutter/model/p2p_swap/htlc_swap.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; @@ -27,10 +28,10 @@ class AutoUnlockHtlcWorker extends BaseBloc { Future autoUnlock() async { if (pool.isNotEmpty && !running && kWalletFile != null) { running = true; - final currentHash = pool.first; + final Hash currentHash = pool.first; try { - final htlc = await zenon!.embedded.htlc.getById(currentHash); - final swap = htlcSwapsService! + final HtlcInfo htlc = await zenon!.embedded.htlc.getById(currentHash); + final HtlcSwap? swap = htlcSwapsService! .getSwapByHashLock(FormatUtils.encodeHexString(htlc.hashLock)); if (swap == null || swap.preimage == null) { throw 'Invalid swap'; @@ -38,9 +39,9 @@ class AutoUnlockHtlcWorker extends BaseBloc { if (!kDefaultAddressList.contains(htlc.hashLocked.toString())) { throw 'Swap address not in default addresses. Please add the address in the addresses list.'; } - final transactionParams = zenon!.embedded.htlc + final AccountBlockTemplate transactionParams = zenon!.embedded.htlc .unlock(htlc.id, FormatUtils.decodeHexString(swap.preimage!)); - final response = + final AccountBlockTemplate response = await AccountBlockUtils.createAccountBlock( transactionParams, 'complete swap', @@ -91,7 +92,7 @@ class AutoUnlockHtlcWorker extends BaseBloc { void addHash(Hash hash) { if (!processedHashes.contains(hash)) { - zenon!.stats.syncInfo().then((syncInfo) { + zenon!.stats.syncInfo().then((SyncInfo syncInfo) { if (!processedHashes.contains(hash) && (syncInfo.state == SyncState.syncDone || (syncInfo.targetHeight > 0 && @@ -101,7 +102,7 @@ class AutoUnlockHtlcWorker extends BaseBloc { processedHashes.add(hash); } }).onError( - (e, stackTrace) { + (Object? e, StackTrace stackTrace) { Logger('AutoUnlockHtlcWorker') .log(Level.WARNING, 'addHash', e, stackTrace); }, diff --git a/lib/blocs/dashboard/balance_bloc.dart b/lib/blocs/dashboard/balance_bloc.dart index d4287fdb..48ac4288 100644 --- a/lib/blocs/dashboard/balance_bloc.dart +++ b/lib/blocs/dashboard/balance_bloc.dart @@ -14,15 +14,15 @@ class BalanceBloc extends BaseBloc?> Future getBalanceForAllAddresses() async { try { addEvent(null); - final addressBalanceMap = {}; - final accountInfoList = await Future.wait( + final Map addressBalanceMap = {}; + final List accountInfoList = await Future.wait( kDefaultAddressList.map( - (address) => _getBalancePerAddress( + (String? address) => _getBalancePerAddress( address!, ), ), ); - for (final accountInfo in accountInfoList) { + for (final AccountInfo accountInfo in accountInfoList) { addressBalanceMap[accountInfo.address!] = accountInfo; } addEvent(addressBalanceMap); diff --git a/lib/blocs/decrypt_wallet_file_bloc.dart b/lib/blocs/decrypt_wallet_file_bloc.dart index 6436c362..c7346e59 100644 --- a/lib/blocs/decrypt_wallet_file_bloc.dart +++ b/lib/blocs/decrypt_wallet_file_bloc.dart @@ -6,7 +6,7 @@ class DecryptWalletFileBloc extends BaseBloc { Future decryptWalletFile(String path, String password) async { try { addEvent(null); - final walletFile = await WalletUtils.decryptWalletFile(path, password); + final WalletFile walletFile = await WalletUtils.decryptWalletFile(path, password); addEvent(walletFile); } catch (e, stackTrace) { addError(e, stackTrace); diff --git a/lib/blocs/infinite_scroll_bloc.dart b/lib/blocs/infinite_scroll_bloc.dart index 0ce91b6d..d23b2812 100644 --- a/lib/blocs/infinite_scroll_bloc.dart +++ b/lib/blocs/infinite_scroll_bloc.dart @@ -38,11 +38,11 @@ abstract class InfiniteScrollBloc with RefreshBlocMixin { yield* _fetchList(0); } - static const _pageSize = 10; + static const int _pageSize = 10; - final _subscriptions = CompositeSubscription(); + final CompositeSubscription _subscriptions = CompositeSubscription(); - final _onNewListingStateController = + final BehaviorSubject> _onNewListingStateController = BehaviorSubject>.seeded( InfiniteScrollBlocListingState(), ); @@ -50,8 +50,8 @@ abstract class InfiniteScrollBloc with RefreshBlocMixin { Stream> get onNewListingState => _onNewListingStateController.stream; - final _onPageRequest = StreamController(); - final _onRefreshResultsRequest = StreamController(); + final StreamController _onPageRequest = StreamController(); + final StreamController _onRefreshResultsRequest = StreamController(); Sink get onPageRequestSink => _onPageRequest.sink; @@ -60,13 +60,13 @@ abstract class InfiniteScrollBloc with RefreshBlocMixin { List? get lastListingItems => _onNewListingStateController.value.itemList; Stream> _fetchList(int pageKey) async* { - final lastListingState = _onNewListingStateController.value; + final InfiniteScrollBlocListingState lastListingState = _onNewListingStateController.value; try { - final newItems = await getData(pageKey, _pageSize); - final isLastPage = newItems.length < _pageSize || !isDataRequestPaginated; - final nextPageKey = isLastPage ? null : pageKey + 1; - var allItems = isDataRequestPaginated - ? [...lastListingState.itemList ?? [], ...newItems] + final List newItems = await getData(pageKey, _pageSize); + final bool isLastPage = newItems.length < _pageSize || !isDataRequestPaginated; + final int? nextPageKey = isLastPage ? null : pageKey + 1; + List allItems = isDataRequestPaginated + ? [...lastListingState.itemList ?? [], ...newItems] : newItems; if (filterItemsFunction != null) { allItems = filterItemsFunction!(allItems); diff --git a/lib/blocs/notifications_bloc.dart b/lib/blocs/notifications_bloc.dart index e89fdb6a..b7dcb123 100644 --- a/lib/blocs/notifications_bloc.dart +++ b/lib/blocs/notifications_bloc.dart @@ -11,7 +11,7 @@ class NotificationsBloc extends BaseBloc { Future addNotification(WalletNotification? notification) async { try { await Hive.openBox(kNotificationsBox); - final notificationsBox = Hive.box(kNotificationsBox); + final Box notificationsBox = Hive.box(kNotificationsBox); if (notificationsBox.length >= kNotificationsEntriesLimit) { while (notificationsBox.length >= kNotificationsEntriesLimit) { await notificationsBox.delete(notificationsBox.keys.first); @@ -19,7 +19,7 @@ class NotificationsBloc extends BaseBloc { } await notificationsBox.add(notification); if (notification != null && _areDesktopNotificationsEnabled()) { - final localNotification = LocalNotification( + final LocalNotification localNotification = LocalNotification( title: notification.title ?? 'Empty title', body: notification.details ?? 'No details available', ); diff --git a/lib/blocs/p2p_swap/htlc_swap/complete_htlc_swap_bloc.dart b/lib/blocs/p2p_swap/htlc_swap/complete_htlc_swap_bloc.dart index 2d4e264a..80ecb59d 100644 --- a/lib/blocs/p2p_swap/htlc_swap/complete_htlc_swap_bloc.dart +++ b/lib/blocs/p2p_swap/htlc_swap/complete_htlc_swap_bloc.dart @@ -11,13 +11,13 @@ class CompleteHtlcSwapBloc extends BaseBloc { }) async { try { addEvent(null); - final htlcId = swap.direction == P2pSwapDirection.outgoing + final String htlcId = swap.direction == P2pSwapDirection.outgoing ? swap.counterHtlcId! : swap.initialHtlcId; // Make sure that the HTLC exists and has a safe amount of time left // until expiration. - final htlc = await zenon!.embedded.htlc.getById(Hash.parse(htlcId)); + final HtlcInfo htlc = await zenon!.embedded.htlc.getById(Hash.parse(htlcId)); if (htlc.expirationTime <= DateTimeUtils.unixTimeNow + kMinSafeTimeToCompleteSwap.inSeconds) { throw 'The swap will expire too soon for a safe swap.'; @@ -28,19 +28,19 @@ class CompleteHtlcSwapBloc extends BaseBloc { throw 'The swap secret size exceeds the maximum allowed size.'; } - final transactionParams = zenon!.embedded.htlc.unlock( + final AccountBlockTemplate transactionParams = zenon!.embedded.htlc.unlock( Hash.parse(htlcId), FormatUtils.decodeHexString(swap.preimage!),); AccountBlockUtils.createAccountBlock(transactionParams, 'complete swap', address: Address.parse(swap.selfAddress), waitForRequiredPlasma: true,) .then( - (response) async { + (AccountBlockTemplate response) async { swap.state = P2pSwapState.completed; await htlcSwapsService!.storeSwap(swap); ZenonAddressUtils.refreshBalance(); addEvent(swap); }, ).onError( - (error, stackTrace) { + (Object? error, StackTrace stackTrace) { addError(error.toString(), stackTrace); }, ); diff --git a/lib/blocs/p2p_swap/htlc_swap/htlc_swap_bloc.dart b/lib/blocs/p2p_swap/htlc_swap/htlc_swap_bloc.dart index 8e67e68c..945516a7 100644 --- a/lib/blocs/p2p_swap/htlc_swap/htlc_swap_bloc.dart +++ b/lib/blocs/p2p_swap/htlc_swap/htlc_swap_bloc.dart @@ -14,7 +14,7 @@ class HtlcSwapBloc extends PeriodicP2pSwapBaseBloc { if (zenon!.wsClient.isClosed()) { throw noConnectionException; } - final swap = htlcSwapsService!.getSwapById(swapId); + final HtlcSwap? swap = htlcSwapsService!.getSwapById(swapId); if (swap != null) { return swap; } else { diff --git a/lib/blocs/p2p_swap/htlc_swap/initial_htlc_for_swap_bloc.dart b/lib/blocs/p2p_swap/htlc_swap/initial_htlc_for_swap_bloc.dart index b4782f5f..ac5d4af3 100644 --- a/lib/blocs/p2p_swap/htlc_swap/initial_htlc_for_swap_bloc.dart +++ b/lib/blocs/p2p_swap/htlc_swap/initial_htlc_for_swap_bloc.dart @@ -3,17 +3,18 @@ import 'dart:async'; import 'package:collection/collection.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; +import 'package:zenon_syrius_wallet_flutter/model/block_data.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class InitialHtlcForSwapBloc extends BaseBloc { - final _minimumRequiredDuration = + final Duration _minimumRequiredDuration = kMinSafeTimeToFindPreimage + kCounterHtlcDuration; Future getInitialHtlc(Hash id) async { try { - final htlc = await zenon!.embedded.htlc.getById(id); - final hashlock = FormatUtils.encodeHexString(htlc.hashLock); + final HtlcInfo htlc = await zenon!.embedded.htlc.getById(id); + final String hashlock = FormatUtils.encodeHexString(htlc.hashLock); if (!kDefaultAddressList.contains(htlc.hashLocked.toString())) { throw 'This deposit is not intended for you.'; } @@ -26,7 +27,7 @@ class InitialHtlcForSwapBloc extends BaseBloc { if (htlcSwapsService!.getSwapByHashLock(hashlock) != null) { throw "The deposit's hashlock is already used in another swap."; } - final remainingDuration = + final Duration remainingDuration = Duration(seconds: htlc.expirationTime - DateTimeUtils.unixTimeNow); if (remainingDuration < _minimumRequiredDuration) { if (remainingDuration.inSeconds <= 0) { @@ -37,7 +38,7 @@ class InitialHtlcForSwapBloc extends BaseBloc { if (remainingDuration > kMaxAllowedInitialHtlcDuration) { throw "The deposit's duration is too long. Expected ${kMaxAllowedInitialHtlcDuration.inHours} hours at most."; } - final creationBlock = await zenon!.ledger.getAccountBlockByHash(htlc.id); + final AccountBlock? creationBlock = await zenon!.ledger.getAccountBlockByHash(htlc.id); if (htlc.expirationTime - creationBlock!.confirmationDetail!.momentumTimestamp > kMaxAllowedInitialHtlcDuration.inSeconds) { @@ -46,12 +47,12 @@ class InitialHtlcForSwapBloc extends BaseBloc { // Verify that the hashlock has not been used in another currently active // HTLC. - final htlcBlocks = await AccountBlockUtils.getAccountBlocksAfterTime( + final List htlcBlocks = await AccountBlockUtils.getAccountBlocksAfterTime( htlcAddress, htlc.expirationTime - kMaxAllowedInitialHtlcDuration.inSeconds, ); if (htlcBlocks.firstWhereOrNull( - (block) => + (AccountBlock block) => !_isInitialHtlcBlock(block, htlc.id) && _hasMatchingHashlock(block, hashlock), ) != @@ -77,7 +78,7 @@ bool _hasMatchingHashlock(AccountBlock block, String hashlock) { return false; } - final blockData = AccountBlockUtils.getDecodedBlockData( + final BlockData? blockData = AccountBlockUtils.getDecodedBlockData( Definitions.htlc, block.pairedAccountBlock!.data, ); diff --git a/lib/blocs/p2p_swap/htlc_swap/join_htlc_swap_bloc.dart b/lib/blocs/p2p_swap/htlc_swap/join_htlc_swap_bloc.dart index a66f059b..01b2b805 100644 --- a/lib/blocs/p2p_swap/htlc_swap/join_htlc_swap_bloc.dart +++ b/lib/blocs/p2p_swap/htlc_swap/join_htlc_swap_bloc.dart @@ -21,7 +21,7 @@ class JoinHtlcSwapBloc extends BaseBloc { }) async { try { addEvent(null); - final transactionParams = zenon!.embedded.htlc.create( + final AccountBlockTemplate transactionParams = zenon!.embedded.htlc.create( fromToken, fromAmount, initialHtlc.timeLocked, @@ -33,8 +33,8 @@ class JoinHtlcSwapBloc extends BaseBloc { AccountBlockUtils.createAccountBlock(transactionParams, 'join swap', address: initialHtlc.hashLocked, waitForRequiredPlasma: true,) .then( - (response) async { - final swap = HtlcSwap( + (AccountBlockTemplate response) async { + final HtlcSwap swap = HtlcSwap( id: initialHtlc.id.toString(), chainId: response.chainIdentifier, type: swapType, @@ -65,7 +65,7 @@ class JoinHtlcSwapBloc extends BaseBloc { addEvent(swap); }, ).onError( - (error, stackTrace) { + (Object? error, StackTrace stackTrace) { addError(error.toString(), stackTrace); }, ); diff --git a/lib/blocs/p2p_swap/htlc_swap/reclaim_htlc_swap_funds_bloc.dart b/lib/blocs/p2p_swap/htlc_swap/reclaim_htlc_swap_funds_bloc.dart index 8f498984..8e1db549 100644 --- a/lib/blocs/p2p_swap/htlc_swap/reclaim_htlc_swap_funds_bloc.dart +++ b/lib/blocs/p2p_swap/htlc_swap/reclaim_htlc_swap_funds_bloc.dart @@ -11,18 +11,18 @@ class ReclaimHtlcSwapFundsBloc extends BaseBloc { }) async { try { addEvent(null); - final transactionParams = + final AccountBlockTemplate transactionParams = zenon!.embedded.htlc.reclaim(htlcId); AccountBlockUtils.createAccountBlock( transactionParams, 'reclaim swap funds', address: selfAddress, waitForRequiredPlasma: true,) .then( - (response) { + (AccountBlockTemplate response) { ZenonAddressUtils.refreshBalance(); addEvent(response); }, ).onError( - (error, stackTrace) { + (Object? error, StackTrace stackTrace) { addError(error.toString(), stackTrace); }, ); diff --git a/lib/blocs/p2p_swap/htlc_swap/recover_htlc_swap_funds_bloc.dart b/lib/blocs/p2p_swap/htlc_swap/recover_htlc_swap_funds_bloc.dart index d528da87..86e116c5 100644 --- a/lib/blocs/p2p_swap/htlc_swap/recover_htlc_swap_funds_bloc.dart +++ b/lib/blocs/p2p_swap/htlc_swap/recover_htlc_swap_funds_bloc.dart @@ -9,7 +9,7 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class RecoverHtlcSwapFundsBloc extends ReclaimHtlcSwapFundsBloc { Future recoverFunds({required Hash htlcId}) async { try { - final htlc = await zenon!.embedded.htlc.getById(htlcId); + final HtlcInfo htlc = await zenon!.embedded.htlc.getById(htlcId); if (!kDefaultAddressList.contains(htlc.timeLocked.toString())) { throw 'The deposit does not belong to you.'; diff --git a/lib/blocs/p2p_swap/htlc_swap/start_htlc_swap_bloc.dart b/lib/blocs/p2p_swap/htlc_swap/start_htlc_swap_bloc.dart index 455edcb9..dde02568 100644 --- a/lib/blocs/p2p_swap/htlc_swap/start_htlc_swap_bloc.dart +++ b/lib/blocs/p2p_swap/htlc_swap/start_htlc_swap_bloc.dart @@ -24,10 +24,10 @@ class StartHtlcSwapBloc extends BaseBloc { }) async { try { addEvent(null); - final preimage = _generatePreimage(); - final hashLock = await _getHashLock(hashType, preimage); - final expirationTime = await _getExpirationTime(initialHtlcDuration); - final transactionParams = zenon!.embedded.htlc.create( + final List preimage = _generatePreimage(); + final Hash hashLock = await _getHashLock(hashType, preimage); + final int expirationTime = await _getExpirationTime(initialHtlcDuration); + final AccountBlockTemplate transactionParams = zenon!.embedded.htlc.create( fromToken, fromAmount, counterpartyAddress, @@ -39,8 +39,8 @@ class StartHtlcSwapBloc extends BaseBloc { AccountBlockUtils.createAccountBlock(transactionParams, 'start swap', address: selfAddress, waitForRequiredPlasma: true,) .then( - (response) async { - final swap = HtlcSwap( + (AccountBlockTemplate response) async { + final HtlcSwap swap = HtlcSwap( id: response.hash.toString(), chainId: response.chainIdentifier, type: swapType, @@ -66,7 +66,7 @@ class StartHtlcSwapBloc extends BaseBloc { addEvent(swap); }, ).onError( - (error, stackTrace) { + (Object? error, StackTrace stackTrace) { addError(error.toString(), stackTrace); }, ); @@ -76,9 +76,9 @@ class StartHtlcSwapBloc extends BaseBloc { } List _generatePreimage() { - const maxInt = 256; + const int maxInt = 256; return List.generate( - htlcPreimageDefaultLength, (i) => Random.secure().nextInt(maxInt),); + htlcPreimageDefaultLength, (int i) => Random.secure().nextInt(maxInt),); } Future _getHashLock(int hashType, List preimage) async { diff --git a/lib/blocs/p2p_swap/p2p_swaps_list_bloc.dart b/lib/blocs/p2p_swap/p2p_swaps_list_bloc.dart index 084b5ad5..674f65f8 100644 --- a/lib/blocs/p2p_swap/p2p_swaps_list_bloc.dart +++ b/lib/blocs/p2p_swap/p2p_swaps_list_bloc.dart @@ -1,5 +1,6 @@ import 'package:zenon_syrius_wallet_flutter/blocs/p2p_swap/periodic_p2p_swap_base_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; +import 'package:zenon_syrius_wallet_flutter/model/p2p_swap/htlc_swap.dart'; import 'package:zenon_syrius_wallet_flutter/model/p2p_swap/p2p_swap.dart'; class P2pSwapsListBloc extends PeriodicP2pSwapBaseBloc> { @@ -14,7 +15,7 @@ class P2pSwapsListBloc extends PeriodicP2pSwapBaseBloc> { void getData() { try { - final data = _getSwaps(); + final List data = _getSwaps(); addEvent(data); } catch (e, stackTrace) { addError(e, stackTrace); @@ -22,8 +23,8 @@ class P2pSwapsListBloc extends PeriodicP2pSwapBaseBloc> { } List _getSwaps() { - final swaps = htlcSwapsService!.getAllSwaps(); - swaps.sort((a, b) => b.startTime.compareTo(a.startTime)); + final List swaps = htlcSwapsService!.getAllSwaps(); + swaps.sort((HtlcSwap a, HtlcSwap b) => b.startTime.compareTo(a.startTime)); return swaps; } } diff --git a/lib/blocs/p2p_swap/periodic_p2p_swap_base_bloc.dart b/lib/blocs/p2p_swap/periodic_p2p_swap_base_bloc.dart index 72a40cdb..2020e06b 100644 --- a/lib/blocs/p2p_swap/periodic_p2p_swap_base_bloc.dart +++ b/lib/blocs/p2p_swap/periodic_p2p_swap_base_bloc.dart @@ -3,7 +3,7 @@ import 'dart:async'; import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; abstract class PeriodicP2pSwapBaseBloc extends BaseBloc { - final _refreshInterval = const Duration(seconds: 5); + final Duration _refreshInterval = const Duration(seconds: 5); Timer? _autoRefresher; diff --git a/lib/blocs/pillars/delegate_button_bloc.dart b/lib/blocs/pillars/delegate_button_bloc.dart index e0889eaa..71d440d6 100644 --- a/lib/blocs/pillars/delegate_button_bloc.dart +++ b/lib/blocs/pillars/delegate_button_bloc.dart @@ -10,7 +10,7 @@ class DelegateButtonBloc extends BaseBloc { ) async { try { addEvent(null); - final transactionParams = zenon!.embedded.pillar.delegate( + final AccountBlockTemplate transactionParams = zenon!.embedded.pillar.delegate( pillarName!, ); AccountBlockUtils.createAccountBlock( @@ -18,7 +18,7 @@ class DelegateButtonBloc extends BaseBloc { 'delegate to Pillar', waitForRequiredPlasma: true, ).then( - (response) async { + (AccountBlockTemplate response) async { await Future.delayed(kDelayAfterAccountBlockCreationCall); addEvent(response); }, diff --git a/lib/blocs/pillars/disassemble_pillar_bloc.dart b/lib/blocs/pillars/disassemble_pillar_bloc.dart index 1fc9b11f..ba149ae1 100644 --- a/lib/blocs/pillars/disassemble_pillar_bloc.dart +++ b/lib/blocs/pillars/disassemble_pillar_bloc.dart @@ -12,7 +12,7 @@ class DisassemblePillarBloc extends BaseBloc { ) { try { addEvent(null); - final transactionParams = zenon!.embedded.pillar.revoke( + final AccountBlockTemplate transactionParams = zenon!.embedded.pillar.revoke( pillarName, ); AccountBlockUtils.createAccountBlock( @@ -20,7 +20,7 @@ class DisassemblePillarBloc extends BaseBloc { 'disassemble Pillar', waitForRequiredPlasma: true, ).then( - (response) { + (AccountBlockTemplate response) { ZenonAddressUtils.refreshBalance(); addEvent(response); }, diff --git a/lib/blocs/pillars/pillar_rewards_history_bloc.dart b/lib/blocs/pillars/pillar_rewards_history_bloc.dart index 0d21fd69..1fec99b3 100644 --- a/lib/blocs/pillars/pillar_rewards_history_bloc.dart +++ b/lib/blocs/pillars/pillar_rewards_history_bloc.dart @@ -8,12 +8,12 @@ class PillarRewardsHistoryBloc extends BaseBlocForReloadingIndicator { @override Future getDataAsync() async { - final response = + final RewardHistoryList response = await zenon!.embedded.pillar.getFrontierRewardByPage( Address.parse(kSelectedAddress!), pageSize: kStandardChartNumDays.toInt(), ); - if (response.list.any((element) => element.znnAmount > BigInt.zero)) { + if (response.list.any((RewardHistoryEntry element) => element.znnAmount > BigInt.zero)) { return response; } else { throw 'No rewards in the last week'; diff --git a/lib/blocs/pillars/pillars_deploy_bloc.dart b/lib/blocs/pillars/pillars_deploy_bloc.dart index 5f9925eb..e95d6c99 100644 --- a/lib/blocs/pillars/pillars_deploy_bloc.dart +++ b/lib/blocs/pillars/pillars_deploy_bloc.dart @@ -23,7 +23,7 @@ class PillarsDeployBloc extends BaseBloc { if (await _pillarNameAlreadyExists(pillarName)) { throw 'Pillar name already exists'; } - final transactionParams = zenon!.embedded.pillar.register( + final AccountBlockTemplate transactionParams = zenon!.embedded.pillar.register( pillarName, Address.parse(blockProducingAddress), Address.parse(rewardAddress), @@ -35,7 +35,7 @@ class PillarsDeployBloc extends BaseBloc { 'register Pillar', waitForRequiredPlasma: true, ).then( - (response) { + (AccountBlockTemplate response) { ZenonAddressUtils.refreshBalance(); addEvent(response); }, diff --git a/lib/blocs/pillars/pillars_deposit_qsr_bloc.dart b/lib/blocs/pillars/pillars_deposit_qsr_bloc.dart index 08a81b6e..432ea33c 100644 --- a/lib/blocs/pillars/pillars_deposit_qsr_bloc.dart +++ b/lib/blocs/pillars/pillars_deposit_qsr_bloc.dart @@ -16,7 +16,7 @@ class PillarsDepositQsrBloc extends BaseBloc { try { addEvent(null); if (!justMarkStepCompleted) { - final transactionParams = + final AccountBlockTemplate transactionParams = zenon!.embedded.pillar.depositQsr( amount, ); @@ -25,7 +25,7 @@ class PillarsDepositQsrBloc extends BaseBloc { 'deposit ${kQsrCoin.symbol} for Pillar Slot', waitForRequiredPlasma: true, ).then( - (response) async { + (AccountBlockTemplate response) async { await Future.delayed( kDelayAfterAccountBlockCreationCall, ); diff --git a/lib/blocs/pillars/pillars_qsr_info_bloc.dart b/lib/blocs/pillars/pillars_qsr_info_bloc.dart index 13424044..8c03f3cd 100644 --- a/lib/blocs/pillars/pillars_qsr_info_bloc.dart +++ b/lib/blocs/pillars/pillars_qsr_info_bloc.dart @@ -11,10 +11,10 @@ class PillarsQsrInfoBloc extends BaseBloc { ) async { try { addEvent(null); - final deposit = await zenon!.embedded.pillar.getDepositedQsr( + final BigInt deposit = await zenon!.embedded.pillar.getDepositedQsr( Address.parse(address), ); - final cost = await zenon!.embedded.pillar.getQsrRegistrationCost(); + final BigInt cost = await zenon!.embedded.pillar.getQsrRegistrationCost(); addEvent( PillarsQsrInfo( deposit: deposit, diff --git a/lib/blocs/pillars/pillars_withdraw_qsr_bloc.dart b/lib/blocs/pillars/pillars_withdraw_qsr_bloc.dart index 2670b478..390ba7e1 100644 --- a/lib/blocs/pillars/pillars_withdraw_qsr_bloc.dart +++ b/lib/blocs/pillars/pillars_withdraw_qsr_bloc.dart @@ -12,14 +12,14 @@ class PillarsWithdrawQsrBloc extends BaseBloc { Future withdrawQsr(String address) async { try { addEvent(null); - final transactionParams = + final AccountBlockTemplate transactionParams = zenon!.embedded.pillar.withdrawQsr(); AccountBlockUtils.createAccountBlock( transactionParams, 'withdraw ${kQsrCoin.symbol} from Pillar Slot', waitForRequiredPlasma: true, ).then( - (response) async { + (AccountBlockTemplate response) async { await Future.delayed(kDelayAfterAccountBlockCreationCall); ZenonAddressUtils.refreshBalance(); addEvent(response); diff --git a/lib/blocs/pillars/undelegate_button_bloc.dart b/lib/blocs/pillars/undelegate_button_bloc.dart index 84e8af31..2b021a38 100644 --- a/lib/blocs/pillars/undelegate_button_bloc.dart +++ b/lib/blocs/pillars/undelegate_button_bloc.dart @@ -9,14 +9,14 @@ class UndelegateButtonBloc extends BaseBloc { void cancelPillarVoting(BuildContext context) { try { addEvent(null); - final transactionParams = + final AccountBlockTemplate transactionParams = zenon!.embedded.pillar.undelegate(); AccountBlockUtils.createAccountBlock( transactionParams, 'undelegate', waitForRequiredPlasma: true, ).then( - (response) async { + (AccountBlockTemplate response) async { await Future.delayed(kDelayAfterAccountBlockCreationCall); addEvent(response); }, diff --git a/lib/blocs/pillars/update_pillar_bloc.dart b/lib/blocs/pillars/update_pillar_bloc.dart index 525100a3..024e813a 100644 --- a/lib/blocs/pillars/update_pillar_bloc.dart +++ b/lib/blocs/pillars/update_pillar_bloc.dart @@ -13,7 +13,7 @@ class UpdatePillarBloc extends BaseBloc { ) { try { addEvent(null); - final transactionParams = + final AccountBlockTemplate transactionParams = zenon!.embedded.pillar.updatePillar( name, producerAddress, diff --git a/lib/blocs/plasma/cancel_plasma_bloc.dart b/lib/blocs/plasma/cancel_plasma_bloc.dart index cf6135f9..100098cf 100644 --- a/lib/blocs/plasma/cancel_plasma_bloc.dart +++ b/lib/blocs/plasma/cancel_plasma_bloc.dart @@ -9,13 +9,13 @@ class CancelPlasmaBloc extends BaseBloc { void cancelPlasmaStaking(String id, BuildContext context) { try { addEvent(null); - final transactionParams = zenon!.embedded.plasma.cancel( + final AccountBlockTemplate transactionParams = zenon!.embedded.plasma.cancel( Hash.parse(id), ); AccountBlockUtils.createAccountBlock(transactionParams, 'cancel Plasma', waitForRequiredPlasma: true,) .then( - (response) { + (AccountBlockTemplate response) { ZenonAddressUtils.refreshBalance(); addEvent(response); }, diff --git a/lib/blocs/plasma/plasma_list_bloc.dart b/lib/blocs/plasma/plasma_list_bloc.dart index 3d734e0d..1f74e12b 100644 --- a/lib/blocs/plasma/plasma_list_bloc.dart +++ b/lib/blocs/plasma/plasma_list_bloc.dart @@ -10,16 +10,16 @@ class PlasmaListBloc extends InfiniteScrollBloc { @override Future> getData(int pageKey, int pageSize) async { - final results = + final List results = (await zenon!.embedded.plasma.getEntriesByAddress( Address.parse(kSelectedAddress!), pageIndex: pageKey, pageSize: pageSize, )) .list; - final lastMomentum = await zenon!.ledger.getFrontierMomentum(); + final Momentum lastMomentum = await zenon!.ledger.getFrontierMomentum(); lastMomentumHeight = lastMomentum.height; - for (final fusionEntry in results) { + for (final FusionEntry fusionEntry in results) { fusionEntry.isRevocable = lastMomentum.height > fusionEntry.expirationHeight; } diff --git a/lib/blocs/plasma/plasma_options_bloc.dart b/lib/blocs/plasma/plasma_options_bloc.dart index b5a6cdc4..da315865 100644 --- a/lib/blocs/plasma/plasma_options_bloc.dart +++ b/lib/blocs/plasma/plasma_options_bloc.dart @@ -9,7 +9,7 @@ class PlasmaOptionsBloc extends BaseBloc { void generatePlasma(String beneficiaryAddress, BigInt amount) { try { addEvent(null); - final transactionParams = zenon!.embedded.plasma.fuse( + final AccountBlockTemplate transactionParams = zenon!.embedded.plasma.fuse( Address.parse(beneficiaryAddress), amount, ); @@ -18,7 +18,7 @@ class PlasmaOptionsBloc extends BaseBloc { 'fuse ${kQsrCoin.symbol} for Plasma', waitForRequiredPlasma: true, ).then( - (response) { + (AccountBlockTemplate response) { ZenonAddressUtils.refreshBalance(); addEvent(response); }, diff --git a/lib/blocs/plasma/plasma_stats_bloc.dart b/lib/blocs/plasma/plasma_stats_bloc.dart index 5547d627..dbaf56a0 100644 --- a/lib/blocs/plasma/plasma_stats_bloc.dart +++ b/lib/blocs/plasma/plasma_stats_bloc.dart @@ -14,8 +14,8 @@ class PlasmaStatsBloc extends BaseBloc> Future getPlasmas() async { try { - final plasmaInfoWrapper = await Future.wait( - kDefaultAddressList.map((e) => _getPlasma(e!)).toList(), + final List plasmaInfoWrapper = await Future.wait( + kDefaultAddressList.map((String? e) => _getPlasma(e!)).toList(), ); addEvent(plasmaInfoWrapper); } catch (e, stackTrace) { @@ -25,7 +25,7 @@ class PlasmaStatsBloc extends BaseBloc> Future _getPlasma(String address) async { try { - final plasmaInfo = await zenon!.embedded.plasma.get( + final PlasmaInfo plasmaInfo = await zenon!.embedded.plasma.get( Address.parse(address), ); return PlasmaInfoWrapper(address: address, plasmaInfo: plasmaInfo); diff --git a/lib/blocs/refresh_bloc_mixin.dart b/lib/blocs/refresh_bloc_mixin.dart index da2453ea..09f54700 100644 --- a/lib/blocs/refresh_bloc_mixin.dart +++ b/lib/blocs/refresh_bloc_mixin.dart @@ -8,7 +8,7 @@ mixin RefreshBlocMixin { void listenToWsRestart(VoidCallback onWsConnectionRestartedCallback) { _restartWsStreamSubscription = zenon!.wsClient.restartedStream.listen( - (restarted) { + (bool restarted) { if (restarted) { onWsConnectionRestartedCallback(); } diff --git a/lib/blocs/sentinels/disassemble_button_bloc.dart b/lib/blocs/sentinels/disassemble_button_bloc.dart index 7c220df9..88e1f7e1 100644 --- a/lib/blocs/sentinels/disassemble_button_bloc.dart +++ b/lib/blocs/sentinels/disassemble_button_bloc.dart @@ -9,14 +9,14 @@ class DisassembleButtonBloc extends BaseBloc { Future disassembleSentinel(BuildContext context) async { try { addEvent(null); - final transactionParams = + final AccountBlockTemplate transactionParams = zenon!.embedded.sentinel.revoke(); AccountBlockUtils.createAccountBlock( transactionParams, 'disassemble Sentinel', waitForRequiredPlasma: true, ).then( - (response) { + (AccountBlockTemplate response) { ZenonAddressUtils.refreshBalance(); addEvent(response); }, diff --git a/lib/blocs/sentinels/sentinel_deposit_qsr_bloc.dart b/lib/blocs/sentinels/sentinel_deposit_qsr_bloc.dart index eb787f7e..8f14ba6d 100644 --- a/lib/blocs/sentinels/sentinel_deposit_qsr_bloc.dart +++ b/lib/blocs/sentinels/sentinel_deposit_qsr_bloc.dart @@ -16,7 +16,7 @@ class SentinelsDepositQsrBloc extends BaseBloc { try { addEvent(null); if (!justMarkStepCompleted) { - final transactionParams = + final AccountBlockTemplate transactionParams = zenon!.embedded.sentinel.depositQsr( amount, ); @@ -25,7 +25,7 @@ class SentinelsDepositQsrBloc extends BaseBloc { 'deposit ${kQsrCoin.symbol} for Sentinel Slot', waitForRequiredPlasma: true, ).then( - (response) async { + (AccountBlockTemplate response) async { await Future.delayed( kDelayAfterAccountBlockCreationCall, ); diff --git a/lib/blocs/sentinels/sentinel_qsr_info_bloc.dart b/lib/blocs/sentinels/sentinel_qsr_info_bloc.dart index 6024c068..1491b4f6 100644 --- a/lib/blocs/sentinels/sentinel_qsr_info_bloc.dart +++ b/lib/blocs/sentinels/sentinel_qsr_info_bloc.dart @@ -7,10 +7,10 @@ class SentinelsQsrInfoBloc extends BaseBloc { Future getQsrManagementInfo(String address) async { try { addEvent(null); - final deposit = await zenon!.embedded.sentinel.getDepositedQsr( + final BigInt deposit = await zenon!.embedded.sentinel.getDepositedQsr( Address.parse(address), ); - final cost = sentinelRegisterQsrAmount; + final BigInt cost = sentinelRegisterQsrAmount; addEvent( SentinelsQsrInfo( deposit: deposit, diff --git a/lib/blocs/sentinels/sentinel_register_bloc.dart b/lib/blocs/sentinels/sentinel_register_bloc.dart index b28488fd..429076fb 100644 --- a/lib/blocs/sentinels/sentinel_register_bloc.dart +++ b/lib/blocs/sentinels/sentinel_register_bloc.dart @@ -8,14 +8,14 @@ class SentinelsDeployBloc extends BaseBloc { Future deploySentinel(BigInt amount) async { try { addEvent(null); - final transactionParams = + final AccountBlockTemplate transactionParams = zenon!.embedded.sentinel.register(); AccountBlockUtils.createAccountBlock( transactionParams, 'register Sentinel', waitForRequiredPlasma: true, ).then( - (response) { + (AccountBlockTemplate response) { ZenonAddressUtils.refreshBalance(); addEvent(response); }, diff --git a/lib/blocs/sentinels/sentinel_rewards_history_bloc.dart b/lib/blocs/sentinels/sentinel_rewards_history_bloc.dart index 0c9e31f7..a516bb74 100644 --- a/lib/blocs/sentinels/sentinel_rewards_history_bloc.dart +++ b/lib/blocs/sentinels/sentinel_rewards_history_bloc.dart @@ -8,13 +8,13 @@ class SentinelRewardsHistoryBloc extends BaseBlocForReloadingIndicator { @override Future getDataAsync() async { - final response = + final RewardHistoryList response = await zenon!.embedded.sentinel.getFrontierRewardByPage( Address.parse(kSelectedAddress!), pageSize: kStandardChartNumDays.toInt(), ); if (response.list.any( - (element) => + (RewardHistoryEntry element) => element.qsrAmount > BigInt.zero || element.znnAmount > BigInt.zero, )) { return response; diff --git a/lib/blocs/sentinels/sentinel_withdraw_qsr_bloc.dart b/lib/blocs/sentinels/sentinel_withdraw_qsr_bloc.dart index 27e5bb9e..2a61de7e 100644 --- a/lib/blocs/sentinels/sentinel_withdraw_qsr_bloc.dart +++ b/lib/blocs/sentinels/sentinel_withdraw_qsr_bloc.dart @@ -12,14 +12,14 @@ class SentinelsWithdrawQsrBloc extends BaseBloc { withdrawQsr(String address) async { try { addEvent(null); - final transactionParams = + final AccountBlockTemplate transactionParams = zenon!.embedded.sentinel.withdrawQsr(); AccountBlockUtils.createAccountBlock( transactionParams, 'withdraw ${kQsrCoin.symbol} from Sentinel Slot', waitForRequiredPlasma: true, ).then( - (response) async { + (AccountBlockTemplate response) async { await Future.delayed(kDelayAfterAccountBlockCreationCall); ZenonAddressUtils.refreshBalance(); addEvent(response); diff --git a/lib/blocs/settings/account_chain_stats_bloc.dart b/lib/blocs/settings/account_chain_stats_bloc.dart index 8d7332a7..2146c715 100644 --- a/lib/blocs/settings/account_chain_stats_bloc.dart +++ b/lib/blocs/settings/account_chain_stats_bloc.dart @@ -8,19 +8,19 @@ class AccountChainStatsBloc extends BaseBlocForReloadingIndicator { @override Future getDataAsync() async { - final accountInfo = await zenon!.ledger.getAccountInfoByAddress( + final AccountInfo accountInfo = await zenon!.ledger.getAccountInfoByAddress( Address.parse( kSelectedAddress!, ), ); - final pageSize = accountInfo.blockCount!; - final pageCount = ((pageSize + 1) / rpcMaxPageSize).ceil(); + final int pageSize = accountInfo.blockCount!; + final int pageCount = ((pageSize + 1) / rpcMaxPageSize).ceil(); if (pageSize > 0) { - final allBlocks = []; + final List allBlocks = []; - for (var i = 0; i < pageCount; i++) { + for (int i = 0; i < pageCount; i++) { allBlocks.addAll((await zenon!.ledger.getAccountBlocksByHeight( Address.parse( kSelectedAddress!, @@ -28,7 +28,7 @@ class AccountChainStatsBloc (rpcMaxPageSize * i) + 1, )) .list ?? - [],); + [],); } return AccountChainStats( @@ -44,8 +44,8 @@ class AccountChainStatsBloc Map _getNumOfBlocksForEachBlockType( List blocks,) => BlockTypeEnum.values.fold>( - {}, - (previousValue, blockType) { + {}, + (Map previousValue, BlockTypeEnum blockType) { previousValue[blockType] = _getNumOfBlockForBlockType(blocks, blockType); return previousValue; @@ -56,7 +56,7 @@ class AccountChainStatsBloc List blocks, BlockTypeEnum blockType,) => blocks.fold( 0, - (int previousValue, element) { + (int previousValue, AccountBlock element) { if (element.blockType == blockType.index) { return previousValue + 1; } diff --git a/lib/blocs/settings/general_stats_bloc.dart b/lib/blocs/settings/general_stats_bloc.dart index b5b8cde0..3f3a0323 100644 --- a/lib/blocs/settings/general_stats_bloc.dart +++ b/lib/blocs/settings/general_stats_bloc.dart @@ -10,7 +10,7 @@ class GeneralStatsBloc extends BaseBlocWithRefreshMixin { @override Future getDataAsync() async { - final generalStats = GeneralStats( + final GeneralStats generalStats = GeneralStats( frontierMomentum: await zenon!.ledger.getFrontierMomentum(), processInfo: await zenon!.stats.processInfo(), networkInfo: await zenon!.stats.networkInfo(), diff --git a/lib/blocs/staking/cancel_stake_bloc.dart b/lib/blocs/staking/cancel_stake_bloc.dart index 90f6908c..199cca25 100644 --- a/lib/blocs/staking/cancel_stake_bloc.dart +++ b/lib/blocs/staking/cancel_stake_bloc.dart @@ -9,7 +9,7 @@ class CancelStakeBloc extends BaseBloc { void cancelStake(String hash, BuildContext context) { try { addEvent(null); - final transactionParams = zenon!.embedded.stake.cancel( + final AccountBlockTemplate transactionParams = zenon!.embedded.stake.cancel( Hash.parse(hash), ); AccountBlockUtils.createAccountBlock( @@ -17,7 +17,7 @@ class CancelStakeBloc extends BaseBloc { 'cancel stake', waitForRequiredPlasma: true, ).then( - (response) { + (AccountBlockTemplate response) { ZenonAddressUtils.refreshBalance(); addEvent(response); }, diff --git a/lib/blocs/staking/staking_options_bloc.dart b/lib/blocs/staking/staking_options_bloc.dart index cf9f9c08..d1981dbc 100644 --- a/lib/blocs/staking/staking_options_bloc.dart +++ b/lib/blocs/staking/staking_options_bloc.dart @@ -11,14 +11,14 @@ class StakingOptionsBloc extends BaseBloc { ) { try { addEvent(null); - final transactionParams = zenon!.embedded.stake.stake( + final AccountBlockTemplate transactionParams = zenon!.embedded.stake.stake( stakeDuration.inSeconds, amount, ); AccountBlockUtils.createAccountBlock(transactionParams, 'create stake', waitForRequiredPlasma: true,) .then( - (response) { + (AccountBlockTemplate response) { ZenonAddressUtils.refreshBalance(); addEvent(response); }, diff --git a/lib/blocs/staking/staking_rewards_history_bloc.dart b/lib/blocs/staking/staking_rewards_history_bloc.dart index 1af7d655..530998fb 100644 --- a/lib/blocs/staking/staking_rewards_history_bloc.dart +++ b/lib/blocs/staking/staking_rewards_history_bloc.dart @@ -8,12 +8,12 @@ class StakingRewardsHistoryBloc extends BaseBlocForReloadingIndicator { @override Future getDataAsync() async { - final response = + final RewardHistoryList response = await zenon!.embedded.stake.getFrontierRewardByPage( Address.parse(kSelectedAddress!), pageSize: kStandardChartNumDays.toInt(), ); - if (response.list.any((element) => element.qsrAmount > BigInt.zero)) { + if (response.list.any((RewardHistoryEntry element) => element.qsrAmount > BigInt.zero)) { return response; } else { throw 'No rewards in the last week'; diff --git a/lib/blocs/tokens/burn_token_bloc.dart b/lib/blocs/tokens/burn_token_bloc.dart index 6ba60b31..48afc023 100644 --- a/lib/blocs/tokens/burn_token_bloc.dart +++ b/lib/blocs/tokens/burn_token_bloc.dart @@ -10,14 +10,14 @@ class BurnTokenBloc extends BaseBloc { BigInt amount, ) { try { - final transactionParams = zenon!.embedded.token.burnToken( + final AccountBlockTemplate transactionParams = zenon!.embedded.token.burnToken( token.tokenStandard, amount, ); AccountBlockUtils.createAccountBlock(transactionParams, 'burn token', waitForRequiredPlasma: true,) .then( - (response) { + (AccountBlockTemplate response) { ZenonAddressUtils.refreshBalance(); addEvent(response); }, diff --git a/lib/blocs/tokens/issue_token_bloc.dart b/lib/blocs/tokens/issue_token_bloc.dart index 7576cdb5..c5252ca6 100644 --- a/lib/blocs/tokens/issue_token_bloc.dart +++ b/lib/blocs/tokens/issue_token_bloc.dart @@ -10,7 +10,7 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class IssueTokenBloc extends BaseBloc { void issueToken(NewTokenData tokenStepperData) { try { - final transactionParams = zenon!.embedded.token.issueToken( + final AccountBlockTemplate transactionParams = zenon!.embedded.token.issueToken( tokenStepperData.tokenName, tokenStepperData.tokenSymbol, tokenStepperData.tokenDomain, @@ -25,7 +25,7 @@ class IssueTokenBloc extends BaseBloc { 'issue token', waitForRequiredPlasma: true, ).then( - (response) { + (AccountBlockTemplate response) { Hive.box(kFavoriteTokensBox).add(response.tokenStandard.toString()); ZenonAddressUtils.refreshBalance(); addEvent(response); diff --git a/lib/blocs/tokens/mint_token_bloc.dart b/lib/blocs/tokens/mint_token_bloc.dart index dbeb7d08..95112d12 100644 --- a/lib/blocs/tokens/mint_token_bloc.dart +++ b/lib/blocs/tokens/mint_token_bloc.dart @@ -11,7 +11,7 @@ class MintTokenBloc extends BaseBloc { Address beneficiaryAddress, ) { try { - final transactionParams = zenon!.embedded.token.mintToken( + final AccountBlockTemplate transactionParams = zenon!.embedded.token.mintToken( token.tokenStandard, amount, beneficiaryAddress, @@ -19,7 +19,7 @@ class MintTokenBloc extends BaseBloc { AccountBlockUtils.createAccountBlock(transactionParams, 'mint token', waitForRequiredPlasma: true,) .then( - (response) { + (AccountBlockTemplate response) { response.amount = amount; ZenonAddressUtils.refreshBalance(); addEvent(response); diff --git a/lib/blocs/tokens/token_map_bloc.dart b/lib/blocs/tokens/token_map_bloc.dart index b687fb6e..56fe26c1 100644 --- a/lib/blocs/tokens/token_map_bloc.dart +++ b/lib/blocs/tokens/token_map_bloc.dart @@ -38,11 +38,11 @@ class TokenMapBloc with RefreshBlocMixin { yield* _fetchList(0); } - static const _pageSize = 10; + static const int _pageSize = 10; - final _subscriptions = CompositeSubscription(); + final CompositeSubscription _subscriptions = CompositeSubscription(); - final _onNewListingStateController = + final BehaviorSubject> _onNewListingStateController = BehaviorSubject>.seeded( InfiniteScrollBlocListingState(), ); @@ -50,11 +50,11 @@ class TokenMapBloc with RefreshBlocMixin { Stream> get onNewListingState => _onNewListingStateController.stream; - final _onPageRequest = StreamController(); + final StreamController _onPageRequest = StreamController(); Sink get onPageRequestSink => _onPageRequest.sink; - final _onSearchInputChangedSubject = BehaviorSubject.seeded(null); + final BehaviorSubject _onSearchInputChangedSubject = BehaviorSubject.seeded(null); Sink get onRefreshResultsRequest => _onSearchInputChangedSubject.sink; @@ -68,12 +68,12 @@ class TokenMapBloc with RefreshBlocMixin { String? get _searchInputTerm => _onSearchInputChangedSubject.value; Stream> _fetchList(int pageKey) async* { - final lastListingState = _onNewListingStateController.value; + final InfiniteScrollBlocListingState lastListingState = _onNewListingStateController.value; try { - final newItems = await getData(pageKey, _pageSize, _searchInputTerm); - final isLastPage = newItems.length < _pageSize; - final nextPageKey = isLastPage ? null : pageKey + 1; - var allItems = [...lastListingState.itemList ?? [], ...newItems]; + final List newItems = await getData(pageKey, _pageSize, _searchInputTerm); + final bool isLastPage = newItems.length < _pageSize; + final int? nextPageKey = isLastPage ? null : pageKey + 1; + List allItems = [...lastListingState.itemList ?? [], ...newItems]; allItems = filterItemsFunction(allItems); yield InfiniteScrollBlocListingState( nextPageKey: nextPageKey, @@ -98,9 +98,9 @@ class TokenMapBloc with RefreshBlocMixin { List _sortTokenList(List tokens) { tokens = tokens.fold>( - [], - (previousValue, token) { - if (![kZnnCoin.tokenStandard, kQsrCoin.tokenStandard] + [], + (List previousValue, Token token) { + if (![kZnnCoin.tokenStandard, kQsrCoin.tokenStandard] .contains(token.tokenStandard)) { previousValue.add(token); } @@ -112,9 +112,9 @@ class TokenMapBloc with RefreshBlocMixin { } List _sortByIfTokenCreatedByUser(List tokens) { - final sortedTokens = tokens + final List sortedTokens = tokens .where( - (token) => kDefaultAddressList.contains( + (Token token) => kDefaultAddressList.contains( token.owner.toString(), ), ) @@ -122,7 +122,7 @@ class TokenMapBloc with RefreshBlocMixin { sortedTokens.addAll(tokens .where( - (token) => !kDefaultAddressList.contains( + (Token token) => !kDefaultAddressList.contains( token.owner.toString(), ), ) @@ -132,11 +132,11 @@ class TokenMapBloc with RefreshBlocMixin { } List _sortByIfTokenIsInFavorites(List tokens) { - final favoriteTokens = Hive.box(kFavoriteTokensBox); + final Box favoriteTokens = Hive.box(kFavoriteTokensBox); - final sortedTokens = tokens + final List sortedTokens = tokens .where( - (token) => favoriteTokens.values.contains( + (Token token) => favoriteTokens.values.contains( token.tokenStandard.toString(), ), ) @@ -144,7 +144,7 @@ class TokenMapBloc with RefreshBlocMixin { sortedTokens.addAll(tokens .where( - (token) => !favoriteTokens.values.contains( + (Token token) => !favoriteTokens.values.contains( token.tokenStandard.toString(), ), ) @@ -178,7 +178,7 @@ class TokenMapBloc with RefreshBlocMixin { String searchTerm, ) async { _allTokens ??= (await zenon!.embedded.token.getAll()).list!; - final results = _allTokens!.where((token) => + final Iterable results = _allTokens!.where((Token token) => token.symbol.toLowerCase().contains(searchTerm.toLowerCase()),); results.toList().sublist( pageKey * pageSize, @@ -187,7 +187,7 @@ class TokenMapBloc with RefreshBlocMixin { : results.length, ); return results - .where((token) => + .where((Token token) => token.symbol.toLowerCase().contains(searchTerm.toLowerCase()),) .toList(); } diff --git a/lib/blocs/tokens/tokens_bloc.dart b/lib/blocs/tokens/tokens_bloc.dart index a89556de..87b5d6af 100644 --- a/lib/blocs/tokens/tokens_bloc.dart +++ b/lib/blocs/tokens/tokens_bloc.dart @@ -5,7 +5,7 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class TokensBloc extends BaseBloc?> with RefreshBlocMixin { TokensBloc() { zenon!.wsClient.restartedStream.listen( - (restarted) { + (bool restarted) { if (restarted) { getDataAsync(); } diff --git a/lib/blocs/tokens/transfer_ownership_bloc.dart b/lib/blocs/tokens/transfer_ownership_bloc.dart index 625a4fd8..861c0226 100644 --- a/lib/blocs/tokens/transfer_ownership_bloc.dart +++ b/lib/blocs/tokens/transfer_ownership_bloc.dart @@ -11,7 +11,7 @@ class TransferOwnershipBloc extends BaseBloc { bool isBurnable, ) { try { - final transactionParams = + final AccountBlockTemplate transactionParams = zenon!.embedded.token.updateToken( tokenStandard, owner, diff --git a/lib/blocs/transfer/receive_transaction_bloc.dart b/lib/blocs/transfer/receive_transaction_bloc.dart index 3341b985..aca53414 100644 --- a/lib/blocs/transfer/receive_transaction_bloc.dart +++ b/lib/blocs/transfer/receive_transaction_bloc.dart @@ -7,7 +7,7 @@ class ReceiveTransactionBloc extends BaseBloc { Future receiveTransaction(String id, BuildContext context) async { try { addEvent(null); - final response = await sl() + final AccountBlockTemplate? response = await sl() .autoReceiveTransactionHash(Hash.parse(id)); addEvent(response); } catch (e, stackTrace) { diff --git a/lib/blocs/transfer/send_payment_bloc.dart b/lib/blocs/transfer/send_payment_bloc.dart index bc553430..c224349a 100644 --- a/lib/blocs/transfer/send_payment_bloc.dart +++ b/lib/blocs/transfer/send_payment_bloc.dart @@ -23,7 +23,7 @@ class SendPaymentBloc extends BaseBloc { ); try { addEvent(null); - final accountBlock = block ?? + final AccountBlockTemplate accountBlock = block ?? AccountBlockTemplate.send( Address.parse(toAddress!), token!.tokenStandard, @@ -36,7 +36,7 @@ class SendPaymentBloc extends BaseBloc { address: Address.parse(fromAddress!), waitForRequiredPlasma: true, ).then( - (response) { + (AccountBlockTemplate response) { ZenonAddressUtils.refreshBalance(); addEvent(response); }, diff --git a/lib/blocs/transfer/transfer_widgets_balance_bloc.dart b/lib/blocs/transfer/transfer_widgets_balance_bloc.dart index 93cd61a0..bc89b40b 100644 --- a/lib/blocs/transfer/transfer_widgets_balance_bloc.dart +++ b/lib/blocs/transfer/transfer_widgets_balance_bloc.dart @@ -14,13 +14,13 @@ class TransferWidgetsBalanceBloc extends BaseBloc?> Future getBalanceForAllAddresses() async { try { addEvent(null); - final addressBalanceMap = {}; - final accountInfoList = await Future.wait( + final Map addressBalanceMap = {}; + final List accountInfoList = await Future.wait( kDefaultAddressList.map( - (address) => _getBalancePerAddress(address!), + (String? address) => _getBalancePerAddress(address!), ), ); - for (final accountInfo in accountInfoList) { + for (final AccountInfo accountInfo in accountInfoList) { addressBalanceMap[accountInfo.address!] = accountInfo; } addEvent(addressBalanceMap); diff --git a/lib/blocs/wallet_connect/chains/nom_service.dart b/lib/blocs/wallet_connect/chains/nom_service.dart index b6ab3bd1..b1dfe576 100644 --- a/lib/blocs/wallet_connect/chains/nom_service.dart +++ b/lib/blocs/wallet_connect/chains/nom_service.dart @@ -23,7 +23,7 @@ enum NoMChainId { extension NoMChainIdX on NoMChainId { String chain() { - var name = ''; + String name = ''; switch (this) { case NoMChainId.mainnet: @@ -64,13 +64,13 @@ class NoMService extends IChain { handler: _methodZnnSend, ); } - static const namespace = 'zenon'; + static const String namespace = 'zenon'; final IWeb3WalletService _web3WalletService = sl(); final NoMChainId reference; - final _walletLockedError = const WalletConnectError( + final WalletConnectError _walletLockedError = const WalletConnectError( code: 9000, message: 'Wallet is locked', ); @@ -89,17 +89,17 @@ class NoMService extends IChain { @override List getEvents() { - return ['chainIdChange', 'addressChange']; + return ['chainIdChange', 'addressChange']; } Future _methodZnnInfo(String topic, dynamic params) async { if (!await windowManager.isFocused() || !await windowManager.isVisible()) { windowManager.show(); } - final dAppMetadata = wallet! + final PairingMetadata dAppMetadata = wallet! .getActiveSessions() .values - .firstWhere((element) => element.topic == topic) + .firstWhere((SessionData element) => element.topic == topic) .peer .metadata; @@ -111,7 +111,7 @@ class NoMService extends IChain { title: '${dAppMetadata.name} - Information', content: Column( mainAxisSize: MainAxisSize.min, - children: [ + children: [ Text('Are you sure you want to allow ${dAppMetadata.name} to ' 'retrieve the current address, node URL and chain identifier information?'), kVerticalSpacing, @@ -125,7 +125,7 @@ class NoMService extends IChain { kVerticalSpacing, Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text(dAppMetadata.url), LinkIcon( url: dAppMetadata.url, @@ -139,7 +139,7 @@ class NoMService extends IChain { ); if (actionWasAccepted) { - return { + return { 'address': kSelectedAddress, 'nodeUrl': kCurrentNode, 'chainId': getChainIdentifier(), @@ -162,14 +162,14 @@ class NoMService extends IChain { if (!await windowManager.isFocused() || !await windowManager.isVisible()) { windowManager.show(); } - final dAppMetadata = wallet! + final PairingMetadata dAppMetadata = wallet! .getActiveSessions() .values - .firstWhere((element) => element.topic == topic) + .firstWhere((SessionData element) => element.topic == topic) .peer .metadata; if (kCurrentPage != Tabs.lock) { - final message = params as String; + final String message = params as String; if (globalNavigatorKey.currentContext!.mounted) { final actionWasAccepted = await showDialogWithNoAndYesOptions( @@ -178,7 +178,7 @@ class NoMService extends IChain { title: '${dAppMetadata.name} - Sign Message', content: Column( mainAxisSize: MainAxisSize.min, - children: [ + children: [ Text('Are you sure you want to ' 'sign message $message ?'), kVerticalSpacing, @@ -192,7 +192,7 @@ class NoMService extends IChain { kVerticalSpacing, Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text(dAppMetadata.url), LinkIcon( url: dAppMetadata.url, @@ -225,26 +225,26 @@ class NoMService extends IChain { if (!await windowManager.isFocused() || !await windowManager.isVisible()) { windowManager.show(); } - final dAppMetadata = wallet! + final PairingMetadata dAppMetadata = wallet! .getActiveSessions() .values - .firstWhere((element) => element.topic == topic) + .firstWhere((SessionData element) => element.topic == topic) .peer .metadata; if (kCurrentPage != Tabs.lock) { - final accountBlock = + final AccountBlockTemplate accountBlock = AccountBlockTemplate.fromJson(params['accountBlock']); - final toAddress = ZenonAddressUtils.getLabel( + final String toAddress = ZenonAddressUtils.getLabel( accountBlock.toAddress.toString(), ); - final token = + final Token? token = await zenon!.embedded.token.getByZts(accountBlock.tokenStandard); - final amount = accountBlock.amount.addDecimals(token!.decimals); + final String amount = accountBlock.amount.addDecimals(token!.decimals); - final sendPaymentBloc = SendPaymentBloc(); + final SendPaymentBloc sendPaymentBloc = SendPaymentBloc(); if (globalNavigatorKey.currentContext!.mounted) { final wasActionAccepted = await showDialogWithNoAndYesOptions( @@ -253,7 +253,7 @@ class NoMService extends IChain { title: '${dAppMetadata.name} - Send Payment', content: Column( mainAxisSize: MainAxisSize.min, - children: [ + children: [ Text('Are you sure you want to transfer ' '$amount ${token.symbol} to ' '$toAddress ?'), @@ -268,7 +268,7 @@ class NoMService extends IChain { kVerticalSpacing, Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text(dAppMetadata.url), LinkIcon( url: dAppMetadata.url, @@ -290,8 +290,8 @@ class NoMService extends IChain { block: AccountBlockTemplate.fromJson(params['accountBlock']), ); - final result = await sendPaymentBloc.stream.firstWhere( - (element) => element != null, + final AccountBlockTemplate? result = await sendPaymentBloc.stream.firstWhere( + (AccountBlockTemplate? element) => element != null, ); return result!; diff --git a/lib/blocs/wallet_connect/wallet_connect_sessions_bloc.dart b/lib/blocs/wallet_connect/wallet_connect_sessions_bloc.dart index a19f584e..fada4f7e 100644 --- a/lib/blocs/wallet_connect/wallet_connect_sessions_bloc.dart +++ b/lib/blocs/wallet_connect/wallet_connect_sessions_bloc.dart @@ -8,9 +8,9 @@ class WalletConnectSessionsBloc extends InfiniteScrollBloc { @override Future> getData(int pageKey, int pageSize) async { - final wcService = sl.get(); - final sessions = []; - for (final pairing in wcService.pairings.value) { + final IWeb3WalletService wcService = sl.get(); + final List sessions = []; + for (final PairingInfo pairing in wcService.pairings.value) { sessions.addAll( wcService.getSessionsForPairing(pairing.topic).values, ); diff --git a/lib/embedded_node/embedded_node.dart b/lib/embedded_node/embedded_node.dart index 429a23af..3441e611 100644 --- a/lib/embedded_node/embedded_node.dart +++ b/lib/embedded_node/embedded_node.dart @@ -20,12 +20,12 @@ _RunNodeFunc? _runNodeFunction; class EmbeddedNode { static void initializeNodeLib() { - final insideSdk = path.join('syrius', 'lib', 'embedded_node', 'blobs'); - final currentPathListParts = path.split(Directory.current.path); + final String insideSdk = path.join('syrius', 'lib', 'embedded_node', 'blobs'); + final List currentPathListParts = path.split(Directory.current.path); currentPathListParts.removeLast(); - final executablePathListParts = path.split(Platform.resolvedExecutable); + final List executablePathListParts = path.split(Platform.resolvedExecutable); executablePathListParts.removeLast(); - final possiblePaths = List.empty(growable: true); + final List possiblePaths = List.empty(growable: true); possiblePaths.add(Directory.current.path); possiblePaths.add( path.join( @@ -41,10 +41,10 @@ class EmbeddedNode { .add(path.join(path.joinAll(executablePathListParts), 'Resources')); possiblePaths.add(path.join(path.joinAll(currentPathListParts), insideSdk)); - var libraryPath = ''; - var found = false; + String libraryPath = ''; + bool found = false; - for (final currentPath in possiblePaths) { + for (final String currentPath in possiblePaths) { libraryPath = path.join(currentPath, 'libznn.so'); if (Platform.isMacOS) { @@ -54,7 +54,7 @@ class EmbeddedNode { libraryPath = path.join(currentPath, 'libznn.dll'); } - final libFile = File(libraryPath); + final File libFile = File(libraryPath); if (libFile.existsSync()) { found = true; @@ -71,20 +71,20 @@ class EmbeddedNode { } // Open the dynamic library - final dylib = DynamicLibrary.open(libraryPath); + final DynamicLibrary dylib = DynamicLibrary.open(libraryPath); - final stopNodeFunctionPointer = + final Pointer> stopNodeFunctionPointer = dylib.lookup>('StopNode'); _stopNodeFunction = stopNodeFunctionPointer.asFunction Function()>(); - final runNodeFunctionPointer = + final Pointer> runNodeFunctionPointer = dylib.lookup>('RunNode'); _runNodeFunction = runNodeFunctionPointer.asFunction Function()>(); } static Future runNode(List args) async { - final commandsPort = ReceivePort(); - final sendPort = commandsPort.sendPort; + final ReceivePort commandsPort = ReceivePort(); + final SendPort sendPort = commandsPort.sendPort; IsolateNameServer.registerPortWithName(sendPort, 'embeddedIsolate'); @@ -93,7 +93,7 @@ class EmbeddedNode { } _runNodeFunction!(); - final embeddedIsolateCompleter = Completer(); + final Completer embeddedIsolateCompleter = Completer(); commandsPort.listen((event) { _stopNodeFunction!(); IsolateNameServer.removePortNameMapping('embeddedIsolate'); @@ -111,7 +111,7 @@ class EmbeddedNode { } static bool stopNode() { - final embeddedIsolate = + final SendPort? embeddedIsolate = IsolateNameServer.lookupPortByName('embeddedIsolate'); if (embeddedIsolate != null) { embeddedIsolate.send('stop'); diff --git a/lib/handlers/htlc_swaps_handler.dart b/lib/handlers/htlc_swaps_handler.dart index 135208d3..f6cf095c 100644 --- a/lib/handlers/htlc_swaps_handler.dart +++ b/lib/handlers/htlc_swaps_handler.dart @@ -29,8 +29,8 @@ class HtlcSwapsHandler { } bool get hasActiveIncomingSwaps => - htlcSwapsService!.getSwapsByState([P2pSwapState.active]).firstWhereOrNull( - (e) => e.direction == P2pSwapDirection.incoming,) != + htlcSwapsService!.getSwapsByState([P2pSwapState.active]).firstWhereOrNull( + (HtlcSwap e) => e.direction == P2pSwapDirection.incoming,) != null; Future _runPeriodically() async { @@ -38,14 +38,14 @@ class HtlcSwapsHandler { _isRunning = true; await _enableWakelockIfNeeded(); if (!zenon!.wsClient.isClosed()) { - final unresolvedSwaps = htlcSwapsService!.getSwapsByState([ + final List unresolvedSwaps = htlcSwapsService!.getSwapsByState([ P2pSwapState.pending, P2pSwapState.active, P2pSwapState.reclaimable, ]); if (unresolvedSwaps.isNotEmpty) { if (await _areThereNewHtlcBlocks()) { - final newBlocks = await _getNewHtlcBlocks(unresolvedSwaps); + final List newBlocks = await _getNewHtlcBlocks(unresolvedSwaps); await _goThroughHtlcBlocks(newBlocks); } await _checkForExpiredSwaps(); @@ -73,7 +73,7 @@ class HtlcSwapsHandler { Future _getHtlcFrontierHeight() async { try { - final frontier = await zenon!.ledger.getFrontierAccountBlock(htlcAddress); + final AccountBlock? frontier = await zenon!.ledger.getFrontierAccountBlock(htlcAddress); return frontier?.height; } catch (e, stackTrace) { Logger('HtlcSwapsHandler') @@ -83,15 +83,15 @@ class HtlcSwapsHandler { } Future _areThereNewHtlcBlocks() async { - final frontier = await _getHtlcFrontierHeight(); + final int? frontier = await _getHtlcFrontierHeight(); return frontier != null && frontier > htlcSwapsService!.getLastCheckedHtlcBlockHeight(); } Future> _getNewHtlcBlocks(List swaps) async { - final lastCheckedHeight = htlcSwapsService!.getLastCheckedHtlcBlockHeight(); - final oldestSwapStartTime = _getOldestSwapStartTime(swaps) ?? 0; - var lastCheckedBlockTime = 0; + final int lastCheckedHeight = htlcSwapsService!.getLastCheckedHtlcBlockHeight(); + final int oldestSwapStartTime = _getOldestSwapStartTime(swaps) ?? 0; + int lastCheckedBlockTime = 0; if (lastCheckedHeight > 0) { try { @@ -102,7 +102,7 @@ class HtlcSwapsHandler { } catch (e, stackTrace) { Logger('HtlcSwapsHandler') .log(Level.WARNING, '_getNewHtlcBlocks', e, stackTrace); - return []; + return []; } } @@ -112,12 +112,12 @@ class HtlcSwapsHandler { } catch (e, stackTrace) { Logger('HtlcSwapsHandler') .log(Level.WARNING, '_getNewHtlcBlocks', e, stackTrace); - return []; + return []; } } Future _goThroughHtlcBlocks(List blocks) async { - for (final block in blocks) { + for (final AccountBlock block in blocks) { await _extractSwapDataFromBlock(block); await htlcSwapsService!.storeLastCheckedHtlcBlockHeight(block.height); } @@ -128,15 +128,15 @@ class HtlcSwapsHandler { return; } - final pairedBlock = htlcBlock.pairedAccountBlock!; - final blockData = AccountBlockUtils.getDecodedBlockData( + final AccountBlock pairedBlock = htlcBlock.pairedAccountBlock!; + final BlockData? blockData = AccountBlockUtils.getDecodedBlockData( Definitions.htlc, pairedBlock.data,); if (blockData == null) { return; } - final swap = _tryGetSwapFromBlockData(blockData); + final HtlcSwap? swap = _tryGetSwapFromBlockData(blockData); if (swap == null) { return; } @@ -198,7 +198,7 @@ class HtlcSwapsHandler { if (htlcBlock.descendantBlocks.isEmpty) { return; } - var isSelfReclaim = false; + bool isSelfReclaim = false; if (swap.direction == P2pSwapDirection.outgoing && blockData.params['id'].toString() == swap.initialHtlcId) { isSelfReclaim = true; @@ -253,10 +253,10 @@ class HtlcSwapsHandler { } Future _checkForExpiredSwaps() async { - final swaps = htlcSwapsService! - .getSwapsByState([P2pSwapState.pending, P2pSwapState.active]); - final now = DateTimeUtils.unixTimeNow; - for (final swap in swaps) { + final List swaps = htlcSwapsService! + .getSwapsByState([P2pSwapState.pending, P2pSwapState.active]); + final int now = DateTimeUtils.unixTimeNow; + for (final HtlcSwap swap in swaps) { if (swap.initialHtlcExpirationTime < now || (swap.counterHtlcExpirationTime != null && swap.counterHtlcExpirationTime! - @@ -273,9 +273,9 @@ class HtlcSwapsHandler { // since the counterparty may have published the preimage at the last moment // before the HTLC would have expired. In this situation the swap's state // may have already been changed to reclaimable. - final swaps = htlcSwapsService! - .getSwapsByState([P2pSwapState.active, P2pSwapState.reclaimable]); - for (final swap in swaps) { + final List swaps = htlcSwapsService! + .getSwapsByState([P2pSwapState.active, P2pSwapState.reclaimable]); + for (final HtlcSwap swap in swaps) { if (swap.direction == P2pSwapDirection.incoming && swap.preimage != null) { sl().addHash(Hash.parse(swap.initialHtlcId)); @@ -286,7 +286,7 @@ class HtlcSwapsHandler { int? _getOldestSwapStartTime(List swaps) { return swaps.isNotEmpty ? swaps - .reduce((e1, e2) => e1.startTime > e2.startTime ? e1 : e2) + .reduce((HtlcSwap e1, HtlcSwap e2) => e1.startTime > e2.startTime ? e1 : e2) .startTime : null; } diff --git a/lib/main.dart b/lib/main.dart index 042a60f0..503b07ec 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -12,6 +12,7 @@ import 'package:hydrated_bloc/hydrated_bloc.dart'; import 'package:layout/layout.dart'; import 'package:local_notifier/local_notifier.dart'; import 'package:logging/logging.dart'; +import 'package:nested/nested.dart'; import 'package:overlay_support/overlay_support.dart'; import 'package:path/path.dart' as path; import 'package:path_provider/path_provider.dart'; @@ -42,9 +43,9 @@ SharedPrefsService? sharedPrefsService; HtlcSwapsService? htlcSwapsService; IWeb3WalletService? web3WalletService; -final sl = GetIt.instance; +final GetIt sl = GetIt.instance; -final globalNavigatorKey = GlobalKey(); +final GlobalKey globalNavigatorKey = GlobalKey(); main() async { WidgetsFlutterBinding.ensureInitialized(); @@ -60,12 +61,12 @@ main() async { Hive.init(znnDefaultPaths.cache.path); // Setup logger - final syriusLogDir = + final Directory syriusLogDir = Directory(path.join(znnDefaultCacheDirectory.path, 'log')); if (!syriusLogDir.existsSync()) { syriusLogDir.createSync(recursive: true); } - final logFile = File( + final File logFile = File( '${syriusLogDir.path}${path.separator}syrius-${DateTime.now().millisecondsSinceEpoch}.log',); Logger.root.level = Level.ALL; Logger.root.onRecord.listen((LogRecord record) { @@ -92,7 +93,7 @@ main() async { setup(); retry(() => web3WalletService!.init(), - retryIf: (e) => e is SocketException || e is TimeoutException, + retryIf: (Exception e) => e is SocketException || e is TimeoutException, maxAttempts: 0x7FFFFFFFFFFFFFFF,); // Setup local_notifier @@ -165,7 +166,7 @@ Future _setupTrayManager() async { if (Platform.isMacOS) { await trayManager.setToolTip('s y r i u s'); } - final items = [ + final List items = [ MenuItem( key: 'show_wallet', label: 'Show wallet', @@ -185,11 +186,11 @@ Future _setupTrayManager() async { Future _loadDefaultCommunityNodes() async { try { - final nodes = await loadJsonFromAssets('assets/community-nodes.json') + final List nodes = await loadJsonFromAssets('assets/community-nodes.json') as List; kDefaultCommunityNodes = nodes .map((node) => node.toString()) - .where((node) => InputValidators.node(node) == null) + .where((String node) => InputValidators.node(node) == null) .toList(); } catch (e, stackTrace) { Logger('main') @@ -201,7 +202,7 @@ void setup() { sl.registerSingleton(Zenon()); zenon = sl(); sl.registerLazySingletonAsync( - () => SharedPrefsService.getInstance().then((value) => value!),); + () => SharedPrefsService.getInstance().then((SharedPrefsService? value) => value!),); sl.registerSingleton(HtlcSwapsService.getInstance()); // Initialize WalletConnect service @@ -267,7 +268,7 @@ class _MyAppState extends State with WindowListener, TrayListener { @override Widget build(BuildContext context) { return MultiProvider( - providers: [ + providers: [ ChangeNotifierProvider( create: (_) => SelectedAddressNotifier(), ), @@ -285,19 +286,19 @@ class _MyAppState extends State with WindowListener, TrayListener { ), ChangeNotifierProvider>>( create: (_) => ValueNotifier>( - [], + [], ), ), Provider( create: (_) => LockBloc(), - builder: (context, child) { + builder: (BuildContext context, Widget? child) { return Consumer( - builder: (_, appThemeNotifier, __) { - final lockBloc = + builder: (_, AppThemeNotifier appThemeNotifier, __) { + final LockBloc lockBloc = Provider.of(context, listen: false); return OverlaySupport( child: Listener( - onPointerSignal: (event) { + onPointerSignal: (PointerSignalEvent event) { if (event is PointerScrollEvent) { lockBloc.addEvent(LockEvent.resetTimer); } @@ -331,22 +332,22 @@ class _MyAppState extends State with WindowListener, TrayListener { scrollBehavior: RemoveOverscrollEffect(), localizationsDelegates: AppLocalizations.localizationsDelegates, supportedLocales: AppLocalizations.supportedLocales, - routes: { - AccessWalletScreen.route: (context) => + routes: { + AccessWalletScreen.route: (BuildContext context) => const AccessWalletScreen(), - SplashScreen.route: (context) => + SplashScreen.route: (BuildContext context) => const SplashScreen(), - MainAppContainer.route: (context) => + MainAppContainer.route: (BuildContext context) => const MainAppContainer(), NodeManagementScreen.route: (_) => const NodeManagementScreen(), }, - onGenerateRoute: (settings) { + onGenerateRoute: (RouteSettings settings) { if (settings.name == SyriusErrorWidget.route) { - final args = settings.arguments! + final CustomSyriusErrorWidgetArguments args = settings.arguments! as CustomSyriusErrorWidgetArguments; return MaterialPageRoute( - builder: (context) => + builder: (BuildContext context) => SyriusErrorWidget(args.errorText), ); } @@ -368,14 +369,14 @@ class _MyAppState extends State with WindowListener, TrayListener { @override Future onWindowClose() async { - final windowMaximized = await windowManager.isMaximized(); + final bool windowMaximized = await windowManager.isMaximized(); await sharedPrefsService!.put( kWindowMaximizedKey, windowMaximized, ); if (windowMaximized != true) { - final windowSize = await windowManager.getSize(); + final Size windowSize = await windowManager.getSize(); await sharedPrefsService!.put( kWindowSizeWidthKey, windowSize.width, @@ -385,7 +386,7 @@ class _MyAppState extends State with WindowListener, TrayListener { windowSize.height, ); - final windowPosition = await windowManager.getPosition(); + final Offset windowPosition = await windowManager.getPosition(); await sharedPrefsService!.put( kWindowPositionXKey, windowPosition.dx, diff --git a/lib/main_dev.dart b/lib/main_dev.dart index 44ba7c50..9eaa8e7e 100644 --- a/lib/main_dev.dart +++ b/lib/main_dev.dart @@ -2,15 +2,16 @@ import 'dart:async'; import 'dart:io'; import 'dart:isolate'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter/foundation.dart' show kDebugMode, kIsWeb; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:hive/hive.dart'; import 'package:hydrated_bloc/hydrated_bloc.dart'; import 'package:layout/layout.dart'; import 'package:local_notifier/local_notifier.dart'; import 'package:logging/logging.dart'; +import 'package:nested/nested.dart'; import 'package:overlay_support/overlay_support.dart'; import 'package:path/path.dart' as path; import 'package:path_provider/path_provider.dart'; @@ -53,12 +54,12 @@ main() async { Hive.init(znnDefaultPaths.cache.path); // Setup logger - final syriusLogDir = + final Directory syriusLogDir = Directory(path.join(znnDefaultCacheDirectory.path, 'log')); if (!syriusLogDir.existsSync()) { syriusLogDir.createSync(recursive: true); } - final logFile = File( + final File logFile = File( '${syriusLogDir.path}${path.separator}syrius-${DateTime.now().millisecondsSinceEpoch}.log',); Logger.root.level = Level.ALL; Logger.root.onRecord.listen((LogRecord record) { @@ -85,7 +86,7 @@ main() async { setup(); retry(() => web3WalletService!.init(), - retryIf: (e) => e is SocketException || e is TimeoutException, + retryIf: (Exception e) => e is SocketException || e is TimeoutException, maxAttempts: 0x7FFFFFFFFFFFFFFF,); // Setup local_notifier @@ -158,7 +159,7 @@ Future _setupTrayManager() async { if (Platform.isMacOS) { await trayManager.setToolTip('s y r i u s'); } - final items = [ + final List items = [ MenuItem( key: 'show_wallet', label: 'Show wallet', @@ -178,11 +179,11 @@ Future _setupTrayManager() async { Future _loadDefaultCommunityNodes() async { try { - final nodes = await loadJsonFromAssets('assets/community-nodes.json') + final List nodes = await loadJsonFromAssets('assets/community-nodes.json') as List; kDefaultCommunityNodes = nodes .map((node) => node.toString()) - .where((node) => InputValidators.node(node) == null) + .where((String node) => InputValidators.node(node) == null) .toList(); } catch (e, stackTrace) { Logger('main') @@ -194,7 +195,7 @@ void setup() { sl.registerSingleton(Zenon()); zenon = sl(); sl.registerLazySingletonAsync( - () => SharedPrefsService.getInstance().then((value) => value!),); + () => SharedPrefsService.getInstance().then((SharedPrefsService? value) => value!),); sl.registerSingleton(HtlcSwapsService.getInstance()); // Initialize WalletConnect service @@ -260,7 +261,7 @@ class _MyAppState extends State with WindowListener, TrayListener { @override Widget build(BuildContext context) { return MultiProvider( - providers: [ + providers: [ ChangeNotifierProvider( create: (_) => SelectedAddressNotifier(), ), @@ -278,19 +279,19 @@ class _MyAppState extends State with WindowListener, TrayListener { ), ChangeNotifierProvider>>( create: (_) => ValueNotifier>( - [], + [], ), ), Provider( create: (_) => LockBloc(), - builder: (context, child) { + builder: (BuildContext context, Widget? child) { return Consumer( - builder: (_, appThemeNotifier, __) { - final lockBloc = + builder: (_, AppThemeNotifier appThemeNotifier, __) { + final LockBloc lockBloc = Provider.of(context, listen: false); return OverlaySupport( child: Listener( - onPointerSignal: (event) { + onPointerSignal: (PointerSignalEvent event) { if (event is PointerScrollEvent) { lockBloc.addEvent(LockEvent.resetTimer); } @@ -324,22 +325,22 @@ class _MyAppState extends State with WindowListener, TrayListener { scrollBehavior: RemoveOverscrollEffect(), localizationsDelegates: AppLocalizations.localizationsDelegates, supportedLocales: AppLocalizations.supportedLocales, - routes: { - AccessWalletScreen.route: (context) => + routes: { + AccessWalletScreen.route: (BuildContext context) => const AccessWalletScreen(), - DevelopmentInitializationScreen.route: (context) => + DevelopmentInitializationScreen.route: (BuildContext context) => const DevelopmentInitializationScreen(), - MainAppContainer.route: (context) => + MainAppContainer.route: (BuildContext context) => const MainAppContainer(), NodeManagementScreen.route: (_) => const NodeManagementScreen(), }, - onGenerateRoute: (settings) { + onGenerateRoute: (RouteSettings settings) { if (settings.name == SyriusErrorWidget.route) { - final args = settings.arguments! + final CustomSyriusErrorWidgetArguments args = settings.arguments! as CustomSyriusErrorWidgetArguments; return MaterialPageRoute( - builder: (context) => + builder: (BuildContext context) => SyriusErrorWidget(args.errorText), ); } @@ -361,14 +362,14 @@ class _MyAppState extends State with WindowListener, TrayListener { @override Future onWindowClose() async { - final windowMaximized = await windowManager.isMaximized(); + final bool windowMaximized = await windowManager.isMaximized(); await sharedPrefsService!.put( kWindowMaximizedKey, windowMaximized, ); if (windowMaximized != true) { - final windowSize = await windowManager.getSize(); + final Size windowSize = await windowManager.getSize(); await sharedPrefsService!.put( kWindowSizeWidthKey, windowSize.width, @@ -378,7 +379,7 @@ class _MyAppState extends State with WindowListener, TrayListener { windowSize.height, ); - final windowPosition = await windowManager.getPosition(); + final Offset windowPosition = await windowManager.getPosition(); await sharedPrefsService!.put( kWindowPositionXKey, windowPosition.dx, diff --git a/lib/model/p2p_swap/htlc_swap.dart b/lib/model/p2p_swap/htlc_swap.dart index da396041..3f05326c 100644 --- a/lib/model/p2p_swap/htlc_swap.dart +++ b/lib/model/p2p_swap/htlc_swap.dart @@ -49,7 +49,7 @@ class HtlcSwap extends P2pSwap { @override Map toJson() { - final data = super.toJson(); + final Map data = super.toJson(); data['hashLock'] = hashLock; data['initialHtlcId'] = initialHtlcId; data['initialHtlcExpirationTime'] = initialHtlcExpirationTime; diff --git a/lib/model/p2p_swap/p2p_swap.dart b/lib/model/p2p_swap/p2p_swap.dart index 6c3ffd2c..323c4e34 100644 --- a/lib/model/p2p_swap/p2p_swap.dart +++ b/lib/model/p2p_swap/p2p_swap.dart @@ -90,7 +90,7 @@ class P2pSwap { String? toSymbol; int? toDecimals; - Map toJson() => { + Map toJson() => { 'id': id, 'chainId': chainId, 'type': type.name, diff --git a/lib/rearchitecture/features/balance/cubit/balance_cubit.dart b/lib/rearchitecture/features/balance/cubit/balance_cubit.dart index a451b85c..4910015e 100644 --- a/lib/rearchitecture/features/balance/cubit/balance_cubit.dart +++ b/lib/rearchitecture/features/balance/cubit/balance_cubit.dart @@ -4,6 +4,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'balance_cubit.g.dart'; + part 'balance_state.dart'; /// A cubit that is responsible for managing and fetching the account balance @@ -28,7 +29,9 @@ class BalanceCubit extends TimerCubit { /// Throws an exception if the balance retrieval fails. @override Future fetch() async { - final response = await zenon.ledger.getAccountInfoByAddress(address); + final AccountInfo response = await zenon.ledger.getAccountInfoByAddress( + address, + ); if (response.blockCount! > 0 && (response.znn()! > BigInt.zero || response.qsr()! > BigInt.zero)) { return response; diff --git a/lib/rearchitecture/features/balance/view/balance_card.dart b/lib/rearchitecture/features/balance/view/balance_card.dart index c717ab94..93e5b29e 100644 --- a/lib/rearchitecture/features/balance/view/balance_card.dart +++ b/lib/rearchitecture/features/balance/view/balance_card.dart @@ -21,7 +21,7 @@ class BalanceCard extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (_) { - final cubit = BalanceCubit( + final BalanceCubit cubit = BalanceCubit( Address.parse(kSelectedAddress!), zenon!, const BalanceState(), @@ -31,7 +31,7 @@ class BalanceCard extends StatelessWidget { child: CardScaffoldWithoutListener( data: CardType.balance.getData(context: context), body: BlocBuilder( - builder: (context, state) { + builder: (BuildContext context, BalanceState state) { return switch (state.status) { TimerStatus.initial => const BalanceEmpty(), TimerStatus.loading => const BalanceLoading(), diff --git a/lib/rearchitecture/features/balance/widgets/balance_address.dart b/lib/rearchitecture/features/balance/widgets/balance_address.dart index 8a997419..18d6bcf8 100644 --- a/lib/rearchitecture/features/balance/widgets/balance_address.dart +++ b/lib/rearchitecture/features/balance/widgets/balance_address.dart @@ -27,7 +27,7 @@ class BalanceAddress extends StatelessWidget { valueListenable: edgesColorNotifier, builder: (_, Color? edgesColor, __) { return FocusableActionDetector( - onShowHoverHighlight: (x) { + onShowHoverHighlight: (bool x) { if (x) { edgesColorNotifier.value = AppColors.znnColor; } else { @@ -50,7 +50,7 @@ class BalanceAddress extends StatelessWidget { ), child: AutoSizeText.rich( TextSpan( - children: [ + children: [ TextSpan( text: address.substring(0, 3), style: TextStyle(color: edgesColor), diff --git a/lib/rearchitecture/features/balance/widgets/balance_chart.dart b/lib/rearchitecture/features/balance/widgets/balance_chart.dart index bf2ca0e0..49bec6c5 100644 --- a/lib/rearchitecture/features/balance/widgets/balance_chart.dart +++ b/lib/rearchitecture/features/balance/widgets/balance_chart.dart @@ -25,14 +25,14 @@ class BalanceChart extends StatelessWidget { Widget build(BuildContext context) { return StandardPieChart( sections: _getChartSection(accountInfo), - onChartSectionTouched: (pieChartSection) { + onChartSectionTouched: (PieTouchedSection? pieChartSection) { hoveredSectionId.value = pieChartSection?.touchedSection?.title; }, ); } List _getChartSection(AccountInfo accountInfo) { - final sections = []; + final List sections = []; if (accountInfo.znn()! > BigInt.zero) { sections.add( _getBalanceChartSection( @@ -57,11 +57,11 @@ class BalanceChart extends StatelessWidget { Token token, AccountInfo accountInfo, ) { - final isTouched = + final bool isTouched = token.tokenStandard.toString() == hoveredSectionId.value; - final opacity = isTouched ? 1.0 : 0.7; + final double opacity = isTouched ? 1.0 : 0.7; - final value = accountInfo.getBalance(token.tokenStandard) / + final double value = accountInfo.getBalance(token.tokenStandard) / (accountInfo.znn()! + accountInfo.qsr()!); return PieChartSectionData( diff --git a/lib/rearchitecture/features/balance/widgets/balance_chart_legend.dart b/lib/rearchitecture/features/balance/widgets/balance_chart_legend.dart index 49242a37..22df3145 100644 --- a/lib/rearchitecture/features/balance/widgets/balance_chart_legend.dart +++ b/lib/rearchitecture/features/balance/widgets/balance_chart_legend.dart @@ -47,7 +47,7 @@ class BalanceChartLegend extends StatelessWidget { ) .addDecimals(coin.decimals), tokenSymbol: coin.symbol, - builder: (amount, tokenSymbol) => AmountInfoColumn( + builder: (String amount, String tokenSymbol) => AmountInfoColumn( context: context, amount: amount, tokenSymbol: tokenSymbol, diff --git a/lib/rearchitecture/features/balance/widgets/balance_populated.dart b/lib/rearchitecture/features/balance/widgets/balance_populated.dart index cbfcba9c..dddb9929 100644 --- a/lib/rearchitecture/features/balance/widgets/balance_populated.dart +++ b/lib/rearchitecture/features/balance/widgets/balance_populated.dart @@ -45,7 +45,7 @@ class _BalancePopulatedState extends State { @override Widget build(BuildContext context) { return Column( - children: [ + children: [ kVerticalSpacing, Expanded( child: AspectRatio( @@ -54,7 +54,7 @@ class _BalancePopulatedState extends State { builder: (BuildContext context, BoxConstraints constraints) { return Stack( alignment: Alignment.center, - children: [ + children: [ BalanceChart( accountInfo: widget.accountInfo, hoveredSectionId: _touchedSectionId, @@ -62,7 +62,7 @@ class _BalancePopulatedState extends State { ValueListenableBuilder( valueListenable: _touchedSectionId, builder: (_, String? id, __) { - final center = id != null + final Widget center = id != null ? _getBalance( accountInfo: widget.accountInfo, constraints: constraints, @@ -97,19 +97,19 @@ class _BalancePopulatedState extends State { required BoxConstraints constraints, required TokenStandard tokenStandard, }) { - final amount = accountInfo + final String amount = accountInfo .getBalance( tokenStandard, ) .addDecimals(coinDecimals); - final symbol = tokenStandard == kZnnCoin.tokenStandard + final String symbol = tokenStandard == kZnnCoin.tokenStandard ? kZnnCoin.symbol : kQsrCoin.symbol; - final margin = constraints.maxWidth * 0.3; + final double margin = constraints.maxWidth * 0.3; - final width = constraints.maxWidth - margin; + final double width = constraints.maxWidth - margin; return SizedBox( width: width, diff --git a/lib/rearchitecture/features/delegation/cubit/delegation_cubit.dart b/lib/rearchitecture/features/delegation/cubit/delegation_cubit.dart index 9bcd10d2..5f077eed 100644 --- a/lib/rearchitecture/features/delegation/cubit/delegation_cubit.dart +++ b/lib/rearchitecture/features/delegation/cubit/delegation_cubit.dart @@ -28,7 +28,7 @@ class DelegationCubit extends TimerCubit { /// - If not available, it throws an exception @override Future fetch() async { - final delegationInfo = await zenon.embedded.pillar.getDelegatedPillar( + final DelegationInfo? delegationInfo = await zenon.embedded.pillar.getDelegatedPillar( address, ); diff --git a/lib/rearchitecture/features/delegation/view/delegation_card.dart b/lib/rearchitecture/features/delegation/view/delegation_card.dart index aef9f67f..92a7b883 100644 --- a/lib/rearchitecture/features/delegation/view/delegation_card.dart +++ b/lib/rearchitecture/features/delegation/view/delegation_card.dart @@ -16,7 +16,7 @@ class DelegationCard extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (_) { - final cubit = DelegationCubit( + final DelegationCubit cubit = DelegationCubit( Address.parse(kSelectedAddress!), zenon!, const DelegationState(), @@ -26,7 +26,7 @@ class DelegationCard extends StatelessWidget { child: CardScaffoldWithoutListener( data: CardType.delegationStats.getData(context: context), body: BlocBuilder( - builder: (context, state) { + builder: (BuildContext context, DelegationState state) { return switch (state.status) { TimerStatus.initial => const DelegationEmpty(), TimerStatus.loading => const DelegationLoading(), diff --git a/lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_cubit.dart b/lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_cubit.dart index c1519e9d..92b595bc 100644 --- a/lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_cubit.dart +++ b/lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_cubit.dart @@ -26,8 +26,8 @@ class DualCoinStatsCubit /// It returns a list containing the fetched token data for ZNN and QSR. @override Future> fetch() async { - final data = await Future.wait( - [ + final List data = await Future.wait( + >[ zenon.embedded.token.getByZts( znnZts, // Fetches the ZNN token statistics ), @@ -38,7 +38,7 @@ class DualCoinStatsCubit ); // For ZNN and QSR, the network will return non-nullable data - final nonNullableData = data.map((token) => token!).toList(); + final List nonNullableData = data.map((Token? token) => token!).toList(); return nonNullableData; } diff --git a/lib/rearchitecture/features/dual_coin_stats/view/dual_coin_stats_card.dart b/lib/rearchitecture/features/dual_coin_stats/view/dual_coin_stats_card.dart index d7c87f79..2bfaf9e3 100644 --- a/lib/rearchitecture/features/dual_coin_stats/view/dual_coin_stats_card.dart +++ b/lib/rearchitecture/features/dual_coin_stats/view/dual_coin_stats_card.dart @@ -17,7 +17,7 @@ class DualCoinStatsCard extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (_) { - final cubit = DualCoinStatsCubit( + final DualCoinStatsCubit cubit = DualCoinStatsCubit( zenon!, const DualCoinStatsState(), )..fetchDataPeriodically(); @@ -26,7 +26,7 @@ class DualCoinStatsCard extends StatelessWidget { child: CardScaffoldWithoutListener( data: CardType.dualCoinStats.getData(context: context), body: BlocBuilder( - builder: (context, state) { + builder: (BuildContext context, DualCoinStatsState state) { return switch (state.status) { TimerStatus.initial => const DualCoinStatsEmpty(), TimerStatus.loading => const DualCoinStatsLoading(), diff --git a/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart.dart b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart.dart index 23b2b02c..ffb35c82 100644 --- a/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart.dart +++ b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart.dart @@ -38,7 +38,7 @@ class DualCoinStatsChart extends StatelessWidget { tokenList: tokenList, touchedSectionIndex: index, ), - onChartSectionTouched: (pieTouchedSection) { + onChartSectionTouched: (PieTouchedSection? pieTouchedSection) { touchedSectionIndexNotifier.value = pieTouchedSection?.touchedSectionIndex; }, @@ -52,16 +52,16 @@ class DualCoinStatsChart extends StatelessWidget { required List tokenList, required int? touchedSectionIndex, }) { - final totalSupply = tokenList.fold( + final BigInt totalSupply = tokenList.fold( BigInt.zero, - (previousValue, element) => previousValue + element.totalSupply, + (BigInt previousValue, Token element) => previousValue + element.totalSupply, ); return List.generate( tokenList.length, - (i) { - final currentTokenInfo = tokenList[i]; - final isTouched = i == touchedSectionIndex; - final opacity = isTouched ? 1.0 : 0.5; + (int i) { + final Token currentTokenInfo = tokenList[i]; + final bool isTouched = i == touchedSectionIndex; + final double opacity = isTouched ? 1.0 : 0.5; return PieChartSectionData( color: ColorUtils.getTokenColor(currentTokenInfo.tokenStandard) .withOpacity(opacity), diff --git a/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart index ec7f6f0c..07878e62 100644 --- a/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart +++ b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart_legend.dart @@ -17,10 +17,10 @@ class DualCoinStatsChartLegend extends StatelessWidget { @override Widget build(BuildContext context) { - final items = List.generate( + final List items = List.generate( tokens.length, - (index) { - final token = tokens[index]; + (int index) { + final Token token = tokens[index]; return Expanded( child: DualCoinStatsChartLegendItem( diff --git a/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart_legend_item.dart b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart_legend_item.dart index 1f60bb3a..26ea24dd 100644 --- a/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart_legend_item.dart +++ b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart_legend_item.dart @@ -20,7 +20,7 @@ class DualCoinStatsChartLegendItem extends StatelessWidget { token.decimals, ), tokenSymbol: token.symbol, - builder: (amount, symbol) => AmountInfoColumn( + builder: (String amount, String symbol) => AmountInfoColumn( amount: amount, tokenSymbol: symbol, context: context, diff --git a/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_populated.dart b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_populated.dart index 911006f0..06ae8102 100644 --- a/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_populated.dart +++ b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_populated.dart @@ -29,7 +29,7 @@ class _DualCoinStatsPopulatedState extends State @override Widget build(BuildContext context) { return Column( - children: [ + children: [ Expanded( child: DualCoinStatsChart( tokenList: widget.tokens, diff --git a/lib/rearchitecture/features/node_sync_status/cubit/node_sync_status_cubit.dart b/lib/rearchitecture/features/node_sync_status/cubit/node_sync_status_cubit.dart index 79ac1dc2..d4150e43 100644 --- a/lib/rearchitecture/features/node_sync_status/cubit/node_sync_status_cubit.dart +++ b/lib/rearchitecture/features/node_sync_status/cubit/node_sync_status_cubit.dart @@ -30,7 +30,7 @@ class NodeSyncStatusCubit @override Future> fetch() async { if (zenon.wsClient.status() == WebsocketStatus.running) { - final syncInfo = await zenon.stats.syncInfo(); + final SyncInfo syncInfo = await zenon.stats.syncInfo(); if (_lastSyncState != syncInfo.state && (syncInfo.state == SyncState.syncDone || (syncInfo.targetHeight > 0 && @@ -39,7 +39,7 @@ class NodeSyncStatusCubit _lastSyncState = syncInfo.state; if (syncInfo.state == SyncState.syncDone) { unawaited( - Future.delayed(const Duration(seconds: 5)).then((_) { + Future.delayed(const Duration(seconds: 5)).then((_) { NodeUtils.getUnreceivedTransactions().then((_) { sl().autoReceive(); }); @@ -47,15 +47,15 @@ class NodeSyncStatusCubit ); } } - return Pair(_lastSyncState, syncInfo); + return Pair(_lastSyncState, syncInfo); } - final placeholderSyncInfo = SyncInfo.fromJson({ + final SyncInfo placeholderSyncInfo = SyncInfo.fromJson({ 'state': 0, 'currentHeight': 0, 'targetHeight': 0, }); - return Pair(_lastSyncState, placeholderSyncInfo); + return Pair(_lastSyncState, placeholderSyncInfo); } @override diff --git a/lib/rearchitecture/features/node_sync_status/view/node_sync_status_icon.dart b/lib/rearchitecture/features/node_sync_status/view/node_sync_status_icon.dart index 9a997a75..ade65308 100644 --- a/lib/rearchitecture/features/node_sync_status/view/node_sync_status_icon.dart +++ b/lib/rearchitecture/features/node_sync_status/view/node_sync_status_icon.dart @@ -13,7 +13,7 @@ class NodeSyncStatusIcon extends StatelessWidget { @override Widget build(BuildContext context) { return BlocBuilder( - builder: (context, state) { + builder: (BuildContext context, NodeSyncStatusState state) { return switch (state.status) { TimerStatus.initial => const NodeSyncStatusEmpty(), TimerStatus.failure => NodeSyncStatusError( diff --git a/lib/rearchitecture/features/node_sync_status/widgets/node_sync_status_populated.dart b/lib/rearchitecture/features/node_sync_status/widgets/node_sync_status_populated.dart index bc516483..66abac02 100644 --- a/lib/rearchitecture/features/node_sync_status/widgets/node_sync_status_populated.dart +++ b/lib/rearchitecture/features/node_sync_status/widgets/node_sync_status_populated.dart @@ -15,9 +15,9 @@ class NodeSyncPopulated extends StatelessWidget { @override Widget build(BuildContext context) { - var (syncState, syncInfo) = (data.first, data.second); + var (SyncState syncState, SyncInfo syncInfo) = (data.first, data.second); - var message = ''; + String message = ''; if (syncState == SyncState.unknown) { message = 'Not ready'; diff --git a/lib/rearchitecture/features/pillars/cubit/pillars_cubit.dart b/lib/rearchitecture/features/pillars/cubit/pillars_cubit.dart index 71437cee..44faad4d 100644 --- a/lib/rearchitecture/features/pillars/cubit/pillars_cubit.dart +++ b/lib/rearchitecture/features/pillars/cubit/pillars_cubit.dart @@ -1,5 +1,6 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; +import 'package:znn_sdk_dart/src/model/embedded/pillar.dart'; part 'pillars_cubit.g.dart'; @@ -21,8 +22,8 @@ class PillarsCubit extends TimerCubit { @override Future fetch() async { // Fetches the list of all pillars from the Zenon network - final pillarInfoList = await zenon.embedded.pillar.getAll(); - final data = pillarInfoList.list.length; // Counts the number of pillars + final PillarInfoList pillarInfoList = await zenon.embedded.pillar.getAll(); + final int data = pillarInfoList.list.length; // Counts the number of pillars return data; // Returns the total number of pillars } diff --git a/lib/rearchitecture/features/pillars/view/pillars_card.dart b/lib/rearchitecture/features/pillars/view/pillars_card.dart index 4dc3eec3..24f5b4db 100644 --- a/lib/rearchitecture/features/pillars/view/pillars_card.dart +++ b/lib/rearchitecture/features/pillars/view/pillars_card.dart @@ -15,7 +15,7 @@ class PillarsCard extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (_) { - final cubit = PillarsCubit( + final PillarsCubit cubit = PillarsCubit( zenon!, const PillarsState(), )..fetchDataPeriodically(); @@ -24,7 +24,7 @@ class PillarsCard extends StatelessWidget { child: CardScaffoldWithoutListener( data: CardType.pillars.getData(context: context), body: BlocBuilder( - builder: (context, state) { + builder: (BuildContext context, PillarsState state) { return switch (state.status) { TimerStatus.initial => const PillarsEmpty(), TimerStatus.loading => const PillarsLoading(), diff --git a/lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_cubit.dart b/lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_cubit.dart index 5d97c5e1..685458ec 100644 --- a/lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_cubit.dart +++ b/lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_cubit.dart @@ -42,27 +42,27 @@ class RealtimeStatisticsCubit @override Future> fetch() async { // Get the current chain height - final chainHeight = (await zenon.ledger.getFrontierMomentum()).height; + final int chainHeight = (await zenon.ledger.getFrontierMomentum()).height; // Calculate the starting height for the block retrieval - final height = chainHeight - kMomentumsPerWeek > 0 + final int height = chainHeight - kMomentumsPerWeek > 0 ? chainHeight - kMomentumsPerWeek : 1; - var pageIndex = 0; // Start from the first page - const pageSize = 10; // Number of blocks to fetch per page - var isLastPage = false; // Flag to determine if it's the last page - final blockList = + int pageIndex = 0; // Start from the first page + const int pageSize = 10; // Number of blocks to fetch per page + bool isLastPage = false; // Flag to determine if it's the last page + final List blockList = []; // List to store fetched account blocks // Fetch account blocks until the last page is reached while (!isLastPage) { // Fetch account blocks for the current page - final response = (await zenon.ledger.getAccountBlocksByPage( + final List response = (await zenon.ledger.getAccountBlocksByPage( Address.parse(kSelectedAddress!), pageIndex: pageIndex, pageSize: pageSize, )) .list ?? // Default to an empty list if no blocks are found - []; + []; if (response.isEmpty) { break; // Exit the loop if no more blocks are found diff --git a/lib/rearchitecture/features/realtime_statistics/view/realtime_statistics_card.dart b/lib/rearchitecture/features/realtime_statistics/view/realtime_statistics_card.dart index 77b7ea99..449ec836 100644 --- a/lib/rearchitecture/features/realtime_statistics/view/realtime_statistics_card.dart +++ b/lib/rearchitecture/features/realtime_statistics/view/realtime_statistics_card.dart @@ -15,7 +15,7 @@ class RealtimeStatisticsCard extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (_) { - final cubit = RealtimeStatisticsCubit( + final RealtimeStatisticsCubit cubit = RealtimeStatisticsCubit( zenon!, const RealtimeStatisticsState(), )..fetchDataPeriodically(); @@ -24,7 +24,7 @@ class RealtimeStatisticsCard extends StatelessWidget { child: CardScaffoldWithoutListener( data: CardType.realtimeStatistics.getData(context: context), body: BlocBuilder( - builder: (context, state) { + builder: (BuildContext context, RealtimeStatisticsState state) { return switch (state.status) { TimerStatus.initial => const RealtimeStatisticsEmpty(), TimerStatus.loading => const RealtimeStatisticsLoading(), diff --git a/lib/rearchitecture/features/realtime_statistics/widgets/realtime_statistics_populated.dart b/lib/rearchitecture/features/realtime_statistics/widgets/realtime_statistics_populated.dart index 10d2f795..642f1c7d 100644 --- a/lib/rearchitecture/features/realtime_statistics/widgets/realtime_statistics_populated.dart +++ b/lib/rearchitecture/features/realtime_statistics/widgets/realtime_statistics_populated.dart @@ -22,10 +22,10 @@ class RealtimeStatisticsPopulated extends StatelessWidget { return Padding( padding: const EdgeInsets.all(16), child: Column( - children: [ + children: [ Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ ChartLegend( dotColor: ColorUtils.getTokenColor(kQsrCoin.tokenStandard), mainText: '${kQsrCoin.symbol} ' diff --git a/lib/rearchitecture/features/realtime_statistics/widgets/realtime_txs_chart.dart b/lib/rearchitecture/features/realtime_statistics/widgets/realtime_txs_chart.dart index 3ad0caaa..383fce0d 100644 --- a/lib/rearchitecture/features/realtime_statistics/widgets/realtime_txs_chart.dart +++ b/lib/rearchitecture/features/realtime_statistics/widgets/realtime_txs_chart.dart @@ -59,8 +59,8 @@ class _RealtimeTxsChartState extends State { } double _getTransactionsByDay(TokenStandard tokenId, DateTime date) { - final transactions = []; - for (final transaction in widget.transactions) { + final List transactions = []; + for (final AccountBlock transaction in widget.transactions) { AccountBlock? pairedAccountBlock; if (transaction.blockType == 3 && transaction.pairedAccountBlock != null) { @@ -81,7 +81,7 @@ class _RealtimeTxsChartState extends State { } } - final transactionsPerDay = transactions.length.toDouble(); + final double transactionsPerDay = transactions.length.toDouble(); if (transactionsPerDay > _maxTransactionsPerDay) { _maxTransactionsPerDay = transactionsPerDay; @@ -90,7 +90,7 @@ class _RealtimeTxsChartState extends State { } List _linesBarData() { - return [ + return [ StandardLineChartBarData( color: ColorUtils.getTokenColor(kZnnCoin.tokenStandard), spots: _znnSpots, @@ -105,7 +105,7 @@ class _RealtimeTxsChartState extends State { List _generateQsrSpots() { return List.generate( kStandardChartNumDays.toInt(), - (index) => FlSpot( + (int index) => FlSpot( index.toDouble(), _getTransactionsByDay( kQsrCoin.tokenStandard, @@ -120,7 +120,7 @@ class _RealtimeTxsChartState extends State { List _generateZnnSpots() { return List.generate( kStandardChartNumDays.toInt(), - (index) => FlSpot( + (int index) => FlSpot( index.toDouble(), _getTransactionsByDay( kZnnCoin.tokenStandard, diff --git a/lib/rearchitecture/features/sentinels/cubit/sentinels_cubit.dart b/lib/rearchitecture/features/sentinels/cubit/sentinels_cubit.dart index f55aa63f..167810bc 100644 --- a/lib/rearchitecture/features/sentinels/cubit/sentinels_cubit.dart +++ b/lib/rearchitecture/features/sentinels/cubit/sentinels_cubit.dart @@ -22,7 +22,7 @@ class SentinelsCubit extends TimerCubit { @override Future fetch() async { // Fetches the list of all active sentinels from the Zenon network - final data = await zenon.embedded.sentinel.getAllActive(); + final SentinelInfoList data = await zenon.embedded.sentinel.getAllActive(); return data; // Returns the fetched sentinel information } diff --git a/lib/rearchitecture/features/sentinels/view/sentinels_card.dart b/lib/rearchitecture/features/sentinels/view/sentinels_card.dart index 20dba17d..79d84934 100644 --- a/lib/rearchitecture/features/sentinels/view/sentinels_card.dart +++ b/lib/rearchitecture/features/sentinels/view/sentinels_card.dart @@ -15,7 +15,7 @@ class SentinelsCard extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (_) { - final cubit = SentinelsCubit( + final SentinelsCubit cubit = SentinelsCubit( zenon!, const SentinelsState(), )..fetchDataPeriodically(); @@ -24,7 +24,7 @@ class SentinelsCard extends StatelessWidget { child: CardScaffoldWithoutListener( data: CardType.sentinels.getData(context: context), body: BlocBuilder( - builder: (context, state) { + builder: (BuildContext context, SentinelsState state) { return switch (state.status) { TimerStatus.initial => const SentinelsEmpty(), TimerStatus.loading => const SentinelsLoading(), diff --git a/lib/rearchitecture/features/staking/cubit/staking_cubit.dart b/lib/rearchitecture/features/staking/cubit/staking_cubit.dart index 9448a94d..46672043 100644 --- a/lib/rearchitecture/features/staking/cubit/staking_cubit.dart +++ b/lib/rearchitecture/features/staking/cubit/staking_cubit.dart @@ -29,7 +29,7 @@ class StakingCubit extends TimerCubit { @override Future fetch() async { // Retrieve the list of staking entries for the demo address - final data = await _getStakeList(); + final StakeList data = await _getStakeList(); if (data.list.isNotEmpty) { return data; // Return the fetched stake data if not empty } else { diff --git a/lib/rearchitecture/features/staking/view/staking_card.dart b/lib/rearchitecture/features/staking/view/staking_card.dart index 29b2124f..87d71f05 100644 --- a/lib/rearchitecture/features/staking/view/staking_card.dart +++ b/lib/rearchitecture/features/staking/view/staking_card.dart @@ -15,7 +15,7 @@ class StakingCard extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (_) { - final cubit = StakingCubit( + final StakingCubit cubit = StakingCubit( zenon!, const StakingState(), )..fetchDataPeriodically(); @@ -24,7 +24,7 @@ class StakingCard extends StatelessWidget { child: CardScaffoldWithoutListener( data: CardType.staking.getData(context: context), body: BlocBuilder( - builder: (context, state) { + builder: (BuildContext context, StakingState state) { return switch (state.status) { TimerStatus.initial => const StakingEmpty(), TimerStatus.loading => const StakingLoading(), diff --git a/lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart b/lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart index d8a8a4ba..98564126 100644 --- a/lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart +++ b/lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart @@ -4,6 +4,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cu import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/exceptions/exceptions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:znn_sdk_dart/src/model/nom/detailed_momentum.dart'; part 'total_hourly_transactions_cubit.g.dart'; @@ -33,20 +34,20 @@ class TotalHourlyTransactionsCubit @override Future fetch() async { // Retrieve the current chain height - final chainHeight = await _ledgerGetMomentumLedgerHeight(); + final int chainHeight = await _ledgerGetMomentumLedgerHeight(); if (chainHeight - kMomentumsPerHour > 0) { // Fetch detailed momentums for the past hour - final response = (await zenon.ledger.getDetailedMomentumsByHeight( + final List response = (await zenon.ledger.getDetailedMomentumsByHeight( chainHeight - kMomentumsPerHour, kMomentumsPerHour, )) .list ?? - []; + []; // Prepare the transaction summary - final transactions = response.fold( + final int transactions = response.fold( 0, - (previousValue, element) => previousValue + element.blocks.length, + (int previousValue, DetailedMomentum element) => previousValue + element.blocks.length, ); return transactions; // Return the summary of transactions } else { diff --git a/lib/rearchitecture/features/total_hourly_transactions/view/total_hourly_transactions_card.dart b/lib/rearchitecture/features/total_hourly_transactions/view/total_hourly_transactions_card.dart index 46eff090..5b8232c4 100644 --- a/lib/rearchitecture/features/total_hourly_transactions/view/total_hourly_transactions_card.dart +++ b/lib/rearchitecture/features/total_hourly_transactions/view/total_hourly_transactions_card.dart @@ -15,7 +15,7 @@ class TotalHourlyTransactionsCard extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (_) { - final cubit = TotalHourlyTransactionsCubit( + final TotalHourlyTransactionsCubit cubit = TotalHourlyTransactionsCubit( zenon!, const TotalHourlyTransactionsState(), )..fetchDataPeriodically(); @@ -25,7 +25,7 @@ class TotalHourlyTransactionsCard extends StatelessWidget { data: CardType.totalHourlyTransactions.getData(context: context), body: BlocBuilder( - builder: (context, state) { + builder: (BuildContext context, TotalHourlyTransactionsState state) { return switch (state.status) { TimerStatus.initial => const TotalHourlyTransactionsEmpty(), TimerStatus.loading => const TotalHourlyTransactionsLoading(), diff --git a/lib/rearchitecture/features/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart b/lib/rearchitecture/features/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart index e76a54c8..6e3cfcd9 100644 --- a/lib/rearchitecture/features/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart +++ b/lib/rearchitecture/features/total_hourly_transactions/widgets/total_hourly_transactions_populated.dart @@ -18,7 +18,7 @@ class TotalHourlyTransactionsPopulated extends StatelessWidget { Widget build(BuildContext context) { return Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ NumberAnimation( end: count, isInt: true, diff --git a/lib/rearchitecture/utils/cubits/timer_state.dart b/lib/rearchitecture/utils/cubits/timer_state.dart index 7e49fac8..70886592 100644 --- a/lib/rearchitecture/utils/cubits/timer_state.dart +++ b/lib/rearchitecture/utils/cubits/timer_state.dart @@ -68,5 +68,5 @@ abstract class TimerState extends Equatable { }); @override - List get props => [status, data, error]; + List get props => [status, data, error]; } diff --git a/lib/rearchitecture/utils/widgets/card_scaffold_without_listener.dart b/lib/rearchitecture/utils/widgets/card_scaffold_without_listener.dart index be737657..8e410752 100644 --- a/lib/rearchitecture/utils/widgets/card_scaffold_without_listener.dart +++ b/lib/rearchitecture/utils/widgets/card_scaffold_without_listener.dart @@ -53,7 +53,7 @@ class _CardScaffoldWithoutListenerState extends State[ ExpandablePanel( collapsed: Container(), theme: ExpandableThemeData( @@ -111,7 +111,7 @@ class _CardScaffoldWithoutListenerState extends State[ const Icon( Icons.info, color: AppColors.znnColor, @@ -141,7 +141,7 @@ class _CardScaffoldWithoutListenerState extends State[ const Icon( Icons.remove_red_eye_rounded, color: AppColors.znnColor, @@ -160,7 +160,7 @@ class _CardScaffoldWithoutListenerState extends State[ Expanded( child: _getPasswordInputField(model), ), @@ -213,7 +213,7 @@ class _CardScaffoldWithoutListenerState extends State[ Expanded( child: Text( title, @@ -230,7 +230,7 @@ class _CardScaffoldWithoutListenerState extends State[ Visibility( visible: widget.onRefreshPressed != null, child: Material( @@ -266,7 +266,7 @@ class _CardScaffoldWithoutListenerState extends State.reactive( - onViewModelReady: (model) { + onViewModelReady: (HideWidgetStatusBloc model) { _actionButton = _getActionButton(model); // Stream will tell us if the widget info is hidden or not model.stream.listen( - (response) { + (bool? response) { if (response != null) { _passwordController.clear(); if (!response) { @@ -310,9 +310,9 @@ class _CardScaffoldWithoutListenerState extends State StreamBuilder( + builder: (_, HideWidgetStatusBloc model, __) => StreamBuilder( stream: model.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return _getBackBody(model); } diff --git a/lib/screens/change_wallet_password_screen.dart b/lib/screens/change_wallet_password_screen.dart index b27e64d5..24987153 100644 --- a/lib/screens/change_wallet_password_screen.dart +++ b/lib/screens/change_wallet_password_screen.dart @@ -5,6 +5,7 @@ import 'package:stacked/stacked.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/decrypt_wallet_file_bloc.dart'; import 'package:zenon_syrius_wallet_flutter/services/htlc_swaps_service.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/wallet_file.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -56,7 +57,7 @@ class _ChangeWalletPasswordScreenState style: Theme.of(context).textTheme.headlineLarge, ), Column( - children: [ + children: [ Form( key: _currentPasswordKey, autovalidateMode: AutovalidateMode.onUserInteraction, @@ -64,7 +65,7 @@ class _ChangeWalletPasswordScreenState errorText: _currentPassErrorText, controller: _currentPasswordController, hintText: 'Current password', - onChanged: (value) { + onChanged: (String value) { setState(() { if (_currentPassErrorText != null) { _currentPassErrorText = null; @@ -80,7 +81,7 @@ class _ChangeWalletPasswordScreenState child: PasswordInputField( controller: _newPasswordController, validator: InputValidators.validatePassword, - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, hintText: 'New password', @@ -92,17 +93,17 @@ class _ChangeWalletPasswordScreenState autovalidateMode: AutovalidateMode.onUserInteraction, child: PasswordInputField( controller: _confirmPasswordController, - validator: (value) => InputValidators.checkPasswordMatch( + validator: (String? value) => InputValidators.checkPasswordMatch( _newPasswordController.text, value, ), hintText: 'Repeat new password', - onSubmitted: (value) { + onSubmitted: (String value) { if (_arePasswordsValid()) { _loadingButton.onPressed!(); } }, - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, ), @@ -148,7 +149,7 @@ class _ChangeWalletPasswordScreenState String currentPassword, String newPassword, ) async { - final baseAddress = WalletUtils.baseAddress; + final Address baseAddress = WalletUtils.baseAddress; await kWalletFile!.changePassword(currentPassword, newPassword); await HtlcSwapsService.getInstance().closeBoxes(); await HtlcSwapsService.getInstance().openBoxes( @@ -172,8 +173,8 @@ class _ChangeWalletPasswordScreenState Widget _getDecryptKeyStoreFileViewModel() { return ViewModelBuilder.reactive( - onViewModelReady: (model) { - model.stream.listen((walletFile) async { + onViewModelReady: (DecryptWalletFileBloc model) { + model.stream.listen((WalletFile? walletFile) async { if (walletFile != null) { setState(() { _currentPassErrorText = null; @@ -206,7 +207,7 @@ class _ChangeWalletPasswordScreenState } },); }, - builder: (_, model, __) { + builder: (_, DecryptWalletFileBloc model, __) { _loadingButton = _getLoadingButton(model); return _getLoadingButton(model); }, diff --git a/lib/screens/development_intialization_screen.dart b/lib/screens/development_intialization_screen.dart index 2a8acc70..250415d0 100644 --- a/lib/screens/development_intialization_screen.dart +++ b/lib/screens/development_intialization_screen.dart @@ -22,9 +22,9 @@ class _DevelopmentInitializationScreenState Widget build(BuildContext context) { return FutureBuilder( future: _checkIfWalletPathIsNull(context: context), - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasData) { - final isWalletPathNull = snapshot.data!; + final bool isWalletPathNull = snapshot.data!; WidgetsBinding.instance.addPostFrameCallback((_) { if (isWalletPathNull) { diff --git a/lib/screens/dump_mnemonic_screen.dart b/lib/screens/dump_mnemonic_screen.dart index 4516d39c..bd7a4f38 100644 --- a/lib/screens/dump_mnemonic_screen.dart +++ b/lib/screens/dump_mnemonic_screen.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/wallet_file.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -44,10 +45,10 @@ class _DumpMnemonicScreenState extends State { child: PasswordInputField( controller: _passwordController, hintText: 'Current password', - onSubmitted: (value) { + onSubmitted: (String value) { _continueButton!.onPressed!(); }, - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, errorText: _passwordError, @@ -65,12 +66,12 @@ class _DumpMnemonicScreenState extends State { ), Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ _getLockButton(), Visibility( visible: _seedWords == null, child: Row( - children: [ + children: [ kSpacingBetweenActionButtons, _continueButton!, ], @@ -103,11 +104,11 @@ class _DumpMnemonicScreenState extends State { if (_passwordController.text.isNotEmpty) { try { _continueButtonKey.currentState!.animateForward(); - final walletFile = await WalletUtils.decryptWalletFile( + final WalletFile walletFile = await WalletUtils.decryptWalletFile( kWalletPath!, _passwordController.text, ); - walletFile.open().then((wallet) { + walletFile.open().then((Wallet wallet) { setState(() { _passwordController.clear(); _seedWords = (wallet as KeyStore).mnemonic!.split(' '); diff --git a/lib/screens/export/export_wallet_info_screen.dart b/lib/screens/export/export_wallet_info_screen.dart index 7fbe53b9..e765a694 100644 --- a/lib/screens/export/export_wallet_info_screen.dart +++ b/lib/screens/export/export_wallet_info_screen.dart @@ -60,8 +60,8 @@ class _ExportWalletInfoScreenState extends State { } Widget _getSeedFieldsGrid() { - final seedFieldsGridWidth = MediaQuery.of(context).size.width * 0.5; - const text = 'A Seed Vault is an encrypted file for backing up your Seed.' + final double seedFieldsGridWidth = MediaQuery.of(context).size.width * 0.5; + const String text = 'A Seed Vault is an encrypted file for backing up your Seed.' ' The Seed is encrypted with a Seed Vault Key and cannot be accessed ' 'without it. Make sure you backup your Seed Vault in multiple offline locations ' '(e.g. USB, external HDD) and do not lose your Seed Vault Key.' diff --git a/lib/screens/export/export_wallet_password_screen.dart b/lib/screens/export/export_wallet_password_screen.dart index 363e997a..aa635219 100644 --- a/lib/screens/export/export_wallet_password_screen.dart +++ b/lib/screens/export/export_wallet_password_screen.dart @@ -48,7 +48,7 @@ class _ExportWalletPasswordScreenState mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( - children: [ + children: [ const ProgressBar( currentLevel: 2, numLevels: 2, @@ -77,7 +77,7 @@ class _ExportWalletPasswordScreenState height: 50, ), Column( - children: [ + children: [ Form( key: _passwordKey, autovalidateMode: AutovalidateMode.onUserInteraction, @@ -85,7 +85,7 @@ class _ExportWalletPasswordScreenState hintText: 'Password', controller: _passwordController, validator: InputValidators.validatePassword, - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, ), @@ -97,12 +97,12 @@ class _ExportWalletPasswordScreenState child: PasswordInputField( hintText: 'Confirm password', controller: _confirmPasswordController, - validator: (value) => + validator: (String? value) => InputValidators.checkPasswordMatch( _passwordController.text, value, ), - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, ), @@ -144,7 +144,7 @@ class _ExportWalletPasswordScreenState initialDirectory = (await getApplicationDocumentsDirectory()).path; } - final walletPath = await getSaveLocation( + final FileSaveLocation? walletPath = await getSaveLocation( acceptedTypeGroups: [ const XTypeGroup( label: 'file', @@ -159,12 +159,12 @@ class _ExportWalletPasswordScreenState )}.json', ); if (walletPath != null) { - final keyStoreManager = KeyStoreManager( + final KeyStoreManager keyStoreManager = KeyStoreManager( walletPath: Directory( path.dirname(walletPath.path), ), ); - final keyStore = KeyStore.fromMnemonic(widget.seed); + final KeyStore keyStore = KeyStore.fromMnemonic(widget.seed); await keyStoreManager.saveKeyStore( keyStore, _passwordController.text, @@ -185,7 +185,7 @@ class _ExportWalletPasswordScreenState } void _updateExportedSeedList() { - final exportedSeeds = []; + final List exportedSeeds = []; exportedSeeds.addAll(Provider.of>>( context, listen: false, diff --git a/lib/screens/node_management_screen.dart b/lib/screens/node_management_screen.dart index f6412ea5..56d6a4bf 100644 --- a/lib/screens/node_management_screen.dart +++ b/lib/screens/node_management_screen.dart @@ -64,7 +64,7 @@ class _NodeManagementScreenState extends State { ), child: ListView( shrinkWrap: true, - children: [ + children: [ const NotificationWidget(), Text( 'Node Management', @@ -84,7 +84,7 @@ class _NodeManagementScreenState extends State { height: kVerticalSpacing.height! * 2, ), Row( - children: [ + children: [ const Expanded( child: SizedBox(), ), @@ -92,7 +92,7 @@ class _NodeManagementScreenState extends State { flex: 2, child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Text( 'Node selection', style: Theme.of(context).textTheme.bodyLarge, @@ -137,7 +137,7 @@ class _NodeManagementScreenState extends State { if (value == true) { NodeUtils.getUnreceivedTransactions().then((value) { sl().autoReceive(); - }).onError((error, stackTrace) { + }).onError((Object? error, StackTrace stackTrace) { Logger('MainAppContainer').log(Level.WARNING, '_getAutoReceiveCheckboxContainer', error, stackTrace,); }); @@ -193,7 +193,7 @@ class _NodeManagementScreenState extends State { Row _getConfirmNodeSelectionButton() { return Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ LoadingButton.settings( text: 'Continue', onPressed: _onConfirmNodeButtonPressed, @@ -211,16 +211,16 @@ class _NodeManagementScreenState extends State { try { _confirmNodeButtonKey.currentState?.animateForward(); - final url = _selectedNode == kEmbeddedNode + final String url = _selectedNode == kEmbeddedNode ? kLocalhostDefaultNodeUrl : _selectedNode!; - var isConnectionEstablished = + bool isConnectionEstablished = await NodeUtils.establishConnectionToNode(url); if (_selectedNode == kEmbeddedNode) { // Check if node is already running if (!isConnectionEstablished) { // Initialize local full node - await Isolate.spawn(EmbeddedNode.runNode, [''], + await Isolate.spawn(EmbeddedNode.runNode, [''], onExit: sl(instanceName: 'embeddedStoppedPort').sendPort, debugName: 'EmbeddedNodeIsolate',); @@ -272,14 +272,14 @@ class _NodeManagementScreenState extends State { Widget _getAddNodeColumn() { return Column( - children: [ + children: [ Form( key: _newNodeKey, autovalidateMode: AutovalidateMode.onUserInteraction, child: InputField( controller: _newNodeController, hintText: 'Node address with port', - onSubmitted: (value) { + onSubmitted: (String value) { if (_ifUserInputValid()) { _onAddNodePressed(); } @@ -306,7 +306,7 @@ class _NodeManagementScreenState extends State { InputValidators.node(_newNodeController.text) == null; Future _onAddNodePressed() async { - if ([...kDbNodes, ...kDefaultCommunityNodes, ...kDefaultNodes] + if ([...kDbNodes, ...kDefaultCommunityNodes, ...kDefaultNodes] .contains(_newNodeController.text)) { await NotificationUtils.sendNotificationError( 'Node ${_newNodeController.text} already exists', @@ -348,11 +348,11 @@ class _NodeManagementScreenState extends State { Row _getNodeTile(String node) { return Row( - children: [ + children: [ Radio( value: node, groupValue: _selectedNode, - onChanged: (value) { + onChanged: (String? value) { setState(() { _selectedNode = value; }); @@ -362,7 +362,7 @@ class _NodeManagementScreenState extends State { child: SettingsNode( key: ValueKey(node), node: node, - onNodePressed: (value) { + onNodePressed: (String? value) { setState(() { _selectedNode = value; }); diff --git a/lib/screens/onboarding/access_wallet_screen.dart b/lib/screens/onboarding/access_wallet_screen.dart index 145e9709..391bd9e0 100644 --- a/lib/screens/onboarding/access_wallet_screen.dart +++ b/lib/screens/onboarding/access_wallet_screen.dart @@ -19,7 +19,7 @@ class _AccessWalletScreenState extends State { body: Container( padding: const EdgeInsets.all(50), child: Column( - children: [ + children: [ Column( children: [ Text( @@ -39,7 +39,7 @@ class _AccessWalletScreenState extends State { Expanded( child: StandardFluidLayout( defaultCellHeight: kStaggeredNumOfColumns / 3, - children: [ + children: [ AccessWalletFluidCell( onPressed: _onCreateWalletButtonPressed, buttonIconLocation: 'assets/svg/ic_create_new.svg', diff --git a/lib/screens/onboarding/create_key_store_screen.dart b/lib/screens/onboarding/create_key_store_screen.dart index f513b98e..6f50e4f4 100644 --- a/lib/screens/onboarding/create_key_store_screen.dart +++ b/lib/screens/onboarding/create_key_store_screen.dart @@ -44,10 +44,10 @@ class _CreateKeyStoreScreenState extends State { child: Center( child: StreamBuilder( stream: _keyStoreFileBloc.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasData) { return Column( - children: [ + children: [ ProgressBar( currentLevel: widget.progressBarNumLevels - 1, numLevels: widget.progressBarNumLevels, diff --git a/lib/screens/onboarding/create_ledger_screen.dart b/lib/screens/onboarding/create_ledger_screen.dart index d8beeb5c..db1467cc 100644 --- a/lib/screens/onboarding/create_ledger_screen.dart +++ b/lib/screens/onboarding/create_ledger_screen.dart @@ -47,10 +47,10 @@ class _CreateLedgerWalletScreenState extends State { child: Center( child: StreamBuilder( stream: _ledgerWalletFileBloc.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasData) { return Column( - children: [ + children: [ ProgressBar( currentLevel: widget.progressBarNumLevels - 1, numLevels: widget.progressBarNumLevels, diff --git a/lib/screens/onboarding/hardware_wallet/hardware_wallet_device_choice_screen.dart b/lib/screens/onboarding/hardware_wallet/hardware_wallet_device_choice_screen.dart index 2d24df5e..6f807aec 100644 --- a/lib/screens/onboarding/hardware_wallet/hardware_wallet_device_choice_screen.dart +++ b/lib/screens/onboarding/hardware_wallet/hardware_wallet_device_choice_screen.dart @@ -20,8 +20,8 @@ class HardwareWalletDeviceChoiceScreen extends StatefulWidget { class _HardwareWalletDeviceChoiceScreenState extends State { - final List _walletManagers = [LedgerWalletManager()]; - List _devices = []; + final List _walletManagers = [LedgerWalletManager()]; + List _devices = []; WalletDefinition? _selectedDevice; final Map> _deviceValueMap = >{}; @@ -54,7 +54,7 @@ class _HardwareWalletDeviceChoiceScreenState mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( - children: [ + children: [ const ProgressBar( currentLevel: 1, numLevels: 4, @@ -131,22 +131,22 @@ class _HardwareWalletDeviceChoiceScreenState } Future _scanDevices() async { - final futures = _walletManagers - .map((manager) => manager.getWalletDefinitions()) + final List>> futures = _walletManagers + .map((WalletManager manager) => manager.getWalletDefinitions()) .toList(); - final listOfDefinitions = + final List> listOfDefinitions = await Future.wait(futures); // Combine all the iterables into a single list using fold or expand // For example, using fold: - final combinedList = + final List combinedList = listOfDefinitions.fold>( [], - (previousList, element) => previousList..addAll(element), + (List previousList, Iterable element) => previousList..addAll(element), ); - for (final device in combinedList) { + for (final WalletDefinition device in combinedList) { if (!_deviceValueMap.containsKey(device.walletId)) { _deviceValueMap[device.walletId] = ValueNotifier(null); } @@ -156,7 +156,7 @@ class _HardwareWalletDeviceChoiceScreenState _devices = combinedList; _selectedDevice = null; - for (final valueNotifier in _deviceValueMap.values) { + for (final ValueNotifier valueNotifier in _deviceValueMap.values) { valueNotifier.value = null; } }); @@ -165,8 +165,8 @@ class _HardwareWalletDeviceChoiceScreenState List _getDevices() { return _devices .map( - (e) => Row( - children: [ + (WalletDefinition e) => Row( + children: [ Radio( value: e, groupValue: _selectedDevice, @@ -178,7 +178,7 @@ class _HardwareWalletDeviceChoiceScreenState vertical: 5, ), child: Row( - children: [ + children: [ Expanded( child: InkWell( borderRadius: BorderRadius.circular( @@ -190,7 +190,7 @@ class _HardwareWalletDeviceChoiceScreenState horizontal: 5, vertical: 5,), child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Text( _getWalletName(e), style: Theme.of(context) @@ -206,7 +206,7 @@ class _HardwareWalletDeviceChoiceScreenState ), ValueListenableBuilder( valueListenable: _deviceValueMap[e.walletId]!, - builder: (context, value, _) => SizedBox( + builder: (BuildContext context, String? value, _) => SizedBox( height: 20, child: value == null ? const Text( @@ -236,8 +236,8 @@ class _HardwareWalletDeviceChoiceScreenState WalletDefinition? walletDefinition,) async { Wallet? wallet; try { - for (final walletManager in _walletManagers) { - final wd = walletDefinition!; + for (final WalletManager walletManager in _walletManagers) { + final WalletDefinition wd = walletDefinition!; if (await walletManager.supportsWallet(wd)) { wallet = await walletManager.getWallet(walletDefinition); break; @@ -248,7 +248,7 @@ class _HardwareWalletDeviceChoiceScreenState origMessage: 'Not connected, please connect the device and try again.',); } - final walletAddress = await _getWalletAddress(wallet); + final Address walletAddress = await _getWalletAddress(wallet); setState(() { _deviceValueMap[walletDefinition!.walletId]!.value = walletAddress.toString(); @@ -267,7 +267,7 @@ class _HardwareWalletDeviceChoiceScreenState } Future
_getWalletAddress(Wallet wallet) async { - final account = await wallet.getAccount(); + final WalletAccount account = await wallet.getAccount(); if (account is LedgerWalletAccount) { await sl.get().addNotification( WalletNotification( diff --git a/lib/screens/onboarding/hardware_wallet/hardware_wallet_password_screen.dart b/lib/screens/onboarding/hardware_wallet/hardware_wallet_password_screen.dart index 78b27273..566b65e7 100644 --- a/lib/screens/onboarding/hardware_wallet/hardware_wallet_password_screen.dart +++ b/lib/screens/onboarding/hardware_wallet/hardware_wallet_password_screen.dart @@ -33,7 +33,7 @@ class _HardwareWalletPasswordScreenState extends State[ Column( - children: [ + children: [ const ProgressBar( currentLevel: 2, numLevels: 4, @@ -51,14 +51,14 @@ class _HardwareWalletPasswordScreenState extends State[ Form( key: _passwordKey, autovalidateMode: AutovalidateMode.onUserInteraction, child: PasswordInputField( controller: _passwordController, validator: InputValidators.validatePassword, - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, hintText: 'Password', @@ -70,10 +70,10 @@ class _HardwareWalletPasswordScreenState extends State + validator: (String? value) => InputValidators.checkPasswordMatch( _passwordController.text, value,), - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, hintText: 'Confirm password', diff --git a/lib/screens/onboarding/import_wallet/import_wallet_decrypt_screen.dart b/lib/screens/onboarding/import_wallet/import_wallet_decrypt_screen.dart index 574db2e3..966c6b5a 100644 --- a/lib/screens/onboarding/import_wallet/import_wallet_decrypt_screen.dart +++ b/lib/screens/onboarding/import_wallet/import_wallet_decrypt_screen.dart @@ -37,7 +37,7 @@ class _ImportWalletDecryptScreenState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( - children: [ + children: [ const ProgressBar( currentLevel: 2, ), @@ -58,11 +58,11 @@ class _ImportWalletDecryptScreenState extends State { PasswordInputField( hintText: 'Password', controller: _passwordController, - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, errorText: _passwordErrorText, - onSubmitted: (value) { + onSubmitted: (String value) { if (_passwordController.text.isNotEmpty) { _loadingButton.onPressed!(); } @@ -109,16 +109,16 @@ class _ImportWalletDecryptScreenState extends State { ViewModelBuilder _getDecryptKeyStoreFileViewModel() { return ViewModelBuilder.reactive( - onViewModelReady: (model) { - model.stream.listen((walletFile) { + onViewModelReady: (DecryptWalletFileBloc model) { + model.stream.listen((WalletFile? walletFile) { if (walletFile != null && walletFile is KeyStoreWalletFile) { _loadingButtonKey.currentState!.animateReverse(); setState(() { _passwordErrorText = null; }); walletFile - .access((wallet) => Future.value((wallet as KeyStore).mnemonic!)) - .then((value) => NavigationUtils.push( + .access((Wallet wallet) => Future.value((wallet as KeyStore).mnemonic!)) + .then((String value) => NavigationUtils.push( context, ImportWalletPasswordScreen(value),),); } }, onError: (error) { @@ -134,7 +134,7 @@ class _ImportWalletDecryptScreenState extends State { } },); }, - builder: (_, model, __) { + builder: (_, DecryptWalletFileBloc model, __) { _loadingButton = _getLoadingButton(model); return _getLoadingButton(model); }, diff --git a/lib/screens/onboarding/import_wallet/import_wallet_password_screen.dart b/lib/screens/onboarding/import_wallet/import_wallet_password_screen.dart index 318e515e..c5dea392 100644 --- a/lib/screens/onboarding/import_wallet/import_wallet_password_screen.dart +++ b/lib/screens/onboarding/import_wallet/import_wallet_password_screen.dart @@ -38,7 +38,7 @@ class _ImportWalletPasswordScreenState mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( - children: [ + children: [ ProgressBar( currentLevel: widget.progressBarNumLevels - 2, numLevels: widget.progressBarNumLevels, @@ -59,7 +59,7 @@ class _ImportWalletPasswordScreenState height: 100, ), Column( - children: [ + children: [ Form( key: _passwordKey, autovalidateMode: AutovalidateMode.onUserInteraction, @@ -67,10 +67,10 @@ class _ImportWalletPasswordScreenState hintText: 'Password', controller: _passwordController, validator: InputValidators.validatePassword, - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, - onSubmitted: (value) { + onSubmitted: (String value) { if (_arePasswordsValid()) { NavigationUtils.push( context, @@ -92,15 +92,15 @@ class _ImportWalletPasswordScreenState child: PasswordInputField( hintText: 'Confirm password', controller: _confirmPasswordController, - validator: (value) => + validator: (String? value) => InputValidators.checkPasswordMatch( _passwordController.text, value, ), - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, - onSubmitted: (value) { + onSubmitted: (String value) { if (_arePasswordsValid()) { NavigationUtils.push( context, diff --git a/lib/screens/onboarding/import_wallet/import_wallet_seed_choice_screen.dart b/lib/screens/onboarding/import_wallet/import_wallet_seed_choice_screen.dart index 85938f82..ff15525c 100644 --- a/lib/screens/onboarding/import_wallet/import_wallet_seed_choice_screen.dart +++ b/lib/screens/onboarding/import_wallet/import_wallet_seed_choice_screen.dart @@ -38,7 +38,7 @@ class _ImportWalletSeedChoiceScreenState mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( - children: [ + children: [ ProgressBar( currentLevel: 1, // If the seed is imported from a file, an extra step to decrypt the file is needed @@ -118,10 +118,10 @@ class _ImportWalletSeedChoiceScreenState } else { showDialog( context: context, - builder: (context) => AlertDialog( + builder: (BuildContext context) => AlertDialog( title: const Text('Importing seed'), content: const Text('Mnemonic is not valid'), - actions: [ + actions: [ TextButton( child: const Text('OK'), onPressed: () { @@ -163,7 +163,7 @@ class _ImportWalletSeedChoiceScreenState setState(() { _isSeed12Selected = false; _seedGridKey.currentState!.changedSeed( - List.generate(24, (index) => ''), + List.generate(24, (int index) => ''), ); }); }, @@ -171,7 +171,7 @@ class _ImportWalletSeedChoiceScreenState setState(() { _isSeed12Selected = true; _seedGridKey.currentState!.changedSeed( - List.generate(12, (index) => ''), + List.generate(12, (int index) => ''), ); }); }, @@ -183,11 +183,11 @@ class _ImportWalletSeedChoiceScreenState _isSeed12Selected ? List.generate( 12, - (index) => '', + (int index) => '', ) : List.generate( 24, - (index) => '', + (int index) => '', ), key: _seedGridKey, isContinueButtonDisabled: true, diff --git a/lib/screens/onboarding/new_wallet/new_wallet_confirm_seed_screen.dart b/lib/screens/onboarding/new_wallet/new_wallet_confirm_seed_screen.dart index 8c26a206..cff334de 100644 --- a/lib/screens/onboarding/new_wallet/new_wallet_confirm_seed_screen.dart +++ b/lib/screens/onboarding/new_wallet/new_wallet_confirm_seed_screen.dart @@ -27,15 +27,15 @@ class _NewWalletConfirmSeedScreenState late Widget _actionButton; String? _draggedValue; - final List _seedGridElements = []; - final List _randomIndexes = []; - List _foundMissingRandomElementsIndexes = []; + final List _seedGridElements = []; + final List _randomIndexes = []; + List _foundMissingRandomElementsIndexes = []; @override void initState() { super.initState(); _actionButton = _getVerifyButton(); - for (final word in widget.seedWords) { + for (final String word in widget.seedWords) { _seedGridElements.add( SeedGridElement( word: word, @@ -45,7 +45,7 @@ class _NewWalletConfirmSeedScreenState ); } _generateRandomIndexes(); - for (final index in _randomIndexes) { + for (final int index in _randomIndexes) { _seedGridElements[index].word = ''; } } @@ -61,7 +61,7 @@ class _NewWalletConfirmSeedScreenState mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( - children: [ + children: [ const ProgressBar( currentLevel: 2, ), @@ -75,7 +75,7 @@ class _NewWalletConfirmSeedScreenState kVerticalSpacing, Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text( 'Drag & drop the words in the correct order', style: Theme.of(context).textTheme.headlineMedium, @@ -93,7 +93,7 @@ class _NewWalletConfirmSeedScreenState ], ), Row( - children: [ + children: [ Container( margin: const EdgeInsets.only(left: 90), child: _getMissingSeedGridElements(widget.seedWords), @@ -121,7 +121,7 @@ class _NewWalletConfirmSeedScreenState } void _generateRandomIndex() { - final randomNumber = Random().nextInt(_seedGridElements.length); + final int randomNumber = Random().nextInt(_seedGridElements.length); if (!_randomIndexes.contains(randomNumber)) { _randomIndexes.add(randomNumber); } @@ -152,9 +152,9 @@ class _NewWalletConfirmSeedScreenState } Widget _seedFieldWidget(SeedGridElement seedGridElement) { - final seedGridElementIndex = _seedGridElements.indexOf(seedGridElement); + final int seedGridElementIndex = _seedGridElements.indexOf(seedGridElement); - final controller = TextEditingController(); + final TextEditingController controller = TextEditingController(); controller.text = seedGridElement.word; if (_textCursor == seedGridElementIndex) { controller.selection = TextSelection.collapsed( @@ -175,7 +175,7 @@ class _NewWalletConfirmSeedScreenState }); }, child: FocusableActionDetector( - onShowHoverHighlight: (x) { + onShowHoverHighlight: (bool x) { if (x) { setState(() { _hoveredSeedGridIndex = seedGridElementIndex; @@ -213,7 +213,7 @@ class _NewWalletConfirmSeedScreenState ), Expanded( child: FocusableActionDetector( - onShowHoverHighlight: (x) { + onShowHoverHighlight: (bool x) { if (x) { setState(() { _hoveredSeedGridIndex = seedGridElementIndex; @@ -225,7 +225,7 @@ class _NewWalletConfirmSeedScreenState } }, child: DragTarget( - builder: (BuildContext context, accepted, rejected) { + builder: (BuildContext context, List accepted, List rejected) { return TextField( enabled: false, controller: controller, @@ -257,13 +257,13 @@ class _NewWalletConfirmSeedScreenState ), ); }, - onWillAcceptWithDetails: (data) { + onWillAcceptWithDetails: (DragTargetDetails data) { return _randomIndexes.contains(seedGridElementIndex) || !seedGridElement.isValid; }, onAcceptWithDetails: (DragTargetDetails data) { - final element = _seedGridElements[seedGridElementIndex]; - var i = -1; + final SeedGridElement element = _seedGridElements[seedGridElementIndex]; + int i = -1; if (element.word != '') { while ((i = widget.seedWords.indexOf(element.word, i + 1)) != @@ -296,8 +296,8 @@ class _NewWalletConfirmSeedScreenState } Widget _getMissingSeedGridElements(List seedWords) { - final list = []; - for (final index in _randomIndexes) { + final List list = []; + for (final int index in _randomIndexes) { if (!_foundMissingRandomElementsIndexes.contains(index)) { list.add( Draggable( @@ -359,16 +359,16 @@ class _NewWalletConfirmSeedScreenState void _checkSeed() { _seedError = false; - for (final element in _seedGridElements) { - final i = _seedGridElements.indexOf(element); + for (final SeedGridElement element in _seedGridElements) { + final int i = _seedGridElements.indexOf(element); element.isValid = element.word == widget.seedWords[i]; if (!element.isValid) { _seedError = true; } } if (_seedError) { - for (final element in _seedGridElements) { - final i = _seedGridElements.indexOf(element); + for (final SeedGridElement element in _seedGridElements) { + final int i = _seedGridElements.indexOf(element); if (_randomIndexes.contains(i)) { element.isValid = false; element.word = ''; @@ -379,7 +379,7 @@ class _NewWalletConfirmSeedScreenState setState(() { _seedError = true; _foundMissingRandomElementsIndexes = _randomIndexes - .where((index) => _seedGridElements[index].isValid) + .where((int index) => _seedGridElements[index].isValid) .toList(); _actionButton = _foundMissingRandomElementsIndexes.length == kNumOfSeedWordsToBeFound @@ -395,7 +395,7 @@ class _NewWalletConfirmSeedScreenState NavigationUtils.push( context, NewWalletPasswordScreen( - _seedGridElements.map((e) => e.word).toList(), + _seedGridElements.map((SeedGridElement e) => e.word).toList(), ), ); }, @@ -419,16 +419,16 @@ class _NewWalletConfirmSeedScreenState } Widget _getSeedInputWidgetsGrid() { - final divider = widget.seedWords.length ~/ kSeedGridNumOfRows; + final int divider = widget.seedWords.length ~/ kSeedGridNumOfRows; - var columnChildren = []; + List columnChildren = []; - for (var i = 0; i <= _seedGridElements.length / divider - 1; i++) { + for (int i = 0; i <= _seedGridElements.length / divider - 1; i++) { columnChildren.add( _getSeedRow( List.generate( divider, - (index) => index + (divider * i), + (int index) => index + (divider * i), ), ), ); @@ -437,7 +437,7 @@ class _NewWalletConfirmSeedScreenState columnChildren = columnChildren.zip( List.generate( kSeedGridNumOfRows - 1, - (index) => const SizedBox( + (int index) => const SizedBox( height: 10, ), ), @@ -450,9 +450,9 @@ class _NewWalletConfirmSeedScreenState } Widget _getSeedRow(List rangeIndexes) { - final children = rangeIndexes.fold>( - [], - (previousValue, index) { + final List children = rangeIndexes.fold>( + [], + (List previousValue, int index) { previousValue.add(_seedFieldWidget( _seedGridElements[index], ),); diff --git a/lib/screens/onboarding/new_wallet/new_wallet_password_screen.dart b/lib/screens/onboarding/new_wallet/new_wallet_password_screen.dart index f7687290..9d0a0d5f 100644 --- a/lib/screens/onboarding/new_wallet/new_wallet_password_screen.dart +++ b/lib/screens/onboarding/new_wallet/new_wallet_password_screen.dart @@ -32,7 +32,7 @@ class _NewWalletPasswordScreenState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( - children: [ + children: [ const ProgressBar( currentLevel: 3, ), @@ -49,14 +49,14 @@ class _NewWalletPasswordScreenState extends State { height: 65, ), Column( - children: [ + children: [ Form( key: _passwordKey, autovalidateMode: AutovalidateMode.onUserInteraction, child: PasswordInputField( controller: _passwordController, validator: InputValidators.validatePassword, - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, hintText: 'Password', @@ -68,10 +68,10 @@ class _NewWalletPasswordScreenState extends State { autovalidateMode: AutovalidateMode.onUserInteraction, child: PasswordInputField( controller: _confirmPasswordController, - validator: (value) => + validator: (String? value) => InputValidators.checkPasswordMatch( _passwordController.text, value,), - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, hintText: 'Confirm password', diff --git a/lib/screens/onboarding/new_wallet/new_wallet_seed_choice_screen.dart b/lib/screens/onboarding/new_wallet/new_wallet_seed_choice_screen.dart index 7ac63cd2..b5bfabff 100644 --- a/lib/screens/onboarding/new_wallet/new_wallet_seed_choice_screen.dart +++ b/lib/screens/onboarding/new_wallet/new_wallet_seed_choice_screen.dart @@ -46,7 +46,7 @@ class _NewWalletSeedChoiceScreenState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( - children: [ + children: [ const ProgressBar( currentLevel: 1, ), @@ -84,7 +84,7 @@ class _NewWalletSeedChoiceScreenState extends State { ), ), Column( - children: [ + children: [ _getConfirmSecureCheckboxContainer(), _getConfirmWrittenDownCheckbox(), ], @@ -143,7 +143,7 @@ class _NewWalletSeedChoiceScreenState extends State { Widget _getBackUpSeedContainer() { return Consumer>>( - builder: (_, exportedSeed, __) => Container( + builder: (_, ValueNotifier> exportedSeed, __) => Container( decoration: BoxDecoration( color: _isSeedExported(exportedSeed.value) ? AppColors.znnColor diff --git a/lib/screens/onboarding/wallet_success_screen.dart b/lib/screens/onboarding/wallet_success_screen.dart index 1b2b56db..b1341f85 100644 --- a/lib/screens/onboarding/wallet_success_screen.dart +++ b/lib/screens/onboarding/wallet_success_screen.dart @@ -33,7 +33,7 @@ class _WalletSuccessScreenState extends State { return Column( children: [ Column( - children: [ + children: [ ProgressBar( currentLevel: widget.progressBarNumLevels, numLevels: widget.progressBarNumLevels, diff --git a/lib/screens/project_details_screen.dart b/lib/screens/project_details_screen.dart index 95d91397..0cdb243b 100644 --- a/lib/screens/project_details_screen.dart +++ b/lib/screens/project_details_screen.dart @@ -34,10 +34,10 @@ class _ProjectDetailsScreenState extends State { bottom: 20, ), child: Column( - children: [ + children: [ Row( mainAxisAlignment: MainAxisAlignment.end, - children: [ + children: [ IconButton( splashRadius: 20, onPressed: () { @@ -68,7 +68,7 @@ class _ProjectDetailsScreenState extends State { RefreshProjectBloc refreshProjectViewModel, ) { return StandardFluidLayout( - children: [ + children: [ FluidCell( width: project.owner.toString() == kSelectedAddress! ? context.layout.value( @@ -115,12 +115,12 @@ class _ProjectDetailsScreenState extends State { Widget _getStreamBuilder() { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (RefreshProjectBloc model) { model.refreshProject(widget.project.id); }, - builder: (_, model, __) => StreamBuilder( + builder: (_, RefreshProjectBloc model, __) => StreamBuilder( stream: model.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } diff --git a/lib/screens/reset_wallet_screen.dart b/lib/screens/reset_wallet_screen.dart index e00735d4..83470a9c 100644 --- a/lib/screens/reset_wallet_screen.dart +++ b/lib/screens/reset_wallet_screen.dart @@ -20,7 +20,7 @@ class _ResetWalletScreenState extends State { Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Container( padding: const EdgeInsets.only( bottom: 10, diff --git a/lib/screens/splash_screen.dart b/lib/screens/splash_screen.dart index f7185685..87c32ca4 100644 --- a/lib/screens/splash_screen.dart +++ b/lib/screens/splash_screen.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; import 'package:logging/logging.dart'; import 'package:lottie/lottie.dart'; +import 'package:walletconnect_flutter_v2/apis/core/pairing/utils/pairing_models.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/model/model.dart'; @@ -42,8 +43,8 @@ class _SplashScreenState extends State { Widget build(BuildContext context) { return FutureBuilder( future: _composition, - builder: (context, snapshot) { - final composition = snapshot.data; + builder: (BuildContext context, AsyncSnapshot snapshot) { + final LottieComposition? composition = snapshot.data; if (composition != null) { Future.delayed(composition.duration, _splashInits); return Lottie( @@ -116,15 +117,15 @@ class _SplashScreenState extends State { await Hive.close(); await Future.forEach( kCacheBoxesToBeDeleted, - (boxName) async => Hive.deleteBoxFromDisk(boxName), + (String boxName) async => Hive.deleteBoxFromDisk(boxName), ); await _deleteWeb3Cache(); } Future _deleteWeb3Cache() async { try { - final web3WalletService = sl(); - for (final pairing in web3WalletService.pairings.value) { + final IWeb3WalletService web3WalletService = sl(); + for (final PairingInfo pairing in web3WalletService.pairings.value) { await web3WalletService.deactivatePairing(topic: pairing.topic); } } catch (e, stackTrace) { diff --git a/lib/screens/stepper_screen.dart b/lib/screens/stepper_screen.dart index 1c4dfb99..f06122d7 100644 --- a/lib/screens/stepper_screen.dart +++ b/lib/screens/stepper_screen.dart @@ -18,7 +18,7 @@ class StepperScreen extends StatelessWidget { margin: const EdgeInsets.all(20), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ + children: [ NotificationWidget( onSeeMorePressed: onStepperNotificationSeeMorePressed, ), @@ -32,14 +32,14 @@ class StepperScreen extends StatelessWidget { ), child: Stack( fit: StackFit.expand, - children: [ + children: [ stepper, Positioned( top: 0, right: 0, child: Row( mainAxisAlignment: MainAxisAlignment.end, - children: [ + children: [ RawMaterialButton( constraints: const BoxConstraints.tightForFinite(), materialTapTargetSize: diff --git a/lib/services/htlc_swaps_service.dart b/lib/services/htlc_swaps_service.dart index c54db80c..7a1b40ee 100644 --- a/lib/services/htlc_swaps_service.dart +++ b/lib/services/htlc_swaps_service.dart @@ -25,7 +25,7 @@ class HtlcSwapsService { _htlcSwapsBox = await Hive.openBox('${kHtlcSwapsBox}_$htlcSwapsBoxSuffix', encryptionCipher: HiveAesCipher(cipherKey),); if (newCipherKey != null) { - final values = _htlcSwapsBox!.toMap(); + final Map values = _htlcSwapsBox!.toMap(); await _htlcSwapsBox!.deleteFromDisk(); _htlcSwapsBox = await Hive.openBox( '${kHtlcSwapsBox}_$htlcSwapsBoxSuffix', @@ -41,7 +41,7 @@ class HtlcSwapsService { kLastCheckedHtlcBlockBox, encryptionCipher: HiveAesCipher(cipherKey),); if (newCipherKey != null) { - final values = _lastCheckedHtlcBlockHeightBox!.toMap(); + final Map values = _lastCheckedHtlcBlockHeightBox!.toMap(); await _lastCheckedHtlcBlockHeightBox!.deleteFromDisk(); _lastCheckedHtlcBlockHeightBox = await Hive.openBox( kLastCheckedHtlcBlockBox, @@ -70,14 +70,14 @@ class HtlcSwapsService { List getSwapsByState(List states) { return _swapsForCurrentChainId - .where((e) => states.contains(e.state)) + .where((HtlcSwap e) => states.contains(e.state)) .toList(); } HtlcSwap? getSwapByHashLock(String hashLock) { try { return _swapsForCurrentChainId - .firstWhereOrNull((e) => e.hashLock == hashLock); + .firstWhereOrNull((HtlcSwap e) => e.hashLock == hashLock); } on HiveError { return null; } @@ -86,7 +86,7 @@ class HtlcSwapsService { HtlcSwap? getSwapByHtlcId(String htlcId) { try { return _swapsForCurrentChainId.firstWhereOrNull( - (e) => e.initialHtlcId == htlcId || e.counterHtlcId == htlcId,); + (HtlcSwap e) => e.initialHtlcId == htlcId || e.counterHtlcId == htlcId,); } on HiveError { return null; } @@ -94,7 +94,7 @@ class HtlcSwapsService { HtlcSwap? getSwapById(String id) { try { - return _swapsForCurrentChainId.firstWhereOrNull((e) => e.id == id); + return _swapsForCurrentChainId.firstWhereOrNull((HtlcSwap e) => e.id == id); } on HiveError { return null; } @@ -121,12 +121,12 @@ class HtlcSwapsService { Future deleteInactiveSwaps() async => _htlcSwapsBox!.deleteAll(_swapsForCurrentChainId - .where((e) => [ + .where((HtlcSwap e) => [ P2pSwapState.completed, P2pSwapState.unsuccessful, P2pSwapState.error, ].contains(e.state),) - .map((e) => e.id),); + .map((HtlcSwap e) => e.id),); List get _swapsForCurrentChainId { return kNodeChainId != null @@ -135,21 +135,21 @@ class HtlcSwapsService { (e) => HtlcSwap.fromJson(jsonDecode(e)).chainId == kNodeChainId,) .map((e) => HtlcSwap.fromJson(jsonDecode(e))) .toList() - : []; + : []; } HtlcSwap? _getOldestPrunableSwap() { - final swaps = getAllSwaps() - .where((e) => [P2pSwapState.completed, P2pSwapState.unsuccessful] + final List swaps = getAllSwaps() + .where((HtlcSwap e) => [P2pSwapState.completed, P2pSwapState.unsuccessful] .contains(e.state),) .toList(); - swaps.sort((a, b) => b.startTime.compareTo(a.startTime)); + swaps.sort((HtlcSwap a, HtlcSwap b) => b.startTime.compareTo(a.startTime)); return swaps.isNotEmpty ? swaps.last : null; } Future _pruneSwapsHistoryIfNeeded() async { if (_htlcSwapsBox!.length > kMaxP2pSwapsToStore) { - final toBePruned = _getOldestPrunableSwap(); + final HtlcSwap? toBePruned = _getOldestPrunableSwap(); if (toBePruned != null) { await deleteSwap(toBePruned.id); } diff --git a/lib/services/web3wallet_service.dart b/lib/services/web3wallet_service.dart index e2873f39..6f1742bf 100644 --- a/lib/services/web3wallet_service.dart +++ b/lib/services/web3wallet_service.dart @@ -24,14 +24,14 @@ class Web3WalletService extends IWeb3WalletService { /// [SessionProposalEvent], [AuthRequest] @override ValueNotifier> pairings = - ValueNotifier>([]); + ValueNotifier>([]); @override ValueNotifier> sessions = - ValueNotifier>([]); + ValueNotifier>([]); @override - ValueNotifier> auth = ValueNotifier>([]); + ValueNotifier> auth = ValueNotifier>([]); - final List _idSessionsApproved = []; + final List _idSessionsApproved = []; @override void create() { @@ -44,7 +44,7 @@ class Web3WalletService extends IWeb3WalletService { name: 's y r i u s', description: 'A wallet for interacting with Zenon Network', url: 'https://zenon.network', - icons: [ + icons: [ 'https://raw.githubusercontent.com/zenon-network/syrius/master/macos/Runner/Assets.xcassets/AppIcon.appiconset/Icon-MacOS-512x512%402x.png', ], ), @@ -183,7 +183,7 @@ class Web3WalletService extends IWeb3WalletService { Future disconnectSessions() async { Logger('WalletConnectService') .log(Level.INFO, 'disconnectSessions triggered'); - for (var i = 0; i < pairings.value.length; i++) { + for (int i = 0; i < pairings.value.length; i++) { await _wcClient!.disconnectSession( topic: pairings.value[i].topic, reason: Errors.getSdkError(Errors.USER_DISCONNECTED),); @@ -291,7 +291,7 @@ class Web3WalletService extends IWeb3WalletService { Logger('WalletConnectService') .log(Level.INFO, '_onSessionProposal event', event.params.toJson()); - final dAppMetadata = event.params.proposer.metadata; + final PairingMetadata dAppMetadata = event.params.proposer.metadata; final actionWasAccepted = await showDialogWithNoAndYesOptions( context: globalNavigatorKey.currentContext!, @@ -299,7 +299,7 @@ class Web3WalletService extends IWeb3WalletService { title: 'Approve session', content: Column( mainAxisSize: MainAxisSize.min, - children: [ + children: [ Text('Are you sure you want to ' 'connect to ${dAppMetadata.name} ?'), kVerticalSpacing, @@ -313,7 +313,7 @@ class Web3WalletService extends IWeb3WalletService { kVerticalSpacing, Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text(dAppMetadata.url), LinkIcon( url: dAppMetadata.url, @@ -330,7 +330,7 @@ class Web3WalletService extends IWeb3WalletService { if (!_idSessionsApproved.contains(event.id)) { _idSessionsApproved.add(event.id); try { - final approveResponse = + final ApproveResponse approveResponse = await _approveSession(id: event.id); await _sendSuccessfullyApprovedSessionNotification(dAppMetadata); sessions.value.add(approveResponse.session); @@ -381,15 +381,15 @@ class Web3WalletService extends IWeb3WalletService { windowManager.show(); } namespaces = namespaces ?? - { + { 'zenon': Namespace( accounts: _getWalletAccounts(), - methods: [ + methods: [ 'znn_sign', 'znn_info', 'znn_send', ], - events: ['chainIdChange', 'addressChange'], + events: ['chainIdChange', 'addressChange'], ), }; return _wcClient!.approveSession( @@ -403,7 +403,7 @@ class Web3WalletService extends IWeb3WalletService { List _getWalletAccounts() => kAddressLabelMap.values .map( - (address) => _generateAccount(address, getChainIdentifier()), + (String address) => _generateAccount(address, getChainIdentifier()), ) .toList(); @@ -411,8 +411,8 @@ class Web3WalletService extends IWeb3WalletService { required String changeName, required String newValue, }) async { - final sessionTopics = - pairings.value.fold>([], (previousValue, pairing) { + final List sessionTopics = + pairings.value.fold>([], (List previousValue, PairingInfo pairing) { if (pairing.active) { previousValue.addAll(getSessionsForPairing(pairing.topic).keys); return previousValue; @@ -420,7 +420,7 @@ class Web3WalletService extends IWeb3WalletService { return previousValue; }); - for (final sessionTopic in sessionTopics) { + for (final String sessionTopic in sessionTopics) { _emitDAppEvent( sessionTopic: sessionTopic, changeName: changeName, diff --git a/lib/utils/account_block_utils.dart b/lib/utils/account_block_utils.dart index d90c277d..aac17c4c 100644 --- a/lib/utils/account_block_utils.dart +++ b/lib/utils/account_block_utils.dart @@ -15,24 +15,24 @@ class AccountBlockUtils { Address? address, bool waitForRequiredPlasma = false, }) async { - final syncInfo = await zenon!.stats.syncInfo(); - final nodeIsSynced = syncInfo.state == SyncState.syncDone || + final SyncInfo syncInfo = await zenon!.stats.syncInfo(); + final bool nodeIsSynced = syncInfo.state == SyncState.syncDone || (syncInfo.targetHeight > 0 && syncInfo.currentHeight > 0 && (syncInfo.targetHeight - syncInfo.currentHeight) < 20); if (nodeIsSynced) { // Acquire wallet lock to prevent concurrent access. - final wallet = await kWalletFile!.open(); + final Wallet wallet = await kWalletFile!.open(); try { address ??= Address.parse(kSelectedAddress!); - final walletAccount = await wallet + final WalletAccount walletAccount = await wallet .getAccount(kDefaultAddressList.indexOf(address.toString())); - final needPlasma = await zenon!.requiresPoW( + final bool needPlasma = await zenon!.requiresPoW( transactionParams, blockSigningKey: walletAccount, ); - final needReview = kWalletFile!.isHardwareWallet; + final bool needReview = kWalletFile!.isHardwareWallet; if (needPlasma) { await sl @@ -41,10 +41,10 @@ class AccountBlockUtils { } else if (needReview) { await _sendReviewNotification(transactionParams); } - final response = await zenon!.send( + final AccountBlockTemplate response = await zenon!.send( transactionParams, currentKeyPair: walletAccount, - generatingPowCallback: (status) async { + generatingPowCallback: (PowStatus status) async { // Wait for plasma to be generated before sending review notification if (needReview && status == PowStatus.done) { await _sendReviewNotification(transactionParams); @@ -89,15 +89,15 @@ class AccountBlockUtils { if (encodedData.length < AbiFunction.encodedSignLength) { return null; } - final eq = const ListEquality().equals; + final bool Function(List? list1, List? list2) eq = const ListEquality().equals; try { - for (final entry in abi.entries) { + for (final Entry entry in abi.entries) { if (eq(AbiFunction.extractSignature(entry.encodeSignature()), AbiFunction.extractSignature(encodedData),)) { - final decoded = + final List decoded = AbiFunction(entry.name!, entry.inputs!).decode(encodedData); - final params = {}; - for (var i = 0; i < entry.inputs!.length; i += 1) { + final Map params = {}; + for (int i = 0; i < entry.inputs!.length; i += 1) { params[entry.inputs![i].name!] = decoded[i]; } return BlockData(function: entry.name!, params: params); @@ -113,18 +113,18 @@ class AccountBlockUtils { // The list is returned in ascending order. static Future> getAccountBlocksAfterTime( Address address, int time,) async { - final blocks = []; - var pageIndex = 0; + final List blocks = []; + int pageIndex = 0; try { while (true) { - final fetched = await zenon!.ledger.getAccountBlocksByPage(address, + final AccountBlockList fetched = await zenon!.ledger.getAccountBlocksByPage(address, pageIndex: pageIndex, pageSize: 100,); - final lastBlockConfirmation = fetched.list!.last.confirmationDetail; + final AccountBlockConfirmationDetail? lastBlockConfirmation = fetched.list!.last.confirmationDetail; if (lastBlockConfirmation == null || lastBlockConfirmation.momentumTimestamp <= time) { - for (final block in fetched.list!) { - final confirmation = block.confirmationDetail; + for (final AccountBlock block in fetched.list!) { + final AccountBlockConfirmationDetail? confirmation = block.confirmationDetail; if (confirmation == null || confirmation.momentumTimestamp <= time) { break; @@ -152,7 +152,7 @@ class AccountBlockUtils { Address address, int height,) async { if (height >= 1) { try { - final block = + final AccountBlockList block = await zenon!.ledger.getAccountBlocksByHeight(address, height, 1); if (block.count != null && block.count! > 0) { return block.list?.first.confirmationDetail?.momentumTimestamp; diff --git a/lib/utils/address_utils.dart b/lib/utils/address_utils.dart index ea64d503..107a50c2 100644 --- a/lib/utils/address_utils.dart +++ b/lib/utils/address_utils.dart @@ -23,14 +23,14 @@ class ZenonAddressUtils { static Future generateNewAddress( {int numAddr = 1, VoidCallback? callback,}) async { - final wallet = await kWalletFile!.open(); + final Wallet wallet = await kWalletFile!.open(); try { await Future.delayed(const Duration(milliseconds: 500)); - final listAddr = []; - final addrListLength = kDefaultAddressList.length; - for (var i = 0; i < numAddr; i++) { - final addrListCounter = addrListLength + i; - final walletAccount = await wallet.getAccount(addrListCounter); + final List listAddr = []; + final int addrListLength = kDefaultAddressList.length; + for (int i = 0; i < numAddr; i++) { + final int addrListCounter = addrListLength + i; + final WalletAccount walletAccount = await wallet.getAccount(addrListCounter); Address? address; if (walletAccount is LedgerWalletAccount) { await sl.get().addNotification( @@ -48,10 +48,10 @@ class ZenonAddressUtils { address = await walletAccount.getAddress(); } listAddr.add(address); - final addressesBox = Hive.box(kAddressesBox); + final Box addressesBox = Hive.box(kAddressesBox); await addressesBox.add(listAddr.elementAt(i).toString()); _initAddresses(addressesBox); - final addressLabelsBox = Hive.box(kAddressLabelsBox); + final Box addressLabelsBox = Hive.box(kAddressLabelsBox); await addressLabelsBox.put( listAddr.elementAt(i).toString(), 'Address ${kDefaultAddressList.length}', @@ -70,10 +70,10 @@ class ZenonAddressUtils { } static Future setAddressLabels() async { - final addressLabelsBox = await Hive.openBox(kAddressLabelsBox); + final Box addressLabelsBox = await Hive.openBox(kAddressLabelsBox); if (addressLabelsBox.isEmpty) { - for (final address in kDefaultAddressList) { + for (final String? address in kDefaultAddressList) { await addressLabelsBox.put( address, 'Address ${kDefaultAddressList.indexOf(address) + 1}',); } @@ -92,13 +92,13 @@ class ZenonAddressUtils { } static Future setAddresses(WalletFile? walletFile) async { - final addressesBox = await Hive.openBox(kAddressesBox); + final Box addressesBox = await Hive.openBox(kAddressesBox); if (addressesBox.isEmpty) { - await walletFile!.access((wallet) async { - for (final element in await Future.wait( + await walletFile!.access((Wallet wallet) async { + for (final String element in await Future.wait( List>.generate( kNumOfInitialAddresses, - (index) async => + (int index) async => (await (await wallet.getAccount(index)).getAddress()) .toString(),), )) { @@ -114,8 +114,8 @@ class ZenonAddressUtils { static void _initAddressLabels(Box box) => kAddressLabelMap = box.keys.toList().fold>( - {}, - (previousValue, key) { + {}, + (Map previousValue, key) { previousValue[key] = box.get(key); return previousValue; }, diff --git a/lib/utils/app_colors.dart b/lib/utils/app_colors.dart index 6a25012e..ea0175f3 100644 --- a/lib/utils/app_colors.dart +++ b/lib/utils/app_colors.dart @@ -1,43 +1,43 @@ import 'package:flutter/material.dart'; class AppColors { - static const znnColor = Color(0xFF4FD166); - static const qsrColor = Color(0xFF005FE3); - static const ztsColor = Color(0xFFF91690); + static const Color znnColor = Color(0xFF4FD166); + static const Color qsrColor = Color(0xFF005FE3); + static const Color ztsColor = Color(0xFFF91690); - static const errorColor = Color.fromRGBO(244, 4, 88, 1); + static const Color errorColor = Color.fromRGBO(244, 4, 88, 1); - static const backgroundLight = Color(0xFFEAEAEA); - static const backgroundDark = Color(0xFF1E1E1E); + static const Color backgroundLight = Color(0xFFEAEAEA); + static const Color backgroundDark = Color(0xFF1E1E1E); - static const subtitleColor = Color(0xFFB3B3B3); + static const Color subtitleColor = Color(0xFFB3B3B3); - static const maxAmountBorder = Color(0xFF474747); + static const Color maxAmountBorder = Color(0xFF474747); - static const lightSecondary = Color(0xFFB3B3B3); - static const lightSecondaryContainer = Color(0xFF545454); - static const darkSecondary = Color(0xFF3F3F3F); - static const darkSecondaryContainer = Color.fromRGBO(46, 46, 46, 1); + static const Color lightSecondary = Color(0xFFB3B3B3); + static const Color lightSecondaryContainer = Color(0xFF545454); + static const Color darkSecondary = Color(0xFF3F3F3F); + static const Color darkSecondaryContainer = Color.fromRGBO(46, 46, 46, 1); - static const alertNotification = Color(0xFFDAE240); + static const Color alertNotification = Color(0xFFDAE240); - static const accessWalletContainersGray = Color.fromRGBO(46, 46, 46, 1); - static const inactiveIconsGray = Color.fromRGBO(51, 51, 51, 1); + static const Color accessWalletContainersGray = Color.fromRGBO(46, 46, 46, 1); + static const Color inactiveIconsGray = Color.fromRGBO(51, 51, 51, 1); - static const darkPrimary = Color(0xFF262626); - static const darkPrimaryContainer = Color(0xFF2D2D2D); - static const lightPrimaryContainer = Color(0xFFF4FEFF); + static const Color darkPrimary = Color(0xFF262626); + static const Color darkPrimaryContainer = Color(0xFF2D2D2D); + static const Color lightPrimaryContainer = Color(0xFFF4FEFF); - static const lightDividerColor = Color.fromRGBO(193, 193, 193, 0.8); - static const darkDividerColor = Color(0xFF333333); + static const Color lightDividerColor = Color.fromRGBO(193, 193, 193, 0.8); + static const Color darkDividerColor = Color(0xFF333333); - static const lightTextFormFieldFill = Color(0xFFE4E4E4); - static const darkTextFormFieldFill = Color.fromRGBO(51, 51, 51, 1); + static const Color lightTextFormFieldFill = Color(0xFFE4E4E4); + static const Color darkTextFormFieldFill = Color.fromRGBO(51, 51, 51, 1); - static const darkHintTextColor = Color.fromRGBO(99, 99, 99, 1); - static const lightHintTextColor = Color.fromRGBO(179, 179, 179, 1); + static const Color darkHintTextColor = Color.fromRGBO(99, 99, 99, 1); + static const Color lightHintTextColor = Color.fromRGBO(179, 179, 179, 1); - static const seedUnderlineBorderColor = Color.fromRGBO(99, 99, 99, 1); - static const unselectedSeedChoiceColor = Color(0xFF636363); - static const selectedSeedChoiceColor = Color(0xFF292929); + static const Color seedUnderlineBorderColor = Color.fromRGBO(99, 99, 99, 1); + static const Color unselectedSeedChoiceColor = Color(0xFF636363); + static const Color selectedSeedChoiceColor = Color(0xFF292929); } diff --git a/lib/utils/app_theme.dart b/lib/utils/app_theme.dart index 75337d97..87b00e36 100644 --- a/lib/utils/app_theme.dart +++ b/lib/utils/app_theme.dart @@ -126,7 +126,7 @@ class AppTheme { outlinedButtonTheme: OutlinedButtonThemeData( style: kOutlinedButtonStyle.copyWith( foregroundColor: WidgetStateProperty.resolveWith( - (states) { + (Set states) { if (states.contains(WidgetState.disabled)) { return Colors.black38; } @@ -263,7 +263,7 @@ class AppTheme { outlinedButtonTheme: OutlinedButtonThemeData( style: kOutlinedButtonStyle.copyWith( foregroundColor: WidgetStateProperty.resolveWith( - (states) { + (Set states) { if (states.contains(WidgetState.disabled)) { return Colors.white38; } diff --git a/lib/utils/clipboard_utils.dart b/lib/utils/clipboard_utils.dart index c7a74a51..38e26565 100644 --- a/lib/utils/clipboard_utils.dart +++ b/lib/utils/clipboard_utils.dart @@ -29,7 +29,7 @@ class ClipboardUtils { static void pasteToClipboard( BuildContext context, Function(String) callback,) { - Clipboard.getData('text/plain').then((value) async { + Clipboard.getData('text/plain').then((ClipboardData? value) async { if (value != null) { callback(value.text!); } else { diff --git a/lib/utils/color_utils.dart b/lib/utils/color_utils.dart index 1a1941cf..e9443ac2 100644 --- a/lib/utils/color_utils.dart +++ b/lib/utils/color_utils.dart @@ -15,7 +15,7 @@ class ColorUtils { } static String _getHexCodeFromTokenZts(TokenStandard tokenStandard) { - final bytes = + final List bytes = tokenStandard.getBytes().sublist(tokenStandard.getBytes().length - 3); return BytesUtils.bytesToHex(bytes); } diff --git a/lib/utils/constants.dart b/lib/utils/constants.dart index 2be2a27b..30b2ec59 100644 --- a/lib/utils/constants.dart +++ b/lib/utils/constants.dart @@ -6,7 +6,7 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; // WalletConnect const String kWcProjectId = '6106aa8c2f308b338f31465bef999a1f'; const String kZenonNameSpace = 'zenon'; -const walletConnectDirName = 'walletconnect'; +const String walletConnectDirName = 'walletconnect'; // Dimensions const double kAmountSuffixHeight = 25; @@ -42,7 +42,7 @@ const String kKeyStoreBox = 'key_store_box'; const String kHtlcSwapsBox = 'htlc_swaps_box'; const String kLastCheckedHtlcBlockBox = 'last_checked_htlc_block_box'; -const List kCacheBoxesToBeDeleted = [ +const List kCacheBoxesToBeDeleted = [ kFavoriteTokensBox, kAddressesBox, kAddressLabelsBox, @@ -108,12 +108,12 @@ const int kAmountInputMaxCharacterLength = 21; const int kSecondsPerMomentum = 10; const int kMaxP2pSwapsToStore = 500; -const List kNormalUsersPlasmaRequirements = [ +const List kNormalUsersPlasmaRequirements = [ kStakePlasmaAmountNeeded, kDelegatePlasmaAmountNeeded, ]; -const List kPowerUsersPlasmaRequirements = [ +const List kPowerUsersPlasmaRequirements = [ kPillarPlasmaAmountNeeded, kSentinelPlasmaAmountNeeded, kIssueTokenPlasmaAmountNeeded, @@ -123,7 +123,7 @@ const String kEmbeddedNode = 'Embedded Node'; const String kLocalhostDefaultNodeUrl = 'ws://127.0.0.1:$kDefaultPort'; const int kDefaultPort = 35998; -const List kWalletActions = [ +const List kWalletActions = [ 'pillar', 'sentinel', 'delegation', @@ -188,7 +188,7 @@ const String kThemeModeKey = 'theme_mode_key'; const ThemeMode kDefaultThemeMode = ThemeMode.dark; const TextScaling kDefaultTextScaling = TextScaling.system; -const kBlockTypeColorMap = { +const Map kBlockTypeColorMap = { BlockTypeEnum.userReceive: AppColors.darkHintTextColor, BlockTypeEnum.userSend: AppColors.lightHintTextColor, }; @@ -202,7 +202,7 @@ const Duration kEmbeddedConnectionDelay = Duration(seconds: 30); const Duration kDashboardRefreshInterval = Duration(minutes: 1); // Tabs -const List kTabsWithTextTitles = [ +const List kTabsWithTextTitles = [ Tabs.dashboard, Tabs.transfer, Tabs.pillars, diff --git a/lib/utils/device_utils.dart b/lib/utils/device_utils.dart index 6ef786ca..f1192f7d 100644 --- a/lib/utils/device_utils.dart +++ b/lib/utils/device_utils.dart @@ -6,7 +6,7 @@ import 'package:package_info_plus/package_info_plus.dart'; class DeviceUtils { static Future> getDeviceInfo() async { - final deviceInfoPlugin = DeviceInfoPlugin(); + final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin(); if (Platform.isLinux) { return _readLinuxDeviceInfo(await deviceInfoPlugin.linuxInfo); } @@ -16,7 +16,7 @@ class DeviceUtils { if (Platform.isMacOS) { return _readMacOsDeviceInfo(await deviceInfoPlugin.macOsInfo); } - return {'info': 'device not supported'}; + return {'info': 'device not supported'}; } static Map _readLinuxDeviceInfo(LinuxDeviceInfo data) { @@ -58,8 +58,8 @@ class DeviceUtils { } static Future> getPackageInfo() async { - final packageInfo = await PackageInfo.fromPlatform(); - return { + final PackageInfo packageInfo = await PackageInfo.fromPlatform(); + return { 'appName': packageInfo.appName, 'packageName': packageInfo.packageName, 'appVersion': packageInfo.version, @@ -68,9 +68,9 @@ class DeviceUtils { } static Future> getGitInfo() async { - final head = await rootBundle.loadString('.git/HEAD'); - final branchName = head.split('/').last; - final commitHash = await rootBundle.loadString('.git/ORIG_HEAD'); - return {'branchName': branchName, 'commitHash': commitHash}; + final String head = await rootBundle.loadString('.git/HEAD'); + final String branchName = head.split('/').last; + final String commitHash = await rootBundle.loadString('.git/ORIG_HEAD'); + return {'branchName': branchName, 'commitHash': commitHash}; } } diff --git a/lib/utils/extensions.dart b/lib/utils/extensions.dart index 8efa8afe..b0140d64 100644 --- a/lib/utils/extensions.dart +++ b/lib/utils/extensions.dart @@ -16,7 +16,7 @@ extension StringExtensions on String { } return BigInt.parse(this + ''.padRight(decimals, '0')); } - final parts = split('.'); + final List parts = split('.'); return BigInt.parse(parts[0] + (parts[1].length > decimals @@ -48,8 +48,8 @@ extension ZipTwoLists on List { List zip(List smallerList) { return fold( [], - (previousValue, element) { - final elementIndex = indexOf(element); + (List previousValue, element) { + final int elementIndex = indexOf(element); previousValue.add(element); if (elementIndex < smallerList.length) { previousValue.add( @@ -64,7 +64,7 @@ extension ZipTwoLists on List { extension ShortString on String { String get short { - final longString = this; + final String longString = this; return '${longString.substring(0, 6)}...' '${longString.substring(longString.length - 6)}'; } @@ -73,7 +73,7 @@ extension ShortString on String { extension LedgerErrorExtensions on LedgerError { String toFriendlyString() { return when( - connectionError: (origMessage) => origMessage, + connectionError: (String origMessage) => origMessage, responseError: _mapStatusWord,); } diff --git a/lib/utils/file_utils.dart b/lib/utils/file_utils.dart index b9a93c84..14c7a3b5 100644 --- a/lib/utils/file_utils.dart +++ b/lib/utils/file_utils.dart @@ -3,7 +3,7 @@ import 'dart:io'; class FileUtils { static Future deleteFile(String path) async { try { - final file = File(path); + final File file = File(path); if (file.existsSync()) { await file.delete(); } else { @@ -16,7 +16,7 @@ class FileUtils { static Future deleteDirectory(String path) async { try { - final directory = Directory(path); + final Directory directory = Directory(path); if (directory.existsSync()) { await directory.delete(recursive: true); } else { diff --git a/lib/utils/format_utils.dart b/lib/utils/format_utils.dart index 638f803c..e6dbae36 100644 --- a/lib/utils/format_utils.dart +++ b/lib/utils/format_utils.dart @@ -8,7 +8,7 @@ class FormatUtils { static List getAmountTextInputFormatters( String replacementString, ) => - [ + [ FilteringTextInputFormatter.allow(RegExp(r'^\d*\.?\d*?$'), replacementString: replacementString,), FilteringTextInputFormatter.deny( @@ -20,7 +20,7 @@ class FormatUtils { static List getPlasmaAmountTextInputFormatters( String replacementString, ) => - [ + [ FilteringTextInputFormatter.digitsOnly, FilteringTextInputFormatter.deny( RegExp(r'^0\d+'), @@ -33,16 +33,16 @@ class FormatUtils { static String formatDate(int timestampMillis, {String dateFormat = kDefaultDateFormat,}) { - final date = DateTime.fromMillisecondsSinceEpoch(timestampMillis); + final DateTime date = DateTime.fromMillisecondsSinceEpoch(timestampMillis); return DateFormat(dateFormat).format(date); } static String extractNameFromEnum(T enumValue) { - final valueName = enumValue.toString().split('.')[1]; + final String valueName = enumValue.toString().split('.')[1]; if (RegExp('^[a-z]+[A-Z]+').hasMatch(valueName)) { - final parts = valueName + final List parts = valueName .split(RegExp('(?<=[a-z])(?=[A-Z])')) - .map((e) => e.toLowerCase()) + .map((String e) => e.toLowerCase()) .toList(); parts.first = parts.first.capitalize(); return parts.join(' '); @@ -61,7 +61,7 @@ class FormatUtils { } static String formatData(int transactionMillis) { - final currentMillis = DateTime.now().millisecondsSinceEpoch; + final int currentMillis = DateTime.now().millisecondsSinceEpoch; if (currentMillis - transactionMillis <= const Duration(days: 1).inMilliseconds) { return formatDataShort(currentMillis - transactionMillis); @@ -70,7 +70,7 @@ class FormatUtils { } static String formatDataShort(int i) { - final duration = Duration(milliseconds: i); + final Duration duration = Duration(milliseconds: i); if (duration.inHours > 0) { return '${duration.inHours} h ago'; } diff --git a/lib/utils/functions.dart b/lib/utils/functions.dart index e3d8cb52..6209a165 100644 --- a/lib/utils/functions.dart +++ b/lib/utils/functions.dart @@ -12,12 +12,12 @@ class Signature { } Future walletSign(List message) async { - final wallet = await kWalletFile!.open(); + final Wallet wallet = await kWalletFile!.open(); try { - final walletAccount = await wallet + final WalletAccount walletAccount = await wallet .getAccount(kDefaultAddressList.indexOf(kSelectedAddress)); - final publicKey = await walletAccount.getPublicKey(); - final signature = await walletAccount.sign( + final List publicKey = await walletAccount.getPublicKey(); + final List signature = await walletAccount.sign( Uint8List.fromList( message, ), @@ -30,6 +30,6 @@ Future walletSign(List message) async { } Future loadJsonFromAssets(String filePath) async { - final jsonString = await rootBundle.loadString(filePath); + final String jsonString = await rootBundle.loadString(filePath); return jsonDecode(jsonString); } \ No newline at end of file diff --git a/lib/utils/global.dart b/lib/utils/global.dart index 467d5999..5b82cc6d 100644 --- a/lib/utils/global.dart +++ b/lib/utils/global.dart @@ -20,14 +20,14 @@ bool kWalletInitCompleted = false; WalletFile? kWalletFile; -List kDbNodes = []; -List kDefaultAddressList = []; +List kDbNodes = []; +List kDefaultAddressList = []; -Map kAddressLabelMap = {}; +Map kAddressLabelMap = {}; Tabs? kCurrentPage; -final List kTabs = [...kTabsWithTextTitles, ...kTabsWithIconTitles]; +final List kTabs = [...kTabsWithTextTitles, ...kTabsWithIconTitles]; WalletNotification? kLastNotification; WalletNotification? kLastDismissedNotification; @@ -36,7 +36,7 @@ int? kNumOfPillars; bool kEmbeddedNodeRunning = false; -final List kTabsWithIconTitles = [ +final List kTabsWithIconTitles = [ if (kWcProjectId.isNotEmpty) Tabs.walletConnect, Tabs.accelerator, Tabs.help, @@ -47,15 +47,15 @@ final List kTabsWithIconTitles = [ Tabs.lock, ]; -final List kDisabledTabs = [ +final List kDisabledTabs = [ Tabs.generation, Tabs.sync, ]; -List kDefaultNodes = [ +List kDefaultNodes = [ kEmbeddedNode, kLocalhostDefaultNodeUrl, ]; // Community supplied public rpc nodes -List kDefaultCommunityNodes = []; \ No newline at end of file +List kDefaultCommunityNodes = []; \ No newline at end of file diff --git a/lib/utils/init_utils.dart b/lib/utils/init_utils.dart index 6287b1e2..937d7119 100644 --- a/lib/utils/init_utils.dart +++ b/lib/utils/init_utils.dart @@ -69,7 +69,7 @@ class InitUtils { ); static Future initWalletAfterDecryption(List cipherKey) async { - final walletVersion = Version.parse(sharedPrefsService! + final Version walletVersion = Version.parse(sharedPrefsService! .get(kWalletVersionKey, defaultValue: kWalletVersion),); await ZenonAddressUtils.setAddresses(kWalletFile); await ZenonAddressUtils.setAddressLabels(); diff --git a/lib/utils/input_validators.dart b/lib/utils/input_validators.dart index 96a34a55..3d36e651 100644 --- a/lib/utils/input_validators.dart +++ b/lib/utils/input_validators.dart @@ -90,7 +90,7 @@ class InputValidators { } } - final inputNum = value.extractDecimals(decimals); + final BigInt inputNum = value.extractDecimals(decimals); if (value.contains('.') && value.split('.')[1].length > decimals) { return 'Inputted number has too many decimals'; @@ -142,9 +142,9 @@ class InputValidators { if (value.length < 8) { return 'Password not strong enough'; } - const pattern = + const String pattern = r'''^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[`~!@#$%^&*()\-_=+\[\]\{\}\\|;:",<.>\/\?']).{8,}$'''; - final regExp = RegExp(pattern); + final RegExp regExp = RegExp(pattern); if (regExp.hasMatch(value)) { return null; } @@ -207,7 +207,7 @@ class InputValidators { static Future checkSecret(HtlcInfo htlc, String? value) async { if (value != null) { try { - final preimageCheck = htlc.hashType == htlcHashTypeSha3 + final Hash preimageCheck = htlc.hashType == htlcHashTypeSha3 ? Hash.digest(hex.decode(value)) : Hash.fromBytes(await Crypto.sha256Bytes(hex.decode(value))); diff --git a/lib/utils/navigation_utils.dart b/lib/utils/navigation_utils.dart index 02bb8952..59986014 100644 --- a/lib/utils/navigation_utils.dart +++ b/lib/utils/navigation_utils.dart @@ -10,7 +10,7 @@ class NavigationUtils { if (!RegExp('^http').hasMatch(url)) { url = 'http://$url'; } - final uri = Uri.parse(url); + final Uri uri = Uri.parse(url); if (await canLaunchUrl(uri)) { await launchUrl(uri); } else { @@ -46,7 +46,7 @@ class NavigationUtils { } static void popRepeated(context, int times) { - var count = 0; - Navigator.popUntil(context, (route) => count++ == times); + int count = 0; + Navigator.popUntil(context, (Route route) => count++ == times); } } diff --git a/lib/utils/network_utils.dart b/lib/utils/network_utils.dart index 7ab07a7a..e65518a8 100644 --- a/lib/utils/network_utils.dart +++ b/lib/utils/network_utils.dart @@ -3,22 +3,22 @@ import 'dart:io'; class NetworkUtils { static Future getLocalIpAddress( InternetAddressType internetAddressType,) async { - final interfaces = await NetworkInterface.list( + final List interfaces = await NetworkInterface.list( type: internetAddressType, includeLinkLocal: true,); try { - final vpnInterface = - interfaces.firstWhere((element) => element.name == 'tun0'); + final NetworkInterface vpnInterface = + interfaces.firstWhere((NetworkInterface element) => element.name == 'tun0'); return vpnInterface.addresses.first.address; } on StateError { try { - final interface = - interfaces.firstWhere((element) => element.name == 'wlan0'); + final NetworkInterface interface = + interfaces.firstWhere((NetworkInterface element) => element.name == 'wlan0'); return interface.addresses.first.address; } catch (e) { try { - final interface = interfaces.firstWhere((element) => + final NetworkInterface interface = interfaces.firstWhere((NetworkInterface element) => !(element.name == 'tun0' || element.name == 'wlan0'),); return interface.addresses.first.address; } catch (e) { diff --git a/lib/utils/node_utils.dart b/lib/utils/node_utils.dart index e6f54e6c..d3a1cb2c 100644 --- a/lib/utils/node_utils.dart +++ b/lib/utils/node_utils.dart @@ -18,7 +18,7 @@ int _kHeight = 0; class NodeUtils { static Future establishConnectionToNode(String url) async { - final connectionStatus = await zenon!.wsClient.initialize( + final bool connectionStatus = await zenon!.wsClient.initialize( url, retry: false, ); @@ -26,9 +26,9 @@ class NodeUtils { } static Future getNodeChainIdentifier() async { - var nodeChainId = 1; + int nodeChainId = 1; try { - await zenon!.ledger.getFrontierMomentum().then((value) { + await zenon!.ledger.getFrontierMomentum().then((Momentum value) { nodeChainId = value.chainIdentifier; }); } catch (e, stackTrace) { @@ -58,7 +58,7 @@ class NodeUtils { ); // If the message is null, it means that the isolate has closed - final embeddedStoppedCompleter = Completer(); + final Completer embeddedStoppedCompleter = Completer(); sl(instanceName: 'embeddedStoppedStream').listen( (message) { kEmbeddedNodeRunning = false; @@ -84,10 +84,10 @@ class NodeUtils { static initWebSocketClient() async { addOnWebSocketConnectedCallback(); - final url = kCurrentNode == kEmbeddedNode + final String url = kCurrentNode == kEmbeddedNode ? kLocalhostDefaultNodeUrl : kCurrentNode ?? ''; - var connected = false; + bool connected = false; try { connected = await establishConnectionToNode(url); } catch (_) {} @@ -100,7 +100,7 @@ class NodeUtils { static Future addOnWebSocketConnectedCallback() async { zenon!.wsClient - .addOnConnectionEstablishedCallback((allResponseBroadcaster) async { + .addOnConnectionEstablishedCallback((Stream?> allResponseBroadcaster) async { kNodeChainId = await getNodeChainIdentifier(); await _getSubscriptionForMomentums(); await _getSubscriptionForAllAccountEvents(); @@ -116,7 +116,7 @@ class NodeUtils { static Future getUnreceivedTransactions() async { await Future.forEach( kDefaultAddressList, - (address) async => getUnreceivedTransactionsByAddress( + (String? address) async => getUnreceivedTransactionsByAddress( Address.parse(address!), ), ); @@ -125,14 +125,14 @@ class NodeUtils { static Future getUnreceivedTransactionsByAddress( Address address, ) async { - final unreceivedBlocks = + final List unreceivedBlocks = (await zenon!.ledger.getUnreceivedBlocksByAddress( address, )) .list!; if (unreceivedBlocks.isNotEmpty) { - for (final unreceivedBlock in unreceivedBlocks) { + for (final AccountBlock unreceivedBlock in unreceivedBlocks) { if (sharedPrefsService!.get( kAutoReceiveKey, defaultValue: kAutoReceiveDefaultValue, @@ -145,17 +145,17 @@ class NodeUtils { static Future checkForLocalTimeDiscrepancy( String warningMessage,) async { - const maxAllowedDiscrepancy = Duration(minutes: 5); + const Duration maxAllowedDiscrepancy = Duration(minutes: 5); try { - final syncInfo = await zenon!.stats.syncInfo(); - final nodeIsSynced = syncInfo.state == SyncState.syncDone || + final SyncInfo syncInfo = await zenon!.stats.syncInfo(); + final bool nodeIsSynced = syncInfo.state == SyncState.syncDone || (syncInfo.targetHeight > 0 && syncInfo.currentHeight > 0 && (syncInfo.targetHeight - syncInfo.currentHeight) < 20); if (nodeIsSynced) { - final frontierTime = + final int frontierTime = (await zenon!.ledger.getFrontierMomentum()).timestamp; - final timeDifference = (frontierTime - DateTimeUtils.unixTimeNow).abs(); + final int timeDifference = (frontierTime - DateTimeUtils.unixTimeNow).abs(); if (timeDifference > maxAllowedDiscrepancy.inSeconds) { await NotificationUtils.sendNotificationError( Exception('Local time discrepancy detected.'), @@ -177,11 +177,11 @@ class NodeUtils { event['method'] == 'ledger.subscription' && sharedPrefsService! .get(kAutoReceiveKey, defaultValue: kAutoReceiveDefaultValue)) { - for (var i = 0; i < event['params']['result'].length; i += 1) { + for (int i = 0; i < event['params']['result'].length; i += 1) { final tx = event['params']['result'][i]; if (tx.containsKey('toAddress') && kDefaultAddressList.contains(tx['toAddress'])) { - final hash = Hash.parse(tx['hash']); + final Hash hash = Hash.parse(tx['hash']); sl().addHash(hash); } } @@ -211,14 +211,14 @@ class NodeUtils { if (!Hive.isBoxOpen(kNodesBox)) { await Hive.openBox(kNodesBox); } - final nodesBox = Hive.box(kNodesBox); + final Box nodesBox = Hive.box(kNodesBox); if (kDbNodes.isNotEmpty) { kDbNodes.clear(); } kDbNodes.addAll(nodesBox.values); // Handle the case in which some default nodes were deleted // so they can't be found in the cache - final currentNode = kCurrentNode; + final String? currentNode = kCurrentNode; if (currentNode != null && !kDefaultNodes.contains(currentNode) && !kDbNodes.contains(currentNode)) { @@ -232,7 +232,7 @@ class NodeUtils { if (savedNode == kEmbeddedNode) { // First we need to check if the node is not already running - final isConnectionEstablished = + final bool isConnectionEstablished = await NodeUtils.establishConnectionToNode(kLocalhostDefaultNodeUrl); if (isConnectionEstablished == false) { // Acquire WakeLock @@ -240,7 +240,7 @@ class NodeUtils { WakelockPlus.enable(); } // Initialize local full node - await Isolate.spawn(EmbeddedNode.runNode, [''], + await Isolate.spawn(EmbeddedNode.runNode, [''], onExit: sl(instanceName: 'embeddedStoppedPort').sendPort,); diff --git a/lib/utils/notification_utils.dart b/lib/utils/notification_utils.dart index 8f81afcd..50e0ba3e 100644 --- a/lib/utils/notification_utils.dart +++ b/lib/utils/notification_utils.dart @@ -3,6 +3,7 @@ import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; +import 'package:znn_sdk_dart/src/model/stats.dart'; class NotificationUtils { static Future sendNotificationError( @@ -22,7 +23,7 @@ class NotificationUtils { kLastNotification?.timestamp != kLastDismissedNotification?.timestamp; static Future sendNodeSyncingNotification() async { - final syncInfo = await zenon!.stats.syncInfo(); + final SyncInfo syncInfo = await zenon!.stats.syncInfo(); if (syncInfo.targetHeight == 0 || syncInfo.currentHeight == 0 || (syncInfo.targetHeight - syncInfo.currentHeight) > 20) { diff --git a/lib/utils/toast_utils.dart b/lib/utils/toast_utils.dart index b861d6b2..725c0629 100644 --- a/lib/utils/toast_utils.dart +++ b/lib/utils/toast_utils.dart @@ -7,7 +7,7 @@ class ToastUtils { static void showToast(BuildContext context, String message, {Color? color}) { if (_timer == null || !_timer!.isActive) { - final overlay = _getOverlayEntry(message, color); + final OverlayEntry overlay = _getOverlayEntry(message, color); Overlay.of(context).insert(overlay); _timer = Timer(const Duration(seconds: 3), overlay.remove); } diff --git a/lib/utils/wallet_file.dart b/lib/utils/wallet_file.dart index f3d5e5d7..c65792b7 100644 --- a/lib/utils/wallet_file.dart +++ b/lib/utils/wallet_file.dart @@ -13,7 +13,7 @@ abstract class WalletFile { final String _path; static Future decrypt(String walletPath, String password) async { - final encrypted = await WalletFile.read(walletPath); + final EncryptedFile encrypted = await WalletFile.read(walletPath); final walletType = encrypted.metadata != null ? encrypted.metadata![walletTypeKey] : null; if (walletType == null || walletType == keyStoreWalletType) { @@ -27,7 +27,7 @@ abstract class WalletFile { } static Future read(String walletPath) async { - final file = File(walletPath); + final File file = File(walletPath); if (!file.existsSync()) { throw WalletException('Given wallet path does not exist ($walletPath)'); } @@ -36,8 +36,8 @@ abstract class WalletFile { static Future write(String walletPath, String password, List data, {Map? metadata,}) async { - final file = File(walletPath); - final encrypted = + final File file = File(walletPath); + final EncryptedFile encrypted = await EncryptedFile.encrypt(data, password, metadata: metadata); file.writeAsString(json.encode(encrypted), mode: FileMode.writeOnly); } @@ -55,7 +55,7 @@ abstract class WalletFile { void close(); Future access(Future Function(Wallet) accessSection) async { - final wallet = await open(); + final Wallet wallet = await open(); try { return await accessSection(wallet); } finally { @@ -65,8 +65,8 @@ abstract class WalletFile { Future changePassword( String currentPassword, String newPassword,) async { - final file = await WalletFile.read(walletPath); - final decrypted = await file.decrypt(currentPassword); + final EncryptedFile file = await WalletFile.read(walletPath); + final List decrypted = await file.decrypt(currentPassword); await WalletFile.write(walletPath, newPassword, decrypted, metadata: file.metadata,); } @@ -84,8 +84,8 @@ class KeyStoreWalletFile extends WalletFile { static Future create(String mnemonic, String password, {String? name,}) async { - final wallet = KeyStore.fromMnemonic(mnemonic); - final walletDefinition = + final KeyStore wallet = KeyStore.fromMnemonic(mnemonic); + final KeyStoreDefinition walletDefinition = await keyStoreWalletManager.saveKeyStore(wallet, password, name: name); return KeyStoreWalletFile._internal( walletDefinition.walletId, wallet.entropy,); @@ -93,14 +93,14 @@ class KeyStoreWalletFile extends WalletFile { static Future decrypt( String walletPath, String password,) async { - final encrypted = await WalletFile.read(walletPath); + final EncryptedFile encrypted = await WalletFile.read(walletPath); if (encrypted.metadata != null && encrypted.metadata![walletTypeKey] != null && encrypted.metadata![walletTypeKey] != keyStoreWalletType) { throw WalletException( 'Wallet type (${encrypted.metadata![walletTypeKey]}) is not supported',); } - final decrypted = await encrypted.decrypt(password); + final List decrypted = await encrypted.decrypt(password); return KeyStoreWalletFile._internal(walletPath, HEX.encode(decrypted)); } @@ -141,7 +141,7 @@ class LedgerWalletFile extends WalletFile { static final LedgerWalletManager ledgerWalletManager = LedgerWalletManager(); static Future _connect(String walletIdOrName) async { - for (final walletDefinition + for (final WalletDefinition walletDefinition in await ledgerWalletManager.getWalletDefinitions()) { if (walletDefinition.walletId == walletIdOrName || walletDefinition.walletName == walletIdOrName) { @@ -156,13 +156,13 @@ class LedgerWalletFile extends WalletFile { static Future create(String walletId, String password, {String? walletName,}) async { - final wallet = await _connect(walletId); + final LedgerWallet wallet = await _connect(walletId); try { - final baseAddress = await (await wallet.getAccount()).getAddress(); + final Address baseAddress = await (await wallet.getAccount()).getAddress(); walletName ??= baseAddress.toString(); - final walletPath = path.join(znnDefaultWalletDirectory.path, walletName); + final String walletPath = path.join(znnDefaultWalletDirectory.path, walletName); await WalletFile.write(walletPath, password, utf8.encode(walletName), - metadata: { + metadata: { baseAddressKey: baseAddress.toString(), walletTypeKey: ledgerWalletType, },); @@ -174,13 +174,13 @@ class LedgerWalletFile extends WalletFile { static Future decrypt( String walletPath, String password,) async { - final encrypted = await WalletFile.read(walletPath); + final EncryptedFile encrypted = await WalletFile.read(walletPath); if (encrypted.metadata == null || encrypted.metadata![walletTypeKey] != ledgerWalletType) { throw WalletException( 'Wallet type (${encrypted.metadata![walletTypeKey]}) is not supported',); } - final decrypted = await encrypted.decrypt(password); + final List decrypted = await encrypted.decrypt(password); return LedgerWalletFile._internal(walletPath, utf8.decode(decrypted)); } diff --git a/lib/utils/wallet_utils.dart b/lib/utils/wallet_utils.dart index dcdb7507..5feadd8b 100644 --- a/lib/utils/wallet_utils.dart +++ b/lib/utils/wallet_utils.dart @@ -38,13 +38,13 @@ class WalletUtils { } static Future _storeWalletPath(String? walletPath) async { - final keyStoreBox = await Hive.openBox(kKeyStoreBox); + final Box keyStoreBox = await Hive.openBox(kKeyStoreBox); await keyStoreBox.put(0, walletPath); } static Future setWalletPath() async { if (kWalletPath == null) { - final keyStoreBox = await Hive.openBox(kKeyStoreBox); + final Box keyStoreBox = await Hive.openBox(kKeyStoreBox); if (keyStoreBox.isEmpty) { // Here we check if the key store path is saved in another place // and we copy that value, if it exists diff --git a/lib/utils/widget_utils.dart b/lib/utils/widget_utils.dart index adc7c6a7..0e7e8061 100644 --- a/lib/utils/widget_utils.dart +++ b/lib/utils/widget_utils.dart @@ -11,12 +11,12 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class WidgetUtils { static void setThemeMode(BuildContext context) { - final appThemeNotifier = Provider.of( + final AppThemeNotifier appThemeNotifier = Provider.of( context, listen: false, ); - final savedThemeMode = ThemeMode.values.firstWhere( - (element) => element.toString() == sharedPrefsService!.get(kThemeModeKey), + final ThemeMode savedThemeMode = ThemeMode.values.firstWhere( + (ThemeMode element) => element.toString() == sharedPrefsService!.get(kThemeModeKey), orElse: () => kDefaultThemeMode, ); if (appThemeNotifier.currentThemeMode != savedThemeMode) { @@ -25,13 +25,13 @@ class WidgetUtils { } static void setTextScale(BuildContext context) { - final textScalingNotifier = Provider.of( + final TextScalingNotifier textScalingNotifier = Provider.of( context, listen: false, ); - final savedTextScaling = TextScaling.values.firstWhere( - (element) => + final TextScaling savedTextScaling = TextScaling.values.firstWhere( + (TextScaling element) => element.toString() == sharedPrefsService!.get(kTextScalingKey), orElse: () => kDefaultTextScaling, ); @@ -47,7 +47,7 @@ class WidgetUtils { Address? address, BuildContext context, ) { - final textStyle = address != null && address.isEmbedded() + final TextStyle? textStyle = address != null && address.isEmbedded() ? Theme.of(context).textTheme.titleMedium!.copyWith( color: AppColors.znnColor, fontWeight: FontWeight.bold, @@ -90,7 +90,7 @@ class WidgetUtils { bool isShortVersion = true, bool showCopyToClipboardIcon = false, }) { - var textStyle = address != null && address.isEmbedded() + TextStyle? textStyle = address != null && address.isEmbedded() ? Theme.of(context).textTheme.titleMedium!.copyWith( color: AppColors.znnColor, fontWeight: FontWeight.bold, diff --git a/lib/utils/zts_utils.dart b/lib/utils/zts_utils.dart index aad5ed54..22cf0ba7 100644 --- a/lib/utils/zts_utils.dart +++ b/lib/utils/zts_utils.dart @@ -4,7 +4,7 @@ import 'package:hive/hive.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; -final List kDualCoin = [ +final List kDualCoin = [ kZnnCoin, kQsrCoin, ]; @@ -36,13 +36,13 @@ final Token kQsrCoin = Token( true, ); -final Map kCoinIdColor = { +final Map kCoinIdColor = { kZnnCoin.tokenStandard: AppColors.znnColor, kQsrCoin.tokenStandard: AppColors.qsrColor, }; bool isTrustedToken(String tokenStandard) { - return [ + return [ znnTokenStandard, qsrTokenStandard, ...Hive.box(kFavoriteTokensBox).values, diff --git a/lib/widgets/charts/pillar_rewards_chart.dart b/lib/widgets/charts/pillar_rewards_chart.dart index 44ce1951..79dffcef 100644 --- a/lib/widgets/charts/pillar_rewards_chart.dart +++ b/lib/widgets/charts/pillar_rewards_chart.dart @@ -43,13 +43,13 @@ class PillarRewardsChartState extends State { List _getRewardsSpots() => List.generate( widget.rewardsHistory!.list.length, - (index) => FlSpot( + (int index) => FlSpot( index.toDouble(), _getRewardsByIndex(index).toDouble(), ), ); - List _linesBarData() => [ + List _linesBarData() => [ StandardLineChartBarData( color: AppColors.znnColor, spots: _getRewardsSpots(), @@ -66,7 +66,7 @@ class PillarRewardsChartState extends State { num _getMaxValueOfZnnRewards() { BigInt? max = widget.rewardsHistory!.list.first.znnAmount; - for (final element in widget.rewardsHistory!.list) { + for (final RewardHistoryEntry element in widget.rewardsHistory!.list) { if (element.znnAmount > max!) { max = element.znnAmount; } diff --git a/lib/widgets/charts/sentinel_rewards_chart.dart b/lib/widgets/charts/sentinel_rewards_chart.dart index 0fa352c2..d25cc41e 100644 --- a/lib/widgets/charts/sentinel_rewards_chart.dart +++ b/lib/widgets/charts/sentinel_rewards_chart.dart @@ -46,7 +46,7 @@ class _SentinelRewardsChart extends State { List _getZnnRewardsSpots() => List.generate( widget.rewardsHistory!.list.length, - (index) => FlSpot( + (int index) => FlSpot( index.toDouble(), _getRewardsByIndex(index, kZnnCoin.tokenStandard).toDouble(), ), @@ -54,13 +54,13 @@ class _SentinelRewardsChart extends State { List _getQsrRewardsSpots() => List.generate( widget.rewardsHistory!.list.length, - (index) => FlSpot( + (int index) => FlSpot( index.toDouble(), _getRewardsByIndex(index, kQsrCoin.tokenStandard).toDouble(), ), ); - List _linesBarData() => [ + List _linesBarData() => [ StandardLineChartBarData( color: AppColors.znnColor, spots: _getZnnRewardsSpots(), @@ -90,12 +90,12 @@ class _SentinelRewardsChart extends State { } num _getMaxValueOfRewards() { - final maxZnn = _getMaxValueOfZnnRewards() + final num maxZnn = _getMaxValueOfZnnRewards() .addDecimals( coinDecimals, ) .toNum(); - final maxQsr = _getMaxValueOfQsrRewards() + final num maxQsr = _getMaxValueOfQsrRewards() .addDecimals( coinDecimals, ) @@ -104,8 +104,8 @@ class _SentinelRewardsChart extends State { } BigInt _getMaxValueOfZnnRewards() { - var max = widget.rewardsHistory!.list.first.znnAmount; - for (final element in widget.rewardsHistory!.list) { + BigInt max = widget.rewardsHistory!.list.first.znnAmount; + for (final RewardHistoryEntry element in widget.rewardsHistory!.list) { if (element.znnAmount > max) { max = element.znnAmount; } @@ -114,8 +114,8 @@ class _SentinelRewardsChart extends State { } BigInt _getMaxValueOfQsrRewards() { - var max = widget.rewardsHistory!.list.first.qsrAmount; - for (final element in widget.rewardsHistory!.list) { + BigInt max = widget.rewardsHistory!.list.first.qsrAmount; + for (final RewardHistoryEntry element in widget.rewardsHistory!.list) { if (element.qsrAmount > max) { max = element.qsrAmount; } diff --git a/lib/widgets/charts/staking_rewards_chart.dart b/lib/widgets/charts/staking_rewards_chart.dart index c112f093..31a53ddc 100644 --- a/lib/widgets/charts/staking_rewards_chart.dart +++ b/lib/widgets/charts/staking_rewards_chart.dart @@ -43,13 +43,13 @@ class _StakingRewardsChart extends State { List _getRewardsSpots() => List.generate( widget.rewardsHistory!.list.length, - (index) => FlSpot( + (int index) => FlSpot( index.toDouble(), _getRewardsByIndex(index).toDouble(), ), ); - List _linesBarData() => [ + List _linesBarData() => [ StandardLineChartBarData( color: AppColors.qsrColor, spots: _getRewardsSpots(), @@ -65,8 +65,8 @@ class _StakingRewardsChart extends State { .toNum(); num _getMaxValueOfQsrRewards() { - var max = widget.rewardsHistory!.list.first.qsrAmount; - for (final element in widget.rewardsHistory!.list) { + BigInt max = widget.rewardsHistory!.list.first.qsrAmount; + for (final RewardHistoryEntry element in widget.rewardsHistory!.list) { if (element.qsrAmount > max) { max = element.qsrAmount; } diff --git a/lib/widgets/main_app_container.dart b/lib/widgets/main_app_container.dart index 03f49711..f9308b33 100644 --- a/lib/widgets/main_app_container.dart +++ b/lib/widgets/main_app_container.dart @@ -78,7 +78,7 @@ class _MainAppContainerState extends State TransferTabChild? _transferTabChild; bool _initialUriIsHandled = false; - final _appLinks = AppLinks(); + final AppLinks _appLinks = AppLinks(); final FocusNode _focusNode = FocusNode( skipTraversal: true, canRequestFocus: false, @@ -114,10 +114,10 @@ class _MainAppContainerState extends State @override Widget build(BuildContext context) { return Consumer( - builder: (context, textScalingNotifier, child) => MediaQuery( + builder: (BuildContext context, TextScalingNotifier textScalingNotifier, Widget? child) => MediaQuery( data: MediaQuery.of(context).copyWith( textScaler: TextScaler.linear( - textScalingNotifier.getTextScaleFactor(context)), + textScalingNotifier.getTextScaleFactor(context),), ), child: Scaffold( body: Container( @@ -162,15 +162,15 @@ class _MainAppContainerState extends State } Widget _getDesktopNavigationContainer() { - final borderColor = NotificationUtils.shouldShowNotification() + final Color borderColor = NotificationUtils.shouldShowNotification() ? kLastNotification!.getColor() : Colors.transparent; return AnimatedBuilder( animation: _animationController, - builder: (context, widget) { + builder: (BuildContext context, Widget? widget) { return Row( - children: [ + children: [ Expanded( child: Container( alignment: Alignment.center, @@ -181,14 +181,14 @@ class _MainAppContainerState extends State ), ), boxShadow: (borderColor != Colors.transparent) - ? [ + ? [ BoxShadow( color: borderColor, blurRadius: _animation.value, spreadRadius: _animation.value, ), ] - : [ + : [ const BoxShadow( color: Colors.transparent, ), @@ -207,7 +207,7 @@ class _MainAppContainerState extends State ), child: Focus( focusNode: _focusNode, - onKeyEvent: (focusNode, KeyEvent event) { + onKeyEvent: (FocusNode focusNode, KeyEvent event) { if ((event.physicalKey == PhysicalKeyboardKey.tab || event.physicalKey == PhysicalKeyboardKey.enter || @@ -283,7 +283,7 @@ class _MainAppContainerState extends State List _getTextTabs() { return kTabsWithTextTitles .map( - (e) => e == Tabs.p2pSwap + (Tabs e) => e == Tabs.p2pSwap ? const Tab(text: 'P2P Swap') : Tab( text: FormatUtils.extractNameFromEnum(e).capitalize(), @@ -374,7 +374,7 @@ class _MainAppContainerState extends State Widget _getGenerationStatus() { return StreamBuilder( stream: sl.get().stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasData && snapshot.data == PowStatus.generating) { return Tooltip( message: 'Generating Plasma', @@ -401,7 +401,7 @@ class _MainAppContainerState extends State return TabBarView( physics: const NeverScrollableScrollPhysics(), controller: _tabController, - children: [ + children: [ DashboardTabChild(changePage: _navigateTo), _transferTabChild!, PillarsTabChild( @@ -492,7 +492,7 @@ class _MainAppContainerState extends State } void _listenToAutoReceiveTxWorkerNotifications() { - sl().stream.listen((event) { + sl().stream.listen((WalletNotification event) { sl().addNotification(event); }); } @@ -536,7 +536,7 @@ class _MainAppContainerState extends State if (kDisabledTabs.contains( kTabs[_tabController!.index], )) { - final index = _tabController!.previousIndex; + final int index = _tabController!.previousIndex; setState(() { _tabController!.index = index; }); @@ -549,7 +549,7 @@ class _MainAppContainerState extends State void _initLockBlock() { _lockBloc = Provider.of(context, listen: false); - _lockBlockStreamSubscription = _lockBloc.stream.listen((event) { + _lockBlockStreamSubscription = _lockBloc.stream.listen((LockEvent event) { switch (event) { case LockEvent.countDown: if (kCurrentPage != Tabs.lock) { @@ -583,7 +583,7 @@ class _MainAppContainerState extends State } Timer _createAutoLockTimer() { - return Timer.periodic(Duration(minutes: kAutoLockWalletMinutes!), (timer) { + return Timer.periodic(Duration(minutes: kAutoLockWalletMinutes!), (Timer timer) { if (!sl().hasActiveIncomingSwaps) { _lockBloc.addEvent(LockEvent.navigateToLock); } @@ -600,7 +600,7 @@ class _MainAppContainerState extends State } if (uri != null) { - var uriRaw = uri.toString(); + String uriRaw = uri.toString(); Logger('MainAppContainer') .log(Level.INFO, '_handleIncomingLinks $uriRaw'); @@ -610,7 +610,7 @@ class _MainAppContainerState extends State if (Platform.isWindows) { uriRaw = uriRaw.replaceAll('/?', '?'); } - final wcUri = Uri.decodeFull(uriRaw.split('wc?uri=').last); + final String wcUri = Uri.decodeFull(uriRaw.split('wc?uri=').last); if (WalletConnectUri.tryParse(wcUri) != null) { await _updateWalletConnectUri(wcUri); } @@ -618,15 +618,15 @@ class _MainAppContainerState extends State } // Deep link query parameters - var queryAddress = ''; - var queryAmount = ''; // with decimals - var queryDuration = 0; // in months - var queryZTS = ''; - var queryPillarName = ''; + String queryAddress = ''; + String queryAmount = ''; // with decimals + int queryDuration = 0; // in months + String queryZTS = ''; + String queryPillarName = ''; Token? token; if (uri.hasQuery) { - uri.queryParametersAll.forEach((key, value) async { + uri.queryParametersAll.forEach((String key, List value) async { if (key == 'amount') { queryAmount = value.first; } else if (key == 'zts') { @@ -652,10 +652,10 @@ class _MainAppContainerState extends State } } - final sendPaymentBloc = SendPaymentBloc(); - final stakingOptionsBloc = StakingOptionsBloc(); - final delegateButtonBloc = DelegateButtonBloc(); - final plasmaOptionsBloc = PlasmaOptionsBloc(); + final SendPaymentBloc sendPaymentBloc = SendPaymentBloc(); + final StakingOptionsBloc stakingOptionsBloc = StakingOptionsBloc(); + final DelegateButtonBloc delegateButtonBloc = DelegateButtonBloc(); + final PlasmaOptionsBloc plasmaOptionsBloc = PlasmaOptionsBloc(); if (context.mounted) { switch (uri.host) { @@ -679,7 +679,7 @@ class _MainAppContainerState extends State isBarrierDismissible: true, content: Column( mainAxisSize: MainAxisSize.min, - children: [ + children: [ Text( 'Are you sure you want transfer $queryAmount ${token.symbol} from $kSelectedAddress to $queryAddress?', ), @@ -718,7 +718,7 @@ class _MainAppContainerState extends State isBarrierDismissible: true, content: Column( mainAxisSize: MainAxisSize.min, - children: [ + children: [ Text( 'Are you sure you want stake $queryAmount ${kZnnCoin.symbol} for $queryDuration month(s)?', ), @@ -753,7 +753,7 @@ class _MainAppContainerState extends State isBarrierDismissible: true, content: Column( mainAxisSize: MainAxisSize.min, - children: [ + children: [ Text( 'Are you sure you want delegate the ${kZnnCoin.symbol} from $kSelectedAddress to Pillar $queryPillarName?', ), @@ -785,7 +785,7 @@ class _MainAppContainerState extends State isBarrierDismissible: true, content: Column( mainAxisSize: MainAxisSize.min, - children: [ + children: [ Text( 'Are you sure you want fuse $queryAmount ${kQsrCoin.symbol} for address $queryAddress?', ), @@ -866,7 +866,7 @@ class _MainAppContainerState extends State if (!_initialUriIsHandled) { _initialUriIsHandled = true; try { - final uri = await _appLinks.getInitialLink(); + final Uri? uri = await _appLinks.getInitialLink(); if (uri != null) { Logger('MainAppContainer').log(Level.INFO, '_handleInitialUri $uri'); } @@ -892,8 +892,8 @@ class _MainAppContainerState extends State @override Future onClipboardChanged() async { - final newClipboardData = await Clipboard.getData(Clipboard.kTextPlain); - final text = newClipboardData?.text ?? ''; + final ClipboardData? newClipboardData = await Clipboard.getData(Clipboard.kTextPlain); + final String text = newClipboardData?.text ?? ''; if (text.isNotEmpty && WalletConnectUri.tryParse(text) != null) { // This check is needed because onClipboardChanged is called twice sometimes if (kLastWalletConnectUriNotifier.value != text) { diff --git a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donation_stepper.dart b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donation_stepper.dart index bc671b9d..3361c090 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donation_stepper.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donation_stepper.dart @@ -50,7 +50,7 @@ class _AcceleratorDonationStepperState Widget build(BuildContext context) { return StreamBuilder?>( stream: sl.get().stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot?> snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } @@ -70,9 +70,9 @@ class _AcceleratorDonationStepperState Widget _getWidgetBody(BuildContext context, AccountInfo accountInfo) { return Stack( - children: [ + children: [ ListView( - children: [ + children: [ _getMaterialStepper(context, accountInfo), ], ), @@ -84,7 +84,7 @@ class _AcceleratorDonationStepperState left: 0, child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ StepperButton.icon( label: 'Make another donation', onPressed: () { @@ -138,7 +138,7 @@ class _AcceleratorDonationStepperState child: custom_material_stepper.Stepper( currentStep: _currentStep.index, onStepTapped: (int index) {}, - steps: [ + steps: [ StepperUtils.getMaterialStep( stepTitle: 'Donation address', stepContent: _getDonationAddressStepContent(accountInfo), @@ -175,13 +175,13 @@ class _AcceleratorDonationStepperState } String _getDonationDetailsStepSubtitle() { - final znnPrefix = _znnAmountController.text.isNotEmpty + final String znnPrefix = _znnAmountController.text.isNotEmpty ? '${_znnAmountController.text} ${kZnnCoin.symbol}' : ''; - final qsrSuffix = _qsrAmountController.text.isNotEmpty + final String qsrSuffix = _qsrAmountController.text.isNotEmpty ? '${_qsrAmountController.text} ${kQsrCoin.symbol}' : ''; - final splitter = znnPrefix.isNotEmpty && qsrSuffix.isNotEmpty ? ' ● ' : ''; + final String splitter = znnPrefix.isNotEmpty && qsrSuffix.isNotEmpty ? ' ● ' : ''; return znnPrefix + splitter + qsrSuffix; } @@ -189,9 +189,9 @@ class _AcceleratorDonationStepperState Widget _getDonationAddressStepContent(AccountInfo accountInfo) { return Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ DisabledAddressField(_addressController), - Row(children: [ + Row(children: [ StepperUtils.getBalanceWidget(kZnnCoin, accountInfo), StepperUtils.getBalanceWidget(kQsrCoin, accountInfo), ],), @@ -200,7 +200,7 @@ class _AcceleratorDonationStepperState ), kVerticalSpacing, Row( - children: [ + children: [ StepperButton( onPressed: () { Navigator.pop(context); @@ -232,9 +232,9 @@ class _AcceleratorDonationStepperState Widget _getDonationDetailsStepContent(AccountInfo accountInfo) { return Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ const Row( - children: [ + children: [ Text('Total donation budget'), StandardTooltipIcon( 'Your donation matters', @@ -252,7 +252,7 @@ class _AcceleratorDonationStepperState suffixIcon: AmountSuffixWidgets( kZnnCoin, onMaxPressed: () { - final maxZnn = accountInfo.getBalance( + final BigInt maxZnn = accountInfo.getBalance( kZnnCoin.tokenStandard, ); if (_znnAmountController.text.isEmpty || @@ -265,7 +265,7 @@ class _AcceleratorDonationStepperState } }, ), - validator: (value) => InputValidators.correctValue( + validator: (String? value) => InputValidators.correctValue( value, accountInfo.znn()!, coinDecimals, @@ -273,7 +273,7 @@ class _AcceleratorDonationStepperState canBeEqualToMin: true, canBeBlank: true, ), - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, inputFormatters: FormatUtils.getAmountTextInputFormatters( @@ -291,7 +291,7 @@ class _AcceleratorDonationStepperState suffixIcon: AmountSuffixWidgets( kQsrCoin, onMaxPressed: () { - final maxQsr = accountInfo.getBalance( + final BigInt maxQsr = accountInfo.getBalance( kQsrCoin.tokenStandard, ); if (_qsrAmountController.text.isEmpty || @@ -304,7 +304,7 @@ class _AcceleratorDonationStepperState } }, ), - validator: (value) => InputValidators.correctValue( + validator: (String? value) => InputValidators.correctValue( value, accountInfo.qsr()!, coinDecimals, @@ -312,7 +312,7 @@ class _AcceleratorDonationStepperState canBeEqualToMin: true, canBeBlank: true, ), - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, inputFormatters: FormatUtils.getAmountTextInputFormatters( @@ -322,7 +322,7 @@ class _AcceleratorDonationStepperState ), StepperUtils.getBalanceWidget(kQsrCoin, accountInfo), Row( - children: [ + children: [ StepperButton( text: 'Cancel', onPressed: () { @@ -397,13 +397,13 @@ class _AcceleratorDonationStepperState Widget _getSubmitDonationStepContent() { return Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ const DottedBorderInfoWidget( text: 'Thank you for supporting the Accelerator', ), kVerticalSpacing, Row( - children: [ + children: [ StepperButton( onPressed: () { setState(() { @@ -439,9 +439,9 @@ class _AcceleratorDonationStepperState Widget _getSubmitDonationViewModel() { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (SubmitDonationBloc model) { model.stream.listen( - (event) { + (AccountBlockTemplate? event) { if (event != null) { _submitButtonKey.currentState?.animateReverse(); setState(() { @@ -458,7 +458,7 @@ class _AcceleratorDonationStepperState }, ); }, - builder: (_, model, __) => _getSubmitDonationButton(model), + builder: (_, SubmitDonationBloc model, __) => _getSubmitDonationButton(model), viewModelBuilder: SubmitDonationBloc.new, ); } diff --git a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donations.dart b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donations.dart index 017340c8..4cb444bf 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donations.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donations.dart @@ -24,7 +24,7 @@ class AcceleratorDonations extends StatelessWidget { Widget _getWidgetBody(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ + children: [ const Icon( MaterialCommunityIcons.ufo_outline, size: 75, @@ -33,7 +33,7 @@ class AcceleratorDonations extends StatelessWidget { Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ SizedBox( width: 200, child: Text( @@ -47,7 +47,7 @@ class AcceleratorDonations extends StatelessWidget { Navigator.push( context, MaterialPageRoute( - builder: (context) => StepperScreen( + builder: (BuildContext context) => StepperScreen( stepper: const AcceleratorDonationStepper(), onStepperNotificationSeeMorePressed: onStepperNotificationSeeMorePressed, diff --git a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list.dart b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list.dart index 624a4e47..f17f45f0 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list.dart @@ -31,7 +31,7 @@ class _AcceleratorProjectListState extends State { final TextEditingController _searchKeyWordController = TextEditingController(); - final List _selectedProjectsFilterTag = []; + final List _selectedProjectsFilterTag = []; final ScrollController _scrollController = ScrollController(); @@ -42,7 +42,7 @@ class _AcceleratorProjectListState extends State { return Container( margin: const EdgeInsets.all(15), child: Column( - children: [ + children: [ _getSearchInputField(), const SizedBox( height: 10, @@ -65,7 +65,7 @@ class _AcceleratorProjectListState extends State { shrinkWrap: true, itemCount: _filterBaseProjects(widget.acceleratorProjects).length, - itemBuilder: (context, index) => AcceleratorProjectListItem( + itemBuilder: (BuildContext context, int index) => AcceleratorProjectListItem( key: ValueKey( _filterBaseProjects(widget.acceleratorProjects) .elementAt(index) @@ -96,7 +96,7 @@ class _AcceleratorProjectListState extends State { Icons.search, color: Colors.green, ), - onChanged: (value) { + onChanged: (String value) { setState(() { _searchKeyWord = value; }); @@ -106,12 +106,12 @@ class _AcceleratorProjectListState extends State { Set _filterBaseProjects( List acceleratorProjects,) { - var filteredBaseProjects = + Set filteredBaseProjects = _filterBaseProjectsBySearchKeyWord(acceleratorProjects); if (widget.acceleratorProjects.first is Project && _selectedProjectsFilterTag.isNotEmpty) { filteredBaseProjects = _filterProjectsByFilterTags( - filteredBaseProjects.map((e) => e as Project).toList(), + filteredBaseProjects.map((AcceleratorProject e) => e as Project).toList(), ); } return filteredBaseProjects; @@ -120,10 +120,10 @@ class _AcceleratorProjectListState extends State { Set _filterBaseProjectsBySearchKeyWord( List acceleratorProjects, ) { - final filteredBaseProjects = {}; + final Set filteredBaseProjects = {}; filteredBaseProjects.addAll( acceleratorProjects.where( - (element) => element.id.toString().toLowerCase().contains( + (AcceleratorProject element) => element.id.toString().toLowerCase().contains( _searchKeyWord.toLowerCase(), ), ), @@ -131,7 +131,7 @@ class _AcceleratorProjectListState extends State { if (acceleratorProjects.first is Project) { filteredBaseProjects.addAll( acceleratorProjects.where( - (element) => + (AcceleratorProject element) => (element as Project).owner.toString().toLowerCase().contains( _searchKeyWord.toLowerCase(), ), @@ -140,21 +140,21 @@ class _AcceleratorProjectListState extends State { } filteredBaseProjects.addAll( acceleratorProjects.where( - (element) => element.name.toLowerCase().contains( + (AcceleratorProject element) => element.name.toLowerCase().contains( _searchKeyWord.toLowerCase(), ), ), ); filteredBaseProjects.addAll( acceleratorProjects.where( - (element) => element.description.toLowerCase().contains( + (AcceleratorProject element) => element.description.toLowerCase().contains( _searchKeyWord.toLowerCase(), ), ), ); filteredBaseProjects.addAll( acceleratorProjects.where( - (element) => element.url.toLowerCase().contains( + (AcceleratorProject element) => element.url.toLowerCase().contains( _searchKeyWord.toLowerCase(), ), ), @@ -164,7 +164,7 @@ class _AcceleratorProjectListState extends State { Widget _getProjectsFilterTags() { return Row( - children: [ + children: [ _getProjectsFilterTag(AcceleratorProjectsFilterTag.myProjects), _getProjectsFilterTag(AcceleratorProjectsFilterTag.onlyAccepted), if (widget.pillarInfo != null) @@ -199,22 +199,22 @@ class _AcceleratorProjectListState extends State { } Set _filterProjectsByFilterTags(List projects) { - var filteredBaseProjects = const Iterable.empty(); + Iterable filteredBaseProjects = const Iterable.empty(); if (_selectedProjectsFilterTag .contains(AcceleratorProjectsFilterTag.myProjects)) { filteredBaseProjects = projects.where( - (project) => project.owner.toString() == kSelectedAddress, + (Project project) => project.owner.toString() == kSelectedAddress, ); } if (_selectedProjectsFilterTag .contains(AcceleratorProjectsFilterTag.onlyAccepted)) { if (filteredBaseProjects.isNotEmpty) { filteredBaseProjects = filteredBaseProjects.where( - (project) => project.status == AcceleratorProjectStatus.active, + (Project project) => project.status == AcceleratorProjectStatus.active, ); } else { filteredBaseProjects = projects.where( - (project) => project.status == AcceleratorProjectStatus.active, + (Project project) => project.status == AcceleratorProjectStatus.active, ); } } @@ -222,11 +222,11 @@ class _AcceleratorProjectListState extends State { .contains(AcceleratorProjectsFilterTag.votingOpened)) { if (filteredBaseProjects.isNotEmpty) { filteredBaseProjects = filteredBaseProjects.where( - (project) => project.status == AcceleratorProjectStatus.voting, + (Project project) => project.status == AcceleratorProjectStatus.voting, ); } else { filteredBaseProjects = projects.where( - (project) => project.status == AcceleratorProjectStatus.voting, + (Project project) => project.status == AcceleratorProjectStatus.voting, ); } } diff --git a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list_item.dart b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list_item.dart index 46641f68..b8b4611c 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list_item.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list_item.dart @@ -36,7 +36,7 @@ class _AcceleratorProjectListItemState Navigator.push( context, MaterialPageRoute( - builder: (context) => ProjectDetailsScreen( + builder: (BuildContext context) => ProjectDetailsScreen( pillarInfo: widget.pillarInfo, project: widget.acceleratorProject, onStepperNotificationSeeMorePressed: @@ -58,7 +58,7 @@ class _AcceleratorProjectListItemState color: Theme.of(context).colorScheme.primaryContainer, ), child: Column( - children: [ + children: [ _getProjectTitle(context), const SizedBox( height: 10, @@ -98,7 +98,7 @@ class _AcceleratorProjectListItemState ) { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ Visibility( visible: voteBreakdown.total > 0, child: _getVotingResults(context, voteBreakdown), @@ -114,7 +114,7 @@ class _AcceleratorProjectListItemState Widget _getProjectTitle(BuildContext context) { return Row( - children: [ + children: [ Text( widget.acceleratorProject.name, style: Theme.of(context).textTheme.headlineSmall, @@ -125,7 +125,7 @@ class _AcceleratorProjectListItemState Widget _getProjectDescription(BuildContext context) { return Row( - children: [ + children: [ Expanded( child: Text( widget.acceleratorProject.description, @@ -137,7 +137,7 @@ class _AcceleratorProjectListItemState } Widget _getProjectStatuses(BuildContext context) { - final tags = [ + final List tags = [ _getProjectStatusTag(), ]; @@ -170,7 +170,7 @@ class _AcceleratorProjectListItemState children: tags.zip( List.generate( tags.length - 1, - (index) => const SizedBox( + (int index) => const SizedBox( width: 5, ), ), @@ -239,30 +239,30 @@ class _AcceleratorProjectListItemState BuildContext context, VoteBreakdown voteBreakdown, ) { - final yesVotes = voteBreakdown.yes; - final noVotes = voteBreakdown.no; - final quorum = voteBreakdown.total; - final quorumNeeded = (kNumOfPillars! * 0.33).ceil(); - final votesToAchieveQuorum = quorumNeeded - quorum; - final pillarsThatCanStillVote = kNumOfPillars! - + final int yesVotes = voteBreakdown.yes; + final int noVotes = voteBreakdown.no; + final int quorum = voteBreakdown.total; + final int quorumNeeded = (kNumOfPillars! * 0.33).ceil(); + final int votesToAchieveQuorum = quorumNeeded - quorum; + final int pillarsThatCanStillVote = kNumOfPillars! - quorum - (votesToAchieveQuorum > 0 ? votesToAchieveQuorum : 0); return Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ const Row( - children: [ + children: [ Text('Voting results'), ], ), kVerticalSpacing, Row( - children: [ + children: [ AcceleratorProgressBar( context: context, child: Row( - children: [ + children: [ AcceleratorProgressBarSpan( value: yesVotes / (yesVotes + noVotes), color: AppColors.znnColor, @@ -297,11 +297,11 @@ class _AcceleratorProjectListItemState height: 10, ), Row( - children: [ + children: [ AcceleratorProgressBar( context: context, child: Row( - children: [ + children: [ AcceleratorProgressBarSpan( value: quorum / kNumOfPillars!, color: AppColors.qsrColor, @@ -378,7 +378,7 @@ class _AcceleratorProjectListItemState ProjectVoteBreakdownBloc projectVoteBreakdownViewModel, ) { return Row( - children: [ + children: [ if (pillarVoteList != null && ((widget.acceleratorProject is Phase && (widget.acceleratorProject as Phase).status == @@ -390,13 +390,13 @@ class _AcceleratorProjectListItemState pillarVoteList, projectVoteBreakdownViewModel, ), - if ([ + if ([ AcceleratorProjectStatus.voting, AcceleratorProjectStatus.active, AcceleratorProjectStatus.paid, ].contains(widget.acceleratorProject.status)) Row( - children: [ + children: [ const SizedBox( width: 10, ), @@ -408,7 +408,7 @@ class _AcceleratorProjectListItemState AcceleratorProjectStatus.voting && widget.project!.owner.toString() == kSelectedAddress) Row( - children: [ + children: [ const SizedBox( width: 10, ), @@ -425,7 +425,7 @@ class _AcceleratorProjectListItemState List pillarVoteList, ) { return Row( - children: [ + children: [ Tooltip( message: 'No', child: RawMaterialButton( @@ -547,7 +547,7 @@ class _AcceleratorProjectListItemState Navigator.push( context, MaterialPageRoute( - builder: (context) => StepperScreen( + builder: (BuildContext context) => StepperScreen( stepper: UpdatePhaseStepper( widget.acceleratorProject as Phase, widget.project!, @@ -582,8 +582,8 @@ class _AcceleratorProjectListItemState ProjectVoteBreakdownBloc projectVoteBreakdownViewModel, ) { return ViewModelBuilder.reactive( - onViewModelReady: (model) { - model.stream.listen((event) { + onViewModelReady: (VoteProjectBloc model) { + model.stream.listen((AccountBlockTemplate? event) { if (event != null) { projectVoteBreakdownViewModel.getVoteBreakdown( widget.pillarInfo?.name, @@ -597,9 +597,9 @@ class _AcceleratorProjectListItemState ); },); }, - builder: (_, model, __) => StreamBuilder( + builder: (_, VoteProjectBloc model, __) => StreamBuilder( stream: model.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return _getVotingIcons(context, model, pillarVoteList); } @@ -617,20 +617,20 @@ class _AcceleratorProjectListItemState Widget _getProjectVoteBreakdownViewModel(BuildContext context) { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (ProjectVoteBreakdownBloc model) { model.getVoteBreakdown( widget.pillarInfo?.name, widget.acceleratorProject.id,); - model.stream.listen((event) {}, onError: (error) async { + model.stream.listen((Pair?>? event) {}, onError: (error) async { await NotificationUtils.sendNotificationError( error, 'Error while trying to get the vote breakdown', ); },); }, - builder: (_, model, __) => + builder: (_, ProjectVoteBreakdownBloc model, __) => StreamBuilder?>?>( stream: model.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot?>?> snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } @@ -655,8 +655,8 @@ class _AcceleratorProjectListItemState bool _ifOptionVotedByUser( List pillarVoteList, AcceleratorProjectVote vote,) { try { - final pillarVote = pillarVoteList.firstWhere( - (pillarVote) => pillarVote?.name == widget.pillarInfo!.name, + final PillarVote? pillarVote = pillarVoteList.firstWhere( + (PillarVote? pillarVote) => pillarVote?.name == widget.pillarInfo!.name, ); return pillarVote!.vote == vote.index; } catch (e) { diff --git a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_stats.dart b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_stats.dart index 270f90e2..0211d8db 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_stats.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_stats.dart @@ -37,7 +37,7 @@ class _AcceleratorStatsState extends State { Widget _getWidgetBodyFutureBuilder(BuildContext context) { return StreamBuilder( stream: sl.get().stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } @@ -55,7 +55,7 @@ class _AcceleratorStatsState extends State { Widget _getWidgetBody(BuildContext context, AccountInfo accountInfo) { return Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ SizedBox( width: 150, child: _getPieChart(accountInfo), @@ -72,7 +72,7 @@ class _AcceleratorStatsState extends State { return Column( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ ChartLegend( dotColor: AppColors.znnColor, mainText: 'Available', @@ -83,7 +83,7 @@ class _AcceleratorStatsState extends State { ) .addDecimals(coinDecimals), tokenSymbol: kZnnCoin.symbol, - builder: (amount, tokenSymbol) => Text( + builder: (String amount, String tokenSymbol) => Text( '$amount $tokenSymbol', style: Theme.of(context).textTheme.titleMedium, ), @@ -100,7 +100,7 @@ class _AcceleratorStatsState extends State { ) .addDecimals(coinDecimals), tokenSymbol: kQsrCoin.symbol, - builder: (amount, tokenSymbol) => Text( + builder: (String amount, String tokenSymbol) => Text( '$amount $tokenSymbol', style: Theme.of(context).textTheme.titleMedium, ), @@ -117,7 +117,7 @@ class _AcceleratorStatsState extends State { sections: showingSections(accountInfo), centerSpaceRadius: 0, sectionsSpace: 4, - onChartSectionTouched: (pieTouchedSection) { + onChartSectionTouched: (PieTouchedSection? pieTouchedSection) { setState(() { _touchedSectionTitle = pieTouchedSection?.touchedSection?.title; }); @@ -127,7 +127,7 @@ class _AcceleratorStatsState extends State { } List showingSections(AccountInfo accountInfo) { - return [ + return [ if (accountInfo.findTokenByTokenStandard(kZnnCoin.tokenStandard) != null) _getPieCharSectionsData(kZnnCoin, accountInfo), if (accountInfo.findTokenByTokenStandard(kQsrCoin.tokenStandard) != null) @@ -139,13 +139,13 @@ class _AcceleratorStatsState extends State { Token token, AccountInfo accountInfo, ) { - final value = token.tokenStandard == kZnnCoin.tokenStandard + final BigInt value = token.tokenStandard == kZnnCoin.tokenStandard ? accountInfo.znn()! : accountInfo.qsr()!; - final sumValues = accountInfo.znn()! + accountInfo.qsr()!; + final BigInt sumValues = accountInfo.znn()! + accountInfo.qsr()!; - final isTouched = token.symbol == _touchedSectionTitle; - final opacity = isTouched ? 1.0 : 0.5; + final bool isTouched = token.symbol == _touchedSectionTitle; + final double opacity = isTouched ? 1.0 : 0.5; return PieChartSectionData( color: ColorUtils.getTokenColor(token.tokenStandard).withOpacity(opacity), diff --git a/lib/widgets/modular_widgets/accelerator_widgets/create_phase.dart b/lib/widgets/modular_widgets/accelerator_widgets/create_phase.dart index c73d7fdb..c829088c 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/create_phase.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/create_phase.dart @@ -29,7 +29,7 @@ class CreatePhase extends StatelessWidget { Widget _getWidgetBody(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ + children: [ const Icon( MaterialCommunityIcons.creation, size: 100, @@ -38,7 +38,7 @@ class CreatePhase extends StatelessWidget { Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ SizedBox( width: 200, child: Text( @@ -53,7 +53,7 @@ class CreatePhase extends StatelessWidget { Navigator.push( context, MaterialPageRoute( - builder: (context) => StepperScreen( + builder: (BuildContext context) => StepperScreen( stepper: PhaseCreationStepper(project), onStepperNotificationSeeMorePressed: onStepperNotificationSeeMorePressed, diff --git a/lib/widgets/modular_widgets/accelerator_widgets/create_project.dart b/lib/widgets/modular_widgets/accelerator_widgets/create_project.dart index ce08d8ae..e1932d3e 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/create_project.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/create_project.dart @@ -24,7 +24,7 @@ class CreateProject extends StatelessWidget { Widget _getWidgetBody(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ + children: [ const Icon( MaterialCommunityIcons.alien, size: 75, @@ -33,7 +33,7 @@ class CreateProject extends StatelessWidget { Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ SizedBox( width: 200, child: Text( @@ -47,7 +47,7 @@ class CreateProject extends StatelessWidget { Navigator.push( context, MaterialPageRoute( - builder: (context) => StepperScreen( + builder: (BuildContext context) => StepperScreen( stepper: const ProjectCreationStepper(), onStepperNotificationSeeMorePressed: onStepperNotificationSeeMorePressed, diff --git a/lib/widgets/modular_widgets/accelerator_widgets/phase_creation_stepper.dart b/lib/widgets/modular_widgets/accelerator_widgets/phase_creation_stepper.dart index fe61d1a1..ac5df330 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/phase_creation_stepper.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/phase_creation_stepper.dart @@ -53,7 +53,7 @@ class _PhaseCreationStepperState extends State { Widget build(BuildContext context) { return StreamBuilder?>( stream: sl.get().stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot?> snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } @@ -73,9 +73,9 @@ class _PhaseCreationStepperState extends State { Widget _getWidgetBody(BuildContext context, AccountInfo accountInfo) { return Stack( - children: [ + children: [ ListView( - children: [ + children: [ _getMaterialStepper(context, accountInfo), ], ), @@ -87,7 +87,7 @@ class _PhaseCreationStepperState extends State { left: 0, child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ StepperButton.icon( label: 'Create another phase', onPressed: () { @@ -142,7 +142,7 @@ class _PhaseCreationStepperState extends State { child: custom_material_stepper.Stepper( currentStep: _currentStep.index, onStepTapped: (int index) {}, - steps: [ + steps: [ StepperUtils.getMaterialStep( stepTitle: 'Phase details', stepContent: _getPhaseDetailsStepContent(accountInfo), @@ -173,12 +173,12 @@ class _PhaseCreationStepperState extends State { Widget _getPhaseDetailsStepContent(AccountInfo accountInfo) { return Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Text('This phase belongs to Project ID ' '${widget.project.id.toShortString()}'), kVerticalSpacing, Row( - children: [ + children: [ Expanded( child: Form( key: _phaseNameKey, @@ -186,7 +186,7 @@ class _PhaseCreationStepperState extends State { child: InputField( controller: _phaseNameController, hintText: 'Phase name', - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, validator: Validations.projectName, @@ -201,7 +201,7 @@ class _PhaseCreationStepperState extends State { ), kVerticalSpacing, Row( - children: [ + children: [ Expanded( child: Form( key: _phaseDescriptionKey, @@ -209,7 +209,7 @@ class _PhaseCreationStepperState extends State { child: InputField( controller: _phaseDescriptionController, hintText: 'Phase description', - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, validator: Validations.projectDescription, @@ -224,7 +224,7 @@ class _PhaseCreationStepperState extends State { ), kVerticalSpacing, Row( - children: [ + children: [ Expanded( child: Form( key: _phaseUrlKey, @@ -232,7 +232,7 @@ class _PhaseCreationStepperState extends State { child: InputField( controller: _phaseUrlController, hintText: 'Phase URL', - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, validator: InputValidators.checkUrl, @@ -247,7 +247,7 @@ class _PhaseCreationStepperState extends State { ), kVerticalSpacing, Row( - children: [ + children: [ Text( 'Total phase budget', style: Theme.of(context).textTheme.bodyLarge, @@ -260,7 +260,7 @@ class _PhaseCreationStepperState extends State { ), kVerticalSpacing, Row( - children: [ + children: [ Expanded( child: Form( key: _phaseZnnAmountKey, @@ -281,14 +281,14 @@ class _PhaseCreationStepperState extends State { inputFormatters: FormatUtils.getAmountTextInputFormatters( _phaseZnnAmountController.text, ), - validator: (value) => InputValidators.correctValue( + validator: (String? value) => InputValidators.correctValue( value, widget.project.getRemainingZnnFunds(), coinDecimals, BigInt.zero, canBeEqualToMin: true, ), - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, ), @@ -302,7 +302,7 @@ class _PhaseCreationStepperState extends State { ), kVerticalSpacing, Row( - children: [ + children: [ Expanded( child: Form( key: _phaseQsrAmountKey, @@ -323,14 +323,14 @@ class _PhaseCreationStepperState extends State { inputFormatters: FormatUtils.getAmountTextInputFormatters( _phaseQsrAmountController.text, ), - validator: (value) => InputValidators.correctValue( + validator: (String? value) => InputValidators.correctValue( value, widget.project.getRemainingQsrFunds(), coinDecimals, BigInt.zero, canBeEqualToMin: true, ), - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, ), @@ -344,7 +344,7 @@ class _PhaseCreationStepperState extends State { ), kVerticalSpacing, Row( - children: [ + children: [ StepperButton( text: 'Cancel', onPressed: () { @@ -372,19 +372,19 @@ class _PhaseCreationStepperState extends State { } Widget _getSubmitPhaseStepContent() { - final remainingZnnBudget = widget.project.getRemainingZnnFunds() - + final BigInt remainingZnnBudget = widget.project.getRemainingZnnFunds() - (_phaseZnnAmountController.text.isNotEmpty ? _phaseZnnAmountController.text.extractDecimals(coinDecimals) : BigInt.zero); - final remainingQsrBudget = widget.project.getRemainingQsrFunds() - + final BigInt remainingQsrBudget = widget.project.getRemainingQsrFunds() - (_phaseQsrAmountController.text.isNotEmpty ? _phaseQsrAmountController.text.extractDecimals(coinDecimals) : BigInt.zero); return Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ DottedBorderInfoWidget( text: 'Remaining budget for the next phases is ' '${remainingZnnBudget.addDecimals(coinDecimals)} ${kZnnCoin.symbol} and ' @@ -392,7 +392,7 @@ class _PhaseCreationStepperState extends State { ), kVerticalSpacing, Row( - children: [ + children: [ StepperButton( onPressed: () { setState(() { @@ -436,9 +436,9 @@ class _PhaseCreationStepperState extends State { Widget _getCreatePhaseViewModel() { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (CreatePhaseBloc model) { model.stream.listen( - (event) { + (AccountBlockTemplate? event) { if (event != null) { _submitButtonKey.currentState?.animateReverse(); setState(() { @@ -455,7 +455,7 @@ class _PhaseCreationStepperState extends State { }, ); }, - builder: (_, model, __) => _getSubmitButton(model), + builder: (_, CreatePhaseBloc model, __) => _getSubmitButton(model), viewModelBuilder: CreatePhaseBloc.new, ); } diff --git a/lib/widgets/modular_widgets/accelerator_widgets/project_creation_stepper.dart b/lib/widgets/modular_widgets/accelerator_widgets/project_creation_stepper.dart index c8028893..f476a67f 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/project_creation_stepper.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/project_creation_stepper.dart @@ -52,7 +52,7 @@ class _ProjectCreationStepperState extends State { Widget build(BuildContext context) { return StreamBuilder?>( stream: sl.get().stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot?> snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } @@ -72,9 +72,9 @@ class _ProjectCreationStepperState extends State { Widget _getWidgetBody(BuildContext context, AccountInfo accountInfo) { return Stack( - children: [ + children: [ ListView( - children: [ + children: [ _getMaterialStepper(context, accountInfo), ], ), @@ -86,7 +86,7 @@ class _ProjectCreationStepperState extends State { left: 0, child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ StepperButton.icon( label: 'Create another project', onPressed: () { @@ -154,7 +154,7 @@ class _ProjectCreationStepperState extends State { child: custom_material_stepper.Stepper( currentStep: _currentStep.index, onStepTapped: (int index) {}, - steps: [ + steps: [ StepperUtils.getMaterialStep( stepTitle: 'Project creation', stepContent: _getProjectCreationStepContent(accountInfo), @@ -195,7 +195,7 @@ class _ProjectCreationStepperState extends State { Widget _getProjectCreationStepContent(AccountInfo accountInfo) { return Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ const Text('This will be your project owner address'), kVerticalSpacing, DisabledAddressField(_addressController), @@ -206,7 +206,7 @@ class _ProjectCreationStepperState extends State { ), kVerticalSpacing, Row( - children: [ + children: [ StepperButton( onPressed: () { Navigator.pop(context); @@ -240,9 +240,9 @@ class _ProjectCreationStepperState extends State { Widget _getProjectDetailsStepContent(AccountInfo accountInfo) { return Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Row( - children: [ + children: [ Expanded( child: Form( key: _projectNameKey, @@ -250,7 +250,7 @@ class _ProjectCreationStepperState extends State { child: InputField( controller: _projectNameController, hintText: 'Project name', - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, validator: Validations.projectName, @@ -265,7 +265,7 @@ class _ProjectCreationStepperState extends State { ), kVerticalSpacing, Row( - children: [ + children: [ Expanded( child: Form( key: _projectDescriptionKey, @@ -273,7 +273,7 @@ class _ProjectCreationStepperState extends State { child: InputField( controller: _projectDescriptionController, hintText: 'Project description', - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, validator: Validations.projectDescription, @@ -288,7 +288,7 @@ class _ProjectCreationStepperState extends State { ), kVerticalSpacing, Row( - children: [ + children: [ Expanded( child: Form( key: _projectUrlKey, @@ -296,7 +296,7 @@ class _ProjectCreationStepperState extends State { child: InputField( controller: _projectUrlController, hintText: 'Project URL', - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, validator: InputValidators.checkUrl, @@ -311,7 +311,7 @@ class _ProjectCreationStepperState extends State { ), kVerticalSpacing, Row( - children: [ + children: [ Text( 'Total project budget', style: Theme.of(context).textTheme.bodyLarge, @@ -324,7 +324,7 @@ class _ProjectCreationStepperState extends State { ), kVerticalSpacing, Row( - children: [ + children: [ Expanded( child: Form( key: _projectZnnKey, @@ -338,7 +338,7 @@ class _ProjectCreationStepperState extends State { suffixIcon: AmountSuffixWidgets( kZnnCoin, onMaxPressed: () { - final maxZnn = kZnnProjectMaximumFunds; + final BigInt maxZnn = kZnnProjectMaximumFunds; if (_projectZnnAmountController.text.isEmpty || _projectZnnAmountController.text .extractDecimals(coinDecimals) < @@ -350,14 +350,14 @@ class _ProjectCreationStepperState extends State { } }, ), - validator: (value) => InputValidators.correctValue( + validator: (String? value) => InputValidators.correctValue( value, kZnnProjectMaximumFunds, kZnnCoin.decimals, kZnnProjectMinimumFunds, canBeEqualToMin: true, ), - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, ), @@ -371,7 +371,7 @@ class _ProjectCreationStepperState extends State { ), kVerticalSpacing, Row( - children: [ + children: [ Expanded( child: Form( key: _projectQsrKey, @@ -385,7 +385,7 @@ class _ProjectCreationStepperState extends State { suffixIcon: AmountSuffixWidgets( kQsrCoin, onMaxPressed: () { - final maxQsr = kQsrProjectMaximumFunds; + final BigInt maxQsr = kQsrProjectMaximumFunds; if (_projectQsrAmountController.text.isEmpty || _projectQsrAmountController.text .extractDecimals(coinDecimals) < @@ -397,14 +397,14 @@ class _ProjectCreationStepperState extends State { } }, ), - validator: (value) => InputValidators.correctValue( + validator: (String? value) => InputValidators.correctValue( value, kQsrProjectMaximumFunds, kQsrCoin.decimals, kQsrProjectMinimumFunds, canBeEqualToMin: true, ), - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, ), @@ -417,7 +417,7 @@ class _ProjectCreationStepperState extends State { ), kVerticalSpacing, Row( - children: [ + children: [ StepperButton( text: 'Cancel', onPressed: () { @@ -447,14 +447,14 @@ class _ProjectCreationStepperState extends State { Widget _getSubmitProjectStepContent() { return Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ DottedBorderInfoWidget( text: 'Consume ${projectCreationFeeInZnn.addDecimals(coinDecimals)} ${kZnnCoin.symbol} to submit the project', ), kVerticalSpacing, Row( - children: [ + children: [ StepperButton( onPressed: () { setState(() { @@ -476,9 +476,9 @@ class _ProjectCreationStepperState extends State { Widget _getSubmitProjectViewModel() { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (CreateProjectBloc model) { model.stream.listen( - (event) { + (AccountBlockTemplate? event) { if (event != null) { _submitButtonKey.currentState?.animateReverse(); setState(() { @@ -495,7 +495,7 @@ class _ProjectCreationStepperState extends State { }, ); }, - builder: (_, model, __) => _getSubmitProjectButton(model), + builder: (_, CreateProjectBloc model, __) => _getSubmitProjectButton(model), viewModelBuilder: CreateProjectBloc.new, ); } diff --git a/lib/widgets/modular_widgets/accelerator_widgets/project_list.dart b/lib/widgets/modular_widgets/accelerator_widgets/project_list.dart index 5a6ca809..6c01254c 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/project_list.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/project_list.dart @@ -58,14 +58,14 @@ class _AccProjectListState extends State { const Duration(seconds: 1), ) .distinct() - .listen((text) { + .listen((String text) { _bloc.onSearchInputChangedSink.add(text); }); - _pagingController.addPageRequestListener((pageKey) { + _pagingController.addPageRequestListener((int pageKey) { _bloc.onPageRequestSink.add(pageKey); }); _blocListingStateSubscription = _bloc.onNewListingState.listen( - (listingState) { + (InfiniteScrollBlocListingState listingState) { _pagingController.value = PagingState( nextPageKey: listingState.nextPageKey, error: listingState.error, @@ -92,12 +92,12 @@ class _AccProjectListState extends State { return Padding( padding: const EdgeInsets.all(15), child: Column( - children: [ + children: [ _getSearchInputField(), kVerticalSpacing, Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ _getProjectsFilterTags(), InkWell( onTap: _sortProjectListByLastUpdate, @@ -121,7 +121,7 @@ class _AccProjectListState extends State { height: 15, ), builderDelegate: PagedChildBuilderDelegate( - itemBuilder: (_, project, __) => AcceleratorProjectListItem( + itemBuilder: (_, Project project, __) => AcceleratorProjectListItem( key: ValueKey( project.id.toString(), ), @@ -163,11 +163,11 @@ class _AccProjectListState extends State { } Row _getProjectsFilterTags() { - final children = []; + final List children = []; - for (final tag in AccProjectsFilterTag.values) { + for (final AccProjectsFilterTag tag in AccProjectsFilterTag.values) { if (widget.pillarInfo == null) { - if ([ + if ([ AccProjectsFilterTag.needsVoting, AccProjectsFilterTag.alreadyVoted, ].contains(tag)) { @@ -226,9 +226,9 @@ class _AccProjectListState extends State { _pagingController.itemList!.isNotEmpty) { _sortAscending ? _pagingController.itemList!.sort( - (a, b) => a.lastUpdateTimestamp.compareTo(b.lastUpdateTimestamp),) + (Project a, Project b) => a.lastUpdateTimestamp.compareTo(b.lastUpdateTimestamp),) : _pagingController.itemList!.sort( - (a, b) => b.lastUpdateTimestamp.compareTo(a.lastUpdateTimestamp),); + (Project a, Project b) => b.lastUpdateTimestamp.compareTo(a.lastUpdateTimestamp),); setState(() { _sortAscending = !_sortAscending; }); diff --git a/lib/widgets/modular_widgets/accelerator_widgets/projects_stats.dart b/lib/widgets/modular_widgets/accelerator_widgets/projects_stats.dart index 5bcb1d71..bcef90e4 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/projects_stats.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/projects_stats.dart @@ -22,12 +22,12 @@ class ProjectsStats extends StatelessWidget { return Padding( padding: const EdgeInsets.all(15), child: Column( - children: [ + children: [ Row( - children: [ + children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Text( project.name, ), @@ -46,11 +46,11 @@ class ProjectsStats extends StatelessWidget { kVerticalSpacing, Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ + children: [ Visibility( child: Expanded( child: Row( - children: [ + children: [ Expanded( flex: 2, child: _getChart(_getZnnChartSections(context)), @@ -69,7 +69,7 @@ class ProjectsStats extends StatelessWidget { Visibility( child: Expanded( child: Row( - children: [ + children: [ Expanded( flex: 2, child: _getChart(_getQsrChartSections(context)), @@ -120,7 +120,7 @@ class ProjectsStats extends StatelessWidget { } List _getZnnChartSections(BuildContext context) { - return [ + return [ _getBalanceChartSection( AppColors.znnColor, project.znnFundsNeeded == BigInt.zero @@ -137,7 +137,7 @@ class ProjectsStats extends StatelessWidget { } List _getQsrChartSections(BuildContext context) { - return [ + return [ _getBalanceChartSection( AppColors.qsrColor, project.qsrFundsNeeded == BigInt.zero @@ -157,7 +157,7 @@ class ProjectsStats extends StatelessWidget { return Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ child, ], ); @@ -169,14 +169,14 @@ class ProjectsStats extends StatelessWidget { child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ ChartLegend( dotColor: AppColors.znnColor, mainText: 'Received', detailsWidget: FormattedAmountWithTooltip( amount: project.getPaidZnnFunds().addDecimals(coinDecimals), tokenSymbol: kZnnCoin.symbol, - builder: (amount, tokenSymbol) => Text( + builder: (String amount, String tokenSymbol) => Text( '$amount $tokenSymbol', style: Theme.of(context).textTheme.titleMedium, ), @@ -188,7 +188,7 @@ class ProjectsStats extends StatelessWidget { detailsWidget: FormattedAmountWithTooltip( amount: project.getRemainingZnnFunds().addDecimals(coinDecimals), tokenSymbol: kZnnCoin.symbol, - builder: (amount, tokenSymbol) => Text( + builder: (String amount, String tokenSymbol) => Text( '$amount $tokenSymbol', style: Theme.of(context).textTheme.titleMedium, ), @@ -200,7 +200,7 @@ class ProjectsStats extends StatelessWidget { detailsWidget: FormattedAmountWithTooltip( amount: project.getTotalZnnFunds().addDecimals(coinDecimals), tokenSymbol: kZnnCoin.symbol, - builder: (amount, tokenSymbol) => Text( + builder: (String amount, String tokenSymbol) => Text( '$amount $tokenSymbol', style: Theme.of(context).textTheme.titleMedium, ), @@ -217,14 +217,14 @@ class ProjectsStats extends StatelessWidget { child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ ChartLegend( dotColor: AppColors.qsrColor, mainText: 'Received', detailsWidget: FormattedAmountWithTooltip( amount: project.getPaidQsrFunds().addDecimals(coinDecimals), tokenSymbol: kQsrCoin.symbol, - builder: (amount, tokenSymbol) => Text( + builder: (String amount, String tokenSymbol) => Text( '$amount $tokenSymbol', style: Theme.of(context).textTheme.titleMedium, ), @@ -236,7 +236,7 @@ class ProjectsStats extends StatelessWidget { detailsWidget: FormattedAmountWithTooltip( amount: project.getRemainingQsrFunds().addDecimals(coinDecimals), tokenSymbol: kQsrCoin.symbol, - builder: (amount, tokenSymbol) => Text( + builder: (String amount, String tokenSymbol) => Text( '$amount $tokenSymbol', style: Theme.of(context).textTheme.titleMedium, ), @@ -248,7 +248,7 @@ class ProjectsStats extends StatelessWidget { detailsWidget: FormattedAmountWithTooltip( amount: project.getTotalQsrFunds().addDecimals(coinDecimals), tokenSymbol: kQsrCoin.symbol, - builder: (amount, tokenSymbol) => Text( + builder: (String amount, String tokenSymbol) => Text( '$amount $tokenSymbol', style: Theme.of(context).textTheme.titleMedium, ), diff --git a/lib/widgets/modular_widgets/accelerator_widgets/update_phase_stepper.dart b/lib/widgets/modular_widgets/accelerator_widgets/update_phase_stepper.dart index 37672c16..d60edab3 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/update_phase_stepper.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/update_phase_stepper.dart @@ -67,7 +67,7 @@ class _UpdatePhaseStepperState extends State { Widget build(BuildContext context) { return StreamBuilder?>( stream: sl.get().stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot?> snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } @@ -87,9 +87,9 @@ class _UpdatePhaseStepperState extends State { Widget _getWidgetBody(BuildContext context, AccountInfo accountInfo) { return Stack( - children: [ + children: [ ListView( - children: [ + children: [ _getMaterialStepper(context, accountInfo), ], ), @@ -101,7 +101,7 @@ class _UpdatePhaseStepperState extends State { left: 0, child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ StepperButton( text: 'View Phases', onPressed: () { @@ -142,7 +142,7 @@ class _UpdatePhaseStepperState extends State { child: custom_material_stepper.Stepper( currentStep: _currentStep.index, onStepTapped: (int index) {}, - steps: [ + steps: [ StepperUtils.getMaterialStep( stepTitle: 'Phase details', stepContent: _getPhaseDetailsStepContent(accountInfo), @@ -165,7 +165,7 @@ class _UpdatePhaseStepperState extends State { } custom_material_stepper.StepState _getStepState(UpdatePhaseStep step) { - final stepIndex = step.index; + final int stepIndex = step.index; return stepIndex <= (_lastCompletedStep?.index ?? -1) ? custom_material_stepper.StepState.complete : custom_material_stepper.StepState.indexed; @@ -174,9 +174,9 @@ class _UpdatePhaseStepperState extends State { Widget _getPhaseDetailsStepContent(AccountInfo accountInfo) { return Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Row( - children: [ + children: [ Expanded( child: Text( 'This phase belongs to Project ID ' @@ -193,7 +193,7 @@ class _UpdatePhaseStepperState extends State { child: InputField( controller: _phaseNameController, hintText: 'Phase name', - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, validator: Validations.projectName, @@ -206,7 +206,7 @@ class _UpdatePhaseStepperState extends State { child: InputField( controller: _phaseDescriptionController, hintText: 'Phase description', - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, validator: Validations.projectDescription, @@ -219,7 +219,7 @@ class _UpdatePhaseStepperState extends State { child: InputField( controller: _phaseUrlController, hintText: 'Phase URL', - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, validator: InputValidators.checkUrl, @@ -250,14 +250,14 @@ class _UpdatePhaseStepperState extends State { inputFormatters: FormatUtils.getAmountTextInputFormatters( _phaseZnnAmountController.text, ), - validator: (value) => InputValidators.correctValue( + validator: (String? value) => InputValidators.correctValue( value, widget.project.getRemainingZnnFunds(), kZnnCoin.decimals, BigInt.zero, canBeEqualToMin: true, ), - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, ), @@ -282,21 +282,21 @@ class _UpdatePhaseStepperState extends State { inputFormatters: FormatUtils.getAmountTextInputFormatters( _phaseQsrAmountController.text, ), - validator: (value) => InputValidators.correctValue( + validator: (String? value) => InputValidators.correctValue( value, widget.project.getRemainingQsrFunds(), kQsrCoin.decimals, BigInt.zero, canBeEqualToMin: true, ), - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, ), ), kVerticalSpacing, Row( - children: [ + children: [ StepperButton( text: 'Cancel', onPressed: () { @@ -326,13 +326,13 @@ class _UpdatePhaseStepperState extends State { Widget _getUpdatePhaseStepContent() { return Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ const DottedBorderInfoWidget( text: 'Updating this phase will reset all current votes', ), kVerticalSpacing, Row( - children: [ + children: [ StepperButton( onPressed: () { setState(() { @@ -392,9 +392,9 @@ class _UpdatePhaseStepperState extends State { Widget _getUpdatePhaseViewModel() { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (UpdatePhaseBloc model) { model.stream.listen( - (event) { + (AccountBlockTemplate? event) { if (event != null) { setState(() { _lastCompletedStep = UpdatePhaseStep.updatePhase; @@ -409,9 +409,9 @@ class _UpdatePhaseStepperState extends State { }, ); }, - builder: (_, model, __) => StreamBuilder( + builder: (_, UpdatePhaseBloc model, __) => StreamBuilder( stream: model.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return _getUpdatePhaseButton(model); } diff --git a/lib/widgets/modular_widgets/dashboard_widgets/plasma_stats.dart b/lib/widgets/modular_widgets/dashboard_widgets/plasma_stats.dart index c4331305..f23078b9 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/plasma_stats.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/plasma_stats.dart @@ -37,7 +37,7 @@ class PlasmaStats extends StatefulWidget { } class _PlasmaStatsState extends State { - final List _addresses = []; + final List _addresses = []; bool _sortAscending = true; @@ -68,7 +68,7 @@ class _PlasmaStatsState extends State { : null, items: plasmaInfoStats, headerColumns: widget.version == PlasmaStatsWidgetVersion.plasmaTab - ? [ + ? [ CustomHeaderColumn( columnName: 'Address', onSortArrowsPressed: _onSortArrowsPressed, @@ -80,8 +80,8 @@ class _PlasmaStatsState extends State { ), ] : null, - generateRowCells: (plasmaStatsWrapper, isSelected) { - return [ + generateRowCells: (PlasmaInfoWrapper plasmaStatsWrapper, bool isSelected) { + return [ if (widget.version == PlasmaStatsWidgetVersion.plasmaTab) isSelected ? CustomTableCell.tooltipWithMarquee( Address.parse(plasmaStatsWrapper.address), @@ -120,13 +120,13 @@ class _PlasmaStatsState extends State { switch (columnName) { case 'Address': _sortAscending - ? _addresses.sort((a, b) => a.compareTo(b)) - : _addresses.sort((a, b) => b.compareTo(a)); + ? _addresses.sort((String a, String b) => a.compareTo(b)) + : _addresses.sort((String a, String b) => b.compareTo(a)); default: _sortAscending - ? _addresses.sort((a, b) => a.compareTo(b)) - : _addresses.sort((a, b) => b.compareTo(a)); + ? _addresses.sort((String a, String b) => a.compareTo(b)) + : _addresses.sort((String a, String b) => b.compareTo(a)); break; } diff --git a/lib/widgets/modular_widgets/help_widgets/about_card.dart b/lib/widgets/modular_widgets/help_widgets/about_card.dart index 704d5ff9..c5c56582 100644 --- a/lib/widgets/modular_widgets/help_widgets/about_card.dart +++ b/lib/widgets/modular_widgets/help_widgets/about_card.dart @@ -39,7 +39,7 @@ class AboutCardState extends State { Widget _getNewBody(GeneralStats generalStats) { return ListView( shrinkWrap: true, - children: [ + children: [ CustomExpandablePanel( 'Syrius wallet version', _getGenericTextExpandedChild(kWalletVersion), @@ -150,7 +150,7 @@ class AboutCardState extends State { } Widget _getGenericTextExpandedChild(String expandedText) { - return Row(children: [ + return Row(children: [ CustomTableCell.withMarquee( expandedText, ), @@ -158,7 +158,7 @@ class AboutCardState extends State { } Widget _getGenericLinkButtonExpandedChild(String url) { - return Row(children: [ + return Row(children: [ CustomTableCell.withMarquee( url, ), @@ -177,7 +177,7 @@ class AboutCardState extends State { } Widget _getGenericOpenButtonExpandedChild(String expandedText) { - return Row(children: [ + return Row(children: [ CustomTableCell.withMarquee( expandedText, ), @@ -198,7 +198,7 @@ class AboutCardState extends State { Widget _getStreamBuilder() { return StreamBuilder( stream: _generalStatsBloc!.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasData) { return _getNewBody(snapshot.data!); } else if (snapshot.hasError) { diff --git a/lib/widgets/modular_widgets/help_widgets/community_card.dart b/lib/widgets/modular_widgets/help_widgets/community_card.dart index 4aefbda2..0a70b352 100644 --- a/lib/widgets/modular_widgets/help_widgets/community_card.dart +++ b/lib/widgets/modular_widgets/help_widgets/community_card.dart @@ -21,7 +21,7 @@ class CommunityCard extends StatelessWidget { return ListView( physics: const ClampingScrollPhysics(), shrinkWrap: true, - children: [ + children: [ CustomExpandablePanel( 'Websites', _getWebsitesExpandableChild(context), @@ -46,7 +46,7 @@ class CommunityCard extends StatelessWidget { return ListView( physics: const ClampingScrollPhysics(), shrinkWrap: true, - children: [ + children: [ _getListViewChild( iconData: MaterialCommunityIcons.home, title: 'Zenon Network', @@ -85,7 +85,7 @@ class CommunityCard extends StatelessWidget { return ListView( physics: const ClampingScrollPhysics(), shrinkWrap: true, - children: [ + children: [ _getListViewChild( iconData: Icons.explore, title: 'Zenon Explorer', @@ -106,7 +106,7 @@ class CommunityCard extends StatelessWidget { return ListView( physics: const ClampingScrollPhysics(), shrinkWrap: true, - children: [ + children: [ _getListViewChild( iconData: MaterialCommunityIcons.twitter, title: 'Zenon Twitter', @@ -163,7 +163,7 @@ class CommunityCard extends StatelessWidget { return ListView( physics: const ClampingScrollPhysics(), shrinkWrap: true, - children: [ + children: [ _getListViewChild( iconData: MaterialCommunityIcons.book_open_page_variant, title: 'Zenon Wiki', @@ -193,7 +193,7 @@ class CommunityCard extends StatelessWidget { required BuildContext context, }) { return Row( - children: [ + children: [ Icon( iconData, color: AppColors.znnColor, diff --git a/lib/widgets/modular_widgets/help_widgets/update_card.dart b/lib/widgets/modular_widgets/help_widgets/update_card.dart index d63968be..c055a162 100644 --- a/lib/widgets/modular_widgets/help_widgets/update_card.dart +++ b/lib/widgets/modular_widgets/help_widgets/update_card.dart @@ -18,7 +18,7 @@ class UpdateCard extends StatelessWidget { Widget _getWidgetBody(BuildContext context) { return ListView( shrinkWrap: true, - children: [ + children: [ CustomExpandablePanel( 'Check update', _getCheckUpdateExpandableChild(context), diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/detail_row.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/detail_row.dart index e50b2a26..3765cebd 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/detail_row.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/detail_row.dart @@ -22,12 +22,12 @@ class DetailRow extends StatelessWidget { Widget build(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ Text(label, style: const TextStyle( fontSize: 12, color: AppColors.subtitleColor,),), Row( - children: [ + children: [ prefixWidget ?? Container(), if (prefixWidget != null) const SizedBox( diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_card.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_card.dart index 3e29b97c..bc232bc7 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_card.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_card.dart @@ -148,7 +148,7 @@ class _HtlcCardState extends State padding: const EdgeInsets.all(20), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ + children: [ Text( widget.title, style: @@ -160,9 +160,9 @@ class _HtlcCardState extends State Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.end, - children: [ + children: [ Row( - children: [ + children: [ Container( constraints: const BoxConstraints(maxWidth: 280), child: Text( @@ -230,7 +230,7 @@ class _HtlcCardState extends State child: Visibility( visible: _areDetailsExpanded, child: Column( - children: [ + children: [ const SizedBox(height: 20), Divider(color: Colors.white.withOpacity(0.1)), const SizedBox(height: 20), @@ -242,9 +242,9 @@ class _HtlcCardState extends State } Widget _getDetailsList() { - final children = []; - final htlcId = Hash.parse(widget.htlcId!); - final hashLock = Hash.parse(widget.hashLock!); + final List children = []; + final Hash htlcId = Hash.parse(widget.htlcId!); + final Hash hashLock = Hash.parse(widget.hashLock!); children.add(_getExpirationRow(widget.expirationTime!)); children.add( DetailRow( @@ -281,7 +281,7 @@ class _HtlcCardState extends State children: children.zip( List.generate( children.length - 1, - (index) => const SizedBox( + (int index) => const SizedBox( height: 15, ), ), @@ -290,10 +290,10 @@ class _HtlcCardState extends State } Widget? _getTokenStandardTooltip(String tokenStandard) { - var message = 'This token is not in your favorites.'; - var icon = Icons.help; - var iconColor = AppColors.errorColor; - if ([znnTokenStandard, qsrTokenStandard].contains(tokenStandard)) { + String message = 'This token is not in your favorites.'; + IconData icon = Icons.help; + Color iconColor = AppColors.errorColor; + if ([znnTokenStandard, qsrTokenStandard].contains(tokenStandard)) { message = 'This token is verified.'; icon = Icons.check_circle_outline; iconColor = AppColors.znnColor; @@ -316,7 +316,7 @@ class _HtlcCardState extends State } Widget _getExpirationRow(int expirationTime) { - final duration = + final Duration duration = Duration(seconds: expirationTime - DateTimeUtils.unixTimeNow); if (duration.isNegative) { return const DetailRow( diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_swap_details_widget.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_swap_details_widget.dart index 15c80cda..5ce98c45 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_swap_details_widget.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/htlc_swap_details_widget.dart @@ -40,7 +40,7 @@ class _HtlcSwapDetailsWidgetState extends State Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ + children: [ InkWell( borderRadius: BorderRadius.circular(4), hoverColor: Colors.transparent, @@ -57,7 +57,7 @@ class _HtlcSwapDetailsWidgetState extends State child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text( _isExpanded ? 'Hide details' : 'Show details', style: const TextStyle( @@ -83,7 +83,7 @@ class _HtlcSwapDetailsWidgetState extends State child: Visibility( visible: _isExpanded, child: Column( - children: [ + children: [ const SizedBox(height: 20), Divider(color: Colors.white.withOpacity(0.1)), const SizedBox(height: 20), @@ -97,11 +97,11 @@ class _HtlcSwapDetailsWidgetState extends State } Widget _getDetailsList(HtlcSwap swap) { - final children = []; - final yourDepositId = swap.direction == P2pSwapDirection.outgoing + final List children = []; + final String yourDepositId = swap.direction == P2pSwapDirection.outgoing ? swap.initialHtlcId : swap.counterHtlcId!; - final counterpartyDepositId = swap.direction == P2pSwapDirection.incoming + final String? counterpartyDepositId = swap.direction == P2pSwapDirection.incoming ? swap.initialHtlcId : swap.counterHtlcId; children.add( @@ -154,7 +154,7 @@ class _HtlcSwapDetailsWidgetState extends State children: children.zip( List.generate( children.length - 1, - (index) => const SizedBox( + (int index) => const SizedBox( height: 15, ), ), diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/join_native_swap_modal.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/join_native_swap_modal.dart index 7562449c..4fffd599 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/join_native_swap_modal.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/join_native_swap_modal.dart @@ -85,7 +85,7 @@ class _JoinNativeSwapModalState extends State { : FutureBuilder( future: zenon!.embedded.token.getByZts(_initialHltc!.tokenStandard), - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return Padding( padding: const EdgeInsets.all(20), @@ -105,14 +105,14 @@ class _JoinNativeSwapModalState extends State { Widget _getSearchView() { return Column( - children: [ + children: [ const SizedBox( height: 20, ), Form( autovalidateMode: AutovalidateMode.onUserInteraction, child: InputField( - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, validator: InputValidators.checkHash, @@ -146,7 +146,7 @@ class _JoinNativeSwapModalState extends State { Visibility( visible: _initialHtlcError != null, child: Column( - children: [ + children: [ ImportantTextContainer( text: _initialHtlcError ?? '', showBorder: true, @@ -164,9 +164,9 @@ class _JoinNativeSwapModalState extends State { ViewModelBuilder _getInitialHtlcViewModel() { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (InitialHtlcForSwapBloc model) { model.stream.listen( - (event) async { + (HtlcInfo? event) async { if (event is HtlcInfo) { _initialHltc = event; _isLoading = false; @@ -186,7 +186,7 @@ class _JoinNativeSwapModalState extends State { }, ); }, - builder: (_, model, __) => _getContinueButton(model), + builder: (_, InitialHtlcForSwapBloc model, __) => _getContinueButton(model), viewModelBuilder: InitialHtlcForSwapBloc.new, ); } @@ -214,10 +214,10 @@ class _JoinNativeSwapModalState extends State { return Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ + children: [ const SizedBox(height: 20), Row( - children: [ + children: [ Expanded( child: LabeledInputContainer( labelText: 'Your address', @@ -238,7 +238,7 @@ class _JoinNativeSwapModalState extends State { inputWidget: Flexible( child: StreamBuilder?>( stream: sl.get().stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot?> snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } @@ -251,7 +251,7 @@ class _JoinNativeSwapModalState extends State { textColor: Theme.of(context).colorScheme.inverseSurface, initialToken: _selectedToken, hintText: '0.0', - onChanged: (token, isValid) { + onChanged: (Token token, bool isValid) { setState(() { _selectedToken = token; _isAmountValid = isValid; @@ -285,7 +285,7 @@ class _JoinNativeSwapModalState extends State { padding: const EdgeInsets.symmetric(horizontal: 10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ const Text( 'Exchange Rate', style: @@ -300,11 +300,11 @@ class _JoinNativeSwapModalState extends State { if (_safeExpirationTime != null) const SizedBox(height: 20), if (_safeExpirationTime != null) BulletPointCard( - bulletPoints: [ + bulletPoints: [ RichText( text: BulletPointCard.textSpan( 'You have ', - children: [ + children: [ TextSpan( text: '${(((_initialHltc!.expirationTime - kMinSafeTimeToFindPreimage.inSeconds - kCounterHtlcDuration.inSeconds) - DateTimeUtils.unixTimeNow) / 60).ceil()} minutes', @@ -317,7 +317,7 @@ class _JoinNativeSwapModalState extends State { RichText( text: BulletPointCard.textSpan( 'The counterparty will have ', - children: [ + children: [ TextSpan( text: '~${kCounterHtlcDuration.inHours} hour', style: const TextStyle( @@ -334,7 +334,7 @@ class _JoinNativeSwapModalState extends State { ], ), const SizedBox(height: 20), - if (_safeExpirationTime != null) Column(children: [ + if (_safeExpirationTime != null) Column(children: [ Visibility( visible: !isTrustedToken(tokenToReceive.tokenStandard.toString()), @@ -360,9 +360,9 @@ class _JoinNativeSwapModalState extends State { ViewModelBuilder _getJoinSwapViewModel(Token tokenToReceive) { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (JoinHtlcSwapBloc model) { model.stream.listen( - (event) async { + (HtlcSwap? event) async { if (event is HtlcSwap) { widget.onJoinedSwap.call(event.id); } @@ -375,7 +375,7 @@ class _JoinNativeSwapModalState extends State { }, ); }, - builder: (_, model, __) => _getJoinSwapButton(model, tokenToReceive), + builder: (_, JoinHtlcSwapBloc model, __) => _getJoinSwapButton(model, tokenToReceive), viewModelBuilder: JoinHtlcSwapBloc.new, ); } @@ -409,10 +409,10 @@ class _JoinNativeSwapModalState extends State { } int? _calculateSafeExpirationTime(int initialHtlcExpiration) { - final minNeededRemainingTime = + final Duration minNeededRemainingTime = kMinSafeTimeToFindPreimage + kCounterHtlcDuration; - final now = DateTimeUtils.unixTimeNow; - final remaining = Duration(seconds: initialHtlcExpiration - now); + final int now = DateTimeUtils.unixTimeNow; + final Duration remaining = Duration(seconds: initialHtlcExpiration - now); return remaining >= minNeededRemainingTime ? now + kCounterHtlcDuration.inSeconds : null; diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/native_p2p_swap_modal.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/native_p2p_swap_modal.dart index b4f00c3f..e8959dd0 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/native_p2p_swap_modal.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/native_p2p_swap_modal.dart @@ -59,7 +59,7 @@ class _NativeP2pSwapModalState extends State { Widget build(BuildContext context) { return StreamBuilder( stream: _htlcSwapBloc.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasData) { return BaseModal( title: _getTitle(snapshot.data!), @@ -104,7 +104,7 @@ class _NativeP2pSwapModalState extends State { height: 215, child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text( 'Starting swap. This will take a moment.', style: TextStyle( @@ -120,7 +120,7 @@ class _NativeP2pSwapModalState extends State { Widget _getActiveView(HtlcSwap swap) { return Column( - children: [ + children: [ const SizedBox( height: 20, ), @@ -148,7 +148,7 @@ class _NativeP2pSwapModalState extends State { Widget _getCompletedView(HtlcSwap swap) { return Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ const SizedBox( height: 10, ), @@ -179,10 +179,10 @@ class _NativeP2pSwapModalState extends State { child: Padding( padding: const EdgeInsets.all(20), child: Column( - children: [ + children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ const Text( 'From', style: TextStyle( @@ -198,7 +198,7 @@ class _NativeP2pSwapModalState extends State { ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ const Text( 'To', style: TextStyle( @@ -214,7 +214,7 @@ class _NativeP2pSwapModalState extends State { ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ const Text( 'Exchange Rate', style: TextStyle( @@ -236,16 +236,16 @@ class _NativeP2pSwapModalState extends State { } Widget _getUnsuccessfulView(HtlcSwap swap) { - final expiration = swap.direction == P2pSwapDirection.outgoing + final int? expiration = swap.direction == P2pSwapDirection.outgoing ? swap.initialHtlcExpirationTime : swap.counterHtlcExpirationTime; - final remainingDuration = + final Duration remainingDuration = Duration(seconds: (expiration ?? 0) - DateTimeUtils.unixTimeNow); - final isReclaimable = remainingDuration.inSeconds <= 0 && + final bool isReclaimable = remainingDuration.inSeconds <= 0 && swap.state == P2pSwapState.reclaimable; return Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ const SizedBox( height: 10, ), @@ -279,7 +279,7 @@ class _NativeP2pSwapModalState extends State { child: Padding( padding: const EdgeInsets.all(20), child: Column( - children: [ + children: [ if (remainingDuration.inSeconds > 0) TweenAnimationBuilder( duration: remainingDuration, @@ -292,7 +292,7 @@ class _NativeP2pSwapModalState extends State { padding: const EdgeInsets.only(bottom: 15), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ const Text( 'Deposit expires in', style: TextStyle( @@ -313,7 +313,7 @@ class _NativeP2pSwapModalState extends State { ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ Text( swap.state == P2pSwapState.reclaimable ? 'Deposited amount' @@ -346,7 +346,7 @@ class _NativeP2pSwapModalState extends State { Widget _getBottomSection(HtlcSwap swap) { if (swap.counterHtlcId == null) { return Column( - children: [ + children: [ const Padding( padding: EdgeInsets.symmetric(horizontal: 10), child: Text( @@ -377,12 +377,12 @@ class _NativeP2pSwapModalState extends State { ); } else { return Column( - children: [ + children: [ Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ const Text( 'Exchange Rate', style: TextStyle( @@ -400,7 +400,7 @@ class _NativeP2pSwapModalState extends State { Visibility( visible: swap.direction == P2pSwapDirection.outgoing, child: Column( - children: [ + children: [ Visibility( visible: !isTrustedToken(swap.toTokenStandard ?? ''), child: Padding( @@ -440,8 +440,8 @@ class _NativeP2pSwapModalState extends State { } Widget _getExpirationWarningForOutgoingSwap(HtlcSwap swap) { - const warningThreshold = Duration(minutes: 10); - final timeToCompleteSwap = Duration( + const Duration warningThreshold = Duration(minutes: 10); + final Duration timeToCompleteSwap = Duration( seconds: swap.counterHtlcExpirationTime! - DateTimeUtils.unixTimeNow,) - kMinSafeTimeToCompleteSwap; @@ -465,9 +465,9 @@ class _NativeP2pSwapModalState extends State { Widget _getSwapButtonViewModel(HtlcSwap swap) { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (CompleteHtlcSwapBloc model) { model.stream.listen( - (event) async { + (HtlcSwap? event) async { if (event is HtlcSwap) { setState(() { _swapCompletedText = @@ -483,7 +483,7 @@ class _NativeP2pSwapModalState extends State { }, ); }, - builder: (_, model, __) => InstructionButton( + builder: (_, CompleteHtlcSwapBloc model, __) => InstructionButton( text: 'Swap', isEnabled: true, isLoading: _isSendingTransaction, @@ -543,7 +543,7 @@ class _NativeP2pSwapModalState extends State { Widget _getReclaimButton(HtlcSwap swap) { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (ReclaimHtlcSwapFundsBloc model) { model.stream.listen( null, onError: (error) { @@ -553,7 +553,7 @@ class _NativeP2pSwapModalState extends State { }, ); }, - builder: (_, model, __) => InstructionButton( + builder: (_, ReclaimHtlcSwapFundsBloc model, __) => InstructionButton( text: 'Reclaim funds', isEnabled: true, isLoading: _isSendingTransaction, @@ -586,7 +586,7 @@ class _NativeP2pSwapModalState extends State { Widget _getAmountAndSymbolWidget(String amount, String symbol) { return Row( - children: [ + children: [ Container( constraints: const BoxConstraints(maxWidth: 150), child: Text( diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/p2p_swap_warning_modal.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/p2p_swap_warning_modal.dart index f35f9dcb..5eb17d35 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/p2p_swap_warning_modal.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/p2p_swap_warning_modal.dart @@ -24,7 +24,7 @@ class _P2PSwapWarningModalState extends State { Widget _getContent() { return Column( - children: [ + children: [ const SizedBox( height: 20, ), diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/recover_deposit_modal.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/recover_deposit_modal.dart index be439607..9fa20e21 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/recover_deposit_modal.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/recover_deposit_modal.dart @@ -59,7 +59,7 @@ class _RecoverDepositModalState extends State { Widget _getPendingFundsView() { return Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ const SizedBox( height: 10, ), @@ -91,7 +91,7 @@ class _RecoverDepositModalState extends State { Widget _getSearchView() { return Column( - children: [ + children: [ const SizedBox( height: 20, ), @@ -108,7 +108,7 @@ class _RecoverDepositModalState extends State { cursor: SystemMouseCursors.click, child: GestureDetector( child: const Row( - children: [ + children: [ Text( 'View swap tutorial', style: TextStyle( @@ -135,7 +135,7 @@ class _RecoverDepositModalState extends State { Form( autovalidateMode: AutovalidateMode.onUserInteraction, child: InputField( - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, validator: InputValidators.checkHash, @@ -169,7 +169,7 @@ class _RecoverDepositModalState extends State { Visibility( visible: _errorText != null, child: Column( - children: [ + children: [ ImportantTextContainer( text: _errorText ?? '', showBorder: true, @@ -187,9 +187,9 @@ class _RecoverDepositModalState extends State { Widget _getRecoverButton() { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (RecoverHtlcSwapFundsBloc model) { model.stream.listen( - (event) async { + (AccountBlockTemplate? event) async { if (event is AccountBlockTemplate) { setState(() { _isPendingFunds = true; @@ -204,7 +204,7 @@ class _RecoverDepositModalState extends State { }, ); }, - builder: (_, model, __) => InstructionButton( + builder: (_, RecoverHtlcSwapFundsBloc model, __) => InstructionButton( text: 'Recover deposit', isEnabled: _isHashValid(), isLoading: _isLoading, diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/start_native_swap_modal.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/start_native_swap_modal.dart index 85f695f4..3b562137 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/modals/start_native_swap_modal.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/modals/start_native_swap_modal.dart @@ -72,16 +72,16 @@ class _StartNativeSwapModalState extends State { return Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ + children: [ const SizedBox(height: 20), Row( - children: [ + children: [ Expanded( child: LabeledInputContainer( labelText: 'Your address', inputWidget: AddressesDropdown( _selectedSelfAddress, - (address) => setState(() { + (String? address) => setState(() { _selectedSelfAddress = address; sl.get().getBalanceForAllAddresses(); }), @@ -98,7 +98,7 @@ class _StartNativeSwapModalState extends State { inputWidget: Form( autovalidateMode: AutovalidateMode.onUserInteraction, child: InputField( - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, enabled: !_isLoading, @@ -137,7 +137,7 @@ class _StartNativeSwapModalState extends State { inputWidget: Flexible( child: StreamBuilder?>( stream: sl.get().stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot?> snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } @@ -151,7 +151,7 @@ class _StartNativeSwapModalState extends State { textColor: Theme.of(context).colorScheme.inverseSurface, initialToken: _selectedToken, hintText: '0.0', - onChanged: (token, isValid) { + onChanged: (Token token, bool isValid) { if (!_isLoading) { setState(() { _selectedToken = token; @@ -172,7 +172,7 @@ class _StartNativeSwapModalState extends State { ), const SizedBox(height: 20), BulletPointCard( - bulletPoints: [ + bulletPoints: [ RichText( text: BulletPointCard.textSpan( 'After starting the swap, wait for the counterparty to join the swap with the agreed upon amount.',), @@ -180,7 +180,7 @@ class _StartNativeSwapModalState extends State { RichText( text: BulletPointCard.textSpan( '''You can reclaim your funds in ''', - children: [ + children: [ TextSpan( text: '${kInitialHtlcDuration.inHours} hours', style: @@ -204,9 +204,9 @@ class _StartNativeSwapModalState extends State { ViewModelBuilder _getStartSwapViewModel() { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (StartHtlcSwapBloc model) { model.stream.listen( - (event) async { + (HtlcSwap? event) async { if (event is HtlcSwap) { widget.onSwapStarted.call(event.id); } @@ -219,7 +219,7 @@ class _StartNativeSwapModalState extends State { }, ); }, - builder: (_, model, __) => _getStartSwapButton(model), + builder: (_, StartHtlcSwapBloc model, __) => _getStartSwapButton(model), viewModelBuilder: StartHtlcSwapBloc.new, ); } @@ -258,7 +258,7 @@ class _StartNativeSwapModalState extends State { _isAmountValid; String? _validateCounterpartyAddress(String? address) { - final result = InputValidators.checkAddress(address); + final String? result = InputValidators.checkAddress(address); if (result != null) { return result; } else { diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_button.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_button.dart index fc3041d4..0796862e 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_button.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_button.dart @@ -45,11 +45,11 @@ class _P2pSwapOptionsButtonState extends State { ), ), child: Row( - children: [ + children: [ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ + children: [ Text( widget.primaryText, textAlign: TextAlign.left, @@ -73,7 +73,7 @@ class _P2pSwapOptionsButtonState extends State { width: 15, ), const Column( - children: [ + children: [ Icon(Icons.keyboard_arrow_right, size: 18), ], ), diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_card.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_card.dart index d6f6b340..ba726dde 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_card.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_card.dart @@ -46,7 +46,7 @@ class _P2pSwapOptionsCardState extends State { ); }, child: Row( - children: [ + children: [ const Icon( Icons.refresh, color: AppColors.znnColor, @@ -72,11 +72,11 @@ class _P2pSwapOptionsCardState extends State { Widget _getWidgetBody(BuildContext context) { return StreamBuilder( stream: sl.get().stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } - final isGeneratingPlasma = _isGeneratingPlasma(snapshot.data); + final bool isGeneratingPlasma = _isGeneratingPlasma(snapshot.data); return Container( margin: const EdgeInsets.all(20), child: _getNativeOptions(isGeneratingPlasma), @@ -118,7 +118,7 @@ class _P2pSwapOptionsCardState extends State { Column _getNativeOptions(bool isGeneratingPlasma) { return Column( - children: [ + children: [ P2pSwapOptionsButton( primaryText: 'Start swap', secondaryText: 'Start a native swap with a counterparty.', @@ -155,7 +155,7 @@ class _P2pSwapOptionsCardState extends State { child: GestureDetector( child: const Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text( 'View swap tutorial', style: TextStyle( diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_card.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_card.dart index 6fea950b..49d99b3e 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_card.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_card.dart @@ -54,7 +54,7 @@ class _P2pSwapsCardState extends State { return CardScaffold>( title: 'P2P Swaps', childStream: _p2pSwapsListBloc.stream, - onCompletedStatusCallback: (data) => data.isEmpty + onCompletedStatusCallback: (List data) => data.isEmpty ? const SyriusErrorWidget('No P2P swaps') : _getTable(data), onRefreshPressed: _p2pSwapsListBloc.getData, @@ -66,7 +66,7 @@ class _P2pSwapsCardState extends State { child: GestureDetector( onTap: _onDeleteSwapHistoryTapped, child: Row( - children: [ + children: [ const Icon( Icons.delete, color: AppColors.znnColor, @@ -130,7 +130,7 @@ class _P2pSwapsCardState extends State { return Padding( padding: const EdgeInsets.all(15), child: Column( - children: [ + children: [ _getHeader(), const SizedBox( height: 15, @@ -151,7 +151,7 @@ class _P2pSwapsCardState extends State { height: 15, ); }, - itemBuilder: (_, index) { + itemBuilder: (_, int index) { return P2pSwapsListItem( key: ValueKey(swaps.elementAt(index).id), swap: swaps.elementAt(index), @@ -170,7 +170,7 @@ class _P2pSwapsCardState extends State { return Padding( padding: const EdgeInsets.symmetric(horizontal: 20), child: Row( - children: [ + children: [ Expanded( flex: 20, child: _getHeaderItem('Status'), @@ -193,7 +193,7 @@ class _P2pSwapsCardState extends State { visible: htlcSwapsService!.isMaxSwapsReached, child: Row( mainAxisAlignment: MainAxisAlignment.end, - children: [ + children: [ _getHeaderItem( 'Swap history is full', textColor: AppColors.errorColor, diff --git a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_list_item.dart b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_list_item.dart index 4ac24f0c..a3d7ff94 100644 --- a/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_list_item.dart +++ b/lib/widgets/modular_widgets/p2p_swap_widgets/p2p_swaps_list_item.dart @@ -41,11 +41,11 @@ class _P2pSwapsListItemState extends State { height: 56, padding: const EdgeInsets.symmetric(horizontal: 20), child: Row( - children: [ + children: [ Expanded( flex: 20, child: Row( - children: [ + children: [ _getStatusWidget(), const SizedBox( width: 8, @@ -90,7 +90,7 @@ class _P2pSwapsListItemState extends State { } Widget _getStatusWidget() { - const size = 16.0; + const double size = 16; switch (widget.swap.state) { case P2pSwapState.pending: case P2pSwapState.active: @@ -141,9 +141,9 @@ class _P2pSwapsListItemState extends State { return _getTextWidget('-'); } return Row( - children: [ + children: [ Row( - children: [ + children: [ Container( constraints: const BoxConstraints(maxWidth: 70), child: _getTextWidget(amount.addDecimals(decimals)), @@ -228,7 +228,7 @@ class _P2pSwapsListItemState extends State { } String _formatTime(int transactionMillis) { - final currentMillis = DateTime.now().millisecondsSinceEpoch; + final int currentMillis = DateTime.now().millisecondsSinceEpoch; if (currentMillis - transactionMillis <= const Duration(days: 1).inMilliseconds) { return _formatTimeShort(currentMillis - transactionMillis); @@ -238,7 +238,7 @@ class _P2pSwapsListItemState extends State { } String _formatTimeShort(int i) { - final duration = Duration(milliseconds: i); + final Duration duration = Duration(milliseconds: i); if (duration.inHours > 0) { return '${duration.inHours} h ago'; } diff --git a/lib/widgets/modular_widgets/pillar_widgets/create_pillar.dart b/lib/widgets/modular_widgets/pillar_widgets/create_pillar.dart index 967d9f8a..347ea0aa 100644 --- a/lib/widgets/modular_widgets/pillar_widgets/create_pillar.dart +++ b/lib/widgets/modular_widgets/pillar_widgets/create_pillar.dart @@ -36,7 +36,7 @@ class _CreatePillarState extends State { Widget _getStreamBuilder(BuildContext context) { return StreamBuilder>( stream: _getPillarByOwnerBloc.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot> snapshot) { if (snapshot.hasData) { if (snapshot.data!.isNotEmpty) { return _getUpdatePillarWidgetBody(context, snapshot.data!.first); @@ -54,17 +54,17 @@ class _CreatePillarState extends State { Widget _getCreatePillarWidgetBody(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ + children: [ Lottie.asset('assets/lottie/ic_anim_pillar.json', repeat: false), Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ SyriusElevatedButton( onPressed: () { Navigator.push( context, MaterialPageRoute( - builder: (context) => StepperScreen( + builder: (BuildContext context) => StepperScreen( stepper: const PillarStepperContainer(), onStepperNotificationSeeMorePressed: widget.onStepperNotificationSeeMorePressed, @@ -91,7 +91,7 @@ class _CreatePillarState extends State { ) { return Row( mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ + children: [ Expanded( child: Lottie.asset( 'assets/lottie/ic_anim_pillar.json', @@ -102,7 +102,7 @@ class _CreatePillarState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text( 'Update Pillar settings', style: Theme.of(context).textTheme.headlineSmall, @@ -110,13 +110,13 @@ class _CreatePillarState extends State { kVerticalSpacing, Row( mainAxisSize: MainAxisSize.min, - children: [ + children: [ SyriusElevatedButton( onPressed: () { Navigator.push( context, MaterialPageRoute( - builder: (context) => StepperScreen( + builder: (BuildContext context) => StepperScreen( stepper: PillarUpdateStepper(pillarInfo), onStepperNotificationSeeMorePressed: widget.onStepperNotificationSeeMorePressed, diff --git a/lib/widgets/modular_widgets/pillar_widgets/pillar_collect.dart b/lib/widgets/modular_widgets/pillar_widgets/pillar_collect.dart index 87e0be6d..46e7dae8 100644 --- a/lib/widgets/modular_widgets/pillar_widgets/pillar_collect.dart +++ b/lib/widgets/modular_widgets/pillar_widgets/pillar_collect.dart @@ -49,7 +49,7 @@ class _PillarCollectState extends State { Widget _getFutureBuilder() { return StreamBuilder( stream: _pillarCollectRewardsBloc.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } else if (snapshot.hasData) { @@ -66,7 +66,7 @@ class _PillarCollectState extends State { Widget _getWidgetBody(UncollectedReward uncollectedReward) { return Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ NumberAnimation( end: uncollectedReward.znnAmount .addDecimals( @@ -102,7 +102,7 @@ class _PillarCollectState extends State { 'collect Pillar rewards', waitForRequiredPlasma: true, ).then( - (response) async { + (AccountBlockTemplate response) async { await Future.delayed(kDelayAfterAccountBlockCreationCall); if (mounted) { _pillarCollectRewardsBloc.updateStream(); diff --git a/lib/widgets/modular_widgets/pillar_widgets/pillar_list_widget.dart b/lib/widgets/modular_widgets/pillar_widgets/pillar_list_widget.dart index b05a2774..4113d069 100644 --- a/lib/widgets/modular_widgets/pillar_widgets/pillar_list_widget.dart +++ b/lib/widgets/modular_widgets/pillar_widgets/pillar_list_widget.dart @@ -34,9 +34,9 @@ class _PillarListWidgetState extends State { final PillarsListBloc _pillarsListBloc = PillarsListBloc(); final DelegationInfoBloc _delegationInfoBloc = DelegationInfoBloc(); - final List _pillarInfoWrappers = []; + final List _pillarInfoWrappers = []; - final Map> _delegateButtonKeys = {}; + final Map> _delegateButtonKeys = >{}; bool _sortAscending = true; @@ -50,11 +50,11 @@ class _PillarListWidgetState extends State { void initState() { super.initState(); sl.get().getBalanceForAllAddresses(); - _pagingController.addPageRequestListener((pageKey) { + _pagingController.addPageRequestListener((int pageKey) { _pillarsListBloc.onPageRequestSink.add(pageKey); }); _blocListingStateSubscription = _pillarsListBloc.onNewListingState.listen( - (listingState) { + (InfiniteScrollBlocListingState listingState) { _pagingController.value = PagingState( nextPageKey: listingState.nextPageKey, error: listingState.error, @@ -93,7 +93,7 @@ class _PillarListWidgetState extends State { ) { return StreamBuilder( stream: _delegationInfoBloc.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } @@ -112,7 +112,7 @@ class _PillarListWidgetState extends State { Widget _getTable(PillarsListBloc bloc) { return Column( - children: [ + children: [ _getTableHeader(bloc), Expanded( child: Scrollbar( @@ -121,7 +121,7 @@ class _PillarListWidgetState extends State { scrollController: _scrollController, pagingController: _pagingController, builderDelegate: PagedChildBuilderDelegate( - itemBuilder: (_, item, index) => _getTableRow( + itemBuilder: (_, PillarInfo item, int index) => _getTableRow( item, index, ), @@ -155,13 +155,13 @@ class _PillarListWidgetState extends State { ), child: Row( children: List.from( - [ + [ const SizedBox( width: 20, ), ], ) + - [ + [ InfiniteScrollTableHeaderColumn( columnName: 'Name', onSortArrowsPressed: _onSortArrowsPressed, @@ -193,12 +193,12 @@ class _PillarListWidgetState extends State { width: 5, ), ] + - [ + [ SizedBox( width: 110, child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Visibility( visible: _delegationInfo?.name != null, child: _getUndelegateButtonViewModel(bloc), @@ -209,7 +209,7 @@ class _PillarListWidgetState extends State { } Widget _getTableRow(dynamic item, int indexOfRow) { - final isSelected = _selectedRowIndex == indexOfRow; + final bool isSelected = _selectedRowIndex == indexOfRow; return InkWell( onTap: () { @@ -246,14 +246,14 @@ class _PillarListWidgetState extends State { ), child: Row( children: List.from( - [ + [ const SizedBox( width: 20, ), ], ) + generateRowCells(item, isSelected) + - [ + [ const SizedBox( width: 110, ), @@ -270,7 +270,7 @@ class _PillarListWidgetState extends State { PillarInfo pillarInfo, bool isSelected, ) { - return [ + return [ InfiniteScrollTableCell.withText( context, pillarInfo.name, @@ -293,7 +293,7 @@ class _PillarListWidgetState extends State { kZnnCoin.decimals, ), tokenSymbol: kZnnCoin.symbol, - builder: (formattedAmount, tokenSymbol) => Text( + builder: (String formattedAmount, String tokenSymbol) => Text( '$formattedAmount $tokenSymbol', style: Theme.of(context).textTheme.titleMedium!.copyWith( color: _isStakeAddressDefault(pillarInfo) @@ -338,7 +338,7 @@ class _PillarListWidgetState extends State { PillarsListBloc model, ) { return Row( - children: [ + children: [ Visibility( visible: _currentlyDelegatingToPillar == null ? true @@ -383,7 +383,7 @@ class _PillarListWidgetState extends State { return Visibility( visible: _isStakeAddressDefault(pillarItem), child: Row( - children: [ + children: [ Visibility( visible: pillarItem.isRevocable, child: _getDisassemblePillarViewModel( @@ -441,9 +441,9 @@ class _PillarListWidgetState extends State { PillarInfo pillarInfo, ) { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (DisassemblePillarBloc model) { model.stream.listen( - (event) { + (AccountBlockTemplate? event) { if (event != null) { pillarsListModel.refreshResults(); } @@ -456,9 +456,9 @@ class _PillarListWidgetState extends State { }, ); }, - builder: (_, model, __) => StreamBuilder( + builder: (_, DisassemblePillarBloc model, __) => StreamBuilder( stream: model.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return _getDisassembleButton(isSelected, model, pillarInfo); } @@ -495,7 +495,7 @@ class _PillarListWidgetState extends State { : null, child: Row( mainAxisSize: MainAxisSize.min, - children: [ + children: [ Text( 'DISASSEMBLE', style: isSelected @@ -541,22 +541,22 @@ class _PillarListWidgetState extends State { switch (columnName) { case 'Name': _sortAscending - ? _pillarInfoWrappers.sort((a, b) => a.name.compareTo(b.name)) - : _pillarInfoWrappers.sort((a, b) => b.name.compareTo(a.name)); + ? _pillarInfoWrappers.sort((PillarInfo a, PillarInfo b) => a.name.compareTo(b.name)) + : _pillarInfoWrappers.sort((PillarInfo a, PillarInfo b) => b.name.compareTo(a.name)); case 'Producer Address': _sortAscending ? _pillarInfoWrappers - .sort((a, b) => a.producerAddress.compareTo(b.producerAddress)) + .sort((PillarInfo a, PillarInfo b) => a.producerAddress.compareTo(b.producerAddress)) : _pillarInfoWrappers - .sort((a, b) => b.producerAddress.compareTo(a.producerAddress)); + .sort((PillarInfo a, PillarInfo b) => b.producerAddress.compareTo(a.producerAddress)); case 'Weight': _sortAscending - ? _pillarInfoWrappers.sort((a, b) => a.weight.compareTo(b.weight)) - : _pillarInfoWrappers.sort((a, b) => b.weight.compareTo(a.weight)); + ? _pillarInfoWrappers.sort((PillarInfo a, PillarInfo b) => a.weight.compareTo(b.weight)) + : _pillarInfoWrappers.sort((PillarInfo a, PillarInfo b) => b.weight.compareTo(a.weight)); default: _sortAscending - ? _pillarInfoWrappers.sort((a, b) => a.name.compareTo(b.name)) - : _pillarInfoWrappers.sort((a, b) => b.name.compareTo(a.name)); + ? _pillarInfoWrappers.sort((PillarInfo a, PillarInfo b) => a.name.compareTo(b.name)) + : _pillarInfoWrappers.sort((PillarInfo a, PillarInfo b) => b.name.compareTo(a.name)); break; } @@ -566,12 +566,12 @@ class _PillarListWidgetState extends State { } Widget _getUndelegateButtonViewModel(PillarsListBloc pillarsModel) { - final undelegateButtonKey = GlobalKey(); + final GlobalKey undelegateButtonKey = GlobalKey(); return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (UndelegateButtonBloc model) { model.stream.listen( - (event) { + (AccountBlockTemplate? event) { if (event != null) { undelegateButtonKey.currentState?.animateReverse(); _delegationInfoBloc.updateStream(); @@ -586,7 +586,7 @@ class _PillarListWidgetState extends State { }, ); }, - builder: (_, model, __) => _getUndelegateButton( + builder: (_, UndelegateButtonBloc model, __) => _getUndelegateButton( model, undelegateButtonKey, ), @@ -600,7 +600,7 @@ class _PillarListWidgetState extends State { ) { return StreamBuilder?>( stream: sl.get().stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot?> snapshot) { if (snapshot.hasError) { return Expanded(child: SyriusErrorWidget(snapshot.error!)); } @@ -638,9 +638,9 @@ class _PillarListWidgetState extends State { ? true : _currentlyDelegatingToPillar == pillarInfo.name), child: ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (DelegateButtonBloc model) { model.stream.listen( - (event) { + (AccountBlockTemplate? event) { if (event != null) { _delegationInfoBloc.updateStream(); delegateButtonKey.currentState?.animateReverse(); @@ -661,7 +661,7 @@ class _PillarListWidgetState extends State { }, ); }, - builder: (_, model, __) => _getDelegateButton( + builder: (_, DelegateButtonBloc model, __) => _getDelegateButton( pillarInfo, model, delegateButtonKey, @@ -680,7 +680,7 @@ class _PillarListWidgetState extends State { } int _getMomentumsPercentage(PillarInfo pillarInfo) { - final percentage = + final double percentage = pillarInfo.producedMomentums / pillarInfo.expectedMomentums * 100; if (percentage.isNaN) { return 0; diff --git a/lib/widgets/modular_widgets/pillar_widgets/pillar_rewards.dart b/lib/widgets/modular_widgets/pillar_widgets/pillar_rewards.dart index 208d36ce..b8193280 100644 --- a/lib/widgets/modular_widgets/pillar_widgets/pillar_rewards.dart +++ b/lib/widgets/modular_widgets/pillar_widgets/pillar_rewards.dart @@ -30,7 +30,7 @@ class _PillarRewardsState extends State { Widget _getStreamBody() { return StreamBuilder( stream: widget.pillarRewardsHistoryBloc.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } diff --git a/lib/widgets/modular_widgets/pillar_widgets/pillar_stepper_container.dart b/lib/widgets/modular_widgets/pillar_widgets/pillar_stepper_container.dart index 736471cc..4dc64b4b 100644 --- a/lib/widgets/modular_widgets/pillar_widgets/pillar_stepper_container.dart +++ b/lib/widgets/modular_widgets/pillar_widgets/pillar_stepper_container.dart @@ -73,7 +73,7 @@ class _MainPillarState extends State { final List> _pillarFormKeys = List.generate( 3, - (index) => GlobalKey(), + (int index) => GlobalKey(), ); late PillarsQsrInfoBloc _pillarsQsrInfoViewModel; @@ -97,7 +97,7 @@ class _MainPillarState extends State { Widget build(BuildContext context) { return StreamBuilder?>( stream: sl.get().stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot?> snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } @@ -117,14 +117,14 @@ class _MainPillarState extends State { Widget _getQsrManagementStep(BuildContext context, AccountInfo accountInfo) { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (PillarsQsrInfoBloc model) { _pillarsQsrInfoViewModel = model; model.getQsrManagementInfo( _selectedPillarType, _addressController.text, ); model.stream.listen( - (event) { + (PillarsQsrInfo? event) { if (event != null) { _maxQsrAmount = MathUtils.bigMin( accountInfo.getBalance( @@ -140,9 +140,9 @@ class _MainPillarState extends State { }, ); }, - builder: (_, model, __) => StreamBuilder( + builder: (_, PillarsQsrInfoBloc model, __) => StreamBuilder( stream: model.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasData) { return _getQsrManagementStepBody( context, @@ -169,14 +169,14 @@ class _MainPillarState extends State { ) { return Row( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Row( children: [ Expanded( @@ -191,7 +191,7 @@ class _MainPillarState extends State { padding: const EdgeInsets.only(left: 20), child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ AvailableBalance( kQsrCoin, accountInfo, @@ -208,7 +208,7 @@ class _MainPillarState extends State { height: 10, ), Row( - children: [ + children: [ Expanded( child: Form( key: _qsrFormKey, @@ -219,7 +219,7 @@ class _MainPillarState extends State { _qsrAmountController.text, ), controller: _qsrAmountController, - validator: (value) => InputValidators.correctValue( + validator: (String? value) => InputValidators.correctValue( value, _maxQsrAmount, kQsrCoin.decimals, @@ -229,7 +229,7 @@ class _MainPillarState extends State { suffixIconConstraints: const BoxConstraints(maxWidth: 50), hintText: 'Amount', - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, ), @@ -249,7 +249,7 @@ class _MainPillarState extends State { ], ), Row( - children: [ + children: [ Visibility( visible: qsrInfo.deposit < qsrInfo.cost, child: _getDepositQsrViewModel(accountInfo, qsrInfo), @@ -284,19 +284,19 @@ class _MainPillarState extends State { padding: const EdgeInsets.symmetric(vertical: 30), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ + children: [ Column( - children: [ + children: [ Stack( alignment: Alignment.center, - children: [ + children: [ SizedBox( width: 150, height: 150, child: AspectRatio( aspectRatio: 1, child: StandardPieChart( - sections: [ + sections: [ PieChartSectionData( showTitle: false, radius: 7, @@ -327,7 +327,7 @@ class _MainPillarState extends State { ], ), Column( - children: [ + children: [ SizedBox( width: 130, child: Text( @@ -356,9 +356,9 @@ class _MainPillarState extends State { Widget _getDepositQsrViewModel( AccountInfo accountInfo, PillarsQsrInfo qsrInfo,) { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (PillarsDepositQsrBloc model) { model.stream.listen( - (response) { + (AccountBlockTemplate? response) { if (response != null) { _depositQsrButtonKey.currentState?.animateReverse(); _pillarsQsrInfoViewModel.getQsrManagementInfo( @@ -380,7 +380,7 @@ class _MainPillarState extends State { }, ); }, - builder: (_, model, __) => + builder: (_, PillarsDepositQsrBloc model, __) => _getDepositQsrButton(model, accountInfo, qsrInfo), viewModelBuilder: PillarsDepositQsrBloc.new, ); @@ -406,9 +406,9 @@ class _MainPillarState extends State { BigInt qsrDeposit, ) { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (PillarsWithdrawQsrBloc model) { model.stream.listen( - (event) { + (AccountBlockTemplate? event) { if (event != null) { _withdrawButtonKey.currentState?.animateReverse(); _saveProgressAndNavigateToNextStep( @@ -429,7 +429,7 @@ class _MainPillarState extends State { }, ); }, - builder: (_, model, __) => _getWithdrawQsrButton(model, qsrDeposit), + builder: (_, PillarsWithdrawQsrBloc model, __) => _getWithdrawQsrButton(model, qsrDeposit), viewModelBuilder: PillarsWithdrawQsrBloc.new, ); } @@ -459,7 +459,7 @@ class _MainPillarState extends State { child: custom_material_stepper.Stepper( currentStep: _currentStep.index, onStepTapped: (int index) {}, - steps: [ + steps: [ StepperUtils.getMaterialStep( stepTitle: 'Pillar deployment: Plasma check', stepContent: _getPlasmaCheckFutureBuilder(), @@ -508,7 +508,7 @@ class _MainPillarState extends State { Widget _getAmountSuffix(AccountInfo accountInfo) { return Row( - children: [ + children: [ Container( height: 20, alignment: Alignment.center, @@ -522,7 +522,7 @@ class _MainPillarState extends State { horizontal: 7, ), child: Row( - children: [ + children: [ Text( kQsrCoin.symbol, style: Theme.of(context).textTheme.titleSmall!.copyWith( @@ -542,9 +542,9 @@ class _MainPillarState extends State { padding: const EdgeInsets.only(bottom: 25), child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Row( - children: [ + children: [ Expanded( child: Form( key: _pillarFormKeys[0], @@ -555,7 +555,7 @@ class _MainPillarState extends State { thisNode: _pillarNameNode, nextNode: _pillarRewardNode, validator: Validations.pillarName, - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, ), @@ -568,7 +568,7 @@ class _MainPillarState extends State { ), kVerticalSpacing, Row( - children: [ + children: [ Expanded( child: Form( key: _pillarFormKeys[1], @@ -579,7 +579,7 @@ class _MainPillarState extends State { thisNode: _pillarRewardNode, nextNode: _pillarMomentumNode, validator: InputValidators.checkAddress, - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, ), @@ -593,7 +593,7 @@ class _MainPillarState extends State { ), kVerticalSpacing, Row( - children: [ + children: [ Expanded( child: Form( key: _pillarFormKeys[2], @@ -603,7 +603,7 @@ class _MainPillarState extends State { controller: _pillarMomentumController, thisNode: _pillarMomentumNode, validator: InputValidators.validatePillarMomentumAddress, - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, ), @@ -628,9 +628,9 @@ class _MainPillarState extends State { Widget _getDeployButton() { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (PillarsDeployBloc model) { model.stream.listen( - (response) { + (AccountBlockTemplate? response) { if (response != null) { _registerButtonKey.currentState?.animateReverse(); _saveProgressAndNavigateToNextStep( @@ -649,7 +649,7 @@ class _MainPillarState extends State { }, ); }, - builder: (_, model, __) => _getRegisterPillarButton(model), + builder: (_, PillarsDeployBloc model, __) => _getRegisterPillarButton(model), viewModelBuilder: PillarsDeployBloc.new, ); } @@ -668,7 +668,7 @@ class _MainPillarState extends State { ) { return Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Row( children: [ Expanded( @@ -680,7 +680,7 @@ class _MainPillarState extends State { StepperUtils.getBalanceWidget(kZnnCoin, accountInfo), kVerticalSpacing, Row( - children: [ + children: [ Expanded( child: InputField( enabled: false, @@ -740,7 +740,7 @@ class _MainPillarState extends State { void _onDeployPressed(PillarsDeployBloc model) { if (_lastCompletedStep == PillarStepperStep.znnManagement) { if (_pillarFormKeys - .every((element) => element.currentState!.validate())) { + .every((GlobalKey element) => element.currentState!.validate())) { _registerButtonKey.currentState?.animateForward(); model.deployPillar( pillarType: _selectedPillarType!, @@ -751,7 +751,7 @@ class _MainPillarState extends State { giveDelegateRewardPercentage: _delegateRewardPercentageGiven.toInt(), ); } else { - for (final element in _pillarFormKeys) { + for (final GlobalKey element in _pillarFormKeys) { element.currentState!.validate(); } } @@ -770,15 +770,15 @@ class _MainPillarState extends State { Widget _getWidgetBody(BuildContext context, AccountInfo accountInfo) { return Stack( - children: [ + children: [ ListView( - children: [ + children: [ _getMaterialStepper(context, accountInfo), Visibility( visible: (_lastCompletedStep?.index ?? -1) == _numSteps - 1, child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Container( padding: const EdgeInsets.symmetric( vertical: 40, @@ -800,7 +800,7 @@ class _MainPillarState extends State { textAlign: TextAlign.center, text: TextSpan( style: Theme.of(context).textTheme.headlineSmall, - children: [ + children: [ TextSpan( text: 'Pillar ', style: Theme.of(context).textTheme.headlineSmall, @@ -846,7 +846,7 @@ class _MainPillarState extends State { ), Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ StepperButton.icon( label: 'Register another Pillar', onPressed: _onDeployAnotherPillarButtonPressed, @@ -961,7 +961,7 @@ class _MainPillarState extends State { Widget _getPlasmaCheckFutureBuilder() { return FutureBuilder( future: zenon!.embedded.plasma.get(Address.parse(kSelectedAddress!)), - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } else if (snapshot.hasData) { @@ -978,7 +978,7 @@ class _MainPillarState extends State { Widget _getPlasmaCheckBody(PlasmaInfo plasmaInfo) { return Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Text( 'More Plasma is required to perform complex transactions. Please fuse enough QSR before proceeding.', style: Theme.of(context).textTheme.headlineSmall, @@ -1026,10 +1026,10 @@ class _MainPillarState extends State { Widget _getPillarMomentumRewardsStepContent() { return Column( - children: [ + children: [ Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text( 'Percentage of momentum rewards given to the delegators', style: Theme.of(context).textTheme.headlineSmall, @@ -1049,7 +1049,7 @@ class _MainPillarState extends State { ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ Text( 'Pillar: ${100 - _momentumRewardPercentageGiven.toInt()}', style: Theme.of(context).textTheme.titleMedium, @@ -1063,7 +1063,7 @@ class _MainPillarState extends State { kVerticalSpacing, Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text( 'Percentage of delegation rewards given to the delegators', style: Theme.of(context).textTheme.headlineSmall, @@ -1083,7 +1083,7 @@ class _MainPillarState extends State { ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ Text( 'Pillar: ${100 - _delegateRewardPercentageGiven.toInt()}', style: Theme.of(context).textTheme.titleMedium, diff --git a/lib/widgets/modular_widgets/pillar_widgets/pillar_update_stepper.dart b/lib/widgets/modular_widgets/pillar_widgets/pillar_update_stepper.dart index 316d5803..1e01124e 100644 --- a/lib/widgets/modular_widgets/pillar_widgets/pillar_update_stepper.dart +++ b/lib/widgets/modular_widgets/pillar_widgets/pillar_update_stepper.dart @@ -61,9 +61,9 @@ class _PillarUpdateStepperState extends State { @override Widget build(BuildContext context) { return Stack( - children: [ + children: [ ListView( - children: [ + children: [ _getMaterialStepper(), ], ), @@ -75,7 +75,7 @@ class _PillarUpdateStepperState extends State { left: 0, child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ StepperButton( text: 'View Pillars', onPressed: () { @@ -114,7 +114,7 @@ class _PillarUpdateStepperState extends State { child: custom_material_stepper.Stepper( currentStep: _currentStep.index, onStepTapped: (int index) {}, - steps: [ + steps: [ StepperUtils.getMaterialStep( stepTitle: 'Pillar details', stepContent: _getPillarDetailsStepContent(), @@ -156,7 +156,7 @@ class _PillarUpdateStepperState extends State { Widget _getPillarDetailsStepContent() { return Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Text( 'Pillar name', style: Theme.of(context).textTheme.bodyLarge, @@ -181,7 +181,7 @@ class _PillarUpdateStepperState extends State { thisNode: _pillarRewardNode, nextNode: _pillarMomentumNode, validator: InputValidators.checkAddress, - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, ), @@ -200,14 +200,14 @@ class _PillarUpdateStepperState extends State { controller: _pillarProducerController, thisNode: _pillarMomentumNode, validator: InputValidators.validatePillarMomentumAddress, - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, ), ), kVerticalSpacing, Row( - children: [ + children: [ StepperButton( onPressed: () { Navigator.pop(context); @@ -236,10 +236,10 @@ class _PillarUpdateStepperState extends State { Widget _getPillarMomentumRewardsStepContent() { return Column( - children: [ + children: [ Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text( 'Percentage of momentum rewards given to the delegators', style: Theme.of(context).textTheme.headlineSmall, @@ -259,7 +259,7 @@ class _PillarUpdateStepperState extends State { ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ Text( 'Pillar: ${100 - _momentumRewardPercentageGiven.toInt()}', style: Theme.of(context).textTheme.titleMedium, @@ -273,7 +273,7 @@ class _PillarUpdateStepperState extends State { kVerticalSpacing, Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text( 'Percentage of delegation rewards given to the delegators', style: Theme.of(context).textTheme.headlineSmall, @@ -293,7 +293,7 @@ class _PillarUpdateStepperState extends State { ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ Text( 'Pillar: ${100 - _delegateRewardPercentageGiven.toInt()}', style: Theme.of(context).textTheme.titleMedium, @@ -306,7 +306,7 @@ class _PillarUpdateStepperState extends State { ), kVerticalSpacing, Row( - children: [ + children: [ StepperButton( onPressed: () { setState(() { @@ -336,7 +336,7 @@ class _PillarUpdateStepperState extends State { Widget _getPillarUpdateStepContent() { return Row( - children: [ + children: [ StepperButton( onPressed: () { setState(() { @@ -379,9 +379,9 @@ class _PillarUpdateStepperState extends State { Widget _getUpdatePillarViewModel() { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (UpdatePillarBloc model) { model.stream.listen( - (event) { + (AccountBlockTemplate? event) { if (event != null) { _updateButtonKey.currentState?.animateReverse(); setState(() { @@ -398,7 +398,7 @@ class _PillarUpdateStepperState extends State { }, ); }, - builder: (_, model, __) => _getUpdatePillarButton(model), + builder: (_, UpdatePillarBloc model, __) => _getUpdatePillarButton(model), viewModelBuilder: UpdatePillarBloc.new, ); } diff --git a/lib/widgets/modular_widgets/plasma_widgets/plasma_list/plasma_list.dart b/lib/widgets/modular_widgets/plasma_widgets/plasma_list/plasma_list.dart index 8340482a..6a000989 100644 --- a/lib/widgets/modular_widgets/plasma_widgets/plasma_list/plasma_list.dart +++ b/lib/widgets/modular_widgets/plasma_widgets/plasma_list/plasma_list.dart @@ -22,7 +22,7 @@ class PlasmaList extends StatefulWidget { } class _PlasmaListState extends State { - final List _stakingList = []; + final List _stakingList = []; bool _sortAscending = true; @@ -43,7 +43,7 @@ class _PlasmaListState extends State { return InfiniteScrollTable( disposeBloc: false, bloc: bloc, - headerColumns: [ + headerColumns: [ InfiniteScrollTableHeaderColumn( columnName: 'Amount', onSortArrowsPressed: _onSortArrowsPressed, @@ -57,15 +57,15 @@ class _PlasmaListState extends State { columnName: 'Expiration', ), ], - generateRowCells: (plasmaItem, bool isSelected) { - return [ + generateRowCells: (FusionEntry plasmaItem, bool isSelected) { + return [ InfiniteScrollTableCell( FormattedAmountWithTooltip( amount: plasmaItem.qsrAmount.addDecimals( kQsrCoin.decimals, ), tokenSymbol: kQsrCoin.symbol, - builder: (formattedAmount, tokenSymbol) => Text( + builder: (String formattedAmount, String tokenSymbol) => Text( '$formattedAmount $tokenSymbol', style: Theme.of(context).textTheme.titleMedium!.copyWith( color: AppColors.subtitleColor, @@ -94,7 +94,7 @@ class _PlasmaListState extends State { ) { return Stack( alignment: Alignment.centerLeft, - children: [ + children: [ if (plasmaItem.isRevocable!) _getCancelButtonViewModel(plasmaModel, isSelected, plasmaItem) else _getCancelCountdownTimer(plasmaItem, plasmaModel), ], ); @@ -105,12 +105,12 @@ class _PlasmaListState extends State { bool isSelected, FusionEntry plasmaItem, ) { - final cancelButtonKey = GlobalKey(); + final GlobalKey cancelButtonKey = GlobalKey(); return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (CancelPlasmaBloc model) { model.stream.listen( - (event) { + (AccountBlockTemplate? event) { if (event != null) { cancelButtonKey.currentState?.animateReverse(); plasmaModel.refreshResults(); @@ -123,7 +123,7 @@ class _PlasmaListState extends State { }, ); }, - builder: (_, model, __) => _getCancelButton( + builder: (_, CancelPlasmaBloc model, __) => _getCancelButton( model, plasmaItem.id.toString(), cancelButtonKey, @@ -160,20 +160,20 @@ class _PlasmaListState extends State { switch (columnName) { case 'Amount': _sortAscending - ? _stakingList.sort((a, b) => a.qsrAmount.compareTo(b.qsrAmount)) - : _stakingList.sort((a, b) => b.qsrAmount.compareTo(a.qsrAmount)); + ? _stakingList.sort((FusionEntry a, FusionEntry b) => a.qsrAmount.compareTo(b.qsrAmount)) + : _stakingList.sort((FusionEntry a, FusionEntry b) => b.qsrAmount.compareTo(a.qsrAmount)); case 'Beneficiary': _sortAscending ? _stakingList - .sort((a, b) => a.beneficiary.compareTo(b.beneficiary)) + .sort((FusionEntry a, FusionEntry b) => a.beneficiary.compareTo(b.beneficiary)) : _stakingList - .sort((a, b) => b.beneficiary.compareTo(a.beneficiary)); + .sort((FusionEntry a, FusionEntry b) => b.beneficiary.compareTo(a.beneficiary)); default: _sortAscending ? _stakingList - .sort((a, b) => a.beneficiary.compareTo(b.beneficiary)) + .sort((FusionEntry a, FusionEntry b) => a.beneficiary.compareTo(b.beneficiary)) : _stakingList - .sort((a, b) => b.beneficiary.compareTo(a.beneficiary)); + .sort((FusionEntry a, FusionEntry b) => b.beneficiary.compareTo(a.beneficiary)); break; } @@ -190,10 +190,10 @@ class _PlasmaListState extends State { FusionEntry plasmaItem, PlasmaListBloc model, ) { - final heightUntilCancellation = + final int heightUntilCancellation = plasmaItem.expirationHeight - model.lastMomentumHeight!; - final durationUntilCancellation = + final Duration durationUntilCancellation = kIntervalBetweenMomentums * heightUntilCancellation; if (plasmaItem.isRevocable!) { diff --git a/lib/widgets/modular_widgets/plasma_widgets/plasma_options/plasma_options.dart b/lib/widgets/modular_widgets/plasma_widgets/plasma_options/plasma_options.dart index 219c5136..df5737fa 100644 --- a/lib/widgets/modular_widgets/plasma_widgets/plasma_options/plasma_options.dart +++ b/lib/widgets/modular_widgets/plasma_widgets/plasma_options/plasma_options.dart @@ -71,12 +71,12 @@ class _PlasmaOptionsState extends State { @override Widget build(BuildContext context) { return Consumer( - builder: (_, __, child) { + builder: (_, __, Widget? child) { _addressController.text = kSelectedAddress!; return child!; }, child: LayoutBuilder( - builder: (_, constraints) { + builder: (_, BoxConstraints constraints) { _maxWidth = constraints.maxWidth; return CardScaffold( title: 'Plasma Options', @@ -95,7 +95,7 @@ class _PlasmaOptionsState extends State { ? SyriusErrorWidget(widget.errorText!) : StreamBuilder?>( stream: sl.get().stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot?> snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } @@ -139,12 +139,12 @@ class _PlasmaOptionsState extends State { margin: EdgeInsets.all(_marginWidth), child: Row( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Expanded( flex: _beneficiaryAddressExpandedFlex, child: ListView( shrinkWrap: true, - children: [ + children: [ DisabledAddressField( _addressController, contentLeftPadding: 20, @@ -157,7 +157,7 @@ class _PlasmaOptionsState extends State { onChanged: (String value) { _beneficiaryAddressString.value = value; }, - inputFormatters: [ + inputFormatters: [ FilteringTextInputFormatter.allow(RegExp('[0-9a-z]')), ], controller: _beneficiaryAddressController, @@ -176,7 +176,7 @@ class _PlasmaOptionsState extends State { flex: _fuseButtonExpandedFlex, child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ + children: [ SizedBox( height: 87, child: Form( @@ -192,7 +192,7 @@ class _PlasmaOptionsState extends State { _qsrAmountController.text, ), controller: _qsrAmountController, - validator: (value) => InputValidators.correctValue( + validator: (String? value) => InputValidators.correctValue( value, _maxQsrAmount, kQsrCoin.decimals, @@ -209,12 +209,12 @@ class _PlasmaOptionsState extends State { valueListenable: _beneficiaryAddressString, builder: (_, __, ___) { return Row( - children: [ + children: [ _getGeneratePlasmaButtonStreamBuilder(), Visibility( visible: _isInputValid(), child: Row( - children: [ + children: [ const SizedBox( width: 10, ), @@ -237,7 +237,7 @@ class _PlasmaOptionsState extends State { PlasmaIcon _getPlasmaIcon() { return PlasmaIcon( PlasmaInfo.fromJson( - { + { 'currentPlasma': ((_qsrAmountController.text.isNotEmpty ? BigInt.parse(zenon!.embedded.plasma .getPlasmaByQsr(_qsrAmountController.text @@ -257,7 +257,7 @@ class _PlasmaOptionsState extends State { try { return widget.plasmaStatsResults .firstWhere( - (plasmaInfo) => + (PlasmaInfoWrapper plasmaInfo) => plasmaInfo.address == _beneficiaryAddressController.text, ) .plasmaInfo @@ -281,8 +281,8 @@ class _PlasmaOptionsState extends State { ), ); - final widthOfPlasmaIcon = _isInputValid() ? 20.0 : 0.0; - final plasmaIconMargin = _isInputValid() ? 10.0 : 0.0; + final double widthOfPlasmaIcon = _isInputValid() ? 20.0 : 0.0; + final double plasmaIconMargin = _isInputValid() ? 10.0 : 0.0; return LoadingButton.icon( onPressed: _isInputValid() ? () => _onGeneratePlasmaPressed(model) : null, @@ -330,9 +330,9 @@ class _PlasmaOptionsState extends State { Widget _getGeneratePlasmaButtonStreamBuilder() { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (PlasmaOptionsBloc model) { model.stream.listen( - (event) { + (AccountBlockTemplate? event) { if (event != null) { _fuseButtonKey.currentState?.animateReverse(); _qsrAmountKey.currentState?.reset(); @@ -341,7 +341,7 @@ class _PlasmaOptionsState extends State { widget.plasmaListBloc.refreshResults(); } }, - onError: (error) async { + onError: (Object error) async { _fuseButtonKey.currentState?.animateReverse(); await NotificationUtils.sendNotificationError( error, @@ -350,7 +350,7 @@ class _PlasmaOptionsState extends State { }, ); }, - builder: (_, model, __) => _getGeneratePlasmaButton(model), + builder: (_, PlasmaOptionsBloc model, __) => _getGeneratePlasmaButton(model), viewModelBuilder: PlasmaOptionsBloc.new, ); } diff --git a/lib/widgets/modular_widgets/sentinel_widgets/create_sentinel.dart b/lib/widgets/modular_widgets/sentinel_widgets/create_sentinel.dart index fed62bc1..138c9efc 100644 --- a/lib/widgets/modular_widgets/sentinel_widgets/create_sentinel.dart +++ b/lib/widgets/modular_widgets/sentinel_widgets/create_sentinel.dart @@ -36,7 +36,7 @@ class _CreateSentinelState extends State { Widget _getStreamBuilder(BuildContext context) { return StreamBuilder( stream: _getSentinelByOwnerBloc.stream, - builder: (context, snapshot) { + builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } @@ -56,7 +56,7 @@ class _CreateSentinelState extends State { return Center( child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text( 'Sentinel detected on this address', style: Theme.of(context).textTheme.bodyLarge, @@ -74,14 +74,14 @@ class _CreateSentinelState extends State { Row _getCreateSentinelWidgetBody(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ + children: [ Lottie.asset('assets/lottie/ic_anim_sentinel.json', repeat: false), SyriusElevatedButton( onPressed: () { Navigator.push( context, MaterialPageRoute( - builder: (context) => StepperScreen( + builder: (BuildContext context) => StepperScreen( stepper: const SentinelStepperContainer(), onStepperNotificationSeeMorePressed: widget.onStepperNotificationSeeMorePressed, diff --git a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_collect.dart b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_collect.dart index e80f93bc..61ba7c18 100644 --- a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_collect.dart +++ b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_collect.dart @@ -48,7 +48,7 @@ class _SentinelCollectState extends State { Widget _getFutureBuilder() { return StreamBuilder( stream: _sentinelCollectRewardsBloc.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } else if (snapshot.hasData) { @@ -66,7 +66,7 @@ class _SentinelCollectState extends State { Widget _getWidgetBody(UncollectedReward uncollectedReward) { return Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ NumberAnimation( end: uncollectedReward.znnAmount.addDecimals(coinDecimals).toNum(), after: ' ${kZnnCoin.symbol}', @@ -109,7 +109,7 @@ class _SentinelCollectState extends State { 'collect Sentinel rewards', waitForRequiredPlasma: true, ).then( - (response) async { + (AccountBlockTemplate response) async { await Future.delayed(kDelayAfterAccountBlockCreationCall); if (mounted) { _sentinelCollectRewardsBloc.updateStream(); diff --git a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_list_widget.dart b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_list_widget.dart index 2140e5de..cad4ac95 100644 --- a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_list_widget.dart +++ b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_list_widget.dart @@ -19,7 +19,7 @@ class SentinelListWidget extends StatefulWidget { class _SentinelListWidgetState extends State { late SentinelsListBloc _bloc; - final List _sentinels = []; + final List _sentinels = []; bool _sortAscending = true; @override @@ -40,7 +40,7 @@ class _SentinelListWidgetState extends State { Widget _getTable(SentinelsListBloc bloc) { return InfiniteScrollTable( bloc: _bloc, - headerColumns: [ + headerColumns: [ InfiniteScrollTableHeaderColumn( columnName: 'Sentinel Address', onSortArrowsPressed: _onSortArrowsPressed, @@ -52,8 +52,8 @@ class _SentinelListWidgetState extends State { columnName: '', ), ], - generateRowCells: (sentinelInfo, isSelected) { - return [ + generateRowCells: (SentinelInfo sentinelInfo, bool isSelected) { + return [ WidgetUtils.getTextAddressTableCell( sentinelInfo.owner, context, @@ -79,9 +79,9 @@ class _SentinelListWidgetState extends State { return Visibility( visible: isStakeAddressDefault(sentinelInfo), child: Stack( - children: [ + children: [ Row( - children: [ + children: [ if (sentinelInfo.isRevocable) CancelTimer( Duration( seconds: sentinelInfo.revokeCooldown, @@ -131,7 +131,7 @@ class _SentinelListWidgetState extends State { visible: sentinelInfo.isRevocable, child: Stack( alignment: Alignment.center, - children: [ + children: [ _getDisassembleButtonViewModel(isSelected, model, sentinelInfo), ], ), @@ -155,7 +155,7 @@ class _SentinelListWidgetState extends State { : null, child: Row( mainAxisSize: MainAxisSize.min, - children: [ + children: [ Text( 'DISASSEMBLE', style: isSelected @@ -183,13 +183,13 @@ class _SentinelListWidgetState extends State { switch (columnName) { case 'Sentinel Owner': _sortAscending - ? _sentinels.sort((a, b) => a.owner.compareTo(b.owner)) - : _sentinels.sort((a, b) => b.owner.compareTo(a.owner)); + ? _sentinels.sort((SentinelInfo a, SentinelInfo b) => a.owner.compareTo(b.owner)) + : _sentinels.sort((SentinelInfo a, SentinelInfo b) => b.owner.compareTo(a.owner)); case 'Registration time': _sortAscending - ? _sentinels.sort((a, b) => + ? _sentinels.sort((SentinelInfo a, SentinelInfo b) => a.registrationTimestamp.compareTo(b.registrationTimestamp),) - : _sentinels.sort((a, b) => + : _sentinels.sort((SentinelInfo a, SentinelInfo b) => b.registrationTimestamp.compareTo(a.registrationTimestamp),); case 'Reward Address': default: @@ -207,9 +207,9 @@ class _SentinelListWidgetState extends State { SentinelInfo sentinelInfo, ) { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (DisassembleButtonBloc model) { model.stream.listen( - (event) { + (AccountBlockTemplate? event) { if (event != null) { sentinelsModel.refreshResults(); } @@ -222,9 +222,9 @@ class _SentinelListWidgetState extends State { }, ); }, - builder: (_, model, __) => StreamBuilder( + builder: (_, DisassembleButtonBloc model, __) => StreamBuilder( stream: model.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return _getDisassembleButton(isSelected, model, sentinelInfo); } diff --git a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_rewards.dart b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_rewards.dart index 8b93214d..f7d8cb01 100644 --- a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_rewards.dart +++ b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_rewards.dart @@ -34,7 +34,7 @@ class _SentinelRewardsState extends State { Widget _getStreamBody() { return StreamBuilder( stream: widget.sentinelRewardsHistoryBloc.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } diff --git a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_stepper_container.dart b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_stepper_container.dart index d7d9567e..442592d7 100644 --- a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_stepper_container.dart +++ b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_stepper_container.dart @@ -72,7 +72,7 @@ class _MainSentinelState extends State { Widget build(BuildContext context) { return StreamBuilder?>( stream: sl.get().stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot?> snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } @@ -92,11 +92,11 @@ class _MainSentinelState extends State { Widget _getQsrManagementStep(BuildContext context, AccountInfo accountInfo) { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (SentinelsQsrInfoBloc model) { _sentinelsQsrInfoViewModel = model; model.getQsrManagementInfo(_addressController.text); model.stream.listen( - (event) { + (SentinelsQsrInfo? event) { if (event != null) { _maxQsrAmount = MathUtils.bigMin( accountInfo.getBalance( @@ -112,9 +112,9 @@ class _MainSentinelState extends State { }, ); }, - builder: (_, model, __) => StreamBuilder( + builder: (_, SentinelsQsrInfoBloc model, __) => StreamBuilder( stream: model.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasData) { return _getQsrManagementStepBody( context, @@ -141,14 +141,14 @@ class _MainSentinelState extends State { ) { return Row( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Row( children: [ Expanded( @@ -163,7 +163,7 @@ class _MainSentinelState extends State { padding: const EdgeInsets.only(left: 20), child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ AvailableBalance( kQsrCoin, accountInfo, @@ -180,7 +180,7 @@ class _MainSentinelState extends State { height: 10, ), Row( - children: [ + children: [ Expanded( child: Form( key: _qsrFormKey, @@ -191,7 +191,7 @@ class _MainSentinelState extends State { _qsrAmountController.text, ), controller: _qsrAmountController, - validator: (value) => InputValidators.correctValue( + validator: (String? value) => InputValidators.correctValue( value, _maxQsrAmount, kQsrCoin.decimals, @@ -201,7 +201,7 @@ class _MainSentinelState extends State { suffixIconConstraints: const BoxConstraints(maxWidth: 50), hintText: 'Amount', - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, ), @@ -221,7 +221,7 @@ class _MainSentinelState extends State { ], ), Row( - children: [ + children: [ Visibility( visible: qsrInfo.deposit < qsrInfo.cost, child: _getDepositQsrViewModel(accountInfo, qsrInfo), @@ -256,19 +256,19 @@ class _MainSentinelState extends State { padding: const EdgeInsets.symmetric(vertical: 30), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ + children: [ Column( - children: [ + children: [ Stack( alignment: Alignment.center, - children: [ + children: [ SizedBox( width: 150, height: 150, child: AspectRatio( aspectRatio: 1, child: StandardPieChart( - sections: [ + sections: [ PieChartSectionData( showTitle: false, radius: 7, @@ -298,7 +298,7 @@ class _MainSentinelState extends State { ], ), Column( - children: [ + children: [ SizedBox( width: 130, child: Text( @@ -327,9 +327,9 @@ class _MainSentinelState extends State { Widget _getDepositQsrViewModel( AccountInfo accountInfo, SentinelsQsrInfo qsrInfo,) { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (SentinelsDepositQsrBloc model) { model.stream.listen( - (response) { + (AccountBlockTemplate? response) { if (response != null) { _depositQsrButtonKey.currentState?.animateReverse(); _sentinelsQsrInfoViewModel.getQsrManagementInfo( @@ -350,7 +350,7 @@ class _MainSentinelState extends State { }, ); }, - builder: (_, model, __) => + builder: (_, SentinelsDepositQsrBloc model, __) => _getDepositQsrButton(model, accountInfo, qsrInfo), viewModelBuilder: SentinelsDepositQsrBloc.new, ); @@ -374,9 +374,9 @@ class _MainSentinelState extends State { Widget _getWithdrawQsrButtonViewModel(BigInt qsrDeposit) { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (SentinelsWithdrawQsrBloc model) { model.stream.listen( - (event) { + (AccountBlockTemplate? event) { if (event != null) { _withdrawButtonKey.currentState?.animateReverse(); _saveProgressAndNavigateToNextStep( @@ -396,7 +396,7 @@ class _MainSentinelState extends State { }, ); }, - builder: (_, model, __) => _getWithdrawQsrButton(model, qsrDeposit), + builder: (_, SentinelsWithdrawQsrBloc model, __) => _getWithdrawQsrButton(model, qsrDeposit), viewModelBuilder: SentinelsWithdrawQsrBloc.new, ); } @@ -426,7 +426,7 @@ class _MainSentinelState extends State { child: custom_material_stepper.Stepper( currentStep: _currentStep.index, onStepTapped: (int index) {}, - steps: [ + steps: [ StepperUtils.getMaterialStep( stepTitle: 'Sentinel deployment: Plasma check', stepContent: _getPlasmaCheckFutureBuilder(), @@ -486,7 +486,7 @@ class _MainSentinelState extends State { bottom: 25, ), child: Row( - children: [ + children: [ _getDeployButtonViewModel(), ], ), @@ -495,9 +495,9 @@ class _MainSentinelState extends State { Widget _getDeployButtonViewModel() { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (SentinelsDeployBloc model) { model.stream.listen( - (response) { + (AccountBlockTemplate? response) { if (response != null) { _registerButtonKey.currentState?.animateReverse(); _saveProgressAndNavigateToNextStep( @@ -517,7 +517,7 @@ class _MainSentinelState extends State { }, ); }, - builder: (_, model, __) => _getRegisterSentinelButton(model), + builder: (_, SentinelsDeployBloc model, __) => _getRegisterSentinelButton(model), viewModelBuilder: SentinelsDeployBloc.new, ); } @@ -536,7 +536,7 @@ class _MainSentinelState extends State { ) { return Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Row( children: [ Expanded( @@ -548,7 +548,7 @@ class _MainSentinelState extends State { StepperUtils.getBalanceWidget(kZnnCoin, accountInfo), kVerticalSpacing, Row( - children: [ + children: [ Expanded( child: InputField( enabled: false, @@ -623,15 +623,15 @@ class _MainSentinelState extends State { Widget _getWidgetBody(BuildContext context, AccountInfo accountInfo) { return Stack( - children: [ + children: [ ListView( - children: [ + children: [ _getMaterialStepper(context, accountInfo), Visibility( visible: _lastCompletedStep == SentinelStepperStep.deploySentinel, child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Container( padding: const EdgeInsets.symmetric( vertical: 40, @@ -653,7 +653,7 @@ class _MainSentinelState extends State { textAlign: TextAlign.center, text: TextSpan( style: Theme.of(context).textTheme.headlineSmall, - children: [ + children: [ TextSpan( text: 'Sentinel ', style: Theme.of(context).textTheme.headlineSmall, @@ -702,7 +702,7 @@ class _MainSentinelState extends State { ), Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ _getViewSentinelsButton(), ], ), @@ -779,7 +779,7 @@ class _MainSentinelState extends State { Widget _getPlasmaCheckFutureBuilder() { return FutureBuilder( future: zenon!.embedded.plasma.get(Address.parse(kSelectedAddress!)), - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } else if (snapshot.hasData) { @@ -796,7 +796,7 @@ class _MainSentinelState extends State { Widget _getPlasmaCheckBody(PlasmaInfo plasmaInfo) { return Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Text( 'More Plasma is required to perform complex transactions. Please fuse enough QSR before proceeding.', style: Theme.of(context).textTheme.headlineSmall, diff --git a/lib/widgets/modular_widgets/settings_widgets/account_chain_stats.dart b/lib/widgets/modular_widgets/settings_widgets/account_chain_stats.dart index 811d7968..ccf7e0a4 100644 --- a/lib/widgets/modular_widgets/settings_widgets/account_chain_stats.dart +++ b/lib/widgets/modular_widgets/settings_widgets/account_chain_stats.dart @@ -52,7 +52,7 @@ class _AccountChainStatsState extends State { ), Stack( alignment: Alignment.center, - children: [ + children: [ NumberAnimation( end: stats.blockCount, isInt: true, @@ -88,7 +88,7 @@ class _AccountChainStatsState extends State { ), ), Row( - children: [ + children: [ Expanded( child: Container( padding: const EdgeInsets.only( @@ -131,7 +131,7 @@ class _AccountChainStatsState extends State { AccountChainStats stats, BlockTypeEnum blockType, ) { - final blockTypeCount = stats.blockTypeNumOfBlocksMap[blockType]!; + final int blockTypeCount = stats.blockTypeNumOfBlocksMap[blockType]!; return PieChartSectionData( showTitle: false, @@ -144,7 +144,7 @@ class _AccountChainStatsState extends State { Widget _getStreamBuilder() { return StreamBuilder( stream: widget.accountChainStatsBloc.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } @@ -162,7 +162,7 @@ class _AccountChainStatsState extends State { List _getChartSections(AccountChainStats stats) => List.generate( BlockTypeEnum.values.length, - (index) => _getChartSection( + (int index) => _getChartSection( stats, BlockTypeEnum.values.elementAt(index), ), @@ -179,7 +179,7 @@ class _AccountChainStatsState extends State { ), child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text( '● ', style: Theme.of(context).textTheme.bodyMedium!.copyWith( @@ -203,14 +203,14 @@ class _AccountChainStatsState extends State { } Widget _getChartLegend(AccountChainStats stats) { - final typesWithBlocks = stats.blockTypeNumOfBlocksMap.keys - .where((key) => stats.blockTypeNumOfBlocksMap[key]! > 0) + final List typesWithBlocks = stats.blockTypeNumOfBlocksMap.keys + .where((BlockTypeEnum key) => stats.blockTypeNumOfBlocksMap[key]! > 0) .toList(); return ListView.builder( shrinkWrap: true, itemCount: typesWithBlocks.length, - itemBuilder: (context, index) => _getBlockTypeCountDetails( + itemBuilder: (BuildContext context, int index) => _getBlockTypeCountDetails( typesWithBlocks[index], stats.blockTypeNumOfBlocksMap[typesWithBlocks[index]], ), diff --git a/lib/widgets/modular_widgets/settings_widgets/addresses.dart b/lib/widgets/modular_widgets/settings_widgets/addresses.dart index ce6e80ca..f1a54d95 100644 --- a/lib/widgets/modular_widgets/settings_widgets/addresses.dart +++ b/lib/widgets/modular_widgets/settings_widgets/addresses.dart @@ -57,7 +57,7 @@ class AddressesState extends State { Future _changeDefaultAddress(String? newDefaultAddress) async { try { - final box = Hive.box(kSharedPrefsBox); + final Box box = Hive.box(kSharedPrefsBox); await box.put(kDefaultAddressKey, newDefaultAddress); if (!mounted) return; Provider.of( @@ -80,7 +80,7 @@ class AddressesState extends State { padding: const EdgeInsets.all(8), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ + children: [ Expanded( child: Container( padding: const EdgeInsets.symmetric(horizontal: 20), @@ -91,7 +91,7 @@ class AddressesState extends State { current: 1, min: 1, max: 10, - onUpdate: (val) { + onUpdate: (int val) { _onAddAddressPressedCallback(val); }, ), @@ -115,7 +115,7 @@ class AddressesState extends State { const BoxConstraints(minWidth: 150, minHeight: 50), alignment: Alignment.center, child: Row( - children: [ + children: [ const Icon( Icons.add_circle, color: AppColors.znnColor, @@ -140,8 +140,8 @@ class AddressesState extends State { Widget _getAddresses() { final List addresses = kDefaultAddressList .map( - (e) => Row( - children: [ + (String? e) => Row( + children: [ Radio( value: e, groupValue: _selectedAddress, @@ -163,7 +163,7 @@ class AddressesState extends State { key: const PageStorageKey('Addresses list view'), shrinkWrap: true, itemCount: addresses.length, - itemBuilder: (context, index) { + itemBuilder: (BuildContext context, int index) { return addresses[index]; }, ); @@ -189,7 +189,7 @@ class AddressesState extends State { Widget _getCardBody() { return Column( - children: [ + children: [ Expanded( child: _getAddresses(), ), @@ -202,10 +202,10 @@ class AddressesState extends State { Widget _getGenerateNewAddressFutureBuilder() { return FutureBuilder( future: _futureGenerateNewAddress, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); - } else if ([ + } else if ([ ConnectionState.none, ConnectionState.done, ].contains(snapshot.connectionState)) { @@ -219,10 +219,10 @@ class AddressesState extends State { Widget _getChangeDefaultAddressFutureBuilder() { return FutureBuilder( future: _futureChangeDefaultAddress, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); - } else if ([ + } else if ([ ConnectionState.none, ConnectionState.done, ].contains(snapshot.connectionState)) { diff --git a/lib/widgets/modular_widgets/settings_widgets/backup.dart b/lib/widgets/modular_widgets/settings_widgets/backup.dart index 5434926b..0eb4dd7b 100644 --- a/lib/widgets/modular_widgets/settings_widgets/backup.dart +++ b/lib/widgets/modular_widgets/settings_widgets/backup.dart @@ -47,8 +47,8 @@ class _BackupWidgetState extends State { Future _onBackupWalletPressed() async { kWalletFile! - .access((wallet) => Future.value((wallet as KeyStore).mnemonic!)) - .then((value) => NavigationUtils.push( + .access((Wallet wallet) => Future.value((wallet as KeyStore).mnemonic!)) + .then((String value) => NavigationUtils.push( context, ExportWalletInfoScreen( value, diff --git a/lib/widgets/modular_widgets/settings_widgets/display.dart b/lib/widgets/modular_widgets/settings_widgets/display.dart index 2646ff77..937c57d8 100644 --- a/lib/widgets/modular_widgets/settings_widgets/display.dart +++ b/lib/widgets/modular_widgets/settings_widgets/display.dart @@ -47,7 +47,7 @@ class _DisplayWidget extends State { Widget _getWidgetBody() { return ListView( shrinkWrap: true, - children: [ + children: [ CustomExpandablePanel('Text scaling', _getTextScalingExpandableChild()), CustomExpandablePanel('Locale', _getLocaleExpandableChild()), CustomExpandablePanel('Theme', _getThemeExpandableChild()), @@ -57,7 +57,7 @@ class _DisplayWidget extends State { Widget _getTextScalingExpandableChild() { return Column( - children: [ + children: [ _getTextScalingTiles(), _getConfirmScaleButton(), ], @@ -69,7 +69,7 @@ class _DisplayWidget extends State { crossAxisAlignment: CrossAxisAlignment.start, children: TextScaling.values .map( - (e) => _getListTile( + (TextScaling e) => _getListTile( FormatUtils.extractNameFromEnum(e), e, ), @@ -80,7 +80,7 @@ class _DisplayWidget extends State { Widget _getListTile(String text, T value) { return Row( - children: [ + children: [ Radio( materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, value: value, @@ -130,7 +130,7 @@ class _DisplayWidget extends State { crossAxisAlignment: CrossAxisAlignment.start, children: LocaleType.values .map( - (e) => _getListTile( + (LocaleType e) => _getListTile( FormatUtils.extractNameFromEnum(e), e, ), @@ -141,7 +141,7 @@ class _DisplayWidget extends State { Widget _getThemeExpandableChild() { return Column( - children: [ + children: [ _getThemeModeTiles(), _getConfirmThemeButton(), ], @@ -153,7 +153,7 @@ class _DisplayWidget extends State { crossAxisAlignment: CrossAxisAlignment.start, children: ThemeMode.values .map( - (e) => _getListTile( + (ThemeMode e) => _getListTile( FormatUtils.extractNameFromEnum(e), e, ), @@ -165,7 +165,7 @@ class _DisplayWidget extends State { Widget _getConfirmThemeButton() { return Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Padding( padding: const EdgeInsets.all(8), child: LoadingButton.settings( @@ -181,7 +181,7 @@ class _DisplayWidget extends State { Future _onConfirmThemeButtonPressed() async { try { _confirmThemeButtonKey.currentState!.animateForward(); - final currentThemeMode = Provider.of( + final ThemeMode? currentThemeMode = Provider.of( context, listen: false, ).currentThemeMode; @@ -213,7 +213,7 @@ class _DisplayWidget extends State { Widget _getConfirmScaleButton() { return Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Padding( padding: const EdgeInsets.all(8), child: LoadingButton.settings( @@ -230,7 +230,7 @@ class _DisplayWidget extends State { try { _confirmScaleButtonKey.currentState!.animateForward(); - final currentTextScaling = Provider.of( + final TextScaling? currentTextScaling = Provider.of( context, listen: false, ).currentTextScaling; diff --git a/lib/widgets/modular_widgets/settings_widgets/general.dart b/lib/widgets/modular_widgets/settings_widgets/general.dart index c5287c5a..26b6671d 100644 --- a/lib/widgets/modular_widgets/settings_widgets/general.dart +++ b/lib/widgets/modular_widgets/settings_widgets/general.dart @@ -85,7 +85,7 @@ class GeneralWidgetState extends State { ), Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ if (generalStats.networkInfo.peers.isNotEmpty) Text( 'Peers connected', style: Theme.of(context).textTheme.bodyMedium, @@ -162,7 +162,7 @@ class GeneralWidgetState extends State { ), ), Row( - children: [ + children: [ Expanded( child: Container( padding: const EdgeInsets.only( @@ -190,7 +190,7 @@ class GeneralWidgetState extends State { Widget _getStreamBuilder() { return StreamBuilder( stream: _generalStatsBloc!.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasData) { return _getNewBody(snapshot.data!); } else if (snapshot.hasError) { diff --git a/lib/widgets/modular_widgets/settings_widgets/node_management.dart b/lib/widgets/modular_widgets/settings_widgets/node_management.dart index e3b2d663..d5239314 100644 --- a/lib/widgets/modular_widgets/settings_widgets/node_management.dart +++ b/lib/widgets/modular_widgets/settings_widgets/node_management.dart @@ -80,7 +80,7 @@ class _NodeManagementState extends State { Widget _getWidgetBody() { return ListView( shrinkWrap: true, - children: [ + children: [ CustomExpandablePanel( 'Client chain identifier selection', _getChainIdSelectionExpandableChild(), @@ -99,7 +99,7 @@ class _NodeManagementState extends State { Widget _getNodeSelectionExpandableChild() { return Column( - children: [ + children: [ _getNodeTiles(), _getConfirmNodeSelectionButton(), ], @@ -109,7 +109,7 @@ class _NodeManagementState extends State { Row _getConfirmNodeSelectionButton() { return Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ LoadingButton.settings( text: 'Confirm node', onPressed: _onConfirmNodeButtonPressed, @@ -127,7 +127,7 @@ class _NodeManagementState extends State { try { _confirmNodeButtonKey.currentState?.animateForward(); - final isConnectionEstablished = + final bool isConnectionEstablished = await _establishConnectionToNode(_selectedNode); if (isConnectionEstablished) { kNodeChainId = await NodeUtils.getNodeChainIdentifier(); @@ -164,14 +164,14 @@ class _NodeManagementState extends State { } Future _establishConnectionToNode(String? url) async { - final targetUrl = url == kEmbeddedNode ? kLocalhostDefaultNodeUrl : url!; - var isConnectionEstablished = + final String targetUrl = url == kEmbeddedNode ? kLocalhostDefaultNodeUrl : url!; + bool isConnectionEstablished = await NodeUtils.establishConnectionToNode(targetUrl); if (url == kEmbeddedNode) { // Check if node is already running if (!isConnectionEstablished) { // Initialize local full node - await Isolate.spawn(EmbeddedNode.runNode, [''], + await Isolate.spawn(EmbeddedNode.runNode, [''], onExit: sl(instanceName: 'embeddedStoppedPort').sendPort,); kEmbeddedNodeRunning = true; @@ -192,14 +192,14 @@ class _NodeManagementState extends State { Widget _getAddNodeExpandableChild() { return Column( - children: [ + children: [ Form( key: _newNodeKey, autovalidateMode: AutovalidateMode.onUserInteraction, child: InputField( controller: _newNodeController, hintText: 'Node address with port', - onSubmitted: (value) { + onSubmitted: (String value) { if (_ifUserInputValid()) { _onAddNodePressed(); } @@ -226,7 +226,7 @@ class _NodeManagementState extends State { InputValidators.node(_newNodeController.text) == null; Future _onAddNodePressed() async { - if ([...kDbNodes, ...kDefaultCommunityNodes, ...kDefaultNodes] + if ([...kDbNodes, ...kDefaultCommunityNodes, ...kDefaultNodes] .contains(_newNodeController.text)) { await NotificationUtils.sendNotificationError( 'Node ${_newNodeController.text} already exists', @@ -266,11 +266,11 @@ class _NodeManagementState extends State { Row _getNodeTile(String node) { return Row( - children: [ + children: [ Radio( value: node, groupValue: _selectedNode, - onChanged: (value) { + onChanged: (String? value) { setState(() { _selectedNode = value; }); @@ -280,7 +280,7 @@ class _NodeManagementState extends State { child: SettingsNode( key: ValueKey(node), node: node, - onNodePressed: (value) { + onNodePressed: (String? value) { setState(() { _selectedNode = value; }); @@ -326,21 +326,21 @@ class _NodeManagementState extends State { Widget _getChainIdSelectionExpandableChild() { return Column( - children: [ + children: [ Row( - children: [ + children: [ Expanded( child: Form( key: _newChainIdKey, autovalidateMode: AutovalidateMode.onUserInteraction, child: InputField( - inputFormatters: [ + inputFormatters: [ FilteringTextInputFormatter.digitsOnly, ], controller: _newChainIdController, hintText: 'Current client chain identifier is ${getChainIdentifier()}', - onSubmitted: (value) async { + onSubmitted: (String value) async { if (_isChainIdSelectionInputIsValid()) { _onConfirmChainIdPressed(); } @@ -419,9 +419,9 @@ class _NodeManagementState extends State { } Future _checkForChainIdMismatch() async { - var match = false; - await zenon!.ledger.getFrontierMomentum().then((momentum) async { - final nodeChainId = momentum.chainIdentifier; + bool match = false; + await zenon!.ledger.getFrontierMomentum().then((Momentum momentum) async { + final int nodeChainId = momentum.chainIdentifier; if (nodeChainId != _currentChainId) { match = await _showChainIdWarningDialog(nodeChainId, _currentChainId); } else { diff --git a/lib/widgets/modular_widgets/settings_widgets/peers.dart b/lib/widgets/modular_widgets/settings_widgets/peers.dart index ca12b3bc..a607d9ab 100644 --- a/lib/widgets/modular_widgets/settings_widgets/peers.dart +++ b/lib/widgets/modular_widgets/settings_widgets/peers.dart @@ -36,7 +36,7 @@ class _PeersWidget extends State { Widget _getTable() { return CustomTable( items: _peers, - headerColumns: [ + headerColumns: [ CustomHeaderColumn( columnName: 'IP', onSortArrowsPressed: _onSortArrowsPressed, @@ -48,8 +48,8 @@ class _PeersWidget extends State { contentAlign: MainAxisAlignment.center, ), ], - generateRowCells: (peer, isSelected, {SentinelsListBloc? model}) { - return [ + generateRowCells: (Peer peer, bool isSelected, {SentinelsListBloc? model}) { + return [ CustomTableCell.withText(context, peer.ip), CustomTableCell.withMarquee( peer.publicKey, @@ -63,7 +63,7 @@ class _PeersWidget extends State { Widget _getStreamBuilder() { return StreamBuilder( stream: _peersBloc!.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasData) { _peers = snapshot.data!.peers; return _getTable(); @@ -79,16 +79,16 @@ class _PeersWidget extends State { switch (columnName) { case 'IP': _sortAscending - ? _peers!.sort((a, b) => a.ip.compareTo(b.ip)) - : _peers!.sort((a, b) => b.ip.compareTo(a.ip)); + ? _peers!.sort((Peer a, Peer b) => a.ip.compareTo(b.ip)) + : _peers!.sort((Peer a, Peer b) => b.ip.compareTo(a.ip)); case 'Public Key': _sortAscending - ? _peers!.sort((a, b) => a.publicKey.compareTo(b.publicKey)) - : _peers!.sort((a, b) => b.publicKey.compareTo(a.publicKey)); + ? _peers!.sort((Peer a, Peer b) => a.publicKey.compareTo(b.publicKey)) + : _peers!.sort((Peer a, Peer b) => b.publicKey.compareTo(a.publicKey)); default: _sortAscending - ? _peers!.sort((a, b) => a.ip.compareTo(b.ip)) - : _peers!.sort((a, b) => b.ip.compareTo(a.ip)); + ? _peers!.sort((Peer a, Peer b) => a.ip.compareTo(b.ip)) + : _peers!.sort((Peer a, Peer b) => b.ip.compareTo(a.ip)); break; } setState(() { diff --git a/lib/widgets/modular_widgets/settings_widgets/security.dart b/lib/widgets/modular_widgets/settings_widgets/security.dart index 99ece4dd..0b5e7b66 100644 --- a/lib/widgets/modular_widgets/settings_widgets/security.dart +++ b/lib/widgets/modular_widgets/settings_widgets/security.dart @@ -91,7 +91,7 @@ class _SecurityWidgetState extends State { Widget _getWidgetBody(BuildContext context) { return ListView( shrinkWrap: true, - children: [ + children: [ CustomExpandablePanel( 'Change password', _getChangePasswordExpandedWidget(), @@ -127,7 +127,7 @@ class _SecurityWidgetState extends State { Widget _getAutoLockSlider() { return Column( - children: [ + children: [ CustomSlider( description: 'Lock after $_autoLockWalletMinutes minutes of inactivity', @@ -147,7 +147,7 @@ class _SecurityWidgetState extends State { Widget _getAutoEraseSlider() { return Column( - children: [ + children: [ CustomSlider( description: 'Erase after ${_autoEraseWalletLimit!.toInt()} ' 'failed password attempts', @@ -240,7 +240,7 @@ class _SecurityWidgetState extends State { Widget _getSignExpandedWidget() { return Column( - children: [ + children: [ kVerticalSpacing, InputField( controller: _textToBeSignedController, @@ -265,7 +265,7 @@ class _SecurityWidgetState extends State { visible: _signedTextController.text.isNotEmpty, child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ const SizedBox( height: 10, ), @@ -274,7 +274,7 @@ class _SecurityWidgetState extends State { height: 10, ), Row( - children: [ + children: [ Expanded( child: InputField( enabled: false, @@ -292,7 +292,7 @@ class _SecurityWidgetState extends State { height: 10, ), Row( - children: [ + children: [ Expanded( child: InputField( enabled: false, @@ -312,7 +312,7 @@ class _SecurityWidgetState extends State { Future _onSignButtonPressed() async { try { _signButtonKey.currentState?.animateForward(); - final signature = await walletSign( + final Signature signature = await walletSign( _textToBeSignedController.text.codeUnits, ); setState(() { @@ -328,10 +328,10 @@ class _SecurityWidgetState extends State { Widget _getVerifyExpandedWidget() { return Column( - children: [ + children: [ kVerticalSpacing, InputField( - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, controller: _textToBeVerifiedController, @@ -362,7 +362,7 @@ class _SecurityWidgetState extends State { ), kVerticalSpacing, InputField( - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, controller: _signatureController, @@ -393,7 +393,7 @@ class _SecurityWidgetState extends State { ), kVerticalSpacing, InputField( - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, controller: _publicKeyToBeFilledController, @@ -439,7 +439,7 @@ class _SecurityWidgetState extends State { Future _onVerifyButtonPressed() async { try { _verifyButtonKey.currentState?.animateForward(); - final verified = await Crypto.verify( + final bool verified = await Crypto.verify( FormatUtils.decodeHexString(_signatureController.text), Uint8List.fromList(_textToBeVerifiedController.text.codeUnits), FormatUtils.decodeHexString(_publicKeyToBeFilledController.text), @@ -482,7 +482,7 @@ class _SecurityWidgetState extends State { Widget _getSignFileExpandedWidget() { return Column( - children: [ + children: [ SelectFileWidget( onPathFoundCallback: (String path) { setState(() { @@ -495,7 +495,7 @@ class _SecurityWidgetState extends State { Visibility( visible: _toBeSignedFilePath != null, child: Column( - children: [ + children: [ kVerticalSpacing, LoadingButton.settings( key: _signFileButtonKey, @@ -509,12 +509,12 @@ class _SecurityWidgetState extends State { visible: _fileHashController.text.isNotEmpty, child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ kVerticalSpacing, const Text('Signed hash:'), kVerticalSpacing, Row( - children: [ + children: [ Expanded( child: InputField( enabled: false, @@ -528,7 +528,7 @@ class _SecurityWidgetState extends State { const Text('Public key:'), kVerticalSpacing, Row( - children: [ + children: [ Expanded( child: InputField( enabled: false, @@ -548,10 +548,10 @@ class _SecurityWidgetState extends State { Future _onSignFileButtonPressed() async { try { _signFileButtonKey.currentState?.animateForward(); - final droppedFile = File( + final File droppedFile = File( _toBeSignedFilePath!, ); - final fileSignature = await walletSign(Crypto.digest( + final Signature fileSignature = await walletSign(Crypto.digest( await droppedFile.readAsBytes(), ),); setState(() { @@ -569,7 +569,7 @@ class _SecurityWidgetState extends State { Widget _getVerifyFileExpandedWidget() { return Column( - children: [ + children: [ SelectFileWidget( onPathFoundCallback: (String path) { setState(() { @@ -582,7 +582,7 @@ class _SecurityWidgetState extends State { Visibility( visible: _toBeVerifiedFilePath != null, child: Column( - children: [ + children: [ kVerticalSpacing, LoadingButton.settings( key: _verifyFileButtonKey, @@ -596,10 +596,10 @@ class _SecurityWidgetState extends State { ), ), Column( - children: [ + children: [ kVerticalSpacing, InputField( - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, controller: _fileHashVerifyController, @@ -630,7 +630,7 @@ class _SecurityWidgetState extends State { ), kVerticalSpacing, InputField( - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, controller: _publicKeyVerifyFileController, @@ -669,7 +669,7 @@ class _SecurityWidgetState extends State { Future _onVerifyFileButtonPressed() async { try { _verifyFileButtonKey.currentState?.animateForward(); - final verified = await Crypto.verify( + final bool verified = await Crypto.verify( FormatUtils.decodeHexString(_fileHashVerifyController.text), Uint8List.fromList(Crypto.digest(await File( _toBeVerifiedFilePath!, diff --git a/lib/widgets/modular_widgets/settings_widgets/wallet_options.dart b/lib/widgets/modular_widgets/settings_widgets/wallet_options.dart index 5cf76f89..584e6344 100644 --- a/lib/widgets/modular_widgets/settings_widgets/wallet_options.dart +++ b/lib/widgets/modular_widgets/settings_widgets/wallet_options.dart @@ -57,7 +57,7 @@ class _WalletOptionsState extends State { Widget _getWidgetBody() { return ListView( shrinkWrap: true, - children: [ + children: [ CustomExpandablePanel('Delete cache', _getDeleteCacheExpandedWidget()), CustomExpandablePanel('Reset wallet', _getResetWalletExpandedWidget()), CustomExpandablePanel('Preferences', _getPreferencesExpandedWidget()), @@ -116,7 +116,7 @@ class _WalletOptionsState extends State { Widget _getPreferencesExpandedWidget() { return Column( - children: [ + children: [ _getLaunchAtStartupWidget(), _getEnableDesktopNotifications(), _buildEnableClipboardWatcher(), @@ -127,13 +127,13 @@ class _WalletOptionsState extends State { Widget _getLaunchAtStartupWidget() { return Row( - children: [ + children: [ Text( 'Launch at startup ', style: Theme.of(context).textTheme.bodyMedium, ), SyriusCheckbox( - onChanged: (value) async { + onChanged: (bool? value) async { setState(() { _launchAtStartup = value; }); @@ -148,17 +148,17 @@ class _WalletOptionsState extends State { Widget _getAutoReceiveWidget() { return Row( - children: [ + children: [ Text( 'Auto-receiver', style: Theme.of(context).textTheme.bodyMedium, ), SyriusCheckbox( - onChanged: (value) async { + onChanged: (bool? value) async { if (value == true) { NodeUtils.getUnreceivedTransactions().then((value) { sl().autoReceive(); - }).onError((error, stackTrace) { + }).onError((Object? error, StackTrace stackTrace) { Logger('MainAppContainer').log( Level.WARNING, '_getAutoReceiveWidget', error, stackTrace,); }); @@ -183,7 +183,7 @@ class _WalletOptionsState extends State { } Future _setupLaunchAtStartup() async { - final packageInfo = await PackageInfo.fromPlatform(); + final PackageInfo packageInfo = await PackageInfo.fromPlatform(); launchAtStartup.setup( appName: packageInfo.appName, appPath: Platform.resolvedExecutable, @@ -260,13 +260,13 @@ class _WalletOptionsState extends State { Widget _getEnableDesktopNotifications() { return Row( - children: [ + children: [ Text( 'Enable desktop notifications ', style: Theme.of(context).textTheme.bodyMedium, ), SyriusCheckbox( - onChanged: (value) { + onChanged: (bool? value) { setState(() { _enableDesktopNotifications = value; _changeEnableDesktopNotificationsStatus(value ?? false); @@ -281,13 +281,13 @@ class _WalletOptionsState extends State { Widget _buildEnableClipboardWatcher() { return Row( - children: [ + children: [ Text( 'Enable clipboard watcher', style: Theme.of(context).textTheme.bodyMedium, ), SyriusCheckbox( - onChanged: (value) { + onChanged: (bool? value) { setState(() { _enabledClipboardWatcher = value; _changeEnableClipboardWatcherStatus(value ?? false); diff --git a/lib/widgets/modular_widgets/staking_widgets/stake_collect.dart b/lib/widgets/modular_widgets/staking_widgets/stake_collect.dart index 5c550d75..d5cebe5b 100644 --- a/lib/widgets/modular_widgets/staking_widgets/stake_collect.dart +++ b/lib/widgets/modular_widgets/staking_widgets/stake_collect.dart @@ -45,7 +45,7 @@ class _StakeCollectState extends State { Widget _getFutureBuilder() { return StreamBuilder( stream: _stakingUncollectedRewardsBloc.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } else if (snapshot.hasData) { @@ -62,7 +62,7 @@ class _StakeCollectState extends State { Widget _getWidgetBody(UncollectedReward uncollectedReward) { return Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ NumberAnimation( end: uncollectedReward.qsrAmount.addDecimals(coinDecimals).toNum(), after: ' ${kQsrCoin.symbol}', @@ -95,7 +95,7 @@ class _StakeCollectState extends State { 'collect staking rewards', waitForRequiredPlasma: true, ).then( - (response) async { + (AccountBlockTemplate response) async { await Future.delayed(kDelayAfterAccountBlockCreationCall); if (mounted) { _stakingUncollectedRewardsBloc.updateStream(); diff --git a/lib/widgets/modular_widgets/staking_widgets/staking_list/staking_list.dart b/lib/widgets/modular_widgets/staking_widgets/staking_list/staking_list.dart index 0aef875a..5f26ff73 100644 --- a/lib/widgets/modular_widgets/staking_widgets/staking_list/staking_list.dart +++ b/lib/widgets/modular_widgets/staking_widgets/staking_list/staking_list.dart @@ -21,7 +21,7 @@ class StakingList extends StatefulWidget { } class _StakingListState extends State { - final List _stakingList = []; + final List _stakingList = []; bool _sortAscending = true; @@ -42,7 +42,7 @@ class _StakingListState extends State { // This bloc is being used in another place, so it shouldn't be disposed // when this widget is disposed itself disposeBloc: false, - headerColumns: [ + headerColumns: [ InfiniteScrollTableHeaderColumn( columnName: 'Amount', onSortArrowsPressed: _onSortArrowsPressed, @@ -62,15 +62,15 @@ class _StakingListState extends State { ), const InfiniteScrollTableHeaderColumn(columnName: ''), ], - generateRowCells: (stakingItem, bool isSelected) { - return [ + generateRowCells: (StakeEntry stakingItem, bool isSelected) { + return [ InfiniteScrollTableCell( FormattedAmountWithTooltip( amount: stakingItem.amount.addDecimals( kZnnCoin.decimals, ), tokenSymbol: kZnnCoin.symbol, - builder: (formattedAmount, tokenSymbol) => Text( + builder: (String formattedAmount, String tokenSymbol) => Text( '$formattedAmount $tokenSymbol', style: Theme.of(context).textTheme.titleMedium!.copyWith( color: AppColors.subtitleColor, @@ -105,7 +105,7 @@ class _StakingListState extends State { ) { return Stack( alignment: Alignment.centerLeft, - children: [ + children: [ if (stakingItem.expirationTimestamp * 1000 < DateTime.now().millisecondsSinceEpoch) _getCancelButtonViewModel( stakingListModel, @@ -121,12 +121,12 @@ class _StakingListState extends State { bool isSelected, String stakeHash, ) { - final cancelButtonKey = GlobalKey(); + final GlobalKey cancelButtonKey = GlobalKey(); return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (CancelStakeBloc model) { model.stream.listen( - (event) { + (AccountBlockTemplate? event) { if (event != null) { cancelButtonKey.currentState?.animateReverse(); bloc.refreshResults(); @@ -141,7 +141,7 @@ class _StakingListState extends State { }, ); }, - builder: (_, model, __) => _getCancelButton( + builder: (_, CancelStakeBloc model, __) => _getCancelButton( model, stakeHash, cancelButtonKey, @@ -178,32 +178,32 @@ class _StakingListState extends State { switch (columnName) { case 'Amount': _sortAscending - ? _stakingList.sort((a, b) => a.amount.compareTo(b.amount)) - : _stakingList.sort((a, b) => b.amount.compareTo(a.amount)); + ? _stakingList.sort((StakeEntry a, StakeEntry b) => a.amount.compareTo(b.amount)) + : _stakingList.sort((StakeEntry a, StakeEntry b) => b.amount.compareTo(a.amount)); case 'Staking duration': _sortAscending ? _stakingList.sort( - (a, b) => (a.expirationTimestamp - a.startTimestamp) + (StakeEntry a, StakeEntry b) => (a.expirationTimestamp - a.startTimestamp) .compareTo(b.expirationTimestamp - b.startTimestamp), ) : _stakingList.sort( - (a, b) => (b.expirationTimestamp - b.startTimestamp) + (StakeEntry a, StakeEntry b) => (b.expirationTimestamp - b.startTimestamp) .compareTo(a.expirationTimestamp - a.startTimestamp), ); case 'Recipient': _sortAscending - ? _stakingList.sort((a, b) => a.address.compareTo(b.address)) - : _stakingList.sort((a, b) => b.address.compareTo(a.address)); + ? _stakingList.sort((StakeEntry a, StakeEntry b) => a.address.compareTo(b.address)) + : _stakingList.sort((StakeEntry a, StakeEntry b) => b.address.compareTo(a.address)); case 'Expiration': _sortAscending - ? _stakingList.sort((a, b) => + ? _stakingList.sort((StakeEntry a, StakeEntry b) => a.expirationTimestamp.compareTo(b.expirationTimestamp),) - : _stakingList.sort((a, b) => + : _stakingList.sort((StakeEntry a, StakeEntry b) => b.expirationTimestamp.compareTo(a.expirationTimestamp),); default: _sortAscending - ? _stakingList.sort((a, b) => a.address.compareTo(b.address)) - : _stakingList.sort((a, b) => b.address.compareTo(a.address)); + ? _stakingList.sort((StakeEntry a, StakeEntry b) => a.address.compareTo(b.address)) + : _stakingList.sort((StakeEntry a, StakeEntry b) => b.address.compareTo(a.address)); break; } @@ -216,7 +216,7 @@ class _StakingListState extends State { StakeEntry stakingItem, StakingListBloc model, ) { - final secondsUntilExpiration = stakingItem.expirationTimestamp - + final int secondsUntilExpiration = stakingItem.expirationTimestamp - DateTime.now().millisecondsSinceEpoch ~/ 1000; return CancelTimer( Duration(seconds: secondsUntilExpiration), @@ -228,8 +228,8 @@ class _StakingListState extends State { } String _getStakingDurationInMonths(int seconds) { - final numDays = seconds / 3600 ~/ 24; - final numMonths = numDays ~/ 30; + final int numDays = seconds / 3600 ~/ 24; + final int numMonths = numDays ~/ 30; return '$numMonths month${numMonths > 1 ? 's' : ''}'; } diff --git a/lib/widgets/modular_widgets/staking_widgets/staking_options/staking_options.dart b/lib/widgets/modular_widgets/staking_widgets/staking_options/staking_options.dart index d658ecd5..1313b650 100644 --- a/lib/widgets/modular_widgets/staking_widgets/staking_options/staking_options.dart +++ b/lib/widgets/modular_widgets/staking_widgets/staking_options/staking_options.dart @@ -33,7 +33,7 @@ class _StakingOptionsState extends State { final List _durations = List.generate( stakeTimeMaxSec ~/ stakeTimeUnitSec, - (index) => Duration( + (int index) => Duration( seconds: (index + 1) * stakeTimeUnitSec, ),); @@ -58,7 +58,7 @@ class _StakingOptionsState extends State { _addressController.text = kSelectedAddress!; return LayoutBuilder( - builder: (_, constraints) { + builder: (_, BoxConstraints constraints) { _maxWidth = constraints.maxWidth; return CardScaffold( title: 'Staking Options', @@ -68,7 +68,7 @@ class _StakingOptionsState extends State { '${kQsrCoin.symbol}', childBuilder: () => StreamBuilder?>( stream: sl.get().stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot?> snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } @@ -99,7 +99,7 @@ class _StakingOptionsState extends State { ), child: ListView( shrinkWrap: true, - children: [ + children: [ DisabledAddressField( _addressController, contentLeftPadding: 20, @@ -125,7 +125,7 @@ class _StakingOptionsState extends State { _znnAmountController.text, ), controller: _znnAmountController, - validator: (value) => InputValidators.correctValue( + validator: (String? value) => InputValidators.correctValue( value, _maxZnnAmount, kZnnCoin.decimals, @@ -140,7 +140,7 @@ class _StakingOptionsState extends State { kVerticalSpacing, Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ _getStakeForQsrViewModel(), ], ), @@ -151,9 +151,9 @@ class _StakingOptionsState extends State { Widget _getStakeForQsrViewModel() { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (StakingOptionsBloc model) { model.stream.listen( - (event) { + (AccountBlockTemplate? event) { if (event != null) { _stakeButtonKey.currentState?.animateReverse(); widget.stakingListViewModel!.refreshResults(); @@ -173,7 +173,7 @@ class _StakingOptionsState extends State { }, ); }, - builder: (_, model, __) => _getStakeForQsrButton(model), + builder: (_, StakingOptionsBloc model, __) => _getStakeForQsrButton(model), viewModelBuilder: StakingOptionsBloc.new, ); } @@ -219,7 +219,7 @@ class _StakingOptionsState extends State { value: _selectedStakeDuration, items: _durations .map( - (duration) => DropdownMenuItem( + (Duration duration) => DropdownMenuItem( value: duration, child: Text( '${duration.inSeconds ~/ stakeTimeUnitSec} $stakeUnitDurationName' @@ -234,7 +234,7 @@ class _StakingOptionsState extends State { ), ) .toList(), - onChanged: (value) { + onChanged: (Duration? value) { setState(() { _selectedStakeDuration = value; }); diff --git a/lib/widgets/modular_widgets/staking_widgets/staking_rewards.dart b/lib/widgets/modular_widgets/staking_widgets/staking_rewards.dart index 67dac5f4..ddb7c539 100644 --- a/lib/widgets/modular_widgets/staking_widgets/staking_rewards.dart +++ b/lib/widgets/modular_widgets/staking_widgets/staking_rewards.dart @@ -36,7 +36,7 @@ class _StakingRewardsState extends State { Widget _getStreamBody() { return StreamBuilder( stream: widget.stakingRewardsHistoryBloc.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } diff --git a/lib/widgets/modular_widgets/token_widgets/create_token.dart b/lib/widgets/modular_widgets/token_widgets/create_token.dart index e4719034..8dd1dba2 100644 --- a/lib/widgets/modular_widgets/token_widgets/create_token.dart +++ b/lib/widgets/modular_widgets/token_widgets/create_token.dart @@ -31,7 +31,7 @@ class _CreateTokenState extends State { Widget _getWidgetBody() { return Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Lottie.asset( 'assets/lottie/ic_anim_zts.json', width: 128, @@ -45,7 +45,7 @@ class _CreateTokenState extends State { Navigator.push( context, MaterialPageRoute( - builder: (context) => StepperScreen( + builder: (BuildContext context) => StepperScreen( stepper: const TokenStepper(), onStepperNotificationSeeMorePressed: widget.onStepperNotificationSeeMorePressed, diff --git a/lib/widgets/modular_widgets/token_widgets/token_balance.dart b/lib/widgets/modular_widgets/token_widgets/token_balance.dart index ba1d9ef7..58d185c6 100644 --- a/lib/widgets/modular_widgets/token_widgets/token_balance.dart +++ b/lib/widgets/modular_widgets/token_widgets/token_balance.dart @@ -16,7 +16,7 @@ class TokenBalance extends StatefulWidget { } class _TokenBalanceState extends State { - List _newTokenIds = []; + List _newTokenIds = []; @override void initState() { @@ -29,9 +29,9 @@ class _TokenBalanceState extends State { _newTokenIds.clear(); } _newTokenIds = accountInfo.balanceInfoList!.fold( - [], - (previousValue, element) { - if (![kZnnCoin.tokenStandard, kQsrCoin.tokenStandard] + [], + (List previousValue, BalanceInfoListItem element) { + if (![kZnnCoin.tokenStandard, kQsrCoin.tokenStandard] .contains(element.token!.tokenStandard)) { previousValue.add(element); } @@ -48,7 +48,7 @@ class _TokenBalanceState extends State { 'currently hold in your wallet', childBuilder: () => StreamBuilder?>( stream: sl.get().stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot?> snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } @@ -72,7 +72,7 @@ class _TokenBalanceState extends State { Widget _getWidgetBody(AccountInfo? accountInfo) { return Column( - children: [ + children: [ kVerticalSpacing, Expanded(child: _getNewTokensGridViewStatus(accountInfo)), ], @@ -81,7 +81,7 @@ class _TokenBalanceState extends State { Widget _getTokenStatus(String formattedAmount, String tokenSymbol) { return Row( - children: [ + children: [ Text( '$formattedAmount $tokenSymbol', style: Theme.of(context).textTheme.bodyLarge, @@ -100,7 +100,7 @@ class _TokenBalanceState extends State { crossAxisSpacing: 10, mainAxisSpacing: 10, ), - itemBuilder: (context, index) => Padding( + itemBuilder: (BuildContext context, int index) => Padding( padding: const EdgeInsets.all(8), child: Marquee( child: FormattedAmountWithTooltip( @@ -108,9 +108,9 @@ class _TokenBalanceState extends State { .balance! .addDecimals(_newTokenIds[index].token!.decimals), tokenSymbol: _newTokenIds[index].token!.symbol, - builder: (amount, symbol) => Row( + builder: (String amount, String symbol) => Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text( '● ', style: Theme.of(context).textTheme.bodyLarge!.copyWith( diff --git a/lib/widgets/modular_widgets/token_widgets/token_card.dart b/lib/widgets/modular_widgets/token_widgets/token_card.dart index 3949f23f..1a9375c7 100644 --- a/lib/widgets/modular_widgets/token_widgets/token_card.dart +++ b/lib/widgets/modular_widgets/token_widgets/token_card.dart @@ -97,7 +97,7 @@ class _TokenCardState extends State { ), child: StreamBuilder?>( stream: sl.get().stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot?> snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } @@ -125,9 +125,9 @@ class _TokenCardState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Row( - children: [ + children: [ Container( height: 5, width: 5, @@ -152,13 +152,13 @@ class _TokenCardState extends State { ], ), Row( - children: [ + children: [ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Row( - children: [ + children: [ Expanded( child: Marquee( child: Text( @@ -178,7 +178,7 @@ class _TokenCardState extends State { height: 5, ), Wrap( - children: [ + children: [ if (kDefaultAddressList .contains(widget.token.owner.toString())) _getTokenOptionIconButton( @@ -258,9 +258,9 @@ class _TokenCardState extends State { ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ Row( - children: [ + children: [ Text( kDefaultAddressList.contains(widget.token.owner.toString()) ? kAddressLabelMap[widget.token.owner.toString()]! @@ -339,18 +339,18 @@ class _TokenCardState extends State { } Widget _getAnimatedChart(Token token) { - final totalSupply = token.totalSupply; + final BigInt totalSupply = token.totalSupply; - final maxSupply = token.maxSupply; + final BigInt maxSupply = token.maxSupply; return Stack( alignment: Alignment.center, - children: [ + children: [ SizedBox( height: 100, width: 100, child: StandardPieChart( - sections: [ + sections: [ PieChartSectionData( showTitle: false, radius: 5, @@ -372,7 +372,7 @@ class _TokenCardState extends State { child: FormattedAmountWithTooltip( amount: totalSupply.addDecimals(token.decimals), tokenSymbol: token.symbol, - builder: (formattedAmount, tokenSymbol) => Text( + builder: (String formattedAmount, String tokenSymbol) => Text( '$formattedAmount $tokenSymbol', style: Theme.of(context).textTheme.bodyMedium, textAlign: TextAlign.center, @@ -391,7 +391,7 @@ class _TokenCardState extends State { return ListView( shrinkWrap: true, - children: [ + children: [ Form( key: _burnAmountKey, autovalidateMode: AutovalidateMode.onUserInteraction, @@ -403,7 +403,7 @@ class _TokenCardState extends State { _burnAmountController.text, ), controller: _burnAmountController, - validator: (value) => InputValidators.correctValue( + validator: (String? value) => InputValidators.correctValue( value, _burnMaxAmount, widget.token.decimals, BigInt.zero,), suffixIcon: _getAmountSuffix(), suffixIconConstraints: const BoxConstraints(maxWidth: 50), @@ -415,9 +415,9 @@ class _TokenCardState extends State { Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Column( - children: [ + children: [ _getBurnButtonViewModel(), const SizedBox( height: 10, @@ -436,9 +436,9 @@ class _TokenCardState extends State { Widget _getBurnButtonViewModel() { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (BurnTokenBloc model) { model.stream.listen( - (event) { + (AccountBlockTemplate event) { setState(() { _burnAmountKey.currentState?.reset(); _burnAmountController.clear(); @@ -456,7 +456,7 @@ class _TokenCardState extends State { }, ); }, - builder: (_, model, __) => _getBurnButton(model), + builder: (_, BurnTokenBloc model, __) => _getBurnButton(model), viewModelBuilder: BurnTokenBloc.new, ); } @@ -500,7 +500,7 @@ class _TokenCardState extends State { Widget _getAmountSuffix() { return Row( - children: [ + children: [ AmountSuffixMaxWidget( onPressed: _onMaxPressed, context: context, @@ -532,15 +532,15 @@ class _TokenCardState extends State { return ListView( shrinkWrap: true, - children: [ + children: [ Form( key: _beneficiaryAddressKey, autovalidateMode: AutovalidateMode.onUserInteraction, child: InputField( - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, - inputFormatters: [ + inputFormatters: [ FilteringTextInputFormatter.allow(RegExp('[0-9a-z]')), ], controller: _beneficiaryAddressController, @@ -554,14 +554,14 @@ class _TokenCardState extends State { key: _mintAmountKey, autovalidateMode: AutovalidateMode.onUserInteraction, child: InputField( - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, inputFormatters: FormatUtils.getAmountTextInputFormatters( _mintAmountController.text, ), controller: _mintAmountController, - validator: (value) => InputValidators.correctValue( + validator: (String? value) => InputValidators.correctValue( value, _mintMaxAmount, widget.token.decimals, BigInt.zero,), suffixIcon: _getAmountSuffix(), suffixIconConstraints: const BoxConstraints(maxWidth: 50), @@ -573,9 +573,9 @@ class _TokenCardState extends State { Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Column( - children: [ + children: [ _getMintButtonViewModel(), const SizedBox( height: 10, @@ -594,8 +594,8 @@ class _TokenCardState extends State { Widget _getMintButtonViewModel() { return ViewModelBuilder.reactive( - onViewModelReady: (model) { - model.stream.listen((event) { + onViewModelReady: (MintTokenBloc model) { + model.stream.listen((AccountBlockTemplate event) { setState(() { _beneficiaryAddressKey.currentState!.reset(); _mintAmountKey.currentState!.reset(); @@ -612,7 +612,7 @@ class _TokenCardState extends State { _mintButtonKey.currentState!.animateReverse(); },); }, - builder: (_, model, __) => _getMintButton(model), + builder: (_, MintTokenBloc model, __) => _getMintButton(model), viewModelBuilder: MintTokenBloc.new, ); } @@ -669,7 +669,7 @@ class _TokenCardState extends State { Widget _getTransferOwnershipBackOfCard() { return ListView( shrinkWrap: true, - children: [ + children: [ Form( key: _newOwnerAddressKey, autovalidateMode: AutovalidateMode.onUserInteraction, @@ -677,7 +677,7 @@ class _TokenCardState extends State { onChanged: (String value) { setState(() {}); }, - inputFormatters: [ + inputFormatters: [ FilteringTextInputFormatter.allow(RegExp('[0-9a-z]')), ], controller: _newOwnerAddressController, @@ -690,9 +690,9 @@ class _TokenCardState extends State { Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Column( - children: [ + children: [ _getTransferOwnershipButtonViewModel(), const SizedBox( height: 10, @@ -722,8 +722,8 @@ class _TokenCardState extends State { Widget _getTransferOwnershipButtonViewModel() { return ViewModelBuilder.reactive( - onViewModelReady: (model) { - model.stream.listen((event) { + onViewModelReady: (TransferOwnershipBloc model) { + model.stream.listen((AccountBlockTemplate event) { _sendTransferSuccessfulNotification(); if (mounted) { setState(() { @@ -740,9 +740,9 @@ class _TokenCardState extends State { ); },); }, - builder: (_, model, __) => StreamBuilder( + builder: (_, TransferOwnershipBloc model, __) => StreamBuilder( stream: model.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return _getTransferOwnershipButton(model); } diff --git a/lib/widgets/modular_widgets/token_widgets/token_favorite.dart b/lib/widgets/modular_widgets/token_widgets/token_favorite.dart index 24645beb..b7e41f8e 100644 --- a/lib/widgets/modular_widgets/token_widgets/token_favorite.dart +++ b/lib/widgets/modular_widgets/token_widgets/token_favorite.dart @@ -63,7 +63,7 @@ class _TokenFavoriteState extends State { _showLoading = true; }); _favoriteTokensBox.add(widget.token.tokenStandard.toString()).then( - (value) async { + (int value) async { await sl.get().addNotification( WalletNotification( title: '${widget.token.name} token has been added to favorites', diff --git a/lib/widgets/modular_widgets/token_widgets/token_map.dart b/lib/widgets/modular_widgets/token_widgets/token_map.dart index 57d88557..d423811d 100644 --- a/lib/widgets/modular_widgets/token_widgets/token_map.dart +++ b/lib/widgets/modular_widgets/token_widgets/token_map.dart @@ -42,14 +42,14 @@ class _TokenMapState extends State { const Duration(seconds: 1), ) .distinct() - .listen((text) { + .listen((String text) { _bloc.onSearchInputChangedSink.add(text); }); - _pagingController.addPageRequestListener((pageKey) { + _pagingController.addPageRequestListener((int pageKey) { _bloc.onPageRequestSink.add(pageKey); }); _blocListingStateSubscription = _bloc.onNewListingState.listen( - (listingState) { + (InfiniteScrollBlocListingState listingState) { _pagingController.value = PagingState( nextPageKey: listingState.nextPageKey, error: listingState.error, @@ -77,7 +77,7 @@ class _TokenMapState extends State { return Padding( padding: const EdgeInsets.all(15), child: Column( - children: [ + children: [ InputField( controller: _searchKeyWordController, hintText: 'Search token by symbol', @@ -101,7 +101,7 @@ class _TokenMapState extends State { crossAxisCount: 2, ), builderDelegate: PagedChildBuilderDelegate( - itemBuilder: (_, token, __) => TokenCard( + itemBuilder: (_, Token token, __) => TokenCard( token, () { bloc.refreshResults(); diff --git a/lib/widgets/modular_widgets/token_widgets/token_stepper.dart b/lib/widgets/modular_widgets/token_widgets/token_stepper.dart index e77efe72..860e55b4 100644 --- a/lib/widgets/modular_widgets/token_widgets/token_stepper.dart +++ b/lib/widgets/modular_widgets/token_widgets/token_stepper.dart @@ -92,7 +92,7 @@ class _TokenStepperState extends State { Widget build(BuildContext context) { return StreamBuilder?>( stream: sl.get().stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot?> snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } @@ -115,7 +115,7 @@ class _TokenStepperState extends State { actions: _actionMap, shortcuts: _shortcutMap, child: Column( - children: [ + children: [ Row( children: [ Expanded( @@ -124,7 +124,7 @@ class _TokenStepperState extends State { autovalidateMode: AutovalidateMode.onUserInteraction, child: InputField( thisNode: _focusNodes[0], - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, controller: _tokenNameController, @@ -137,14 +137,14 @@ class _TokenStepperState extends State { ), kVerticalSpacing, Row( - children: [ + children: [ Expanded( child: Form( key: _tokenSymbolKey, autovalidateMode: AutovalidateMode.onUserInteraction, child: InputField( thisNode: _focusNodes[1], - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, controller: _tokenSymbolController, @@ -161,7 +161,7 @@ class _TokenStepperState extends State { autovalidateMode: AutovalidateMode.onUserInteraction, child: InputField( thisNode: _focusNodes[2], - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, controller: _tokenDomainController, @@ -196,7 +196,7 @@ class _TokenStepperState extends State { activeColor: AppColors.ztsColor, currentStep: _currentStep.index, onStepTapped: (int index) {}, - steps: [ + steps: [ StepperUtils.getMaterialStep( stepTitle: 'Token creation: Plasma check', stepContent: _getPlasmaCheckFutureBuilder(), @@ -280,7 +280,7 @@ class _TokenStepperState extends State { Widget _getPlasmaCheckFutureBuilder() { return FutureBuilder( future: zenon!.embedded.plasma.get(Address.parse(kSelectedAddress!)), - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } else if (snapshot.hasData) { @@ -294,7 +294,7 @@ class _TokenStepperState extends State { Widget _getPlasmaCheckBody(PlasmaInfo plasmaInfo) { return Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Text( 'More Plasma is required to perform complex transactions. Please fuse enough QSR before proceeding.', style: Theme.of(context).textTheme.headlineSmall, @@ -345,13 +345,13 @@ class _TokenStepperState extends State { margin: const EdgeInsets.only(bottom: 25), child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Row( - children: [ + children: [ Checkbox( activeColor: AppColors.ztsColor, value: _isUtility, - onChanged: (value) { + onChanged: (bool? value) { setState(() { _isUtility = value!; }); @@ -387,13 +387,13 @@ class _TokenStepperState extends State { Padding( padding: const EdgeInsets.only(left: 15), child: Row( - children: [ + children: [ Visibility( visible: (_createButtonKey.currentState?.btnState ?? ButtonState.idle) == ButtonState.idle, child: Row( - children: [ + children: [ _getStepBackButton(), const SizedBox( width: 25, @@ -424,7 +424,7 @@ class _TokenStepperState extends State { AccountInfo accountInfo, ) { return Column( - children: [ + children: [ Padding( padding: const EdgeInsets.only(bottom: 20), child: CustomSlider( @@ -454,7 +454,7 @@ class _TokenStepperState extends State { inputFormatters: FormatUtils.getAmountTextInputFormatters( _maxSupplyController.text, ), - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, controller: _maxSupplyController, @@ -485,12 +485,12 @@ class _TokenStepperState extends State { inputFormatters: FormatUtils.getAmountTextInputFormatters( _totalSupplyController.text, ), - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, controller: _totalSupplyController, hintText: 'Total supply', - validator: (value) => InputValidators.correctValue( + validator: (String? value) => InputValidators.correctValue( value, _isMintable ? _maxSupplyController.text.isNotEmpty @@ -515,9 +515,9 @@ class _TokenStepperState extends State { Row _getTokenMetricsActionButtons() { return Row( - children: [ + children: [ Row( - children: [ + children: [ _getStepBackButton(), const SizedBox( width: 25, @@ -549,9 +549,9 @@ class _TokenStepperState extends State { Widget _getBody(BuildContext context, AccountInfo accountInfo) { return Stack( - children: [ + children: [ ListView( - children: [ + children: [ _getMaterialStepper(context, accountInfo), Padding( padding: const EdgeInsets.only( @@ -562,7 +562,7 @@ class _TokenStepperState extends State { visible: (_lastCompletedStep?.index ?? -1) == _numSteps - 1, child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ StepperButton.icon( label: 'Create another Token', onPressed: _onCreateAnotherTokenPressed, @@ -626,7 +626,7 @@ class _TokenStepperState extends State { Widget _getTokenCreationStepContent(AccountInfo accountInfo) { return Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Text( 'This will be your issuance address', style: Theme.of(context).textTheme.headlineSmall, @@ -703,9 +703,9 @@ class _TokenStepperState extends State { Widget _getIssueTokenViewModel() { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (IssueTokenBloc model) { model.stream.listen( - (response) { + (AccountBlockTemplate response) { _createButtonKey.currentState?.animateReverse(); _saveProgressAndNavigateToNextStep(TokenStepperStep.issueToken); }, @@ -718,7 +718,7 @@ class _TokenStepperState extends State { }, ); }, - builder: (_, model, __) => _getCreateButton(model), + builder: (_, IssueTokenBloc model, __) => _getCreateButton(model), viewModelBuilder: IssueTokenBloc.new, ); } @@ -737,7 +737,7 @@ class _TokenStepperState extends State { Widget _getTokenDetailsActionButtons() { return Row( - children: [ + children: [ _getStepBackButton(), const SizedBox( width: 25, @@ -802,13 +802,13 @@ class _TokenStepperState extends State { void _initFocusNodes(int length) => _focusNodes = List.generate( length, - (index) => FocusNode(), + (int index) => FocusNode(), ); void _changeFocusToNextNode() { - final indexOfFocusedNode = _focusNodes.indexOf( + final int indexOfFocusedNode = _focusNodes.indexOf( _focusNodes.firstWhere( - (node) => node.hasFocus, + (FocusNode node) => node.hasFocus, ), ); if (indexOfFocusedNode + 1 < _focusNodes.length) { @@ -820,16 +820,16 @@ class _TokenStepperState extends State { Widget _getTokenMintableAndBurnableStepContent() { return Column( - children: [ + children: [ Row( - children: [ + children: [ const SizedBox( width: 20, ), Checkbox( activeColor: AppColors.ztsColor, value: _isMintable, - onChanged: (value) { + onChanged: (bool? value) { setState(() { if (value! && _totalSupplyController.text.isNotEmpty) { _maxSupplyController.text = _totalSupplyController.text; @@ -850,14 +850,14 @@ class _TokenStepperState extends State { ], ), Row( - children: [ + children: [ const SizedBox( width: 20, ), Checkbox( activeColor: AppColors.ztsColor, value: _isBurnable, - onChanged: (value) { + onChanged: (bool? value) { setState(() { _isBurnable = value!; }); @@ -881,7 +881,7 @@ class _TokenStepperState extends State { ), kVerticalSpacing, Row( - children: [ + children: [ _getStepBackButton(), const SizedBox( width: 25, diff --git a/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions.dart b/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions.dart index 92733ff1..b096f034 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions.dart @@ -68,11 +68,11 @@ class _LatestTransactionsState extends State { bool isSelected, AccountBlock transactionBlock, ) { - final infoBlock = + final AccountBlock infoBlock = BlockUtils.isReceiveBlock(transactionBlock.blockType) ? transactionBlock.pairedAccountBlock! : transactionBlock; - return [ + return [ if (isSelected) WidgetUtils.getMarqueeAddressTableCell(infoBlock.address, context) else WidgetUtils.getTextAddressTableCell(infoBlock.address, context), if (isSelected) WidgetUtils.getMarqueeAddressTableCell(infoBlock.toAddress, context) else WidgetUtils.getTextAddressTableCell(infoBlock.toAddress, context), if (isSelected) InfiniteScrollTableCell.withMarquee(infoBlock.hash.toString(), @@ -91,7 +91,7 @@ class _LatestTransactionsState extends State { infoBlock.token?.decimals ?? 0, ), tokenSymbol: infoBlock.token?.symbol ?? '', - builder: (formattedAmount, tokenSymbol) => Text( + builder: (String formattedAmount, String tokenSymbol) => Text( formattedAmount, style: Theme.of(context).textTheme.titleMedium!.copyWith( color: AppColors.subtitleColor, @@ -121,7 +121,7 @@ class _LatestTransactionsState extends State { } List _getHeaderColumnsForTransferWidget() { - return [ + return [ InfiniteScrollTableHeaderColumn( columnName: 'Sender', onSortArrowsPressed: _onSortArrowsPressed, @@ -196,71 +196,71 @@ class _LatestTransactionsState extends State { case 'Sender': _sortAscending ? _transactions!.sort( - (a, b) => a.address.toString().compareTo( + (AccountBlock a, AccountBlock b) => a.address.toString().compareTo( b.address.toString(), ), ) : _transactions!.sort( - (a, b) => b.address.toString().compareTo( + (AccountBlock a, AccountBlock b) => b.address.toString().compareTo( a.address.toString(), ), ); case 'Receiver': _sortAscending ? _transactions!.sort( - (a, b) => a.toAddress.toString().compareTo( + (AccountBlock a, AccountBlock b) => a.toAddress.toString().compareTo( b.toAddress.toString(), ), ) - : _transactions!.sort((a, b) => + : _transactions!.sort((AccountBlock a, AccountBlock b) => b.toAddress.toString().compareTo(a.toAddress.toString()),); case 'Hash': _sortAscending ? _transactions!.sort( - (a, b) => a.hash.toString().compareTo( + (AccountBlock a, AccountBlock b) => a.hash.toString().compareTo( b.hash.toString(), ), ) : _transactions!.sort( - (a, b) => b.hash.toString().compareTo( + (AccountBlock a, AccountBlock b) => b.hash.toString().compareTo( a.hash.toString(), ), ); case 'Amount': _sortAscending - ? _transactions!.sort((a, b) => a.amount.compareTo(b.amount)) - : _transactions!.sort((a, b) => b.amount.compareTo(a.amount)); + ? _transactions!.sort((AccountBlock a, AccountBlock b) => a.amount.compareTo(b.amount)) + : _transactions!.sort((AccountBlock a, AccountBlock b) => b.amount.compareTo(a.amount)); case 'Date': _sortAscending ? _transactions!.sort( - (a, b) => a.confirmationDetail!.momentumTimestamp.compareTo( + (AccountBlock a, AccountBlock b) => a.confirmationDetail!.momentumTimestamp.compareTo( b.confirmationDetail!.momentumTimestamp, ),) : _transactions!.sort( - (a, b) => b.confirmationDetail!.momentumTimestamp.compareTo( + (AccountBlock a, AccountBlock b) => b.confirmationDetail!.momentumTimestamp.compareTo( a.confirmationDetail!.momentumTimestamp, ),); case 'Type': _sortAscending - ? _transactions!.sort((a, b) => a.blockType.compareTo(b.blockType)) - : _transactions!.sort((a, b) => b.blockType.compareTo(a.blockType)); + ? _transactions!.sort((AccountBlock a, AccountBlock b) => a.blockType.compareTo(b.blockType)) + : _transactions!.sort((AccountBlock a, AccountBlock b) => b.blockType.compareTo(a.blockType)); case 'Assets': _sortAscending ? _transactions!.sort( - (a, b) => a.token!.symbol.compareTo(b.token!.symbol), + (AccountBlock a, AccountBlock b) => a.token!.symbol.compareTo(b.token!.symbol), ) : _transactions!.sort( - (a, b) => b.token!.symbol.compareTo(a.token!.symbol), + (AccountBlock a, AccountBlock b) => b.token!.symbol.compareTo(a.token!.symbol), ); default: _sortAscending ? _transactions!.sort( - (a, b) => a.tokenStandard.toString().compareTo( + (AccountBlock a, AccountBlock b) => a.tokenStandard.toString().compareTo( b.tokenStandard.toString(), ), ) : _transactions!.sort( - (a, b) => b.tokenStandard.toString().compareTo( + (AccountBlock a, AccountBlock b) => b.tokenStandard.toString().compareTo( a.tokenStandard.toString(), ), ); @@ -279,7 +279,7 @@ class _LatestTransactionsState extends State { } List _getHeaderColumnsForDashboardWidget() { - return [ + return [ InfiniteScrollTableHeaderColumn( columnName: 'Sender', onSortArrowsPressed: _onSortArrowsPressed, @@ -308,12 +308,12 @@ class _LatestTransactionsState extends State { bool isSelected, AccountBlock transactionBlock, ) { - final infoBlock = + final AccountBlock infoBlock = BlockUtils.isReceiveBlock(transactionBlock.blockType) ? transactionBlock.pairedAccountBlock! : transactionBlock; - return [ + return [ if (isSelected) WidgetUtils.getMarqueeAddressTableCell(infoBlock.address, context) else WidgetUtils.getTextAddressTableCell(infoBlock.address, context), InfiniteScrollTableCell( Padding( @@ -326,7 +326,7 @@ class _LatestTransactionsState extends State { infoBlock.token?.decimals ?? 0, ), tokenSymbol: infoBlock.token?.symbol ?? '', - builder: (formattedAmount, tokenSymbol) => Text( + builder: (String formattedAmount, String tokenSymbol) => Text( formattedAmount, style: Theme.of(context).textTheme.titleMedium!.copyWith( color: AppColors.subtitleColor, diff --git a/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions_transfer_widget.dart b/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions_transfer_widget.dart index 424376d7..b60fec95 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions_transfer_widget.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions_transfer_widget.dart @@ -68,11 +68,11 @@ class _LatestTransactionsState extends State { bool isSelected, AccountBlock transactionBlock, ) { - final infoBlock = + final AccountBlock infoBlock = BlockUtils.isReceiveBlock(transactionBlock.blockType) ? transactionBlock.pairedAccountBlock! : transactionBlock; - return [ + return [ if (isSelected) WidgetUtils.getMarqueeAddressTableCell(infoBlock.address, context) else WidgetUtils.getTextAddressTableCell(infoBlock.address, context), if (isSelected) WidgetUtils.getMarqueeAddressTableCell(infoBlock.toAddress, context) else WidgetUtils.getTextAddressTableCell(infoBlock.toAddress, context), if (isSelected) InfiniteScrollTableCell.withMarquee(infoBlock.hash.toString(), @@ -91,7 +91,7 @@ class _LatestTransactionsState extends State { infoBlock.token?.decimals ?? 0, ), tokenSymbol: infoBlock.token?.symbol ?? '', - builder: (formattedAmount, tokenSymbol) => Text( + builder: (String formattedAmount, String tokenSymbol) => Text( formattedAmount, style: Theme.of(context).textTheme.titleMedium!.copyWith( color: AppColors.subtitleColor, @@ -115,7 +115,7 @@ class _LatestTransactionsState extends State { } List _getHeaderColumnsForTransferWidget() { - return [ + return [ InfiniteScrollTableHeaderColumn( columnName: 'Sender', onSortArrowsPressed: _onSortArrowsPressed, @@ -152,7 +152,7 @@ class _LatestTransactionsState extends State { } String _formatData(int transactionMillis) { - final currentMillis = DateTime.now().millisecondsSinceEpoch; + final int currentMillis = DateTime.now().millisecondsSinceEpoch; if (currentMillis - transactionMillis <= const Duration(days: 1).inMilliseconds) { return _formatDataShort(currentMillis - transactionMillis); @@ -161,7 +161,7 @@ class _LatestTransactionsState extends State { } String _formatDataShort(int i) { - final duration = Duration(milliseconds: i); + final Duration duration = Duration(milliseconds: i); if (duration.inHours > 0) { return '${duration.inHours} h ago'; } @@ -211,71 +211,71 @@ class _LatestTransactionsState extends State { case 'Sender': _sortAscending ? _transactions!.sort( - (a, b) => a.address.toString().compareTo( + (AccountBlock a, AccountBlock b) => a.address.toString().compareTo( b.address.toString(), ), ) : _transactions!.sort( - (a, b) => b.address.toString().compareTo( + (AccountBlock a, AccountBlock b) => b.address.toString().compareTo( a.address.toString(), ), ); case 'Receiver': _sortAscending ? _transactions!.sort( - (a, b) => a.toAddress.toString().compareTo( + (AccountBlock a, AccountBlock b) => a.toAddress.toString().compareTo( b.toAddress.toString(), ), ) - : _transactions!.sort((a, b) => + : _transactions!.sort((AccountBlock a, AccountBlock b) => b.toAddress.toString().compareTo(a.toAddress.toString()),); case 'Hash': _sortAscending ? _transactions!.sort( - (a, b) => a.hash.toString().compareTo( + (AccountBlock a, AccountBlock b) => a.hash.toString().compareTo( b.hash.toString(), ), ) : _transactions!.sort( - (a, b) => b.hash.toString().compareTo( + (AccountBlock a, AccountBlock b) => b.hash.toString().compareTo( a.hash.toString(), ), ); case 'Amount': _sortAscending - ? _transactions!.sort((a, b) => a.amount.compareTo(b.amount)) - : _transactions!.sort((a, b) => b.amount.compareTo(a.amount)); + ? _transactions!.sort((AccountBlock a, AccountBlock b) => a.amount.compareTo(b.amount)) + : _transactions!.sort((AccountBlock a, AccountBlock b) => b.amount.compareTo(a.amount)); case 'Date': _sortAscending ? _transactions!.sort( - (a, b) => a.confirmationDetail!.momentumTimestamp.compareTo( + (AccountBlock a, AccountBlock b) => a.confirmationDetail!.momentumTimestamp.compareTo( b.confirmationDetail!.momentumTimestamp, ),) : _transactions!.sort( - (a, b) => b.confirmationDetail!.momentumTimestamp.compareTo( + (AccountBlock a, AccountBlock b) => b.confirmationDetail!.momentumTimestamp.compareTo( a.confirmationDetail!.momentumTimestamp, ),); case 'Type': _sortAscending - ? _transactions!.sort((a, b) => a.blockType.compareTo(b.blockType)) - : _transactions!.sort((a, b) => b.blockType.compareTo(a.blockType)); + ? _transactions!.sort((AccountBlock a, AccountBlock b) => a.blockType.compareTo(b.blockType)) + : _transactions!.sort((AccountBlock a, AccountBlock b) => b.blockType.compareTo(a.blockType)); case 'Assets': _sortAscending ? _transactions!.sort( - (a, b) => a.token!.symbol.compareTo(b.token!.symbol), + (AccountBlock a, AccountBlock b) => a.token!.symbol.compareTo(b.token!.symbol), ) : _transactions!.sort( - (a, b) => b.token!.symbol.compareTo(a.token!.symbol), + (AccountBlock a, AccountBlock b) => b.token!.symbol.compareTo(a.token!.symbol), ); default: _sortAscending ? _transactions!.sort( - (a, b) => a.tokenStandard.toString().compareTo( + (AccountBlock a, AccountBlock b) => a.tokenStandard.toString().compareTo( b.tokenStandard.toString(), ), ) : _transactions!.sort( - (a, b) => b.tokenStandard.toString().compareTo( + (AccountBlock a, AccountBlock b) => b.tokenStandard.toString().compareTo( a.tokenStandard.toString(), ), ); @@ -294,7 +294,7 @@ class _LatestTransactionsState extends State { } List _getHeaderColumnsForDashboardWidget() { - return [ + return [ InfiniteScrollTableHeaderColumn( columnName: 'Sender', onSortArrowsPressed: _onSortArrowsPressed, @@ -324,12 +324,12 @@ class _LatestTransactionsState extends State { bool isSelected, AccountBlock transactionBlock, ) { - final infoBlock = + final AccountBlock infoBlock = BlockUtils.isReceiveBlock(transactionBlock.blockType) ? transactionBlock.pairedAccountBlock! : transactionBlock; - return [ + return [ if (isSelected) WidgetUtils.getMarqueeAddressTableCell(infoBlock.address, context) else WidgetUtils.getTextAddressTableCell(infoBlock.address, context), InfiniteScrollTableCell( Padding( @@ -342,7 +342,7 @@ class _LatestTransactionsState extends State { infoBlock.token?.decimals ?? 0, ), tokenSymbol: infoBlock.token?.symbol ?? '', - builder: (formattedAmount, tokenSymbol) => Text( + builder: (String formattedAmount, String tokenSymbol) => Text( formattedAmount, style: Theme.of(context).textTheme.titleMedium!.copyWith( color: AppColors.subtitleColor, diff --git a/lib/widgets/modular_widgets/transfer_widgets/pending_transactions/pending_transactions.dart b/lib/widgets/modular_widgets/transfer_widgets/pending_transactions/pending_transactions.dart index 60381cef..2bcd6102 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/pending_transactions/pending_transactions.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/pending_transactions/pending_transactions.dart @@ -54,10 +54,10 @@ class _PendingTransactionsState extends State { List _getCellsForPendingTransactions( bool isSelected, AccountBlock transaction,) { - final infoBlock = BlockUtils.isReceiveBlock(transaction.blockType) + final AccountBlock infoBlock = BlockUtils.isReceiveBlock(transaction.blockType) ? transaction.pairedAccountBlock! : transaction; - return [ + return [ if (isSelected) WidgetUtils.getMarqueeAddressTableCell(infoBlock.address, context) else WidgetUtils.getTextAddressTableCell(infoBlock.address, context), if (isSelected) WidgetUtils.getMarqueeAddressTableCell(infoBlock.toAddress, context) else WidgetUtils.getTextAddressTableCell(infoBlock.toAddress, context), if (isSelected) InfiniteScrollTableCell.withMarquee(infoBlock.hash.toString(), @@ -76,7 +76,7 @@ class _PendingTransactionsState extends State { infoBlock.token?.decimals ?? 0, ), tokenSymbol: infoBlock.token?.symbol ?? '', - builder: (formattedAmount, tokenSymbol) => Text( + builder: (String formattedAmount, String tokenSymbol) => Text( formattedAmount, style: Theme.of(context).textTheme.titleMedium!.copyWith( color: AppColors.subtitleColor, @@ -106,7 +106,7 @@ class _PendingTransactionsState extends State { List _getHeaderColumnsForPendingTransactions() { - return [ + return [ InfiniteScrollTableHeaderColumn( columnName: 'Sender', onSortArrowsPressed: _onSortArrowsPressed, @@ -145,67 +145,67 @@ class _PendingTransactionsState extends State { case 'Sender': _sortAscending ? _transactions!.sort( - (a, b) => a.address.toString().compareTo( + (AccountBlock a, AccountBlock b) => a.address.toString().compareTo( b.address.toString(), ), ) : _transactions!.sort( - (a, b) => b.address.toString().compareTo( + (AccountBlock a, AccountBlock b) => b.address.toString().compareTo( a.address.toString(), ), ); case 'Receiver': _sortAscending ? _transactions!.sort( - (a, b) => a.toAddress.toString().compareTo( + (AccountBlock a, AccountBlock b) => a.toAddress.toString().compareTo( b.toAddress.toString(), ), ) - : _transactions!.sort((a, b) => + : _transactions!.sort((AccountBlock a, AccountBlock b) => b.toAddress.toString().compareTo(a.toAddress.toString()),); case 'Hash': _sortAscending ? _transactions!.sort( - (a, b) => a.hash.toString().compareTo( + (AccountBlock a, AccountBlock b) => a.hash.toString().compareTo( b.hash.toString(), ), ) : _transactions!.sort( - (a, b) => b.hash.toString().compareTo( + (AccountBlock a, AccountBlock b) => b.hash.toString().compareTo( a.hash.toString(), ), ); case 'Amount': _sortAscending - ? _transactions!.sort((a, b) => a.amount.compareTo(b.amount)) - : _transactions!.sort((a, b) => b.amount.compareTo(a.amount)); + ? _transactions!.sort((AccountBlock a, AccountBlock b) => a.amount.compareTo(b.amount)) + : _transactions!.sort((AccountBlock a, AccountBlock b) => b.amount.compareTo(a.amount)); case 'Date': _sortAscending ? _transactions!.sort( - (a, b) => a.confirmationDetail!.momentumTimestamp.compareTo( + (AccountBlock a, AccountBlock b) => a.confirmationDetail!.momentumTimestamp.compareTo( b.confirmationDetail!.momentumTimestamp, ),) : _transactions!.sort( - (a, b) => b.confirmationDetail!.momentumTimestamp.compareTo( + (AccountBlock a, AccountBlock b) => b.confirmationDetail!.momentumTimestamp.compareTo( a.confirmationDetail!.momentumTimestamp, ),); case 'Assets': _sortAscending ? _transactions!.sort( - (a, b) => a.token!.symbol.compareTo(b.token!.symbol), + (AccountBlock a, AccountBlock b) => a.token!.symbol.compareTo(b.token!.symbol), ) : _transactions!.sort( - (a, b) => b.token!.symbol.compareTo(a.token!.symbol), + (AccountBlock a, AccountBlock b) => b.token!.symbol.compareTo(a.token!.symbol), ); default: _sortAscending ? _transactions!.sort( - (a, b) => a.tokenStandard.toString().compareTo( + (AccountBlock a, AccountBlock b) => a.tokenStandard.toString().compareTo( b.tokenStandard.toString(), ), ) : _transactions!.sort( - (a, b) => b.tokenStandard.toString().compareTo( + (AccountBlock a, AccountBlock b) => b.tokenStandard.toString().compareTo( a.tokenStandard.toString(), ), ); @@ -233,9 +233,9 @@ class _PendingTransactionsState extends State { AccountBlock transactionItem, ) { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (ReceiveTransactionBloc model) { model.stream.listen( - (event) { + (AccountBlockTemplate? event) { if (event != null) { transactionModel.refreshResults(); } @@ -246,7 +246,7 @@ class _PendingTransactionsState extends State { }, ); }, - builder: (_, model, __) => _getReceiveButton( + builder: (_, ReceiveTransactionBloc model, __) => _getReceiveButton( model, transactionItem.hash.toString(), ), diff --git a/lib/widgets/modular_widgets/transfer_widgets/receive/receive_large.dart b/lib/widgets/modular_widgets/transfer_widgets/receive/receive_large.dart index 99826b32..817f4401 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/receive/receive_large.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/receive/receive_large.dart @@ -35,7 +35,7 @@ class _ReceiveLargeCardState extends State { String? _selectedSelfAddress = kSelectedAddress; Token _selectedToken = kDualCoin.first; - final List _tokens = []; + final List _tokens = []; final Box _recipientAddressBox = Hive.box(kRecipientAddressBox); @@ -61,7 +61,7 @@ class _ReceiveLargeCardState extends State { Widget _getTokensStreamBuilder() { return StreamBuilder?>( stream: _tokensBloc.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot?> snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } @@ -126,12 +126,12 @@ class _ReceiveLargeCardState extends State { key: _amountKey, autovalidateMode: AutovalidateMode.onUserInteraction, child: InputField( - validator: (value) => InputValidators.correctValue( + validator: (String? value) => InputValidators.correctValue( value, kBigP255m1, _selectedToken.decimals, BigInt.zero,), - onChanged: (value) => setState(() {}), + onChanged: (String value) => setState(() {}), inputFormatters: FormatUtils.getAmountTextInputFormatters( _amountController.text, @@ -140,7 +140,7 @@ class _ReceiveLargeCardState extends State { suffixIcon: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.end, - children: [ + children: [ _getCoinDropdown(), const SizedBox( width: 15, @@ -195,7 +195,7 @@ class _ReceiveLargeCardState extends State { Widget _getDefaultAddressDropdown() { return AddressesDropdown( _selectedSelfAddress, - (value) => setState( + (String? value) => setState( () { _selectedToken = kDualCoin.first; _selectedSelfAddress = value; @@ -208,7 +208,7 @@ class _ReceiveLargeCardState extends State { Widget _getCoinDropdown() => CoinDropdown( _tokens, _selectedToken, - (value) { + (Token? value) { if (_selectedToken.tokenStandard != value!.tokenStandard) { setState( () { @@ -224,7 +224,7 @@ class _ReceiveLargeCardState extends State { _tokens.clear(); } _tokens.addAll(kDualCoin); - for (final element in tokens) { + for (final Token element in tokens) { if (!_tokens.contains(element)) { _tokens.add(element); } diff --git a/lib/widgets/modular_widgets/transfer_widgets/receive/receive_medium.dart b/lib/widgets/modular_widgets/transfer_widgets/receive/receive_medium.dart index 0017af27..ef6815c1 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/receive/receive_medium.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/receive/receive_medium.dart @@ -30,7 +30,7 @@ class _ReceiveMediumCardState extends State { Token _selectedToken = kDualCoin.first; - final List _tokens = []; + final List _tokens = []; final GlobalKey _amountKey = GlobalKey(); @@ -58,7 +58,7 @@ class _ReceiveMediumCardState extends State { Widget _getTokensStreamBuilder() { return StreamBuilder?>( stream: _tokensBloc.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot?> snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } @@ -107,7 +107,7 @@ class _ReceiveMediumCardState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( - children: [ + children: [ Expanded( child: _getDefaultAddressDropdown(), ), @@ -122,12 +122,12 @@ class _ReceiveMediumCardState extends State { key: _amountKey, autovalidateMode: AutovalidateMode.onUserInteraction, child: InputField( - validator: (value) => InputValidators.correctValue( + validator: (String? value) => InputValidators.correctValue( value, kBigP255m1, _selectedToken.decimals, BigInt.zero,), - onChanged: (value) => setState(() {}), + onChanged: (String value) => setState(() {}), inputFormatters: FormatUtils.getAmountTextInputFormatters( _amountController.text, @@ -136,7 +136,7 @@ class _ReceiveMediumCardState extends State { suffixIcon: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.end, - children: [ + children: [ _getCoinDropdown(), const SizedBox( width: 15, @@ -191,7 +191,7 @@ class _ReceiveMediumCardState extends State { Widget _getDefaultAddressDropdown() { return AddressesDropdown( _selectedSelfAddress, - (value) => setState(() { + (String? value) => setState(() { _selectedSelfAddress = value; }), ); @@ -200,7 +200,7 @@ class _ReceiveMediumCardState extends State { Widget _getCoinDropdown() => CoinDropdown( _tokens.toList(), _selectedToken, - (value) { + (Token? value) { if (_selectedToken != value) { setState( () { @@ -216,7 +216,7 @@ class _ReceiveMediumCardState extends State { _tokens.clear(); } _tokens.addAll(kDualCoin); - for (final element in tokens) { + for (final Token element in tokens) { if (!_tokens.contains(element)) { _tokens.add(element); } diff --git a/lib/widgets/modular_widgets/transfer_widgets/send/send_large.dart b/lib/widgets/modular_widgets/transfer_widgets/send/send_large.dart index 13f77e87..1fce39f7 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/send/send_large.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/send/send_large.dart @@ -41,7 +41,7 @@ class _SendLargeCardState extends State { final GlobalKey _sendPaymentButtonKey = GlobalKey(); - final List _tokensWithBalance = []; + final List _tokensWithBalance = []; Token _selectedToken = kDualCoin.first; @@ -67,7 +67,7 @@ class _SendLargeCardState extends State { Widget _getBalanceStreamBuilder() { return StreamBuilder?>( stream: sl.get().stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot?> snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } @@ -103,7 +103,7 @@ class _SendLargeCardState extends State { key: _recipientKey, autovalidateMode: AutovalidateMode.onUserInteraction, child: InputField( - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, controller: _recipientController, @@ -142,14 +142,14 @@ class _SendLargeCardState extends State { key: _amountKey, autovalidateMode: AutovalidateMode.onUserInteraction, child: InputField( - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, inputFormatters: FormatUtils.getAmountTextInputFormatters( _amountController.text, ), controller: _amountController, - validator: (value) => InputValidators.correctValue( + validator: (String? value) => InputValidators.correctValue( value, accountInfo.getBalance( _selectedToken.tokenStandard, @@ -195,7 +195,7 @@ class _SendLargeCardState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Padding( padding: const EdgeInsets.only( left: 10, @@ -239,7 +239,7 @@ class _SendLargeCardState extends State { return Row( mainAxisAlignment: MainAxisAlignment.end, mainAxisSize: MainAxisSize.min, - children: [ + children: [ _getCoinDropdown(), const SizedBox( width: 5, @@ -268,7 +268,7 @@ class _SendLargeCardState extends State { Widget _getDefaultAddressDropdown() { return AddressesDropdown( _selectedSelfAddress, - (value) => setState( + (String? value) => setState( () { _selectedSelfAddress = value; _selectedToken = kDualCoin.first; @@ -283,7 +283,7 @@ class _SendLargeCardState extends State { Widget _getCoinDropdown() => CoinDropdown( _tokensWithBalance, _selectedToken, - (value) { + (Token? value) { if (_selectedToken != value) { setState( () { @@ -295,7 +295,7 @@ class _SendLargeCardState extends State { ); void _onMaxPressed(AccountInfo accountInfo) { - final maxBalance = accountInfo.getBalance( + final BigInt maxBalance = accountInfo.getBalance( _selectedToken.tokenStandard, ); @@ -311,9 +311,9 @@ class _SendLargeCardState extends State { Widget _getSendPaymentViewModel(AccountInfo? accountInfo) { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (SendPaymentBloc model) { model.stream.listen( - (event) async { + (AccountBlockTemplate? event) async { if (event is AccountBlockTemplate) { await _sendConfirmationNotification(); setState(() { @@ -331,7 +331,7 @@ class _SendLargeCardState extends State { }, ); }, - builder: (_, model, __) => SendPaymentButton( + builder: (_, SendPaymentBloc model, __) => SendPaymentButton( onPressed: _hasBalance(accountInfo!) && _isInputValid(accountInfo) ? () => _onSendPaymentPressed(model) : null, @@ -371,7 +371,7 @@ class _SendLargeCardState extends State { BigInt.zero; void _addTokensWithBalance(AccountInfo accountInfo) { - for (final balanceInfo in accountInfo.balanceInfoList!) { + for (final BalanceInfoListItem balanceInfo in accountInfo.balanceInfoList!) { if (balanceInfo.balance! > BigInt.zero && !_tokensWithBalance.contains(balanceInfo.token)) { _tokensWithBalance.add(balanceInfo.token); diff --git a/lib/widgets/modular_widgets/transfer_widgets/send/send_medium.dart b/lib/widgets/modular_widgets/transfer_widgets/send/send_medium.dart index 97b0eb80..a6444467 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/send/send_medium.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/send/send_medium.dart @@ -37,7 +37,7 @@ class _SendMediumCardState extends State { Token _selectedToken = kDualCoin.first; - final List _tokensWithBalance = []; + final List _tokensWithBalance = []; final FocusNode _recipientFocusNode = FocusNode(); @@ -63,7 +63,7 @@ class _SendMediumCardState extends State { Widget _getBalanceStreamBuilder() { return StreamBuilder?>( stream: sl.get().stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot?> snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } @@ -99,7 +99,7 @@ class _SendMediumCardState extends State { key: _recipientKey, autovalidateMode: AutovalidateMode.onUserInteraction, child: InputField( - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, thisNode: _recipientFocusNode, @@ -134,13 +134,13 @@ class _SendMediumCardState extends State { key: _amountKey, autovalidateMode: AutovalidateMode.onUserInteraction, child: InputField( - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, inputFormatters: FormatUtils.getAmountTextInputFormatters( _amountController.text, ), - validator: (value) => InputValidators.correctValue( + validator: (String? value) => InputValidators.correctValue( value, accountInfo.getBalance( _selectedToken.tokenStandard, @@ -203,7 +203,7 @@ class _SendMediumCardState extends State { return Row( mainAxisAlignment: MainAxisAlignment.end, mainAxisSize: MainAxisSize.min, - children: [ + children: [ _getCoinDropdown(), const SizedBox( width: 5, @@ -222,7 +222,7 @@ class _SendMediumCardState extends State { Widget _getCoinDropdown() => CoinDropdown( _tokensWithBalance, _selectedToken, - (value) { + (Token? value) { if (_selectedToken != value) { setState( () { @@ -234,7 +234,7 @@ class _SendMediumCardState extends State { ); void _onMaxPressed(AccountInfo accountInfo) { - final maxBalance = accountInfo.getBalance( + final BigInt maxBalance = accountInfo.getBalance( _selectedToken.tokenStandard, ); @@ -251,9 +251,9 @@ class _SendMediumCardState extends State { Widget _getSendPaymentViewModel(AccountInfo? accountInfo) { return ViewModelBuilder.reactive( fireOnViewModelReadyOnce: true, - onViewModelReady: (model) { + onViewModelReady: (SendPaymentBloc model) { model.stream.listen( - (event) async { + (AccountBlockTemplate? event) async { if (event is AccountBlockTemplate) { await _sendConfirmationNotification(); setState(() { @@ -271,7 +271,7 @@ class _SendMediumCardState extends State { }, ); }, - builder: (_, model, __) => SendPaymentButton( + builder: (_, SendPaymentBloc model, __) => SendPaymentButton( onPressed: _hasBalance(accountInfo!) && _isInputValid(accountInfo) ? () => _onSendPaymentPressed(model) : null, @@ -309,7 +309,7 @@ class _SendMediumCardState extends State { BigInt.zero; void _addTokensWithBalance(AccountInfo accountInfo) { - for (final balanceInfo in accountInfo.balanceInfoList!) { + for (final BalanceInfoListItem balanceInfo in accountInfo.balanceInfoList!) { if (balanceInfo.balance! > BigInt.zero && !_tokensWithBalance.contains(balanceInfo.token)) { _tokensWithBalance.add(balanceInfo.token); diff --git a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_camera_card.dart b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_camera_card.dart index 7ec59ab2..6baa92f9 100644 --- a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_camera_card.dart +++ b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_camera_card.dart @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:logging/logging.dart'; import 'package:wallet_connect_uri_validator/wallet_connect_uri_validator.dart'; +import 'package:walletconnect_flutter_v2/apis/core/pairing/utils/pairing_models.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/services/i_web3wallet_service.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; @@ -43,7 +44,7 @@ class _WalletConnectCameraCardState extends State { padding: const EdgeInsets.all(15), child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ + children: [ const CircleAvatar( radius: 60, backgroundColor: Colors.white12, @@ -58,18 +59,18 @@ class _WalletConnectCameraCardState extends State { onPressed: () async { await Navigator.of(context).push( MaterialPageRoute( - builder: (context) => AiBarcodeScanner( - validator: (capture) => _filterBarcodes(capture) != null, - onDetect: (value) async { + builder: (BuildContext context) => AiBarcodeScanner( + validator: (BarcodeCapture capture) => _filterBarcodes(capture) != null, + onDetect: (BarcodeCapture value) async { Logger('WalletConnectCameraCard').log( Level.INFO, 'onDetect', value.toString(), ); - final wcService = sl.get(); - final barcode = _filterBarcodes(value); + final IWeb3WalletService wcService = sl.get(); + final Barcode? barcode = _filterBarcodes(value); if (barcode != null) { - final pairingInfo = await wcService.pair( + final PairingInfo pairingInfo = await wcService.pair( Uri.parse(value.barcodes.first.displayValue!), ); Logger('WalletConnectCameraCard').log( @@ -88,7 +89,7 @@ class _WalletConnectCameraCardState extends State { facing: CameraFacing.front, detectionSpeed: DetectionSpeed.noDuplicates, ), - errorBuilder: (p0, p1, p2) { + errorBuilder: (BuildContext p0, MobileScannerException p1, Widget? p2) { // Pop navigator and close camera after 10 seconds Timer(const Duration(seconds: 10), () { Navigator.pop(context); @@ -96,7 +97,7 @@ class _WalletConnectCameraCardState extends State { return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text('${p1.errorCode}', style: Theme.of(context) .textTheme @@ -142,8 +143,8 @@ class _WalletConnectCameraCardState extends State { /// A BarcodeCapture can contain multiple barcodes. This function returns /// the first valid WC barcode Barcode? _filterBarcodes(BarcodeCapture capture) { - for (final barcode in capture.barcodes) { - final uri = barcode.displayValue; + for (final Barcode barcode in capture.barcodes) { + final String? uri = barcode.displayValue; if (uri != null) { if (!canParseWalletConnectUri(uri)) { return barcode; diff --git a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_pairing_list_card.dart b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_pairing_list_card.dart index c876aff5..7be2bdb2 100644 --- a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_pairing_list_card.dart +++ b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_pairing_list_card.dart @@ -51,7 +51,7 @@ class _WalletConnectPairingsCardState extends State { return InfiniteScrollTable( disposeBloc: false, bloc: _pairingsBloc, - headerColumns: const [ + headerColumns: const [ InfiniteScrollTableHeaderColumn( columnName: 'Name', ), @@ -72,8 +72,8 @@ class _WalletConnectPairingsCardState extends State { columnName: '', ), ], - generateRowCells: (pairingInfo, bool isSelected) { - return [ + generateRowCells: (PairingInfo pairingInfo, bool isSelected) { + return [ InfiniteScrollTableCell.withText( context, pairingInfo.peerMetadata?.name ?? 'Empty', @@ -113,7 +113,7 @@ class _WalletConnectPairingsCardState extends State { Row _buildTableUrlWidget(PairingInfo pairingInfo) { return Row( - children: [ + children: [ Text(pairingInfo.peerMetadata?.url ?? 'Empty'), Visibility( visible: pairingInfo.peerMetadata?.url != null, @@ -126,7 +126,7 @@ class _WalletConnectPairingsCardState extends State { } String _formatExpiryDateTime(int expirySeconds) { - final expiryDateTime = + final DateTime expiryDateTime = DateTime.fromMillisecondsSinceEpoch(expirySeconds * 1000); return DateFormat('MMM dd, y HH:mm:ss').format(expiryDateTime); diff --git a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_qr_card.dart b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_qr_card.dart index cb8099e9..d41ffd09 100644 --- a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_qr_card.dart +++ b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_qr_card.dart @@ -7,6 +7,7 @@ import 'package:path/path.dart' as path; import 'package:pretty_qr_code/pretty_qr_code.dart'; import 'package:screen_capturer/screen_capturer.dart'; import 'package:wallet_connect_uri_validator/wallet_connect_uri_validator.dart'; +import 'package:walletconnect_flutter_v2/apis/core/pairing/utils/pairing_models.dart'; import 'package:window_manager/window_manager.dart'; import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; @@ -23,7 +24,7 @@ const String _kWidgetDescription = 'Scan the WalletConnect QR code using an on-screen QR scanner. ' 'This requires the screen recording permission'; -final screenCapturer = ScreenCapturer.instance; +final ScreenCapturer screenCapturer = ScreenCapturer.instance; class WalletConnectQrCard extends StatefulWidget { const WalletConnectQrCard({super.key}); @@ -38,7 +39,7 @@ class _WalletConnectQrCardState extends State { ); CapturedData? _lastCapturedData; - final _uriKey = GlobalKey(); + final GlobalKey _uriKey = GlobalKey(); @override Widget build(BuildContext context) { @@ -54,7 +55,7 @@ class _WalletConnectQrCardState extends State { padding: const EdgeInsets.all(15), child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ + children: [ Container( height: 130, width: 130, @@ -81,7 +82,7 @@ class _WalletConnectQrCardState extends State { MyOutlinedButton( text: 'Scan QR', onPressed: () { - checkPermissionForMacOS().then((value) { + checkPermissionForMacOS().then((bool value) { if (value) { windowManager.minimize().then( (value) => _handleClickCapture(CaptureMode.region), @@ -98,8 +99,8 @@ class _WalletConnectQrCardState extends State { Future _pairWithDapp(Uri uri) async { try { - final wcService = sl.get(); - final pairingInfo = await wcService.pair(uri); + final IWeb3WalletService wcService = sl.get(); + final PairingInfo pairingInfo = await wcService.pair(uri); Logger('WalletConnectPairingCard') .log(Level.INFO, 'pairing info', pairingInfo.toJson()); _uriController = TextEditingController(); @@ -112,17 +113,17 @@ class _WalletConnectQrCardState extends State { Future _handleClickCapture(CaptureMode mode) async { try { - final walletConnectDirectory = Directory( + final Directory walletConnectDirectory = Directory( path.join(znnDefaultPaths.cache.path, walletConnectDirName),); if (!walletConnectDirectory.existsSync()) { walletConnectDirectory.createSync(recursive: true); } - final screenshotName = + final String screenshotName = 'screenshot-${DateTime.now().millisecondsSinceEpoch}'; - final imagePath = await File( + final File imagePath = await File( '${walletConnectDirectory.absolute.path}${path.separator}$screenshotName.png',) .create(); @@ -132,14 +133,14 @@ class _WalletConnectQrCardState extends State { ); if (_lastCapturedData != null) { - final image = img.decodePng(imagePath.readAsBytesSync())!; + final img.Image image = img.decodePng(imagePath.readAsBytesSync())!; final LuminanceSource source = RGBLuminanceSource( image.width, image.height, image.getBytes().buffer.asInt32List(),); - final bitmap = BinaryBitmap(HybridBinarizer(source)); + final BinaryBitmap bitmap = BinaryBitmap(HybridBinarizer(source)); - final reader = QRCodeReader(); - final result = reader.decode(bitmap); + final QRCodeReader reader = QRCodeReader(); + final Result result = reader.decode(bitmap); if (result.rawBytes!.isNotEmpty) { if (result.text.isNotEmpty && @@ -194,7 +195,7 @@ class _WalletConnectQrCardState extends State { } Future _requestAccessForMacOS() async { - final isAccessAllowed = await ScreenCapturer.instance.isAccessAllowed(); + final bool isAccessAllowed = await ScreenCapturer.instance.isAccessAllowed(); if (!isAccessAllowed) { await ScreenCapturer.instance.requestAccess(); } diff --git a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_session_list_card.dart b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_session_list_card.dart index 2a990506..f8a3a013 100644 --- a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_session_list_card.dart +++ b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_session_list_card.dart @@ -42,7 +42,7 @@ class _WalletConnectSessionsCardState extends State { return InfiniteScrollTable( disposeBloc: false, bloc: _sessionsBloc, - headerColumns: const [ + headerColumns: const [ InfiniteScrollTableHeaderColumn( columnName: 'Name', ), @@ -63,8 +63,8 @@ class _WalletConnectSessionsCardState extends State { columnName: 'Acknowledged', ), ], - generateRowCells: (sessionData, bool isSelected) { - return [ + generateRowCells: (SessionData sessionData, bool isSelected) { + return [ InfiniteScrollTableCell.withText( context, sessionData.peer.metadata.name, @@ -100,7 +100,7 @@ class _WalletConnectSessionsCardState extends State { Row _buildTableUrlWidget(String? peerUrl) { return Row( - children: [ + children: [ Text(peerUrl ?? 'Empty'), Visibility( visible: peerUrl != null, @@ -113,7 +113,7 @@ class _WalletConnectSessionsCardState extends State { } String _formatExpiryDateTime(int expirySeconds) { - final expiryDateTime = + final DateTime expiryDateTime = DateTime.fromMillisecondsSinceEpoch(expirySeconds * 1000); return DateFormat('MMM dd, y HH:mm:ss').format(expiryDateTime); diff --git a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_uri_card.dart b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_uri_card.dart index 44aba894..bd3c23b7 100644 --- a/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_uri_card.dart +++ b/lib/widgets/modular_widgets/wallet_connect_widgets/wallet_connect_uri_card.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:logging/logging.dart'; import 'package:wallet_connect_uri_validator/wallet_connect_uri_validator.dart'; +import 'package:walletconnect_flutter_v2/apis/core/pairing/utils/pairing_models.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/services/i_web3wallet_service.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; @@ -21,7 +22,7 @@ class _WalletConnectUriCardState extends State { text: kLastWalletConnectUriNotifier.value, ); - final _uriKey = GlobalKey(); + final GlobalKey _uriKey = GlobalKey(); @override Widget build(BuildContext context) { @@ -36,19 +37,19 @@ class _WalletConnectUriCardState extends State { return Padding( padding: const EdgeInsets.all(15), child: ValueListenableBuilder( - builder: (_, value, child) { + builder: (_, String? value, Widget? child) { if (value != null) { _uriController.text = value; kLastWalletConnectUriNotifier.value = null; } return Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ + children: [ SizedBox( height: 120, child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ const CircleAvatar( backgroundColor: Colors.white12, child: Icon( @@ -60,14 +61,14 @@ class _WalletConnectUriCardState extends State { key: _uriKey, autovalidateMode: AutovalidateMode.onUserInteraction, child: InputField( - validator: (value) { + validator: (String? value) { if (WalletConnectUri.tryParse(value ?? '') != null) { return null; } else { return 'URI invalid'; } }, - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, controller: _uriController, @@ -118,7 +119,7 @@ class _WalletConnectUriCardState extends State { Future _pairWithDapp(Uri uri) async { try { - final pairingInfo = await sl.get().pair(uri); + final PairingInfo pairingInfo = await sl.get().pair(uri); Logger('WalletConnectPairingCard') .log(Level.INFO, 'pairing info', pairingInfo.toJson()); _uriController = TextEditingController(); diff --git a/lib/widgets/reusable_widgets/accelerator_project_details.dart b/lib/widgets/reusable_widgets/accelerator_project_details.dart index 87638178..b4a9d3bf 100644 --- a/lib/widgets/reusable_widgets/accelerator_project_details.dart +++ b/lib/widgets/reusable_widgets/accelerator_project_details.dart @@ -23,7 +23,7 @@ class AcceleratorProjectDetails extends StatelessWidget { @override Widget build(BuildContext context) { - final children = []; + final List children = []; if (owner != null) { children.add(Text( @@ -59,7 +59,7 @@ class AcceleratorProjectDetails extends StatelessWidget { return Row( children: children.zip(List.generate( children.length - 1, - (index) => Text( + (int index) => Text( ' ● ', style: Theme.of(context).inputDecorationTheme.hintStyle, ), @@ -68,7 +68,7 @@ class AcceleratorProjectDetails extends StatelessWidget { } String _formatData(int transactionMillis) { - final currentMillis = DateTime.now().millisecondsSinceEpoch; + final int currentMillis = DateTime.now().millisecondsSinceEpoch; if (currentMillis - transactionMillis <= const Duration( days: 1, @@ -79,7 +79,7 @@ class AcceleratorProjectDetails extends StatelessWidget { } String _formatDataShort(int i) { - final duration = Duration(milliseconds: i); + final Duration duration = Duration(milliseconds: i); if (duration.inHours > 0) { return '${duration.inHours} h ago'; } @@ -90,12 +90,12 @@ class AcceleratorProjectDetails extends StatelessWidget { } String _getTimeUntilVotingCloses() { - const prefix = 'Voting closes in '; - var suffix = ''; - final creationDate = + const String prefix = 'Voting closes in '; + String suffix = ''; + final DateTime creationDate = DateTime.fromMillisecondsSinceEpoch((creationTimestamp ?? 0) * 1000); - final votingEnds = creationDate.add(kProjectVotingPeriod); - final difference = votingEnds.difference(DateTime.now()); + final DateTime votingEnds = creationDate.add(kProjectVotingPeriod); + final Duration difference = votingEnds.difference(DateTime.now()); if (difference.isNegative) { return 'Voting closed'; } @@ -112,7 +112,7 @@ class AcceleratorProjectDetails extends StatelessWidget { } String _getOwnerDetails() { - var address = owner!.toShortString(); + String address = owner!.toShortString(); if (kDefaultAddressList.contains(owner.toString())) { address = kAddressLabelMap[owner.toString()]!; } diff --git a/lib/widgets/reusable_widgets/amount_info_column.dart b/lib/widgets/reusable_widgets/amount_info_column.dart index 321f844e..dbed24e7 100644 --- a/lib/widgets/reusable_widgets/amount_info_column.dart +++ b/lib/widgets/reusable_widgets/amount_info_column.dart @@ -5,7 +5,7 @@ class AmountInfoColumn extends Column { AmountInfoColumn({ required this.context, required this.amount, required this.tokenSymbol, super.key, }) : super( - children: [ + children: [ Text( tokenSymbol, style: Theme.of(context).textTheme.bodyLarge, diff --git a/lib/widgets/reusable_widgets/bullet_point_card.dart b/lib/widgets/reusable_widgets/bullet_point_card.dart index 8792351f..0876563c 100644 --- a/lib/widgets/reusable_widgets/bullet_point_card.dart +++ b/lib/widgets/reusable_widgets/bullet_point_card.dart @@ -29,8 +29,8 @@ class BulletPointCard extends StatelessWidget { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: bulletPoints - .map((e) => Row( - children: [ + .map((RichText e) => Row( + children: [ const Text('●', style: TextStyle( fontSize: 14, color: AppColors.subtitleColor,),), @@ -42,7 +42,7 @@ class BulletPointCard extends StatelessWidget { .zip( List.generate( bulletPoints.length - 1, - (index) => const SizedBox( + (int index) => const SizedBox( height: 15, ), ), diff --git a/lib/widgets/reusable_widgets/buttons/elevated_button.dart b/lib/widgets/reusable_widgets/buttons/elevated_button.dart index 53156092..8ff745a7 100644 --- a/lib/widgets/reusable_widgets/buttons/elevated_button.dart +++ b/lib/widgets/reusable_widgets/buttons/elevated_button.dart @@ -47,7 +47,7 @@ class _SyriusElevatedButtonState extends State { style: widget.style, child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Visibility( visible: widget.icon != null, child: Container( diff --git a/lib/widgets/reusable_widgets/buttons/loading_button.dart b/lib/widgets/reusable_widgets/buttons/loading_button.dart index ec3322bc..505fc82c 100644 --- a/lib/widgets/reusable_widgets/buttons/loading_button.dart +++ b/lib/widgets/reusable_widgets/buttons/loading_button.dart @@ -117,7 +117,7 @@ class LoadingButton extends StatefulWidget { child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ icon, SizedBox( width: label.isNotEmpty ? 10.0 : 0.0, @@ -184,7 +184,7 @@ class LoadingButtonState extends State ), ); - _animation.addStatusListener((status) { + _animation.addStatusListener((AnimationStatus status) { if (status == AnimationStatus.dismissed) { setState(() { btnState = ButtonState.idle; @@ -206,7 +206,7 @@ class LoadingButtonState extends State Widget build(BuildContext context) { return AnimatedBuilder( animation: _animationController, - builder: (context, child) { + builder: (BuildContext context, Widget? child) { return buttonBody(); }, ); diff --git a/lib/widgets/reusable_widgets/buttons/outlined_button.dart b/lib/widgets/reusable_widgets/buttons/outlined_button.dart index 1009656d..a33feeab 100644 --- a/lib/widgets/reusable_widgets/buttons/outlined_button.dart +++ b/lib/widgets/reusable_widgets/buttons/outlined_button.dart @@ -73,7 +73,7 @@ class MyOutlinedButtonState extends State { : null, ).copyWith( side: WidgetStateProperty.resolveWith( - (states) { + (Set states) { if (states.contains(WidgetState.disabled)) { return BorderSide( color: AppColors.lightSecondaryContainer, @@ -144,7 +144,7 @@ class _MyOutlinedButtonWithIconChild extends StatelessWidget { Widget build(BuildContext context) { return Row( mainAxisSize: MainAxisSize.min, - children: [ + children: [ icon, const SizedBox( width: 15, diff --git a/lib/widgets/reusable_widgets/buttons/stepper_button.dart b/lib/widgets/reusable_widgets/buttons/stepper_button.dart index 16a028d9..49b1a5d7 100644 --- a/lib/widgets/reusable_widgets/buttons/stepper_button.dart +++ b/lib/widgets/reusable_widgets/buttons/stepper_button.dart @@ -50,7 +50,7 @@ class _MyStepperButtonWithIconChild extends StatelessWidget { Widget build(BuildContext context) { return Row( mainAxisSize: MainAxisSize.min, - children: [ + children: [ Text(label), const SizedBox( width: 10, diff --git a/lib/widgets/reusable_widgets/buttons/transfer_toggle_card_size_button.dart b/lib/widgets/reusable_widgets/buttons/transfer_toggle_card_size_button.dart index 9b14128c..4679da9b 100644 --- a/lib/widgets/reusable_widgets/buttons/transfer_toggle_card_size_button.dart +++ b/lib/widgets/reusable_widgets/buttons/transfer_toggle_card_size_button.dart @@ -17,7 +17,7 @@ class TransferToggleCardSizeButton extends StatelessWidget { Widget build(BuildContext context) { return StreamBuilder( stream: sl.get().stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return _getButton(context, onPressed); } else if (snapshot.hasData) { diff --git a/lib/widgets/reusable_widgets/cancel_timer.dart b/lib/widgets/reusable_widgets/cancel_timer.dart index 4a64ca08..5b8f1d54 100644 --- a/lib/widgets/reusable_widgets/cancel_timer.dart +++ b/lib/widgets/reusable_widgets/cancel_timer.dart @@ -32,7 +32,7 @@ class _CancelTimerState extends State { const Duration( seconds: 1, ), - (v) { + (Timer v) { if (mounted && _currentDuration > const Duration( diff --git a/lib/widgets/reusable_widgets/chart/chart_legend.dart b/lib/widgets/reusable_widgets/chart/chart_legend.dart index b4620e37..59c2a39f 100644 --- a/lib/widgets/reusable_widgets/chart/chart_legend.dart +++ b/lib/widgets/reusable_widgets/chart/chart_legend.dart @@ -15,7 +15,7 @@ class ChartLegend extends StatelessWidget { @override Widget build(BuildContext context) { return Row( - children: [ + children: [ Text( '● ', style: Theme.of(context).textTheme.bodyLarge!.copyWith( diff --git a/lib/widgets/reusable_widgets/chart/standard_chart.dart b/lib/widgets/reusable_widgets/chart/standard_chart.dart index e95894f9..ec9f63c1 100644 --- a/lib/widgets/reusable_widgets/chart/standard_chart.dart +++ b/lib/widgets/reusable_widgets/chart/standard_chart.dart @@ -42,10 +42,10 @@ class StandardChart extends StatelessWidget { tooltipRoundedRadius: 6, getTooltipColor: (LineBarSpot lineBarSpot) => Theme.of(context).colorScheme.surface, - getTooltipItems: (touchedSpots) { + getTooltipItems: (List touchedSpots) { return touchedSpots.map( (LineBarSpot touchedSpot) { - final textStyle = TextStyle( + final TextStyle textStyle = TextStyle( color: touchedSpot.bar.color, fontWeight: FontWeight.bold, fontSize: 14, @@ -67,14 +67,14 @@ class StandardChart extends StatelessWidget { return const FlLine( strokeWidth: 1, color: Colors.black87, - dashArray: [3, 3], + dashArray: [3, 3], ); }, ), titlesData: FlTitlesData( bottomTitles: AxisTitles( sideTitles: SideTitles( - getTitlesWidget: (value, titleMeta) => Padding( + getTitlesWidget: (double value, TitleMeta titleMeta) => Padding( padding: const EdgeInsets.only(top: 8), child: Text( FormatUtils.formatDate( @@ -93,7 +93,7 @@ class StandardChart extends StatelessWidget { sideTitles: SideTitles( interval: yValuesInterval, showTitles: true, - getTitlesWidget: (value, _) => Padding( + getTitlesWidget: (double value, _) => Padding( padding: const EdgeInsets.only(top: 8), child: Text( value != 0 diff --git a/lib/widgets/reusable_widgets/chart/standard_line_chart_bar_data.dart b/lib/widgets/reusable_widgets/chart/standard_line_chart_bar_data.dart index 8e59e767..35aacfb4 100644 --- a/lib/widgets/reusable_widgets/chart/standard_line_chart_bar_data.dart +++ b/lib/widgets/reusable_widgets/chart/standard_line_chart_bar_data.dart @@ -9,6 +9,6 @@ class StandardLineChartBarData extends LineChartBarData { color: color, barWidth: 3, isStrokeCapRound: true, - spots: spots ?? const [], + spots: spots ?? const [], ); } diff --git a/lib/widgets/reusable_widgets/chart/standard_pie_chart.dart b/lib/widgets/reusable_widgets/chart/standard_pie_chart.dart index 14bb3e31..9e36c8b9 100644 --- a/lib/widgets/reusable_widgets/chart/standard_pie_chart.dart +++ b/lib/widgets/reusable_widgets/chart/standard_pie_chart.dart @@ -11,7 +11,7 @@ class StandardPieChart extends PieChart { }) : super( PieChartData( pieTouchData: PieTouchData( - touchCallback: (event, pieTouchResponse) { + touchCallback: (FlTouchEvent event, PieTouchResponse? pieTouchResponse) { if (!event.isInterestedForInteractions || pieTouchResponse == null || pieTouchResponse.touchedSection == null) { diff --git a/lib/widgets/reusable_widgets/context_menu_region.dart b/lib/widgets/reusable_widgets/context_menu_region.dart index 592cd397..630f03a5 100644 --- a/lib/widgets/reusable_widgets/context_menu_region.dart +++ b/lib/widgets/reusable_widgets/context_menu_region.dart @@ -65,7 +65,7 @@ class _ContextMenuRegionState extends State { void _show(Offset position) { _contextMenuController.show( context: context, - contextMenuBuilder: (context) { + contextMenuBuilder: (BuildContext context) { return widget.contextMenuBuilder(context, position); }, ); diff --git a/lib/widgets/reusable_widgets/custom_material_stepper.dart b/lib/widgets/reusable_widgets/custom_material_stepper.dart index b5cfdce8..4bb52b65 100644 --- a/lib/widgets/reusable_widgets/custom_material_stepper.dart +++ b/lib/widgets/reusable_widgets/custom_material_stepper.dart @@ -231,7 +231,7 @@ class _StepperState extends State with TickerProviderStateMixin { (int i) => GlobalKey(), ); - for (var i = 0; i < widget.steps.length; i += 1) { + for (int i = 0; i < widget.steps.length; i += 1) { _oldStates[i] = widget.steps[i].state; } } @@ -241,7 +241,7 @@ class _StepperState extends State with TickerProviderStateMixin { super.didUpdateWidget(oldWidget); assert(widget.steps.length == oldWidget.steps.length); - for (var i = 0; i < oldWidget.steps.length; i += 1) { + for (int i = 0; i < oldWidget.steps.length; i += 1) { _oldStates[i] = oldWidget.steps[i].state; } } @@ -271,9 +271,9 @@ class _StepperState extends State with TickerProviderStateMixin { } Widget? _buildCircleChild(int index, bool oldState) { - final state = + final StepState state = oldState ? _oldStates[index]! : widget.steps[index].state; - final isDarkActive = _isDark() && widget.steps[index].isActive; + final bool isDarkActive = _isDark() && widget.steps[index].isActive; switch (state) { case StepState.indexed: case StepState.disabled: @@ -379,8 +379,8 @@ class _StepperState extends State with TickerProviderStateMixin { } TextStyle? _titleStyle(int index) { - final themeData = Theme.of(context); - final textTheme = themeData.textTheme; + final ThemeData themeData = Theme.of(context); + final TextTheme textTheme = themeData.textTheme; switch (widget.steps[index].state) { case StepState.indexed: @@ -397,8 +397,8 @@ class _StepperState extends State with TickerProviderStateMixin { } TextStyle? _subtitleStyle(int index) { - final themeData = Theme.of(context); - final textTheme = themeData.textTheme; + final ThemeData themeData = Theme.of(context); + final TextTheme textTheme = themeData.textTheme; switch (widget.steps[index].state) { case StepState.indexed: @@ -522,7 +522,7 @@ class _StepperState extends State with TickerProviderStateMixin { key: _keys[i], children: [ InkWell( - overlayColor: WidgetStateProperty.resolveWith((states) => + overlayColor: WidgetStateProperty.resolveWith((Set states) => states.contains(WidgetState.hovered) ? Colors.transparent : null,), @@ -552,7 +552,7 @@ class _StepperState extends State with TickerProviderStateMixin { } Widget _buildHorizontal() { - final children = [ + final List children = [ for (int i = 0; i < widget.steps.length; i += 1) ...[ InkResponse( onTap: widget.steps[i].state != StepState.disabled @@ -663,10 +663,10 @@ class _TrianglePainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { - final base = size.width; - final halfBase = size.width / 2.0; - final height = size.height; - final points = [ + final double base = size.width; + final double halfBase = size.width / 2.0; + final double height = size.height; + final List points = [ Offset(0, height), Offset(base, height), Offset(halfBase, 0), diff --git a/lib/widgets/reusable_widgets/custom_slider.dart b/lib/widgets/reusable_widgets/custom_slider.dart index 6138c1de..ced248d6 100644 --- a/lib/widgets/reusable_widgets/custom_slider.dart +++ b/lib/widgets/reusable_widgets/custom_slider.dart @@ -8,11 +8,11 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; Path _downTriangle(double size, Offset thumbCenter, {bool invert = false}) { - final thumbPath = Path(); - final height = math.sqrt(3) / 2.0; - final centerHeight = size * height / 3.0; - final halfSize = size / 2.0; - final sign = invert ? -1.0 : 1.0; + final Path thumbPath = Path(); + final double height = math.sqrt(3) / 2.0; + final double centerHeight = size * height / 3.0; + final double halfSize = size / 2.0; + final double sign = invert ? -1.0 : 1.0; thumbPath.moveTo( thumbCenter.dx - halfSize, thumbCenter.dy + sign * centerHeight, @@ -63,13 +63,13 @@ class _CustomThumbShape extends SliderComponentShape { double? textScaleFactor, Size? sizeWithOverflow, }) { - final canvas = context.canvas; - final colorTween = ColorTween( + final Canvas canvas = context.canvas; + final ColorTween colorTween = ColorTween( begin: sliderTheme.disabledThumbColor, end: sliderTheme.thumbColor, ); - final size = _thumbSize * sizeTween.evaluate(enableAnimation); - final thumbPath = _downTriangle(size, thumbCenter); + final double size = _thumbSize * sizeTween.evaluate(enableAnimation); + final Path thumbPath = _downTriangle(size, thumbCenter); canvas.drawPath( thumbPath, Paint()..color = colorTween.evaluate(enableAnimation)!, @@ -107,20 +107,20 @@ class _CustomValueIndicatorShape extends SliderComponentShape { double? textScaleFactor, Size? sizeWithOverflow, }) { - final canvas = context.canvas; - final enableColor = ColorTween( + final Canvas canvas = context.canvas; + final ColorTween enableColor = ColorTween( begin: sliderTheme.disabledThumbColor, end: sliderTheme.valueIndicatorColor, ); - final slideUpTween = Tween( + final Tween slideUpTween = Tween( begin: 0, end: _slideUpHeight, ); - final size = _indicatorSize * sizeTween.evaluate(enableAnimation); - final slideUpOffset = + final double size = _indicatorSize * sizeTween.evaluate(enableAnimation); + final Offset slideUpOffset = Offset(0, -slideUpTween.evaluate(activationAnimation)); - final thumbPath = _upTriangle(size, thumbCenter + slideUpOffset); - final paintColor = enableColor + final Path thumbPath = _upTriangle(size, thumbCenter + slideUpOffset); + final Color paintColor = enableColor .evaluate(enableAnimation)! .withAlpha((255.0 * activationAnimation.value).round()); canvas.drawPath( @@ -172,13 +172,13 @@ class _CustomSliderState extends State { Widget build(BuildContext context) { _discreteCustomValue ??= widget.startValue; - final theme = Theme.of(context); + final ThemeData theme = Theme.of(context); return Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Column( mainAxisSize: MainAxisSize.min, - children: [ + children: [ SliderTheme( data: theme.sliderTheme.copyWith( trackHeight: 2, @@ -204,9 +204,9 @@ class _CustomSliderState extends State { min: widget.min, max: widget.maxValue, divisions: (widget.maxValue - widget.min).toInt(), - semanticFormatterCallback: (value) => value.round().toString(), + semanticFormatterCallback: (double value) => value.round().toString(), label: '${_discreteCustomValue!.round()}', - onChanged: (value) { + onChanged: (double value) { setState(() { _discreteCustomValue = value; widget.callback(value); diff --git a/lib/widgets/reusable_widgets/custom_table.dart b/lib/widgets/reusable_widgets/custom_table.dart index 565bb437..169ad303 100644 --- a/lib/widgets/reusable_widgets/custom_table.dart +++ b/lib/widgets/reusable_widgets/custom_table.dart @@ -35,7 +35,7 @@ class _CustomTableState extends State> { @override Widget build(BuildContext context) { return Column( - children: [ + children: [ Visibility( visible: widget.headerColumns != null, child: _getTableHeader(), @@ -47,7 +47,7 @@ class _CustomTableState extends State> { controller: _scrollController, shrinkWrap: true, children: widget.onShowMoreButtonPressed != null - ? _getRows() + [_getShowMoreButton()] + ? _getRows() + [_getShowMoreButton()] : _getRows(), ), ), @@ -79,19 +79,19 @@ class _CustomTableState extends State> { ), child: Row( children: List.from( - [ + [ const SizedBox( width: 20, ), ], ) + - (widget.headerColumns ?? []), + (widget.headerColumns ?? []), ), ); } Widget _getTableRow(dynamic item, int indexOfRow) { - final isSelected = _selectedRowIndex == indexOfRow; + final bool isSelected = _selectedRowIndex == indexOfRow; return InkWell( onTap: () { @@ -129,7 +129,7 @@ class _CustomTableState extends State> { ), child: Row( children: List.from( - [ + [ const SizedBox( width: 20, ), @@ -183,7 +183,7 @@ class CustomHeaderColumn extends StatelessWidget { flex: flex, child: Row( mainAxisAlignment: contentAlign, - children: [ + children: [ Text( columnName, style: Theme.of(context).textTheme.bodyMedium, @@ -220,7 +220,7 @@ class CustomTableCell extends StatelessWidget { this.flex = 1, Color textColor = AppColors.subtitleColor, }) : child = Row( - children: [ + children: [ Expanded( child: Tooltip( message: address.toString(), @@ -259,7 +259,7 @@ class CustomTableCell extends StatelessWidget { this.flex = 1, Color textColor = AppColors.subtitleColor, }) : child = Row( - children: [ + children: [ Expanded( child: Container( margin: const EdgeInsets.only( @@ -280,7 +280,7 @@ class CustomTableCell extends StatelessWidget { Visibility( visible: showCopyToClipboardIcon, child: Row( - children: [ + children: [ CopyToClipboardIcon( text, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, @@ -304,7 +304,7 @@ class CustomTableCell extends StatelessWidget { Color textColor = AppColors.subtitleColor, TextAlign textAlign = TextAlign.start, }) : child = Row( - children: [ + children: [ Expanded( child: Tooltip( message: address.toString(), @@ -322,7 +322,7 @@ class CustomTableCell extends StatelessWidget { Visibility( visible: showCopyToClipboardIcon, child: Row( - children: [ + children: [ CopyToClipboardIcon( address.toString(), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, @@ -346,7 +346,7 @@ class CustomTableCell extends StatelessWidget { Color textColor = AppColors.subtitleColor, TextAlign textAlign = TextAlign.start, }) : child = Row( - children: [ + children: [ Expanded( child: Text( text, @@ -360,7 +360,7 @@ class CustomTableCell extends StatelessWidget { Visibility( visible: showCopyToClipboardIcon, child: Row( - children: [ + children: [ CopyToClipboardIcon( text, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, diff --git a/lib/widgets/reusable_widgets/dialogs.dart b/lib/widgets/reusable_widgets/dialogs.dart index 5619a2be..445125e6 100644 --- a/lib/widgets/reusable_widgets/dialogs.dart +++ b/lib/widgets/reusable_widgets/dialogs.dart @@ -8,10 +8,10 @@ Future showWarningDialog({ required String buttonText, VoidCallback? onActionButtonPressed, }) async { - var isPressed = false; + bool isPressed = false; await showDialog( context: context, - builder: (context) => AlertDialog( + builder: (BuildContext context) => AlertDialog( icon: const Icon( Icons.warning, size: 24, @@ -19,7 +19,7 @@ Future showWarningDialog({ ), title: Text(title), content: Text(description), - actions: [ + actions: [ TextButton( onPressed: onActionButtonPressed ?? () { @@ -66,10 +66,10 @@ Future showDialogWithNoAndYesOptions({ showDialog( barrierDismissible: isBarrierDismissible, context: context, - builder: (context) => AlertDialog( + builder: (BuildContext context) => AlertDialog( title: Text(title), content: content ?? Text(description!), - actions: [ + actions: [ TextButton( onPressed: () { onNoButtonPressed?.call(); @@ -83,7 +83,7 @@ Future showDialogWithNoAndYesOptions({ TextButton( style: Theme.of(context).textButtonTheme.style!.copyWith( backgroundColor: WidgetStateColor.resolveWith( - (states) => AppColors.errorColor,), + (Set states) => AppColors.errorColor,), ), onPressed: () { onYesButtonPressed.call(); @@ -103,7 +103,7 @@ Future showCustomDialog({required BuildContext context, required Widget context: context, barrierLabel: '', barrierDismissible: true, - pageBuilder: (context, Animation animation, + pageBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation,) => Center( child: ClipRRect( diff --git a/lib/widgets/reusable_widgets/dotted_border_info_widget.dart b/lib/widgets/reusable_widgets/dotted_border_info_widget.dart index 279461b5..911cb79c 100644 --- a/lib/widgets/reusable_widgets/dotted_border_info_widget.dart +++ b/lib/widgets/reusable_widgets/dotted_border_info_widget.dart @@ -25,7 +25,7 @@ class _DottedBorderInfoWidgetState extends State { color: widget.borderColor, borderType: BorderType.RRect, radius: const Radius.circular(6), - dashPattern: const [3.0], + dashPattern: const [3], strokeWidth: 2, child: Row( mainAxisSize: MainAxisSize.min, diff --git a/lib/widgets/reusable_widgets/dropdown/coin_dropdown.dart b/lib/widgets/reusable_widgets/dropdown/coin_dropdown.dart index c980b392..db6fa1bc 100644 --- a/lib/widgets/reusable_widgets/dropdown/coin_dropdown.dart +++ b/lib/widgets/reusable_widgets/dropdown/coin_dropdown.dart @@ -27,7 +27,7 @@ class CoinDropdown extends StatelessWidget { child: DropdownButton( value: _selectedToken, isDense: true, - selectedItemBuilder: (context) { + selectedItemBuilder: (BuildContext context) { return _availableTokens .map( (Token? e) => Container( @@ -41,7 +41,7 @@ class CoinDropdown extends StatelessWidget { child: Padding( padding: const EdgeInsets.only(left: 8), child: Row( - children: [ + children: [ Text( e.symbol, style: Theme.of(context) diff --git a/lib/widgets/reusable_widgets/error_widget.dart b/lib/widgets/reusable_widgets/error_widget.dart index 8b0a45ef..47b4dbee 100644 --- a/lib/widgets/reusable_widgets/error_widget.dart +++ b/lib/widgets/reusable_widgets/error_widget.dart @@ -18,7 +18,7 @@ class SyriusErrorWidget extends StatelessWidget { padding: const EdgeInsets.all(8), child: SingleChildScrollView( child: Column( - children: [ + children: [ Lottie.asset( 'assets/lottie/ic_anim_no_data.json', width: 32, diff --git a/lib/widgets/reusable_widgets/exchange_rate_widget.dart b/lib/widgets/reusable_widgets/exchange_rate_widget.dart index ba6f1f51..014129cd 100644 --- a/lib/widgets/reusable_widgets/exchange_rate_widget.dart +++ b/lib/widgets/reusable_widgets/exchange_rate_widget.dart @@ -33,7 +33,7 @@ class _ExchangeRateWidgetState extends State { return Visibility( visible: widget.fromAmount > BigInt.zero && widget.toAmount > BigInt.zero, child: Row( - children: [ + children: [ Text( _getFormattedRate(), style: @@ -64,16 +64,16 @@ class _ExchangeRateWidgetState extends State { if (widget.fromAmount <= BigInt.zero || widget.toAmount <= BigInt.zero) { return '-'; } - final fromAmountWithDecimals = BigDecimal.createAndStripZerosForScale( + final BigDecimal fromAmountWithDecimals = BigDecimal.createAndStripZerosForScale( widget.fromAmount, widget.fromDecimals, widget.fromDecimals,); - final toAmountWithDecimals = BigDecimal.createAndStripZerosForScale( + final BigDecimal toAmountWithDecimals = BigDecimal.createAndStripZerosForScale( widget.toAmount, widget.toDecimals, widget.toDecimals,); if (_isToggled) { - final rate = fromAmountWithDecimals.divide(toAmountWithDecimals, + final BigDecimal rate = fromAmountWithDecimals.divide(toAmountWithDecimals, roundingMode: RoundingMode.DOWN,); return '1 ${widget.toSymbol} = ${rate.toDouble().toStringFixedNumDecimals(5)} ${widget.fromSymbol}'; } else { - final rate = toAmountWithDecimals.divide(fromAmountWithDecimals, + final BigDecimal rate = toAmountWithDecimals.divide(fromAmountWithDecimals, roundingMode: RoundingMode.DOWN,); return '1 ${widget.fromSymbol} = ${rate.toDouble().toStringFixedNumDecimals(5)} ${widget.toSymbol}'; } diff --git a/lib/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart b/lib/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart index 57bd0172..58b0f7b5 100644 --- a/lib/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart +++ b/lib/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart @@ -27,7 +27,7 @@ class CopyToClipboardIcon extends StatefulWidget { } class _CopyToClipboardIcon extends State { - final _iconSize = 15.0; + final double _iconSize = 15; bool _isCopied = false; @override diff --git a/lib/widgets/reusable_widgets/important_text_container.dart b/lib/widgets/reusable_widgets/important_text_container.dart index 1cd91c9a..e8bdf224 100644 --- a/lib/widgets/reusable_widgets/important_text_container.dart +++ b/lib/widgets/reusable_widgets/important_text_container.dart @@ -30,7 +30,7 @@ class ImportantTextContainer extends StatelessWidget { child: Padding( padding: const EdgeInsets.fromLTRB(15, 20, 15, 20), child: Row( - children: [ + children: [ const Icon( Icons.info, size: 20, diff --git a/lib/widgets/reusable_widgets/infinite_scroll_table.dart b/lib/widgets/reusable_widgets/infinite_scroll_table.dart index f8eaa416..944f3753 100644 --- a/lib/widgets/reusable_widgets/infinite_scroll_table.dart +++ b/lib/widgets/reusable_widgets/infinite_scroll_table.dart @@ -42,11 +42,11 @@ class _InfiniteScrollTableState extends State> { @override void initState() { - _pagingController.addPageRequestListener((pageKey) { + _pagingController.addPageRequestListener((int pageKey) { widget.bloc.onPageRequestSink.add(pageKey); }); _blocListingStateSubscription = - widget.bloc.onNewListingState.listen((listingState) { + widget.bloc.onNewListingState.listen((InfiniteScrollBlocListingState listingState) { _pagingController.value = PagingState( nextPageKey: listingState.nextPageKey, error: listingState.error, @@ -59,7 +59,7 @@ class _InfiniteScrollTableState extends State> { @override Widget build(BuildContext context) { return Column( - children: [ + children: [ Visibility( visible: widget.headerColumns != null, child: _getTableHeader(), @@ -71,7 +71,7 @@ class _InfiniteScrollTableState extends State> { scrollController: _scrollController, pagingController: _pagingController, builderDelegate: PagedChildBuilderDelegate( - itemBuilder: (_, item, index) => _getTableRow( + itemBuilder: (_, item, int index) => _getTableRow( item, index, ), @@ -107,19 +107,19 @@ class _InfiniteScrollTableState extends State> { ), child: Row( children: List.from( - [ + [ const SizedBox( width: 20, ), ], ) + - (widget.headerColumns ?? []), + (widget.headerColumns ?? []), ), ); } Widget _getTableRow(dynamic item, int indexOfRow) { - final isSelected = _selectedRowIndex == indexOfRow; + final bool isSelected = _selectedRowIndex == indexOfRow; return InkWell( onTap: () { @@ -157,7 +157,7 @@ class _InfiniteScrollTableState extends State> { ), child: Row( children: List.from( - [ + [ const SizedBox( width: 20, ), @@ -201,7 +201,7 @@ class InfiniteScrollTableHeaderColumn extends StatelessWidget { flex: flex, child: Row( mainAxisAlignment: contentAlign, - children: [ + children: [ Expanded( child: Text( columnName, @@ -242,7 +242,7 @@ class InfiniteScrollTableCell extends StatelessWidget { }) => InfiniteScrollTableCell( Row( - children: [ + children: [ Expanded( child: Tooltip( message: address.toString(), @@ -286,7 +286,7 @@ class InfiniteScrollTableCell extends StatelessWidget { }) => InfiniteScrollTableCell( Row( - children: [ + children: [ Expanded( child: Container( margin: const EdgeInsets.only( @@ -307,7 +307,7 @@ class InfiniteScrollTableCell extends StatelessWidget { Visibility( visible: showCopyToClipboardIcon, child: Row( - children: [ + children: [ CopyToClipboardIcon( text, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, @@ -336,7 +336,7 @@ class InfiniteScrollTableCell extends StatelessWidget { }) => InfiniteScrollTableCell( Row( - children: [ + children: [ Expanded( child: Tooltip( message: address.toString(), @@ -354,7 +354,7 @@ class InfiniteScrollTableCell extends StatelessWidget { Visibility( visible: showCopyToClipboardIcon, child: Row( - children: [ + children: [ CopyToClipboardIcon( address.toString(), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, @@ -383,7 +383,7 @@ class InfiniteScrollTableCell extends StatelessWidget { }) => InfiniteScrollTableCell( Row( - children: [ + children: [ Expanded( child: Text( text, @@ -397,7 +397,7 @@ class InfiniteScrollTableCell extends StatelessWidget { Visibility( visible: showCopyToClipboardIcon, child: Row( - children: [ + children: [ CopyToClipboardIcon( text, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, diff --git a/lib/widgets/reusable_widgets/input_fields/amount_input_field.dart b/lib/widgets/reusable_widgets/input_fields/amount_input_field.dart index 04c23b8a..63f7a948 100644 --- a/lib/widgets/reusable_widgets/input_fields/amount_input_field.dart +++ b/lib/widgets/reusable_widgets/input_fields/amount_input_field.dart @@ -38,7 +38,7 @@ class AmountInputField extends StatefulWidget { } class _AmountInputFieldState extends State { - final List _tokensWithBalance = []; + final List _tokensWithBalance = []; Token? _selectedToken; @override @@ -55,13 +55,13 @@ class _AmountInputFieldState extends State { key: widget.key, autovalidateMode: AutovalidateMode.onUserInteraction, child: InputField( - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, inputFormatters: FormatUtils.getAmountTextInputFormatters( widget.controller.text, ), - validator: (value) => InputValidators.correctValue( + validator: (String? value) => InputValidators.correctValue( value, widget.accountInfo.getBalance( _selectedToken!.tokenStandard, @@ -85,7 +85,7 @@ class _AmountInputFieldState extends State { return Row( mainAxisAlignment: MainAxisAlignment.end, mainAxisSize: MainAxisSize.min, - children: [ + children: [ _getCoinDropdown(), const SizedBox( width: 5, @@ -102,7 +102,7 @@ class _AmountInputFieldState extends State { } void _onMaxPressed() => setState(() { - final maxBalance = widget.accountInfo.getBalance( + final BigInt maxBalance = widget.accountInfo.getBalance( _selectedToken!.tokenStandard, ); widget.controller.text = @@ -112,7 +112,7 @@ class _AmountInputFieldState extends State { Widget _getCoinDropdown() => CoinDropdown( _tokensWithBalance, _selectedToken!, - (value) { + (Token? value) { if (_selectedToken != value) { setState( () { @@ -126,7 +126,7 @@ class _AmountInputFieldState extends State { ); void _addTokensWithBalance() { - for (final balanceInfo in widget.accountInfo.balanceInfoList!) { + for (final BalanceInfoListItem balanceInfo in widget.accountInfo.balanceInfoList!) { if (balanceInfo.balance! > BigInt.zero && !_tokensWithBalance.contains(balanceInfo.token)) { _tokensWithBalance.add(balanceInfo.token); diff --git a/lib/widgets/reusable_widgets/input_fields/amount_suffix_widgets.dart b/lib/widgets/reusable_widgets/input_fields/amount_suffix_widgets.dart index 01c19c5b..53ad0a9c 100644 --- a/lib/widgets/reusable_widgets/input_fields/amount_suffix_widgets.dart +++ b/lib/widgets/reusable_widgets/input_fields/amount_suffix_widgets.dart @@ -18,7 +18,7 @@ class AmountSuffixWidgets extends StatelessWidget { Widget build(BuildContext context) { return Row( mainAxisSize: MainAxisSize.min, - children: [ + children: [ AmountSuffixTokenSymbolWidget( token: tokenId, context: context, diff --git a/lib/widgets/reusable_widgets/input_fields/input_field.dart b/lib/widgets/reusable_widgets/input_fields/input_field.dart index f81c5139..0af72dc3 100644 --- a/lib/widgets/reusable_widgets/input_fields/input_field.dart +++ b/lib/widgets/reusable_widgets/input_fields/input_field.dart @@ -64,12 +64,12 @@ class _InputFieldState extends State { @override Widget build(BuildContext context) { return TextFormField( - contextMenuBuilder: (context, editableTextState) { + contextMenuBuilder: (BuildContext context, EditableTextState editableTextState) { return AdaptiveTextSelectionToolbar( anchors: editableTextState.contextMenuAnchors, children: editableTextState.contextMenuButtonItems .map((ContextMenuButtonItem buttonItem) { - return Row(children: [ + return Row(children: [ Expanded( child: TextButton( onPressed: buttonItem.onPressed, @@ -88,7 +88,7 @@ class _InputFieldState extends State { obscureText: widget.obscureText, onChanged: widget.onChanged, validator: widget.validator, - inputFormatters: widget.inputFormatters ?? [], + inputFormatters: widget.inputFormatters ?? [], enabled: widget.enabled, controller: widget.controller, focusNode: widget.thisNode, diff --git a/lib/widgets/reusable_widgets/input_fields/labeled_input_container.dart b/lib/widgets/reusable_widgets/input_fields/labeled_input_container.dart index 535ffee0..afeb0ba6 100644 --- a/lib/widgets/reusable_widgets/input_fields/labeled_input_container.dart +++ b/lib/widgets/reusable_widgets/input_fields/labeled_input_container.dart @@ -18,9 +18,9 @@ class LabeledInputContainer extends StatelessWidget { return Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ + children: [ Row( - children: [ + children: [ Text( labelText, style: const TextStyle( diff --git a/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart b/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart index 4de21b14..b21ae2aa 100644 --- a/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart +++ b/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart @@ -64,7 +64,7 @@ class _CardScaffoldState extends State> { return FlipCard( flipOnTouch: false, key: cardKey, - onFlipDone: (status) {}, + onFlipDone: (bool status) {}, front: ClipRRect( borderRadius: BorderRadius.circular( 15, @@ -113,7 +113,7 @@ class _CardScaffoldState extends State> { padding: const EdgeInsets.all(8), child: ListView( shrinkWrap: true, - children: [ + children: [ ExpandablePanel( collapsed: Container(), theme: ExpandableThemeData( @@ -122,7 +122,7 @@ class _CardScaffoldState extends State> { iconPlacement: ExpandablePanelIconPlacement.right, ), header: Row( - children: [ + children: [ const Icon( Icons.info, color: AppColors.znnColor, @@ -152,7 +152,7 @@ class _CardScaffoldState extends State> { ), ), Row( - children: [ + children: [ const Icon( Icons.remove_red_eye_rounded, color: AppColors.znnColor, @@ -171,7 +171,7 @@ class _CardScaffoldState extends State> { Switch( splashRadius: 0, value: _hideWidgetInfo!, - onChanged: (value) { + onChanged: (bool value) { setState(() { _hideWidgetInfo = value; }); @@ -200,7 +200,7 @@ class _CardScaffoldState extends State> { visible: _showPasswordInputField, child: Row( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Expanded( child: _getPasswordInputField(model), ), @@ -225,7 +225,7 @@ class _CardScaffoldState extends State> { child: Padding( padding: const EdgeInsets.all(14), child: Row( - children: [ + children: [ Expanded( child: Text( title, @@ -246,7 +246,7 @@ class _CardScaffoldState extends State> { Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.end, - children: [ + children: [ Visibility( visible: widget.onRefreshPressed != null, child: Material( @@ -282,7 +282,7 @@ class _CardScaffoldState extends State> { Widget _getPasswordInputField(HideWidgetStatusBloc model) { return PasswordInputField( - onSubmitted: (value) { + onSubmitted: (String value) { _actionButton!.onPressed!(); }, controller: _passwordController, @@ -305,11 +305,11 @@ class _CardScaffoldState extends State> { Widget _getHideWidgetInfoViewModel() { return ViewModelBuilder.reactive( - onViewModelReady: (model) { + onViewModelReady: (HideWidgetStatusBloc model) { _actionButton = _getActionButton(model); // Stream will tell us if the widget info is hidden or not model.stream.listen( - (response) { + (bool? response) { if (response != null) { _passwordController.clear(); if (!response) { @@ -326,9 +326,9 @@ class _CardScaffoldState extends State> { }, ); }, - builder: (_, model, __) => StreamBuilder( + builder: (_, HideWidgetStatusBloc model, __) => StreamBuilder( stream: model.stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot snapshot) { if (snapshot.hasError) { return _getBackBody(model); } @@ -355,7 +355,7 @@ class _CardScaffoldState extends State> { : widget.childStream != null && widget.onCompletedStatusCallback != null ? StreamBuilder( stream: widget.childStream, - builder: (context, snapshot) { + builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } else if (snapshot.hasData) { diff --git a/lib/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart b/lib/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart index efbf764f..61ff3c27 100644 --- a/lib/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart +++ b/lib/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart @@ -22,20 +22,20 @@ class StandardFluidLayout extends StatelessWidget { return Layout( format: FluidLayoutFormat(), child: Builder( - builder: (context) { - const crossAxisCount = kStaggeredNumOfColumns; + builder: (BuildContext context) { + const int crossAxisCount = kStaggeredNumOfColumns; - final spacing = + final double spacing = context.breakpoint < LayoutBreakpoint.sm ? 4.0 : 12.0; - final totalDurationMs = children.length > 5 ? 800 : 400; + final int totalDurationMs = children.length > 5 ? 800 : 400; - final durationPerTile = totalDurationMs ~/ children.length; + final int durationPerTile = totalDurationMs ~/ children.length; - final tiles = List.generate( + final List tiles = List.generate( children.length, - (index) { - final widgetAnimatorOffset = durationPerTile * (index + 1); + (int index) { + final int widgetAnimatorOffset = durationPerTile * (index + 1); return _generateStaggeredTitle( children[index], diff --git a/lib/widgets/reusable_widgets/loading_info_text.dart b/lib/widgets/reusable_widgets/loading_info_text.dart index 8aa6e950..2a0b9232 100644 --- a/lib/widgets/reusable_widgets/loading_info_text.dart +++ b/lib/widgets/reusable_widgets/loading_info_text.dart @@ -16,7 +16,7 @@ class LoadingInfoText extends StatelessWidget { Widget build(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ const SyriusLoadingWidget( size: 16, strokeWidth: 2, diff --git a/lib/widgets/reusable_widgets/modals/base_modal.dart b/lib/widgets/reusable_widgets/modals/base_modal.dart index ac0fee9a..46f3b0f8 100644 --- a/lib/widgets/reusable_widgets/modals/base_modal.dart +++ b/lib/widgets/reusable_widgets/modals/base_modal.dart @@ -29,12 +29,12 @@ class BaseModal extends StatelessWidget { padding: const EdgeInsets.all(25), child: Column( mainAxisSize: MainAxisSize.min, - children: [ + children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ Column( - children: [ + children: [ Text( title, style: const TextStyle( diff --git a/lib/widgets/reusable_widgets/notification_widget.dart b/lib/widgets/reusable_widgets/notification_widget.dart index 24b3f1df..2b9af2ab 100644 --- a/lib/widgets/reusable_widgets/notification_widget.dart +++ b/lib/widgets/reusable_widgets/notification_widget.dart @@ -52,7 +52,7 @@ class _NotificationWidgetState extends State { ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ _getNotificationDetails(kLastNotification!), _getNotificationOptions(kLastNotification!), ], @@ -71,7 +71,7 @@ class _NotificationWidgetState extends State { void _initNotificationsBloc() { _notificationsBloc = sl.get(); _notificationsBloc.stream.listen( - (value) { + (WalletNotification? value) { if (mounted) { setState(() { kLastNotification = value; @@ -84,7 +84,7 @@ class _NotificationWidgetState extends State { Row _getNotificationDetails(WalletNotification notification) { return Row( - children: [ + children: [ notification.getIcon(), const SizedBox( width: 15, @@ -99,7 +99,7 @@ class _NotificationWidgetState extends State { Row _getNotificationOptions(WalletNotification notification) { return Row( - children: [ + children: [ Visibility( visible: kCurrentPage != Tabs.lock && widget.onSeeMorePressed != null, child: RawMaterialButton( diff --git a/lib/widgets/reusable_widgets/number_animation.dart b/lib/widgets/reusable_widgets/number_animation.dart index dbc3a4f3..79965d18 100644 --- a/lib/widgets/reusable_widgets/number_animation.dart +++ b/lib/widgets/reusable_widgets/number_animation.dart @@ -82,7 +82,7 @@ class _NumberAnimationState extends State controller = AnimationController(duration: widget.duration, vsync: this); _curve = CurvedAnimation(parent: controller!, curve: Curves.easeOut); if (widget.isLoading == false) { - final animation = Tween( + final Animation animation = Tween( begin: widget.start.toDouble(), end: widget.end!.toDouble(),) .animate(_curve as Animation); _animation = animation; @@ -107,7 +107,7 @@ class _NumberAnimationState extends State if (oldWidget.end == widget.end && _hasShowNumber == true) { return; } - final animation = Tween( + final Animation animation = Tween( begin: _animation != null ? _animation!.value : widget.start.toDouble(), @@ -124,9 +124,9 @@ class _NumberAnimationState extends State /// build @override Widget build(BuildContext context) { - final style = widget.style; - final textAlign = widget.textAlign; - final strutStyle = widget.strutStyle; + final TextStyle? style = widget.style; + final TextAlign? textAlign = widget.textAlign; + final StrutStyle? strutStyle = widget.strutStyle; if (widget.isLoading == true) { return Text( widget.loadingPlaceHolder, @@ -137,7 +137,7 @@ class _NumberAnimationState extends State } return AnimatedBuilder( animation: _animation!, - builder: (context, child) { + builder: (BuildContext context, Widget? child) { if (widget.isLoading == true) { return Text( widget.loadingPlaceHolder, diff --git a/lib/widgets/reusable_widgets/progress_bars.dart b/lib/widgets/reusable_widgets/progress_bars.dart index 9ffb6d93..a366f5ff 100644 --- a/lib/widgets/reusable_widgets/progress_bars.dart +++ b/lib/widgets/reusable_widgets/progress_bars.dart @@ -19,7 +19,7 @@ class PasswordProgressBar extends StatefulWidget { } class _PasswordProgressBarState extends State { - final List _colors = [ + final List _colors = [ AppColors.accessWalletContainersGray, AppColors.accessWalletContainersGray, AppColors.accessWalletContainersGray, @@ -45,12 +45,12 @@ class _PasswordProgressBarState extends State { List _getProgressBars() => List.generate( _colors.length, - (index) => _getPasswordProgressBar(_colors[index]), + (int index) => _getPasswordProgressBar(_colors[index]), ); List _getSpacers() => List.generate( _colors.length - 1, - (index) => _getSpacer(), + (int index) => _getSpacer(), ); Expanded _getPasswordProgressBar(Color color) { @@ -112,12 +112,12 @@ class ProgressBar extends StatelessWidget { List _getProgressBars() => List.generate( numLevels, - (index) => _getProgressBar(index + 1), + (int index) => _getProgressBar(index + 1), ); List _getSpacers() => List.generate( numLevels - 1, - (index) => _getSpacer(), + (int index) => _getSpacer(), ); Container _getProgressBar(int level) { diff --git a/lib/widgets/reusable_widgets/receive_qr_image.dart b/lib/widgets/reusable_widgets/receive_qr_image.dart index 140bb78b..fb0ec2ef 100644 --- a/lib/widgets/reusable_widgets/receive_qr_image.dart +++ b/lib/widgets/reusable_widgets/receive_qr_image.dart @@ -27,7 +27,7 @@ class ReceiveQrImage extends StatelessWidget { final TokenStandard tokenStandard; final BuildContext context; - static const decorationImage = PrettyQrDecorationImage( + static const PrettyQrDecorationImage decorationImage = PrettyQrDecorationImage( scale: 0.3, padding: EdgeInsets.only(top: 10, bottom: 10), image: AssetImage('assets/images/qr_code_child_image_znn.png'), @@ -47,14 +47,14 @@ class ReceiveQrImage extends StatelessWidget { ), color: Theme.of(context).colorScheme.surface, child: ContextMenuRegion( - contextMenuBuilder: (context, offset) { + contextMenuBuilder: (BuildContext context, Offset offset) { return AdaptiveTextSelectionToolbar( anchors: TextSelectionToolbarAnchors( primaryAnchor: offset, ), - children: [ + children: [ Row( - children: [ + children: [ Expanded( child: Directionality( textDirection: TextDirection.rtl, @@ -84,7 +84,7 @@ class ReceiveQrImage extends StatelessWidget { ), Row( crossAxisAlignment: CrossAxisAlignment.end, - children: [ + children: [ Expanded( child: Directionality( textDirection: TextDirection.rtl, @@ -124,12 +124,12 @@ class ReceiveQrImage extends StatelessWidget { ), image: decorationImage,), errorCorrectLevel: QrErrorCorrectLevel.M, - errorBuilder: (context, error, stack) => Center( + errorBuilder: (BuildContext context, Object error, StackTrace? stack) => Center( child: Padding( padding: const EdgeInsets.all(5), child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Lottie.asset( 'assets/lottie/ic_anim_no_data.json', width: 32, @@ -151,12 +151,12 @@ class ReceiveQrImage extends StatelessWidget { } Future _getQRImageData() async { - final qr = QrImage(QrCode.fromData( + final QrImage qr = QrImage(QrCode.fromData( data: data, errorCorrectLevel: QrErrorCorrectLevel.M, ),); - final b = await qr.toImageAsBytes( + final ByteData? b = await qr.toImageAsBytes( size: size, decoration: PrettyQrDecoration( shape: PrettyQrSmoothSymbol( @@ -170,10 +170,10 @@ class ReceiveQrImage extends StatelessWidget { } Future _saveQR() async { - final imageData = await _getQRImageData(); + final Uint8List? imageData = await _getQRImageData(); if (imageData != null) { - final fileName = DateTime.now().millisecondsSinceEpoch.toString(); - final imagePath = await File( + final String fileName = DateTime.now().millisecondsSinceEpoch.toString(); + final File imagePath = await File( '${znnDefaultPaths.cache.path}${path.separator}$fileName.png',) .create(); await imagePath.writeAsBytes(imageData); @@ -182,14 +182,14 @@ class ReceiveQrImage extends StatelessWidget { } Future _shareQR() async { - final imageData = await _getQRImageData(); + final Uint8List? imageData = await _getQRImageData(); if (imageData != null) { - final fileName = DateTime.now().millisecondsSinceEpoch.toString(); - final imagePath = await File( + final String fileName = DateTime.now().millisecondsSinceEpoch.toString(); + final File imagePath = await File( '${znnDefaultPaths.cache.path}${path.separator}$fileName.png',) .create(); await imagePath.writeAsBytes(imageData); - await Share.shareXFiles([XFile(imagePath.path)]); + await Share.shareXFiles([XFile(imagePath.path)]); } } } diff --git a/lib/widgets/reusable_widgets/seed/seed_choice.dart b/lib/widgets/reusable_widgets/seed/seed_choice.dart index 697ad55b..e291a34f 100644 --- a/lib/widgets/reusable_widgets/seed/seed_choice.dart +++ b/lib/widgets/reusable_widgets/seed/seed_choice.dart @@ -44,7 +44,7 @@ class _SeedChoiceState extends State { }); }, child: FocusableActionDetector( - onShowHoverHighlight: (x) { + onShowHoverHighlight: (bool x) { if (x) { setState(() { _seed24Color = AppColors.znnColor; @@ -88,7 +88,7 @@ class _SeedChoiceState extends State { }); }, child: FocusableActionDetector( - onShowHoverHighlight: (x) { + onShowHoverHighlight: (bool x) { if (x) { setState(() { _seed12Color = AppColors.znnColor; diff --git a/lib/widgets/reusable_widgets/seed/seed_grid.dart b/lib/widgets/reusable_widgets/seed/seed_grid.dart index 689d7bc5..d9e81a47 100644 --- a/lib/widgets/reusable_widgets/seed/seed_grid.dart +++ b/lib/widgets/reusable_widgets/seed/seed_grid.dart @@ -26,7 +26,7 @@ class SeedGrid extends StatefulWidget { } class SeedGridState extends State { - final List _seedGridElements = []; + final List _seedGridElements = []; int? _textCursor; int? _onHoverText; @@ -61,16 +61,16 @@ class SeedGridState extends State { } Widget _getSeedInputWidgetsGrid() { - final divider = widget.seedWords.length ~/ kSeedGridNumOfRows; + final int divider = widget.seedWords.length ~/ kSeedGridNumOfRows; - var columnChildren = []; + List columnChildren = []; - for (var i = 0; i <= widget.seedWords.length / divider - 1; i++) { + for (int i = 0; i <= widget.seedWords.length / divider - 1; i++) { columnChildren.add( _getSeedRow( List.generate( divider, - (index) => index + (divider * i), + (int index) => index + (divider * i), ), ), ); @@ -79,7 +79,7 @@ class SeedGridState extends State { columnChildren = columnChildren.zip( List.generate( kSeedGridNumOfRows - 1, - (index) => const SizedBox( + (int index) => const SizedBox( height: 10, ), ), @@ -93,9 +93,9 @@ class SeedGridState extends State { } Widget _getSeedRow(List rangeIndexes) { - final children = rangeIndexes.fold>( - [], - (previousValue, index) { + final List children = rangeIndexes.fold>( + [], + (List previousValue, int index) { previousValue.add(_seedWordWidget(index)); if (rangeIndexes.last != index) { previousValue.add(const SizedBox( @@ -112,9 +112,9 @@ class SeedGridState extends State { } Widget _seedWordWidget(int seedWordIndex) { - final seedWord = _seedGridElements[seedWordIndex].word; + final String seedWord = _seedGridElements[seedWordIndex].word; - final controller = TextEditingController(); + final TextEditingController controller = TextEditingController(); controller.text = seedWord; if (_textCursor == seedWordIndex) { @@ -136,7 +136,7 @@ class SeedGridState extends State { }, child: FocusableActionDetector( mouseCursor: SystemMouseCursors.click, - onShowHoverHighlight: (x) { + onShowHoverHighlight: (bool x) { if (x) { setState(() { _onHoverText = seedWordIndex; @@ -176,7 +176,7 @@ class SeedGridState extends State { child: FocusableActionDetector( actions: _actionMap, shortcuts: _shortcutMap, - onShowHoverHighlight: (x) { + onShowHoverHighlight: (bool x) { if (x) { setState(() { _onHoverText = seedWordIndex; @@ -191,7 +191,7 @@ class SeedGridState extends State { color: Colors.transparent, child: TextField( focusNode: _focusNodes[seedWordIndex], - onChanged: (text) { + onChanged: (String text) { controller.text = text; _seedGridElements[seedWordIndex].word = text; _seedGridElements[seedWordIndex].isValid = @@ -202,7 +202,7 @@ class SeedGridState extends State { _checkIfSeedIsValid(); widget.onTextFieldChangedCallback?.call(); }, - inputFormatters: [LengthLimitingTextInputFormatter(8)], + inputFormatters: [LengthLimitingTextInputFormatter(8)], enabled: widget.enableSeedInputFields, controller: controller, obscureText: _onHoverText == seedWordIndex @@ -321,7 +321,7 @@ class SeedGridState extends State { } bool _foundInvalidSeedGridElement() { - return _seedGridElements.any((element) => !element.isValid); + return _seedGridElements.any((SeedGridElement element) => !element.isValid); } void changedSeed(List newSeed) { @@ -333,19 +333,19 @@ class SeedGridState extends State { } List get getSeedWords => - _seedGridElements.map((e) => e.word).toList(); + _seedGridElements.map((SeedGridElement e) => e.word).toList(); String get getSeed => getSeedWords.join(' '); void _initFocusNodes(int length) => _focusNodes = List.generate( length, - (index) => FocusNode(), + (int index) => FocusNode(), ); void _changeFocusToNextNode() { - final indexOfFocusedNode = _focusNodes.indexOf( + final int indexOfFocusedNode = _focusNodes.indexOf( _focusNodes.firstWhere( - (node) => node.hasFocus, + (FocusNode node) => node.hasFocus, ), ); if (indexOfFocusedNode + 1 < _focusNodes.length) { @@ -356,7 +356,7 @@ class SeedGridState extends State { } void _initSeedGridElements(List seed) { - for (final word in seed) { + for (final String word in seed) { _seedGridElements.add( SeedGridElement( word: word, @@ -369,7 +369,7 @@ class SeedGridState extends State { @override void dispose() { - for (final focusNode in _focusNodes) { + for (final FocusNode focusNode in _focusNodes) { focusNode.dispose(); } super.dispose(); diff --git a/lib/widgets/reusable_widgets/select_file_widget.dart b/lib/widgets/reusable_widgets/select_file_widget.dart index 9d0627f9..d9e66255 100644 --- a/lib/widgets/reusable_widgets/select_file_widget.dart +++ b/lib/widgets/reusable_widgets/select_file_widget.dart @@ -32,8 +32,8 @@ class SelectFileWidgetState extends State { @override Widget build(BuildContext context) { return DropTarget( - onDragDone: (detail) { - final walletFilePath = detail.files.first.path; + onDragDone: (DropDoneDetails detail) { + final String walletFilePath = detail.files.first.path; if (walletFilePath.contains(widget.fileExtension ?? '')) { setState(() { widget.onPathFoundCallback(walletFilePath); @@ -41,12 +41,12 @@ class SelectFileWidgetState extends State { }); } }, - onDragEntered: (detail) { + onDragEntered: (DropEventDetails detail) { setState(() { _dragging = true; }); }, - onDragExited: (detail) { + onDragExited: (DropEventDetails detail) { setState(() { _dragging = false; }); @@ -55,7 +55,7 @@ class SelectFileWidgetState extends State { onTap: () async { String? initialDirectory; initialDirectory = (await getApplicationDocumentsDirectory()).path; - final selectedFile = await openFile( + final XFile? selectedFile = await openFile( acceptedTypeGroups: [ XTypeGroup( label: 'file', @@ -76,7 +76,7 @@ class SelectFileWidgetState extends State { } }, child: FocusableActionDetector( - onShowHoverHighlight: (x) { + onShowHoverHighlight: (bool x) { if (x) { setState(() { _browseButtonHover = true; @@ -93,7 +93,7 @@ class SelectFileWidgetState extends State { ? AppColors.znnColor : Theme.of(context).textTheme.headlineSmall!.color!, strokeWidth: 2, - dashPattern: const [8.0, 5.0], + dashPattern: const [8, 5], radius: const Radius.circular(10), child: Container( height: 100, diff --git a/lib/widgets/reusable_widgets/settings_address.dart b/lib/widgets/reusable_widgets/settings_address.dart index 2d13b009..86961174 100644 --- a/lib/widgets/reusable_widgets/settings_address.dart +++ b/lib/widgets/reusable_widgets/settings_address.dart @@ -50,7 +50,7 @@ class _SettingsAddressState extends State { Row _getAddressLabel(BuildContext context) { return Row( - children: [ + children: [ Expanded( child: InkWell( borderRadius: BorderRadius.circular( @@ -62,7 +62,7 @@ class _SettingsAddressState extends State { const EdgeInsets.symmetric(horizontal: 5, vertical: 5), child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Text( _labelController.text, style: Theme.of(context).textTheme.bodyLarge!.copyWith( @@ -109,21 +109,21 @@ class _SettingsAddressState extends State { Widget _getAddressLabelInputField() { return Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Row( - children: [ + children: [ Expanded( child: SizedBox( height: 40, child: InputField( controller: _labelController, - onSubmitted: (value) { + onSubmitted: (String value) { if (_labelController.text != kAddressLabelMap[widget.address]!) { _onChangeButtonPressed(); } }, - onChanged: (value) { + onChanged: (String value) { setState(() {}); }, inputtedTextStyle: diff --git a/lib/widgets/reusable_widgets/settings_node.dart b/lib/widgets/reusable_widgets/settings_node.dart index a8f55dff..96193710 100644 --- a/lib/widgets/reusable_widgets/settings_node.dart +++ b/lib/widgets/reusable_widgets/settings_node.dart @@ -42,7 +42,7 @@ class _SettingsNodeState extends State { void initState() { _nodeController.text = widget.node; - NodeUtils.getNodeChainIdentifier().then((chainIdentifier) { + NodeUtils.getNodeChainIdentifier().then((int chainIdentifier) { connectedNodeChainIdentifier = chainIdentifier; setState(() {}); }); @@ -62,7 +62,7 @@ class _SettingsNodeState extends State { Row _getNode(BuildContext context) { return Row( - children: [ + children: [ Expanded( child: InkWell( borderRadius: BorderRadius.circular( @@ -74,7 +74,7 @@ class _SettingsNodeState extends State { const EdgeInsets.symmetric(horizontal: 5, vertical: 5), child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Text( _nodeController.text, style: Theme.of(context).textTheme.bodyLarge!.copyWith( @@ -191,9 +191,9 @@ class _SettingsNodeState extends State { Widget _getNodeInputField() { return Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Row( - children: [ + children: [ Expanded( child: SizedBox( child: Form( @@ -202,7 +202,7 @@ class _SettingsNodeState extends State { child: InputField( controller: _nodeController, hintText: 'Node address with port', - onSubmitted: (value) { + onSubmitted: (String value) { if (_nodeController.text != widget.node && _ifUserInputValid()) { _onChangeButtonPressed(); @@ -215,7 +215,7 @@ class _SettingsNodeState extends State { }); } }, - validator: (value) => + validator: (String? value) => InputValidators.node(value) ?? _nodeError,), ), ), @@ -256,12 +256,12 @@ class _SettingsNodeState extends State { _changeButtonKey.currentState!.showLoadingIndicator(true); if (_nodeController.text.isNotEmpty && _nodeController.text.length <= kAddressLabelMaxLength && - ![...kDefaultNodes, ...kDefaultCommunityNodes, ...kDbNodes] + ![...kDefaultNodes, ...kDefaultCommunityNodes, ...kDbNodes] .contains(_nodeController.text)) { if (!Hive.isBoxOpen(kNodesBox)) { await Hive.openBox(kNodesBox); } - final nodesBox = Hive.box(kNodesBox); + final Box nodesBox = Hive.box(kNodesBox); final nodeKey = nodesBox.keys.firstWhere( (key) => nodesBox.get(key) == widget.node, ); @@ -302,7 +302,7 @@ class _SettingsNodeState extends State { if (!Hive.isBoxOpen(kNodesBox)) { await Hive.openBox(kNodesBox); } - final nodesBox = Hive.box(kNodesBox); + final Box nodesBox = Hive.box(kNodesBox); final nodeKey = nodesBox.keys.firstWhere( (key) => nodesBox.get(key) == node, ); diff --git a/lib/widgets/reusable_widgets/stepper_utils.dart b/lib/widgets/reusable_widgets/stepper_utils.dart index 09e57717..41173f50 100644 --- a/lib/widgets/reusable_widgets/stepper_utils.dart +++ b/lib/widgets/reusable_widgets/stepper_utils.dart @@ -23,7 +23,7 @@ class StepperUtils { ), subtitle: stepState == custom_material_stepper.StepState.complete ? Row( - children: [ + children: [ Text( stepSubtitle, style: Theme.of(context).textTheme.bodyLarge!.copyWith( @@ -43,7 +43,7 @@ class StepperUtils { content: Container( margin: const EdgeInsets.only(left: 37), child: Row( - children: [ + children: [ Expanded( child: stepContent, ), @@ -67,7 +67,7 @@ class StepperUtils { static Widget getBalanceWidget(Token token, AccountInfo accountInfo) { return Row( - children: [ + children: [ Expanded( child: Padding( diff --git a/lib/widgets/reusable_widgets/tag_widget.dart b/lib/widgets/reusable_widgets/tag_widget.dart index c2ef4bf3..5532abb4 100644 --- a/lib/widgets/reusable_widgets/tag_widget.dart +++ b/lib/widgets/reusable_widgets/tag_widget.dart @@ -21,7 +21,7 @@ class TagWidget extends StatelessWidget { @override Widget build(BuildContext context) { return Row( - children: [ + children: [ InkWell( onTap: onPressed, borderRadius: BorderRadius.circular(50), @@ -36,10 +36,10 @@ class TagWidget extends StatelessWidget { : Theme.of(context).colorScheme.secondary, ), child: Row( - children: [ + children: [ if (iconData != null) Row( - children: [ + children: [ Icon( iconData, color: Colors.white, diff --git a/lib/widgets/tab_children_widgets/accelerator_tab_child.dart b/lib/widgets/tab_children_widgets/accelerator_tab_child.dart index b6eac97c..96f9f571 100644 --- a/lib/widgets/tab_children_widgets/accelerator_tab_child.dart +++ b/lib/widgets/tab_children_widgets/accelerator_tab_child.dart @@ -20,7 +20,7 @@ class AcceleratorTabChild extends StatelessWidget { return FutureBuilder>( future: zenon!.embedded.pillar.getByOwner(Address.parse(kSelectedAddress!)), - builder: (_, snapshot) { + builder: (_, AsyncSnapshot> snapshot) { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error.toString()); } else if (snapshot.hasData) { @@ -34,7 +34,7 @@ class AcceleratorTabChild extends StatelessWidget { StandardFluidLayout _getLayout(BuildContext context, PillarInfo? pillarInfo) { return StandardFluidLayout( - children: [ + children: [ FluidCell( width: context.layout.value( xl: kStaggeredNumOfColumns ~/ 3, diff --git a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart index 8ed2038c..a55fda75 100644 --- a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart +++ b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart @@ -31,7 +31,7 @@ class _DashboardTabChildState extends State { } Widget _getFluidLayout() { - final defaultCellWidth = context.layout.value( + final int defaultCellWidth = context.layout.value( xl: kStaggeredNumOfColumns ~/ 6, lg: kStaggeredNumOfColumns ~/ 6, md: kStaggeredNumOfColumns ~/ 6, @@ -39,7 +39,7 @@ class _DashboardTabChildState extends State { xs: kStaggeredNumOfColumns ~/ 2, ); - final children = [ + final List children = [ const FluidCell( child: DualCoinStatsCard(), ), diff --git a/lib/widgets/tab_children_widgets/help_tab_child.dart b/lib/widgets/tab_children_widgets/help_tab_child.dart index 907ed1bd..b54909c9 100644 --- a/lib/widgets/tab_children_widgets/help_tab_child.dart +++ b/lib/widgets/tab_children_widgets/help_tab_child.dart @@ -8,7 +8,7 @@ class HelpTabChild extends StatelessWidget { @override Widget build(BuildContext context) { return StandardFluidLayout( - children: [ + children: [ FluidCell( width: context.layout.value( xl: kStaggeredNumOfColumns ~/ 3, diff --git a/lib/widgets/tab_children_widgets/lock_tab_child.dart b/lib/widgets/tab_children_widgets/lock_tab_child.dart index 19f5a281..8ac249cd 100644 --- a/lib/widgets/tab_children_widgets/lock_tab_child.dart +++ b/lib/widgets/tab_children_widgets/lock_tab_child.dart @@ -77,7 +77,7 @@ class _LockTabChildState extends State { PasswordInputField( controller: _passwordController, hintText: 'Current password', - onSubmitted: (value) { + onSubmitted: (String value) { _actionButton!.onPressed!(); }, ), diff --git a/lib/widgets/tab_children_widgets/notifications_tab_child.dart b/lib/widgets/tab_children_widgets/notifications_tab_child.dart index 7a0df739..0c9c7c11 100644 --- a/lib/widgets/tab_children_widgets/notifications_tab_child.dart +++ b/lib/widgets/tab_children_widgets/notifications_tab_child.dart @@ -34,7 +34,7 @@ class _NotificationsTabChildState extends State { 'wallet notifications', childBuilder: () => CustomTable( items: _notifications, - headerColumns: const [ + headerColumns: const [ CustomHeaderColumn(columnName: 'Description', flex: 5), CustomHeaderColumn(columnName: 'Date', flex: 2), CustomHeaderColumn(columnName: 'Time', flex: 2), @@ -56,7 +56,7 @@ class _NotificationsTabChildState extends State { iconPlacement: ExpandablePanelIconPlacement.right, ), header: Row( - children: [ + children: [ notification.getIcon(), const SizedBox( width: 10, @@ -72,7 +72,7 @@ class _NotificationsTabChildState extends State { expanded: Padding( padding: const EdgeInsets.only(left: 14, top: 5, bottom: 5), child: Row( - children: [ + children: [ Expanded( child: Text( notification.details!, @@ -95,8 +95,8 @@ class _NotificationsTabChildState extends State { List _getNotificationsFromDb() { try { - final notificationsBox = Hive.box(kNotificationsBox); - final keys = notificationsBox.keys.toList(); + final Box notificationsBox = Hive.box(kNotificationsBox); + final List keys = notificationsBox.keys.toList(); if (keys.length >= kNotificationsResultLimit) { return List.from( notificationsBox.valuesBetween( @@ -111,12 +111,12 @@ class _NotificationsTabChildState extends State { ) .toList(); } catch (e) { - return []; + return []; } } Future _deleteNotification(int? notificationTimestamp) async { - final notificationsBox = Hive.box(kNotificationsBox); + final Box notificationsBox = Hive.box(kNotificationsBox); final notificationKey = notificationsBox.keys.firstWhere( (key) => notificationsBox.get(key).timestamp == notificationTimestamp, @@ -129,7 +129,7 @@ class _NotificationsTabChildState extends State { void _loadNotifications() { _notifications = _getNotificationsFromDb(); - _notifications!.sort((a, b) => b.timestamp!.compareTo(a.timestamp!)); + _notifications!.sort((WalletNotification a, WalletNotification b) => b.timestamp!.compareTo(a.timestamp!)); } List _rowCellsGenerator( @@ -137,7 +137,7 @@ class _NotificationsTabChildState extends State { isSelected, { SentinelsListBloc? model, }) { - return [ + return [ CustomTableCell( _getNotificationExpandablePanel(notification), flex: 5, diff --git a/lib/widgets/tab_children_widgets/p2p_swap_tab_child.dart b/lib/widgets/tab_children_widgets/p2p_swap_tab_child.dart index 5b8a9b8c..286d1feb 100644 --- a/lib/widgets/tab_children_widgets/p2p_swap_tab_child.dart +++ b/lib/widgets/tab_children_widgets/p2p_swap_tab_child.dart @@ -34,7 +34,7 @@ class P2pSwapTabChildState extends State { StandardFluidLayout _getLayout(BuildContext context) { return StandardFluidLayout( - children: [ + children: [ FluidCell( height: kStaggeredNumOfColumns / 2, width: context.layout.value( diff --git a/lib/widgets/tab_children_widgets/pillars_tab_child.dart b/lib/widgets/tab_children_widgets/pillars_tab_child.dart index b503cb05..d85c71f9 100644 --- a/lib/widgets/tab_children_widgets/pillars_tab_child.dart +++ b/lib/widgets/tab_children_widgets/pillars_tab_child.dart @@ -21,7 +21,7 @@ class _PillarsTabChildState extends State { @override Widget build(BuildContext context) { - final children = [ + final List children = [ FluidCell( child: PillarRewards( pillarRewardsHistoryBloc: _pillarRewardsHistoryBloc, diff --git a/lib/widgets/tab_children_widgets/plasma_tab_child.dart b/lib/widgets/tab_children_widgets/plasma_tab_child.dart index 5a0c9039..d8d0084b 100644 --- a/lib/widgets/tab_children_widgets/plasma_tab_child.dart +++ b/lib/widgets/tab_children_widgets/plasma_tab_child.dart @@ -30,9 +30,9 @@ class _PlasmaTabChildState extends State { Widget build(BuildContext context) { return StreamBuilder>( stream: sl.get().stream, - builder: (_, snapshot) { + builder: (_, AsyncSnapshot> snapshot) { if (snapshot.hasError) { - return _getFluidLayout([], errorText: snapshot.error.toString()); + return _getFluidLayout([], errorText: snapshot.error.toString()); } if (snapshot.connectionState == ConnectionState.active) { if (snapshot.hasData) { @@ -50,7 +50,7 @@ class _PlasmaTabChildState extends State { String? errorText, }) { return StandardFluidLayout( - children: [ + children: [ FluidCell( child: Consumer( builder: (_, __, ___) => const PlasmaStats( diff --git a/lib/widgets/tab_children_widgets/sentinels_tab_child.dart b/lib/widgets/tab_children_widgets/sentinels_tab_child.dart index 0688a939..b31f316c 100644 --- a/lib/widgets/tab_children_widgets/sentinels_tab_child.dart +++ b/lib/widgets/tab_children_widgets/sentinels_tab_child.dart @@ -21,7 +21,7 @@ class _SentinelsTabChildState extends State { @override Widget build(BuildContext context) { - final children = [ + final List children = [ FluidCell( child: SentinelRewards( sentinelRewardsHistoryBloc: _sentinelRewardsHistoryBloc, diff --git a/lib/widgets/tab_children_widgets/settings_tab_child.dart b/lib/widgets/tab_children_widgets/settings_tab_child.dart index 0b595a15..c4376692 100644 --- a/lib/widgets/tab_children_widgets/settings_tab_child.dart +++ b/lib/widgets/tab_children_widgets/settings_tab_child.dart @@ -32,7 +32,7 @@ class _SettingsTabChildState extends State { sm: kStaggeredNumOfColumns, xs: kStaggeredNumOfColumns, ), - children: [ + children: [ FluidCell( width: context.layout.value( xl: kStaggeredNumOfColumns ~/ 2, diff --git a/lib/widgets/tab_children_widgets/staking_tab_child.dart b/lib/widgets/tab_children_widgets/staking_tab_child.dart index 833f0a17..ce915d60 100644 --- a/lib/widgets/tab_children_widgets/staking_tab_child.dart +++ b/lib/widgets/tab_children_widgets/staking_tab_child.dart @@ -25,7 +25,7 @@ class _StakingTabChildState extends State { } Widget _getFluidLayout() { - final children = [ + final List children = [ FluidCell( child: StakingRewards( stakingRewardsHistoryBloc: _stakingRewardsHistoryBloc, @@ -52,7 +52,7 @@ class _StakingTabChildState extends State { ), FluidCell( child: Consumer( - builder: (_, __, child) => StakingOptions(_stakingListBloc), + builder: (_, __, Widget? child) => StakingOptions(_stakingListBloc), ), width: context.layout.value( xl: kStaggeredNumOfColumns ~/ 3, diff --git a/lib/widgets/tab_children_widgets/tokens_tab_child.dart b/lib/widgets/tab_children_widgets/tokens_tab_child.dart index d9c167e3..a32f9308 100644 --- a/lib/widgets/tab_children_widgets/tokens_tab_child.dart +++ b/lib/widgets/tab_children_widgets/tokens_tab_child.dart @@ -13,7 +13,7 @@ class TokensTabChild extends StatelessWidget { @override Widget build(BuildContext context) { return StandardFluidLayout( - children: [ + children: [ FluidCell( width: context.layout.value( xl: kStaggeredNumOfColumns ~/ 3, diff --git a/lib/widgets/tab_children_widgets/transfer_tab_child.dart b/lib/widgets/tab_children_widgets/transfer_tab_child.dart index 70d32460..00e9cce3 100644 --- a/lib/widgets/tab_children_widgets/transfer_tab_child.dart +++ b/lib/widgets/tab_children_widgets/transfer_tab_child.dart @@ -22,7 +22,7 @@ class _TransferTabChildState extends State { @override Widget build(BuildContext context) { return StandardFluidLayout( - children: [ + children: [ _getSendCard(), _getReceiveCard(), const FluidCell( diff --git a/lib/widgets/tab_children_widgets/wallet_connect_tab_child.dart b/lib/widgets/tab_children_widgets/wallet_connect_tab_child.dart index 290dc247..f03372e8 100644 --- a/lib/widgets/tab_children_widgets/wallet_connect_tab_child.dart +++ b/lib/widgets/tab_children_widgets/wallet_connect_tab_child.dart @@ -8,7 +8,7 @@ class WalletConnectTabChild extends StatelessWidget { @override Widget build(BuildContext context) { return StandardFluidLayout( - children: [ + children: [ FluidCell( width: context.layout.value( xl: kStaggeredNumOfColumns ~/ 3, diff --git a/test/delegation/cubit/delegation_cubit_test.dart b/test/delegation/cubit/delegation_cubit_test.dart index 10b48801..03d0d4ad 100644 --- a/test/delegation/cubit/delegation_cubit_test.dart +++ b/test/delegation/cubit/delegation_cubit_test.dart @@ -61,7 +61,7 @@ void main() { blocTest( 'calls getDelegatedPillar once', build: () => delegationCubit, - act: (cubit) => cubit.fetchDataPeriodically(), + act: (Object? cubit) => cubit.fetchDataPeriodically(), verify: (_) { verify(() => mockZenon.embedded.pillar.getDelegatedPillar( emptyAddress, @@ -79,7 +79,7 @@ void main() { ).thenThrow(delegationException); }, build: () => delegationCubit, - act: (cubit) => cubit.fetchDataPeriodically(), + act: (Object? cubit) => cubit.fetchDataPeriodically(), expect: () => [ DelegationState(status: DashboardStatus.loading), DelegationState( @@ -93,11 +93,11 @@ void main() { 'emits [loading, success] when getDelegatedPillar ' 'returns a DelegationInfo instance', build: () => delegationCubit, - act: (cubit) => cubit.fetchDataPeriodically(), - expect: () => [ + act: (Object? cubit) => cubit.fetchDataPeriodically(), + expect: () => <>[ DelegationState(status: DashboardStatus.loading), isA() - .having((state) => state.status, 'status', DashboardStatus.success), + .having((Object? state) => state.status, 'status', DashboardStatus.success), ], ); }); From 87dc80d554a95fc6c86e703ddbb31ea1a12ab189 Mon Sep 17 00:00:00 2001 From: maznnwell <181888996+maznnwell@users.noreply.github.com> Date: Mon, 28 Oct 2024 20:03:05 +0200 Subject: [PATCH 053/102] chore: Solve linter hints in rearchitecture folder --- .../features/balance/view/balance_card.dart | 2 +- .../balance/widgets/balance_address.dart | 2 +- .../balance/widgets/balance_populated.dart | 6 +- .../delegation/cubit/delegation_cubit.dart | 4 +- .../delegation/view/delegation_card.dart | 2 +- .../cubit/dual_coin_stats_cubit.dart | 9 ++- .../view/dual_coin_stats_card.dart | 2 +- .../widgets/dual_coin_stats_chart.dart | 12 ++- .../widgets/dual_coin_stats_populated.dart | 5 +- .../features/pillars/cubit/pillars_cubit.dart | 11 +-- .../features/pillars/view/pillars_card.dart | 2 +- .../cubit/realtime_statistics_cubit.dart | 80 ++++++++++--------- .../view/realtime_statistics_card.dart | 2 +- .../widgets/realtime_txs_chart.dart | 4 +- .../sentinels/view/sentinels_card.dart | 2 +- .../features/staking/view/staking_card.dart | 2 +- .../total_hourly_transactions_cubit.dart | 18 +++-- .../view/total_hourly_transactions_card.dart | 2 +- .../utils/cubits/timer_cubit.dart | 2 +- .../card_scaffold_without_listener.dart | 23 +++--- 20 files changed, 105 insertions(+), 87 deletions(-) diff --git a/lib/rearchitecture/features/balance/view/balance_card.dart b/lib/rearchitecture/features/balance/view/balance_card.dart index 93e5b29e..482c22e4 100644 --- a/lib/rearchitecture/features/balance/view/balance_card.dart +++ b/lib/rearchitecture/features/balance/view/balance_card.dart @@ -19,7 +19,7 @@ class BalanceCard extends StatelessWidget { @override Widget build(BuildContext context) { - return BlocProvider( + return BlocProvider( create: (_) { final BalanceCubit cubit = BalanceCubit( Address.parse(kSelectedAddress!), diff --git a/lib/rearchitecture/features/balance/widgets/balance_address.dart b/lib/rearchitecture/features/balance/widgets/balance_address.dart index 18d6bcf8..88b53a15 100644 --- a/lib/rearchitecture/features/balance/widgets/balance_address.dart +++ b/lib/rearchitecture/features/balance/widgets/balance_address.dart @@ -23,7 +23,7 @@ class BalanceAddress extends StatelessWidget { @override Widget build(BuildContext context) { - return ValueListenableBuilder( + return ValueListenableBuilder( valueListenable: edgesColorNotifier, builder: (_, Color? edgesColor, __) { return FocusableActionDetector( diff --git a/lib/rearchitecture/features/balance/widgets/balance_populated.dart b/lib/rearchitecture/features/balance/widgets/balance_populated.dart index dddb9929..1c0de197 100644 --- a/lib/rearchitecture/features/balance/widgets/balance_populated.dart +++ b/lib/rearchitecture/features/balance/widgets/balance_populated.dart @@ -33,13 +33,13 @@ class BalancePopulated extends StatefulWidget { } class _BalancePopulatedState extends State { - final ValueNotifier _touchedSectionId = ValueNotifier(null); + final ValueNotifier _touchedSectionId = ValueNotifier(null); late final ValueNotifier _addressEdgesColor; @override void didChangeDependencies() { super.didChangeDependencies(); - _addressEdgesColor = ValueNotifier(Theme.of(context).hintColor); + _addressEdgesColor = ValueNotifier(Theme.of(context).hintColor); } @override @@ -59,7 +59,7 @@ class _BalancePopulatedState extends State { accountInfo: widget.accountInfo, hoveredSectionId: _touchedSectionId, ), - ValueListenableBuilder( + ValueListenableBuilder( valueListenable: _touchedSectionId, builder: (_, String? id, __) { final Widget center = id != null diff --git a/lib/rearchitecture/features/delegation/cubit/delegation_cubit.dart b/lib/rearchitecture/features/delegation/cubit/delegation_cubit.dart index 5f077eed..bc151d32 100644 --- a/lib/rearchitecture/features/delegation/cubit/delegation_cubit.dart +++ b/lib/rearchitecture/features/delegation/cubit/delegation_cubit.dart @@ -4,6 +4,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'delegation_cubit.g.dart'; + part 'delegation_state.dart'; /// A cubit that manages the fetching and state of delegation information @@ -28,7 +29,8 @@ class DelegationCubit extends TimerCubit { /// - If not available, it throws an exception @override Future fetch() async { - final DelegationInfo? delegationInfo = await zenon.embedded.pillar.getDelegatedPillar( + final DelegationInfo? delegationInfo = + await zenon.embedded.pillar.getDelegatedPillar( address, ); diff --git a/lib/rearchitecture/features/delegation/view/delegation_card.dart b/lib/rearchitecture/features/delegation/view/delegation_card.dart index 92a7b883..d08f99b6 100644 --- a/lib/rearchitecture/features/delegation/view/delegation_card.dart +++ b/lib/rearchitecture/features/delegation/view/delegation_card.dart @@ -14,7 +14,7 @@ class DelegationCard extends StatelessWidget { @override Widget build(BuildContext context) { - return BlocProvider( + return BlocProvider( create: (_) { final DelegationCubit cubit = DelegationCubit( Address.parse(kSelectedAddress!), diff --git a/lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_cubit.dart b/lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_cubit.dart index 92b595bc..9953932d 100644 --- a/lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_cubit.dart +++ b/lib/rearchitecture/features/dual_coin_stats/cubit/dual_coin_stats_cubit.dart @@ -12,8 +12,7 @@ part 'dual_coin_stats_state.dart'; /// This cubit extends [TimerCubit], using a list of [Token] objects to /// represent the statistics for the ZNN and QSR tokens fetched from the Zenon /// network. -class DualCoinStatsCubit - extends TimerCubit, DualCoinStatsState> { +class DualCoinStatsCubit extends TimerCubit, DualCoinStatsState> { /// Constructs a [DualCoinStatsCubit], passing the [zenon] client and the /// initial state to the parent class. /// @@ -38,7 +37,11 @@ class DualCoinStatsCubit ); // For ZNN and QSR, the network will return non-nullable data - final List nonNullableData = data.map((Token? token) => token!).toList(); + final List nonNullableData = data + .map( + (Token? token) => token!, + ) + .toList(); return nonNullableData; } diff --git a/lib/rearchitecture/features/dual_coin_stats/view/dual_coin_stats_card.dart b/lib/rearchitecture/features/dual_coin_stats/view/dual_coin_stats_card.dart index 2bfaf9e3..33409fd5 100644 --- a/lib/rearchitecture/features/dual_coin_stats/view/dual_coin_stats_card.dart +++ b/lib/rearchitecture/features/dual_coin_stats/view/dual_coin_stats_card.dart @@ -15,7 +15,7 @@ class DualCoinStatsCard extends StatelessWidget { @override Widget build(BuildContext context) { - return BlocProvider( + return BlocProvider( create: (_) { final DualCoinStatsCubit cubit = DualCoinStatsCubit( zenon!, diff --git a/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart.dart b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart.dart index ffb35c82..40584d9d 100644 --- a/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart.dart +++ b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_chart.dart @@ -10,7 +10,6 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// When the cursor hovers over a section, that respective section is /// highlighted class DualCoinStatsChart extends StatelessWidget { - /// Create a DualCoinStatsChart const DualCoinStatsChart({ required this.tokenList, @@ -20,13 +19,14 @@ class DualCoinStatsChart extends StatelessWidget { /// List of [Token] that will provide data for the chart final List tokenList; + /// ValueNotifier used for rebuilding the widget tree when a section of the /// chart is being hovered over final ValueNotifier touchedSectionIndexNotifier; @override Widget build(BuildContext context) { - return ValueListenableBuilder( + return ValueListenableBuilder( valueListenable: touchedSectionIndexNotifier, builder: (_, int? index, ___) => AspectRatio( aspectRatio: 1, @@ -54,9 +54,13 @@ class DualCoinStatsChart extends StatelessWidget { }) { final BigInt totalSupply = tokenList.fold( BigInt.zero, - (BigInt previousValue, Token element) => previousValue + element.totalSupply, + ( + BigInt previousValue, + Token element, + ) => + previousValue + element.totalSupply, ); - return List.generate( + return List.generate( tokenList.length, (int i) { final Token currentTokenInfo = tokenList[i]; diff --git a/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_populated.dart b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_populated.dart index 06ae8102..ca6ce10e 100644 --- a/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_populated.dart +++ b/lib/rearchitecture/features/dual_coin_stats/widgets/dual_coin_stats_populated.dart @@ -8,7 +8,6 @@ import 'package:znn_sdk_dart/znn_sdk_dart.dart'; /// - [DualCoinStatsChart] - and a legend - [DualCoinStatsChartLegend] class DualCoinStatsPopulated extends StatefulWidget { - /// Creates a DualCoinStatsPopulated widget const DualCoinStatsPopulated({ required this.tokens, @@ -24,7 +23,9 @@ class DualCoinStatsPopulated extends StatefulWidget { class _DualCoinStatsPopulatedState extends State with SingleTickerProviderStateMixin { - final ValueNotifier _touchedSectionIndexNotifier = ValueNotifier(null); + final ValueNotifier _touchedSectionIndexNotifier = ValueNotifier( + null, + ); @override Widget build(BuildContext context) { diff --git a/lib/rearchitecture/features/pillars/cubit/pillars_cubit.dart b/lib/rearchitecture/features/pillars/cubit/pillars_cubit.dart index 44faad4d..489be006 100644 --- a/lib/rearchitecture/features/pillars/cubit/pillars_cubit.dart +++ b/lib/rearchitecture/features/pillars/cubit/pillars_cubit.dart @@ -1,6 +1,6 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/utils.dart'; -import 'package:znn_sdk_dart/src/model/embedded/pillar.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'pillars_cubit.g.dart'; @@ -21,10 +21,11 @@ class PillarsCubit extends TimerCubit { /// Fetches the total count of pillars from the Zenon network. @override Future fetch() async { - // Fetches the list of all pillars from the Zenon network - final PillarInfoList pillarInfoList = await zenon.embedded.pillar.getAll(); - final int data = pillarInfoList.list.length; // Counts the number of pillars - return data; // Returns the total number of pillars + // Fetches the list of all pillars from the Zenon network + final PillarInfoList pillarInfoList = await zenon.embedded.pillar.getAll(); + // Counts the number of pillars + final int data = pillarInfoList.list.length; + return data; // Returns the total number of pillars } @override diff --git a/lib/rearchitecture/features/pillars/view/pillars_card.dart b/lib/rearchitecture/features/pillars/view/pillars_card.dart index 24f5b4db..92a00c46 100644 --- a/lib/rearchitecture/features/pillars/view/pillars_card.dart +++ b/lib/rearchitecture/features/pillars/view/pillars_card.dart @@ -13,7 +13,7 @@ class PillarsCard extends StatelessWidget { @override Widget build(BuildContext context) { - return BlocProvider( + return BlocProvider( create: (_) { final PillarsCubit cubit = PillarsCubit( zenon!, diff --git a/lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_cubit.dart b/lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_cubit.dart index 685458ec..c1028572 100644 --- a/lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_cubit.dart +++ b/lib/rearchitecture/features/realtime_statistics/cubit/realtime_statistics_cubit.dart @@ -6,6 +6,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'realtime_statistics_cubit.g.dart'; + part 'realtime_statistics_state.dart'; /// [RealtimeStatisticsCubit] manages the fetching and state of real-time @@ -41,51 +42,52 @@ class RealtimeStatisticsCubit /// - An [NoBlocksAvailableException] if no data is available @override Future> fetch() async { - // Get the current chain height - final int chainHeight = (await zenon.ledger.getFrontierMomentum()).height; - // Calculate the starting height for the block retrieval - final int height = chainHeight - kMomentumsPerWeek > 0 - ? chainHeight - kMomentumsPerWeek - : 1; - int pageIndex = 0; // Start from the first page - const int pageSize = 10; // Number of blocks to fetch per page - bool isLastPage = false; // Flag to determine if it's the last page - final List blockList = - []; // List to store fetched account blocks - - // Fetch account blocks until the last page is reached - while (!isLastPage) { - // Fetch account blocks for the current page - final List response = (await zenon.ledger.getAccountBlocksByPage( - Address.parse(kSelectedAddress!), - pageIndex: pageIndex, - pageSize: pageSize, - )) - .list ?? // Default to an empty list if no blocks are found - []; + // Get the current chain height + final int chainHeight = (await zenon.ledger.getFrontierMomentum()).height; + // Calculate the starting height for the block retrieval + final int height = chainHeight - kMomentumsPerWeek > 0 + ? chainHeight - kMomentumsPerWeek + : 1; + int pageIndex = 0; // Start from the first page + const int pageSize = 10; // Number of blocks to fetch per page + bool isLastPage = false; // Flag to determine if it's the last page + final List blockList = + []; // List to store fetched account blocks - if (response.isEmpty) { - break; // Exit the loop if no more blocks are found - } + // Fetch account blocks until the last page is reached + while (!isLastPage) { + // Fetch account blocks for the current page + final AccountBlockList accountBlockList = + await zenon.ledger.getAccountBlocksByPage( + Address.parse(kSelectedAddress!), + pageIndex: pageIndex, + pageSize: pageSize, + ); + // Default to an empty list if no blocks are found + final List response = + accountBlockList.list ?? []; - blockList.addAll(response); // Add the fetched blocks to the list + if (response.isEmpty) { + break; // Exit the loop if no more blocks are found + } - // Check if the last block's momentum height is less than the - // calculated height - if (response.last.confirmationDetail!.momentumHeight <= height) { - break; // Exit if we've fetched enough data - } + blockList.addAll(response); // Add the fetched blocks to the list - pageIndex += 1; // Increment the page index for the next fetch - isLastPage = - response.length < pageSize; // Check if this is the last page + // Check if the last block's momentum height is less than the + // calculated height + if (response.last.confirmationDetail!.momentumHeight <= height) { + break; // Exit if we've fetched enough data } - if (blockList.isNotEmpty) { - return blockList; // Return the list of fetched blocks if available - } else { - throw NoBlocksAvailableException(); - } + pageIndex += 1; // Increment the page index for the next fetch + isLastPage = response.length < pageSize; // Check if this is the last page + } + + if (blockList.isNotEmpty) { + return blockList; // Return the list of fetched blocks if available + } else { + throw NoBlocksAvailableException(); + } } @override diff --git a/lib/rearchitecture/features/realtime_statistics/view/realtime_statistics_card.dart b/lib/rearchitecture/features/realtime_statistics/view/realtime_statistics_card.dart index 449ec836..1f1c46f2 100644 --- a/lib/rearchitecture/features/realtime_statistics/view/realtime_statistics_card.dart +++ b/lib/rearchitecture/features/realtime_statistics/view/realtime_statistics_card.dart @@ -13,7 +13,7 @@ class RealtimeStatisticsCard extends StatelessWidget { @override Widget build(BuildContext context) { - return BlocProvider( + return BlocProvider( create: (_) { final RealtimeStatisticsCubit cubit = RealtimeStatisticsCubit( zenon!, diff --git a/lib/rearchitecture/features/realtime_statistics/widgets/realtime_txs_chart.dart b/lib/rearchitecture/features/realtime_statistics/widgets/realtime_txs_chart.dart index 383fce0d..4957b901 100644 --- a/lib/rearchitecture/features/realtime_statistics/widgets/realtime_txs_chart.dart +++ b/lib/rearchitecture/features/realtime_statistics/widgets/realtime_txs_chart.dart @@ -103,7 +103,7 @@ class _RealtimeTxsChartState extends State { } List _generateQsrSpots() { - return List.generate( + return List.generate( kStandardChartNumDays.toInt(), (int index) => FlSpot( index.toDouble(), @@ -118,7 +118,7 @@ class _RealtimeTxsChartState extends State { } List _generateZnnSpots() { - return List.generate( + return List.generate( kStandardChartNumDays.toInt(), (int index) => FlSpot( index.toDouble(), diff --git a/lib/rearchitecture/features/sentinels/view/sentinels_card.dart b/lib/rearchitecture/features/sentinels/view/sentinels_card.dart index 79d84934..6384966b 100644 --- a/lib/rearchitecture/features/sentinels/view/sentinels_card.dart +++ b/lib/rearchitecture/features/sentinels/view/sentinels_card.dart @@ -13,7 +13,7 @@ class SentinelsCard extends StatelessWidget { @override Widget build(BuildContext context) { - return BlocProvider( + return BlocProvider( create: (_) { final SentinelsCubit cubit = SentinelsCubit( zenon!, diff --git a/lib/rearchitecture/features/staking/view/staking_card.dart b/lib/rearchitecture/features/staking/view/staking_card.dart index 87d71f05..8282023c 100644 --- a/lib/rearchitecture/features/staking/view/staking_card.dart +++ b/lib/rearchitecture/features/staking/view/staking_card.dart @@ -13,7 +13,7 @@ class StakingCard extends StatelessWidget { @override Widget build(BuildContext context) { - return BlocProvider( + return BlocProvider( create: (_) { final StakingCubit cubit = StakingCubit( zenon!, diff --git a/lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart b/lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart index 98564126..8cb78774 100644 --- a/lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart +++ b/lib/rearchitecture/features/total_hourly_transactions/cubit/total_hourly_transactions_cubit.dart @@ -4,7 +4,7 @@ import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/cubits/timer_cu import 'package:zenon_syrius_wallet_flutter/rearchitecture/utils/exceptions/exceptions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; -import 'package:znn_sdk_dart/src/model/nom/detailed_momentum.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; part 'total_hourly_transactions_cubit.g.dart'; @@ -37,17 +37,19 @@ class TotalHourlyTransactionsCubit final int chainHeight = await _ledgerGetMomentumLedgerHeight(); if (chainHeight - kMomentumsPerHour > 0) { // Fetch detailed momentums for the past hour - final List response = (await zenon.ledger.getDetailedMomentumsByHeight( - chainHeight - kMomentumsPerHour, - kMomentumsPerHour, - )) - .list ?? - []; + final List response = + (await zenon.ledger.getDetailedMomentumsByHeight( + chainHeight - kMomentumsPerHour, + kMomentumsPerHour, + )) + .list ?? + []; // Prepare the transaction summary final int transactions = response.fold( 0, - (int previousValue, DetailedMomentum element) => previousValue + element.blocks.length, + (int previousValue, DetailedMomentum element) => + previousValue + element.blocks.length, ); return transactions; // Return the summary of transactions } else { diff --git a/lib/rearchitecture/features/total_hourly_transactions/view/total_hourly_transactions_card.dart b/lib/rearchitecture/features/total_hourly_transactions/view/total_hourly_transactions_card.dart index 5b8232c4..510eea51 100644 --- a/lib/rearchitecture/features/total_hourly_transactions/view/total_hourly_transactions_card.dart +++ b/lib/rearchitecture/features/total_hourly_transactions/view/total_hourly_transactions_card.dart @@ -13,7 +13,7 @@ class TotalHourlyTransactionsCard extends StatelessWidget { @override Widget build(BuildContext context) { - return BlocProvider( + return BlocProvider( create: (_) { final TotalHourlyTransactionsCubit cubit = TotalHourlyTransactionsCubit( zenon!, diff --git a/lib/rearchitecture/utils/cubits/timer_cubit.dart b/lib/rearchitecture/utils/cubits/timer_cubit.dart index e300e010..b5ff02f1 100644 --- a/lib/rearchitecture/utils/cubits/timer_cubit.dart +++ b/lib/rearchitecture/utils/cubits/timer_cubit.dart @@ -71,7 +71,7 @@ abstract class TimerCubit> try { emit(state.copyWith(status: TimerStatus.loading) as S); if (!zenon.wsClient.isClosed()) { - final data = await fetch(); + final T data = await fetch(); emit(state.copyWith(data: data, status: TimerStatus.success) as S); } else { throw noConnectionException; diff --git a/lib/rearchitecture/utils/widgets/card_scaffold_without_listener.dart b/lib/rearchitecture/utils/widgets/card_scaffold_without_listener.dart index 8e410752..15a1a96e 100644 --- a/lib/rearchitecture/utils/widgets/card_scaffold_without_listener.dart +++ b/lib/rearchitecture/utils/widgets/card_scaffold_without_listener.dart @@ -11,22 +11,24 @@ import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class CardScaffoldWithoutListener extends StatefulWidget { - const CardScaffoldWithoutListener({ required this.body, required this.data, this.onRefreshPressed, super.key, }); + final Widget body; final CardData data; final VoidCallback? onRefreshPressed; @override - State createState() => _CardScaffoldWithoutListenerState(); + State createState() => + _CardScaffoldWithoutListenerState(); } -class _CardScaffoldWithoutListenerState extends State { +class _CardScaffoldWithoutListenerState + extends State { GlobalKey cardKey = GlobalKey(); final GlobalKey _actionButtonKey = GlobalKey(); @@ -37,9 +39,10 @@ class _CardScaffoldWithoutListenerState extends State widget.data.title; + String get _description => widget.data.description; @override @@ -58,7 +61,7 @@ class _CardScaffoldWithoutListenerState extends State[ @@ -196,7 +199,7 @@ class _CardScaffoldWithoutListenerState extends State