-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…sword-screen [#8] Integrate Reset Password screen
- Loading branch information
Showing
21 changed files
with
312 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="chinese_black">#15151A</color> | ||
<color name="raisin_black">#252525</color> | ||
</resources> |
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
|
||
part 'reset_password_state.freezed.dart'; | ||
|
||
@freezed | ||
class ResetPasswordState with _$ResetPasswordState { | ||
const factory ResetPasswordState.init() = _Init; | ||
|
||
const factory ResetPasswordState.loading() = _Loading; | ||
|
||
const factory ResetPasswordState.success() = _Success; | ||
|
||
const factory ResetPasswordState.apiError(String errorMessage) = _Error; | ||
|
||
const factory ResetPasswordState.invalidInputError() = _InvalidInputError; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'package:email_validator/email_validator.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:survey/page/resetpassword/reset_password_state.dart'; | ||
import 'package:survey/usecase/base/base_use_case.dart'; | ||
import 'package:survey/usecase/reset_password_use_case.dart'; | ||
|
||
class ResetPasswordViewModel extends StateNotifier<ResetPasswordState> { | ||
final ResetPasswordUseCase _resetPasswordUseCase; | ||
|
||
ResetPasswordViewModel(this._resetPasswordUseCase) | ||
: super(const ResetPasswordState.init()); | ||
|
||
void resetPassword(String email) async { | ||
state = const ResetPasswordState.loading(); | ||
if (EmailValidator.validate(email)) { | ||
Result<void> result = await _resetPasswordUseCase.call(email); | ||
if (result is Success) { | ||
state = const ResetPasswordState.success(); | ||
} else { | ||
state = | ||
ResetPasswordState.apiError((result as Failed).getErrorMessage()); | ||
} | ||
} else { | ||
state = const ResetPasswordState.invalidInputError(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:loading_indicator/loading_indicator.dart'; | ||
import 'package:survey/resource/dimens.dart'; | ||
|
||
class LoadingIndicatorWidget extends StatelessWidget { | ||
final bool shouldIgnoreOtherGestures; | ||
|
||
const LoadingIndicatorWidget({ | ||
Key? key, | ||
this.shouldIgnoreOtherGestures = true, | ||
}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return shouldIgnoreOtherGestures | ||
? Container( | ||
width: double.infinity, | ||
height: double.infinity, | ||
color: Colors.transparent, | ||
child: _buildLoadingIndicator(), | ||
) | ||
: _buildLoadingIndicator(); | ||
} | ||
|
||
Widget _buildLoadingIndicator() { | ||
return Center( | ||
child: Container( | ||
padding: EdgeInsets.all(Dimens.space12), | ||
width: Dimens.circularProgressBarBackgroundSize, | ||
height: Dimens.circularProgressBarBackgroundSize, | ||
color: Colors.black54, | ||
child: LoadingIndicator( | ||
indicatorType: Indicator.lineSpinFadeLoader, | ||
colors: const [Colors.white], | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.