BonusDialog.dart 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import '../styles/colors.dart';
  4. import '../model/CompetitionInfo.dart';
  5. import '../Constants.dart';
  6. import 'CompetitionRooms.dart';
  7. class BonusDialog extends StatefulWidget {
  8. final List<CompetitionInfo> competitions;
  9. const BonusDialog({Key key, this.competitions}) : super(key: key);
  10. @override
  11. State<StatefulWidget> createState() {
  12. return BonusDialogState();
  13. }
  14. }
  15. class BonusDialogState extends State<BonusDialog> {
  16. final Color primaryColor = Color(0xFF1990F8);
  17. final Color bgColor = Color(0xE6293559);
  18. @override
  19. Widget build(BuildContext context) {
  20. return Column(
  21. mainAxisAlignment: MainAxisAlignment.center,
  22. mainAxisSize: MainAxisSize.min,
  23. children: <Widget>[
  24. Container(
  25. width: 320,
  26. height: 330,
  27. padding: EdgeInsets.all(0),
  28. decoration: BoxDecoration(
  29. color: bgColor,
  30. border: Border.all(width: 1, color: primaryColor)),
  31. child: Builder(builder: (context) {
  32. List<Widget> list = [
  33. Container(
  34. padding: EdgeInsets.fromLTRB(20, 0, 20, 0),
  35. height: 75,
  36. child: Row(
  37. crossAxisAlignment: CrossAxisAlignment.center,
  38. children: <Widget>[
  39. Expanded(
  40. child: Container(
  41. height: 2,
  42. color: Colors.white.withAlpha(72),
  43. ),
  44. ),
  45. Container(
  46. margin: EdgeInsets.only(left: 10, right: 10),
  47. child: Text(
  48. '奖品',
  49. style: TextStyle(
  50. color: Colors.white,
  51. fontSize: 18,
  52. fontWeight: FontWeight.bold),
  53. ),
  54. ),
  55. Expanded(
  56. child: Container(
  57. height: 2,
  58. color: Colors.white.withAlpha(72),
  59. ),
  60. ),
  61. ],
  62. ),
  63. )
  64. ];
  65. for (CompetitionInfo competitionInfo in widget.competitions) {
  66. list.add(bonusItem(competitionInfo));
  67. }
  68. return ListView(
  69. children: list,
  70. padding: EdgeInsets.all(0),
  71. );
  72. }),
  73. ),
  74. Container(
  75. margin: EdgeInsets.only(top: 20),
  76. child: GestureDetector(
  77. child: Image.asset('images/icon_guanbi.png'),
  78. onTap: () {
  79. Navigator.of(context).pop();
  80. },
  81. ),
  82. )
  83. ],
  84. );
  85. }
  86. Widget bonusItem(CompetitionInfo competitionInfo) {
  87. return GestureDetector(
  88. child: Container(
  89. padding: EdgeInsets.only(left: 20, right: 20),
  90. margin: EdgeInsets.only(bottom: 30),
  91. child: Column(
  92. crossAxisAlignment: CrossAxisAlignment.stretch,
  93. children: <Widget>[
  94. Row(
  95. children: <Widget>[
  96. Container(
  97. width: 23,
  98. height: 20,
  99. child: competitionInfo.type == 2
  100. ? Image.asset('images/home_icon_vip1.png')
  101. : Container(),
  102. ),
  103. Expanded(
  104. child: Container(
  105. margin: EdgeInsets.only(left: 10),
  106. child: Text(
  107. competitionInfo.competitionName,
  108. style: TextStyle(
  109. color: Colors.white,
  110. fontSize: 13,
  111. fontWeight: FontWeight.bold),
  112. overflow: TextOverflow.ellipsis,
  113. ),
  114. ),
  115. ),
  116. Container(
  117. width: 46,
  118. height: 20,
  119. color: PRIMARY_COLOR,
  120. child: Center(
  121. child: Text(
  122. '进入',
  123. style: TextStyle(color: Colors.white, fontSize: 12),
  124. ),
  125. ),
  126. ),
  127. ],
  128. ),
  129. Container(
  130. color: Colors.white.withAlpha(30),
  131. margin: EdgeInsets.only(left: 31, top: 7),
  132. height: 1,
  133. ),
  134. Container(
  135. margin: EdgeInsets.only(left: 31, top: 6),
  136. child: Text(
  137. competitionInfo.bonus ?? '',
  138. style: TextStyle(color: Colors.yellow, fontSize: 12),
  139. ),
  140. )
  141. ],
  142. ),
  143. ),
  144. onTap: () {
  145. Navigator.push(
  146. context,
  147. CupertinoPageRoute(
  148. builder: (context) => CompetitionRooms(competitionInfo)));
  149. },
  150. );
  151. }
  152. }
  153. Future showBonusDialog(context, List<CompetitionInfo> competitions) async {
  154. return await showGeneralDialog(
  155. context: context,
  156. barrierDismissible: true,
  157. pageBuilder: (BuildContext buildContext, Animation<double> animation,
  158. Animation<double> secondaryAnimation) {
  159. return Center(
  160. child: Material(
  161. color: Colors.transparent,
  162. child: BonusDialog(competitions: competitions),
  163. ),
  164. );
  165. },
  166. barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
  167. barrierColor: Colors.black87,
  168. transitionDuration: const Duration(milliseconds: 300),
  169. );
  170. }