Skip to content

Commit

Permalink
[#16] Integrate the top snack bar after sucessfully reseting the forg…
Browse files Browse the repository at this point in the history
…otten password
  • Loading branch information
nmint8m committed Feb 15, 2023
1 parent 3e67fd2 commit e004ae2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/views/forget_password/forget_password_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:kayla_flutter_ic/gen/assets.gen.dart';
import 'package:kayla_flutter_ic/usecases/oath/forget_password_use_case.dart';
import 'package:kayla_flutter_ic/views/common/build_context_ext.dart';
import 'package:kayla_flutter_ic/views/common/linear_gradient_blur_background/linear_gradient_blur_background.dart';
import 'package:kayla_flutter_ic/views/common/top_snack_bar/top_snack_bar.dart';
import 'package:kayla_flutter_ic/views/forget_password/forget_password_form.dart';
import 'package:kayla_flutter_ic/views/forget_password/forget_password_state.dart';
import 'package:kayla_flutter_ic/views/forget_password/forget_password_view_model.dart';
Expand Down Expand Up @@ -122,8 +123,14 @@ class ForgetPasswordViewState extends ConsumerState<ForgetPasswordView>
context.showSnackBar(message: 'Please try again. $error.');
},
success: () async {
// TODO: - Show the notification widget
context.showSnackBar(message: 'Check your email.');
String message = ref
.read(forgetPasswordViewModelProvider.notifier)
.successMessage ??
'';
context.showTopSnackBar(TopSnackbar(
title: 'Check your email.',
message: message,
));
},
orElse: () {},
);
Expand Down
4 changes: 4 additions & 0 deletions lib/views/forget_password/forget_password_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import 'package:kayla_flutter_ic/views/forget_password/forget_password_state.dar

class ForgetPasswordViewModel extends StateNotifier<ForgetPasswordState> {
String? get emailWarningMessage => _emailWarningMessage;
String? get successMessage => _successMessage;

final ForgetPasswordUseCase _forgetPasswordUseCase;
String? _emailWarningMessage;
String? _successMessage;

ForgetPasswordViewModel(this._forgetPasswordUseCase)
: super(const ForgetPasswordState.init());
Expand All @@ -29,8 +31,10 @@ class ForgetPasswordViewModel extends StateNotifier<ForgetPasswordState> {
state = const ForgetPasswordState.loading();
final result = await _forgetPasswordUseCase.call(email);
if (result is Success<String>) {
_successMessage = result.value;
state = const ForgetPasswordState.success();
} else {
_successMessage = '';
_handleError(result as Failed);
}
}
Expand Down

0 comments on commit e004ae2

Please sign in to comment.