import 'package:flutter/material.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; import '../model/HouseInfo.dart'; import '../widget/LinearButton.dart'; //竞赛须知 class CompetitionInformation extends StatefulWidget { HouseInfo houseInfo; CompetitionInformation(this.houseInfo); @override CompetitionInformationState createState() => CompetitionInformationState(); } class CompetitionInformationState extends State { int nowSwiperIndex = 0; SwiperController _swiperController; @override void initState() { super.initState(); _swiperController = SwiperController(); } @override Widget build(BuildContext context) { return WillPopScope( child: Scaffold( backgroundColor: Colors.black87, body: Container( child: Center( child: Swiper( controller: _swiperController, layout: SwiperLayout.DEFAULT, itemWidth: 270.0, itemHeight: 422.0, control: SwiperControl(color: Theme.of(context).primaryColor, disableColor: Colors.transparent), index: nowSwiperIndex, itemCount: 4, scrollDirection: Axis.horizontal, loop: false, itemBuilder: (context, index) { return InfoBox( houseInfo: widget.houseInfo, typeIndex: index + 1, next: () { _swiperController.next(); }, end: () { Navigator.of(context).pop(); }); }))), ), onWillPop: () { return Future.value(false); }, ); } } typedef OnTapHomeMenu = void Function(); class InfoBox extends StatelessWidget { InfoBox({Key key, this.typeIndex, this.next, this.end, this.houseInfo}) : super(key: key); final int typeIndex; final OnTapHomeMenu next; final OnTapHomeMenu end; final HouseInfo houseInfo; @override Widget build(BuildContext context) { return UnconstrainedBox( child: Container( width: 270, height: 422, decoration: BoxDecoration(border: Border.all(width: 1, color: Theme.of(context).primaryColor), color: Colors.black), child: Stack( children: [ Container( width: 270, padding: EdgeInsets.only(top: 25), child: Column( children: [ Text('竞赛须知 ' + typeIndex.toString() + '/4', style: TextStyle(color: Color(0xFFC2524D), fontSize: 20, fontWeight: FontWeight.w600)), _centerContent(typeIndex, context) ], ), ), Positioned( top: 0, left: 0, child: Image.asset( 'images/tancuang_shang.png', // width: 131, ), ), Positioned( bottom: 0, right: 4, child: Image.asset( 'images/tancuang_xia.png', // width: 148, ), ), Positioned( bottom: 15, left: 25, child: Column( children: [ Container( width: 220, height: 36, child: LinearButton( btntext: typeIndex != 4 ? '下一个' : '知道了', onTapHomeMenu: typeIndex != 4 ? next : end, ) // RaisedButton( // textColor: Colors.white, // child: Text(typeIndex != 4 ? '下一个' : '结束'), // onPressed: typeIndex != 4 ? next : end, // ), ), typeIndex!=4? FlatButton( textColor: Color(0xFF727785), highlightColor: Colors.transparent, splashColor: Colors.transparent, child: Text('关闭'), onPressed: () { end(); }, ):Container( width: 10, height: 43, ) ], ), ) ], ), )); } // 第一名获得${houseInfo.houseLevel.firstRatio}%,第二名获得${houseInfo.houseLevel.secondRatio}%,第三名获得${houseInfo.houseLevel.thirdRatio}% Widget _centerContent(int index, BuildContext context) { Widget useContent = Container(); TextStyle _text = TextStyle(color: Colors.white, fontSize: 14); if (index == 1) { useContent = Container( margin: EdgeInsets.only(top: 20), padding: EdgeInsets.symmetric(horizontal: 20), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( '吃鸡模式', style: TextStyle(color: Color(0xFFFFB726)), ), Text('胜利条件:只要在游戏中成功吃鸡,即可获得一枚铂金奖牌,没有吃鸡即算做失败', style: TextStyle(color: Colors.white)), Container( height: 15, ), Text('评分模式', style: TextStyle(color: Color(0xFFFFB726))), Text('胜利条件:不管游戏最终是否吃鸡,按游戏最终显示评分数值进行排序,评分相同用时短者优胜,前三名分别获得金银铜奖牌,其它人算做失败', style: TextStyle(color: Colors.white)) ], ), ); } else if (index == 2) { useContent = Container( margin: EdgeInsets.only(top: 20), padding: EdgeInsets.symmetric(horizontal: 20), child: Column( children: [ Image.asset('images/img_xuzhi_02.png', width: 136), Container( height: 10, ), Text.rich( TextSpan(children: [ TextSpan( text: '竞赛开始前请在此耐心等待,在开始时会有上图所示弹窗,', style: _text, ), TextSpan( text: '玩家必须在10秒内点击确认', style: TextStyle(color: Color(0xFFFFB726), fontSize: 14, fontWeight: FontWeight.w500), ), TextSpan( text: ',否则视为放弃此次竞赛,已支付参赛券概不退换', style: _text, ) ]), textAlign: TextAlign.center) ], ), ); } else if (index == 3) { useContent = Container( margin: EdgeInsets.only(top: 20), padding: EdgeInsets.symmetric(horizontal: 20), child: Column( children: [ Image.asset('images/img_xuzhi_03.png', width: 176), Container( height: 10, ), Text.rich( TextSpan(children: [ TextSpan( text: '确认竞赛后会有弹窗提示授权进行录屏的操作,请一定', style: _text, ), TextSpan( text: '点击“确定”', style: TextStyle(color: Color(0xFFFFB726), fontSize: 14, fontWeight: FontWeight.w500), ), TextSpan( text: '或', style: _text, ), TextSpan( text: '“允许”', style: TextStyle(color: Color(0xFFFFB726), fontSize: 14, fontWeight: FontWeight.w500), ), TextSpan( text: '此操作,否则竞赛判定失败', style: _text, ) ]), textAlign: TextAlign.center) ], ), ); } else if (index == 4) { useContent = Container( margin: EdgeInsets.only(top: 20), padding: EdgeInsets.symmetric(horizontal: 20), child: Column( children: [ Image.asset('images/img_xuzhi_04.png', width: 216), Container( height: 10, ), Text.rich( TextSpan(children: [ TextSpan( text: '在游戏比赛结束后,', style: _text, ), TextSpan( text: '请一定要点击查看游戏最后的分数名次结算页面', style: TextStyle(color:Color(0xFFFFB726), fontSize: 14, fontWeight: FontWeight.w600), ), TextSpan( text: ',返回游戏主页,最后再切换到我们竞赛app中,点击完成比赛,方可成功长传本次成绩,赢取大奖', style: _text, ) ]), textAlign: TextAlign.center) ], ), ); } return useContent; } }