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 14, 2023
1 parent 590f0e4 commit 5abad8a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/views/common/top_snack_bar/top_snack_bar.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'package:flutter/material.dart';
import 'package:kayla_flutter_ic/gen/assets.gen.dart';

class TopSnackbar extends StatelessWidget {
class TopSnackBar extends StatelessWidget {
final String title;
final String message;

const TopSnackbar({
const TopSnackBar({
super.key,
required this.title,
required this.message,
Expand Down
2 changes: 1 addition & 1 deletion lib/views/forget_password/forget_password_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ class ForgetPasswordState with _$ForgetPasswordState {

const factory ForgetPasswordState.error(String? error) = _Error;

const factory ForgetPasswordState.success() = _Success;
const factory ForgetPasswordState.success(String message) = _Success;
}
8 changes: 2 additions & 6 deletions lib/views/forget_password/forget_password_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,8 @@ class ForgetPasswordViewState extends ConsumerState<ForgetPasswordView>
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Please try again. $error.')));
},
success: () async {
String message = ref
.read(forgetPasswordViewModelProvider.notifier)
.successMessage ??
'';
context.showTopSnackBar(TopSnackbar(
success: (message) async {
context.showTopSnackBar(TopSnackBar(
title: 'Check your email.',
message: message,
));
Expand Down
6 changes: 1 addition & 5 deletions lib/views/forget_password/forget_password_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ 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 @@ -31,10 +29,8 @@ 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();
state = ForgetPasswordState.success(result.value);
} else {
_successMessage = '';
_handleError(result as Failed);
}
}
Expand Down

0 comments on commit 5abad8a

Please sign in to comment.