toTheme method
- {String? fontFamily,
- ZetaAppBarStyle appBarStyle = ZetaAppBarStyle.primary}
Converts the ZetaColorScheme to a ThemeData object.
Takes optional parameters fontFamily
, a string representing
the font that the generated ThemeData object will use, and
appBarStyle
an enum object of type ZetaAppBarStyle to define the
style of the AppBar. These parameters defaults to null and ZetaAppBarStyle.primary
respectively if they're not provided.
Implementation
ThemeData toTheme({
String? fontFamily,
ZetaAppBarStyle appBarStyle = ZetaAppBarStyle.primary,
}) {
// A TextTheme object for the colors onPrimary.
final primaryTextTheme = buildZdsTextTheme(
textColor: onPrimary,
fontFamily: fontFamily,
);
// A TextTheme object for the colors onSurface.
final TextTheme textTheme = buildZdsTextTheme(
textColor: onSurface,
fontFamily: fontFamily,
);
// The actual appBar color defined by the appBarStyle, based on the color scheme.
final effectiveAppBarColor = appBarStyle.effectiveAppBarColor(this);
// Returns a ThemeData that is constructed from the ZetaColorScheme.
final barTheme = appBarTheme(primaryTextTheme, effectiveAppBarColor);
return ThemeData(
colorScheme: this,
appBarTheme: barTheme,
bottomAppBarTheme: bottomAppBarTheme(),
bottomNavigationBarTheme: bottomNavigationBarTheme(textTheme),
bottomSheetTheme: bottomSheetTheme(),
brightness: brightness,
canvasColor: surface,
cardTheme: cardTheme(),
checkboxTheme: checkboxTheme(),
chipTheme: chipThemeData(textTheme),
datePickerTheme: datePickerTheme(barTheme),
dividerColor: zetaColors.borderSubtle,
dividerTheme: dividerTheme(),
elevatedButtonTheme: elevatedButtonTheme(primaryTextTheme),
fontFamily: fontFamily,
iconTheme: iconTheme(color: zetaColors.iconDefault),
indicatorColor: secondary,
inputDecorationTheme: inputDecorationTheme(textTheme),
listTileTheme: listTileTheme(textTheme),
outlinedButtonTheme: outlinedButtonTheme(primaryTextTheme),
popupMenuTheme: popupMenuTheme(textTheme),
primaryColor: primary,
primaryIconTheme: iconTheme(color: onPrimary),
primaryTextTheme: primaryTextTheme,
progressIndicatorTheme: progressIndicatorTheme(),
radioTheme: radioThemeData(),
scaffoldBackgroundColor: background,
searchBarTheme: searchBarTheme(textTheme),
shadowColor: zetaColors.borderDisabled.withOpacity(0.7),
sliderTheme: sliderTheme(),
splashColor: zetaColors.surfaceSelected,
switchTheme: switchTheme(),
tabBarTheme: tabBarTheme(textTheme),
textButtonTheme: textButtonTheme(primaryTextTheme),
textSelectionTheme: textSelectionTheme(),
textTheme: textTheme,
dialogTheme: dialogTheme(),
);
}