refactor(apps): 主题系统迁移至 ColorScheme + 扩展架构并支持 Dark Mode
This commit is contained in:
@@ -5,8 +5,9 @@ class AuthBootScreen extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFEFF8FF),
|
||||
backgroundColor: colorScheme.surface,
|
||||
body: SafeArea(
|
||||
child: Center(
|
||||
child: Image.asset(
|
||||
|
||||
@@ -97,6 +97,8 @@ class _LoginViewState extends State<LoginView> {
|
||||
}
|
||||
|
||||
Widget _buildAgreementCheckbox() {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return Center(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -107,7 +109,7 @@ class _LoginViewState extends State<LoginView> {
|
||||
checked: _agreedToTerms,
|
||||
button: true,
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(AppRadius.md),
|
||||
borderRadius: BorderRadius.circular(AppRadius.sm),
|
||||
onTap: () => setState(() => _agreedToTerms = !_agreedToTerms),
|
||||
child: SizedBox(
|
||||
width: 44,
|
||||
@@ -119,21 +121,21 @@ class _LoginViewState extends State<LoginView> {
|
||||
margin: const EdgeInsets.only(right: AppSpacing.sm),
|
||||
decoration: BoxDecoration(
|
||||
color: _agreedToTerms
|
||||
? AppColors.blue600
|
||||
: Colors.transparent,
|
||||
? colorScheme.primary
|
||||
: colorScheme.surface.withValues(alpha: 0),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(
|
||||
color: _agreedToTerms
|
||||
? AppColors.blue600
|
||||
: AppColors.slate400,
|
||||
? colorScheme.primary
|
||||
: colorScheme.onSurfaceVariant,
|
||||
width: 1.5,
|
||||
),
|
||||
),
|
||||
child: _agreedToTerms
|
||||
? const Icon(
|
||||
? Icon(
|
||||
Icons.check,
|
||||
size: 14,
|
||||
color: AppColors.white,
|
||||
color: colorScheme.onPrimary,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
@@ -143,21 +145,24 @@ class _LoginViewState extends State<LoginView> {
|
||||
),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: const TextStyle(fontSize: 13, color: AppColors.slate600),
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
),
|
||||
children: [
|
||||
TextSpan(text: context.l10n.authAgreementPrefix),
|
||||
TextSpan(
|
||||
text: context.l10n.authAgreementTerms,
|
||||
style: const TextStyle(
|
||||
color: AppColors.blue600,
|
||||
style: TextStyle(
|
||||
color: colorScheme.primary,
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
),
|
||||
TextSpan(text: context.l10n.authAgreementAnd),
|
||||
TextSpan(
|
||||
text: context.l10n.authAgreementPrivacy,
|
||||
style: const TextStyle(
|
||||
color: AppColors.blue600,
|
||||
style: TextStyle(
|
||||
color: colorScheme.primary,
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -29,16 +29,18 @@ class AuthField extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (label != null) ...[
|
||||
Text(
|
||||
label!,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppColors.slate700,
|
||||
color: colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
SizedBox(height: AppSpacing.sm),
|
||||
@@ -52,15 +54,15 @@ class AuthField extends StatelessWidget {
|
||||
obscureText: obscureText,
|
||||
onChanged: onChanged,
|
||||
inputFormatters: inputFormatters,
|
||||
style: const TextStyle(fontSize: 16, color: AppColors.slate900),
|
||||
style: TextStyle(fontSize: 16, color: colorScheme.onSurface),
|
||||
decoration: InputDecoration(
|
||||
hintText: hint,
|
||||
hintStyle: const TextStyle(
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 15,
|
||||
color: AppColors.slate400,
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
),
|
||||
filled: true,
|
||||
fillColor: AppColors.authInputBackground,
|
||||
fillColor: colorScheme.surface,
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: AppSpacing.lg,
|
||||
vertical: AppSpacing.lg,
|
||||
@@ -73,11 +75,11 @@ class AuthField extends StatelessWidget {
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(AppRadius.lg),
|
||||
borderSide: const BorderSide(color: AppColors.authInputBorder),
|
||||
borderSide: BorderSide(color: colorScheme.outlineVariant),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(AppRadius.lg),
|
||||
borderSide: const BorderSide(color: AppColors.authInputFocus),
|
||||
borderSide: BorderSide(color: colorScheme.primary),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -21,24 +21,26 @@ class AuthPageScaffold extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final keyboardInset = MediaQuery.viewInsetsOf(context).bottom;
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.authBackgroundBottom,
|
||||
backgroundColor: colorScheme.surface,
|
||||
resizeToAvoidBottomInset: resizeOnKeyboard,
|
||||
body: DecoratedBox(
|
||||
decoration: const BoxDecoration(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
AppColors.authBackgroundTop,
|
||||
AppColors.authBackgroundBottom,
|
||||
],
|
||||
colors: [colorScheme.surfaceContainerLow, colorScheme.surface],
|
||||
),
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
const _AuthBackgroundOrbs(),
|
||||
_AuthBackgroundOrbs(
|
||||
topColor: colorScheme.primary.withValues(alpha: 0.2),
|
||||
rightColor: colorScheme.primaryContainer.withValues(alpha: 0.25),
|
||||
bottomColor: colorScheme.tertiaryContainer.withValues(alpha: 0.3),
|
||||
),
|
||||
SafeArea(
|
||||
maintainBottomViewPadding: !resizeOnKeyboard,
|
||||
child: LayoutBuilder(
|
||||
@@ -122,6 +124,8 @@ class AuthHeroHeader extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
@@ -130,12 +134,12 @@ class AuthHeroHeader extends StatelessWidget {
|
||||
width: 88,
|
||||
height: 88,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.appIconRing,
|
||||
color: colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(AppRadius.full),
|
||||
border: Border.all(color: AppColors.appIconBorder),
|
||||
border: Border.all(color: colorScheme.outlineVariant),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.blue300.withValues(alpha: 0.28),
|
||||
color: colorScheme.primary.withValues(alpha: 0.28),
|
||||
blurRadius: 30,
|
||||
offset: const Offset(0, 16),
|
||||
),
|
||||
@@ -154,14 +158,14 @@ class AuthHeroHeader extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
SizedBox(height: AppSpacing.lg),
|
||||
const Text(
|
||||
Text(
|
||||
'linksy',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Playfair Display',
|
||||
fontSize: 34,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: AppColors.appTitle,
|
||||
color: colorScheme.onSurface,
|
||||
letterSpacing: 0.4,
|
||||
),
|
||||
),
|
||||
@@ -171,10 +175,10 @@ class AuthHeroHeader extends StatelessWidget {
|
||||
Text(
|
||||
title!,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppColors.slate900,
|
||||
color: colorScheme.onSurface,
|
||||
letterSpacing: -0.2,
|
||||
),
|
||||
),
|
||||
@@ -184,10 +188,10 @@ class AuthHeroHeader extends StatelessWidget {
|
||||
Text(
|
||||
subtitle!,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
height: 1.45,
|
||||
color: AppColors.authLinkMuted,
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -203,21 +207,23 @@ class AuthSurfaceCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(AppSpacing.xl),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.authCardBackground,
|
||||
color: colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(AppRadius.xxl),
|
||||
border: Border.all(color: AppColors.authCardBorder),
|
||||
border: Border.all(color: colorScheme.outlineVariant),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.blue200.withValues(alpha: 0.18),
|
||||
color: colorScheme.primary.withValues(alpha: 0.12),
|
||||
blurRadius: 34,
|
||||
offset: const Offset(0, 18),
|
||||
),
|
||||
BoxShadow(
|
||||
color: AppColors.slate900.withValues(alpha: 0.06),
|
||||
color: colorScheme.shadow.withValues(alpha: 0.06),
|
||||
blurRadius: 20,
|
||||
offset: const Offset(0, 10),
|
||||
),
|
||||
@@ -242,26 +248,28 @@ class AuthSection extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (title != null) ...[
|
||||
Text(
|
||||
title!,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppColors.slate800,
|
||||
color: colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
if (description != null) ...[
|
||||
SizedBox(height: AppSpacing.xs),
|
||||
Text(
|
||||
description!,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
height: 1.4,
|
||||
color: AppColors.authLinkMuted,
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -274,7 +282,15 @@ class AuthSection extends StatelessWidget {
|
||||
}
|
||||
|
||||
class _AuthBackgroundOrbs extends StatelessWidget {
|
||||
const _AuthBackgroundOrbs();
|
||||
const _AuthBackgroundOrbs({
|
||||
required this.topColor,
|
||||
required this.rightColor,
|
||||
required this.bottomColor,
|
||||
});
|
||||
|
||||
final Color topColor;
|
||||
final Color rightColor;
|
||||
final Color bottomColor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -284,26 +300,17 @@ class _AuthBackgroundOrbs extends StatelessWidget {
|
||||
Positioned(
|
||||
top: -72,
|
||||
left: -38,
|
||||
child: _Orb(
|
||||
size: 168,
|
||||
color: AppColors.authBackgroundOrb.withValues(alpha: 0.42),
|
||||
),
|
||||
child: _Orb(size: 168, color: topColor),
|
||||
),
|
||||
Positioned(
|
||||
top: 108,
|
||||
right: -32,
|
||||
child: _Orb(
|
||||
size: 120,
|
||||
color: AppColors.blue100.withValues(alpha: 0.32),
|
||||
),
|
||||
child: _Orb(size: 120, color: rightColor),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 36,
|
||||
left: 24,
|
||||
child: _Orb(
|
||||
size: 92,
|
||||
color: AppColors.blue50.withValues(alpha: 0.7),
|
||||
),
|
||||
child: _Orb(size: 92, color: bottomColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/l10n/l10n.dart';
|
||||
import '../../../../core/theme/design_tokens.dart';
|
||||
import 'auth_field.dart';
|
||||
|
||||
class PasswordField extends StatefulWidget {
|
||||
@@ -33,6 +32,8 @@ class _PasswordFieldState extends State<PasswordField> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return AuthField(
|
||||
label: widget.label,
|
||||
hint: widget.hint,
|
||||
@@ -46,7 +47,7 @@ class _PasswordFieldState extends State<PasswordField> {
|
||||
: context.l10n.authHidePassword,
|
||||
icon: Icon(
|
||||
_obscured ? Icons.visibility_off_rounded : Icons.visibility_rounded,
|
||||
color: AppColors.authInputIcon,
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user