getThemeByBrightness static method
Implementation
static ThemeData getThemeByBrightness(Brightness brightness) {
final PlexBrandConfig? brand = _maybeBrandConfig();
final Color? colorSchemeSeed = _colorSchemeSeed(brightness);
final ColorScheme? colorScheme = _imageColorScheme(brightness);
final PlexThemeData plexExtension = _buildExtension(
brightness,
seed: colorSchemeSeed,
colorScheme: colorScheme,
brand: brand,
);
_storeExtension(brightness, plexExtension);
if (PlexTheme.appTheme != null) {
return _mergeExtensionOnto(
PlexTheme.appTheme!,
plexExtension,
brightness,
);
}
Color? textColor = Brightness.dark == brightness ? Colors.white : null;
return ThemeData(
colorSchemeSeed: colorSchemeSeed,
colorScheme: colorScheme,
useMaterial3: true,
fontFamily: plexExtension.fontFamily,
visualDensity: plexExtension.visualDensity,
scaffoldBackgroundColor: plexExtension.colors.surfacePage,
appBarTheme: AppBarTheme(
toolbarHeight: PlexLayout.topbarHeight,
elevation: 0,
scrolledUnderElevation: 0,
backgroundColor: plexExtension.colors.surfaceCard,
foregroundColor: plexExtension.colors.textPrimary,
surfaceTintColor: Colors.transparent,
shadowColor: Colors.transparent,
shape: Border(
bottom: BorderSide(color: plexExtension.colors.borderSubtle),
),
),
navigationBarTheme: NavigationBarThemeData(
labelTextStyle:
const TextStyle(fontSize: PlexFontSize.smallest).getState()),
brightness: brightness,
textTheme: _textThemeFor(brightness, textColor),
extensions: <ThemeExtension<dynamic>>[plexExtension],
filledButtonTheme: FilledButtonThemeData(
style: FilledButton.styleFrom(
backgroundColor: plexExtension.colors.brandPrimary,
foregroundColor: plexExtension.colors.textInverse,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(PlexRadius.md),
),
),
),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
backgroundColor: plexExtension.colors.brandPrimary,
foregroundColor: plexExtension.colors.textInverse,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(PlexRadius.md),
),
),
),
outlinedButtonTheme: OutlinedButtonThemeData(
style: OutlinedButton.styleFrom(
foregroundColor: plexExtension.colors.brandPrimary,
side: BorderSide(color: plexExtension.colors.borderDefault),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(PlexRadius.md),
),
),
),
textButtonTheme: TextButtonThemeData(
style: TextButton.styleFrom(
foregroundColor: plexExtension.colors.brandPrimary,
),
),
inputDecorationTheme: InputDecorationTheme(
filled: true,
fillColor: plexExtension.colors.surfaceSunken,
errorStyle: TextStyle(color: plexExtension.colors.statusDanger),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(PlexRadius.md),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(PlexRadius.md),
borderSide:
BorderSide(color: plexExtension.colors.borderFocus, width: 1.5),
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(PlexRadius.md),
borderSide: BorderSide(color: plexExtension.colors.statusDanger),
),
),
cardTheme: CardThemeData(
color: plexExtension.colors.surfaceCard,
surfaceTintColor: Colors.transparent,
shadowColor: plexExtension.colors.brandInk.withValues(alpha: 0.12),
elevation: PlexElevation.sm,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(PlexRadius.lg),
side: BorderSide(color: plexExtension.colors.borderSubtle),
),
),
dialogTheme: DialogThemeData(
backgroundColor: plexExtension.colors.surfaceCard,
surfaceTintColor: Colors.transparent,
elevation: PlexElevation.lg,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(PlexRadius.lg),
),
),
bottomSheetTheme: BottomSheetThemeData(
backgroundColor: plexExtension.colors.surfaceCard,
surfaceTintColor: Colors.transparent,
elevation: PlexElevation.lg,
shape: const RoundedRectangleBorder(
borderRadius:
BorderRadius.vertical(top: Radius.circular(PlexRadius.xl)),
),
),
);
}