fix:折扣设置页

This commit is contained in:
jingyun
2026-06-18 18:22:49 +08:00
parent 2d7523f901
commit 975f115859
@@ -334,10 +334,8 @@ class RecycleDiscountPage extends ConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
final settings = ref.watch(profileSettingsControllerProvider); final settings = ref.watch(profileSettingsControllerProvider);
final notifier = ref.read(profileSettingsControllerProvider.notifier); final notifier = ref.read(profileSettingsControllerProvider.notifier);
final gold = settings.recycleDiscounts[MetalType.gold] ?? 0.97; final discount = settings.recycleDiscounts[MetalType.gold] ?? 0.97;
final platinum = settings.recycleDiscounts[MetalType.platinum] ?? 0.93; final preview = 483812.0 * discount;
final silver = settings.recycleDiscounts[MetalType.silver] ?? 0.88;
final preview = 483812.0 * gold;
return _ActionScaffold( return _ActionScaffold(
title: '回收折扣设置', title: '回收折扣设置',
@@ -345,87 +343,122 @@ class RecycleDiscountPage extends ConsumerWidget {
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
PrototypeCard( PrototypeCard(
child: Column( padding: const EdgeInsets.all(14),
crossAxisAlignment: CrossAxisAlignment.stretch, child: Container(
children: [ padding: const EdgeInsets.fromLTRB(16, 16, 16, 16),
const SizedBox(height: 2), decoration: BoxDecoration(
Row( color: const Color(0xFFF8F7F3),
children: [ borderRadius: BorderRadius.circular(18),
const Text( ),
'回收参考预览', child: Column(
style: TextStyle(fontSize: 13, color: Color(0xFF8A8780)), crossAxisAlignment: CrossAxisAlignment.stretch,
), children: [
const Spacer(), Row(
Text(
formatCny(preview),
style: const TextStyle(
fontSize: 28,
fontWeight: FontWeight.w700,
height: 1,
),
),
],
),
const SizedBox(height: 8),
Container(
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 16,
),
decoration: BoxDecoration(
color: const Color(0xFFF8F7F3),
borderRadius: BorderRadius.circular(14),
),
child: Column(
children: [ children: [
_DiscountSliderRow( const Text(
metal: MetalType.gold, '回收折扣系数',
value: gold, style: TextStyle(
onChanged: (value) => fontSize: 14,
notifier.setRecycleDiscount(MetalType.gold, value), color: Color(0xFF8A8780),
),
const SizedBox(height: 4),
const PrototypeDivider(margin: EdgeInsets.zero),
_DiscountSliderRow(
metal: MetalType.platinum,
value: platinum,
onChanged: (value) => notifier.setRecycleDiscount(
MetalType.platinum,
value,
), ),
), ),
const SizedBox(height: 4), const Spacer(),
const PrototypeDivider(margin: EdgeInsets.zero), Text(
_DiscountSliderRow( '${(discount * 100).round()}%',
metal: MetalType.silver, style: const TextStyle(
value: silver, fontSize: 34,
onChanged: (value) => notifier.setRecycleDiscount( fontWeight: FontWeight.w700,
MetalType.silver, height: 1,
value, color: Color(0xFFB5862A),
), ),
), ),
], ],
), ),
), const SizedBox(height: 14),
const SizedBox(height: 8), Slider(
const Text( min: 0.8,
'回收参考价 = 材料价值 × 折扣系数,恒标「参考」。同一系数也用于「兑换试算」的回收口径。', max: 1.0,
style: TextStyle( divisions: 20,
fontSize: 12, value: discount.clamp(0.8, 1.0),
height: 1.6, activeColor: const Color(0xFFB5862A),
color: Color(0xFF8A8780), inactiveColor: const Color(0xFFE2DED3),
onChanged: (value) {
for (final metal in MetalType.values) {
notifier.setRecycleDiscount(metal, value);
}
},
), ),
), const Row(
const SizedBox(height: 4), mainAxisAlignment: MainAxisAlignment.spaceBetween,
const Text( children: [
'实务中不同金属折扣不同(足金≈95%、铂金≈78%、白银更低)。', Text(
style: TextStyle( '80%',
fontSize: 11, style: TextStyle(
height: 1.6, fontSize: 13,
color: Color(0xFFB3AFA5), color: Color(0xFFB3AFA5),
),
),
Text(
'100%',
style: TextStyle(
fontSize: 13,
color: Color(0xFFB3AFA5),
),
),
],
), ),
), const SizedBox(height: 14),
], Container(
padding: const EdgeInsets.symmetric(
horizontal: 18,
vertical: 16,
),
decoration: BoxDecoration(
color: const Color(0xFFF1EEE6),
borderRadius: BorderRadius.circular(18),
),
child: Row(
children: [
const Expanded(
child: Text(
'当前总回收参考',
style: TextStyle(
fontSize: 13,
color: Color(0xFF8A8780),
),
),
),
Text(
formatCny(preview),
style: const TextStyle(
fontSize: 30,
fontWeight: FontWeight.w700,
height: 1,
),
),
],
),
),
],
),
),
),
const SizedBox(height: 14),
const Text(
'回收参考价 = 材料价值 × 折扣系数,恒标「参考」。同一系数也用于「兑换试算」的回收口径。',
style: TextStyle(
fontSize: 12,
height: 1.6,
color: Color(0xFF8A8780),
),
),
const SizedBox(height: 4),
const Text(
'实务中不同金属折扣不同(足金≈95%、铂金≈78%、白银更低)。',
style: TextStyle(
fontSize: 11,
height: 1.6,
color: Color(0xFFB3AFA5),
), ),
), ),
], ],
@@ -1025,67 +1058,6 @@ class _MiniSquare extends StatelessWidget {
} }
} }
class _DiscountSliderRow extends StatelessWidget {
const _DiscountSliderRow({
required this.metal,
required this.value,
required this.onChanged,
});
final MetalType metal;
final double value;
final ValueChanged<double> onChanged;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 10),
child: Column(
children: [
Row(
children: [
Container(
width: 8,
height: 8,
decoration: BoxDecoration(
color: metal.color,
shape: BoxShape.circle,
),
),
const SizedBox(width: 8),
Expanded(
child: Text(
metal.label,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
),
),
),
Text(
'${(value * 100).round()}%',
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w700,
),
),
],
),
Slider(
min: 0.7,
max: 1.0,
divisions: 30,
value: value.clamp(0.7, 1.0),
activeColor: const Color(0xFFB5862A),
inactiveColor: const Color(0xFFECEAE3),
onChanged: onChanged,
),
],
),
);
}
}
class _ColorModeTile extends StatelessWidget { class _ColorModeTile extends StatelessWidget {
const _ColorModeTile({ const _ColorModeTile({
required this.title, required this.title,