fix:折扣设置页
This commit is contained in:
@@ -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,69 +343,107 @@ class RecycleDiscountPage extends ConsumerWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
PrototypeCard(
|
PrototypeCard(
|
||||||
|
padding: const EdgeInsets.all(14),
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 16, 16, 16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: const Color(0xFFF8F7F3),
|
||||||
|
borderRadius: BorderRadius.circular(18),
|
||||||
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 2),
|
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
const Text(
|
||||||
'回收参考预览',
|
'回收折扣系数',
|
||||||
style: TextStyle(fontSize: 13, color: Color(0xFF8A8780)),
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: Color(0xFF8A8780),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
|
Text(
|
||||||
|
'${(discount * 100).round()}%',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 34,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
height: 1,
|
||||||
|
color: Color(0xFFB5862A),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
Slider(
|
||||||
|
min: 0.8,
|
||||||
|
max: 1.0,
|
||||||
|
divisions: 20,
|
||||||
|
value: discount.clamp(0.8, 1.0),
|
||||||
|
activeColor: const Color(0xFFB5862A),
|
||||||
|
inactiveColor: const Color(0xFFE2DED3),
|
||||||
|
onChanged: (value) {
|
||||||
|
for (final metal in MetalType.values) {
|
||||||
|
notifier.setRecycleDiscount(metal, value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'80%',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
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(
|
Text(
|
||||||
formatCny(preview),
|
formatCny(preview),
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 28,
|
fontSize: 30,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
height: 1,
|
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: [
|
|
||||||
_DiscountSliderRow(
|
|
||||||
metal: MetalType.gold,
|
|
||||||
value: gold,
|
|
||||||
onChanged: (value) =>
|
|
||||||
notifier.setRecycleDiscount(MetalType.gold, value),
|
|
||||||
),
|
|
||||||
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 PrototypeDivider(margin: EdgeInsets.zero),
|
|
||||||
_DiscountSliderRow(
|
|
||||||
metal: MetalType.silver,
|
|
||||||
value: silver,
|
|
||||||
onChanged: (value) => notifier.setRecycleDiscount(
|
|
||||||
MetalType.silver,
|
|
||||||
value,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
),
|
||||||
|
const SizedBox(height: 14),
|
||||||
const Text(
|
const Text(
|
||||||
'回收参考价 = 材料价值 × 折扣系数,恒标「参考」。同一系数也用于「兑换试算」的回收口径。',
|
'回收参考价 = 材料价值 × 折扣系数,恒标「参考」。同一系数也用于「兑换试算」的回收口径。',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
@@ -427,9 +463,6 @@ class RecycleDiscountPage extends ConsumerWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user