Files
feature-next-arch/lib/core/theme/AppTheme.dart
2026-01-18 20:21:14 +08:00

86 lines
2.8 KiB
Dart

import 'package:flutter/material.dart';
class AppTheme {
// 基础色值定义
static const Color _pureWhite = Color(0xFFFFFFFF);
static const Color _offWhite = Color(0xFFfafafc); // 稍微带点灰的白,用于背景增加层次感
static const Color _pureBlack = Color(0xFF000000);
static const Color _darkGrey = Color(0xFF1C1C1E); // iOS 风格的深灰黑色
static ThemeData get lightTheme {
return ThemeData(
useMaterial3: true,
brightness: Brightness.light,
// 1. 整体背景色
scaffoldBackgroundColor: _offWhite,
// 2. 核心颜色方案
colorScheme: const ColorScheme.light(
primary: _pureBlack, // 主色设为黑色
onPrimary: _pureWhite, // 黑色背景上的文字设为白色
surface: _pureWhite, // 卡片、弹窗等表面颜色
onSurface: _pureBlack, // 表面上的文字色
background: _offWhite,
),
// 3. 全局按钮主题
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
backgroundColor: _pureBlack,
foregroundColor: _pureWhite,
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 24),
),
),
// 4. 填充按钮主题 (常用语 Material 3)
filledButtonTheme: FilledButtonThemeData(
style: FilledButton.styleFrom(
backgroundColor: _pureBlack,
foregroundColor: _pureWhite,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
),
// 5. AppBar 主题 (纯白背景,黑色文字)
appBarTheme: const AppBarTheme(
backgroundColor: _pureWhite,
surfaceTintColor: Colors.transparent,
elevation: 0,
centerTitle: true,
iconTheme: IconThemeData(color: _pureBlack),
titleTextStyle: TextStyle(
color: _pureBlack,
fontSize: 18,
fontWeight: FontWeight.w700,
letterSpacing: -0.5,
),
),
// 6. 输入框主题 (黑白简约)
inputDecorationTheme: InputDecorationTheme(
filled: true,
fillColor: _pureWhite,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(color: Colors.black12),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(color: Colors.black12),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(color: _pureBlack, width: 1.5),
),
),
);
}
}