import 'package:flutter/material.dart'; import 'yanting_text.dart'; import 'yanting_tokens.dart'; ThemeData buildAppTheme(Brightness brightness) { final primary = brightness == Brightness.dark ? YantingDarkColors.primary : YantingColors.primary; final primaryForeground = brightness == Brightness.dark ? YantingDarkColors.primaryForeground : YantingColors.primaryForeground; final secondary = brightness == Brightness.dark ? YantingDarkColors.secondary : YantingColors.secondary; final secondaryForeground = brightness == Brightness.dark ? YantingDarkColors.secondaryForeground : YantingColors.secondaryForeground; final link = brightness == Brightness.dark ? YantingDarkColors.link : YantingColors.link; final card = brightness == Brightness.dark ? YantingDarkColors.card : YantingColors.card; final foreground = brightness == Brightness.dark ? YantingDarkColors.foreground : YantingColors.foreground; final destructive = brightness == Brightness.dark ? YantingDarkColors.destructive : YantingColors.destructive; final border = brightness == Brightness.dark ? YantingDarkColors.border : YantingColors.border; final background = brightness == Brightness.dark ? YantingDarkColors.background : YantingColors.background; final mutedForeground = brightness == Brightness.dark ? YantingDarkColors.mutedForeground : YantingColors.mutedForeground; final input = brightness == Brightness.dark ? YantingDarkColors.input : YantingColors.input; final scheme = ColorScheme.fromSeed( seedColor: primary, brightness: brightness, primary: primary, onPrimary: primaryForeground, secondary: secondary, onSecondary: secondaryForeground, tertiary: link, surface: card, onSurface: foreground, error: destructive, outline: border, ); return ThemeData( useMaterial3: true, colorScheme: scheme, fontFamily: YantingText.fontFamily, fontFamilyFallback: YantingText.fontFallback, brightness: brightness, scaffoldBackgroundColor: background, appBarTheme: AppBarTheme( backgroundColor: background, foregroundColor: foreground, elevation: 0, centerTitle: false, titleTextStyle: YantingText.sectionTitle, surfaceTintColor: Colors.transparent, ), cardTheme: CardThemeData( color: card, elevation: 0, margin: EdgeInsets.zero, shape: RoundedRectangleBorder( borderRadius: const BorderRadius.all(Radius.circular(YantingRadius.xl)), side: BorderSide(color: border), ), ), dividerTheme: DividerThemeData( color: border, thickness: 1, space: 1, ), inputDecorationTheme: InputDecorationTheme( filled: true, fillColor: background, hintStyle: YantingText.body.copyWith(color: mutedForeground), contentPadding: const EdgeInsets.symmetric(horizontal: 14), border: OutlineInputBorder( borderRadius: BorderRadius.circular(YantingRadius.md), borderSide: BorderSide(color: input), ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(YantingRadius.md), borderSide: BorderSide(color: input), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(YantingRadius.md), borderSide: BorderSide(color: foreground), ), ), snackBarTheme: SnackBarThemeData( backgroundColor: foreground, contentTextStyle: YantingText.body.copyWith(color: background), behavior: SnackBarBehavior.floating, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(YantingRadius.md), ), ), navigationBarTheme: NavigationBarThemeData( backgroundColor: background, indicatorColor: Colors.transparent, labelTextStyle: WidgetStateProperty.resolveWith( (states) => YantingText.meta.copyWith( color: states.contains(WidgetState.selected) ? foreground : mutedForeground, fontSize: 11, fontWeight: states.contains(WidgetState.selected) ? FontWeight.w600 : FontWeight.w400, ), ), iconTheme: WidgetStateProperty.resolveWith( (states) => IconThemeData( color: states.contains(WidgetState.selected) ? foreground : mutedForeground, ), ), ), textTheme: const TextTheme( headlineSmall: YantingText.appTitle, titleLarge: YantingText.sectionTitle, titleMedium: YantingText.cardTitle, bodyLarge: YantingText.body, bodyMedium: YantingText.sub, bodySmall: YantingText.meta, labelLarge: YantingText.chip, labelSmall: YantingText.badge, ), ); }