| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369 |
- import 'dart:ui';
- import 'package:flutter/material.dart';
- import '../styles/colors.dart';
- import 'package:flutter/cupertino.dart';
- import '../styles/totast.dart';
- import '../model/PlayerInfo.dart';
- import '../net/HttpManager.dart';
- import '../net/Result.dart';
- import '../model/HouseInfo.dart';
- import '../model/GameInfo.dart';
- import '../pages/RoomInfo.dart';
- import 'package:flutter_redux/flutter_redux.dart';
- import '../redux/AppState.dart';
- import '../widget/ScoreType.dart';
- import 'package:cached_network_image/cached_network_image.dart';
- import '../widget/HouseItem.dart';
- class RecordList extends StatefulWidget {
- @override
- RecordListState createState() => RecordListState();
- }
- class RecordListState extends State<RecordList> with SingleTickerProviderStateMixin {
- final List<Tab> myTabs = <Tab>[Tab(text: '我创建的'), Tab(text: '我加入的')];
- TabController _tabController;
- @override
- void initState() {
- super.initState();
- _tabController = TabController(length: myTabs.length, vsync: this);
- }
- @override
- void dispose() {
- super.dispose();
- _tabController.dispose();
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- // backgroundColor: PRIMARY_COLOR,
- title: Padding(
- padding: EdgeInsets.only(right: 56),
- child: TabBar(
- controller: _tabController,
- tabs: myTabs,
- indicatorColor: Colors.white,
- labelColor: Colors.white,
- indicatorSize: TabBarIndicatorSize.label,
- ),
- ),
- centerTitle: true,
- elevation: 0,
- ),
- body: Container(
- padding: EdgeInsets.only(top: 10),
- child: TabBarView(controller: _tabController, children: <Widget>[RecordInfo(0), RecordInfo(1)]),
- color: Color(0xFF2B2B42),
- ));
- }
- }
- class RecordInfo extends StatefulWidget {
- int type;
- RecordInfo(this.type);
- @override
- RecordInfoState createState() => RecordInfoState();
- }
- class RecordInfoState extends State<RecordInfo> {
- ScrollController _mControll;
- List<PlayerInfo> playerList = [];
- List<HouseInfo> houseList = [];
- int currentPage = 1;
- bool isMore = false;
- Future<void> getHousePage() async {
- Result res = await HttpManager.get('houseInfo/page', data: {
- 'userId': StoreProvider.of<AppState>(context).state.userInfo.id,
- 'currentPage': currentPage,
- 'pageNumber': 20,
- 'orderByStr': 'status_flag_,asc'
- });
- Toast.hide();
- List<HouseInfo> list = houseList;
- if (currentPage == 1) {
- list = [];
- }
- if (res.success) {
- for (var item in res.data['pp']) {
- HouseInfo tip = HouseInfo.fromJson(item);
- list.add(tip);
- }
- if (res.data['page']['currentPage'] < res.data['page']['totalPage']) {
- isMore = true;
- }
- } else {}
- setState(() {
- houseList = list;
- });
- }
- Future<void> getListPage() async {
- isMore = false;
- Toast.show(context, '加载中', -1, 'loading');
- if (widget.type == 0) {
- getHousePage();
- return;
- }
- Result res = await HttpManager.get('playerInfo/page',
- data: {'userId': StoreProvider.of<AppState>(context).state.userInfo.id, 'currentPage': currentPage, 'pageNumber': 20});
- Toast.hide();
- List<PlayerInfo> list = playerList;
- if (currentPage == 1) {
- list = [];
- }
- if (res.success) {
- for (var item in res.data['pp']) {
- PlayerInfo tip = PlayerInfo.fromJson(item);
- list.add(tip);
- }
- if (res.data['page']['currentPage'] < res.data['page']['totalPage']) {
- isMore = true;
- }
- } else {}
- setState(() {
- playerList = list;
- });
- }
- @override
- void initState() {
- super.initState();
- _mControll = ScrollController();
- _mControll.addListener(() {
- if (_mControll.position.pixels == _mControll.position.maxScrollExtent) {
- if (isMore) {
- currentPage++;
- getListPage();
- }
- }
- });
- Future.delayed(Duration.zero, () => getListPage());
- }
- @override
- void dispose() {
- _mControll.dispose();
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: Container(
- color: Color(0xFF2B2B42),
- child: RefreshIndicator(
- color: ThemeData().primaryColor,
- backgroundColor: Colors.white,
- onRefresh: () async {
- await Future.delayed(const Duration(seconds: 1));
- },
- child: widget.type == 0
- ? ListView.builder(
- physics: AlwaysScrollableScrollPhysics(),
- controller: _mControll,
- itemCount: houseList.isNotEmpty ? houseList.length : 1,
- itemBuilder: (BuildContext context, int index) {
- if (houseList.isEmpty) {
- return Text(
- '还没有战绩快去比赛吧...',
- style: TextStyle(color: Colors.white30, fontSize: 13, height: 2),
- textAlign: TextAlign.center,
- );
- }
- return HouseItem(houseList[index],houseList[index].gameInfo);
- })
- : ListView.builder(
- physics: AlwaysScrollableScrollPhysics(),
- controller: _mControll,
- itemCount: playerList.isNotEmpty ? playerList.length : 1,
- itemBuilder: (BuildContext context, int index) {
- if (playerList.isEmpty) {
- return Text(
- '还没有战绩快去比赛吧...',
- style: TextStyle(color: Colors.white30, fontSize: 13, height: 2),
- textAlign: TextAlign.center,
- );
- }
- return HouseItem( playerList[index].houseInfo, playerList[index].gameInfo, playerInfo: playerList[index]);
- }),
- )),
- );
- }
- }
- // class houseItem extends StatelessWidget {
- // houseItem({Key key, this.roomInfo, this.gameInfo, this.playerInfo, this.type = 0}) : super(key: key);
- // final HouseInfo roomInfo;
- // final GameInfo gameInfo;
- // final PlayerInfo playerInfo;
- // final int type;
- // @override
- // Widget build(BuildContext context) {
- // List imageList = [
- // 'images/jiangpai_huangjin.png',
- // 'images/jiangpai_baiyin.png',
- // 'images/jiangpai_qingtong.png',
- // 'images/zhanji_icon_04.png',
- // 'images/jiangpai_bojin.png'
- // ];
- // String imageSrc = '';
- // String tishiStr = '';
- // Color tishiColor;
- // bool isImport = false;
- // if (playerInfo != null) {
- // if (playerInfo.medal != null) {
- // if (playerInfo.medal == 'platinum') {
- // imageSrc = imageList[4];
- // } else if (playerInfo.medal == 'gold') {
- // imageSrc = imageList[0];
- // } else if (playerInfo.medal == 'silver') {
- // imageSrc = imageList[1];
- // } else if (playerInfo.medal == 'bronze') {
- // imageSrc = imageList[2];
- // }
- // else if(playerInfo.rank!=null){
- // tishiStr='第${playerInfo.rank}名';
- // }
- // // if (playerInfo.houseRank < 4) {
- // // imageSrc = imageList[playerInfo.houseRank - 1];
- // // } else {
- // // imageSrc = imageList[3];
- // // }
- // }
- // if (playerInfo.statusFlag != null) {
- // if (playerInfo.statusFlag == 6) {
- // imageSrc = imageList[3];
- // } else if (playerInfo.statusFlag == 0) {
- // tishiStr = '未开始';
- // } else if (playerInfo.statusFlag == 2) {
- // tishiStr = '进行中';
- // } else if (playerInfo.statusFlag < 4 || (roomInfo.statusFlag >= 2 && roomInfo.statusFlag < 4)) {
- // tishiStr = '结算中';
- // }
- // }
- // } else {
- // if (roomInfo.statusFlag == 0) {
- // tishiStr = '未开始';
- // tishiColor = Theme.of(context).primaryColor;
- // } else if (roomInfo.statusFlag == 2) {
- // tishiStr = '进行中';
- // tishiColor = Color(0xFFA9AABA);
- // } else if (roomInfo.statusFlag == 4) {
- // tishiStr = '已结束';
- // tishiColor = Color(0xFF595B77);
- // } else {
- // tishiStr = '结算中';
- // tishiColor = Color(0xFF595B77);
- // }
- // }
- // if (roomInfo == null) {
- // return Container();
- // }
- // return Container(
- // decoration: BoxDecoration(
- // // gradient: LinearGradient(
- // // colors: [Color(0xFF3F4261), Color(0xFF323456)],
- // // begin: Alignment.topCenter,
- // // end: Alignment.bottomCenter,
- // // ),
- // color: Color(0xFF363759),
- // ),
- // child: Column(
- // children: <Widget>[
- // Material(
- // color: Colors.transparent,
- // child: InkWell(
- // child: Padding(
- // padding: EdgeInsets.all(15),
- // child: Row(
- // children: <Widget>[
- // Image.network(
- // gameInfo.icon,
- // width: 48,
- // height: 48,
- // ),
- // Container(
- // width: 10,
- // ),
- // Expanded(
- // flex: 1,
- // child: Column(
- // crossAxisAlignment: CrossAxisAlignment.start,
- // children: <Widget>[
- // Row(
- // children: <Widget>[
- // LimitedBox(
- // maxWidth: 170,
- // child: Text(
- // roomInfo.houseName,
- // style: TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.w500),
- // maxLines: 1,
- // overflow: TextOverflow.ellipsis,
- // ),
- // ),
- // Container(
- // width: 5,
- // ),
- // ScoreType(roomInfo.scoreType)
- // // Container(
- // // margin: EdgeInsets.only(left: 6),
- // // child: Image.network(roomInfo.houseLevel.icon,
- // // width: 14),
- // // ),
- // // Container(
- // // margin: EdgeInsets.only(left: 1),
- // // child: Text(
- // // roomInfo.houseLevel.levelName,
- // // style: TextStyle(
- // // color: Color(0xFFF9D881), fontSize: 9),
- // // )),
- // ],
- // ),
- // Text(
- // roomInfo.houseAbstract ?? '',
- // style: TextStyle(fontSize: 12, fontWeight: FontWeight.w400, color: Color(0xFF9BA0AE)),
- // maxLines: 2,
- // overflow: TextOverflow.ellipsis,
- // )
- // ],
- // ),
- // ),
- // imageSrc != ''
- // ? Image.asset(imageSrc)
- // : (type == 2
- // ? Text(tishiStr, style: TextStyle(color: isImport ? PRIMARY_COLOR : Colors.white54, fontSize: 14))
- // : Container(
- // color: tishiColor,
- // padding: EdgeInsets.symmetric(vertical: 4, horizontal: 9),
- // child: Text(
- // tishiStr,
- // style: TextStyle(color: Color(0xFF252532), fontSize: 12),
- // ),
- // ))
- // ],
- // ),
- // ),
- // onTap: () {
- // Navigator.push(context, CupertinoPageRoute(builder: (context) => RoomInfo(roomId: roomInfo.id.toString())));
- // },
- // ),
- // ),
- // Container(
- // margin: EdgeInsets.symmetric(horizontal: 15),
- // height: 1,
- // color: Color(0xFF2B2B42),
- // )
- // ],
- // ),
- // );
- // }
- // }
|