| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- import 'package:trackoffical_app/pb.dart' as pb;
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import 'package:trackoffical_app/screen.dart';
- import 'package:trackoffical_app/service/app.dart';
- import 'package:trackoffical_app/utils.dart';
- import '../../../generated/assets.dart';
- import '../../../route.dart';
- import '../dialog/dialog_base.dart';
- import '../dialog/dialog_button.dart';
- enum _State{
- success,
- ok,
- fail
- }
- void dialogFinishResult(pb.GameDetailReply data) {
- if(Get.isOverlaysOpen){
- Get.back();
- }
- var state = _State.success;
- var title = '恭喜!挑战成功';
- var titleColor = const Color(0xFFFF870D);
- Color? buttonColor = const Color(0xFF017DC7);
- var soundSrc = Assets.soundFinishSuccess;
- if(!data.isSuccess){
- state = _State.ok;
- }
- if(!data.isComplete){
- state=_State.fail;
- }
- switch(state){
- case _State.ok:
- title = '挑战完成';
- titleColor = Colors.red;
- buttonColor = null;
- soundSrc = Assets.soundFinishOk;
- break;
- case _State.fail:
- title = '挑战失败';
- titleColor = Colors.red;
- buttonColor = null;
- soundSrc = Assets.soundFinishFail;
- break;
- default:
- }
- App.to.soundPlayAsset(soundSrc);
- final minutes = data.duration.toDuration().inSeconds.toDouble() /
- Duration.secondsPerMinute;
- final distanceKm = data.distance.toDouble() / 1000;
- final kcal = data.calorie.toDouble() / 1000;
- Get.dialog(
- WillPopScope(
- onWillPop: () async{
- _goNext();
- return false;
- },
- child: dialogTitle(
- title,
- titleColor,
- Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Card(
- child: Padding(
- padding: EdgeInsets.fromLTRB(
- 41.1.rpx,
- 10.1.rpx,
- 41.1.rpx,
- 10.1.rpx,
- ),
- child: Column(
- children: [
- _elem(Assets.imagesIcFinishTime, '总用时',
- minutes.toStringAsFixed(1), ' min '),
- _elem(Assets.imagesIcFinishTime, '总里程',
- distanceKm.toStringAsFixed(1), ' km '),
- _elem(Assets.imagesIcFinishTime, '消耗卡路里',
- kcal.toStringAsFixed(1), ' kcal'),
- _elem(Assets.imagesIcFinishTime, '脑力值',
- data.answerHistory.accuracy.toString(), ' % '),
- ],
- )),
- ),
- SizedBox(height: 30.0.rpx),
- Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Image.asset(Assets.imagesIcBean, height: 103.9.rpx),
- Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Text('X ${data.sysPoint}',
- style: TextStyle(fontSize: 53.44.rpx)),
- Text('共获得${data.sysPoint}个百味豆',
- style: TextStyle(
- fontSize: 22.9.rpx,
- color: const Color(0xFFaaaaaa))),
- ],
- )
- ],
- ),
- SizedBox(height: 30.0.rpx),
- dialogButton('确定', _goNext, color: buttonColor),
- SizedBox(height: 30.0.rpx),
- Text(
- '提示:可以在“成就”中查看详细数据',
- style: TextStyle(color: Colors.red, fontSize: 28.63.rpx),
- )
- ],
- )),),
- barrierDismissible: false
- );
- }
- void _goNext(){
- Get.offAllNamed(RouteName.home);
- }
- Widget _elem(String iconSrc, String title, String value, String unit) {
- final style = TextStyle(
- fontSize: 45.8.rpx,
- fontWeight: FontWeight.w500,
- color: const Color(0xff333333));
- return Padding(
- padding: EdgeInsets.only(top: 21.0.rpx, bottom: 21.0.rpx),
- child: Row(
- children: [
- Image.asset(iconSrc, height: 45.8.rpx),
- SizedBox(width: 9.5.rpx),
- Expanded(
- child: Text(
- title,
- style: style.copyWith(fontSize: 34.35.rpx),
- )),
- RichText(
- text: TextSpan(text: value, style: style, children: [
- TextSpan(
- text: unit,
- style: style.copyWith(
- fontSize: 19.1.rpx, color: const Color(0xff818181)),
- ),
- ]))
- ],
- ));
- }
|