|
|
@@ -3,101 +3,182 @@ import 'package:flutter/cupertino.dart';
|
|
|
import 'package:wanna_battle/styles/colors.dart';
|
|
|
import 'package:wanna_battle/styles/totast.dart';
|
|
|
import '../styles/colors.dart';
|
|
|
-import '../widget/Dialog.dart';
|
|
|
+import '../model/CheckinConfig.dart';
|
|
|
+import '../net/HttpManager.dart';
|
|
|
|
|
|
void showCheckinDialog(BuildContext context) {
|
|
|
- Navigator.of(context).push(
|
|
|
- PageRouteBuilder(
|
|
|
- opaque: false,
|
|
|
- transitionDuration: Duration(milliseconds: 300),
|
|
|
- transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
|
|
|
- return FadeTransition(
|
|
|
- opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
|
|
|
+ showGeneralDialog(
|
|
|
+ context: context,
|
|
|
+ pageBuilder: (BuildContext buildContext, Animation<double> animation, Animation<double> secondaryAnimation) {
|
|
|
+ return Center(
|
|
|
+ child: Material(
|
|
|
+ color: Colors.transparent,
|
|
|
+ child: _CheckinDialog(),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ },
|
|
|
+ barrierDismissible: true,
|
|
|
+ barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
|
|
|
+ barrierColor: Colors.black26,
|
|
|
+ transitionBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
|
|
|
+ final curvedValue = Curves.easeInOutBack.transform(animation.value) - 1.0;
|
|
|
+ return Transform(
|
|
|
+ transform: Matrix4.translationValues(0.0, curvedValue * 200, 0.0),
|
|
|
+ child: Opacity(
|
|
|
+ opacity: animation.value,
|
|
|
child: child,
|
|
|
- );
|
|
|
- },
|
|
|
- pageBuilder: (BuildContext context, _, __) {
|
|
|
- return _CheckinDialog1();
|
|
|
- },
|
|
|
- ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ },
|
|
|
+ transitionDuration: const Duration(milliseconds: 300),
|
|
|
);
|
|
|
}
|
|
|
|
|
|
-class _CheckinDialog1 extends Dialog {
|
|
|
+class _CheckinDialog extends StatefulWidget {
|
|
|
+ @override
|
|
|
+ State<StatefulWidget> createState() {
|
|
|
+ return _CheckinDialogState();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+class _CheckinDialogState extends State<_CheckinDialog> {
|
|
|
+ Map<int, CheckinConfig> record;
|
|
|
+ bool todayChecked = false;
|
|
|
+
|
|
|
+ Future<void> getRecords() async {
|
|
|
+ final res = await HttpManager.get('checkinRecord/weekRecord');
|
|
|
+ if (res.success) {
|
|
|
+ Map<int, CheckinConfig> map = {};
|
|
|
+ res.data.forEach((k, v) {
|
|
|
+ map[int.parse(k)] = CheckinConfig.fromJson(v);
|
|
|
+ });
|
|
|
+ bool todayChecked = false;
|
|
|
+ if (map[DateTime.now().weekday] != null && map[DateTime.now().weekday].checked == 1) {
|
|
|
+ todayChecked = true;
|
|
|
+ }
|
|
|
+ setState(() {
|
|
|
+ record = map;
|
|
|
+ this.todayChecked = todayChecked;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Future<void> checkin() async {
|
|
|
+ Toast.show(context, '加载中', -1, 'loading');
|
|
|
+ final res = await HttpManager.get('checkinRecord/checkin');
|
|
|
+ print(res.data.toString());
|
|
|
+ Toast.hide();
|
|
|
+ if (res.success) {
|
|
|
+ Toast.show(context, '签到成功', 1500, 'info');
|
|
|
+ } else {
|
|
|
+ Toast.show(context, res.error, 1500, 'info');
|
|
|
+ }
|
|
|
+ Navigator.of(context).pop();
|
|
|
+ }
|
|
|
+
|
|
|
+ @override
|
|
|
+ void initState() {
|
|
|
+ super.initState();
|
|
|
+
|
|
|
+ Future.delayed(Duration.zero, () async {
|
|
|
+ getRecords();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
- return WillPopScope(
|
|
|
- child: Scaffold(
|
|
|
- backgroundColor: Color(0xb3000000),
|
|
|
- body: Container(
|
|
|
- child: SizedBox.expand(
|
|
|
- child: UnconstrainedBox(
|
|
|
- child: Container(
|
|
|
- width: 330,
|
|
|
- height: 390,
|
|
|
- decoration: BoxDecoration(color: Color(0xE6293559), border: Border.all(width: 1, color: Color(0xFF1990F8))),
|
|
|
- child: Column(
|
|
|
- crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
- mainAxisAlignment: MainAxisAlignment.center,
|
|
|
- children: <Widget>[
|
|
|
- Text(
|
|
|
- '每日签到',
|
|
|
- style: TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold),
|
|
|
- ),
|
|
|
- Container(
|
|
|
- margin: EdgeInsets.only(top: 30),
|
|
|
- child: Row(
|
|
|
- mainAxisAlignment: MainAxisAlignment.center,
|
|
|
- children: <Widget>[
|
|
|
- item('星期一', 1, '50金币', 1),
|
|
|
- item('星期二', 1, '50金币', 2),
|
|
|
- item('星期三', 1, '50金币', 3),
|
|
|
- item('星期四', 1, '50金币', 1),
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
- Container(
|
|
|
- margin: EdgeInsets.only(top: 25),
|
|
|
- child: Row(
|
|
|
- mainAxisAlignment: MainAxisAlignment.center,
|
|
|
- children: <Widget>[
|
|
|
- item('星期五', 1, '50金币', 2),
|
|
|
- item('星期六', 1, '50金币', 3),
|
|
|
- item('星期日', 1, '50金币', 1),
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
- Container(
|
|
|
- margin: EdgeInsets.only(top: 40),
|
|
|
- child: MaterialButton(
|
|
|
- minWidth: 220,
|
|
|
- elevation: 0,
|
|
|
- highlightElevation: 0,
|
|
|
- color: PRIMARY_COLOR,
|
|
|
- child: Text(
|
|
|
- '立即签到',
|
|
|
- style: TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.bold),
|
|
|
- ),
|
|
|
- onPressed: () {
|
|
|
- Toast.show(context, '签到成功', 2000, 'info');
|
|
|
- Navigator.of(context).pop();
|
|
|
- },
|
|
|
- ),
|
|
|
- )
|
|
|
- ],
|
|
|
+ return Container(
|
|
|
+ width: 330,
|
|
|
+ height: 390,
|
|
|
+ decoration: BoxDecoration(color: Color(0xE6293559), border: Border.all(width: 1, color: Color(0xFF1990F8))),
|
|
|
+ child: record == null
|
|
|
+ ? null
|
|
|
+ : Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ children: <Widget>[
|
|
|
+ Text(
|
|
|
+ '每日签到',
|
|
|
+ style: TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold),
|
|
|
),
|
|
|
- ),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(top: 30),
|
|
|
+ child: Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ children: <Widget>[
|
|
|
+ item(record[1]),
|
|
|
+ item(record[2]),
|
|
|
+ item(record[3]),
|
|
|
+ item(record[4]),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(top: 25),
|
|
|
+ child: Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ children: <Widget>[
|
|
|
+ item(record[5]),
|
|
|
+ item(record[6]),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ todayChecked
|
|
|
+ ? Container(
|
|
|
+ margin: EdgeInsets.only(top: 40),
|
|
|
+ child: MaterialButton(
|
|
|
+ minWidth: 220,
|
|
|
+ elevation: 0,
|
|
|
+ highlightElevation: 0,
|
|
|
+ color: Color(0xFF4F5C87),
|
|
|
+ child: Text(
|
|
|
+ '今日已签到',
|
|
|
+ style: TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.bold),
|
|
|
+ ),
|
|
|
+ onPressed: () {
|
|
|
+ Navigator.of(context).pop();
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ : Container(
|
|
|
+ margin: EdgeInsets.only(top: 40),
|
|
|
+ child: MaterialButton(
|
|
|
+ minWidth: 220,
|
|
|
+ elevation: 0,
|
|
|
+ highlightElevation: 0,
|
|
|
+ color: PRIMARY_COLOR,
|
|
|
+ child: Text(
|
|
|
+ '立即签到',
|
|
|
+ style: TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.bold),
|
|
|
+ ),
|
|
|
+ onPressed: () {
|
|
|
+ checkin();
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
),
|
|
|
- ),
|
|
|
- ),
|
|
|
- ),
|
|
|
- onWillPop: () {
|
|
|
- return Future.value(true);
|
|
|
- },
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- Widget item(String weekDay, int type, String name, int checked) {
|
|
|
+ Widget item(CheckinConfig config) {
|
|
|
+ String weekDay = config.weekDay;
|
|
|
+ String icon;
|
|
|
+ String name;
|
|
|
+ if (config.moneyCoin != null) {
|
|
|
+ icon = 'images/icon_jinbi_qiandao.png';
|
|
|
+ name = config.moneyCoin.toString() + '金币';
|
|
|
+ } else if (config.pointsRatio != null) {
|
|
|
+ icon = 'images/qiandao_icon_jiacheng.png';
|
|
|
+ name = '加成卡';
|
|
|
+ } else if (config.minPoints != null) {
|
|
|
+ icon = 'images/icon_baodi_03.png';
|
|
|
+ name = '保底卡';
|
|
|
+ } else if (config.probability != null) {
|
|
|
+ icon = 'images/qiandao_icon_gailv.png';
|
|
|
+ name = '概率卡';
|
|
|
+ }
|
|
|
+ int checked = config.checked;
|
|
|
List<Widget> list = [
|
|
|
Container(
|
|
|
decoration: BoxDecoration(
|
|
|
@@ -108,7 +189,8 @@ class _CheckinDialog1 extends Dialog {
|
|
|
),
|
|
|
Center(
|
|
|
child: Image.asset(
|
|
|
- 'images/icon_jinbi_qiandao.png',
|
|
|
+ icon,
|
|
|
+ width: 33,
|
|
|
),
|
|
|
),
|
|
|
];
|
|
|
@@ -128,7 +210,7 @@ class _CheckinDialog1 extends Dialog {
|
|
|
),
|
|
|
child: Center(
|
|
|
child: Text(
|
|
|
- '未签到',
|
|
|
+ '��签到',
|
|
|
style: TextStyle(color: Colors.white, fontSize: 10),
|
|
|
),
|
|
|
),
|
|
|
@@ -156,7 +238,7 @@ class _CheckinDialog1 extends Dialog {
|
|
|
Container(
|
|
|
margin: EdgeInsets.only(top: 2),
|
|
|
child: Text(
|
|
|
- '50金币',
|
|
|
+ name,
|
|
|
style: TextStyle(
|
|
|
color: PRIMARY_COLOR,
|
|
|
fontSize: 12,
|