diff --git a/lib/features/profile/presentation/profile_action_pages.dart b/lib/features/profile/presentation/profile_action_pages.dart index 64454ce..2a9d363 100644 --- a/lib/features/profile/presentation/profile_action_pages.dart +++ b/lib/features/profile/presentation/profile_action_pages.dart @@ -334,10 +334,8 @@ class RecycleDiscountPage extends ConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final settings = ref.watch(profileSettingsControllerProvider); final notifier = ref.read(profileSettingsControllerProvider.notifier); - final gold = settings.recycleDiscounts[MetalType.gold] ?? 0.97; - final platinum = settings.recycleDiscounts[MetalType.platinum] ?? 0.93; - final silver = settings.recycleDiscounts[MetalType.silver] ?? 0.88; - final preview = 483812.0 * gold; + final discount = settings.recycleDiscounts[MetalType.gold] ?? 0.97; + final preview = 483812.0 * discount; return _ActionScaffold( title: '回收折扣设置', @@ -345,87 +343,122 @@ class RecycleDiscountPage extends ConsumerWidget { crossAxisAlignment: CrossAxisAlignment.stretch, children: [ PrototypeCard( - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - const SizedBox(height: 2), - Row( - children: [ - const Text( - '回收参考预览', - style: TextStyle(fontSize: 13, color: Color(0xFF8A8780)), - ), - const Spacer(), - 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( + 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( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Row( 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 Text( + '回收折扣系数', + style: TextStyle( + fontSize: 14, + color: Color(0xFF8A8780), ), ), - const SizedBox(height: 4), - const PrototypeDivider(margin: EdgeInsets.zero), - _DiscountSliderRow( - metal: MetalType.silver, - value: silver, - onChanged: (value) => notifier.setRecycleDiscount( - MetalType.silver, - value, + const Spacer(), + Text( + '${(discount * 100).round()}%', + style: const TextStyle( + fontSize: 34, + fontWeight: FontWeight.w700, + height: 1, + color: Color(0xFFB5862A), ), ), ], ), - ), - const SizedBox(height: 8), - const Text( - '回收参考价 = 材料价值 × 折扣系数,恒标「参考」。同一系数也用于「兑换试算」的回收口径。', - style: TextStyle( - fontSize: 12, - height: 1.6, - color: Color(0xFF8A8780), + 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 SizedBox(height: 4), - const Text( - '实务中不同金属折扣不同(足金≈95%、铂金≈78%、白银更低)。', - style: TextStyle( - fontSize: 11, - height: 1.6, - color: Color(0xFFB3AFA5), + 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( + 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 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 { const _ColorModeTile({ required this.title,