| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429 |
- import 'dart:async';
- import 'package:fast/constants.dart';
- import 'package:fast/model/model.dart';
- import 'package:fast/utils/global.dart';
- import 'package:fast/utils/size_fit.dart';
- import 'package:fast/view/component/fast.dart';
- import 'package:fast/view/component/fast_btn.dart';
- import 'package:fast/view/component/share.dart';
- import 'package:fast/view/component/toast.dart';
- import 'package:flutter/material.dart';
- // ignore: must_be_immutable
- class ChallengeResult extends StatefulWidget {
- FastResultBean resultBean;
- ChallengeResult({Key? key, required this.resultBean}) : super(key: key);
- @override
- State<ChallengeResult> createState() => _ChallengeResultState();
- }
- class _ChallengeResultState extends State<ChallengeResult>
- with SingleTickerProviderStateMixin {
- late AnimationController controller;
- late Animation topAni, centerAni, bottomAni;
- @override
- void initState() {
- controller = AnimationController(
- vsync: this, duration: const Duration(milliseconds: 1000));
- topAni = Tween(begin: 0.0, end: 1.0).animate(
- CurvedAnimation(parent: controller, curve: const Interval(0.0, 0.3)));
- centerAni = Tween(begin: 0.0, end: 1.0).animate(
- CurvedAnimation(parent: controller, curve: const Interval(0.3, 0.6)));
- bottomAni = Tween(begin: 0.0, end: 1.0).animate(
- CurvedAnimation(parent: controller, curve: const Interval(0.6, 0.9)));
- controller.addListener(() {
- setState(() {});
- });
- Timer(const Duration(milliseconds: 300), () {
- controller.forward();
- });
- // controller.forward();
- super.initState();
- }
- @override
- void dispose() {
- controller.dispose();
- super.dispose();
- }
- share() {
- showDialog(
- context: context,
- barrierDismissible: false,
- barrierColor: const Color(0xF2000D1F),
- builder: (BuildContext context) {
- return Share(
- type: 'challenge',
- resultBean: widget.resultBean,
- );
- });
- }
- @override
- Widget build(BuildContext context) {
- String resultTip = 'assets/images/challenge_failed.png';
- if (widget.resultBean.fastingStatus == 'END') {
- resultTip = 'assets/images/challenge_success.png';
- } else if (widget.resultBean.fastingStatus == 'TIMEOUT') {
- resultTip = 'assets/images/challenge_done.png';
- }
- var size = MediaQuery.of(context).size;
- double topSpace = 97.px;
- if (size.height<670){
- topSpace = 70.px;
- }
- return Container(
- decoration: BoxDecoration(
- image: DecorationImage(
- image: AssetImage(
- 'assets/images/${widget.resultBean.days}day_result_bg.png'),
- fit: BoxFit.cover),
- ),
- alignment: Alignment.center,
- child: Column(
- children: [
- SizedBox(
- height: topAni.value * topSpace,
- ),
- Opacity(
- opacity: topAni.value,
- child: Image.asset(
- resultTip,
- width: 204.px,
- height: 72.px,
- ),
- ),
- SizedBox(
- height: centerAni.value * 16.px,
- ),
- Opacity(
- opacity: centerAni.value,
- child: Container(
- width: 324.px,
- height: 260.px,
- decoration: BoxDecoration(
- color: const Color(0xCC000D1F),
- borderRadius: BorderRadius.all(Radius.circular(32.px)),
- border: Border.all(color: kThemeColor, width: 1.px),
- image: const DecorationImage(
- image: AssetImage('assets/images/statistic.png'),
- alignment: Alignment.topRight,
- scale: 2.9)),
- child: Statistic(resultBean: widget.resultBean,rate: 1.0,)),
- ),
- // SizedBox(
- // height: (1 - bottomAni.value) * 40.px + 20.px,
- // ),
- const Expanded(
- child: SizedBox(
- width: 0,
- height: 0,
- )),
- Opacity(
- opacity: bottomAni.value,
- child: Column(
- children: [
- Text(
- '邀请好友注册成功',
- style: TextStyle(
- decoration: TextDecoration.none,
- fontWeight: FontWeight.normal,
- fontSize: 12.px,
- color: const Color(0x99FFFFFF)),
- ),
- SizedBox(
- height: 7.px,
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text(
- '我和ta各得逆龄石',
- style: TextStyle(
- decoration: TextDecoration.none,
- fontWeight: FontWeight.normal,
- fontSize: 12.px,
- height: 1.0,
- color: const Color(0x99FFFFFF)),
- ),
- SizedBox(
- width: 2.px,
- ),
- Text(
- '+3',
- style: TextStyle(
- decoration: TextDecoration.none,
- fontWeight: FontWeight.w600,
- fontSize: 14.px,
- height: 1.0,
- fontFamily: 'Exo2',
- color: const Color(0x99FFFFFF)),
- ),
- SizedBox(
- width: 2.px,
- ),
- Image.asset(
- 'assets/images/stone.png',
- width: 14.px,
- height: 14.px,
- )
- ],
- ),
- GestureDetector(
- onTap: () {
- share();
- },
- child: Container(
- width: 228.px,
- height: 48.px,
- margin: EdgeInsets.only(top: 25.px, bottom: 12.px),
- decoration: BoxDecoration(
- borderRadius:
- BorderRadius.all(Radius.circular(24.px)),
- border: Border.all(color: kThemeColor, width: 1.px),
- image: const DecorationImage(
- image: AssetImage('assets/images/invite.png'),
- alignment: Alignment.center,
- scale: 1.8)),
- ),
- ),
- FastBtn(
- title: '完成',
- disable: false,
- width: 228.px,
- height: 48.px,
- callback: () {
- tapDone();
- }),
- SizedBox(
- // height: 50.px,
- height: bottomAni.value * (size.height<812.px?54.px:108.px),
- )
- ],
- ),
- )
- ],
- ));
- }
- tapDone() {
- Navigator.of(context).pop();
- Global().mainPage.showMe();
- /*
- if (widget.resultBean.checkinStatus == 'SUCCESS') {
- //正常打卡
- Global().mainPage.showMe();
- showDialog(
- context: context,
- barrierDismissible: false,
- barrierColor: Colors.transparent,
- builder: (BuildContext context) {
- return Toast(
- title: '准时打卡',
- content: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text(
- '+1',
- style: TextStyle(
- color: Colors.white,
- fontSize: 16.px,
- fontWeight: FontWeight.w800,
- fontFamily: 'Exo2',
- decoration: TextDecoration.none),
- ),
- SizedBox(
- width: 3.px,
- ),
- Image.asset(
- 'assets/images/stone.png',
- width: 24.px,
- height: 24.px,
- )
- ],
- ),
- );
- });
- } else if (widget.resultBean.checkinStatus == 'TIMEOUT') {
- Global().mainPage.showMe();
- showDialog(
- context: context,
- barrierDismissible: false,
- barrierColor: Colors.transparent,
- builder: (BuildContext context) {
- return Toast(
- title: '超时打卡',
- content: const SizedBox(
- width: 0,
- ),
- );
- });
- //超时打卡
- } else {}*/
- Global().homePage.getDatas();
- if (Global().fastKey!.currentContext != null) {
- FastState seekBar = Global().fastKey!.currentState as FastState;
- seekBar.reset();
- }
- }
- }
- // ignore: must_be_immutable
- class Statistic extends StatelessWidget {
- FastResultBean resultBean;
- double rate;
- Statistic({Key? key, required this.resultBean,required this.rate}) : super(key: key);
- @override
- Widget build(BuildContext context) {
- List<Widget> widgets = [title('期末获得')];
- for (int i = 0; i < resultBean.rjvEarningsMax; i++) {
- if (i < resultBean.rjvEarnings) {
- widgets.add(stone());
- } else {
- widgets.add(stoneEmpty());
- }
- }
- return Column(
- children: [
- SizedBox(
- height: 28.px*rate,
- ),
- Row(
- children: [
- title('期初投入'),
- stone(),
- stone(),
- stone(),
- if (resultBean.rjvExpenditure > 3) stone(),
- if (resultBean.rjvExpenditure > 4) stone(),
- if (resultBean.rjvExpenditure > 5) stone(),
- if (resultBean.rjvExpenditure > 6) stone(),
- ],
- ),
- SizedBox(
- height: 10.px*rate,
- ),
- Row(
- children: widgets,
- ),
- Container(
- height: 1.px*rate,
- color: const Color(0x1AFFFFFF),
- margin: EdgeInsets.only(
- left: 32.px*rate, right: 32.px*rate, top: 16.px*rate, bottom: 12.px*rate),
- ),
- Row(
- children: [
- title('净收益'),
- Text(
- '${resultBean.rjvProfit}',
- style: boldStyle(),
- ),
- SizedBox(
- width: 4.px*rate,
- ),
- Container(
- margin: EdgeInsets.only(top: 5.px*rate),
- child: Text(
- '颗逆龄石',
- style: TextStyle(
- decoration: TextDecoration.none,
- color: Colors.white,
- fontWeight: FontWeight.w500,
- fontSize: 14.px*rate,
- height: 1.2,
- ),
- ),
- ),
- ],
- ),
- SizedBox(
- height: 6.px*rate,
- ),
- Row(
- children: [
- title('净收益率'),
- Text(
- '${resultBean.rjvYieldRate}%',
- style: boldStyle(),
- )
- ],
- ),
- Container(
- height: 1.px,
- color: kThemeColor,
- margin: EdgeInsets.only(
- left: 32.px*rate, right: 32.px*rate, top: 21.px*rate, bottom: 21.px*rate),
- ),
- Row(
- children: [
- title('逆龄石余额'),
- stone(),
- Text(
- '×${resultBean.rjvBalance}',
- style: boldStyle(),
- )
- ],
- ),
- ],
- );
- }
- Widget title(str) {
- return Container(
- width: 80.px*rate,
- margin: EdgeInsets.only(left: 32.px*rate),
- child: Text(
- str,
- style: TextStyle(
- decoration: TextDecoration.none,
- color: const Color(0xCCC4CCDA),
- fontWeight: FontWeight.normal,
- fontSize: 14.px*rate,
- height: 1.0,
- ),
- ),
- );
- }
- Widget stone() {
- return Container(
- child: Image.asset(
- 'assets/images/stone.png',
- width: 24.px*rate,
- height: 24.px*rate,
- ),
- margin: EdgeInsets.only(right: 2.px*rate),
- );
- }
- Widget stoneEmpty() {
- return Container(
- child: Image.asset(
- 'assets/images/stone_failed.png',
- width: 24.px*rate,
- height: 24.px*rate,
- ),
- margin: EdgeInsets.only(right: 2.px*rate),
- );
- }
- TextStyle boldStyle() {
- return TextStyle(
- color: Colors.white,
- fontSize: 24.px*rate,
- fontFamily: 'Exo2',
- fontWeight: FontWeight.w600,
- height: 1.0,
- decoration: TextDecoration.none);
- }
- }
|