SecondRoomInfo.dart 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. import 'package:flutter/material.dart';
  2. import '../model/PlayerInfo.dart';
  3. import 'dart:async';
  4. import '../styles/totast.dart';
  5. import '../net/HttpManager.dart';
  6. import '../net/Result.dart';
  7. import '../styles/colors.dart';
  8. import 'package:flutter/cupertino.dart';
  9. import 'VideoPlayer.dart';
  10. import '../model/HouseInfo.dart';
  11. class SecondPage extends StatefulWidget {
  12. SecondPage({Key key, this.roomId, this.status, this.houseInfo}) : super(key: key);
  13. final String roomId; // 用来储存传递过来的值
  14. final int status;
  15. final HouseInfo houseInfo;
  16. @override
  17. SecondPageState createState() => SecondPageState();
  18. }
  19. class SecondPageState extends State<SecondPage> {
  20. List<PlayerInfo> joinList = [];
  21. int currentPage = 1;
  22. bool ismore = true;
  23. ScrollController _perController;
  24. List jiangpaiImg = ['images/jiangpai_huangjin.png', 'images/jiangpai_baiyin.png', 'images/jiangpai_qingtong.png', 'images/jiangpai_bojin.png'];
  25. //获取房间用户
  26. Future<void> getPlayerPage() async {
  27. ismore = false;
  28. Toast.show(context, '加载中', -1, 'loading');
  29. Result res = await HttpManager.get('playerInfo/rankPage', data: {'houseId': widget.roomId, 'currentPage': currentPage, 'pageNumber': 20});
  30. Toast.hide();
  31. List<PlayerInfo> list = joinList;
  32. if (currentPage == 1) {
  33. list = [];
  34. }
  35. if (res.success) {
  36. print(res.data['pp']);
  37. for (var item in res.data['pp']) {
  38. PlayerInfo jonPlayer = PlayerInfo.fromJson(item);
  39. list.add(jonPlayer);
  40. }
  41. if (res.data['page']['currentPage'] < res.data['page']['totalPage']) {
  42. ismore = true;
  43. }
  44. } else {}
  45. setState(() {
  46. joinList = list;
  47. });
  48. }
  49. @override
  50. void initState() {
  51. super.initState();
  52. _perController = ScrollController();
  53. currentPage = 1;
  54. Future.delayed(Duration.zero, () {
  55. getPlayerPage();
  56. _perController.addListener(() {
  57. if (_perController.position.pixels == _perController.position.maxScrollExtent) {
  58. if (ismore) {
  59. currentPage++;
  60. getPlayerPage();
  61. }
  62. }
  63. });
  64. });
  65. }
  66. @override
  67. void dispose() {
  68. super.dispose();
  69. _perController.dispose();
  70. }
  71. @override
  72. Widget build(BuildContext context) {
  73. return RefreshIndicator(
  74. color: PRIMARY_COLOR,
  75. backgroundColor: Colors.white,
  76. displacement: 10,
  77. onRefresh: () async {
  78. await Future.delayed(const Duration(seconds: 1));
  79. currentPage = 1;
  80. getPlayerPage();
  81. },
  82. child: ListView.builder(
  83. physics: AlwaysScrollableScrollPhysics(),
  84. controller: _perController,
  85. itemCount: joinList.length + 2,
  86. itemBuilder: (BuildContext context, int index) {
  87. if (index == 0 && widget.houseInfo.customerService!=null) {
  88. return Container(
  89. width: double.infinity,
  90. height: 60,
  91. color: Color(0xFF2B2B42),
  92. padding: EdgeInsets.only(left: 15, right: 15),
  93. child: Row(
  94. children: <Widget>[
  95. ClipOval(
  96. child: CircleAvatar(
  97. backgroundImage: NetworkImage(widget.houseInfo.customerService.icon),
  98. ),
  99. ),
  100. Container(
  101. width: 12,
  102. ),
  103. Text(
  104. widget.houseInfo.customerService.serviceName + ' QQ:' + widget.houseInfo.customerService.qq,
  105. style: TextStyle(
  106. color: Colors.white,
  107. fontSize: 14,
  108. ),
  109. )
  110. ],
  111. ));
  112. } else if (index - 1 < joinList.length) {
  113. return PersonItem(joinList[index - 1], index - 1);
  114. } else {
  115. return Container(
  116. padding: EdgeInsets.all(15),
  117. child: Text(
  118. '其他人员正在火速赶来中...',
  119. style: TextStyle(color: Colors.white30),
  120. textAlign: TextAlign.center,
  121. ),
  122. );
  123. }
  124. }),
  125. );
  126. }
  127. Widget PersonItem(PlayerInfo info, int index) {
  128. String img = '';
  129. if (info.statusFlag != 7 && info.statusFlag != 9 && !info.dataError && info.statusFlag != 6 && info.killNumber >= info.needkill) {
  130. if (info.houseRank == 1) {
  131. img = jiangpaiImg[0];
  132. } else if (info.houseRank == 2) {
  133. img = jiangpaiImg[1];
  134. } else if (info.houseRank == 3) {
  135. img = jiangpaiImg[2];
  136. }
  137. }
  138. return Container(
  139. width: double.infinity,
  140. height: 60,
  141. color: Color(0xFF2B2B42),
  142. margin: EdgeInsets.only(top: 0),
  143. padding: EdgeInsets.only(left: 15, right: 15),
  144. child: Container(
  145. decoration: BoxDecoration(border: Border(bottom: BorderSide(width: 1, color: BG_SUB_COLOR, style: BorderStyle.solid))),
  146. child: Row(
  147. children: <Widget>[
  148. Container(
  149. margin: EdgeInsets.only(right: 12),
  150. width: 36,
  151. height: 36,
  152. child: info.userInfo != null
  153. ? CircleAvatar(
  154. backgroundImage: NetworkImage(info.userInfo.icon),
  155. )
  156. : Container(),
  157. ),
  158. Expanded(
  159. flex: 1,
  160. child: Text(
  161. info.userInfo != null ? info.userInfo.nickname : '',
  162. style: TextStyle(
  163. color: Colors.white,
  164. fontSize: 14,
  165. ),
  166. maxLines: 1,
  167. overflow: TextOverflow.ellipsis,
  168. ),
  169. ),
  170. (widget.status == 4 && index < 3 && info.video != '' && info.video != null && img != '')
  171. ? Container(
  172. width: 68,
  173. height: 24,
  174. margin: EdgeInsets.only(right: 30),
  175. child: OutlineButton(
  176. textColor: PRIMARY_COLOR,
  177. borderSide: BorderSide(color: PRIMARY_COLOR),
  178. padding: EdgeInsets.all(0),
  179. highlightColor: BG_SUB_COLOR.withOpacity(0.8),
  180. highlightedBorderColor: PRIMARY_COLOR,
  181. child: Text(
  182. '查看回放',
  183. style: TextStyle(fontSize: 12),
  184. ),
  185. onPressed: () =>
  186. {Navigator.push(context, CupertinoPageRoute(builder: (context) => VideoPlayerPage(videoUrl: info.video, fileType: 'netWork')))},
  187. ),
  188. )
  189. : Container(),
  190. img != ''
  191. ? Image.asset(
  192. img,
  193. width: 32,
  194. )
  195. : Text('')
  196. ],
  197. ),
  198. ),
  199. );
  200. }
  201. }