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 heading1(BuildContext context) => getTextWithStyle(this, AppTextStyles.heading1, context.isDark ? AppColor.backgroundLight : AppColor.neutral70); Text heading2(BuildContext context) => getTextWithStyle(this, AppTextStyles.heading2, context.isDark ? AppColor.neutral30 : AppColor.neutral50); Text heading3(BuildContext context) => getTextWithStyle(this, AppTextStyles.heading3, context.isDark ? AppColor.neutral30 : AppColor.neutral50); Text heading4(BuildContext context) => getTextWithStyle(this, AppTextStyles.heading4, context.isDark ? AppColor.neutral30 : AppColor.neutral50); Text heading5(BuildContext context) => getTextWithStyle(this, AppTextStyles.heading5, context.isDark ? AppColor.neutral30 : AppColor.neutral50); Text heading6(BuildContext context) => getTextWithStyle(this, AppTextStyles.heading6, context.isDark ? AppColor.neutral30 : AppColor.neutral50); Text bodyText(BuildContext context) => getTextWithStyle(this, AppTextStyles.bodyText, context.isDark ? AppColor.neutral10 : AppColor.neutral20); Text bodyText2(BuildContext context) => getTextWithStyle(this, AppTextStyles.bodyText2, context.isDark ? AppColor.neutral10 : AppColor.neutral20); Text tinyFont(BuildContext context) => getTextWithStyle(this, AppTextStyles.tinyFont, context.isDark ? AppColor.neutral10 : AppColor.neutral20); Text overline(BuildContext context) => getTextWithStyle(this, AppTextStyles.overline, context.isDark ? AppColor.neutral10 : AppColor.neutral20); Text getTextWithStyle(String string, TextStyle style, Color color) => Text(string, style: style.copyWith(color: color)); } extension CustomText on Text { Text custom({Color color, FontWeight fontWeight, TextAlign align}) { return Text( data, textAlign: align, style: style.copyWith( color: color, fontWeight: fontWeight, ), ); } } abstract class AppTextStyles { static final TextStyle heading1 = TextStyle( fontSize: 54.toScreenWidth, fontWeight: FontWeight.w500, letterSpacing: -0.81, fontStyle: FontStyle.normal, decoration: TextDecoration.none, ); static final TextStyle heading2 = TextStyle( fontSize: 28.toScreenWidth, fontWeight: FontWeight.w700, letterSpacing: -0.56, fontStyle: FontStyle.normal, decoration: TextDecoration.none, ); static final TextStyle heading3 = TextStyle( fontSize: 24.toScreenWidth, fontWeight: FontWeight.w700, letterSpacing: -0.12, fontStyle: FontStyle.normal, decoration: TextDecoration.none, ); static final TextStyle heading4 = TextStyle( fontSize: 21.toScreenWidth, fontWeight: FontWeight.w500, fontStyle: FontStyle.normal, decoration: TextDecoration.none, ); static final TextStyle heading5 = TextStyle( fontSize: 19.toScreenWidth, fontWeight: FontWeight.w500, fontStyle: FontStyle.normal, decoration: TextDecoration.none, ); static final TextStyle heading6 = TextStyle( fontSize: 16.toScreenWidth, fontWeight: FontWeight.w500, fontStyle: FontStyle.normal, decoration: TextDecoration.none, ); static final TextStyle bodyText = TextStyle( fontSize: 14.toScreenWidth, fontWeight: FontWeight.w500, fontStyle: FontStyle.normal, decoration: TextDecoration.none, ); static final TextStyle bodyText2 = TextStyle( fontSize: 12.toScreenWidth, fontWeight: FontWeight.w500, fontStyle: FontStyle.normal, decoration: TextDecoration.none, ); static final TextStyle tinyFont = TextStyle( fontSize: 11.toScreenWidth, fontWeight: FontWeight.w500, fontStyle: FontStyle.normal, decoration: TextDecoration.none, ); static final TextStyle overline = TextStyle( fontSize: 9.toScreenWidth, fontWeight: FontWeight.w500, letterSpacing: 0.05, fontStyle: FontStyle.normal, 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({ int width, int height, Color color, BoxFit fit = BoxFit.contain, }) => SvgPicture.asset("assets/images/$this.svg", width: width?.toScreenWidth, height: height?.toScreenHeight, color: color, fit: fit); Image toPngAsset({ int width, int height, Color color, BoxFit fit = BoxFit.contain, }) => Image.asset("assets/images/$this.png", width: width?.toScreenWidth, height: height?.toScreenHeight, color: color, fit: fit); }