-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Split login widgets into own classes * Added requested changes * Modified password_text_field.dart for consistency with recent change --------- Co-authored-by: Spoodern0t <[email protected]>
- Loading branch information
1 parent
cb8c337
commit 0eb530e
Showing
8 changed files
with
318 additions
and
187 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
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,59 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
// Package imports: | ||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||
import 'package:fluttertoast/fluttertoast.dart'; | ||
|
||
import 'package:notredame/utils/locator.dart'; | ||
import 'package:notredame/features/app/analytics/remote_config_service.dart'; | ||
import 'package:notredame/features/app/integration/launch_url_service.dart'; | ||
|
||
class ForgotPassword extends StatefulWidget{ | ||
|
||
const ForgotPassword( | ||
{super.key}); | ||
|
||
@override | ||
State<ForgotPassword> createState() => _ForgotPasswordState(); | ||
} | ||
|
||
class _ForgotPasswordState extends State<ForgotPassword>{ | ||
|
||
final LaunchUrlService _launchUrlService = locator<LaunchUrlService>(); | ||
|
||
final RemoteConfigService _remoteConfigService = | ||
locator<RemoteConfigService>(); | ||
|
||
@override | ||
Widget build(BuildContext context) => Align( | ||
alignment: Alignment.topRight, | ||
child: Padding( | ||
padding: const EdgeInsets.only(top: 4), | ||
child: InkWell( | ||
child: Text( | ||
AppIntl.of(context)! | ||
.forgot_password, | ||
style: const TextStyle( | ||
decoration: | ||
TextDecoration.underline, | ||
color: Colors.white), | ||
), | ||
onTap: () { | ||
final signetsPasswordResetUrl = | ||
_remoteConfigService | ||
.signetsPasswordResetUrl; | ||
if (signetsPasswordResetUrl != "") { | ||
_launchUrlService.launchInBrowser( | ||
_remoteConfigService | ||
.signetsPasswordResetUrl, | ||
Theme.of(context).brightness); | ||
} else { | ||
Fluttertoast.showToast( | ||
msg: AppIntl.of(context)! | ||
.error); | ||
} | ||
}, | ||
), | ||
), | ||
); | ||
} |
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,72 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:fluttertoast/fluttertoast.dart'; | ||
|
||
// Package imports: | ||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||
|
||
import 'package:notredame/utils/app_theme.dart'; | ||
import 'package:notredame/utils/utils.dart'; | ||
|
||
class LoginButton extends StatefulWidget{ | ||
final GlobalKey<FormState> formKey; | ||
final bool canSubmit; | ||
final ValueGetter<Future<String>> authenticate; | ||
|
||
const LoginButton({ | ||
super.key, | ||
required this.formKey, | ||
required this.canSubmit, | ||
required this.authenticate}); | ||
|
||
@override | ||
State<LoginButton> createState() => _LoginButtonState(); | ||
} | ||
|
||
class _LoginButtonState extends State<LoginButton>{ | ||
|
||
@override | ||
Widget build(BuildContext context) => SizedBox( | ||
width: double.infinity, | ||
child: ElevatedButton( | ||
onPressed: !widget.canSubmit | ||
? null | ||
: () async { | ||
final String error = await widget.authenticate(); | ||
|
||
setState(() { | ||
if (error.isNotEmpty) { | ||
Fluttertoast.showToast( | ||
msg: error); | ||
} | ||
widget.formKey.currentState?.reset(); | ||
}); | ||
}, | ||
style: ButtonStyle( | ||
backgroundColor: | ||
WidgetStateProperty.all( | ||
widget.canSubmit | ||
? colorButton | ||
: Colors.white38), | ||
padding: WidgetStateProperty.all( | ||
const EdgeInsets.symmetric( | ||
vertical: 16)), | ||
), | ||
child: Text( | ||
AppIntl.of(context)! | ||
.login_action_sign_in, | ||
style: TextStyle( | ||
color: widget.canSubmit | ||
? submitTextColor | ||
: Colors.white60, | ||
fontSize: 18), | ||
), | ||
), | ||
); | ||
|
||
Color get colorButton => | ||
Utils.getColorByBrightness(context, Colors.white, AppTheme.etsLightRed); | ||
|
||
Color get submitTextColor => | ||
Utils.getColorByBrightness(context, AppTheme.etsLightRed, Colors.white); | ||
|
||
} |
Oops, something went wrong.