Skip to content

Commit

Permalink
implementation of seperation widget of login_view
Browse files Browse the repository at this point in the history
  • Loading branch information
charlcl180 committed Jun 29, 2024
1 parent be9d469 commit b4c34c8
Show file tree
Hide file tree
Showing 7 changed files with 303 additions and 247 deletions.
298 changes: 51 additions & 247 deletions lib/features/welcome/login/login_view.dart

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions lib/features/welcome/login/widget/app_ets_logo.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// widgets/AppletsLogo.dart

import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

class AppEtsLogo extends StatelessWidget {
const AppEtsLogo({super.key});

@override
Widget build(BuildContext context) {
return Wrap(
direction: Axis.vertical,
crossAxisAlignment: WrapCrossAlignment.center,
spacing: -20,
children: <Widget>[
Text(
AppIntl.of(context)!.login_applets_logo,
style: const TextStyle(color: Colors.white),
),
Image.asset(
'assets/images/applets_white_logo.png',
excludeFromSemantics: true,
width: 100,
height: 100,
),
],
);
}
}
42 changes: 42 additions & 0 deletions lib/features/welcome/login/widget/forgot_password_link.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// widgets/ForgotPasswordLink.dart

import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:notredame/features/app/integration/launch_url_service.dart';
import 'package:notredame/features/app/analytics/remote_config_service.dart';
import 'package:notredame/utils/locator.dart';

class ForgotPasswordLink extends StatelessWidget {
final LaunchUrlService _launchUrlService = locator<LaunchUrlService>();
final RemoteConfigService _remoteConfigService = locator<RemoteConfigService>();

ForgotPasswordLink({super.key});

@override
Widget build(BuildContext context) {
return 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);
}
},
),
),
);
}
}
55 changes: 55 additions & 0 deletions lib/features/welcome/login/widget/login_button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// widgets/LoginButton.dart

import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:notredame/features/welcome/login/login_viewmodel.dart';
import 'package:notredame/utils/utils.dart';
import 'package:notredame/utils/app_theme.dart';


class LoginButton extends StatelessWidget {
final GlobalKey<FormState> formKey;
final LoginViewModel model;

const LoginButton({super.key, required this.formKey, required this.model});

@override
Widget build(BuildContext context) {
return SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: !model.canSubmit
? null
: () async {
final String error = await model.authenticate();

if (error.isNotEmpty) {
Fluttertoast.showToast(msg: error);
}
formKey.currentState?.reset();
},
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
model.canSubmit ? colorButton(context) : Colors.white38),
padding: MaterialStateProperty.all(
const EdgeInsets.symmetric(vertical: 16)),
),
child: Text(
AppIntl.of(context)!.login_action_sign_in,
style: TextStyle(
color: model.canSubmit
? submitTextColor(context)
: Colors.white60,
fontSize: 18),
),
),
);
}

Color colorButton(BuildContext context) => Utils.getColorByBrightness(
context, Colors.white, AppTheme.etsLightRed);

Color submitTextColor(BuildContext context) => Utils.getColorByBrightness(
context, AppTheme.etsLightRed, Colors.white);
}
25 changes: 25 additions & 0 deletions lib/features/welcome/login/widget/login_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:notredame/utils/app_theme.dart';

class LogoWidget extends StatelessWidget {
const LogoWidget({super.key});

@override
Widget build(BuildContext context) {
return Hero(
tag: 'ets_logo',
child: SvgPicture.asset(
"assets/images/ets_white_logo.svg",
excludeFromSemantics: true,
width: 90,
height: 90,
colorFilter: ColorFilter.mode(
Theme.of(context).brightness == Brightness.light
? Colors.white
: AppTheme.etsLightRed,
BlendMode.srcIn),
),
);
}
}
36 changes: 36 additions & 0 deletions lib/features/welcome/login/widget/need_help_link.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// widgets/NeedHelpLink.dart

import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:notredame/features/app/navigation/navigation_service.dart';
import 'package:notredame/features/app/navigation/router_paths.dart';
import 'package:notredame/utils/utils.dart';
import 'package:notredame/utils/locator.dart';
import 'package:notredame/utils/app_theme.dart';

class NeedHelpLink extends StatelessWidget {
final NavigationService _navigationService = locator<NavigationService>();

NeedHelpLink({super.key});

@override
Widget build(BuildContext context) {
return Center(
child: Padding(
padding: const EdgeInsets.only(top: 24),
child: InkWell(
child: Text(
AppIntl.of(context)!.need_help,
style: const TextStyle(
decoration: TextDecoration.underline, color: Colors.white),
),
onTap: () async {
_navigationService.pushNamed(RouterPaths.faq,
arguments: Utils.getColorByBrightness(
context, AppTheme.etsLightRed, AppTheme.primaryDark));
},
),
),
);
}
}
65 changes: 65 additions & 0 deletions lib/features/welcome/login/widget/universal_code_field.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// widgets/UniversalCodeField.dart

import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:notredame/features/welcome/login/login_mask.dart';
import 'package:notredame/features/welcome/login/login_viewmodel.dart';
import 'package:notredame/utils/utils.dart';

class UniversalCodeField extends StatelessWidget {
final double borderRadiusOnFocus;
final GlobalKey<TooltipState> tooltipKey;
final LoginViewModel model;

const UniversalCodeField({
super.key,
required this.borderRadiusOnFocus,
required this.tooltipKey,
required this.model,
});

@override
Widget build(BuildContext context) {
return TextFormField(
autofillHints: const [AutofillHints.username],
cursorColor: Colors.white,
keyboardType: TextInputType.visiblePassword,
decoration: InputDecoration(
enabledBorder: const OutlineInputBorder(
borderSide: BorderSide(color: Colors.white70)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white, width: borderRadiusOnFocus)),
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: errorTextColor(context), width: borderRadiusOnFocus)),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: errorTextColor(context), width: borderRadiusOnFocus)),
labelText: AppIntl.of(context)!.login_prompt_universal_code,
labelStyle: const TextStyle(color: Colors.white54),
errorStyle: TextStyle(color: errorTextColor(context)),
suffixIcon: Tooltip(
key: tooltipKey,
triggerMode: TooltipTriggerMode.manual,
message: AppIntl.of(context)!.universal_code_example,
preferBelow: true,
child: IconButton(
icon: const Icon(Icons.help, color: Colors.white),
onPressed: () {
tooltipKey.currentState?.ensureTooltipVisible();
},
)),
),
autofocus: true,
style: const TextStyle(color: Colors.white),
onEditingComplete: () => FocusScope.of(context).nextFocus(),
validator: model.validateUniversalCode,
initialValue: model.universalCode,
inputFormatters: [LoginMask()],
);
}

Color errorTextColor(BuildContext context) =>
Utils.getColorByBrightness(context, Colors.amberAccent, Colors.redAccent);
}

0 comments on commit b4c34c8

Please sign in to comment.