import 'package:flutter/material.dart'; import 'package:hadi_hoda_flutter/common_ui/resources/my_colors.dart'; import 'package:hadi_hoda_flutter/core/constants/my_constants.dart'; import 'package:hadi_hoda_flutter/core/utils/local_storage.dart'; import 'package:hadi_hoda_flutter/core/utils/my_device.dart'; import 'package:hadi_hoda_flutter/core/utils/my_device.dart'; import 'package:hadi_hoda_flutter/core/utils/my_device.dart'; import 'package:hadi_hoda_flutter/core/utils/my_device.dart'; import 'package:hadi_hoda_flutter/core/utils/my_device.dart'; import 'package:hadi_hoda_flutter/core/utils/my_device.dart'; import 'package:hadi_hoda_flutter/core/utils/my_device.dart'; import 'package:hadi_hoda_flutter/core/utils/my_device.dart'; import 'package:hadi_hoda_flutter/core/utils/my_device.dart'; import 'package:hadi_hoda_flutter/core/utils/my_device.dart'; import 'package:hadi_hoda_flutter/core/utils/my_device.dart'; class MYTextStyle { static const MYTextStyle _i = MYTextStyle._internal(); const MYTextStyle._internal(); factory MYTextStyle() => _i; static const String dinoKids = 'DinoKids'; static const String notoSansArabic = 'NotoSansArabic'; static const String marhey = 'Marhey'; static const String baloo2 = 'Baloo_2'; static const Color textColor = MyColors.white; static bool _isArabicOrPersianLanguage() { final selectedLanguage = (LocalStorage.readData(key: MyConstants.selectLanguage) ?? MyConstants.defaultLanguage) .toString() .trim() .toLowerCase(); final languageCode = selectedLanguage.split(RegExp(r'[_-]')).first; return languageCode == 'ar' || languageCode == 'fa'; } static String _fontForLanguage(String defaultFont) { return _isArabicOrPersianLanguage() ? notoSansArabic : defaultFont; } static FontWeight _fontWeightForLanguage(FontWeight defaultWeight) { if (!_isArabicOrPersianLanguage()) return defaultWeight; return switch (defaultWeight) { FontWeight.w100 => FontWeight.w300, FontWeight.w200 => FontWeight.w400, FontWeight.w300 => FontWeight.w500, FontWeight.w400 => FontWeight.w600, FontWeight.w500 => FontWeight.w700, FontWeight.w600 => FontWeight.w800, FontWeight.w700 => FontWeight.w900, FontWeight.w800 => FontWeight.w900, FontWeight.w900 => FontWeight.w900, _ => defaultWeight, }; } static TextStyle get titr0 => TextStyle( fontFamily: _fontForLanguage(marhey), fontWeight: _fontWeightForLanguage(FontWeight.w700), fontSize: MyDevice.fontSize(26), color: textColor, ); static TextStyle get titr1 => TextStyle( fontFamily: _fontForLanguage(baloo2), fontWeight: _fontWeightForLanguage(FontWeight.w800), fontSize: MyDevice.fontSize(20), color: textColor, ); static TextStyle get titr3 => TextStyle( fontFamily: _fontForLanguage(marhey), fontWeight: _fontWeightForLanguage(FontWeight.w600), fontSize: MyDevice.fontSize(18), color: textColor, ); static TextStyle get titr4 => TextStyle( fontFamily: _fontForLanguage(marhey), fontWeight: _fontWeightForLanguage(FontWeight.w700), fontSize: MyDevice.fontSize(14), color: textColor, ); static TextStyle get matn1 => TextStyle( fontFamily: _fontForLanguage(baloo2), fontWeight: _fontWeightForLanguage(FontWeight.w600), fontSize: MyDevice.fontSize(18), color: textColor, ); static TextStyle get matn2_3 => TextStyle( fontFamily: _fontForLanguage(baloo2), fontWeight: _fontWeightForLanguage(FontWeight.w700), fontSize: MyDevice.fontSize(18), color: textColor, ); static TextStyle get matn2_2 => TextStyle( fontFamily: _fontForLanguage(baloo2), fontWeight: _fontWeightForLanguage(FontWeight.w700), fontSize: MyDevice.fontSize(16), color: textColor, ); static TextStyle get matn2 => TextStyle( fontFamily: _fontForLanguage(baloo2), fontWeight: _fontWeightForLanguage(FontWeight.w700), fontSize: MyDevice.fontSize(14), color: textColor, ); static TextStyle get matn3 => TextStyle( fontFamily: _fontForLanguage(baloo2), fontWeight: _fontWeightForLanguage(FontWeight.w500), fontSize: MyDevice.fontSize(12), color: textColor, ); static TextStyle get button1 => TextStyle( fontFamily: _fontForLanguage(dinoKids), fontWeight: _fontWeightForLanguage(FontWeight.w400), fontSize: MyDevice.fontSize(45), color: textColor, ); static TextStyle get button2 => TextStyle( fontFamily: _fontForLanguage(dinoKids), fontWeight: _fontWeightForLanguage(FontWeight.w400), fontSize: MyDevice.fontSize(30), color: textColor, ); }