217 lines
8.3 KiB
Dart
Executable File
217 lines
8.3 KiB
Dart
Executable File
import 'package:flutter/material.dart';
|
|
import 'package:siro_driver/constant/style.dart';
|
|
import '../../constant/colors.dart';
|
|
|
|
/// ملاحظة مهمة: لا تستعمل هنا getters من `AppColor` التي تقرأ `Get.isDarkMode`
|
|
/// (مثل `writeColor` و`cardColor`). هذا الملف يُنفَّذ **مرة واحدة عند التحميل**،
|
|
/// فتُخبَّأ قيمة الوضع الحالي داخل الثيمين معاً ⇒ الثيم الفاتح يرث ألوان الداكن
|
|
/// (أو العكس) حسب ما كان الوضع وقت الإقلاع. الألوان هنا تُمرَّر صراحةً لكل ثيم.
|
|
ThemeData _createTheme({
|
|
required Brightness brightness,
|
|
required String fontFamily,
|
|
required Color scaffoldBackgroundColor,
|
|
required Color cardColor,
|
|
required Color dividerColor,
|
|
required Color textColor,
|
|
required Color secondaryTextColor,
|
|
}) {
|
|
final isDark = brightness == Brightness.dark;
|
|
// في الوضع الداكن يصبح النيفي الداكن غير مقروء على خلفية داكنة،
|
|
// فنستعمل لون العلامة الفاتح (Periwinkle) للعناصر التفاعلية.
|
|
final interactive =
|
|
isDark ? AppColor.secondaryColorStatic : AppColor.primaryColor;
|
|
|
|
return ThemeData(
|
|
brightness: brightness,
|
|
fontFamily: fontFamily,
|
|
scaffoldBackgroundColor: scaffoldBackgroundColor,
|
|
cardColor: cardColor,
|
|
dividerColor: dividerColor,
|
|
primaryColor: AppColor.primaryColor,
|
|
splashFactory: InkSparkle.splashFactory,
|
|
colorScheme: ColorScheme.fromSeed(
|
|
seedColor: AppColor.primaryColor,
|
|
brightness: brightness,
|
|
primary: interactive,
|
|
onPrimary: isDark ? AppColor.primaryColor : Colors.white,
|
|
secondary: AppColor.secondaryColorStatic,
|
|
surface: cardColor,
|
|
onSurface: textColor,
|
|
error: AppColor.redColor,
|
|
),
|
|
textTheme: TextTheme(
|
|
displayLarge: AppStyle.headTitle.copyWith(color: textColor),
|
|
displayMedium: AppStyle.headTitle2.copyWith(color: textColor),
|
|
displaySmall: AppStyle.title.copyWith(color: textColor),
|
|
titleLarge: AppStyle.headTitle2.copyWith(color: textColor, fontSize: 20),
|
|
titleMedium: AppStyle.title
|
|
.copyWith(color: textColor, fontWeight: FontWeight.w600),
|
|
bodyLarge: AppStyle.title.copyWith(color: textColor),
|
|
bodyMedium: AppStyle.title.copyWith(color: textColor, fontSize: 14),
|
|
bodySmall: AppStyle.title.copyWith(color: secondaryTextColor, fontSize: 13),
|
|
labelLarge: AppStyle.title
|
|
.copyWith(color: textColor, fontWeight: FontWeight.w600, fontSize: 15),
|
|
labelMedium: AppStyle.subtitle.copyWith(color: secondaryTextColor),
|
|
),
|
|
appBarTheme: AppBarTheme(
|
|
elevation: 0,
|
|
scrolledUnderElevation: 0,
|
|
backgroundColor: scaffoldBackgroundColor,
|
|
foregroundColor: textColor,
|
|
centerTitle: true,
|
|
iconTheme: IconThemeData(color: textColor),
|
|
actionsIconTheme: IconThemeData(color: textColor),
|
|
titleTextStyle: AppStyle.headTitle2.copyWith(
|
|
color: textColor,
|
|
fontSize: 19,
|
|
),
|
|
),
|
|
dialogTheme: DialogThemeData(
|
|
backgroundColor: cardColor,
|
|
contentTextStyle: AppStyle.title.copyWith(color: textColor),
|
|
titleTextStyle: AppStyle.headTitle2.copyWith(color: textColor, fontSize: 20),
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
|
),
|
|
cardTheme: CardThemeData(
|
|
color: cardColor,
|
|
elevation: 0,
|
|
margin: EdgeInsets.zero,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(18),
|
|
side: BorderSide(color: dividerColor),
|
|
),
|
|
),
|
|
listTileTheme: ListTileThemeData(
|
|
iconColor: secondaryTextColor,
|
|
textColor: textColor,
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),
|
|
),
|
|
dividerTheme: DividerThemeData(
|
|
color: dividerColor,
|
|
thickness: 1,
|
|
space: 1,
|
|
),
|
|
chipTheme: ChipThemeData(
|
|
backgroundColor: interactive.withValues(alpha: 0.10),
|
|
side: BorderSide.none,
|
|
labelStyle: AppStyle.subtitle.copyWith(color: textColor),
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(999)),
|
|
),
|
|
elevatedButtonTheme: ElevatedButtonThemeData(
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: interactive,
|
|
foregroundColor: isDark ? AppColor.primaryColor : Colors.white,
|
|
elevation: 0,
|
|
minimumSize: const Size(0, 50),
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),
|
|
textStyle: const TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
|
|
),
|
|
),
|
|
outlinedButtonTheme: OutlinedButtonThemeData(
|
|
style: OutlinedButton.styleFrom(
|
|
foregroundColor: interactive,
|
|
minimumSize: const Size(0, 50),
|
|
side: BorderSide(color: interactive.withValues(alpha: 0.5)),
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),
|
|
textStyle: const TextStyle(fontWeight: FontWeight.w600, fontSize: 15),
|
|
),
|
|
),
|
|
textButtonTheme: TextButtonThemeData(
|
|
style: TextButton.styleFrom(
|
|
foregroundColor: interactive,
|
|
textStyle: const TextStyle(fontWeight: FontWeight.w600),
|
|
),
|
|
),
|
|
snackBarTheme: SnackBarThemeData(
|
|
behavior: SnackBarBehavior.floating,
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),
|
|
),
|
|
progressIndicatorTheme: ProgressIndicatorThemeData(color: interactive),
|
|
inputDecorationTheme: InputDecorationTheme(
|
|
filled: true,
|
|
fillColor: isDark ? Colors.white.withValues(alpha: 0.04) : cardColor,
|
|
hintStyle: AppStyle.title.copyWith(color: secondaryTextColor, fontSize: 14),
|
|
contentPadding:
|
|
const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
|
border: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(14),
|
|
borderSide: BorderSide(color: dividerColor),
|
|
),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(14),
|
|
borderSide: BorderSide(color: dividerColor),
|
|
),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(14),
|
|
borderSide: BorderSide(color: interactive, width: 1.5),
|
|
),
|
|
errorBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(14),
|
|
borderSide: const BorderSide(color: AppColor.redColor),
|
|
),
|
|
),
|
|
bottomSheetTheme: BottomSheetThemeData(
|
|
backgroundColor: cardColor,
|
|
surfaceTintColor: Colors.transparent,
|
|
shape: const RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
// --- ألوان الأسطح: فاتح ---
|
|
const Color _lightBg = Color(0xFFF6F8FA);
|
|
const Color _lightCard = Color(0xFFFFFFFF);
|
|
const Color _lightDivider = Color(0xFFE6EAF0);
|
|
const Color _lightText = Color(0xFF0F172A);
|
|
const Color _lightTextSecondary = Color(0xFF64748B);
|
|
|
|
// --- ألوان الأسطح: داكن ---
|
|
const Color _darkBg = Color(0xFF0F1424);
|
|
const Color _darkCard = Color(0xFF171D33);
|
|
const Color _darkDivider = Color(0xFF262E4A);
|
|
const Color _darkText = Color(0xFFF1F5F9);
|
|
const Color _darkTextSecondary = Color(0xFF94A3B8);
|
|
|
|
ThemeData lightThemeEnglish = _createTheme(
|
|
brightness: Brightness.light,
|
|
fontFamily: 'CupertinoSystemText', // Native fallback
|
|
scaffoldBackgroundColor: _lightBg,
|
|
cardColor: _lightCard,
|
|
dividerColor: _lightDivider,
|
|
textColor: _lightText,
|
|
secondaryTextColor: _lightTextSecondary,
|
|
);
|
|
|
|
ThemeData darkThemeEnglish = _createTheme(
|
|
brightness: Brightness.dark,
|
|
fontFamily: 'CupertinoSystemText',
|
|
scaffoldBackgroundColor: _darkBg,
|
|
cardColor: _darkCard,
|
|
dividerColor: _darkDivider,
|
|
textColor: _darkText,
|
|
secondaryTextColor: _darkTextSecondary,
|
|
);
|
|
|
|
ThemeData lightThemeArabic = _createTheme(
|
|
brightness: Brightness.light,
|
|
fontFamily: 'CupertinoSystemText',
|
|
scaffoldBackgroundColor: _lightBg,
|
|
cardColor: _lightCard,
|
|
dividerColor: _lightDivider,
|
|
textColor: _lightText,
|
|
secondaryTextColor: _lightTextSecondary,
|
|
);
|
|
|
|
ThemeData darkThemeArabic = _createTheme(
|
|
brightness: Brightness.dark,
|
|
fontFamily: 'CupertinoSystemText',
|
|
scaffoldBackgroundColor: _darkBg,
|
|
cardColor: _darkCard,
|
|
dividerColor: _darkDivider,
|
|
textColor: _darkText,
|
|
secondaryTextColor: _darkTextSecondary,
|
|
);
|