refactor(client): 库存域颜色迁移到 context.tokens

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-06-24 23:25:34 +08:00
parent fb8c5b6926
commit 2c1e9b3fe8
2 changed files with 129 additions and 130 deletions
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import '../../core/theme/app_theme.dart';
import '../../core/theme/context_tokens.dart';
import '../../models/inventory.dart';
import '../../models/warehouse.dart';
import '../../core/config/app_constants.dart';
@@ -70,7 +70,7 @@ class _InventoryCheckScreenState extends ConsumerState<InventoryCheckScreen> {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('加载库存失败:$e'),
backgroundColor: AppTheme.danger),
backgroundColor: context.tokens.danger),
);
}
}
@@ -107,9 +107,9 @@ class _InventoryCheckScreenState extends ConsumerState<InventoryCheckScreen> {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
SnackBar(
content: Text('盘点单已提交'),
backgroundColor: AppTheme.success,
backgroundColor: context.tokens.success,
),
);
context.go('/inventory');
@@ -119,7 +119,7 @@ class _InventoryCheckScreenState extends ConsumerState<InventoryCheckScreen> {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('提交失败:$e'),
backgroundColor: AppTheme.danger),
backgroundColor: context.tokens.danger),
);
}
} finally {
@@ -138,13 +138,13 @@ class _InventoryCheckScreenState extends ConsumerState<InventoryCheckScreen> {
final asyncWarehouses = ref.watch(warehouseListProvider);
return Scaffold(
backgroundColor: AppTheme.background,
backgroundColor: context.tokens.bg,
body: Column(
children: [
// Header
Container(
height: 52,
color: AppTheme.surface,
color: context.tokens.surface,
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
children: [
@@ -191,11 +191,11 @@ class _InventoryCheckScreenState extends ConsumerState<InventoryCheckScreen> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text('盘点基本信息',
Text('盘点基本信息',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: AppTheme.primaryDark)),
color: context.tokens.primaryDark)),
const SizedBox(height: 16),
Wrap(
spacing: 16,
@@ -219,8 +219,8 @@ class _InventoryCheckScreenState extends ConsumerState<InventoryCheckScreen> {
loading: () =>
const LinearProgressIndicator(),
error: (e, _) => Text('$e',
style: const TextStyle(
color: AppTheme.danger,
style: TextStyle(
color: context.tokens.danger,
fontSize: 12)),
data: (warehouses) =>
DropdownButtonFormField<Warehouse>(
@@ -288,11 +288,11 @@ class _InventoryCheckScreenState extends ConsumerState<InventoryCheckScreen> {
children: [
Row(
children: [
const Text('盘点明细',
Text('盘点明细',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: AppTheme.primaryDark)),
color: context.tokens.primaryDark)),
const SizedBox(width: 12),
if (_checkItems.isNotEmpty)
Container(
@@ -300,27 +300,27 @@ class _InventoryCheckScreenState extends ConsumerState<InventoryCheckScreen> {
horizontal: 8, vertical: 2),
decoration: BoxDecoration(
color:
AppTheme.accent.withOpacity(0.1),
context.tokens.accent.withOpacity(0.1),
borderRadius:
BorderRadius.circular(3),
),
child: Text(
'差异 ${_checkItems.where((i) => _getDiff(i) != 0).length}',
style: const TextStyle(
style: TextStyle(
fontSize: 12,
color: AppTheme.accent),
color: context.tokens.accent),
),
),
],
),
const SizedBox(height: 12),
if (_selectedWarehouse == null)
const Center(
Center(
child: Padding(
padding: EdgeInsets.all(32),
padding: const EdgeInsets.all(32),
child: Text('请先选择盘点仓库',
style: TextStyle(
color: AppTheme.textSecondary)),
color: context.tokens.muted)),
),
)
else if (_loadingItems)
@@ -331,12 +331,12 @@ class _InventoryCheckScreenState extends ConsumerState<InventoryCheckScreen> {
),
)
else if (_checkItems.isEmpty)
const Center(
Center(
child: Padding(
padding: EdgeInsets.all(32),
padding: const EdgeInsets.all(32),
child: Text('该仓库暂无库存记录',
style: TextStyle(
color: AppTheme.textSecondary)),
color: context.tokens.muted)),
),
)
else
@@ -371,12 +371,11 @@ class _InventoryCheckScreenState extends ConsumerState<InventoryCheckScreen> {
horizontal: 8,
vertical: 10),
child: Text(h,
style: const TextStyle(
style: TextStyle(
fontSize: 13,
fontWeight:
FontWeight.w600,
color: AppTheme
.primaryDark)),
color: context.tokens.primaryDark)),
))
.toList(),
),
@@ -394,28 +393,28 @@ class _InventoryCheckScreenState extends ConsumerState<InventoryCheckScreen> {
_SummaryItem(
label: '盘点商品',
value: '${_checkItems.length}',
color: AppTheme.primary,
color: context.tokens.primary,
),
const SizedBox(width: 24),
_SummaryItem(
label: '盘盈',
value:
'${_checkItems.where((i) => _getDiff(i) > 0).length}',
color: AppTheme.success,
color: context.tokens.success,
),
const SizedBox(width: 24),
_SummaryItem(
label: '盘亏',
value:
'${_checkItems.where((i) => _getDiff(i) < 0).length}',
color: AppTheme.danger,
color: context.tokens.danger,
),
const SizedBox(width: 24),
_SummaryItem(
label: '相符',
value:
'${_checkItems.where((i) => _getDiff(i) == 0).length}',
color: AppTheme.textSecondary,
color: context.tokens.muted,
),
],
),
@@ -443,8 +442,8 @@ class _InventoryCheckScreenState extends ConsumerState<InventoryCheckScreen> {
decoration: BoxDecoration(
color: diff != 0
? (diff > 0
? AppTheme.success.withOpacity(0.04)
: AppTheme.danger.withOpacity(0.04))
? context.tokens.success.withOpacity(0.04)
: context.tokens.danger.withOpacity(0.04))
: (index.isEven ? Colors.white : const Color(0xFFFAFAFA)),
),
children: [
@@ -452,17 +451,17 @@ class _InventoryCheckScreenState extends ConsumerState<InventoryCheckScreen> {
padding:
const EdgeInsets.symmetric(horizontal: 8, vertical: 10),
child: Text('${index + 1}',
style: const TextStyle(
fontSize: 13, color: AppTheme.textSecondary)),
style: TextStyle(
fontSize: 13, color: context.tokens.muted)),
),
Padding(
padding:
const EdgeInsets.symmetric(horizontal: 8, vertical: 10),
child: Text(inv.productCode.isEmpty ? '-' : inv.productCode,
style: const TextStyle(
style: TextStyle(
fontFamily: 'monospace',
fontSize: 12,
color: AppTheme.textSecondary)),
color: context.tokens.muted)),
),
Padding(
padding:
@@ -503,8 +502,8 @@ class _InventoryCheckScreenState extends ConsumerState<InventoryCheckScreen> {
fontSize: 13,
fontWeight: FontWeight.w600,
color: diff == 0
? AppTheme.textSecondary
: (diff > 0 ? AppTheme.success : AppTheme.danger),
? context.tokens.muted
: (diff > 0 ? context.tokens.success : context.tokens.danger),
),
),
),
@@ -551,8 +550,8 @@ class _InfoField extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(label,
style: const TextStyle(
fontSize: 13, color: AppTheme.textSecondary)),
style: TextStyle(
fontSize: 13, color: context.tokens.muted)),
const SizedBox(height: 6),
child,
],
@@ -574,8 +573,8 @@ class _SummaryItem extends StatelessWidget {
return Row(
children: [
Text(label,
style: const TextStyle(
fontSize: 13, color: AppTheme.textSecondary)),
style: TextStyle(
fontSize: 13, color: context.tokens.muted)),
const SizedBox(width: 4),
Text(value,
style: TextStyle(