Commit 58c3551b4e1c96ac11dacc70941e266b9e4767c3

Authored by 吴启风
1 parent 5bc84eff

feat: 隐藏微信支付选项并保留可见性开关

lib/pages/shopping/bloc.dart
@@ -15,13 +15,17 @@ import '../../utils/toast_util.dart'; @@ -15,13 +15,17 @@ import '../../utils/toast_util.dart';
15 import 'event.dart'; 15 import 'event.dart';
16 import 'state.dart'; 16 import 'state.dart';
17 17
  18 +const bool isWechatPayOptionVisible = false;
  19 +
18 class ShoppingBloc extends Bloc<ShoppingEvent, ShoppingState> { 20 class ShoppingBloc extends Bloc<ShoppingEvent, ShoppingState> {
19 21
20 ProductEntity? _productData; 22 ProductEntity? _productData;
21 23
22 ProductEntity? get productData => _productData; 24 ProductEntity? get productData => _productData;
23 25
24 - PaymentChannel _curPaymentChannel = PaymentChannel.wechatPay; 26 + PaymentChannel _curPaymentChannel = isWechatPayOptionVisible
  27 + ? PaymentChannel.wechatPay
  28 + : PaymentChannel.aliPay;
25 29
26 PaymentChannel get curPaymentChannel => _curPaymentChannel; 30 PaymentChannel get curPaymentChannel => _curPaymentChannel;
27 31
lib/pages/shopping/view.dart
@@ -149,17 +149,26 @@ Widget _paymentWidget() =&gt; BlocBuilder&lt;ShoppingBloc, ShoppingState&gt;( @@ -149,17 +149,26 @@ Widget _paymentWidget() =&gt; BlocBuilder&lt;ShoppingBloc, ShoppingState&gt;(
149 fontFamily: 'PingFangSC-Regular')), 149 fontFamily: 'PingFangSC-Regular')),
150 ), 150 ),
151 const SizedBox(height: 18.0), 151 const SizedBox(height: 18.0),
152 - buildRadioOption(  
153 - value: PaymentChannel.wechatPay.payChannelType,  
154 - icon: AssetImage('weixin'.assetPng),  
155 - text: PaymentChannel.wechatPay.payChannelName,  
156 - isSelected: bloc.curPaymentChannel.payChannelType ==  
157 - PaymentChannel.wechatPay.payChannelType,  
158 - onSelect: (newValue) {  
159 - bloc.add(ChangePaymentChannelEvent(PaymentChannel.wechatPay));  
160 - }, 152 + Visibility(
  153 + visible: isWechatPayOptionVisible,
  154 + child: Column(
  155 + children: [
  156 + buildRadioOption(
  157 + value: PaymentChannel.wechatPay.payChannelType,
  158 + icon: AssetImage('weixin'.assetPng),
  159 + text: PaymentChannel.wechatPay.payChannelName,
  160 + isSelected: bloc.curPaymentChannel.payChannelType ==
  161 + PaymentChannel.wechatPay.payChannelType,
  162 + onSelect: (newValue) {
  163 + bloc.add(
  164 + ChangePaymentChannelEvent(PaymentChannel.wechatPay),
  165 + );
  166 + },
  167 + ),
  168 + const SizedBox(height: 15.0),
  169 + ],
  170 + ),
161 ), 171 ),
162 - const SizedBox(height: 15.0),  
163 buildRadioOption( 172 buildRadioOption(
164 value: PaymentChannel.aliPay.payChannelType, 173 value: PaymentChannel.aliPay.payChannelType,
165 icon: AssetImage('zhifubao'.assetPng), 174 icon: AssetImage('zhifubao'.assetPng),