From decd48cdd2b979bd5e28f3a9ba3578445b201924 Mon Sep 17 00:00:00 2001 From: zaid_daoud Date: Mon, 16 Oct 2023 08:39:33 +0300 Subject: [PATCH] Improvements --- assets/translations/en.json | 2 +- lib/extensions/string_extensions.dart | 331 ------------------ lib/extensions/text_extensions.dart | 96 +++-- .../common_widgets/app_filled_button.dart | 37 +- lib/new_views/pages/login_page.dart | 12 +- 5 files changed, 81 insertions(+), 397 deletions(-) delete mode 100644 lib/extensions/string_extensions.dart diff --git a/assets/translations/en.json b/assets/translations/en.json index 58ade3a5..2b801eb5 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -1,6 +1,6 @@ { "login" : "Login", - "enterCredsToLogin" : "Enter you credential to login", + "enterCredsToLogin" : "Enter your credential to login", "forgotPassword" : "Forgot Password?", "password" : "Password", "username" : "Username", diff --git a/lib/extensions/string_extensions.dart b/lib/extensions/string_extensions.dart deleted file mode 100644 index 2e2a8b21..00000000 --- a/lib/extensions/string_extensions.dart +++ /dev/null @@ -1,331 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:test_sa/extensions/context_extension.dart'; -import 'package:test_sa/new_views/app_style/app_color.dart'; -import 'package:test_sa/new_views/app_style/app_text_style.dart'; - -extension CapExtension on String { - String get toCamelCase => "${this[0].toUpperCase()}${substring(1)}"; - - String get inCaps => '${this[0].toUpperCase()}${substring(1)}'; - - String get allInCaps => toUpperCase(); - - String get capitalizeFirstOfEach => trim().isNotEmpty ? trim().toLowerCase().split(" ").map((str) => str.inCaps).join(" ") : ""; -} - -extension TextStyleExtension on String { - Widget toHeading1(BuildContext context, {Color color, int maxLines, FontWeight fontWeight}) => Text( - this, - maxLines: (maxLines != null && maxLines > 0) ? maxLines : null, - style: AppTextStyle.heading1.copyWith(color: color ?? (context.isDark ? AppColor.backgroundLight : AppColor.neutral70), fontWeight: fontWeight), - ); - Widget toHeading2(BuildContext context, {Color color, int maxLines, FontWeight fontWeight}) => Text( - this, - maxLines: (maxLines != null && maxLines > 0) ? maxLines : null, - style: AppTextStyle.heading2.copyWith(color: color ?? (context.isDark ? AppColor.neutral30 : AppColor.neutral50), fontWeight: fontWeight), - ); - Widget toHeading3(BuildContext context, {Color color, int maxLines, FontWeight fontWeight}) => Text( - this, - maxLines: (maxLines != null && maxLines > 0) ? maxLines : null, - style: AppTextStyle.heading3.copyWith(color: color ?? (context.isDark ? AppColor.neutral30 : AppColor.neutral50), fontWeight: fontWeight), - ); - Widget toHeading4(BuildContext context, {Color color, int maxLines, FontWeight fontWeight}) => Text( - this, - maxLines: (maxLines != null && maxLines > 0) ? maxLines : null, - style: AppTextStyle.heading4.copyWith(color: color ?? (context.isDark ? AppColor.neutral30 : AppColor.neutral50), fontWeight: fontWeight), - ); - Widget toHeading5(BuildContext context, {Color color, int maxLines, FontWeight fontWeight}) => Text( - this, - maxLines: (maxLines != null && maxLines > 0) ? maxLines : null, - style: AppTextStyle.heading5.copyWith(color: color ?? (context.isDark ? AppColor.neutral30 : AppColor.neutral50), fontWeight: fontWeight), - ); - Widget toHeading6(BuildContext context, {Color color, int maxLines, FontWeight fontWeight}) => Text( - this, - maxLines: (maxLines != null && maxLines > 0) ? maxLines : null, - style: AppTextStyle.heading6.copyWith(color: color ?? (context.isDark ? AppColor.neutral30 : AppColor.neutral50), fontWeight: fontWeight), - ); - Widget toBody1(BuildContext context, {Color color, int maxLines, FontWeight fontWeight}) => Text( - this, - maxLines: (maxLines != null && maxLines > 0) ? maxLines : null, - style: AppTextStyle.body1.copyWith(color: color ?? (context.isDark ? AppColor.neutral10 : AppColor.neutral20), fontWeight: fontWeight), - ); - Widget toBody2(BuildContext context, {Color color, int maxLines, FontWeight fontWeight}) => Text( - this, - maxLines: (maxLines != null && maxLines > 0) ? maxLines : null, - style: AppTextStyle.body2.copyWith(color: color ?? (context.isDark ? AppColor.neutral10 : AppColor.neutral20), fontWeight: fontWeight), - ); - Widget toTiny(BuildContext context, {Color color, int maxLines, FontWeight fontWeight}) => Text( - this, - maxLines: (maxLines != null && maxLines > 0) ? maxLines : null, - style: AppTextStyle.tiny.copyWith(color: color ?? (context.isDark ? AppColor.neutral10 : AppColor.neutral20), fontWeight: fontWeight), - ); - Widget toOverline(BuildContext context, {Color color, int maxLines, FontWeight fontWeight}) => Text( - this, - maxLines: (maxLines != null && maxLines > 0) ? maxLines : null, - style: AppTextStyle.overline.copyWith(color: color ?? (context.isDark ? AppColor.neutral10 : AppColor.neutral20), fontWeight: fontWeight), - ); -} - -extension FilesExtension on String { - SvgPicture toSvgAsset({ - double width, - double height, - Color color, - BoxFit fit = BoxFit.contain, - }) => - SvgPicture.asset("assets/images/$this.svg", width: width, height: height, color: color, fit: fit); - Image toPngAsset({ - double width, - double height, - Color color, - BoxFit fit = BoxFit.contain, - }) => - Image.asset("assets/images/$this.png", width: width, height: height, color: color, fit: fit); -} - -// -// import 'package:flutter/cupertino.dart'; -// import 'package:intl/intl.dart'; -// -// extension CapExtension on String { -// String get toCamelCase => "${this[0].toUpperCase()}${this.substring(1)}"; -// -// String get inCaps => '${this[0].toUpperCase()}${this.substring(1)}'; -// -// String get allInCaps => this.toUpperCase(); -// -// String get capitalizeFirstofEach => this.trim().length > 0 ? this.trim().toLowerCase().split(" ").map((str) => str.inCaps).join(" ") : ""; -// } -// -// extension EmailValidator on String { -// Widget get toWidget => Text(this); -// -// Widget toText10({Color? color, bool isBold = false, int? maxlines, FontStyle? fontStyle}) => Text( -// this, -// maxLines: maxlines, -// style: TextStyle(fontSize: 10, fontStyle: fontStyle ?? FontStyle.normal, fontWeight: isBold ? FontWeight.bold : FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -0.4), -// ); -// -// Widget toText11({Color? color, FontWeight? weight, bool isUnderLine = false, bool isBold = false, int maxLine = 0}) => Text( -// this, -// maxLines: (maxLine > 0) ? maxLine : null, -// style: TextStyle( -// fontSize: 11, -// fontWeight: weight ?? (isBold ? FontWeight.bold : FontWeight.w600), -// color: color ?? MyColors.darkTextColor, -// letterSpacing: -0.33, -// decoration: isUnderLine ? TextDecoration.underline : null, -// ), -// ); -// -// Widget toText12({Color? color, bool isUnderLine = false, bool isBold = false, bool isCenter = false, int maxLine = 0}) => Text( -// this, -// textAlign: isCenter ? TextAlign.center : null, -// maxLines: (maxLine > 0) ? maxLine : null, -// style: TextStyle( -// fontSize: 12, -// fontWeight: isBold ? FontWeight.bold : FontWeight.w600, -// color: color ?? MyColors.darkTextColor, -// letterSpacing: -0.72, -// decoration: isUnderLine ? TextDecoration.underline : null, -// ), -// ); -// -// Widget toText12Auto({Color? color, bool isUnderLine = false, bool isBold = false, bool isCenter = false, int maxLine = 0}) => AutoSizeText( -// this, -// textAlign: isCenter ? TextAlign.center : null, -// maxLines: (maxLine > 0) ? maxLine : null, -// minFontSize: 8, -// style: TextStyle( -// fontSize: 12, -// fontWeight: isBold ? FontWeight.bold : FontWeight.w600, -// color: color ?? MyColors.darkTextColor, -// letterSpacing: -0.72, -// decoration: isUnderLine ? TextDecoration.underline : null, -// ), -// ); -// -// Widget toTextAuto({ -// Color? color, -// bool isUnderLine = false, -// bool isBold = false, -// bool isCenter = false, -// int maxLine = 0, -// double fontSize = 12, -// double letterSpacing = -0.72, -// double height = 1, -// }) => -// AutoSizeText( -// this, -// textAlign: isCenter ? TextAlign.center : null, -// maxLines: (maxLine > 0) ? maxLine : null, -// minFontSize: 5, -// style: TextStyle( -// fontSize: fontSize, -// fontWeight: isBold ? FontWeight.bold : FontWeight.w600, -// color: color ?? MyColors.darkTextColor, -// letterSpacing: letterSpacing, -// decoration: isUnderLine ? TextDecoration.underline : null, -// ), -// ); -// -// Widget toText13({Color? color, bool isUnderLine = false}) => Text( -// this, -// style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -0.52, decoration: isUnderLine ? TextDecoration.underline : null), -// ); -// -// Widget toText14({Color? color, bool isUnderLine = false, bool isBold = false, FontWeight? weight, int? maxlines, TextAlign? textAlign, bool isCenter = false}) => Text( -// this, -// textAlign: isCenter ? TextAlign.center : (textAlign ?? TextAlign.left), -// maxLines: maxlines, -// style: TextStyle( -// color: color ?? MyColors.darkTextColor, -// fontSize: 14, -// letterSpacing: -0.48, -// fontWeight: weight ?? (isBold ? FontWeight.bold : FontWeight.w600), -// decoration: isUnderLine ? TextDecoration.underline : null), -// ); -// -// Widget toText16({Color? color, bool isUnderLine = false, bool isBold = false, int? maxlines, double? height}) => Text( -// this, -// maxLines: maxlines, -// style: TextStyle( -// color: color ?? MyColors.darkTextColor, -// fontSize: 16, -// letterSpacing: -0.64, -// height: height, -// fontWeight: isBold ? FontWeight.bold : FontWeight.w600, -// decoration: isUnderLine ? TextDecoration.underline : null, -// ), -// ); -// -// Widget toText17({Color? color, bool isBold = false}) => Text( -// this, -// style: TextStyle(color: color ?? MyColors.darkTextColor, fontSize: 17, letterSpacing: -0.68, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), -// ); -// -// Widget toText18({Color? color, bool isBold = false, bool isCentered = false}) => Text( -// this, -// textAlign: isCentered ? TextAlign.center : null, -// style: TextStyle(fontSize: 18, fontWeight: isBold ? FontWeight.bold : FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -1.08), -// ); -// -// Widget toText19({Color? color, bool isBold = false}) => Text( -// this, -// style: TextStyle(fontSize: 19, fontWeight: isBold ? FontWeight.bold : FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -1.14), -// ); -// -// Widget toText20({Color? color, bool isBold = false, bool isCentered = false}) => Text( -// this, -// textAlign: isCentered ? TextAlign.center : null, -// style: TextStyle(fontSize: 20, fontWeight: isBold ? FontWeight.bold : FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -0.4), -// ); -// -// Widget toText21({Color? color, bool isBold = false, FontWeight? weight, int? maxlines}) => Text( -// this, -// maxLines: maxlines, -// style: TextStyle(color: color ?? MyColors.grey3AColor, fontSize: 21, letterSpacing: -0.84, fontWeight: weight ?? (isBold ? FontWeight.bold : FontWeight.w600)), -// ); -// -// Widget toText22({Color? color, bool isBold = false, bool isCentered = false}) => Text( -// this, -// textAlign: isCentered ? TextAlign.center : null, -// style: TextStyle(height: 1, color: color ?? MyColors.darkTextColor, fontSize: 22, letterSpacing: -1.44, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), -// ); -// -// Widget toText24({Color? color, bool isBold = false}) => Text( -// this, -// style: TextStyle(height: 23 / 24, color: color ?? MyColors.darkTextColor, fontSize: 24, letterSpacing: -1.44, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), -// ); -// -// Widget toText30({Color? color, bool isBold = false}) => Text( -// this, -// style: TextStyle(height: 20 / 32, color: color ?? MyColors.darkTextColor, fontSize: 32, letterSpacing: -1.2, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), -// ); -// -// Widget toText32({Color? color, bool isBold = false, bool isCentered = false}) => Text( -// this, -// textAlign: isCentered ? TextAlign.center : null, -// style: TextStyle(height: 32 / 32, color: color ?? MyColors.darkTextColor, fontSize: 32, letterSpacing: -1.92, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), -// ); -// -// Widget toText44({Color? color, bool isBold = false}) => Text( -// this, -// style: TextStyle(height: 32 / 32, color: color ?? MyColors.darkTextColor, fontSize: 44, letterSpacing: -2.64, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), -// ); -// -// Widget toSectionHeading({String upperHeading = "", String lowerHeading = ""}) { -// String upper = ""; -// String lower = ""; -// String heading = this; -// if (heading.isNotEmpty) { -// List data = heading.split(" "); -// -// if (data.length > 1) { -// upper = data[0]; -// data.removeAt(0); -// lower = data.join(" "); -// } else { -// lower = data[0]; -// } -// } -// if (upperHeading.isNotEmpty) { -// upper = upperHeading; -// } -// if (lowerHeading.isNotEmpty) { -// lower = lowerHeading; -// } -// -// return Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// mainAxisSize: MainAxisSize.min, -// children: [ -// if (upper.isNotEmpty) upper.toText12(), -// lower.toText24(isBold: true), -// ], -// ); -// } -// -// bool isValidEmail() { -// return RegExp(r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$').hasMatch(this); -// } -// -// String toFormattedDate() { -// String date = this.split("T")[0]; -// String time = this.split("T")[1]; -// var dates = date.split("-"); -// return "${dates[2]} ${getMonth(int.parse(dates[1]))} ${dates[0]} ${DateFormat('hh:mm a').format(DateFormat('hh:mm:ss').parse(time))}"; -// } -// -// String getMonth(int month) { -// switch (month) { -// case 1: -// return "January"; -// case 2: -// return "February"; -// case 3: -// return "March"; -// case 4: -// return "April"; -// case 5: -// return "May"; -// case 6: -// return "June"; -// case 7: -// return "July"; -// case 8: -// return "August"; -// case 9: -// return "September"; -// case 10: -// return "October"; -// case 11: -// return "November"; -// case 12: -// return "December"; -// default: -// return ""; -// } -// } -// } diff --git a/lib/extensions/text_extensions.dart b/lib/extensions/text_extensions.dart index c426f8b5..d06ae91a 100644 --- a/lib/extensions/text_extensions.dart +++ b/lib/extensions/text_extensions.dart @@ -1,30 +1,35 @@ import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:test_sa/extensions/context_extension.dart'; +import 'package:test_sa/extensions/int_extensions.dart'; + +import '../new_views/app_style/app_color.dart'; extension TextStyles on String { - Text get heading1 => getTextWithStyle(this, AppTextStyles.heading1); + Text heading1(BuildContext context) => getTextWithStyle(this, AppTextStyles.heading1, context.isDark ? AppColor.backgroundLight : AppColor.neutral70); - Text get heading2 => getTextWithStyle(this, AppTextStyles.heading2); + Text heading2(BuildContext context) => getTextWithStyle(this, AppTextStyles.heading2, context.isDark ? AppColor.neutral30 : AppColor.neutral50); - Text get heading3 => getTextWithStyle(this, AppTextStyles.heading3); + Text heading3(BuildContext context) => getTextWithStyle(this, AppTextStyles.heading3, context.isDark ? AppColor.neutral30 : AppColor.neutral50); - Text get heading4 => getTextWithStyle(this, AppTextStyles.heading4); + Text heading4(BuildContext context) => getTextWithStyle(this, AppTextStyles.heading4, context.isDark ? AppColor.neutral30 : AppColor.neutral50); - Text get heading5 => getTextWithStyle(this, AppTextStyles.heading5); + Text heading5(BuildContext context) => getTextWithStyle(this, AppTextStyles.heading5, context.isDark ? AppColor.neutral30 : AppColor.neutral50); - Text get heading6 => getTextWithStyle(this, AppTextStyles.heading6); + Text heading6(BuildContext context) => getTextWithStyle(this, AppTextStyles.heading6, context.isDark ? AppColor.neutral30 : AppColor.neutral50); - Text get bodyText => getTextWithStyle(this, AppTextStyles.bodyText); + Text bodyText(BuildContext context) => getTextWithStyle(this, AppTextStyles.bodyText, context.isDark ? AppColor.neutral10 : AppColor.neutral20); - Text get bodyText2 => getTextWithStyle(this, AppTextStyles.bodyText2); + Text bodyText2(BuildContext context) => getTextWithStyle(this, AppTextStyles.bodyText2, context.isDark ? AppColor.neutral10 : AppColor.neutral20); - Text get tinyFont => getTextWithStyle(this, AppTextStyles.tinyFont); + Text tinyFont(BuildContext context) => getTextWithStyle(this, AppTextStyles.tinyFont, context.isDark ? AppColor.neutral10 : AppColor.neutral20); - Text get overline => getTextWithStyle(this, AppTextStyles.overline); + Text overline(BuildContext context) => getTextWithStyle(this, AppTextStyles.overline, context.isDark ? AppColor.neutral10 : AppColor.neutral20); - Text getTextWithStyle(String string, TextStyle style) => Text(string, style: style); + Text getTextWithStyle(String string, TextStyle style, Color color) => Text(string, style: style.copyWith(color: color)); } -extension customText on Text { +extension CustomText on Text { Text custom({Color color, FontWeight fontWeight, TextAlign align}) { return Text( data, @@ -38,8 +43,8 @@ extension customText on Text { } abstract class AppTextStyles { - static const TextStyle heading1 = TextStyle( - fontSize: 54, + static final TextStyle heading1 = TextStyle( + fontSize: 54.toScreenWidth, fontWeight: FontWeight.w500, height: 0.89, letterSpacing: -0.81, @@ -47,8 +52,8 @@ abstract class AppTextStyles { decoration: TextDecoration.none, ); - static const TextStyle heading2 = TextStyle( - fontSize: 28, + static final TextStyle heading2 = TextStyle( + fontSize: 28.toScreenWidth, fontWeight: FontWeight.w700, height: 1.5, letterSpacing: -0.56, @@ -56,8 +61,8 @@ abstract class AppTextStyles { decoration: TextDecoration.none, ); - static const TextStyle heading3 = TextStyle( - fontSize: 24, + static final TextStyle heading3 = TextStyle( + fontSize: 24.toScreenWidth, fontWeight: FontWeight.w700, height: 1.5, letterSpacing: -0.12, @@ -65,56 +70,56 @@ abstract class AppTextStyles { decoration: TextDecoration.none, ); - static const TextStyle heading4 = TextStyle( - fontSize: 21, + static final TextStyle heading4 = TextStyle( + fontSize: 21.toScreenWidth, fontWeight: FontWeight.w500, height: 1.48, fontStyle: FontStyle.normal, decoration: TextDecoration.none, ); - static const TextStyle heading5 = TextStyle( - fontSize: 19, + static final TextStyle heading5 = TextStyle( + fontSize: 19.toScreenWidth, fontWeight: FontWeight.w500, height: 1.47, fontStyle: FontStyle.normal, decoration: TextDecoration.none, ); - static const TextStyle heading6 = TextStyle( - fontSize: 16, + static final TextStyle heading6 = TextStyle( + fontSize: 16.toScreenWidth, fontWeight: FontWeight.w500, height: 1.5, fontStyle: FontStyle.normal, decoration: TextDecoration.none, ); - static const TextStyle bodyText = TextStyle( - fontSize: 14, + static final TextStyle bodyText = TextStyle( + fontSize: 14.toScreenWidth, fontWeight: FontWeight.w500, height: 1.5, fontStyle: FontStyle.normal, decoration: TextDecoration.none, ); - static const TextStyle bodyText2 = TextStyle( - fontSize: 12, + static final TextStyle bodyText2 = TextStyle( + fontSize: 12.toScreenWidth, fontWeight: FontWeight.w500, height: 1.5, fontStyle: FontStyle.normal, decoration: TextDecoration.none, ); - static const TextStyle tinyFont = TextStyle( - fontSize: 11, + static final TextStyle tinyFont = TextStyle( + fontSize: 11.toScreenWidth, fontWeight: FontWeight.w500, height: 1.45, fontStyle: FontStyle.normal, decoration: TextDecoration.none, ); - static const TextStyle overline = TextStyle( - fontSize: 9, + static final TextStyle overline = TextStyle( + fontSize: 9.toScreenWidth, fontWeight: FontWeight.w500, height: 1.56, letterSpacing: 0.05, @@ -122,3 +127,30 @@ abstract class AppTextStyles { decoration: TextDecoration.none, ); } + +extension CapExtension on String { + String get toCamelCase => "${this[0].toUpperCase()}${substring(1)}"; + + String get inCaps => '${this[0].toUpperCase()}${substring(1)}'; + + String get allInCaps => toUpperCase(); + + String get capitalizeFirstOfEach => trim().isNotEmpty ? trim().toLowerCase().split(" ").map((str) => str.inCaps).join(" ") : ""; +} + +extension FilesExtension on String { + SvgPicture toSvgAsset({ + double width, + double height, + Color color, + BoxFit fit = BoxFit.contain, + }) => + SvgPicture.asset("assets/images/$this.svg", width: width, height: height, color: color, fit: fit); + Image toPngAsset({ + double width, + double height, + Color color, + BoxFit fit = BoxFit.contain, + }) => + Image.asset("assets/images/$this.png", width: width, height: height, color: color, fit: fit); +} diff --git a/lib/new_views/common_widgets/app_filled_button.dart b/lib/new_views/common_widgets/app_filled_button.dart index b91606fa..fed2c9ca 100644 --- a/lib/new_views/common_widgets/app_filled_button.dart +++ b/lib/new_views/common_widgets/app_filled_button.dart @@ -1,8 +1,10 @@ import 'package:flutter/material.dart'; import 'package:test_sa/extensions/context_extension.dart'; +import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/models/enums/translation_keys.dart'; +import 'package:test_sa/new_views/app_style/app_color.dart'; class AppFilledButton extends StatelessWidget { final VoidCallback onPressed; @@ -22,32 +24,15 @@ class AppFilledButton extends StatelessWidget { @override Widget build(BuildContext context) { - // return SizedBox( - // width: maxWidth ? double.infinity : null, - // child: Padding( - // padding: const EdgeInsets.symmetric( - // horizontal: 16, - // vertical: 20, - // ), - // child: ElevatedButton( - // style: ElevatedButton.styleFrom( - // padding: const EdgeInsets.symmetric(vertical: 16), - // shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), - // ), - // onPressed: onPressed, - // child: Text(context.translate(label)), - // ), - // ), - // ); return Container( - height: 56, - width: maxWidth ? double.infinity : null, - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: buttonColor ?? Theme.of(context).primaryColor, - ), - child: context.translate(label).heading6.custom(color: textColor)) - .onPress(onPressed); + height: 56.toScreenHeight, + width: maxWidth ? double.infinity : null, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: buttonColor ?? Theme.of(context).primaryColor, + ), + child: context.translate(label).heading6(context).custom(color: textColor ?? (context.isDark ? AppColor.neutral60 : Colors.white)), + ).onPress(onPressed); } } diff --git a/lib/new_views/pages/login_page.dart b/lib/new_views/pages/login_page.dart index a449a5e6..9c7c08fe 100644 --- a/lib/new_views/pages/login_page.dart +++ b/lib/new_views/pages/login_page.dart @@ -3,7 +3,7 @@ import 'package:fluttertoast/fluttertoast.dart'; import 'package:provider/provider.dart'; import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.dart'; -import 'package:test_sa/extensions/string_extensions.dart' show FilesExtension, TextStyleExtension; +import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/models/enums/translation_keys.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; @@ -49,8 +49,8 @@ class _LoginPageState extends State { children: [ Hero(tag: "logo", child: "logo".toSvgAsset(height: 64.toScreenHeight)), 64.height, - context.translate(TranslationKeys.login).toHeading2(context, fontWeight: FontWeight.w600, color: context.isDark ? AppColor.primary50 : AppColor.neutral50), - context.translate(TranslationKeys.enterCredsToLogin).toHeading6(context, color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), + context.translate(TranslationKeys.login).heading2(context).custom(fontWeight: FontWeight.w600, color: context.isDark ? AppColor.primary50 : AppColor.neutral50), + context.translate(TranslationKeys.enterCredsToLogin).heading6(context).custom(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), 32.height, AppTextFormField( initialValue: _user?.userName, @@ -82,17 +82,15 @@ class _LoginPageState extends State { onTap: () { /// TODO [zaid] : push to another screen }, - child: context.translate(TranslationKeys.forgotPassword).toBody1(context, color: AppColor.primary50, fontWeight: FontWeight.w500), + child: context.translate(TranslationKeys.forgotPassword).bodyText(context).custom(color: AppColor.primary50, fontWeight: FontWeight.w500), ), ), ], ), ).center.expanded, - AppFilledButton(label: TranslationKeys.login, maxWidth: true, onPressed: _login, textColor: Colors.white), + AppFilledButton(label: TranslationKeys.login, maxWidth: true, onPressed: _login), ], ).paddingOnly(left: 16, right: 16, bottom: 24, top: 24), - // floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, - // floatingActionButton: AppFilledButton(label: TranslationKeys.login, maxWidth: true, onPressed: _login), ), ); }