| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- import 'package:cached_network_image/cached_network_image.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_redux/flutter_redux.dart';
- import 'package:wanna_battle/model/HouseInfo.dart';
- import 'package:wanna_battle/redux/AppState.dart';
- import '../model/PlayerInfo.dart';
- import 'dart:async';
- import '../styles/totast.dart';
- import '../net/HttpManager.dart';
- import '../net/Result.dart';
- import '../styles/colors.dart';
- import 'package:flutter/cupertino.dart';
- import 'VideoPlayer.dart';
- import '../Constants.dart';
- class SecondPage extends StatefulWidget {
- SecondPage(this.houseInfo, {Key key, this.playerInfo}) : super(key: key);
- final HouseInfo houseInfo; // 用来储存传递过来的值
- final PlayerInfo playerInfo;
- @override
- SecondPageState createState() => SecondPageState();
- }
- class SecondPageState extends State<SecondPage> {
- List<PlayerInfo> joinList = [];
- int currentPage = 1;
- bool ismore = true;
- ScrollController _perController;
- //获取房间用户
- Future<void> getPlayerPage() async {
- ismore = false;
- Toast.show(context, '加载中', -1, 'loading');
- Result res = await HttpManager.get('playerInfo/rankPage', data: {'houseId': widget.houseInfo.id, 'currentPage': currentPage, 'pageNumber': 20});
- Toast.hide();
- List<PlayerInfo> list = joinList;
- if (res.success) {
- if (currentPage == 1) {
- list = [];
- }
- for (var item in res.data['pp']) {
- PlayerInfo jonPlayer = PlayerInfo.fromJson(item);
- list.add(jonPlayer);
- }
- if (res.data['page']['currentPage'] < res.data['page']['totalPage']) {
- ismore = true;
- }
- } else {}
- setState(() {
- joinList = list;
- });
- }
- @override
- void initState() {
- super.initState();
- _perController = ScrollController();
- currentPage = 1;
- Future.delayed(Duration.zero, () {
- getPlayerPage();
- _perController.addListener(() {
- if (_perController.position.pixels == _perController.position.maxScrollExtent) {
- if (ismore) {
- currentPage++;
- getPlayerPage();
- }
- }
- });
- });
- }
- @override
- void dispose() {
- super.dispose();
- _perController.dispose();
- }
- @override
- Widget build(BuildContext context) {
- return Column(
- children: <Widget>[
- Expanded(
- child: RefreshIndicator(
- color: PRIMARY_COLOR,
- backgroundColor: Colors.white,
- displacement: 10,
- onRefresh: () async {
- await Future.delayed(const Duration(seconds: 1));
- currentPage = 1;
- getPlayerPage();
- },
- child: Container(
- color: Color(0x1A000000),
- child: ListView.builder(
- physics: AlwaysScrollableScrollPhysics(),
- padding: EdgeInsets.only(top: 10),
- controller: _perController,
- itemCount: joinList.length + 1,
- itemBuilder: (BuildContext context, int index) {
- if (index < joinList.length) {
- return playerItem(joinList[index], index);
- } else {
- return Container(
- padding: EdgeInsets.all(15),
- child: Text(
- '其他人员正在火速赶来中...',
- style: TextStyle(color: Colors.white30),
- textAlign: TextAlign.center,
- ),
- );
- }
- }),
- ),
- ),
- ),
- widget.houseInfo.statusFlag == HouseStatus.SETTLEMENT && widget.playerInfo != null
- ? Container(
- height: 60,
- color: SUB_COLOR,
- padding: EdgeInsets.only(right: 15),
- child: Row(
- children: <Widget>[
- Container(
- width: 57,
- child: Center(
- child: Container(
- width: 22,
- height: 22,
- color: Color(0x33FFFFFF),
- child: Center(
- child: Text(
- widget.playerInfo?.houseRank?.toString() ?? '',
- style: TextStyle(color: Colors.white, fontSize: 12),
- ),
- ),
- ),
- ),
- ),
- Container(
- margin: EdgeInsets.only(right: 12),
- child: ClipOval(
- child: CachedNetworkImage(
- width: 36,
- height: 36,
- imageUrl: StoreProvider.of<AppState>(context).state.userInfo.icon,
- ),
- ),
- ),
- Expanded(
- flex: 1,
- child: Text(
- StoreProvider.of<AppState>(context).state.userInfo.nickname,
- style: TextStyle(
- color: PRIMARY_COLOR,
- fontSize: 14,
- ),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- ),
- ),
- Container(
- margin: EdgeInsets.only(right: 3),
- child: Image.asset(
- 'images/icon_jifen_da.png',
- width: 20,
- ),
- ),
- Text(
- widget.playerInfo?.points?.toString() ?? '0',
- style: TextStyle(color: Colors.yellow, fontSize: 14, fontWeight: FontWeight.bold),
- )
- ],
- ),
- )
- : Container()
- ],
- );
- }
- Widget playerItem(PlayerInfo info, int index) {
- return Container(
- width: double.infinity,
- height: 60,
- color: BG_COLOR,
- padding: EdgeInsets.only(right: 15),
- margin: EdgeInsets.only(top: 1),
- child: Container(
- decoration: BoxDecoration(border: Border(bottom: BorderSide(width: 1, color: BG_SUB_COLOR, style: BorderStyle.solid))),
- child: Row(
- children: <Widget>[
- Container(
- width: 57,
- child: Center(
- child: widget.houseInfo.statusFlag == 4 && index < 3
- ? Image.asset(
- 'images/icon_paihangbang_0' + (index + 1).toString() + '.png',
- width: 32,
- )
- : Container(
- width: 22,
- height: 22,
- color: Color(0x33FFFFFF),
- child: Center(
- child: Text(
- (index + 1).toString(),
- style: TextStyle(color: Colors.white, fontSize: 12),
- ),
- ),
- ),
- ),
- ),
- Container(
- margin: EdgeInsets.only(right: 12),
- child: ClipOval(
- child: CachedNetworkImage(
- width: 36,
- height: 36,
- imageUrl: info?.userInfo?.icon ?? '',
- ),
- ),
- ),
- Expanded(
- flex: 1,
- child: Text(
- info?.userInfo?.nickname ?? '',
- style: TextStyle(
- color: Colors.white,
- fontSize: 14,
- ),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- ),
- ),
- widget.houseInfo.statusFlag == 4 && index < 3 && info.video != '' && info.video != null
- ? SizedBox(
- width: 68,
- height: 24,
- child: OutlineButton(
- padding: EdgeInsets.all(0),
- borderSide: BorderSide(color: PRIMARY_COLOR),
- textColor: PRIMARY_COLOR,
- splashColor: PRIMARY_COLOR.withAlpha(50),
- child: Text('查看回放',
- style: TextStyle(
- fontSize: 12,
- )),
- onPressed: () {
- Navigator.push(context, CupertinoPageRoute(builder: (context) => VideoPlayerPage(videoUrl: info.video, fileType: 'netWork')));
- },
- ),
- )
- : Container(),
- ],
- ),
- ),
- );
- }
- }
|