fix;设置和深浅色

This commit is contained in:
jingyun
2026-06-05 17:54:46 +08:00
parent 33d04a5545
commit af865b13fb
24 changed files with 742 additions and 290 deletions
+71 -37
View File
@@ -3,85 +3,119 @@ import 'package:flutter/material.dart';
import 'yanting_text.dart';
import 'yanting_tokens.dart';
ThemeData buildAppTheme() {
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: YantingColors.primary,
primary: YantingColors.primary,
onPrimary: YantingColors.primaryForeground,
secondary: YantingColors.secondary,
onSecondary: YantingColors.secondaryForeground,
tertiary: YantingColors.link,
surface: YantingColors.card,
onSurface: YantingColors.foreground,
error: YantingColors.destructive,
outline: YantingColors.border,
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,
scaffoldBackgroundColor: YantingColors.background,
appBarTheme: const AppBarTheme(
backgroundColor: YantingColors.background,
foregroundColor: YantingColors.foreground,
brightness: brightness,
scaffoldBackgroundColor: background,
appBarTheme: AppBarTheme(
backgroundColor: background,
foregroundColor: foreground,
elevation: 0,
centerTitle: false,
titleTextStyle: YantingText.sectionTitle,
surfaceTintColor: Colors.transparent,
),
cardTheme: const CardThemeData(
color: YantingColors.card,
cardTheme: CardThemeData(
color: card,
elevation: 0,
margin: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(YantingRadius.xl)),
side: BorderSide(color: YantingColors.border),
borderRadius: const BorderRadius.all(Radius.circular(YantingRadius.xl)),
side: BorderSide(color: border),
),
),
dividerTheme: const DividerThemeData(
color: YantingColors.border,
dividerTheme: DividerThemeData(
color: border,
thickness: 1,
space: 1,
),
inputDecorationTheme: InputDecorationTheme(
filled: true,
fillColor: YantingColors.background,
hintStyle: YantingText.body.copyWith(
color: YantingColors.mutedForeground,
),
fillColor: background,
hintStyle: YantingText.body.copyWith(color: mutedForeground),
contentPadding: const EdgeInsets.symmetric(horizontal: 14),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(YantingRadius.md),
borderSide: const BorderSide(color: YantingColors.input),
borderSide: BorderSide(color: input),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(YantingRadius.md),
borderSide: const BorderSide(color: YantingColors.input),
borderSide: BorderSide(color: input),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(YantingRadius.md),
borderSide: const BorderSide(color: YantingColors.foreground),
borderSide: BorderSide(color: foreground),
),
),
snackBarTheme: SnackBarThemeData(
backgroundColor: YantingColors.foreground,
contentTextStyle: YantingText.body.copyWith(
color: YantingColors.background,
),
backgroundColor: foreground,
contentTextStyle: YantingText.body.copyWith(color: background),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(YantingRadius.md),
),
),
navigationBarTheme: NavigationBarThemeData(
backgroundColor: YantingColors.background,
backgroundColor: background,
indicatorColor: Colors.transparent,
labelTextStyle: WidgetStateProperty.resolveWith(
(states) => YantingText.meta.copyWith(
color: states.contains(WidgetState.selected)
? YantingColors.foreground
: YantingColors.mutedForeground,
? foreground
: mutedForeground,
fontSize: 11,
fontWeight: states.contains(WidgetState.selected)
? FontWeight.w600
@@ -91,8 +125,8 @@ ThemeData buildAppTheme() {
iconTheme: WidgetStateProperty.resolveWith(
(states) => IconThemeData(
color: states.contains(WidgetState.selected)
? YantingColors.foreground
: YantingColors.mutedForeground,
? foreground
: mutedForeground,
),
),
),