reserve btn

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-05-15 13:24:43 +08:00
parent d35c85f389
commit 205ae2bf55
2 changed files with 55 additions and 37 deletions

View File

@@ -499,6 +499,8 @@ class ReserveBtn {
String? checkText;
String? uncheckText;
int? disable;
String? jumpText;
String? jumpUrl;
ReserveBtn.fromJson(Map<String, dynamic> json) {
status = json['status'];
@@ -506,6 +508,8 @@ class ReserveBtn {
checkText = json['check']?['text'] ?? '已预约';
uncheckText = json['uncheck']?['text'] ?? '预约';
disable = json['uncheck']?['disable'];
jumpText = json['jump_style']?['text'];
jumpUrl = json['jump_url'];
}
}

View File

@@ -108,52 +108,66 @@ Widget addWidget(
builder: (context) {
final btn = content.button!;
final isReserved = btn.status == btn.type;
final bool canJump = btn.jumpUrl != null;
return FilledButton.tonal(
style: FilledButton.styleFrom(
foregroundColor: isReserved
? theme.colorScheme.onSurface
.withOpacity(0.38)
: null,
backgroundColor: isReserved
? theme.colorScheme.onSurface
.withOpacity(0.12)
: null,
foregroundColor: canJump
? null
: isReserved
? theme.colorScheme.onSurface
.withOpacity(0.38)
: null,
backgroundColor: canJump
? null
: isReserved
? theme.colorScheme.onSurface
.withOpacity(0.12)
: null,
visualDensity: VisualDensity.compact,
padding: const EdgeInsets.symmetric(
horizontal: 16),
tapTargetSize:
MaterialTapTargetSize.shrinkWrap,
),
onPressed: btn.disable == 1
? null
: () async {
var res =
await DynamicsHttp.dynReserve(
reserveId: content.rid,
curBtnStatus: btn.status,
dynamicIdStr: item.idStr,
reserveTotal: content.reserveTotal,
);
if (res['status']) {
content
..desc2?.text =
res['data']['desc_update']
..reserveTotal =
res['data']['reserve_update']
..button!.status = res['data']
['final_btn_status'];
if (context.mounted) {
(context as Element?)
?.markNeedsBuild();
}
} else {
SmartDialog.showToast(res['msg']);
}
},
onPressed: canJump
? () {
PiliScheme.routePushFromUrl(
btn.jumpUrl!);
}
: btn.disable == 1
? null
: () async {
var res =
await DynamicsHttp.dynReserve(
reserveId: content.rid,
curBtnStatus: btn.status,
dynamicIdStr: item.idStr,
reserveTotal:
content.reserveTotal,
);
if (res['status']) {
content
..desc2?.text =
res['data']['desc_update']
..reserveTotal = res['data']
['reserve_update']
..button!.status = res['data']
['final_btn_status'];
if (context.mounted) {
(context as Element?)
?.markNeedsBuild();
}
} else {
SmartDialog.showToast(
res['msg']);
}
},
child: Text(
isReserved
? btn.checkText!
: btn.uncheckText!,
btn.jumpText != null
? btn.jumpText!
: isReserved
? btn.checkText!
: btn.uncheckText!,
),
);
},