sport_list_page.dart 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. import 'dart:ui';
  2. import 'package:cached_network_image/cached_network_image.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_rating_bar/flutter_rating_bar.dart';
  5. import 'package:sport/bean/game.dart';
  6. import 'package:sport/pages/game/game_detail.dart';
  7. import 'package:sport/router/navigator_util.dart';
  8. import 'package:sport/services/api/inject_api.dart';
  9. import 'package:sport/services/api/resp.dart';
  10. import 'package:sport/widgets/decoration.dart';
  11. import 'package:sport/widgets/game_run.dart';
  12. import 'package:sport/widgets/loading.dart';
  13. import 'package:sport/widgets/misc.dart';
  14. class SportListPage extends StatefulWidget {
  15. SportListPage();
  16. @override
  17. State<StatefulWidget> createState() => _PageState();
  18. }
  19. class _PageState extends State<SportListPage> with InjectApi {
  20. Future<RespList<GameInfoData>> _future;
  21. @override
  22. void initState() {
  23. super.initState();
  24. _future = api.getGameAll();
  25. }
  26. @override
  27. Widget build(BuildContext context) {
  28. var _padding = const EdgeInsets.symmetric(vertical: 6.0);
  29. return BackdropFilter(
  30. //背景滤镜
  31. filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
  32. child: Scaffold(
  33. backgroundColor: Colors.transparent.withOpacity(0.5),
  34. body: GestureDetector(
  35. onTap: () => Navigator.maybePop(context),
  36. behavior: HitTestBehavior.opaque,
  37. child: Center(
  38. child: Padding(
  39. padding: const EdgeInsets.fromLTRB(0, 80.0, 0, 20.0),
  40. child: Column(
  41. children: <Widget>[
  42. Padding(
  43. padding: const EdgeInsets.all(12.0),
  44. child: Stack(
  45. alignment: Alignment.center,
  46. children: <Widget>[
  47. Image.asset(
  48. "lib/assets/img/mine_image_achievement.png",
  49. fit: BoxFit.fitWidth,
  50. width: 240,
  51. ),
  52. Text(
  53. "运动列表",
  54. style: Theme.of(context).textTheme.headline4,
  55. strutStyle: fixedLine,
  56. )
  57. ],
  58. ),
  59. ),
  60. Expanded(
  61. child: SingleChildScrollView(
  62. child: Padding(
  63. padding: const EdgeInsets.all(12.0),
  64. child: Column(
  65. children: <Widget>[
  66. Container(
  67. margin: _padding,
  68. child: GameRun(),
  69. decoration: circular(),
  70. ),
  71. FutureBuilder(
  72. future: _future,
  73. builder: (BuildContext context, AsyncSnapshot<RespList<GameInfoData>> snapshot) {
  74. if (snapshot.connectionState != ConnectionState.done) return RequestLoadingWidget();
  75. var list = snapshot.data?.results;
  76. return Column(
  77. children: list
  78. .map((e) => Padding(
  79. padding: _padding,
  80. child: GestureDetector(
  81. onTap: () => NavigatorUtil.goPage(context, (context) => GameDetailsPage(e)),
  82. child: ClipRRect(
  83. borderRadius: BorderRadius.circular(10.0),
  84. child: Container(
  85. color: Colors.white,
  86. child: Row(
  87. children: <Widget>[
  88. CachedNetworkImage(
  89. width: 90.0,
  90. height: 90.0,
  91. fit: BoxFit.cover,
  92. imageUrl: "${e.cover}",
  93. ),
  94. const SizedBox(
  95. width: 12.0,
  96. ),
  97. Expanded(
  98. child: Column(
  99. crossAxisAlignment: CrossAxisAlignment.start,
  100. children: <Widget>[
  101. Text(
  102. e.name,
  103. style: Theme.of(context).textTheme.headline3,
  104. ),
  105. const SizedBox(
  106. height: 3,
  107. ),
  108. Text(
  109. "${e.userCount}人在练",
  110. style: Theme.of(context).textTheme.bodyText1,
  111. ),
  112. const SizedBox(
  113. height: 5,
  114. ),
  115. Row(
  116. children: <Widget>[
  117. Text(
  118. "难度: ",
  119. style: Theme.of(context).textTheme.bodyText1,
  120. ),
  121. RatingBarIndicator(
  122. rating: e.difficulty / 20.0,
  123. itemBuilder: (context, index) => Image.asset(
  124. "lib/assets/img/con_icon_difficulty_normal.png",
  125. color: const Color(0xffFFC400),
  126. ),
  127. itemCount: 5,
  128. itemSize: 14.0,
  129. unratedColor: const Color(0xffCECECE),
  130. direction: Axis.horizontal,
  131. )
  132. ],
  133. )
  134. ],
  135. ),
  136. ),
  137. Container(
  138. width: 120.0,
  139. child: PositionedBottom(
  140. e,
  141. (v) {
  142. startGame(context, e);
  143. },
  144. height: 35.0,
  145. width: 93.0,
  146. textStyle: TextStyle(
  147. color: Colors.white,
  148. fontSize: 14.0,
  149. ),
  150. ),
  151. )
  152. ],
  153. ),
  154. )),
  155. )))
  156. .toList());
  157. },
  158. )
  159. ],
  160. ),
  161. ),
  162. ),
  163. ),
  164. GestureDetector(
  165. behavior: HitTestBehavior.opaque,
  166. onTap: () => Navigator.maybePop(context),
  167. child: Padding(
  168. padding: const EdgeInsets.all(8.0),
  169. child: Image.asset("lib/assets/img/pop_share_chose.png"),
  170. ),
  171. ),
  172. ],
  173. ),
  174. ),
  175. ),
  176. ),
  177. ),
  178. );
  179. }
  180. }