LCOV - code coverage report
Current view: top level - theme - themes.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 44 45 97.8 %
Date: 2022-07-13 09:29:13 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:basf_flutter_components/basf_flutter_components.dart';
       2             : import 'package:flutter/material.dart';
       3             : import 'package:flutter/services.dart';
       4             : 
       5             : /// All BASF Theme types, each one holding the primary color
       6             : /// that will be used in the theme
       7           0 : enum BasfThemeType {
       8             :   /// BASF yellow color
       9             :   yellow(BasfColors.orange),
      10             : 
      11             :   /// BASF red color
      12             :   red(BasfColors.red),
      13             : 
      14             :   /// BASF lightGreen color
      15             :   lightGreen(BasfColors.lightGreen),
      16             : 
      17             :   /// BASF darkGreen color
      18             :   darkGreen(BasfColors.darkGreen),
      19             : 
      20             :   /// BASF lightBlue color
      21             :   lightBlue(BasfColors.lightBlue),
      22             : 
      23             :   /// BASF darkBlue color
      24             :   darkBlue(BasfColors.darkBlue);
      25             : 
      26             :   /// BASF theme type
      27           1 :   const BasfThemeType(this.primaryColor);
      28             : 
      29             :   /// BASF theme primary color
      30             :   final Color primaryColor;
      31             : }
      32             : 
      33             : /// Core of BASF Themes
      34             : class BasfThemes {
      35             :   /// Default BASF border Radius
      36           2 :   static BorderRadius defaultBorderRadius = BorderRadius.zero;
      37             : 
      38             :   /// Default BASF light main theme
      39           1 :   static ThemeData lightMainTheme(BasfThemeType? basfThemeType) {
      40             :     final theme = basfThemeType ?? BasfThemeType.darkBlue;
      41             : 
      42           1 :     return ThemeData(
      43             :       useMaterial3: true,
      44             :       fontFamily: 'Roboto',
      45           1 :       textTheme: mainTextTheme,
      46           1 :       appBarTheme: _mainAppBarTheme(theme),
      47             :       scaffoldBackgroundColor: BasfColors.white,
      48           1 :       snackBarTheme: _snackBarThemeData(theme),
      49           1 :       colorSchemeSeed: theme.primaryColor,
      50           1 :       textButtonTheme: TextButtonThemeData(
      51           2 :         style: ButtonStyles.containedTextButtonStyle(theme.primaryColor),
      52             :       ),
      53           1 :       outlinedButtonTheme: OutlinedButtonThemeData(
      54           2 :         style: ButtonStyles.primaryOutlinedButtonStyle(theme.primaryColor),
      55             :       ),
      56           1 :       dialogTheme: DialogTheme(
      57           2 :         shape: RoundedRectangleBorder(borderRadius: defaultBorderRadius),
      58             :       ),
      59           1 :       inputDecorationTheme: BasfInputThemes.mainInputDecorationTheme,
      60           1 :       hintColor: BasfInputThemes.focusedBorderColor.shade400,
      61           1 :       bottomNavigationBarTheme: _bottomNavigationBarTheme(theme),
      62             :     );
      63             :   }
      64             : 
      65             :   /// BASF Main text theme
      66           1 :   static TextTheme get mainTextTheme {
      67             :     return const TextTheme(
      68             :       headline1: CustomTextStyle(fontWeight: FontWeight.bold, fontSize: 42),
      69             :       headline2: CustomTextStyle(fontWeight: FontWeight.normal, fontSize: 42),
      70             :       headline3: CustomTextStyle(fontWeight: FontWeight.normal, fontSize: 32),
      71             :       headline4: CustomTextStyle(fontWeight: FontWeight.bold, fontSize: 20),
      72             :       headline5: CustomTextStyle(fontWeight: FontWeight.bold, fontSize: 16),
      73             :       headline6: CustomTextStyle(fontWeight: FontWeight.bold, fontSize: 14),
      74             :       bodyText1: CustomTextStyle(fontWeight: FontWeight.normal, fontSize: 16),
      75             :       bodyText2: CustomTextStyle(fontWeight: FontWeight.normal, fontSize: 14),
      76             :       subtitle1: CustomTextStyle(fontWeight: FontWeight.bold, fontSize: 16),
      77             :       subtitle2: CustomTextStyle(fontWeight: FontWeight.bold, fontSize: 14),
      78             :       caption: CustomTextStyle(fontWeight: FontWeight.w700, fontSize: 14),
      79             :       button: CustomTextStyle(fontWeight: FontWeight.bold, fontSize: 16),
      80             :       overline: CustomTextStyle(fontWeight: FontWeight.normal, fontSize: 12),
      81             :     );
      82             :   }
      83             : 
      84           1 :   static AppBarTheme _mainAppBarTheme(BasfThemeType theme) {
      85           1 :     return AppBarTheme(
      86           1 :       backgroundColor: theme.primaryColor,
      87             :       titleTextStyle:
      88           3 :           mainTextTheme.subtitle1!.copyWith(color: BasfColors.white),
      89             :       iconTheme: const IconThemeData(color: BasfColors.white),
      90             :       systemOverlayStyle: SystemUiOverlayStyle.light,
      91             :       scrolledUnderElevation: 0,
      92             :       elevation: 0,
      93             :     );
      94             :   }
      95             : 
      96           1 :   static SnackBarThemeData _snackBarThemeData(BasfThemeType theme) {
      97           1 :     return SnackBarThemeData(
      98           1 :       backgroundColor: theme.primaryColor,
      99             :       behavior: SnackBarBehavior.floating,
     100           1 :       shape: RoundedRectangleBorder(
     101           1 :         borderRadius: defaultBorderRadius,
     102             :       ),
     103             :       contentTextStyle:
     104           3 :           mainTextTheme.subtitle1!.copyWith(color: BasfColors.white),
     105             :     );
     106             :   }
     107             : 
     108           1 :   static BottomNavigationBarThemeData _bottomNavigationBarTheme(
     109             :     BasfThemeType theme,
     110             :   ) {
     111           1 :     return BottomNavigationBarThemeData(
     112             :       type: BottomNavigationBarType.fixed,
     113             :       backgroundColor: BasfColors.white,
     114           1 :       selectedItemColor: theme.primaryColor,
     115           1 :       unselectedItemColor: theme.primaryColor,
     116           2 :       selectedIconTheme: IconThemeData(color: theme.primaryColor, size: 20),
     117           2 :       unselectedIconTheme: IconThemeData(color: theme.primaryColor, size: 20),
     118           2 :       unselectedLabelStyle: mainTextTheme.overline,
     119           3 :       selectedLabelStyle: mainTextTheme.overline!.copyWith(
     120             :         fontWeight: FontWeight.w500,
     121           1 :         color: theme.primaryColor,
     122             :       ),
     123             :     );
     124             :   }
     125             : 
     126             :   /// BASF date picker button theme
     127           1 :   static ThemeData datePickerButtonTheme(ThemeData theme) {
     128           1 :     return theme.copyWith(
     129           1 :       textButtonTheme: TextButtonThemeData(
     130           1 :         style: TextButton.styleFrom(
     131           1 :           primary: theme.primaryColor,
     132           1 :           shape: RoundedRectangleBorder(
     133           1 :             borderRadius: BasfThemes.defaultBorderRadius,
     134             :           ),
     135             :         ),
     136             :       ),
     137             :     );
     138             :   }
     139             : }

Generated by: LCOV version 1.16