You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
130 lines
3.6 KiB
130 lines
3.6 KiB
import 'package:data/app_setting_data/repository/app_setting_box_repository_impl.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import 'package:local_db_core/lib/boxes/box_list/setting_box/app_setting_box.dart';
|
|
import 'package:repositories/app_setting_box_domain/repository/app_setting_box_repository.dart';
|
|
|
|
enum FontWeights {
|
|
light,
|
|
regular,
|
|
medium,
|
|
bold,
|
|
black,
|
|
}
|
|
|
|
enum FontFamilyName {
|
|
segoeui,
|
|
moshaf,
|
|
moshafAEO,
|
|
sname,
|
|
aar,
|
|
aar2,
|
|
times,
|
|
noor,
|
|
noorAeo,
|
|
}
|
|
|
|
extension FontFamilyNameExtension on FontFamilyName {
|
|
String get name {
|
|
switch (this) {
|
|
case FontFamilyName.segoeui:
|
|
return 'Vazir';
|
|
case FontFamilyName.moshaf:
|
|
return 'Moshaf';
|
|
case FontFamilyName.moshafAEO:
|
|
return 'MoshafAEO';
|
|
case FontFamilyName.sname:
|
|
return 'sname';
|
|
case FontFamilyName.aar:
|
|
return 'aar';
|
|
case FontFamilyName.aar2:
|
|
return 'aar2';
|
|
case FontFamilyName.times:
|
|
return 'times';
|
|
case FontFamilyName.noor:
|
|
return 'noor';
|
|
case FontFamilyName.noorAeo:
|
|
return 'noor_aeo';
|
|
}
|
|
}
|
|
}
|
|
|
|
class AppTheme {
|
|
|
|
AppTheme.privateConstructor();
|
|
|
|
static final AppTheme instance = AppTheme.privateConstructor();
|
|
|
|
factory AppTheme() {
|
|
return instance;
|
|
}
|
|
|
|
final AppSettingBoxRepository _localRepository = AppSettingBoxRepositoryImpl(appSettingBox: AppSettingBox());
|
|
|
|
ThemeData lightThemeData = ThemeData(
|
|
brightness: Brightness.light,
|
|
primaryColor: Colors.teal,
|
|
checkboxTheme: const CheckboxThemeData().copyWith(),
|
|
colorScheme: const ColorScheme.light().copyWith(
|
|
primary: const Color(0xFF2049EB),
|
|
secondary: Colors.white.withOpacity(0),
|
|
),
|
|
textTheme: const TextTheme(
|
|
displayLarge: TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold),
|
|
titleLarge: TextStyle(fontSize: 16.0, fontStyle: FontStyle.italic),
|
|
bodyMedium: TextStyle(fontSize: 12.0),
|
|
),
|
|
);
|
|
|
|
final segoeFontName = 'Vazir';
|
|
|
|
TextStyle fontCreator(
|
|
double fontSize,
|
|
FontWeights fontWeights,
|
|
fontColor, [
|
|
FontFamilyName? fontName,
|
|
wordSpacing,
|
|
lineHeight,
|
|
shadow,
|
|
]) {
|
|
String languageCode = _localRepository.getCurrentLanguage() ?? 'fa';
|
|
if (languageCode == 'ar' &&
|
|
(fontName == null || fontName == FontFamilyName.segoeui || fontName == FontFamilyName.times)) {
|
|
return GoogleFonts.notoSansArabic(
|
|
color: fontColor,
|
|
fontStyle: FontStyle.normal,
|
|
fontWeight: fontWeights == FontWeights.light
|
|
? FontWeight.w300
|
|
: fontWeights == FontWeights.regular
|
|
? FontWeight.w400
|
|
: fontWeights == FontWeights.medium
|
|
? FontWeight.w500
|
|
: fontWeights == FontWeights.bold
|
|
? FontWeight.w700
|
|
: FontWeight.w800,
|
|
height: (lineHeight ?? 1) * 1.4,
|
|
wordSpacing: wordSpacing,
|
|
fontSize: fontSize,
|
|
shadows: shadow,
|
|
);
|
|
}
|
|
return TextStyle(
|
|
color: fontColor,
|
|
fontStyle: FontStyle.normal,
|
|
fontFamily: fontName?.name ?? segoeFontName,
|
|
fontWeight: fontWeights == FontWeights.light
|
|
? FontWeight.w300
|
|
: fontWeights == FontWeights.regular
|
|
? FontWeight.w400
|
|
: fontWeights == FontWeights.medium
|
|
? FontWeight.w500
|
|
: fontWeights == FontWeights.bold
|
|
? FontWeight.w700
|
|
: FontWeight.w800,
|
|
height: lineHeight,
|
|
wordSpacing: wordSpacing,
|
|
fontSize: fontSize,
|
|
shadows: shadow,
|
|
);
|
|
}
|
|
}
|