| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import '../styles/colors.dart';
- import '../model/CompetitionInfo.dart';
- import '../Constants.dart';
- import 'CompetitionRooms.dart';
- class BonusDialog extends StatefulWidget {
- final List<CompetitionInfo> competitions;
- const BonusDialog({Key key, this.competitions}) : super(key: key);
- @override
- State<StatefulWidget> createState() {
- return BonusDialogState();
- }
- }
- class BonusDialogState extends State<BonusDialog> {
- final Color primaryColor = Color(0xFF1990F8);
- final Color bgColor = Color(0xE6293559);
- @override
- Widget build(BuildContext context) {
- return Column(
- mainAxisAlignment: MainAxisAlignment.center,
- mainAxisSize: MainAxisSize.min,
- children: <Widget>[
- Container(
- width: 320,
- height: 330,
- padding: EdgeInsets.all(0),
- decoration: BoxDecoration(
- color: bgColor,
- border: Border.all(width: 1, color: primaryColor)),
- child: Builder(builder: (context) {
- List<Widget> list = [
- Container(
- padding: EdgeInsets.fromLTRB(20, 0, 20, 0),
- height: 75,
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: <Widget>[
- Expanded(
- child: Container(
- height: 2,
- color: Colors.white.withAlpha(72),
- ),
- ),
- Container(
- margin: EdgeInsets.only(left: 10, right: 10),
- child: Text(
- '奖品',
- style: TextStyle(
- color: Colors.white,
- fontSize: 18,
- fontWeight: FontWeight.bold),
- ),
- ),
- Expanded(
- child: Container(
- height: 2,
- color: Colors.white.withAlpha(72),
- ),
- ),
- ],
- ),
- )
- ];
- for (CompetitionInfo competitionInfo in widget.competitions) {
- list.add(bonusItem(competitionInfo));
- }
- return ListView(
- children: list,
- padding: EdgeInsets.all(0),
- );
- }),
- ),
- Container(
- margin: EdgeInsets.only(top: 20),
- child: GestureDetector(
- child: Image.asset('images/icon_guanbi.png'),
- onTap: () {
- Navigator.of(context).pop();
- },
- ),
- )
- ],
- );
- }
- Widget bonusItem(CompetitionInfo competitionInfo) {
- return GestureDetector(
- child: Container(
- padding: EdgeInsets.only(left: 20, right: 20),
- margin: EdgeInsets.only(bottom: 30),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: <Widget>[
- Row(
- children: <Widget>[
- Container(
- width: 23,
- height: 20,
- child: competitionInfo.type == 2
- ? Image.asset('images/home_icon_vip1.png')
- : Container(),
- ),
- Expanded(
- child: Container(
- margin: EdgeInsets.only(left: 10),
- child: Text(
- competitionInfo.competitionName,
- style: TextStyle(
- color: Colors.white,
- fontSize: 13,
- fontWeight: FontWeight.bold),
- overflow: TextOverflow.ellipsis,
- ),
- ),
- ),
- Container(
- width: 46,
- height: 20,
- color: PRIMARY_COLOR,
- child: Center(
- child: Text(
- '进入',
- style: TextStyle(color: Colors.white, fontSize: 12),
- ),
- ),
- ),
- ],
- ),
- Container(
- color: Colors.white.withAlpha(30),
- margin: EdgeInsets.only(left: 31, top: 7),
- height: 1,
- ),
- Container(
- margin: EdgeInsets.only(left: 31, top: 6),
- child: Text(
- competitionInfo.bonus ?? '',
- style: TextStyle(color: Colors.yellow, fontSize: 12),
- ),
- )
- ],
- ),
- ),
- onTap: () {
- Navigator.push(
- context,
- CupertinoPageRoute(
- builder: (context) => CompetitionRooms(competitionInfo)));
- },
- );
- }
- }
- Future showBonusDialog(context, List<CompetitionInfo> competitions) async {
- return await showGeneralDialog(
- context: context,
- barrierDismissible: true,
- pageBuilder: (BuildContext buildContext, Animation<double> animation,
- Animation<double> secondaryAnimation) {
- return Center(
- child: Material(
- color: Colors.transparent,
- child: BonusDialog(competitions: competitions),
- ),
- );
- },
- barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
- barrierColor: Colors.black87,
- transitionDuration: const Duration(milliseconds: 300),
- );
- }
|