| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'dark_theme_colors.dart';
- import 'ix_fonts.dart';
- import 'light_theme_colors.dart';
- class IXStyles {
- ///icons theme
- static IconThemeData getIconTheme({required bool isLightTheme}) =>
- IconThemeData(
- color: isLightTheme
- ? LightThemeColors.iconColor
- : DarkThemeColors.iconColor,
- );
- ///app bar theme
- static AppBarTheme getAppBarTheme({required bool isLightTheme}) =>
- AppBarTheme(
- elevation: 0,
- titleTextStyle: getTextTheme(isLightTheme: isLightTheme).bodyMedium!
- .copyWith(color: Colors.white, fontSize: MyFonts.appBarTittleSize),
- iconTheme: IconThemeData(
- color: isLightTheme
- ? LightThemeColors.appBarIconsColor
- : DarkThemeColors.appBarIconsColor,
- ),
- backgroundColor: isLightTheme
- ? LightThemeColors.backgroundColor
- : DarkThemeColors.backgroundColor,
- );
- ///text theme
- static TextTheme getTextTheme({required bool isLightTheme}) => TextTheme(
- labelLarge: MyFonts.buttonTextStyle.copyWith(
- fontSize: MyFonts.buttonTextSize,
- ),
- bodyLarge: (MyFonts.bodyTextStyle).copyWith(
- fontWeight: FontWeight.bold,
- fontSize: MyFonts.bodyLargeSize,
- color: isLightTheme
- ? LightThemeColors.bodyTextColor
- : DarkThemeColors.bodyTextColor,
- ),
- bodyMedium: (MyFonts.bodyTextStyle).copyWith(
- fontSize: MyFonts.bodyMediumSize,
- color: isLightTheme
- ? LightThemeColors.bodyTextColor
- : DarkThemeColors.bodyTextColor,
- ),
- displayLarge: (MyFonts.displayTextStyle).copyWith(
- fontSize: MyFonts.displayLargeSize,
- fontWeight: FontWeight.bold,
- color: isLightTheme
- ? LightThemeColors.displayTextColor
- : DarkThemeColors.displayTextColor,
- ),
- bodySmall: TextStyle(
- color: isLightTheme
- ? LightThemeColors.bodySmallTextColor
- : DarkThemeColors.bodySmallTextColor,
- fontSize: MyFonts.bodySmallTextSize,
- ),
- displayMedium: (MyFonts.displayTextStyle).copyWith(
- fontSize: MyFonts.displayMediumSize,
- fontWeight: FontWeight.bold,
- color: isLightTheme
- ? LightThemeColors.displayTextColor
- : DarkThemeColors.displayTextColor,
- ),
- displaySmall: (MyFonts.displayTextStyle).copyWith(
- fontSize: MyFonts.displaySmallSize,
- fontWeight: FontWeight.bold,
- color: isLightTheme
- ? LightThemeColors.displayTextColor
- : DarkThemeColors.displayTextColor,
- ),
- );
- static ChipThemeData getChipTheme({required bool isLightTheme}) {
- return ChipThemeData(
- backgroundColor: isLightTheme
- ? LightThemeColors.chipBackground
- : DarkThemeColors.chipBackground,
- brightness: Brightness.light,
- labelStyle: getChipTextStyle(isLightTheme: isLightTheme),
- secondaryLabelStyle: getChipTextStyle(isLightTheme: isLightTheme),
- selectedColor: Colors.black,
- disabledColor: Colors.green,
- padding: const EdgeInsets.all(5),
- secondarySelectedColor: Colors.purple,
- );
- }
- ///Chips text style
- static TextStyle getChipTextStyle({required bool isLightTheme}) {
- return MyFonts.chipTextStyle.copyWith(
- fontSize: MyFonts.chipTextSize,
- color: isLightTheme
- ? LightThemeColors.chipTextColor
- : DarkThemeColors.chipTextColor,
- );
- }
- // elevated button text style
- static WidgetStateProperty<TextStyle?>? getElevatedButtonTextStyle(
- bool isLightTheme, {
- bool isBold = true,
- double? fontSize,
- }) {
- return WidgetStateProperty.resolveWith<TextStyle>((
- Set<WidgetState> states,
- ) {
- if (states.contains(WidgetState.pressed)) {
- return MyFonts.buttonTextStyle.copyWith(
- fontWeight: isBold ? FontWeight.bold : FontWeight.normal,
- fontSize: fontSize ?? MyFonts.buttonTextSize,
- color: isLightTheme
- ? LightThemeColors.buttonTextColor
- : DarkThemeColors.buttonTextColor,
- );
- } else if (states.contains(WidgetState.disabled)) {
- return MyFonts.buttonTextStyle.copyWith(
- fontSize: fontSize ?? MyFonts.buttonTextSize,
- fontWeight: isBold ? FontWeight.bold : FontWeight.normal,
- color: isLightTheme
- ? LightThemeColors.buttonDisabledTextColor
- : DarkThemeColors.buttonDisabledTextColor,
- );
- }
- return MyFonts.buttonTextStyle.copyWith(
- fontSize: fontSize ?? MyFonts.buttonTextSize,
- fontWeight: isBold ? FontWeight.bold : FontWeight.normal,
- color: isLightTheme
- ? LightThemeColors.buttonTextColor
- : DarkThemeColors.buttonTextColor,
- ); // Use the component's default.
- });
- }
- //elevated button theme data
- static ElevatedButtonThemeData getElevatedButtonTheme({
- required bool isLightTheme,
- }) => ElevatedButtonThemeData(
- style: ButtonStyle(
- shape: WidgetStateProperty.all<RoundedRectangleBorder>(
- RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(6.r),
- //side: BorderSide(color: Colors.teal, width: 2.0),
- ),
- ),
- elevation: WidgetStateProperty.all(0),
- padding: WidgetStateProperty.all<EdgeInsetsGeometry>(
- EdgeInsets.symmetric(vertical: 8.w),
- ),
- textStyle: getElevatedButtonTextStyle(isLightTheme),
- backgroundColor: WidgetStateProperty.resolveWith<Color>((
- Set<WidgetState> states,
- ) {
- if (states.contains(WidgetState.pressed)) {
- return isLightTheme
- ? LightThemeColors.buttonColor.withValues(alpha: 0.5)
- : DarkThemeColors.buttonColor.withValues(alpha: 0.5);
- } else if (states.contains(WidgetState.disabled)) {
- return isLightTheme
- ? LightThemeColors.buttonDisabledColor
- : DarkThemeColors.buttonDisabledColor;
- }
- return isLightTheme
- ? LightThemeColors.buttonColor
- : DarkThemeColors.buttonColor; // Use the component's default.
- }),
- ),
- );
- /// list tile theme data
- static ListTileThemeData getListTileThemeData({required bool isLightTheme}) {
- return ListTileThemeData(
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.r)),
- iconColor: isLightTheme
- ? LightThemeColors.listTileIconColor
- : DarkThemeColors.listTileIconColor,
- tileColor: isLightTheme
- ? LightThemeColors.listTileBackgroundColor
- : DarkThemeColors.listTileBackgroundColor,
- titleTextStyle: TextStyle(
- fontSize: MyFonts.listTileTitleSize,
- color: isLightTheme
- ? LightThemeColors.listTileTitleColor
- : DarkThemeColors.listTileTitleColor,
- ),
- subtitleTextStyle: TextStyle(
- fontSize: MyFonts.listTileSubtitleSize,
- color: isLightTheme
- ? LightThemeColors.listTileSubtitleColor
- : DarkThemeColors.listTileSubtitleColor,
- ),
- );
- }
- }
|