sport_list_page.dart 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. import 'dart:ui';
  2. import 'package:cached_network_image/cached_network_image.dart';
  3. import 'package:flutter/cupertino.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:flutter_rating_bar/flutter_rating_bar.dart';
  6. import 'package:sport/bean/game.dart';
  7. import 'package:sport/pages/game/game_detail.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,
  34. body: Center(
  35. child: Padding(
  36. padding: const EdgeInsets.fromLTRB(0, 80.0, 0, 20.0),
  37. child: Column(
  38. children: <Widget>[
  39. Padding(
  40. padding: const EdgeInsets.all(12.0),
  41. child: Stack(
  42. alignment: Alignment.center,
  43. children: <Widget>[
  44. Image.asset(
  45. "lib/assets/img/mine_image_achievement.png",
  46. fit: BoxFit.fitWidth,
  47. width: 240,
  48. ),
  49. Text(
  50. "运动列表",
  51. style: Theme.of(context).textTheme.headline4,
  52. strutStyle: fixedLine,
  53. )
  54. ],
  55. ),
  56. ),
  57. Expanded(
  58. child: SingleChildScrollView(
  59. child: Padding(
  60. padding: const EdgeInsets.all(12.0),
  61. child: Column(
  62. children: <Widget>[
  63. Container(
  64. margin: _padding,
  65. child: GameRun(),
  66. decoration: circular(),
  67. ),
  68. FutureBuilder(
  69. future: _future,
  70. builder: (BuildContext context, AsyncSnapshot<RespList<GameInfoData>> snapshot) {
  71. if (snapshot.connectionState != ConnectionState.done) return RequestLoadingWidget();
  72. var list = snapshot.data?.results;
  73. return Column(
  74. children: list
  75. .map((e) => Padding(
  76. padding: _padding,
  77. child: ClipRRect(
  78. borderRadius: BorderRadius.circular(10.0),
  79. child: Container(
  80. color: Colors.white,
  81. child: Row(
  82. children: <Widget>[
  83. CachedNetworkImage(
  84. width: 90.0,
  85. height: 90.0,
  86. fit: BoxFit.cover,
  87. imageUrl: "${e.cover}",
  88. ),
  89. const SizedBox(
  90. width: 12.0,
  91. ),
  92. Expanded(
  93. child: Column(
  94. crossAxisAlignment: CrossAxisAlignment.start,
  95. children: <Widget>[
  96. Text(
  97. e.name,
  98. style: Theme.of(context).textTheme.headline3,
  99. ),
  100. Text(
  101. "${e.userCount}人在练",
  102. style: Theme.of(context).textTheme.bodyText1,
  103. ),
  104. const SizedBox(
  105. height: 5,
  106. ),
  107. Row(
  108. children: <Widget>[
  109. Text(
  110. "难度: ",
  111. style: Theme.of(context).textTheme.bodyText1,
  112. ),
  113. RatingBarIndicator(
  114. rating: e.difficulty / 20.0,
  115. itemBuilder: (context, index) => Image.asset(
  116. "lib/assets/img/con_icon_difficulty_normal.png",
  117. color: const Color(0xffFFC400),
  118. ),
  119. itemCount: 5,
  120. itemSize: 14.0,
  121. unratedColor: const Color(0xffCECECE),
  122. direction: Axis.horizontal,
  123. )
  124. ],
  125. )
  126. ],
  127. ),
  128. ),
  129. Container(
  130. width: 120.0,
  131. child: PositionedBottom(
  132. e,
  133. (v) {
  134. startGame(context, e);
  135. },
  136. height: 35.0,
  137. width: 93.0,
  138. textStyle: TextStyle(
  139. color: Colors.white,
  140. fontSize: 14.0,
  141. ),
  142. ),
  143. )
  144. ],
  145. ),
  146. )),
  147. ))
  148. .toList());
  149. },
  150. )
  151. ],
  152. ),
  153. ),
  154. ),
  155. ),
  156. GestureDetector(
  157. behavior: HitTestBehavior.opaque,
  158. onTap: () => Navigator.maybePop(context),
  159. child: Padding(
  160. padding: const EdgeInsets.all(8.0),
  161. child: Image.asset("lib/assets/img/pop_share_chose.png"),
  162. ),
  163. ),
  164. ],
  165. ),
  166. ),
  167. ),
  168. ),
  169. );
  170. }
  171. }