From 5d46ee3587a3f6bd1f263eea397efed3fbb0afb4 Mon Sep 17 00:00:00 2001 From: Zied Dahmani Date: Wed, 16 Oct 2024 11:21:43 +0100 Subject: [PATCH] refactor: apply changes from PR review --- ios/Podfile.lock | 20 ++++---- .../interactor/proposal_creation_bloc.dart | 2 +- .../creation/proposal_creation_page.dart | 8 ++-- .../failed/sign_transaction_failed_page.dart} | 4 +- .../interactor/page_command.dart | 2 +- .../interactor/sign_transaction_bloc.dart | 4 +- .../sign_transaction_bloc.freezed.dart | 47 ++++++++++++------- .../sign_transaction_page.dart | 8 ++-- .../sign_transaction_success_page.dart} | 23 +++++---- 9 files changed, 65 insertions(+), 53 deletions(-) rename lib/{design/status/failure_page.dart => ui/sign_transaction/failed/sign_transaction_failed_page.dart} (93%) rename lib/{design/status/success_page.dart => ui/sign_transaction/success/sign_transaction_success_page.dart} (84%) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 1ca4b715..bc91c775 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1097,7 +1097,7 @@ PODS: - PromisesSwift (~> 2.1) - FirebaseSharedSwift (10.29.0) - Flutter (1.0.0) - - flutter_keyboard_visibility_temp_fork (0.0.1): + - flutter_keyboard_visibility (0.0.1): - Flutter - flutter_secure_storage (6.0.0): - Flutter @@ -1293,7 +1293,7 @@ PODS: - PromisesObjC (2.4.0) - PromisesSwift (2.4.0): - PromisesObjC (= 2.4.0) - - quill_native_bridge (0.0.1): + - quill_native_bridge_ios (0.0.1): - Flutter - share_plus (0.0.1): - Flutter @@ -1317,7 +1317,7 @@ DEPENDENCIES: - firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`) - firebase_remote_config (from `.symlinks/plugins/firebase_remote_config/ios`) - Flutter (from `Flutter`) - - flutter_keyboard_visibility_temp_fork (from `.symlinks/plugins/flutter_keyboard_visibility_temp_fork/ios`) + - flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`) - flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`) - image_cropper (from `.symlinks/plugins/image_cropper/ios`) - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) @@ -1325,7 +1325,7 @@ DEPENDENCIES: - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) - - quill_native_bridge (from `.symlinks/plugins/quill_native_bridge/ios`) + - quill_native_bridge_ios (from `.symlinks/plugins/quill_native_bridge_ios/ios`) - share_plus (from `.symlinks/plugins/share_plus/ios`) - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) - sqflite (from `.symlinks/plugins/sqflite/darwin`) @@ -1390,8 +1390,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/firebase_remote_config/ios" Flutter: :path: Flutter - flutter_keyboard_visibility_temp_fork: - :path: ".symlinks/plugins/flutter_keyboard_visibility_temp_fork/ios" + flutter_keyboard_visibility: + :path: ".symlinks/plugins/flutter_keyboard_visibility/ios" flutter_secure_storage: :path: ".symlinks/plugins/flutter_secure_storage/ios" image_cropper: @@ -1406,8 +1406,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/path_provider_foundation/darwin" permission_handler_apple: :path: ".symlinks/plugins/permission_handler_apple/ios" - quill_native_bridge: - :path: ".symlinks/plugins/quill_native_bridge/ios" + quill_native_bridge_ios: + :path: ".symlinks/plugins/quill_native_bridge_ios/ios" share_plus: :path: ".symlinks/plugins/share_plus/ios" shared_preferences_foundation: @@ -1446,7 +1446,7 @@ SPEC CHECKSUMS: FirebaseSessions: dbd14adac65ce996228652c1fc3a3f576bdf3ecc FirebaseSharedSwift: 20530f495084b8d840f78a100d8c5ee613375f6e Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 - flutter_keyboard_visibility_temp_fork: 442dadca3b81868a225cd6a2f605bffff1215844 + flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069 flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be GoogleAppMeasurement: 9abf64b682732fed36da827aa2a68f0221fd2356 GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a @@ -1471,7 +1471,7 @@ SPEC CHECKSUMS: permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6 PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47 PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851 - quill_native_bridge: e5afa7d49c08cf68c52a5e23bc272eba6925c622 + quill_native_bridge_ios: 277bdf5bf0fa5d7a12999556b415a5c63dd76ec4 share_plus: c3fef564749587fc939ef86ffb283ceac0baf9f5 shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec diff --git a/lib/ui/proposals/creation/interactor/proposal_creation_bloc.dart b/lib/ui/proposals/creation/interactor/proposal_creation_bloc.dart index 8188cf46..150731d0 100644 --- a/lib/ui/proposals/creation/interactor/proposal_creation_bloc.dart +++ b/lib/ui/proposals/creation/interactor/proposal_creation_bloc.dart @@ -35,7 +35,7 @@ class ProposalCreationBloc navigate(emit, event.nextViewIndex); break; case 2: - if(state.proposal!.details != null) { + if(state.proposal!.title != null && state.proposal!.details != null) { navigate(emit, event.nextViewIndex); } break; diff --git a/lib/ui/proposals/creation/proposal_creation_page.dart b/lib/ui/proposals/creation/proposal_creation_page.dart index f0a0c7ff..87e7706c 100644 --- a/lib/ui/proposals/creation/proposal_creation_page.dart +++ b/lib/ui/proposals/creation/proposal_creation_page.dart @@ -4,8 +4,8 @@ import 'package:get/get.dart'; import 'package:get_it/get_it.dart'; import 'package:hypha_wallet/core/error_handler/model/hypha_error.dart'; import 'package:hypha_wallet/design/hypha_colors.dart'; -import 'package:hypha_wallet/design/status/failure_page.dart'; -import 'package:hypha_wallet/design/status/success_page.dart'; +import 'package:hypha_wallet/ui/sign_transaction/failed/sign_transaction_failed_page.dart'; +import 'package:hypha_wallet/ui/sign_transaction/success/sign_transaction_success_page.dart'; import 'package:hypha_wallet/design/themes/extensions/theme_extension_provider.dart'; import 'package:hypha_wallet/ui/proposals/creation/components/proposal_content_view.dart'; import 'package:hypha_wallet/ui/proposals/creation/components/proposal_review_view.dart'; @@ -47,11 +47,11 @@ class ProposalCreationPage extends StatelessWidget { Get.back(); }, navigateToSuccessPage: () { - Get.to(SuccessPage(successType: SuccessType.published, proposalId: state.proposal!.id)); + Get.to(SignTransactionSuccessPage(transactionType: SignSuccessTransactionType.published, proposalId: state.proposal!.id)); }, navigateToFailurePage: (HyphaError hyphaError) { // TODO(Zied): pass text1 and text2 - Get.to(FailurePage(hyphaError)); + Get.to(SignTransactionFailedPage(hyphaError)); }, ); diff --git a/lib/design/status/failure_page.dart b/lib/ui/sign_transaction/failed/sign_transaction_failed_page.dart similarity index 93% rename from lib/design/status/failure_page.dart rename to lib/ui/sign_transaction/failed/sign_transaction_failed_page.dart index 60f15827..a3263463 100644 --- a/lib/design/status/failure_page.dart +++ b/lib/ui/sign_transaction/failed/sign_transaction_failed_page.dart @@ -10,12 +10,12 @@ import 'package:hypha_wallet/design/hypha_colors.dart'; import 'package:hypha_wallet/design/themes/extensions/theme_extension_provider.dart'; import 'package:hypha_wallet/ui/bottom_navigation/hypha_bottom_navigation.dart'; -class FailurePage extends StatelessWidget { +class SignTransactionFailedPage extends StatelessWidget { final HyphaError error; final String text1; final String text2; - const FailurePage(this.error, {super.key, this.text1 = 'This transaction ', this.text2 = 'Please try again by triggering the transaction from the website or app. Sorry for the inconvenience.'}); + const SignTransactionFailedPage(this.error, {super.key, this.text1 = 'This transaction ', this.text2 = 'Please try again by triggering the transaction from the website or app. Sorry for the inconvenience.'}); @override Widget build(BuildContext context) { diff --git a/lib/ui/sign_transaction/interactor/page_command.dart b/lib/ui/sign_transaction/interactor/page_command.dart index 450d81ac..cc1a1174 100644 --- a/lib/ui/sign_transaction/interactor/page_command.dart +++ b/lib/ui/sign_transaction/interactor/page_command.dart @@ -2,7 +2,7 @@ part of 'sign_transaction_bloc.dart'; @freezed class PageCommand with _$PageCommand { - const factory PageCommand.navigateToTransactionSuccess(SuccessType type) = + const factory PageCommand.navigateToTransactionSuccess(SignSuccessTransactionType type) = _NavigateToTransactionSuccess; const factory PageCommand.navigateToTransactionFailed(ErrorResult errorResult) = _NavigateToTransactionFailed; const factory PageCommand.navigateAway() = _NavigateAway; diff --git a/lib/ui/sign_transaction/interactor/sign_transaction_bloc.dart b/lib/ui/sign_transaction/interactor/sign_transaction_bloc.dart index 83756c07..d7417fd8 100644 --- a/lib/ui/sign_transaction/interactor/sign_transaction_bloc.dart +++ b/lib/ui/sign_transaction/interactor/sign_transaction_bloc.dart @@ -7,7 +7,7 @@ import 'package:hypha_wallet/core/logging/log_helper.dart'; import 'package:hypha_wallet/ui/architecture/interactor/page_states.dart'; import 'package:hypha_wallet/ui/architecture/result/result.dart'; import 'package:hypha_wallet/ui/sign_transaction/interactor/data/transaction_action_data.dart'; -import 'package:hypha_wallet/design/status/success_page.dart'; +import 'package:hypha_wallet/ui/sign_transaction/success/sign_transaction_success_page.dart'; import 'package:hypha_wallet/ui/sign_transaction/usecases/sign_transaction_use_case.dart'; part 'page_command.dart'; @@ -45,7 +45,7 @@ class SignTransactionBloc extends Bloc({ - required TResult Function(SuccessType type) navigateToTransactionSuccess, + required TResult Function(SignSuccessTransactionType type) + navigateToTransactionSuccess, required TResult Function(ErrorResult errorResult) navigateToTransactionFailed, required TResult Function() navigateAway, @@ -26,7 +27,8 @@ mixin _$PageCommand { throw _privateConstructorUsedError; @optionalTypeArgs TResult? whenOrNull({ - TResult? Function(SuccessType type)? navigateToTransactionSuccess, + TResult? Function(SignSuccessTransactionType type)? + navigateToTransactionSuccess, TResult? Function(ErrorResult errorResult)? navigateToTransactionFailed, TResult? Function()? navigateAway, @@ -34,7 +36,8 @@ mixin _$PageCommand { throw _privateConstructorUsedError; @optionalTypeArgs TResult maybeWhen({ - TResult Function(SuccessType type)? navigateToTransactionSuccess, + TResult Function(SignSuccessTransactionType type)? + navigateToTransactionSuccess, TResult Function(ErrorResult errorResult)? navigateToTransactionFailed, TResult Function()? navigateAway, @@ -99,7 +102,7 @@ abstract class _$$NavigateToTransactionSuccessImplCopyWith<$Res> { $Res Function(_$NavigateToTransactionSuccessImpl) then) = __$$NavigateToTransactionSuccessImplCopyWithImpl<$Res>; @useResult - $Res call({SuccessType type}); + $Res call({SignSuccessTransactionType type}); } /// @nodoc @@ -122,7 +125,7 @@ class __$$NavigateToTransactionSuccessImplCopyWithImpl<$Res> null == type ? _value.type : type // ignore: cast_nullable_to_non_nullable - as SuccessType, + as SignSuccessTransactionType, )); } } @@ -134,7 +137,7 @@ class _$NavigateToTransactionSuccessImpl const _$NavigateToTransactionSuccessImpl(this.type); @override - final SuccessType type; + final SignSuccessTransactionType type; @override String toString() { @@ -165,7 +168,8 @@ class _$NavigateToTransactionSuccessImpl @override @optionalTypeArgs TResult when({ - required TResult Function(SuccessType type) navigateToTransactionSuccess, + required TResult Function(SignSuccessTransactionType type) + navigateToTransactionSuccess, required TResult Function(ErrorResult errorResult) navigateToTransactionFailed, required TResult Function() navigateAway, @@ -176,7 +180,8 @@ class _$NavigateToTransactionSuccessImpl @override @optionalTypeArgs TResult? whenOrNull({ - TResult? Function(SuccessType type)? navigateToTransactionSuccess, + TResult? Function(SignSuccessTransactionType type)? + navigateToTransactionSuccess, TResult? Function(ErrorResult errorResult)? navigateToTransactionFailed, TResult? Function()? navigateAway, @@ -187,7 +192,8 @@ class _$NavigateToTransactionSuccessImpl @override @optionalTypeArgs TResult maybeWhen({ - TResult Function(SuccessType type)? navigateToTransactionSuccess, + TResult Function(SignSuccessTransactionType type)? + navigateToTransactionSuccess, TResult Function(ErrorResult errorResult)? navigateToTransactionFailed, TResult Function()? navigateAway, @@ -241,10 +247,11 @@ class _$NavigateToTransactionSuccessImpl } abstract class _NavigateToTransactionSuccess implements PageCommand { - const factory _NavigateToTransactionSuccess(final SuccessType type) = + const factory _NavigateToTransactionSuccess( + final SignSuccessTransactionType type) = _$NavigateToTransactionSuccessImpl; - SuccessType get type; + SignSuccessTransactionType get type; /// Create a copy of PageCommand /// with the given fields replaced by the non-null parameter values. @@ -327,7 +334,8 @@ class _$NavigateToTransactionFailedImpl @override @optionalTypeArgs TResult when({ - required TResult Function(SuccessType type) navigateToTransactionSuccess, + required TResult Function(SignSuccessTransactionType type) + navigateToTransactionSuccess, required TResult Function(ErrorResult errorResult) navigateToTransactionFailed, required TResult Function() navigateAway, @@ -338,7 +346,8 @@ class _$NavigateToTransactionFailedImpl @override @optionalTypeArgs TResult? whenOrNull({ - TResult? Function(SuccessType type)? navigateToTransactionSuccess, + TResult? Function(SignSuccessTransactionType type)? + navigateToTransactionSuccess, TResult? Function(ErrorResult errorResult)? navigateToTransactionFailed, TResult? Function()? navigateAway, @@ -349,7 +358,8 @@ class _$NavigateToTransactionFailedImpl @override @optionalTypeArgs TResult maybeWhen({ - TResult Function(SuccessType type)? navigateToTransactionSuccess, + TResult Function(SignSuccessTransactionType type)? + navigateToTransactionSuccess, TResult Function(ErrorResult errorResult)? navigateToTransactionFailed, TResult Function()? navigateAway, @@ -457,7 +467,8 @@ class _$NavigateAwayImpl implements _NavigateAway { @override @optionalTypeArgs TResult when({ - required TResult Function(SuccessType type) navigateToTransactionSuccess, + required TResult Function(SignSuccessTransactionType type) + navigateToTransactionSuccess, required TResult Function(ErrorResult errorResult) navigateToTransactionFailed, required TResult Function() navigateAway, @@ -468,7 +479,8 @@ class _$NavigateAwayImpl implements _NavigateAway { @override @optionalTypeArgs TResult? whenOrNull({ - TResult? Function(SuccessType type)? navigateToTransactionSuccess, + TResult? Function(SignSuccessTransactionType type)? + navigateToTransactionSuccess, TResult? Function(ErrorResult errorResult)? navigateToTransactionFailed, TResult? Function()? navigateAway, @@ -479,7 +491,8 @@ class _$NavigateAwayImpl implements _NavigateAway { @override @optionalTypeArgs TResult maybeWhen({ - TResult Function(SuccessType type)? navigateToTransactionSuccess, + TResult Function(SignSuccessTransactionType type)? + navigateToTransactionSuccess, TResult Function(ErrorResult errorResult)? navigateToTransactionFailed, TResult Function()? navigateAway, diff --git a/lib/ui/sign_transaction/sign_transaction_page.dart b/lib/ui/sign_transaction/sign_transaction_page.dart index d8b6f567..d0779e0e 100644 --- a/lib/ui/sign_transaction/sign_transaction_page.dart +++ b/lib/ui/sign_transaction/sign_transaction_page.dart @@ -3,10 +3,10 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:get/get.dart' as GetX; import 'package:get_it/get_it.dart'; import 'package:hypha_wallet/core/crypto/seeds_esr/scan_qr_code_result_data.dart'; -import 'package:hypha_wallet/design/status/failure_page.dart'; -import 'package:hypha_wallet/design/status/success_page.dart'; import 'package:hypha_wallet/ui/sign_transaction/components/sign_transaction_view.dart'; +import 'package:hypha_wallet/ui/sign_transaction/failed/sign_transaction_failed_page.dart'; import 'package:hypha_wallet/ui/sign_transaction/interactor/sign_transaction_bloc.dart'; +import 'package:hypha_wallet/ui/sign_transaction/success/sign_transaction_success_page.dart'; class SignTransactionPage extends StatelessWidget { final ScanQrCodeResultData qrCodeData; @@ -23,11 +23,11 @@ class SignTransactionPage extends StatelessWidget { listener: (context, state) { state.command?.when(navigateToTransactionSuccess: (type) { GetX.Get.off( - () => SuccessPage(successType: type), + () => SignTransactionSuccessPage(transactionType: type), transition: GetX.Transition.downToUp, ); }, navigateToTransactionFailed: (error) { - GetX.Get.off(() => FailurePage(error.error), transition: GetX.Transition.downToUp); + GetX.Get.off(() => SignTransactionFailedPage(error.error), transition: GetX.Transition.downToUp); }, navigateAway: () { GetX.Get.back(); }); diff --git a/lib/design/status/success_page.dart b/lib/ui/sign_transaction/success/sign_transaction_success_page.dart similarity index 84% rename from lib/design/status/success_page.dart rename to lib/ui/sign_transaction/success/sign_transaction_success_page.dart index 97601c39..f627deb4 100644 --- a/lib/design/status/success_page.dart +++ b/lib/ui/sign_transaction/success/sign_transaction_success_page.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; -import 'package:get/get.dart' as Get; import 'package:hypha_wallet/design/background/hypha_half_background.dart'; import 'package:hypha_wallet/design/background/hypha_page_background.dart'; import 'package:hypha_wallet/design/bottom_component/hypha_safe_bottom_navigation_bar.dart'; @@ -11,11 +10,11 @@ import 'package:hypha_wallet/design/themes/extensions/theme_extension_provider.d import 'package:hypha_wallet/ui/bottom_navigation/hypha_bottom_navigation.dart'; import 'package:hypha_wallet/ui/proposals/details/proposal_details_page.dart'; -enum SuccessType { +enum SignSuccessTransactionType { approved('Approved'), published('published'); - const SuccessType(this.value); + const SignSuccessTransactionType(this.value); final String value; @@ -25,11 +24,11 @@ enum SuccessType { } -class SuccessPage extends StatelessWidget { - final SuccessType successType; +class SignTransactionSuccessPage extends StatelessWidget { + final SignSuccessTransactionType transactionType; final String? proposalId; - const SuccessPage({super.key, required this.successType, this.proposalId}); + const SignTransactionSuccessPage({super.key, required this.transactionType, this.proposalId}); @override Widget build(BuildContext context) { @@ -45,7 +44,7 @@ class SuccessPage extends StatelessWidget { style: context.hyphaTextTheme.regular.copyWith(color: HyphaColors.primaryBlu), ), const TextSpan(text: ' '), - TextSpan(text: successType.value), + TextSpan(text: transactionType.value), ], ), ); @@ -57,7 +56,7 @@ class SuccessPage extends StatelessWidget { bottomNavigationBar: HyphaSafeBottomNavigationBar( child: HyphaAppButton( onPressed: () { - Get.Get.offAll(() => const HyphaBottomNavigation()); + Get.offAll(() => const HyphaBottomNavigation()); }, title: 'Close', ), @@ -82,11 +81,11 @@ class SuccessPage extends StatelessWidget { decoration: BoxDecoration( shape: BoxShape.circle, border: Border.all( - color: successType.iconBorderColor, + color: transactionType.iconBorderColor, width: 2, ), ), - child: Icon(successType.icon, size: 24, color: successType.iconBorderColor), + child: Icon(transactionType.icon, size: 24, color: transactionType.iconBorderColor), ), const SizedBox(height: 16), if(proposalId != null) ... [ @@ -97,9 +96,9 @@ class SuccessPage extends StatelessWidget { buttonType: ButtonType.secondary, buttonColor: HyphaColors.gradientBlackLight, onPressed: () { - Get.Get.to( + Get.to( ProposalDetailsPage(proposalId: proposalId!), - transition: Get.Transition.rightToLeft, + transition: Transition.rightToLeft, ); }, title: 'See Proposal Details',