import 'package:flutter/material.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; import '../model/HouseInfo.dart'; //竞赛须知 class CompetitionInformation extends StatefulWidget { final 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: Color(0xFFC2524D), 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 = int 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: Color(0xFFC2524D)), 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(0xFFFDC372), fontSize: 20, fontWeight: FontWeight.bold)), _centerContent(typeIndex) ], ), ), 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: RaisedButton( textColor: Colors.white, child: Text(typeIndex != 4 ? '下一个' : '结束'), onPressed: typeIndex != 4 ? next : end, ), ), FlatButton( textColor: Color(0xFF727785), highlightColor: Colors.transparent, splashColor: Colors.transparent, child: Text('关闭'), onPressed: () { end(); }, ) ], ), ) ], ), )); } // 第一名获得${houseInfo.houseLevel.firstRatio}%,第二名获得${houseInfo.houseLevel.secondRatio}%,第三名获得${houseInfo.houseLevel.thirdRatio}% Widget _centerContent(int index) { Widget useContent = Container(); TextStyle _text = TextStyle(color: Colors.white, fontSize: 14); if (index == 1 && houseInfo.scoreType == 0) { useContent = Container( margin: EdgeInsets.only(top: 22), padding: EdgeInsets.symmetric(horizontal: 20), child: Column( children: [ Image.asset('images/icon_jinbi_da_hong.png', width: 30), Container( height: 20, ), Text( '房间人数越多,总奖金就越多', style: _text, ), Text('同房间内玩家进行竞赛,吃上鸡的评分前三名玩家获得相应奖励', style: _text, textAlign: TextAlign.center), // Text('同房间内玩家进行竞赛', style: _text), Text.rich(TextSpan(children: [ TextSpan(text: '第一名获得奖金池的', style: _text), TextSpan( text: '${houseInfo.houseLevel.firstRatio}%', style: TextStyle(color: Color(0xFFC2524D), fontSize: 13), ), ])), Text.rich(TextSpan(children: [ TextSpan(text: '第二名获得奖金池的', style: _text), TextSpan( text: '${houseInfo.houseLevel.secondRatio}%', style: TextStyle(color: Color(0xFFC2524D), fontSize: 13), ), ])), Text.rich(TextSpan(children: [ TextSpan(text: '第三名获得奖金池的', style: _text), TextSpan( text: '${houseInfo.houseLevel.thirdRatio}%', style: TextStyle(color: Color(0xFFC2524D), fontSize: 13), ), ])), Container( margin: EdgeInsets.only(top: 10), width: double.infinity, child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( '注:奖金池的${houseInfo.houseLevel.feeRatio}%为平台方运营服务费', style: TextStyle(fontSize: 11, color: Color.fromARGB(50, 255, 255, 255)), ), Padding( padding: EdgeInsets.only(left: 20), child: Text(' 奖金池的${houseInfo.houseLevel.poolRatio}%流入赛季总奖金', style: TextStyle(fontSize: 11, color: Color.fromARGB(50, 255, 255, 255)))) ], ), ) ], ), ); } else if (index == 1 && houseInfo.scoreType == 1) { useContent = Container( margin: EdgeInsets.only(top: 22), padding: EdgeInsets.symmetric(horizontal: 20), child: Column( children: [ Image.asset('images/icon_jinbi_da_hong.png', width: 30), Container( height: 20, ), Text( '房间人数越多,总奖金就越多', style: _text, ), Text('同房间内的玩家进行竞赛,所有吃上鸡的玩家均可获得奖金', style: _text, textAlign: TextAlign.center), Text.rich(TextSpan(children: [ TextSpan(text: '即平分总奖金池的', style: _text), TextSpan( text: '${houseInfo.houseLevel.avgRatio}%', style: TextStyle(color: Color(0xFFC2524D), fontSize: 13), ), ])), Container( margin: EdgeInsets.only(top: 44), width: double.infinity, child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( '注:奖金池的${houseInfo.houseLevel.feeRatio}%为平台方运营服务费', style: TextStyle(fontSize: 11, color: Color.fromARGB(50, 255, 255, 255)), ), Padding( padding: EdgeInsets.only(left: 20), child: Text(' 奖金池的${houseInfo.houseLevel.poolRatio}%流入赛季总奖金', style: TextStyle(fontSize: 11, color: Color.fromARGB(50, 255, 255, 255)))) ], ), ) ], ), ); } 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: '竞赛开始前请在此耐心等待,在开始时会有上图所示弹窗,玩家必须在10秒内', style: _text, ), TextSpan( text: '点击确认', style: TextStyle(color: Color(0xFFC2524D), fontSize: 14, fontWeight: FontWeight.bold), ), 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(0xFFC2524D), fontSize: 14, fontWeight: FontWeight.bold), ), 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(0xFFC2524D), fontSize: 14, fontWeight: FontWeight.bold), ), TextSpan( text: ',显示到上图所示画面,然后再切换到我们全民APP中,点击完成比赛,方可成功上传本次成绩,赢取大奖', style: _text, ) ]), textAlign: TextAlign.center) ], ), ); } return useContent; } }