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

fix: remove manual navigation from login form #482

Merged
merged 2 commits into from
Dec 27, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:ion/app/router/app_routes.c.dart';
import 'package:ion/app/router/components/navigation_app_bar/navigation_app_bar.dart';
import 'package:ion_identity_client/ion_identity.dart';

// TODO: we need to show it somehow, but be careful with automatic redirect to the Onboarding
class CreateLocalCredsPromptDialog extends HookConsumerWidget {
const CreateLocalCredsPromptDialog({super.key});

Expand Down
32 changes: 0 additions & 32 deletions lib/app/features/auth/views/pages/get_started/login_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ import 'package:ion/app/components/progress_bar/ion_loading_indicator.dart';
import 'package:ion/app/extensions/extensions.dart';
import 'package:ion/app/features/auth/providers/auth_provider.c.dart';
import 'package:ion/app/features/auth/providers/login_action_notifier.c.dart';
import 'package:ion/app/features/auth/providers/onboarding_complete_provider.c.dart';
import 'package:ion/app/features/auth/views/components/identity_key_name_input/identity_key_name_input.dart';
import 'package:ion/app/features/auth/views/pages/create_local_creds_prompt_dialog/create_local_creds_prompt_dialog.dart';
import 'package:ion/app/features/components/verify_identity/verify_identity_prompt_dialog_helper.dart';
import 'package:ion/app/router/app_routes.c.dart';
import 'package:ion/app/router/utils/show_simple_bottom_sheet.dart';
import 'package:ion/generated/assets.gen.dart';

class LoginForm extends HookConsumerWidget {
Expand All @@ -29,8 +25,6 @@ class LoginForm extends HookConsumerWidget {

ref.displayErrors(loginActionNotifierProvider);

_listenLoginSuccess(ref);

return Form(
key: formKey.value,
child: Column(
Expand Down Expand Up @@ -75,30 +69,4 @@ class LoginForm extends HookConsumerWidget {
),
);
}

void _listenLoginSuccess(WidgetRef ref) {
ref.listenSuccess(loginActionNotifierProvider, (result) {
if (result?.localCredsUsed ?? false) {
_navigateNext(ref);
} else {
_showCreateLocalCredsPromptDialog(ref);
}
});
}

void _navigateNext(WidgetRef ref) {
final onboardingComplete = ref.read(onboardingCompleteProvider).valueOrNull;
if (onboardingComplete != null && onboardingComplete) {
FeedRoute().push<void>(ref.context);
} else {
FillProfileRoute().push<void>(ref.context);
}
}

void _showCreateLocalCredsPromptDialog(WidgetRef ref) {
showSimpleBottomSheet<void>(
context: ref.context,
child: const CreateLocalCredsPromptDialog(),
);
}
}