2026-07-01 18:25:58 +08:00

339 lines
12 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:aslan/app_localizations.dart';
import 'package:aslan/chatvibe_ui/components/at_compontent.dart';
import 'package:aslan/chatvibe_ui/components/text/at_text.dart';
import 'package:aslan/chatvibe_ui/components/at_tts.dart';
import 'package:aslan/chatvibe_core/utilities/at_loading_manager.dart';
import 'package:aslan/chatvibe_ui/widgets/sgin/recive_award_sgin_page.dart';
import 'package:aslan/chatvibe_data/sources/repositories/user_repository_impl.dart';
import '../../../chatvibe_data/models/enum/at_activity_reward_props_type.dart';
import '../../../chatvibe_domain/models/res/at_sign_in_res.dart';
///签到页面
class SginPage extends StatefulWidget {
bool fromHome = false;
SginPage(this.fromHome);
@override
_SginPageState createState() => _SginPageState();
}
class _SginPageState extends State<SginPage> {
ATSignInRes? res;
//是否已经签到
bool isSgined = true;
@override
void initState() {
super.initState();
sginListAward();
AccountRepository()
.checkInToday()
.then((result) {
isSgined = result;
setState(() {});
})
.catchError((e) {});
}
@override
Widget build(BuildContext context) {
return GestureDetector(
child: Container(
height: 465.w,
margin: EdgeInsets.symmetric(horizontal: 15.w),
alignment: AlignmentDirectional.center,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("atu_images/index/at_icon_sgin_bg.png"),
fit: BoxFit.fill,
),
),
child:
res != null
? Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(height: 105.w),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(width: 15.w),
_buildItme(
1,
res?.rewards?[0].propsGroup?.activityRewardProps?[0],
res?.days,
),
_buildItme(
2,
res?.rewards?[0].propsGroup?.activityRewardProps?[1],
res?.days,
),
_buildItme(
3,
res?.rewards?[0].propsGroup?.activityRewardProps?[2],
res?.days,
),
_buildItme(
4,
res?.rewards?[0].propsGroup?.activityRewardProps?[3],
res?.days,
),
SizedBox(width: 15.w),
],
),
SizedBox(height: 10.w),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(width: 15.w),
_buildItme(
5,
res?.rewards?[0].propsGroup?.activityRewardProps?[4],
res?.days,
),
_buildItme(
6,
res?.rewards?[0].propsGroup?.activityRewardProps?[5],
res?.days,
),
_buildItme(
7,
res?.rewards?[0].propsGroup?.activityRewardProps?[6],
res?.days,
),
SizedBox(width: 15.w),
],
),
SizedBox(height: 10.w),
GestureDetector(
child: Container(
width: 200.w,
height: 55.w,
alignment: AlignmentDirectional.center,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
isSgined
? "atu_images/index/at_icon_signedin_bg.png"
: "atu_images/index/at_icon_sgin_rec_bg.png",
),
),
),
child: text(
isSgined
? ATAppLocalizations.of(context)!.signedin
: ATAppLocalizations.of(context)!.receive,
fontWeight: FontWeight.bold,
fontSize: 18.sp,
textColor: Colors.white,
),
),
onTap: () {
if (isSgined) {
return;
}
receive();
},
),
SizedBox(height: 5.w),
Container(
margin: EdgeInsets.symmetric(horizontal: 30.w),
child: text(
ATAppLocalizations.of(context)!.sginTips,
maxLines: 4,
textColor: Color(0xffAAAAAA),
lineHeight: 1.2,
letterSpacing: 0.1,
fontSize: 12.sp,
fontWeight: FontWeight.w600,
),
),
SizedBox(height: 10.w),
],
)
: Container(),
),
onTap: () {
SmartDialog.dismiss(tag: "showSginListAward");
},
);
}
_buildItme(int tagDay, ActivityRewardProps? reward, num? days) {
return tagDay == 7
? Column(
children: [
SizedBox(
width: 147.w,
height: 85.w,
child: Stack(
alignment: AlignmentDirectional.center,
children: [
Image.asset("atu_images/index/at_icon_sgin_item_day7_bg1.png"),
tagDay < (days ?? 0) + 1
? Image.asset("atu_images/index/at_icon_sgin_item_day7_bg2.png")
: Container(),
reward?.type == ATActivityRewardATPropsType.GOLD.name
? Image.asset(
"atu_images/general/at_icon_jb.png",
width: 42.w,
height: 42.w,
)
: netImage(
url: reward?.cover ?? "",
width: 42.w,
height: 42.w,
),
Positioned(
top: 0,
right: 10.w,
child: text(
"$tagDay",
fontSize: 9.sp,
textColor: Colors.white,
fontWeight: FontWeight.w600,
),
),
PositionedDirectional(
bottom: 0,
child:
reward?.type == ATActivityRewardATPropsType.PROPS.name
? Row(
children: [
text(
"${reward?.quantity} ${ATAppLocalizations.of(context)!.day}",
fontSize: 12.sp,
textColor: Colors.white,
fontWeight: FontWeight.w600,
),
],
)
: Row(
children: [
SizedBox(width: 2.w),
text(
"${ATAppLocalizations.of(context)!.coins4}*${reward?.amount}",
fontSize: 12.sp,
textColor: Colors.white,
fontWeight: FontWeight.w600,
),
],
),
),
days == tagDay
? Image.asset("atu_images/index/at_icon_sgin_item_day7_bg3.png")
: Container(),
],
),
),
],
)
: Column(
children: [
Container(
width: 70.w,
height: 85.w,
child: Stack(
alignment: AlignmentDirectional.center,
children: [
Image.asset("atu_images/index/at_icon_sgin_item_bg3.png"),
days == tagDay - 1
? Image.asset("atu_images/index/at_icon_sgin_item_bg1.png")
: Container(),
reward?.type == ATActivityRewardATPropsType.GOLD.name
? Image.asset(
"atu_images/general/at_icon_jb.png",
width: 42.w,
height: 42.w,
)
: netImage(
url: reward?.cover ?? "",
width: 42.w,
height: 42.w,
),
Positioned(
top: 0,
right: 11.w,
child: text(
"$tagDay",
fontSize: 9.sp,
textColor: Colors.white,
fontWeight: FontWeight.w600,
),
),
PositionedDirectional(
bottom: 0,
child:
reward?.type == ATActivityRewardATPropsType.PROPS.name
? Row(
children: [
text(
"${reward?.quantity} ${ATAppLocalizations.of(context)!.day}",
fontSize: 12.sp,
textColor: Colors.white,
fontWeight: FontWeight.w600,
),
],
)
: Row(
children: [
SizedBox(width: 2.w),
text(
"${ATAppLocalizations.of(context)!.coins4}*${reward?.amount}",
fontSize: 12.sp,
textColor: Colors.white,
fontWeight: FontWeight.w600,
),
],
),
),
tagDay < (days ?? 0) + 1
? Image.asset("atu_images/index/at_icon_sgin_item_bg2.png")
: Container(),
],
),
),
],
);
}
void sginListAward() async {
res = await AccountRepository().sginListAward();
setState(() {});
}
///签到
void receive() {
ATLoadingManager.exhibitOperation();
String ruleId = res?.rewards?[0].rule?.id ?? "";
String resourceGroupId = res?.rewards?[0].propsGroup?.id ?? "";
AccountRepository()
.checkInReceive(ruleId, resourceGroupId)
.then((resNum) {
ATLoadingManager.veilRoutine();
ATTts.show(ATAppLocalizations.of(context)!.checkInSuccessful);
SmartDialog.dismiss(tag: "showSginListAward");
ActivityRewardProps? awd =
res?.rewards?[0].propsGroup?.activityRewardProps![resNum - 1];
SmartDialog.show(
tag: "showReciveAwardSgin",
alignment: Alignment.center,
animationType: SmartAnimationType.fade,
builder: (_) {
return ReciveAwardSginPage(awd, resNum, widget.fromHome);
},
);
})
.catchError((e) {
ATLoadingManager.veilRoutine();
});
}
}