Skip to content

Commit

Permalink
feat: implement success and failure pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Zied-Dahmani committed Oct 11, 2024
1 parent 5a5fdd2 commit c7029c9
Show file tree
Hide file tree
Showing 16 changed files with 766 additions and 274 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 (0.0.1):
- flutter_keyboard_visibility_temp_fork (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_ios (0.0.1):
- quill_native_bridge (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 (from `.symlinks/plugins/flutter_keyboard_visibility/ios`)
- flutter_keyboard_visibility_temp_fork (from `.symlinks/plugins/flutter_keyboard_visibility_temp_fork/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_ios (from `.symlinks/plugins/quill_native_bridge_ios/ios`)
- quill_native_bridge (from `.symlinks/plugins/quill_native_bridge/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:
:path: ".symlinks/plugins/flutter_keyboard_visibility/ios"
flutter_keyboard_visibility_temp_fork:
:path: ".symlinks/plugins/flutter_keyboard_visibility_temp_fork/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_ios:
:path: ".symlinks/plugins/quill_native_bridge_ios/ios"
quill_native_bridge:
:path: ".symlinks/plugins/quill_native_bridge/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: 0339d06371254c3eb25eeb90ba8d17dca8f9c069
flutter_keyboard_visibility_temp_fork: 442dadca3b81868a225cd6a2f605bffff1215844
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_ios: 277bdf5bf0fa5d7a12999556b415a5c63dd76ec4
quill_native_bridge: e5afa7d49c08cf68c52a5e23bc272eba6925c622
share_plus: c3fef564749587fc939ef86ffb283ceac0baf9f5
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
Expand Down
10 changes: 5 additions & 5 deletions lib/core/crypto/dart_esr/src/models/transaction.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion lib/core/network/models/proposal_creation_model.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
class ProposalCreationModel {
final String? id;
final String? title;
final String? details;

ProposalCreationModel({this.title, this.details});
ProposalCreationModel({this.id, this.title, this.details});

ProposalCreationModel copyWith(Map<String, dynamic> updates) {
return ProposalCreationModel(
id: updates.containsKey('id') ? updates['id'] : id,
title: updates.containsKey('title') ? updates['title'] : title,
details: updates.containsKey('details') ? updates['details'] : details,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +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 SignTransactionFailedPage extends StatelessWidget {
class FailurePage extends StatelessWidget {
final HyphaError error;
final String text1;
final String text2;

const SignTransactionFailedPage(this.error, {super.key});
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.'});

@override
Widget build(BuildContext context) {
Expand All @@ -25,7 +27,7 @@ class SignTransactionFailedPage extends StatelessWidget {
),
children: <TextSpan>[
TextSpan(
text: 'This transaction ',
text: text1,
style: context.hyphaTextTheme.regular.copyWith(color: HyphaColors.error),
),
const TextSpan(text: ' '),
Expand Down Expand Up @@ -63,7 +65,7 @@ class SignTransactionFailedPage extends StatelessWidget {
failedText,
const SizedBox(height: 16),
Text(
'Please try again by triggering the transaction from the website or app. Sorry for the inconvenience.',
text2,
style: context.hyphaTextTheme.ralMediumBody.copyWith(color: HyphaColors.midGrey),
textAlign: TextAlign.center,
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,35 @@
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';
import 'package:hypha_wallet/design/buttons/button_type.dart';
import 'package:hypha_wallet/design/buttons/hypha_app_button.dart';
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';
import 'package:hypha_wallet/ui/proposals/details/proposal_details_page.dart';

enum SignSuccessTransactionType {
approved('Approved');
enum SuccessType {
approved('Approved'),
published('published');

const SignSuccessTransactionType(this.value);
const SuccessType(this.value);

final String value;

Color get iconBackgroundColor {
switch (this) {
case SignSuccessTransactionType.approved:
return HyphaColors.success;
}
}
Color get iconBorderColor => HyphaColors.offWhite;

IconData get icon {
switch (this) {
case SignSuccessTransactionType.approved:
return Icons.check;
}
}
IconData get icon => Icons.check;
}

class SignTransactionSuccessPage extends StatelessWidget {
final SignSuccessTransactionType transactionType;

const SignTransactionSuccessPage({super.key, required this.transactionType});
class SuccessPage extends StatelessWidget {
final SuccessType successType;
final String? proposalId;

const SuccessPage({super.key, required this.successType, this.proposalId});

@override
Widget build(BuildContext context) {
Expand All @@ -45,11 +41,11 @@ class SignTransactionSuccessPage extends StatelessWidget {
),
children: <TextSpan>[
TextSpan(
text: 'Transaction ',
text: proposalId == null ? 'Transaction' : 'Your Proposal has been\nsuccessfully',
style: context.hyphaTextTheme.regular.copyWith(color: HyphaColors.primaryBlu),
),
const TextSpan(text: ' '),
TextSpan(text: transactionType.value),
TextSpan(text: successType.value),
],
),
);
Expand All @@ -61,7 +57,7 @@ class SignTransactionSuccessPage extends StatelessWidget {
bottomNavigationBar: HyphaSafeBottomNavigationBar(
child: HyphaAppButton(
onPressed: () {
Get.offAll(() => const HyphaBottomNavigation());
Get.Get.offAll(() => const HyphaBottomNavigation());
},
title: 'Close',
),
Expand All @@ -82,14 +78,34 @@ class SignTransactionSuccessPage extends StatelessWidget {
Padding(padding: const EdgeInsets.only(left: 45, right: 45), child: successText),
const SizedBox(height: 46),
Container(
padding: const EdgeInsets.all(16),
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: transactionType.iconBackgroundColor,
border: Border.all(
color: successType.iconBorderColor,
width: 2,
),
),
child: Icon(transactionType.icon, size: 24),
child: Icon(successType.icon, size: 24, color: successType.iconBorderColor),
),
const SizedBox(height: 16),
if(proposalId != null) ... [
const Spacer(),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 45.0, vertical: 20.0),
child: HyphaAppButton(
buttonType: ButtonType.secondary,
buttonColor: HyphaColors.gradientBlackLight,
onPressed: () {
Get.Get.to(
ProposalDetailsPage(proposalId: proposalId!),
transition: Get.Transition.rightToLeft,
);
},
title: 'See Proposal Details',
),
),
]
],
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class ProposalReviewView extends StatelessWidget {
HyphaAppButton(
title: 'Publish',
onPressed: () async {
context.read<ProposalCreationBloc>().add(const ProposalCreationEvent.publishProposal());
},
),
],
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/proposals/creation/interactor/page_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ part of 'proposal_creation_bloc.dart';
@freezed
class PageCommand with _$PageCommand {
const factory PageCommand.navigateBackToProposals() = _NavigateBackToProposals;
const factory PageCommand.navigateToSuccessPage() = _NavigateToSuccessPage;
const factory PageCommand.navigateToFailurePage(HyphaError hyphaError) = _NavigateToFailurePage;
}
15 changes: 9 additions & 6 deletions lib/ui/proposals/creation/interactor/proposal_creation_bloc.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:hypha_wallet/core/error_handler/model/hypha_error.dart';
import 'package:hypha_wallet/core/error_handler/model/hypha_error_type.dart';
import 'package:hypha_wallet/core/network/models/proposal_creation_model.dart';
import 'package:hypha_wallet/core/network/models/proposal_details_model.dart';
import 'package:hypha_wallet/ui/architecture/interactor/page_states.dart';

part 'page_command.dart';
part 'proposal_creation_bloc.freezed.dart';
Expand All @@ -15,6 +15,7 @@ class ProposalCreationBloc
ProposalCreationBloc() : super(ProposalCreationState(proposal: ProposalCreationModel())) {
on<_UpdateCurrentView>(_updateCurrentView);
on<_UpdateProposal>(_updateProposal);
on<_PublishProposal>(_publishProposal);
on<_ClearPageCommand>((_, emit) => emit(state.copyWith(command: null)));
}

Expand All @@ -34,7 +35,7 @@ class ProposalCreationBloc
navigate(emit, event.nextViewIndex);
break;
case 2:
if(state.proposal?.details != null) {
if(state.proposal!.details != null) {
navigate(emit, event.nextViewIndex);
}
break;
Expand All @@ -60,9 +61,11 @@ class ProposalCreationBloc
}

Future<void> _updateProposal(_UpdateProposal event, Emitter<ProposalCreationState> emit) async {
final ProposalCreationModel? proposal = state.proposal?.copyWith(event.updates);
if (proposal != null) {
emit(state.copyWith(proposal: proposal));
final ProposalCreationModel proposal = state.proposal!.copyWith(event.updates);
emit(state.copyWith(proposal: proposal));
}

Future<void> _publishProposal(_PublishProposal event, Emitter<ProposalCreationState> emit) async {
// TODO(Zied): Implement proposal creation logic
}
}
Loading

0 comments on commit c7029c9

Please sign in to comment.