Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/Enroll - On invite link #261

Merged
merged 3 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import 'package:hypha_wallet/ui/blocs/authentication/authentication_bloc.dart';
import 'package:hypha_wallet/ui/blocs/deeplink/deeplink_bloc.dart';
import 'package:hypha_wallet/ui/blocs/error_handler/error_handler_bloc.dart';
import 'package:hypha_wallet/ui/blocs/push_notifications/push_notifications_bloc.dart';
import 'package:hypha_wallet/ui/onboarding/join_dao/join_dao_rationale_bottom_sheet.dart';
import 'package:hypha_wallet/ui/onboarding/onboarding_page_with_link.dart';
import 'package:hypha_wallet/ui/settings/hypha_confirmation_page.dart';
import 'package:hypha_wallet/ui/settings/interactor/settings_bloc.dart';
Expand Down Expand Up @@ -60,8 +61,9 @@ class HyphaAppView extends StatelessWidget {
},
listener: (context, state) {
LogHelper.d('Auth Bloc Listener FIRED');

/// If we are handling a deeplink. Do not listen to navigation.
if(context.read<DeeplinkBloc>().state.inviteLinkData != null) {
if (context.read<DeeplinkBloc>().state.inviteLinkData != null) {
LogHelper.d('There is Invite Link data. Ignore this command.');
return;
}
Expand Down Expand Up @@ -90,10 +92,14 @@ class HyphaAppView extends StatelessWidget {
listenWhen: (previous, current) => previous.command != current.command,
listener: (context, state) {
state.command?.when(
navigateToCreateAccount: () => Get.Get.offAll(() => const OnboardingPageWithLink()),
navigateToSignTransaction: (ScanQrCodeResultData data) {
_showSignTransactionBottomSheet(data);
});
navigateToCreateAccount: () => Get.Get.offAll(() => const OnboardingPageWithLink()),
navigateToSignTransaction: (ScanQrCodeResultData data) {
_showSignTransactionBottomSheet(data);
},
showJoinDaoRationale: (daoName, secret) {
_showJoinDaoRationale(daoName, secret, context);
},
);
context.read<DeeplinkBloc>().add(const DeeplinkEvent.clearPageCommand());
},
),
Expand Down Expand Up @@ -219,4 +225,18 @@ class HyphaAppView extends StatelessWidget {
),
);
}

void _showJoinDaoRationale(String daoName, String secret, BuildContext context) {
showModalBottomSheet(
useSafeArea: true,
isScrollControlled: true,
builder: (context) {
return JoinDaoRationaleBottomSheet(daoName: daoName, secret: secret);
},
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(30)),
),
context: context,
);
}
}
9 changes: 9 additions & 0 deletions lib/core/di/bloc_module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ void _registerBlocsModule() {
),
);

_registerFactoryWithParams<JoinDaoBloc, String, void>(
(secret, _) => JoinDaoBloc(
_getIt<AuthRepository>(),
_getIt<InviteService>(),
_getIt<ErrorHandlerManager>(),
secret,
),
);

_registerFactoryWithParams<ReceiveBloc, WalletTokenData, void>(
(tokenData, _) => ReceiveBloc(tokenData, _getIt<SendTokenUseCase>()),
);
Expand Down
1 change: 1 addition & 0 deletions lib/core/di/di_setup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import 'package:hypha_wallet/ui/onboarding/import_account/usecases/find_account_
import 'package:hypha_wallet/ui/onboarding/import_account/usecases/generate_key_from_recovery_words_use_case.dart';
import 'package:hypha_wallet/ui/onboarding/import_account/usecases/generate_key_from_seeds_passport_words_use_case.dart';
import 'package:hypha_wallet/ui/onboarding/import_account/usecases/validate_key_use_case.dart';
import 'package:hypha_wallet/ui/onboarding/join_dao/interactor/join_dao_bloc.dart';
import 'package:hypha_wallet/ui/onboarding/usecases/check_account_availability_use_case.dart';
import 'package:hypha_wallet/ui/onboarding/usecases/create_account_use_case.dart';
import 'package:hypha_wallet/ui/onboarding/usecases/find_available_account_use_case.dart';
Expand Down
11 changes: 9 additions & 2 deletions lib/ui/blocs/deeplink/deeplink_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,14 @@ class DeeplinkBloc extends Bloc<DeeplinkEvent, DeeplinkState> {
final chain = queryParams['chain']!;
final dao = queryParams['dao']!;

final String? enrollSecret = queryParams['enroll_secret'];
final String enrollSecret = queryParams['enroll_secret']!;

final PageCommand command;
if(_authRepository.currentAuthStatus is Authenticated) {
command = PageCommand.showJoinDaoRationale(dao, enrollSecret);
} else {
command = const PageCommand.navigateToCreateAccount();
}

/// Emit new state with data from link
emit(
Expand All @@ -109,7 +116,7 @@ class DeeplinkBloc extends Bloc<DeeplinkEvent, DeeplinkState> {
dao: dao,
enrollSecret: enrollSecret,
),
command: const PageCommand.navigateToCreateAccount(),
command: command,
),
);
}
Expand Down
Loading