This commit is contained in:
J. A. Messias 2024-10-09 17:02:34 -03:00
parent 6fe32d8d7c
commit 55f2d067e0
3 changed files with 200 additions and 135 deletions

View File

@ -199,17 +199,23 @@ class _AppState extends State<App> {
final String token = uri.queryParameters['token'] ?? '';
final BuildContext context = StorageUtil().context!;
final bool isNotEmpty = email.isNotEmpty && token.isNotEmpty;
log('openAppLink: $uri');
if (isNotEmpty)
final MediaQueryData mediaQuery = MediaQuery.of(context);
final double height = mediaQuery.size.height * 0.8;
final FlutterFlowTheme theme = FlutterFlowTheme.of(context);
final Widget screen = ForgotPasswordScreen(email: email, token: token);
final Widget Function(BuildContext) builder = (context) => screen;
if (isNotEmpty) {
showModalBottomSheet(
context: context,
builder: (context) => ForgotPasswordScreen(email: email, token: token),
builder: (context) => SizedBox(height: height, child: builder(context)),
isScrollControlled: true,
showDragHandle: true,
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
)
.then((_) => StorageUtil().isRecovered = false);
barrierColor: theme.primaryText.withOpacity(0.7),
backgroundColor: theme.primaryBackground,
).then((_) => StorageUtil().isRecovered = false);
}
// Use the extracted email and token as needed
// navigatorKey.currentState?.pushNamed('/forgotPassword', arguments: {'email': email, 'token': token});

View File

@ -88,17 +88,56 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> with Ticker
super.dispose();
}
@override Widget build(BuildContext context) {
final MediaQueryData mediaQuery = MediaQuery.of(context);
return buildBody(context);
@override Widget build(BuildContext context) => buildBody(context);
AppBar buildAppBar(BuildContext context) {
return AppBar(
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
automaticallyImplyLeading: false,
forceMaterialTransparency: true,
leading: FlutterFlowIconButton(
borderColor: Colors.transparent,
borderRadius: 30.0,
borderWidth: 1.0,
buttonSize: 60.0,
icon: Icon(
Icons.keyboard_arrow_left,
color: FlutterFlowTheme.of(context).primaryText,
size: 30.0,
),
onPressed: () async {
context.pop();
StorageUtil().isRecovered = true;
},
),
title: Text(
FFLocalizations.of(context).getVariableText(
ptText: 'Recuperar Senha',
enText: 'Recover Password',
),
style: FlutterFlowTheme.of(context).headlineMedium.override(
fontFamily: 'Nunito',
color: FlutterFlowTheme.of(context).primaryText,
fontSize: 15.0,
fontWeight: FontWeight.bold,
letterSpacing: 0.0,
useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'),
),
),
actions: const [],
centerTitle: true,
elevation: 0.0,
);
}
Row buildBody(BuildContext context) {
SafeArea buildBody(BuildContext context) {
late final String message = FFLocalizations.of(context).getVariableText(
ptText: 'Qual será a sua nova senha? Insira abaixo e confirme.',
enText: 'What will be your new password? Enter it below and confirm.',
);
return Row(
return SafeArea(
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
Expanded(
@ -223,11 +262,26 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> with Ticker
),
),
],
),
);
}
Widget _buildPasswordField(BuildContext context, {required TextEditingController? controller, required FocusNode? focusNode, required bool visibility, required VoidCallback onVisibilityToggle}){
Widget _buildPasswordField(
BuildContext context, {
required TextEditingController? controller,
required FocusNode? focusNode,
required bool visibility,
required VoidCallback onVisibilityToggle}){
final label = FFLocalizations.of(context).getVariableText(
ptText: 'Senha',
enText: 'Password',
);
final hint = FFLocalizations.of(context).getVariableText(
ptText: 'Insira sua senha',
enText: 'Enter your password',
);
return Padding(
padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 16.0),
child: SizedBox(
@ -246,7 +300,8 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> with Ticker
obscureText: !visibility,
decoration: InputDecoration(
isDense: true,
labelText: FFLocalizations.of(context).getText('0firji8'),
hintText: hint,
labelText: label,
labelStyle: FlutterFlowTheme.of(context).labelLarge.override(
fontFamily: 'Plus Jakarta Sans',
color: FlutterFlowTheme.of(context).primaryText,

View File

@ -164,6 +164,7 @@ class AuthenticationService {
}
static Future<void> changePassword(BuildContext context, String email, String password, String token) async {
try {
final ApiCallResponse response = await PhpGroup.changePasswordCall.call(email: email, psswd: password, token: token);
if (response.jsonBody['error'] == false) {
@ -171,11 +172,14 @@ class AuthenticationService {
enText: "Password changed successfully!",
ptText: "Senha alterada com sucesso!",
);
DialogUtil.success(context, message);
context.go('/homePage');
DialogUtil.success(context, message).then((_) => context.pop);
} else {
final String message = response.jsonBody['error_msg'];
DialogUtil.error(context, message);
} } catch (e, s) {
DialogUtil.errorDefault(context);
LogUtil.requestAPIFailed(
'changePassword.php', email, "Change Password", e, s);
}