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)),
|
||||||
|
isScrollControlled: true,
|
||||||
showDragHandle: true,
|
showDragHandle: true,
|
||||||
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
barrierColor: theme.primaryText.withOpacity(0.7),
|
||||||
)
|
backgroundColor: theme.primaryBackground,
|
||||||
.then((_) => StorageUtil().isRecovered = false);
|
|
||||||
|
|
||||||
|
|
||||||
|
).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,17 +88,56 @@ 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(
|
||||||
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
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(
|
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