|
|
|
@ -1,40 +1,40 @@ |
|
|
|
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'; |
|
|
|
import 'package:retrofit/http.dart'; |
|
|
|
|
|
|
|
class LiveRechargePopup extends StatelessWidget { |
|
|
|
const LiveRechargePopup({ |
|
|
|
super.key, |
|
|
|
required this.activePay, |
|
|
|
required this.payChecked, |
|
|
|
required this.payList, |
|
|
|
required this.changePayActive, |
|
|
|
}); |
|
|
|
|
|
|
|
final ValueNotifier<int?> activePay; |
|
|
|
final ValueNotifier<bool> payChecked; |
|
|
|
final List<Map> payList; |
|
|
|
final void Function(int) changePayActive; |
|
|
|
|
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
final roseController = Get.isRegistered<RoseController>() |
|
|
|
? Get.find<RoseController>() |
|
|
|
: Get.put(RoseController()); |
|
|
|
|
|
|
|
return Material( |
|
|
|
color: Colors.transparent, |
|
|
|
child: Container( |
|
|
|
color: Colors.white, |
|
|
|
height: 440.w, |
|
|
|
padding: EdgeInsets.symmetric(horizontal: 10.w), |
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w), |
|
|
|
child: Column( |
|
|
|
mainAxisSize: MainAxisSize.min, |
|
|
|
children: [ |
|
|
|
_buildHeader(context), |
|
|
|
_buildBalanceInfo(), |
|
|
|
_buildPayOptions(), |
|
|
|
_buildAgreementRow(), |
|
|
|
SizedBox(height: 23.w), |
|
|
|
_buildSubmitButton(), |
|
|
|
_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), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
@ -49,10 +49,10 @@ class LiveRechargePopup extends StatelessWidget { |
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
children: [ |
|
|
|
InkWell( |
|
|
|
onTap: () => Get.back(), |
|
|
|
onTap: () => SmartDialog.dismiss(), |
|
|
|
child: Icon( |
|
|
|
Icons.close, |
|
|
|
size: 14.w, |
|
|
|
size: 16.w, |
|
|
|
color: const Color.fromRGBO(114, 114, 114, 1), |
|
|
|
), |
|
|
|
), |
|
|
|
@ -74,154 +74,274 @@ class LiveRechargePopup extends StatelessWidget { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
Widget _buildBalanceInfo() { |
|
|
|
return Container( |
|
|
|
Widget _buildBalanceInfo(RoseController controller) { |
|
|
|
return Obx(() => Container( |
|
|
|
padding: EdgeInsets.symmetric(horizontal: 8.w), |
|
|
|
margin: EdgeInsets.only(bottom: 15.w), |
|
|
|
child: Row( |
|
|
|
children: [ |
|
|
|
Text( |
|
|
|
"余额:9玫瑰", |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 11.w, |
|
|
|
color: const Color.fromRGBO(144, 144, 144, 1), |
|
|
|
fontWeight: FontWeight.w500, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
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() { |
|
|
|
return ValueListenableBuilder<int?>( |
|
|
|
valueListenable: activePay, |
|
|
|
builder: (context, active, _) { |
|
|
|
return Wrap( |
|
|
|
spacing: 7.w, |
|
|
|
runSpacing: 7.w, |
|
|
|
children: [ |
|
|
|
...payList.asMap().entries.map( |
|
|
|
(entry) { |
|
|
|
return LiveRoomPayItem( |
|
|
|
item: entry.value, |
|
|
|
active: active ?? 0, |
|
|
|
index: entry.key, |
|
|
|
changeActive: changePayActive, |
|
|
|
); |
|
|
|
}, |
|
|
|
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.unitSellingPrice ?? 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 _buildAgreementRow() { |
|
|
|
return Padding( |
|
|
|
padding: EdgeInsets.only(top: 10.w, bottom: 15.w), |
|
|
|
child: 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.imagesAliPay, |
|
|
|
width: 17.w, |
|
|
|
height: 17.w, |
|
|
|
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.imagesAliPay, |
|
|
|
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, |
|
|
|
), |
|
|
|
SizedBox(width: 6.w), |
|
|
|
Text( |
|
|
|
"支付宝支付", |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 11.w, |
|
|
|
color: const Color.fromRGBO(51, 51, 51, 1), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
Obx(() { |
|
|
|
final checked = controller.payChecked.value; |
|
|
|
return GestureDetector( |
|
|
|
onTap: () => controller.payChecked.value = true, |
|
|
|
child: Container( |
|
|
|
width: 18.w, |
|
|
|
height: 18.w, |
|
|
|
decoration: BoxDecoration( |
|
|
|
shape: BoxShape.circle, |
|
|
|
color: checked |
|
|
|
? const Color.fromRGBO(117, 98, 249, 1) |
|
|
|
: Colors.white, |
|
|
|
border: Border.all( |
|
|
|
width: 1, |
|
|
|
color: checked |
|
|
|
? const Color.fromRGBO(117, 98, 249, 1) |
|
|
|
: const Color.fromRGBO(188, 188, 188, 1), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
ValueListenableBuilder<bool>( |
|
|
|
valueListenable: payChecked, |
|
|
|
builder: (context, checked, _) { |
|
|
|
return GestureDetector( |
|
|
|
onTap: () => payChecked.value = !payChecked.value, |
|
|
|
child: Row( |
|
|
|
children: [ |
|
|
|
Container( |
|
|
|
width: 14.w, |
|
|
|
height: 14.w, |
|
|
|
decoration: BoxDecoration( |
|
|
|
borderRadius: BorderRadius.all(Radius.circular(2.w)), |
|
|
|
color: checked |
|
|
|
? const Color.fromRGBO(239, 19, 46, 1) |
|
|
|
: Colors.white, |
|
|
|
border: Border.all( |
|
|
|
width: 1, |
|
|
|
color: checked |
|
|
|
? const Color.fromRGBO(239, 19, 46, 1) |
|
|
|
: const Color.fromRGBO(188, 188, 188, 1), |
|
|
|
), |
|
|
|
child: checked |
|
|
|
? Center( |
|
|
|
child: Icon( |
|
|
|
Icons.check, |
|
|
|
size: 12.w, |
|
|
|
color: Colors.white, |
|
|
|
), |
|
|
|
child: Center( |
|
|
|
child: Image.asset( |
|
|
|
Assets.imagesCheck, |
|
|
|
width: 6.w, |
|
|
|
height: 4.w, |
|
|
|
color: checked ? Colors.white : Colors.transparent, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(width: 6.w), |
|
|
|
Text( |
|
|
|
"我已阅读并同意《充值协议》", |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 11.w, |
|
|
|
color: const Color.fromRGBO(144, 144, 144, 1), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
) |
|
|
|
: null, |
|
|
|
), |
|
|
|
); |
|
|
|
}), |
|
|
|
], |
|
|
|
), |
|
|
|
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, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
Obx(() { |
|
|
|
final checked = !controller.payChecked.value; |
|
|
|
return GestureDetector( |
|
|
|
onTap: () => controller.payChecked.value = false, |
|
|
|
child: Container( |
|
|
|
width: 18.w, |
|
|
|
height: 18.w, |
|
|
|
decoration: BoxDecoration( |
|
|
|
shape: BoxShape.circle, |
|
|
|
color: checked |
|
|
|
? const Color.fromRGBO(117, 98, 249, 1) |
|
|
|
: Colors.white, |
|
|
|
border: Border.all( |
|
|
|
width: 1, |
|
|
|
color: checked |
|
|
|
? const Color.fromRGBO(117, 98, 249, 1) |
|
|
|
: const Color.fromRGBO(188, 188, 188, 1), |
|
|
|
), |
|
|
|
); |
|
|
|
}, |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
child: checked |
|
|
|
? Center( |
|
|
|
child: Icon( |
|
|
|
Icons.check, |
|
|
|
size: 12.w, |
|
|
|
color: Colors.white, |
|
|
|
), |
|
|
|
) |
|
|
|
: null, |
|
|
|
), |
|
|
|
); |
|
|
|
}), |
|
|
|
], |
|
|
|
), |
|
|
|
], |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
Widget _buildSubmitButton() { |
|
|
|
return Container( |
|
|
|
width: double.infinity, |
|
|
|
height: 44.w, |
|
|
|
decoration: BoxDecoration( |
|
|
|
borderRadius: BorderRadius.all(Radius.circular(44.w)), |
|
|
|
gradient: const LinearGradient( |
|
|
|
begin: Alignment.centerLeft, |
|
|
|
end: Alignment.centerRight, |
|
|
|
colors: [ |
|
|
|
Color.fromRGBO(239, 19, 46, 1), |
|
|
|
Color.fromRGBO(255, 183, 22, 1), |
|
|
|
], |
|
|
|
Widget _buildAgreementText() { |
|
|
|
return Row( |
|
|
|
children: [ |
|
|
|
Text( |
|
|
|
"充值既代表同意", |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 11.w, |
|
|
|
color: const Color.fromRGBO(189, 189, 189, 1), |
|
|
|
fontWeight: FontWeight.w500, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
child: Center( |
|
|
|
child: Text( |
|
|
|
"立即充值", |
|
|
|
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: 13.w, |
|
|
|
color: Colors.white, |
|
|
|
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, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
|