Files
TtxPageAdmin/lib/studio_app_theme.dart
T
2026-05-16 01:10:06 +08:00

136 lines
4.0 KiB
Dart

part of 'studio_app.dart';
bool _isDarkTheme(BuildContext context) {
return Theme.of(context).brightness == Brightness.dark;
}
Color _mutedColor(BuildContext context, [double opacity = 0.68]) {
return Theme.of(context).colorScheme.onSurface.withOpacity(opacity);
}
Color _softPanelColor(BuildContext context) {
return _isDarkTheme(context)
? const Color(0xFF0A1320)
: const Color(0xFFF1F6FA);
}
List<Color> _loginGradientColors(BuildContext context) {
return _isDarkTheme(context)
? const [Color(0xFF060B13), Color(0xFF0D1726), Color(0xFF07121D)]
: const [Color(0xFFF8FBFF), Color(0xFFEFF8F7), Color(0xFFF6F8FB)];
}
List<Color> _shellGradientColors(BuildContext context) {
return _isDarkTheme(context)
? const [Color(0xFF07111A), Color(0xFF091623), Color(0xFF07111A)]
: const [Color(0xFFF8FBFF), Color(0xFFEFF6FF), Color(0xFFF7FAFC)];
}
ThemeData buildStudioTheme(Brightness brightness) {
final colorScheme = ColorScheme.fromSeed(
seedColor: const Color(0xFF1AA6A6),
brightness: brightness,
);
final isDark = brightness == Brightness.dark;
final inputFill = isDark
? const Color(0xFF0E1726)
: colorScheme.surfaceContainerHighest;
return ThemeData(
useMaterial3: true,
brightness: brightness,
colorScheme: colorScheme,
scaffoldBackgroundColor: isDark
? const Color(0xFF07101A)
: const Color(0xFFF6F8FB),
appBarTheme: AppBarTheme(
centerTitle: false,
backgroundColor: isDark ? const Color(0xFF07111A) : const Color(0xFFF8FBFF),
foregroundColor: colorScheme.onSurface,
elevation: 0,
),
cardTheme: CardThemeData(
color: isDark ? const Color(0xFF101B2D) : Colors.white,
elevation: isDark ? 0 : 1,
surfaceTintColor: colorScheme.surfaceTint,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
),
drawerTheme: DrawerThemeData(
backgroundColor: isDark ? const Color(0xFF07111A) : Colors.white,
),
inputDecorationTheme: InputDecorationTheme(
filled: true,
fillColor: inputFill,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide.none,
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide.none,
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(color: colorScheme.primary),
),
),
);
}
class _MiniBadge extends StatelessWidget {
const _MiniBadge({required this.text});
final String text;
@override
Widget build(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
return Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
decoration: BoxDecoration(
color: _isDarkTheme(context)
? Colors.white.withOpacity(0.06)
: scheme.primaryContainer.withOpacity(0.45),
borderRadius: BorderRadius.circular(999),
),
child: Text(
text,
style: Theme.of(context).textTheme.bodySmall
?.copyWith(color: _mutedColor(context, 0.78)),
),
);
}
}
class _ThemeToggleButton extends StatelessWidget {
const _ThemeToggleButton({required this.themeMode, required this.onPressed});
final ThemeMode themeMode;
final VoidCallback onPressed;
@override
Widget build(BuildContext context) {
final isDark = themeMode == ThemeMode.dark;
return FilledButton.tonalIcon(
onPressed: onPressed,
icon: Icon(isDark ? Icons.light_mode_rounded : Icons.dark_mode_rounded),
label: Text(isDark ? '亮色主题' : '暗色主题'),
);
}
}
class _GlowCircle extends StatelessWidget {
const _GlowCircle({required this.color});
final Color color;
@override
Widget build(BuildContext context) {
return Container(
width: 240,
height: 240,
decoration: BoxDecoration(shape: BoxShape.circle, color: color),
);
}
}