Merge branch 'opt-DialogAction'

This commit is contained in:
guozhigq
2024-04-27 16:08:44 +08:00
3 changed files with 52 additions and 80 deletions

View File

@ -131,51 +131,37 @@ class BangumiIntroController extends GetxController {
builder: (context) { builder: (context) {
return AlertDialog( return AlertDialog(
title: const Text('选择投币个数'), title: const Text('选择投币个数'),
contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 12), contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 24),
content: StatefulBuilder(builder: (context, StateSetter setState) { content: StatefulBuilder(builder: (context, StateSetter setState) {
return Column( return Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [1, 2]
RadioListTile( .map(
value: 1, (e) => RadioListTile(
title: const Text('1枚'), value: e,
groupValue: _tempThemeValue, title: Text('$e枚'),
onChanged: (value) { groupValue: _tempThemeValue,
_tempThemeValue = value!; onChanged: (value) async {
Get.appUpdate(); _tempThemeValue = value!;
}, setState(() {});
), var res = await VideoHttp.coinVideo(
RadioListTile( bvid: bvid, multiply: _tempThemeValue);
value: 2, if (res['status']) {
title: const Text('2枚'), SmartDialog.showToast('投币成功 👏');
groupValue: _tempThemeValue, hasCoin.value = true;
onChanged: (value) { bangumiDetail.value.stat!['coins'] =
_tempThemeValue = value!; bangumiDetail.value.stat!['coins'] +
Get.appUpdate(); _tempThemeValue;
}, } else {
), SmartDialog.showToast(res['msg']);
], }
Get.back();
},
),
)
.toList(),
); );
}), }),
actions: [
TextButton(onPressed: () => Get.back(), child: const Text('取消')),
TextButton(
onPressed: () async {
var res = await VideoHttp.coinVideo(
bvid: bvid, multiply: _tempThemeValue);
if (res['status']) {
SmartDialog.showToast('投币成功 👏');
hasCoin.value = true;
bangumiDetail.value.stat!['coins'] =
bangumiDetail.value.stat!['coins'] + _tempThemeValue;
} else {
SmartDialog.showToast(res['msg']);
}
Get.back();
},
child: const Text('确定'),
)
],
); );
}); });
} }

View File

@ -29,7 +29,7 @@ class _SelectDialogState<T> extends State<SelectDialog<T>> {
return AlertDialog( return AlertDialog(
title: Text(widget.title), title: Text(widget.title),
contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 12), contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 24),
content: StatefulBuilder(builder: (context, StateSetter setState) { content: StatefulBuilder(builder: (context, StateSetter setState) {
return SingleChildScrollView( return SingleChildScrollView(
child: Column( child: Column(

View File

@ -219,50 +219,36 @@ class VideoIntroController extends GetxController {
builder: (context) { builder: (context) {
return AlertDialog( return AlertDialog(
title: const Text('选择投币个数'), title: const Text('选择投币个数'),
contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 12), contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 24),
content: StatefulBuilder(builder: (context, StateSetter setState) { content: StatefulBuilder(builder: (context, StateSetter setState) {
return Column( return Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [1, 2]
RadioListTile( .map(
value: 1, (e) => RadioListTile(
title: const Text('1枚'), value: e,
groupValue: _tempThemeValue, title: Text('$e枚'),
onChanged: (value) { groupValue: _tempThemeValue,
_tempThemeValue = value!; onChanged: (value) async {
Get.appUpdate(); _tempThemeValue = value!;
}, setState(() {});
), var res = await VideoHttp.coinVideo(
RadioListTile( bvid: bvid, multiply: _tempThemeValue);
value: 2, if (res['status']) {
title: const Text('2枚'), SmartDialog.showToast('投币成功 👏');
groupValue: _tempThemeValue, hasCoin.value = true;
onChanged: (value) { videoDetail.value.stat!.coin =
_tempThemeValue = value!; videoDetail.value.stat!.coin! + _tempThemeValue;
Get.appUpdate(); } else {
}, SmartDialog.showToast(res['msg']);
), }
], Get.back();
},
),
)
.toList(),
); );
}), }),
actions: [
TextButton(onPressed: () => Get.back(), child: const Text('取消')),
TextButton(
onPressed: () async {
var res = await VideoHttp.coinVideo(
bvid: bvid, multiply: _tempThemeValue);
if (res['status']) {
SmartDialog.showToast('投币成功 👏');
hasCoin.value = true;
videoDetail.value.stat!.coin =
videoDetail.value.stat!.coin! + _tempThemeValue;
} else {
SmartDialog.showToast(res['msg']);
}
Get.back();
},
child: const Text('确定'))
],
); );
}); });
} }