From 2df2dff92b0cf8ffe5ae13b65f61db388b9ac119 Mon Sep 17 00:00:00 2001 From: reasje Date: Tue, 12 Mar 2024 17:53:27 +0330 Subject: [PATCH 1/3] refactor: improve ux by schedule snack bar --- assets/flutter_i18n/en.json | 3 +- .../dapp_hooks/utils/miner_hooks_helper.dart | 35 ++++++++++++------- .../dapp_hooks/utils/snack_bar_utils.dart | 7 ++++ .../dapp_hooks/widgets/auto_claim_dialog.dart | 4 +-- 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/assets/flutter_i18n/en.json b/assets/flutter_i18n/en.json index 408f6b09..be9fe17e 100644 --- a/assets/flutter_i18n/en.json +++ b/assets/flutter_i18n/en.json @@ -346,5 +346,6 @@ "wifi_hooks_solutions": "Try re-enabling. \nRequirements :\n1. Location permission for always should be permitted \n2. Locations service should be running \n3. You should be connected to a Wi-Fi", "auto_claim_execution_dialog_title": "Time Already Passed!", "auto_claim_execution_dialog_text": "The time for auto claim has elapsed. Would you like to execute auto claim now?", - "execute": "Execute" + "execute": "Execute", + "auto_claim_scheduling_text": "Auto-claim will execute at {0} tomorrow" } \ No newline at end of file diff --git a/lib/features/settings/subfeatures/dapp_hooks/utils/miner_hooks_helper.dart b/lib/features/settings/subfeatures/dapp_hooks/utils/miner_hooks_helper.dart index 42ae841a..a15f70c9 100644 --- a/lib/features/settings/subfeatures/dapp_hooks/utils/miner_hooks_helper.dart +++ b/lib/features/settings/subfeatures/dapp_hooks/utils/miner_hooks_helper.dart @@ -3,8 +3,7 @@ import 'package:datadashwallet/features/common/common.dart'; import 'package:datadashwallet/features/settings/subfeatures/dapp_hooks/utils/utils.dart'; import 'package:datadashwallet/features/settings/subfeatures/notifications/domain/background_fetch_config_use_case.dart'; import 'package:flutter/material.dart'; - -import '../dapp_hooks_state.dart'; +import 'package:intl/intl.dart'; import '../domain/dapp_hooks_use_case.dart'; import '../widgets/auto_claim_dialog.dart'; import '../widgets/background_fetch_dialog.dart'; @@ -35,20 +34,28 @@ class MinerHooksHelper { final success = await dAppHooksUseCase.scheduleAutoClaimTransaction(time); final reached = dAppHooksUseCase.isTimeReached(time); + bool shouldShowScheduleSnackBar = false; + if (success) { // Time past, need to run the auto claim if (reached) { - await showAutoClaimExecutionAlertDialog( - context: context!, - executeAutoClaim: () { - dAppHooksUseCase.claimMiners( - account: accountUseCase.account.value!, - minerAutoClaimTime: time, - selectedMinerListId: dAppHooksUseCase - .dappHooksData.value.minerHooks.selectedMiners); - }); + shouldShowScheduleSnackBar = !(await showAutoClaimExecutionAlertDialog( + context: context!, + executeAutoClaim: () { + dAppHooksUseCase.claimMiners( + account: accountUseCase.account.value!, + minerAutoClaimTime: time, + selectedMinerListId: dAppHooksUseCase + .dappHooksData.value.minerHooks.selectedMiners); + }) ?? + false); + } + if (shouldShowScheduleSnackBar) { + dappHooksSnackBarUtils + .showScheduleSnackBar(DateFormat('HH:mm').format(time)); + } else { + dappHooksSnackBarUtils.showMinerHooksServiceSuccessSnackBar(); } - dappHooksSnackBarUtils.showMinerHooksServiceSuccessSnackBar(); return true; } else { dappHooksSnackBarUtils.showMinerHooksServiceFailureSnackBar(); @@ -70,7 +77,9 @@ class MinerHooksHelper { return true; } - Future changeMinerHooksEnabled(bool value) { + Future changeMinerHooksEnabled( + bool value, + ) { return DAppHooksHelper.shouldUpdateWrapper(() async { late bool update; if (value) { diff --git a/lib/features/settings/subfeatures/dapp_hooks/utils/snack_bar_utils.dart b/lib/features/settings/subfeatures/dapp_hooks/utils/snack_bar_utils.dart index dead6293..baa5e3c4 100644 --- a/lib/features/settings/subfeatures/dapp_hooks/utils/snack_bar_utils.dart +++ b/lib/features/settings/subfeatures/dapp_hooks/utils/snack_bar_utils.dart @@ -52,6 +52,13 @@ class DappHooksSnackBarUtils { .replaceAll('{0}', translate('miner_hooks')!)); } + void showScheduleSnackBar(String time) { + showSnackBar( + context: context!, + content: + translate('auto_claim_scheduling_text')!.replaceAll('{0}', time)); + } + void showMinerHooksServiceDisableSuccessSnackBar() { showSnackBar( context: context!, diff --git a/lib/features/settings/subfeatures/dapp_hooks/widgets/auto_claim_dialog.dart b/lib/features/settings/subfeatures/dapp_hooks/widgets/auto_claim_dialog.dart index 15828c5f..317e1526 100644 --- a/lib/features/settings/subfeatures/dapp_hooks/widgets/auto_claim_dialog.dart +++ b/lib/features/settings/subfeatures/dapp_hooks/widgets/auto_claim_dialog.dart @@ -51,9 +51,7 @@ Future showAutoClaimExecutionAlertDialog( MxcButton.secondary( key: const ValueKey('cancelButton'), title: translate('cancel'), - onTap: () { - Navigator.of(context).pop(true); - }, + onTap: () => Navigator.of(context).pop(false), size: AxsButtonSize.xl, ), const SizedBox( From c54ad2872da96d491cda1e8e7a2b2ed0dce09830 Mon Sep 17 00:00:00 2001 From: reasje Date: Tue, 12 Mar 2024 17:53:40 +0330 Subject: [PATCH 2/3] fix: update shared --- packages/shared | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shared b/packages/shared index 42a54d45..3ef401df 160000 --- a/packages/shared +++ b/packages/shared @@ -1 +1 @@ -Subproject commit 42a54d451cab1397951132153c35cbeee2b7a0f2 +Subproject commit 3ef401df7320f83fe9057058317e966c6ca48759 From 0f4bfc1b4bda9c4502d28dea5c76e1886393f623 Mon Sep 17 00:00:00 2001 From: reasje Date: Tue, 12 Mar 2024 18:13:27 +0330 Subject: [PATCH 3/3] fix: Long url address bar --- .../open_dapp/widgets/drag_down_panel.dart | 114 ++++++++++-------- 1 file changed, 65 insertions(+), 49 deletions(-) diff --git a/lib/features/dapps/subfeatures/open_dapp/widgets/drag_down_panel.dart b/lib/features/dapps/subfeatures/open_dapp/widgets/drag_down_panel.dart index 51dc576c..a20b987b 100644 --- a/lib/features/dapps/subfeatures/open_dapp/widgets/drag_down_panel.dart +++ b/lib/features/dapps/subfeatures/open_dapp/widgets/drag_down_panel.dart @@ -23,7 +23,7 @@ class DragDownPanel extends HookConsumerWidget { final logo = state.network!.logo; final name = state.network!.label ?? state.network!.web3RpcHttpUrl; - final url = state.currentUrl; + final url = state.currentUrl?.host ?? ''; final isSecure = state.isSecure; state.animationController = useAnimationController(); @@ -63,62 +63,78 @@ class DragDownPanel extends HookConsumerWidget { ColorsTheme.of(context).screenBackground, )), child: Stack( + fit: StackFit.passthrough, children: [ - Row( - children: [ - IconButton( - key: const Key('closedAppButton'), - onPressed: () { - presenter.closedApp(); - }, - icon: const Icon( - Icons.close_rounded, - size: 24, - )), - InkWell( - onTap: presenter - .showNetworkDetailsBottomSheet, - child: ChainLogoWidget(logo: logo)), - ], - ), - Center( + Expanded( child: Row( - mainAxisAlignment: MainAxisAlignment.center, children: [ - const SizedBox( - width: Sizes.space2XSmall, + Row( + children: [ + IconButton( + key: const Key('closedAppButton'), + onPressed: () { + presenter.closedApp(); + }, + icon: const Icon( + Icons.close_rounded, + size: 24, + )), + InkWell( + onTap: presenter + .showNetworkDetailsBottomSheet, + child: + ChainLogoWidget(logo: logo)), + ], ), - isSecure - ? Icon( - Icons.lock_rounded, - color: ColorsTheme.of(context) - .textPrimary, - size: 16, - ) - : Icon( - Icons.warning, - color: ColorsTheme.of(context) - .mainRed, - size: 16, + Expanded( + child: Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + const SizedBox( + width: Sizes.space2XSmall, ), - const SizedBox( - width: Sizes.space2XSmall, - ), - InkWell( - onTap: () => presenter.copyUrl(), - child: Text( - url?.host ?? '', - style: FontTheme.of(context) - .body1 - .primary() - .copyWith( - fontWeight: FontWeight.w500), - overflow: TextOverflow.ellipsis, + isSecure + ? Icon( + Icons.lock_rounded, + color: + ColorsTheme.of(context) + .textPrimary, + size: 16, + ) + : Icon( + Icons.warning, + color: + ColorsTheme.of(context) + .mainRed, + size: 16, + ), + const SizedBox( + width: Sizes.space2XSmall, + ), + Expanded( + child: InkWell( + onTap: () => + presenter.copyUrl(), + child: Text( + url, + style: FontTheme.of(context) + .body1 + .primary() + .copyWith( + fontWeight: + FontWeight.w500), + overflow: + TextOverflow.ellipsis, + ), + ), + ) + ], ), - ) + ), ], ), - ), + ) ], ), ),