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

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-06-24 23:47:35 +08:00
parent 0c9d7137e3
commit 9709986ff0
2 changed files with 109 additions and 109 deletions
@@ -5,7 +5,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import '../../core/responsive/responsive.dart'; import '../../core/responsive/responsive.dart';
import '../../core/theme/app_theme.dart'; import '../../core/theme/context_tokens.dart';
import '../../core/auth/auth_state.dart'; import '../../core/auth/auth_state.dart';
import '../../core/utils/print_util.dart'; import '../../core/utils/print_util.dart';
import '../../core/utils/date_util.dart'; import '../../core/utils/date_util.dart';
@@ -173,7 +173,7 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
} catch (e) { } catch (e) {
if (mounted) { if (mounted) {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('加载失败:$e'), backgroundColor: AppTheme.danger), SnackBar(content: Text('加载失败:$e'), backgroundColor: context.tokens.danger),
); );
} }
} finally { } finally {
@@ -221,8 +221,8 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
Future<void> _addItem() async { Future<void> _addItem() async {
if (_warehouseId == null) { if (_warehouseId == null) {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
const SnackBar( SnackBar(
content: Text('请先选择出库仓库'), backgroundColor: AppTheme.danger), content: const Text('请先选择出库仓库'), backgroundColor: context.tokens.danger),
); );
return; return;
} }
@@ -265,15 +265,15 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
if (!asDraft && !_formKey.currentState!.validate()) return; if (!asDraft && !_formKey.currentState!.validate()) return;
if (_warehouseId == null) { if (_warehouseId == null) {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
const SnackBar( SnackBar(
content: Text('请选择出库仓库'), backgroundColor: AppTheme.danger), content: const Text('请选择出库仓库'), backgroundColor: context.tokens.danger),
); );
return; return;
} }
if (_items.isEmpty) { if (_items.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
const SnackBar( SnackBar(
content: Text('请添加商品明细'), backgroundColor: AppTheme.danger), content: const Text('请添加商品明细'), backgroundColor: context.tokens.danger),
); );
return; return;
} }
@@ -283,7 +283,7 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
content: Text('${invalidQtyIndex + 1} 行数量必须大于 0'), content: Text('${invalidQtyIndex + 1} 行数量必须大于 0'),
backgroundColor: AppTheme.danger, backgroundColor: context.tokens.danger,
), ),
); );
return; return;
@@ -326,7 +326,7 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
content: Text(asDraft ? '已保存为草稿' : '出库单已提交审核'), content: Text(asDraft ? '已保存为草稿' : '出库单已提交审核'),
backgroundColor: AppTheme.success, backgroundColor: context.tokens.success,
), ),
); );
context.go('/stock-out'); context.go('/stock-out');
@@ -334,7 +334,7 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
} catch (e) { } catch (e) {
if (mounted) { if (mounted) {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('操作失败:$e'), backgroundColor: AppTheme.danger), SnackBar(content: Text('操作失败:$e'), backgroundColor: context.tokens.danger),
); );
} }
} finally { } finally {
@@ -372,7 +372,7 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
), ),
TextButton( TextButton(
onPressed: () => Navigator.of(ctx).pop('discard'), onPressed: () => Navigator.of(ctx).pop('discard'),
child: const Text('放弃', style: TextStyle(color: AppTheme.danger)), child: Text('放弃', style: TextStyle(color: ctx.tokens.danger)),
), ),
ElevatedButton( ElevatedButton(
onPressed: () => Navigator.of(ctx).pop('draft'), onPressed: () => Navigator.of(ctx).pop('draft'),
@@ -401,12 +401,12 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
if (!didPop) _handleExit(); if (!didPop) _handleExit();
}, },
child: Scaffold( child: Scaffold(
backgroundColor: AppTheme.background, backgroundColor: context.tokens.bg,
body: Column( body: Column(
children: [ children: [
Container( Container(
height: 52, height: 52,
color: AppTheme.surface, color: context.tokens.surface,
padding: const EdgeInsets.symmetric(horizontal: 16), padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row( child: Row(
children: [ children: [
@@ -508,11 +508,11 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
const Text('基本信息', Text('基本信息',
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: AppTheme.primaryDark)), color: context.tokens.primaryDark)),
const SizedBox(height: 16), const SizedBox(height: 16),
Wrap( Wrap(
spacing: 16, spacing: 16,
@@ -628,11 +628,11 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
children: [ children: [
Row( Row(
children: [ children: [
const Text('商品明细', Text('商品明细',
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: AppTheme.primaryDark)), color: context.tokens.primaryDark)),
const Spacer(), const Spacer(),
ElevatedButton.icon( ElevatedButton.icon(
onPressed: _addItem, onPressed: _addItem,
@@ -691,12 +691,12 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
horizontal: 8, horizontal: 8,
vertical: 10), vertical: 10),
child: Text(h, child: Text(h,
style: const TextStyle( style: TextStyle(
fontSize: 13, fontSize: 13,
fontWeight: fontWeight:
FontWeight.w600, FontWeight.w600,
color: AppTheme color: context
.primaryDark)), .tokens.primaryDark)),
)) ))
.toList(), .toList(),
), ),
@@ -705,12 +705,12 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
], ],
), ),
if (_items.isEmpty) if (_items.isEmpty)
const Padding( Padding(
padding: EdgeInsets.symmetric(vertical: 24), padding: const EdgeInsets.symmetric(vertical: 24),
child: Center( child: Center(
child: Text('暂无商品,点击"添加商品"从库存中选择', child: Text('暂无商品,点击"添加商品"从库存中选择',
style: TextStyle( style: TextStyle(
color: AppTheme.textSecondary, color: context.tokens.muted,
fontSize: 13))), fontSize: 13))),
), ),
const Divider(height: 1), const Divider(height: 1),
@@ -725,10 +725,10 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
fontWeight: FontWeight.w500)), fontWeight: FontWeight.w500)),
Text( Text(
'¥${_totalAmount.toStringAsFixed(2)}', '¥${_totalAmount.toStringAsFixed(2)}',
style: const TextStyle( style: TextStyle(
fontSize: 18, fontSize: 18,
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
color: AppTheme.danger), color: context.tokens.danger),
), ),
], ],
), ),
@@ -763,11 +763,11 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
// 序号 // 序号
_cell(Text('${index + 1}', _cell(Text('${index + 1}',
style: style:
const TextStyle(fontSize: 13, color: AppTheme.textSecondary))), TextStyle(fontSize: 13, color: context.tokens.muted))),
// 商品编码 // 商品编码
_cell(Text(item.productCode, _cell(Text(item.productCode,
style: style:
const TextStyle(fontSize: 12, color: AppTheme.textSecondary))), TextStyle(fontSize: 12, color: context.tokens.muted))),
// 商品名称 // 商品名称
_cell(Text(item.productName, _cell(Text(item.productName,
style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w500), style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w500),
@@ -775,15 +775,15 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
// 系列 // 系列
_cell(Text(item.series, _cell(Text(item.series,
style: style:
const TextStyle(fontSize: 12, color: AppTheme.textSecondary))), TextStyle(fontSize: 12, color: context.tokens.muted))),
// 规格 // 规格
_cell(Text(item.spec, _cell(Text(item.spec,
style: style:
const TextStyle(fontSize: 12, color: AppTheme.textSecondary))), TextStyle(fontSize: 12, color: context.tokens.muted))),
// 成本价 // 成本价
_cell(Text(price > 0 ? '¥${price.toStringAsFixed(2)}' : '-', _cell(Text(price > 0 ? '¥${price.toStringAsFixed(2)}' : '-',
style: const TextStyle( style: TextStyle(
fontSize: 13, color: AppTheme.textSecondary))), fontSize: 13, color: context.tokens.muted))),
// 售价(可编辑) // 售价(可编辑)
Padding( Padding(
padding: const EdgeInsets.all(4), child: _salePriceField(item)), padding: const EdgeInsets.all(4), child: _salePriceField(item)),
@@ -796,8 +796,8 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 4), padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 4),
child: IconButton( child: IconButton(
icon: const Icon(Icons.delete_outline, icon: Icon(Icons.delete_outline,
size: 18, color: AppTheme.danger), size: 18, color: context.tokens.danger),
onPressed: () => _removeItem(index), onPressed: () => _removeItem(index),
tooltip: '删除', tooltip: '删除',
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
@@ -854,7 +854,7 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
item.productCode.isNotEmpty ? Text('编码 ${item.productCode}') : null, item.productCode.isNotEmpty ? Text('编码 ${item.productCode}') : null,
trailing: IconButton( trailing: IconButton(
icon: icon:
const Icon(Icons.delete_outline, size: 20, color: AppTheme.danger), Icon(Icons.delete_outline, size: 20, color: context.tokens.danger),
onPressed: () => _removeItem(index), onPressed: () => _removeItem(index),
tooltip: '删除', tooltip: '删除',
visualDensity: VisualDensity.compact, visualDensity: VisualDensity.compact,
@@ -878,18 +878,18 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
Widget _buildInventoryCell(int? productId, [double? available]) { Widget _buildInventoryCell(int? productId, [double? available]) {
if (productId == null) { if (productId == null) {
return _cell(const Text('-', return _cell(Text('-',
style: TextStyle(color: AppTheme.textSecondary, fontSize: 13))); style: TextStyle(color: context.tokens.muted, fontSize: 13)));
} }
final qty = available ?? _inventoryMap[productId]; final qty = available ?? _inventoryMap[productId];
final text = qty != null final text = qty != null
? qty.toStringAsFixed(0) ? qty.toStringAsFixed(0)
: (_warehouseId == null ? '选仓库后显示' : '-'); : (_warehouseId == null ? '选仓库后显示' : '-');
final color = qty == null final color = qty == null
? AppTheme.textSecondary ? context.tokens.muted
: qty <= 0 : qty <= 0
? AppTheme.danger ? context.tokens.danger
: AppTheme.primary; : context.tokens.primary;
return _cell(Text(text, return _cell(Text(text,
style: TextStyle( style: TextStyle(
fontSize: 13, fontWeight: FontWeight.w700, color: color))); fontSize: 13, fontWeight: FontWeight.w700, color: color)));
@@ -923,11 +923,11 @@ class _FormField extends StatelessWidget {
Row( Row(
children: [ children: [
if (required) if (required)
const Text('*', Text('*',
style: TextStyle(color: AppTheme.danger, fontSize: 13)), style: TextStyle(color: context.tokens.danger, fontSize: 13)),
Text(label, Text(label,
style: const TextStyle( style: TextStyle(
fontSize: 13, color: AppTheme.textSecondary)), fontSize: 13, color: context.tokens.muted)),
], ],
), ),
const SizedBox(height: 6), const SizedBox(height: 6),
@@ -1050,8 +1050,8 @@ class _InventoryPickerDialogState
TextStyle(fontSize: 15, fontWeight: FontWeight.w600)), TextStyle(fontSize: 15, fontWeight: FontWeight.w600)),
const SizedBox(width: 8), const SizedBox(width: 8),
Text('已选 ${_selected.length}', Text('已选 ${_selected.length}',
style: const TextStyle( style: TextStyle(
fontSize: 13, color: AppTheme.textSecondary)), fontSize: 13, color: context.tokens.muted)),
const Spacer(), const Spacer(),
IconButton( IconButton(
icon: const Icon(Icons.close, size: 20), icon: const Icon(Icons.close, size: 20),
@@ -1109,9 +1109,9 @@ class _InventoryPickerDialogState
// List // List
Expanded( Expanded(
child: filtered.isEmpty child: filtered.isEmpty
? const Center( ? Center(
child: Text('没有匹配的商品', child: Text('没有匹配的商品',
style: TextStyle(color: AppTheme.textSecondary)), style: TextStyle(color: context.tokens.muted)),
) )
: ListView.separated( : ListView.separated(
itemCount: filtered.length, itemCount: filtered.length,
@@ -1147,12 +1147,12 @@ class _InventoryPickerDialogState
), ),
), ),
_dataCell(item.productCode, 110, _dataCell(item.productCode, 110,
color: AppTheme.textSecondary), color: context.tokens.muted),
_dataCell(item.productName, 200, bold: true), _dataCell(item.productName, 200, bold: true),
_dataCell(item.series, 110, _dataCell(item.series, 110,
color: AppTheme.textSecondary), color: context.tokens.muted),
_dataCell(item.spec, 130, _dataCell(item.spec, 130,
color: AppTheme.textSecondary), color: context.tokens.muted),
_dataCell( _dataCell(
item.unitPrice != null item.unitPrice != null
? '¥${item.unitPrice!.toStringAsFixed(2)}' ? '¥${item.unitPrice!.toStringAsFixed(2)}'
@@ -1163,8 +1163,8 @@ class _InventoryPickerDialogState
item.availableQty.toStringAsFixed(0), item.availableQty.toStringAsFixed(0),
90, 90,
color: item.availableQty <= 0 color: item.availableQty <= 0
? AppTheme.danger ? context.tokens.danger
: AppTheme.primary, : context.tokens.primary,
bold: true, bold: true,
), ),
], ],
@@ -1196,8 +1196,8 @@ class _InventoryPickerDialogState
// 库存总数汇总(无搜索=整仓总数,搜索时=匹配总数) // 库存总数汇总(无搜索=整仓总数,搜索时=匹配总数)
Text( Text(
_loading ? '加载中…' : '$_total 项库存商品', _loading ? '加载中…' : '$_total 项库存商品',
style: const TextStyle( style: TextStyle(
fontSize: 13, color: AppTheme.textSecondary), fontSize: 13, color: context.tokens.muted),
), ),
const SizedBox(width: 12), const SizedBox(width: 12),
// 翻页 // 翻页
@@ -1255,10 +1255,10 @@ class _InventoryPickerDialogState
Widget _headerCell(String text, double width) => SizedBox( Widget _headerCell(String text, double width) => SizedBox(
width: width, width: width,
child: Text(text, child: Text(text,
style: const TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: AppTheme.primaryDark)), color: context.tokens.primaryDark)),
); );
Widget _dataCell(String text, double width, Widget _dataCell(String text, double width,
@@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import '../../core/responsive/responsive.dart'; import '../../core/responsive/responsive.dart';
import '../../core/theme/app_theme.dart'; import '../../core/theme/context_tokens.dart';
import '../../models/stock_out.dart'; import '../../models/stock_out.dart';
import '../../providers/stock_out_provider.dart'; import '../../providers/stock_out_provider.dart';
import '../../repositories/stock_out_repository.dart'; import '../../repositories/stock_out_repository.dart';
@@ -158,10 +158,10 @@ class _StockOutListScreenState extends ConsumerState<StockOutListScreen> {
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
const Icon(Icons.cloud_off, size: 40, color: AppTheme.textSecondary), Icon(Icons.cloud_off, size: 40, color: context.tokens.muted),
const SizedBox(height: 12), const SizedBox(height: 12),
const Text('暂无数据,网络不可用', Text('暂无数据,网络不可用',
style: const TextStyle(color: AppTheme.textSecondary)), style: TextStyle(color: context.tokens.muted)),
const SizedBox(height: 12), const SizedBox(height: 12),
ElevatedButton( ElevatedButton(
onPressed: () => onPressed: () =>
@@ -277,8 +277,8 @@ class _StockOutListScreenState extends ConsumerState<StockOutListScreen> {
return DataCell(GestureDetector( return DataCell(GestureDetector(
onTap: () => _showDetail(context, o.id), onTap: () => _showDetail(context, o.id),
child: Text(o.orderNo, child: Text(o.orderNo,
style: const TextStyle( style: TextStyle(
color: AppTheme.primary, color: context.tokens.primary,
fontFamily: 'monospace', fontFamily: 'monospace',
fontSize: 12, fontSize: 12,
decoration: TextDecoration.underline)), decoration: TextDecoration.underline)),
@@ -330,8 +330,8 @@ class _StockOutListScreenState extends ConsumerState<StockOutListScreen> {
cells: List.generate( cells: List.generate(
visibleCols.length, visibleCols.length,
(i) => i == 0 (i) => i == 0
? const DataCell(Text('暂无出库单', ? DataCell(Text('暂无出库单',
style: TextStyle(color: AppTheme.textSecondary))) style: TextStyle(color: context.tokens.muted)))
: const DataCell(SizedBox()), : const DataCell(SizedBox()),
), ),
), ),
@@ -640,7 +640,7 @@ class _StockOutListScreenState extends ConsumerState<StockOutListScreen> {
TextButton(onPressed: () => Navigator.pop(ctx, false), child: const Text('取消')), TextButton(onPressed: () => Navigator.pop(ctx, false), child: const Text('取消')),
TextButton( TextButton(
onPressed: () => Navigator.pop(ctx, true), onPressed: () => Navigator.pop(ctx, true),
child: const Text('确认结清', style: TextStyle(color: AppTheme.accent)), child: Text('确认结清', style: TextStyle(color: context.tokens.accent)),
), ),
], ],
), ),
@@ -650,13 +650,13 @@ class _StockOutListScreenState extends ConsumerState<StockOutListScreen> {
await ref.read(financeRepositoryProvider).closeByRef(refType, orderId); await ref.read(financeRepositoryProvider).closeByRef(refType, orderId);
if (context.mounted) { if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('已结清'), backgroundColor: AppTheme.success), SnackBar(content: const Text('已结清'), backgroundColor: context.tokens.success),
); );
} }
} catch (e) { } catch (e) {
if (context.mounted) { if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(e.toString()), backgroundColor: AppTheme.danger), SnackBar(content: Text(e.toString()), backgroundColor: context.tokens.danger),
); );
} }
} }
@@ -675,7 +675,7 @@ class _StockOutListScreenState extends ConsumerState<StockOutListScreen> {
ElevatedButton( ElevatedButton(
onPressed: () => Navigator.of(ctx).pop(true), onPressed: () => Navigator.of(ctx).pop(true),
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: AppTheme.danger, backgroundColor: context.tokens.danger,
foregroundColor: Colors.white), foregroundColor: Colors.white),
child: const Text('删除'), child: const Text('删除'),
), ),
@@ -686,14 +686,14 @@ class _StockOutListScreenState extends ConsumerState<StockOutListScreen> {
try { try {
await ref.read(stockOutListProvider.notifier).deleteOrder(o.id); await ref.read(stockOutListProvider.notifier).deleteOrder(o.id);
if (mounted) { if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('已删除'), backgroundColor: AppTheme.success)); content: const Text('已删除'), backgroundColor: context.tokens.success));
} }
} catch (e) { } catch (e) {
if (mounted) { if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('删除失败:$e'), content: Text('删除失败:$e'),
backgroundColor: AppTheme.danger)); backgroundColor: context.tokens.danger));
} }
} }
} }
@@ -722,15 +722,15 @@ class _StockOutListScreenState extends ConsumerState<StockOutListScreen> {
.read(stockOutListProvider.notifier) .read(stockOutListProvider.notifier)
.submitOrder(o.id); .submitOrder(o.id);
if (mounted) { if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('已提交审核'), content: const Text('已提交审核'),
backgroundColor: AppTheme.success)); backgroundColor: context.tokens.success));
} }
} catch (e) { } catch (e) {
if (mounted) { if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('提交失败:$e'), content: Text('提交失败:$e'),
backgroundColor: AppTheme.danger)); backgroundColor: context.tokens.danger));
} }
} }
} }
@@ -750,7 +750,7 @@ class _StockOutListScreenState extends ConsumerState<StockOutListScreen> {
ElevatedButton( ElevatedButton(
onPressed: () => Navigator.of(ctx).pop(true), onPressed: () => Navigator.of(ctx).pop(true),
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: AppTheme.success, backgroundColor: context.tokens.success,
foregroundColor: Colors.white), foregroundColor: Colors.white),
child: const Text('通过'), child: const Text('通过'),
), ),
@@ -763,14 +763,14 @@ class _StockOutListScreenState extends ConsumerState<StockOutListScreen> {
.read(stockOutListProvider.notifier) .read(stockOutListProvider.notifier)
.approveOrder(o.id); .approveOrder(o.id);
if (mounted) { if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('审核通过'), backgroundColor: AppTheme.success)); content: const Text('审核通过'), backgroundColor: context.tokens.success));
} }
} catch (e) { } catch (e) {
if (mounted) { if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('审核失败:$e'), content: Text('审核失败:$e'),
backgroundColor: AppTheme.danger, backgroundColor: context.tokens.danger,
duration: const Duration(seconds: 5))); duration: const Duration(seconds: 5)));
} }
} }
@@ -791,7 +791,7 @@ class _StockOutListScreenState extends ConsumerState<StockOutListScreen> {
ElevatedButton( ElevatedButton(
onPressed: () => Navigator.of(ctx).pop(true), onPressed: () => Navigator.of(ctx).pop(true),
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: AppTheme.danger, backgroundColor: context.tokens.danger,
foregroundColor: Colors.white), foregroundColor: Colors.white),
child: const Text('拒绝'), child: const Text('拒绝'),
), ),
@@ -802,14 +802,14 @@ class _StockOutListScreenState extends ConsumerState<StockOutListScreen> {
try { try {
await ref.read(stockOutListProvider.notifier).rejectOrder(o.id); await ref.read(stockOutListProvider.notifier).rejectOrder(o.id);
if (mounted) { if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('已拒绝'), backgroundColor: AppTheme.accent)); content: const Text('已拒绝'), backgroundColor: context.tokens.accent));
} }
} catch (e) { } catch (e) {
if (mounted) { if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('操作失败:$e'), content: Text('操作失败:$e'),
backgroundColor: AppTheme.danger)); backgroundColor: context.tokens.danger));
} }
} }
} }
@@ -829,7 +829,7 @@ class _StockOutListScreenState extends ConsumerState<StockOutListScreen> {
ElevatedButton( ElevatedButton(
onPressed: () => Navigator.of(ctx).pop(true), onPressed: () => Navigator.of(ctx).pop(true),
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: AppTheme.accent, backgroundColor: context.tokens.accent,
foregroundColor: Colors.white), foregroundColor: Colors.white),
child: const Text('撤回'), child: const Text('撤回'),
), ),
@@ -840,14 +840,14 @@ class _StockOutListScreenState extends ConsumerState<StockOutListScreen> {
try { try {
await ref.read(stockOutListProvider.notifier).withdrawOrder(o.id); await ref.read(stockOutListProvider.notifier).withdrawOrder(o.id);
if (mounted) { if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('已撤回为草稿'), backgroundColor: AppTheme.accent)); content: const Text('已撤回为草稿'), backgroundColor: context.tokens.accent));
} }
} catch (e) { } catch (e) {
if (mounted) { if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('撤回失败:$e'), content: Text('撤回失败:$e'),
backgroundColor: AppTheme.danger)); backgroundColor: context.tokens.danger));
} }
} }
} }
@@ -866,7 +866,7 @@ class _StockOutListScreenState extends ConsumerState<StockOutListScreen> {
ElevatedButton( ElevatedButton(
onPressed: () => Navigator.of(ctx).pop(true), onPressed: () => Navigator.of(ctx).pop(true),
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: AppTheme.danger, foregroundColor: Colors.white), backgroundColor: context.tokens.danger, foregroundColor: Colors.white),
child: const Text('确认'), child: const Text('确认'),
), ),
], ],
@@ -879,7 +879,7 @@ class _StockOutListScreenState extends ConsumerState<StockOutListScreen> {
} catch (e) { } catch (e) {
if (mounted) { if (mounted) {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('加载明细失败:$e'), backgroundColor: AppTheme.danger)); SnackBar(content: Text('加载明细失败:$e'), backgroundColor: context.tokens.danger));
} }
return; return;
} }
@@ -967,9 +967,9 @@ class _StockOutDetailDialogState extends ConsumerState<_StockOutDetailDialog> {
children: [ children: [
Container( Container(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14), padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14),
decoration: const BoxDecoration( decoration: BoxDecoration(
color: AppTheme.primary, color: context.tokens.primary,
borderRadius: BorderRadius.only( borderRadius: const BorderRadius.only(
topLeft: Radius.circular(12), topLeft: Radius.circular(12),
topRight: Radius.circular(12), topRight: Radius.circular(12),
), ),
@@ -1003,14 +1003,14 @@ class _StockOutDetailDialogState extends ConsumerState<_StockOutDetailDialog> {
return const Center(child: CircularProgressIndicator()); return const Center(child: CircularProgressIndicator());
} }
if (snap.hasError) { if (snap.hasError) {
return const Center( return Center(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Icon(Icons.cloud_off, size: 40, color: AppTheme.textSecondary), Icon(Icons.cloud_off, size: 40, color: context.tokens.muted),
SizedBox(height: 12), const SizedBox(height: 12),
Text('暂无数据,网络不可用', Text('暂无数据,网络不可用',
style: TextStyle(color: AppTheme.textSecondary)), style: TextStyle(color: context.tokens.muted)),
], ],
), ),
); );
@@ -1047,18 +1047,18 @@ class _StockOutDetailDialogState extends ConsumerState<_StockOutDetailDialog> {
], ],
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
const Text('商品明细', Text('商品明细',
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: AppTheme.primaryDark)), color: context.tokens.primaryDark)),
const SizedBox(height: 8), const SizedBox(height: 8),
if (o.items.isEmpty) if (o.items.isEmpty)
const Text('无商品明细', Text('无商品明细',
style: TextStyle(color: AppTheme.textSecondary)) style: TextStyle(color: context.tokens.muted))
else else
Table( Table(
border: TableBorder.all(color: AppTheme.border, width: 0.5), border: TableBorder.all(color: context.tokens.border, width: 0.5),
columnWidths: const { columnWidths: const {
0: FixedColumnWidth(36), 0: FixedColumnWidth(36),
1: FlexColumnWidth(1.2), 1: FlexColumnWidth(1.2),
@@ -1078,10 +1078,10 @@ class _StockOutDetailDialogState extends ConsumerState<_StockOutDetailDialog> {
.map((h) => Padding( .map((h) => Padding(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 10), padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 10),
child: Text(h, child: Text(h,
style: const TextStyle( style: TextStyle(
fontSize: 13, fontSize: 13,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: AppTheme.primaryDark)), color: context.tokens.primaryDark)),
)) ))
.toList(), .toList(),
), ),
@@ -1144,8 +1144,8 @@ class _InfoField extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text(label, Text(label,
style: const TextStyle( style: TextStyle(
fontSize: 12, color: AppTheme.textSecondary)), fontSize: 12, color: context.tokens.muted)),
const SizedBox(height: 2), const SizedBox(height: 2),
Text(value, Text(value,
style: const TextStyle( style: const TextStyle(
@@ -1184,9 +1184,9 @@ class _StatusFilterDropdown extends StatelessWidget {
height: 36, height: 36,
padding: const EdgeInsets.symmetric(horizontal: 8), padding: const EdgeInsets.symmetric(horizontal: 8),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all(color: AppTheme.border), border: Border.all(color: context.tokens.border),
borderRadius: BorderRadius.circular(4), borderRadius: BorderRadius.circular(4),
color: AppTheme.surface, color: context.tokens.surface,
), ),
child: DropdownButtonHideUnderline( child: DropdownButtonHideUnderline(
child: DropdownButton<String>( child: DropdownButton<String>(
@@ -1199,7 +1199,7 @@ class _StatusFilterDropdown extends StatelessWidget {
DropdownMenuItem(value: 'rejected', child: Text('已拒绝', style: TextStyle(fontSize: 13))), DropdownMenuItem(value: 'rejected', child: Text('已拒绝', style: TextStyle(fontSize: 13))),
], ],
onChanged: onChanged, onChanged: onChanged,
style: const TextStyle(fontSize: 13, color: AppTheme.textPrimary), style: TextStyle(fontSize: 13, color: context.tokens.text),
), ),
), ),
); );