WIP
This commit is contained in:
parent
6fe32d8d7c
commit
55f2d067e0
|
@ -199,17 +199,23 @@ class _AppState extends State<App> {
|
||||||
final String token = uri.queryParameters['token'] ?? '';
|
final String token = uri.queryParameters['token'] ?? '';
|
||||||
final BuildContext context = StorageUtil().context!;
|
final BuildContext context = StorageUtil().context!;
|
||||||
final bool isNotEmpty = email.isNotEmpty && token.isNotEmpty;
|
final bool isNotEmpty = email.isNotEmpty && token.isNotEmpty;
|
||||||
log('openAppLink: $uri');
|
final MediaQueryData mediaQuery = MediaQuery.of(context);
|
||||||
|
final double height = mediaQuery.size.height * 0.8;
|
||||||
if (isNotEmpty)
|
final FlutterFlowTheme theme = FlutterFlowTheme.of(context);
|
||||||
|
final Widget screen = ForgotPasswordScreen(email: email, token: token);
|
||||||
|
final Widget Function(BuildContext) builder = (context) => screen;
|
||||||
|
if (isNotEmpty) {
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => ForgotPasswordScreen(email: email, token: token),
|
builder: (context) => SizedBox(height: height, child: builder(context)),
|
||||||
showDragHandle: true,
|
isScrollControlled: true,
|
||||||
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
showDragHandle: true,
|
||||||
)
|
barrierColor: theme.primaryText.withOpacity(0.7),
|
||||||
.then((_) => StorageUtil().isRecovered = false);
|
backgroundColor: theme.primaryBackground,
|
||||||
|
|
||||||
|
|
||||||
|
).then((_) => StorageUtil().isRecovered = false);
|
||||||
|
}
|
||||||
// Use the extracted email and token as needed
|
// Use the extracted email and token as needed
|
||||||
// navigatorKey.currentState?.pushNamed('/forgotPassword', arguments: {'email': email, 'token': token});
|
// navigatorKey.currentState?.pushNamed('/forgotPassword', arguments: {'email': email, 'token': token});
|
||||||
|
|
||||||
|
|
|
@ -88,146 +88,200 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> with Ticker
|
||||||
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
@override Widget build(BuildContext context) {
|
@override Widget build(BuildContext context) => buildBody(context);
|
||||||
final MediaQueryData mediaQuery = MediaQuery.of(context);
|
|
||||||
return 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(
|
late final String message = FFLocalizations.of(context).getVariableText(
|
||||||
ptText: 'Qual será a sua nova senha? Insira abaixo e confirme.',
|
ptText: 'Qual será a sua nova senha? Insira abaixo e confirme.',
|
||||||
enText: 'What will be your new password? Enter it below and confirm.',
|
enText: 'What will be your new password? Enter it below and confirm.',
|
||||||
);
|
);
|
||||||
return Row(
|
return SafeArea(
|
||||||
mainAxisSize: MainAxisSize.max,
|
child: Row(
|
||||||
children: [
|
mainAxisSize: MainAxisSize.max,
|
||||||
Expanded(
|
children: [
|
||||||
flex: 6,
|
Expanded(
|
||||||
child: Container(
|
flex: 6,
|
||||||
width: 100.0,
|
child: Container(
|
||||||
height: double.infinity,
|
width: 100.0,
|
||||||
decoration: BoxDecoration(color: FlutterFlowTheme.of(context).primaryBackground),
|
height: double.infinity,
|
||||||
alignment: const AlignmentDirectional(0.0, -1.0),
|
decoration: BoxDecoration(color: FlutterFlowTheme.of(context).primaryBackground),
|
||||||
child: Align(
|
alignment: const AlignmentDirectional(0.0, -1.0),
|
||||||
alignment: const AlignmentDirectional(0.0, 0.0),
|
child: Align(
|
||||||
child: SingleChildScrollView(
|
alignment: const AlignmentDirectional(0.0, 0.0),
|
||||||
child: Column(
|
child: SingleChildScrollView(
|
||||||
mainAxisSize: MainAxisSize.max,
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisSize: MainAxisSize.max,
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
Container(
|
children: [
|
||||||
width: 291.0,
|
Container(
|
||||||
height: 167.0,
|
width: 291.0,
|
||||||
decoration: const BoxDecoration(),
|
height: 167.0,
|
||||||
child: ClipRRect(
|
decoration: const BoxDecoration(),
|
||||||
borderRadius: BorderRadius.circular(8.0),
|
child: ClipRRect(
|
||||||
child: const AtomImageSvgTheme(filename: 'register', width: 600, height: 155),
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
|
child: const AtomImageSvgTheme(filename: 'register', width: 600, height: 155),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
Padding(
|
||||||
Padding(
|
padding: const EdgeInsets.all(34.0),
|
||||||
padding: const EdgeInsets.all(34.0),
|
child: Material(
|
||||||
child: Material(
|
child: Container(
|
||||||
child: Container(
|
width: double.infinity,
|
||||||
width: double.infinity,
|
constraints: const BoxConstraints(maxWidth: 570.0),
|
||||||
constraints: const BoxConstraints(maxWidth: 570.0),
|
decoration: BoxDecoration(
|
||||||
decoration: BoxDecoration(
|
color: FlutterFlowTheme.of(context).primaryBackground,
|
||||||
color: FlutterFlowTheme.of(context).primaryBackground,
|
borderRadius: BorderRadius.circular(12.0),
|
||||||
borderRadius: BorderRadius.circular(12.0),
|
|
||||||
),
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(32.0),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Align(
|
|
||||||
alignment: const AlignmentDirectional(-1.0, 0.0),
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(20.0, 24.0, 0.0, 30.0),
|
|
||||||
child: Text(
|
|
||||||
message,
|
|
||||||
textAlign: TextAlign.start,
|
|
||||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
|
||||||
fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
|
||||||
FlutterFlowTheme.of(context).bodyMediumFamily),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Form(
|
|
||||||
key: _model.formKey,
|
|
||||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
children: [
|
|
||||||
_buildPasswordField(
|
|
||||||
context,
|
|
||||||
controller: _model.passwordRegisterFormTextController,
|
|
||||||
focusNode: _model.passwordRegisterFormFocusNode,
|
|
||||||
visibility: _model.passwordRegisterFormVisibility,
|
|
||||||
onVisibilityToggle: () => setState(() => _model.passwordRegisterFormVisibility = !_model.passwordRegisterFormVisibility),
|
|
||||||
),
|
|
||||||
_buildPasswordField(
|
|
||||||
context,
|
|
||||||
controller: _model.passwordConfirmFormTextController,
|
|
||||||
focusNode: _model.passwordConfirmFormFocusNode,
|
|
||||||
visibility: _model.passwordConfirmFormVisibility,
|
|
||||||
onVisibilityToggle: () => setState(() => _model.passwordConfirmFormVisibility = !_model.passwordConfirmFormVisibility),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 16.0),
|
|
||||||
child: FFButtonWidget(
|
|
||||||
key: const ValueKey<String>('SubmitButtonWidget'),
|
|
||||||
onPressed: _model.isFormInvalid() ? null : () async {
|
|
||||||
await AuthenticationService.changePassword(context, widget.email, _model.passwordRegisterFormTextController!.text, widget.token);
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
text: FFLocalizations.of(context).getVariableText(
|
|
||||||
ptText: 'Enviar',
|
|
||||||
enText: 'Submit',
|
|
||||||
),
|
|
||||||
options: FFButtonOptions(
|
|
||||||
width: double.infinity,
|
|
||||||
height: 44.0,
|
|
||||||
color: FlutterFlowTheme.of(context).accent1,
|
|
||||||
textStyle: FlutterFlowTheme.of(context).titleSmall.override(
|
|
||||||
fontFamily: 'Plus Jakarta Sans',
|
|
||||||
color: FlutterFlowTheme.of(context).secondaryText,
|
|
||||||
fontSize: 16.0,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans')),
|
|
||||||
elevation: 3.0,
|
|
||||||
borderSide: const BorderSide(color: Colors.transparent, width: 1.0),
|
|
||||||
borderRadius: BorderRadius.circular(12.0),
|
|
||||||
disabledColor: FlutterFlowTheme.of(context).customColor5,
|
|
||||||
disabledTextColor: Colors.white,
|
|
||||||
),
|
|
||||||
showLoadingIndicator: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
child: Padding(
|
||||||
).animateOnPageLoad(animationsMap['containerOnPageLoadAnimation']!),
|
padding: const EdgeInsets.all(32.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Align(
|
||||||
|
alignment: const AlignmentDirectional(-1.0, 0.0),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.fromSTEB(20.0, 24.0, 0.0, 30.0),
|
||||||
|
child: Text(
|
||||||
|
message,
|
||||||
|
textAlign: TextAlign.start,
|
||||||
|
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||||
|
fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
||||||
|
FlutterFlowTheme.of(context).bodyMediumFamily),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Form(
|
||||||
|
key: _model.formKey,
|
||||||
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: [
|
||||||
|
_buildPasswordField(
|
||||||
|
context,
|
||||||
|
controller: _model.passwordRegisterFormTextController,
|
||||||
|
focusNode: _model.passwordRegisterFormFocusNode,
|
||||||
|
visibility: _model.passwordRegisterFormVisibility,
|
||||||
|
onVisibilityToggle: () => setState(() => _model.passwordRegisterFormVisibility = !_model.passwordRegisterFormVisibility),
|
||||||
|
),
|
||||||
|
_buildPasswordField(
|
||||||
|
context,
|
||||||
|
controller: _model.passwordConfirmFormTextController,
|
||||||
|
focusNode: _model.passwordConfirmFormFocusNode,
|
||||||
|
visibility: _model.passwordConfirmFormVisibility,
|
||||||
|
onVisibilityToggle: () => setState(() => _model.passwordConfirmFormVisibility = !_model.passwordConfirmFormVisibility),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 16.0),
|
||||||
|
child: FFButtonWidget(
|
||||||
|
key: const ValueKey<String>('SubmitButtonWidget'),
|
||||||
|
onPressed: _model.isFormInvalid() ? null : () async {
|
||||||
|
await AuthenticationService.changePassword(context, widget.email, _model.passwordRegisterFormTextController!.text, widget.token);
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
text: FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'Enviar',
|
||||||
|
enText: 'Submit',
|
||||||
|
),
|
||||||
|
options: FFButtonOptions(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 44.0,
|
||||||
|
color: FlutterFlowTheme.of(context).accent1,
|
||||||
|
textStyle: FlutterFlowTheme.of(context).titleSmall.override(
|
||||||
|
fontFamily: 'Plus Jakarta Sans',
|
||||||
|
color: FlutterFlowTheme.of(context).secondaryText,
|
||||||
|
fontSize: 16.0,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans')),
|
||||||
|
elevation: 3.0,
|
||||||
|
borderSide: const BorderSide(color: Colors.transparent, width: 1.0),
|
||||||
|
borderRadius: BorderRadius.circular(12.0),
|
||||||
|
disabledColor: FlutterFlowTheme.of(context).customColor5,
|
||||||
|
disabledTextColor: Colors.white,
|
||||||
|
),
|
||||||
|
showLoadingIndicator: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).animateOnPageLoad(animationsMap['containerOnPageLoadAnimation']!),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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(
|
return Padding(
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 16.0),
|
padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 16.0),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
|
@ -246,7 +300,8 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> with Ticker
|
||||||
obscureText: !visibility,
|
obscureText: !visibility,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
isDense: true,
|
isDense: true,
|
||||||
labelText: FFLocalizations.of(context).getText('0firji8'),
|
hintText: hint,
|
||||||
|
labelText: label,
|
||||||
labelStyle: FlutterFlowTheme.of(context).labelLarge.override(
|
labelStyle: FlutterFlowTheme.of(context).labelLarge.override(
|
||||||
fontFamily: 'Plus Jakarta Sans',
|
fontFamily: 'Plus Jakarta Sans',
|
||||||
color: FlutterFlowTheme.of(context).primaryText,
|
color: FlutterFlowTheme.of(context).primaryText,
|
||||||
|
|
|
@ -164,6 +164,7 @@ class AuthenticationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<void> changePassword(BuildContext context, String email, String password, String token) async {
|
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);
|
final ApiCallResponse response = await PhpGroup.changePasswordCall.call(email: email, psswd: password, token: token);
|
||||||
|
|
||||||
if (response.jsonBody['error'] == false) {
|
if (response.jsonBody['error'] == false) {
|
||||||
|
@ -171,11 +172,14 @@ class AuthenticationService {
|
||||||
enText: "Password changed successfully!",
|
enText: "Password changed successfully!",
|
||||||
ptText: "Senha alterada com sucesso!",
|
ptText: "Senha alterada com sucesso!",
|
||||||
);
|
);
|
||||||
DialogUtil.success(context, message);
|
DialogUtil.success(context, message).then((_) => context.pop);
|
||||||
context.go('/homePage');
|
|
||||||
} else {
|
} else {
|
||||||
final String message = response.jsonBody['error_msg'];
|
final String message = response.jsonBody['error_msg'];
|
||||||
DialogUtil.error(context, message);
|
DialogUtil.error(context, message);
|
||||||
|
} } catch (e, s) {
|
||||||
|
DialogUtil.errorDefault(context);
|
||||||
|
LogUtil.requestAPIFailed(
|
||||||
|
'changePassword.php', email, "Change Password", e, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue