import 'package:dating_touchme_app/generated/assets.dart'; import 'package:dating_touchme_app/widget/live/live_room_pay_item.dart'; import 'package:dating_touchme_app/controller/mine/rose_controller.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; class LiveRechargePopup extends StatelessWidget { const LiveRechargePopup({ super.key, }); @override Widget build(BuildContext context) { final roseController = Get.isRegistered() ? Get.find() : Get.put(RoseController()); return Material( color: Colors.transparent, child: Container( color: Colors.white, padding: EdgeInsets.symmetric(horizontal: 12.w), child: Column( mainAxisSize: MainAxisSize.min, children: [ _buildHeader(context), _buildBalanceInfo(roseController), _buildPayOptions(roseController), SizedBox(height: 10.w), _buildPaymentMethods(roseController), SizedBox(height: 8.w), _buildAgreementText(), SizedBox(height: 20.w), _buildSubmitButton(roseController), SizedBox(height: 20.w), ], ), ), ); } Widget _buildHeader(BuildContext context) { return Container( height: 48.w, padding: EdgeInsets.symmetric(horizontal: 8.w), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ InkWell( onTap: () => SmartDialog.dismiss(), child: Icon( Icons.close, size: 16.w, color: const Color.fromRGBO(114, 114, 114, 1), ), ), Text( "玫瑰充值", style: TextStyle( fontSize: 17.w, color: const Color.fromRGBO(51, 51, 51, 1), fontWeight: FontWeight.w500, ), ), Icon( Icons.close, size: 14.w, color: Colors.transparent, ), ], ), ); } Widget _buildBalanceInfo(RoseController controller) { return Obx(() => Container( padding: EdgeInsets.symmetric(horizontal: 8.w), alignment: Alignment.centerLeft, child: Text( "余额:${controller.roseNum.value}玫瑰", style: TextStyle( fontSize: 11.w, color: const Color.fromRGBO(144, 144, 144, 1), fontWeight: FontWeight.w500, ), ), )); } Widget _buildPayOptions(RoseController controller) { return Obx(() { final roseList = controller.roseList; if (roseList.isEmpty) { return Container( padding: EdgeInsets.symmetric(vertical: 20.w), child: Text( '加载中...', style: TextStyle( fontSize: 14.w, color: Colors.grey, ), ), ); } // 将 RoseData 转换为 Map 格式 final payList = roseList.map((rose) { return { 'num': rose.purchaseTimeValue ?? 0, 'price': rose.unitSellingPriceStr ?? "0", 'hasTag': rose.detailDesc != null && rose.detailDesc!.isNotEmpty, 'tagText': rose.detailDesc ?? '', }; }).toList(); return GridView.builder( shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 3, crossAxisSpacing: 7.w, mainAxisSpacing: 7.w, childAspectRatio: 113.w / 55.w, ), itemCount: payList.length, itemBuilder: (context, index) { return Obx(() => LiveRoomPayItem( item: payList[index], active: controller.activePay.value, index: index, changeActive: controller.changePayActive, )); }, ); }); } Widget _buildPaymentMethods(RoseController controller) { return Column( children: [ Container( height: 1, color: const Color.fromRGBO(219, 219, 219, 1), ), SizedBox(height: 15.w), // 微信支付 Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Image.asset( Assets.imagesWechatPay, width: 20.w, height: 20.w, ), SizedBox(width: 6.w), Text( "微信支付", style: TextStyle( fontSize: 13.w, color: const Color.fromRGBO(51, 51, 51, 1), fontWeight: FontWeight.w500, ), ), ], ), Container( width: 18.w, height: 18.w, decoration: BoxDecoration( shape: BoxShape.circle, color: const Color.fromRGBO(117, 98, 249, 1), border: Border.all( width: 1, color: const Color.fromRGBO(117, 98, 249, 1), ), ), child: Center( child: Icon( Icons.check, size: 12.w, color: Colors.white, ), ), ), ], ), ], ); } Widget _buildAgreementText() { return Row( children: [ Text( "充值既代表同意", style: TextStyle( fontSize: 11.w, color: const Color.fromRGBO(189, 189, 189, 1), fontWeight: FontWeight.w500, ), ), GestureDetector( onTap: () { // TODO: 打开充值协议页面 print('打开充值协议'); }, child: Text( "《趣恋恋充值协议》", style: TextStyle( fontSize: 11.w, color: const Color.fromRGBO(71, 123, 255, 1), fontWeight: FontWeight.w500, ), ), ), Text( "和", style: TextStyle( fontSize: 11.w, color: const Color.fromRGBO(189, 189, 189, 1), fontWeight: FontWeight.w500, ), ), GestureDetector( onTap: () { // TODO: 打开隐私政策页面 print('打开隐私政策'); }, child: Text( "隐私政策", style: TextStyle( fontSize: 11.w, color: const Color.fromRGBO(71, 123, 255, 1), fontWeight: FontWeight.w500, ), ), ), ], ); } Widget _buildSubmitButton(RoseController controller) { return GestureDetector( onTap: () { controller.submitOrder(); }, child: Container( width: double.infinity, height: 45.w, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(45.w)), gradient: const LinearGradient( begin: Alignment.centerLeft, end: Alignment.centerRight, colors: [ Color.fromRGBO(131, 89, 255, 1), // 紫色 Color.fromRGBO(77, 127, 231, 1), // 中间淡蓝 Color.fromRGBO(61, 138, 224, 1), // 右侧深蓝 ], stops: [0.0, 0.7753, 1.0], ), ), child: Center( child: Text( "立即充值", style: TextStyle( fontSize: 18.w, color: Colors.white, fontWeight: FontWeight.w500, ), ), ), ), ); } }