Skip to content

Commit

Permalink
refactor: apply changes from PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
Zied-Dahmani committed Oct 16, 2024
1 parent c7029c9 commit 5d46ee3
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 53 deletions.
20 changes: 10 additions & 10 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -1317,15 +1317,15 @@ 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`)
- mobile_scanner (from `.symlinks/plugins/mobile_scanner/ios`)
- 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`)
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions lib/ui/proposals/creation/proposal_creation_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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));
},
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/sign_transaction/interactor/page_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, HyphaError> errorResult) = _NavigateToTransactionFailed;
const factory PageCommand.navigateAway() = _NavigateAway;
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/sign_transaction/interactor/sign_transaction_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -45,7 +45,7 @@ class SignTransactionBloc extends Bloc<SignTransactionEvent, SignTransactionStat
));
if (result.isValue) {
emit(
state.copyWith(command: const PageCommand.navigateToTransactionSuccess(SuccessType.approved)),
state.copyWith(command: const PageCommand.navigateToTransactionSuccess(SignSuccessTransactionType.approved)),
);
} else {
LogHelper.e('Transaction error: ${result.asError?.error.message}');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,26 @@ final _privateConstructorUsedError = UnsupportedError(
mixin _$PageCommand {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(SuccessType type) navigateToTransactionSuccess,
required TResult Function(SignSuccessTransactionType type)
navigateToTransactionSuccess,
required TResult Function(ErrorResult<String, HyphaError> errorResult)
navigateToTransactionFailed,
required TResult Function() navigateAway,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(SuccessType type)? navigateToTransactionSuccess,
TResult? Function(SignSuccessTransactionType type)?
navigateToTransactionSuccess,
TResult? Function(ErrorResult<String, HyphaError> errorResult)?
navigateToTransactionFailed,
TResult? Function()? navigateAway,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(SuccessType type)? navigateToTransactionSuccess,
TResult Function(SignSuccessTransactionType type)?
navigateToTransactionSuccess,
TResult Function(ErrorResult<String, HyphaError> errorResult)?
navigateToTransactionFailed,
TResult Function()? navigateAway,
Expand Down Expand Up @@ -99,7 +102,7 @@ abstract class _$$NavigateToTransactionSuccessImplCopyWith<$Res> {
$Res Function(_$NavigateToTransactionSuccessImpl) then) =
__$$NavigateToTransactionSuccessImplCopyWithImpl<$Res>;
@useResult
$Res call({SuccessType type});
$Res call({SignSuccessTransactionType type});
}

/// @nodoc
Expand All @@ -122,7 +125,7 @@ class __$$NavigateToTransactionSuccessImplCopyWithImpl<$Res>
null == type
? _value.type
: type // ignore: cast_nullable_to_non_nullable
as SuccessType,
as SignSuccessTransactionType,
));
}
}
Expand All @@ -134,7 +137,7 @@ class _$NavigateToTransactionSuccessImpl
const _$NavigateToTransactionSuccessImpl(this.type);

@override
final SuccessType type;
final SignSuccessTransactionType type;

@override
String toString() {
Expand Down Expand Up @@ -165,7 +168,8 @@ class _$NavigateToTransactionSuccessImpl
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(SuccessType type) navigateToTransactionSuccess,
required TResult Function(SignSuccessTransactionType type)
navigateToTransactionSuccess,
required TResult Function(ErrorResult<String, HyphaError> errorResult)
navigateToTransactionFailed,
required TResult Function() navigateAway,
Expand All @@ -176,7 +180,8 @@ class _$NavigateToTransactionSuccessImpl
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(SuccessType type)? navigateToTransactionSuccess,
TResult? Function(SignSuccessTransactionType type)?
navigateToTransactionSuccess,
TResult? Function(ErrorResult<String, HyphaError> errorResult)?
navigateToTransactionFailed,
TResult? Function()? navigateAway,
Expand All @@ -187,7 +192,8 @@ class _$NavigateToTransactionSuccessImpl
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(SuccessType type)? navigateToTransactionSuccess,
TResult Function(SignSuccessTransactionType type)?
navigateToTransactionSuccess,
TResult Function(ErrorResult<String, HyphaError> errorResult)?
navigateToTransactionFailed,
TResult Function()? navigateAway,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -327,7 +334,8 @@ class _$NavigateToTransactionFailedImpl
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(SuccessType type) navigateToTransactionSuccess,
required TResult Function(SignSuccessTransactionType type)
navigateToTransactionSuccess,
required TResult Function(ErrorResult<String, HyphaError> errorResult)
navigateToTransactionFailed,
required TResult Function() navigateAway,
Expand All @@ -338,7 +346,8 @@ class _$NavigateToTransactionFailedImpl
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(SuccessType type)? navigateToTransactionSuccess,
TResult? Function(SignSuccessTransactionType type)?
navigateToTransactionSuccess,
TResult? Function(ErrorResult<String, HyphaError> errorResult)?
navigateToTransactionFailed,
TResult? Function()? navigateAway,
Expand All @@ -349,7 +358,8 @@ class _$NavigateToTransactionFailedImpl
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(SuccessType type)? navigateToTransactionSuccess,
TResult Function(SignSuccessTransactionType type)?
navigateToTransactionSuccess,
TResult Function(ErrorResult<String, HyphaError> errorResult)?
navigateToTransactionFailed,
TResult Function()? navigateAway,
Expand Down Expand Up @@ -457,7 +467,8 @@ class _$NavigateAwayImpl implements _NavigateAway {
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(SuccessType type) navigateToTransactionSuccess,
required TResult Function(SignSuccessTransactionType type)
navigateToTransactionSuccess,
required TResult Function(ErrorResult<String, HyphaError> errorResult)
navigateToTransactionFailed,
required TResult Function() navigateAway,
Expand All @@ -468,7 +479,8 @@ class _$NavigateAwayImpl implements _NavigateAway {
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(SuccessType type)? navigateToTransactionSuccess,
TResult? Function(SignSuccessTransactionType type)?
navigateToTransactionSuccess,
TResult? Function(ErrorResult<String, HyphaError> errorResult)?
navigateToTransactionFailed,
TResult? Function()? navigateAway,
Expand All @@ -479,7 +491,8 @@ class _$NavigateAwayImpl implements _NavigateAway {
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(SuccessType type)? navigateToTransactionSuccess,
TResult Function(SignSuccessTransactionType type)?
navigateToTransactionSuccess,
TResult Function(ErrorResult<String, HyphaError> errorResult)?
navigateToTransactionFailed,
TResult Function()? navigateAway,
Expand Down
8 changes: 4 additions & 4 deletions lib/ui/sign_transaction/sign_transaction_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
});
Expand Down
Loading

0 comments on commit 5d46ee3

Please sign in to comment.