|
|
@@ -8,6 +8,11 @@ import '../net/HttpManager.dart';
|
|
|
import '../net/Result.dart';
|
|
|
import '../model/HouseInfo.dart';
|
|
|
import '../model/GameInfo.dart';
|
|
|
+import '../widget/ITextInput.dart';
|
|
|
+import 'package:redux/redux.dart';
|
|
|
+import 'package:flutter_redux/flutter_redux.dart';
|
|
|
+import '../redux/AppState.dart';
|
|
|
+import '../model/UserInfo.dart';
|
|
|
|
|
|
class RoomList extends StatefulWidget {
|
|
|
@override
|
|
|
@@ -19,11 +24,14 @@ class RoomListState extends State<RoomList> {
|
|
|
int currentPage = 1;
|
|
|
ScrollController _controller;
|
|
|
bool scrollFlag = true;
|
|
|
+ bool _showSearch = false;
|
|
|
|
|
|
String gameId = '';
|
|
|
String houseLevel = '';
|
|
|
String houseType = '';
|
|
|
String statusFlag = '0';
|
|
|
+ String searchKey = '';
|
|
|
+ FocusNode _contentFocusNode = FocusNode();
|
|
|
|
|
|
List gameList = [
|
|
|
{'id': '', 'gameName': '全部游戏'}
|
|
|
@@ -45,6 +53,17 @@ class RoomListState extends State<RoomList> {
|
|
|
{'name': '结算完成', 'val': '4'}
|
|
|
];
|
|
|
|
|
|
+ Future<void> search(String text) async {
|
|
|
+ if (text != searchKey) {
|
|
|
+ currentPage = 1;
|
|
|
+ searchKey = text;
|
|
|
+ statusFlag = '';
|
|
|
+ houseLevel = '';
|
|
|
+ houseType = '';
|
|
|
+ getRoomInfo();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@override
|
|
|
void initState() {
|
|
|
super.initState();
|
|
|
@@ -93,12 +112,44 @@ class RoomListState extends State<RoomList> {
|
|
|
ScreenUtil.instance = ScreenUtil(width: 375, height: 667)..init(context);
|
|
|
|
|
|
return Scaffold(
|
|
|
- appBar: AppBar(
|
|
|
- backgroundColor: PRIMARY_COLOR,
|
|
|
- title: Text('房间列表'),
|
|
|
- centerTitle: true,
|
|
|
- elevation: 0,
|
|
|
- ),
|
|
|
+ appBar: !_showSearch
|
|
|
+ ? AppBar(
|
|
|
+ backgroundColor: PRIMARY_COLOR,
|
|
|
+ title: Text('房间列表'),
|
|
|
+ centerTitle: true,
|
|
|
+ elevation: 0,
|
|
|
+ actions: <Widget>[
|
|
|
+ GestureDetector(
|
|
|
+ child: Image.asset('images/icon_sousuo.png'),
|
|
|
+ onTap: () async {
|
|
|
+ setState(() {
|
|
|
+ _showSearch = true;
|
|
|
+ });
|
|
|
+ // String result = await Navigator.of(context).push(
|
|
|
+ // PageRouteBuilder(
|
|
|
+ // opaque: false,
|
|
|
+ // transitionDuration: Duration(milliseconds: 300),
|
|
|
+ // transitionsBuilder: (BuildContext context,
|
|
|
+ // Animation<double> animation,
|
|
|
+ // Animation<double> secondaryAnimation,
|
|
|
+ // Widget child) {
|
|
|
+ // return FadeTransition(
|
|
|
+ // opacity: CurvedAnimation(
|
|
|
+ // parent: animation, curve: Curves.linear),
|
|
|
+ // child: child,
|
|
|
+ // );
|
|
|
+ // },
|
|
|
+ // pageBuilder: (BuildContext context, _, __) {
|
|
|
+ // return searchInput();
|
|
|
+ // }));
|
|
|
+ // if (result != '' || searchKey != '') {
|
|
|
+ // search(result);
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ )
|
|
|
+ : null,
|
|
|
body: RefreshIndicator(
|
|
|
color: PRIMARY_COLOR,
|
|
|
backgroundColor: Colors.white,
|
|
|
@@ -110,7 +161,7 @@ class RoomListState extends State<RoomList> {
|
|
|
getRoomInfo();
|
|
|
},
|
|
|
child: Container(
|
|
|
- color: BG_COLOR,
|
|
|
+ color: Color(0xFF363759),
|
|
|
child: Stack(
|
|
|
children: <Widget>[
|
|
|
CustomScrollView(
|
|
|
@@ -119,34 +170,46 @@ class RoomListState extends State<RoomList> {
|
|
|
slivers: <Widget>[
|
|
|
SliverToBoxAdapter(
|
|
|
child: Container(
|
|
|
- height: 44,
|
|
|
+ height: _showSearch
|
|
|
+ ? MediaQueryData.fromWindow(window).padding.top +
|
|
|
+ 100
|
|
|
+ : 44,
|
|
|
),
|
|
|
),
|
|
|
SliverFixedExtentList(
|
|
|
- itemExtent: ScreenUtil().setWidth(78),
|
|
|
- delegate: SliverChildBuilderDelegate((BuildContext context, int index) {
|
|
|
- if(roomList.isEmpty){
|
|
|
- return Text('暂无数据',style: TextStyle(
|
|
|
- color: Colors.grey,
|
|
|
- fontSize: 13,
|
|
|
- height:3
|
|
|
- ),textAlign: TextAlign.center);
|
|
|
- }else if(index ==roomList.length){
|
|
|
- return Text('更多房间敬请期待...',style: TextStyle(
|
|
|
- color: Colors.grey,
|
|
|
- fontSize: 13,
|
|
|
- height:3
|
|
|
- ),textAlign: TextAlign.center);
|
|
|
+ itemExtent:
|
|
|
+ roomList.isEmpty ? 300 : ScreenUtil().setWidth(78),
|
|
|
+ delegate: SliverChildBuilderDelegate(
|
|
|
+ (BuildContext context, int index) {
|
|
|
+ if (roomList.isEmpty) {
|
|
|
+ return Container(
|
|
|
+ padding: EdgeInsets.only(top: 105),
|
|
|
+ child: Column(
|
|
|
+ children: <Widget>[
|
|
|
+ Image.asset('images/icon_kong.png'),
|
|
|
+ Text('暂时没有此房间哦~',
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 14,
|
|
|
+ color:
|
|
|
+ Color(0xFFFFB726).withOpacity(0.3)))
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ } else if (index == roomList.length) {
|
|
|
+ return Text('更多房间敬请期待...',
|
|
|
+ style: TextStyle(
|
|
|
+ color: Colors.grey, fontSize: 13, height: 3),
|
|
|
+ textAlign: TextAlign.center);
|
|
|
}
|
|
|
return HouseItem(
|
|
|
- roomInfo: roomList[index],
|
|
|
- gameInfo:roomList[index].gameInfo
|
|
|
- );
|
|
|
- }, childCount: roomList.length+1),
|
|
|
+ roomInfo: roomList[index],
|
|
|
+ gameInfo: roomList[index].gameInfo);
|
|
|
+ }, childCount: roomList.length + 1),
|
|
|
)
|
|
|
],
|
|
|
),
|
|
|
- _topWidget()
|
|
|
+ _topWidget(),
|
|
|
+ _showSearch ? _searchInput() : Container()
|
|
|
],
|
|
|
),
|
|
|
),
|
|
|
@@ -155,14 +218,20 @@ class RoomListState extends State<RoomList> {
|
|
|
|
|
|
Widget _topWidget() {
|
|
|
return Positioned(
|
|
|
+ top: _showSearch ? MediaQueryData.fromWindow(window).padding.top + 56 : 0,
|
|
|
width: ScreenUtil().setWidth(375),
|
|
|
height: 44,
|
|
|
child: Container(
|
|
|
padding: EdgeInsets.all(14),
|
|
|
- color: Color(0xFF3A3D5C),
|
|
|
+ color: Color(0xFF2B2B42),
|
|
|
child: Row(
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
- children: <Widget>[_chooseGame(), _chooseHouseType(), _chooseLevel(), _chooseStatus()],
|
|
|
+ children: <Widget>[
|
|
|
+ _chooseGame(),
|
|
|
+ _chooseHouseType(),
|
|
|
+ _chooseLevel(),
|
|
|
+ _chooseStatus()
|
|
|
+ ],
|
|
|
),
|
|
|
),
|
|
|
);
|
|
|
@@ -189,7 +258,10 @@ class RoomListState extends State<RoomList> {
|
|
|
flex: 1,
|
|
|
child: Text(
|
|
|
gameInfo['gameName'],
|
|
|
- style: TextStyle(color: gameId != '' ? PRIMARY_COLOR : Colors.white, fontSize: 12, fontWeight: FontWeight.w500),
|
|
|
+ style: TextStyle(
|
|
|
+ color: gameId != '' ? PRIMARY_COLOR : Colors.white,
|
|
|
+ fontSize: 12,
|
|
|
+ fontWeight: FontWeight.w500),
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
textAlign: TextAlign.center,
|
|
|
),
|
|
|
@@ -205,7 +277,7 @@ class RoomListState extends State<RoomList> {
|
|
|
setState(() {
|
|
|
gameId = value;
|
|
|
});
|
|
|
- currentPage=1;
|
|
|
+ currentPage = 1;
|
|
|
getRoomInfo();
|
|
|
},
|
|
|
itemBuilder: (BuildContext context) {
|
|
|
@@ -242,7 +314,10 @@ class RoomListState extends State<RoomList> {
|
|
|
flex: 1,
|
|
|
child: Text(
|
|
|
levelInfo['levelName'],
|
|
|
- style: TextStyle(color: houseLevel != '' ? PRIMARY_COLOR : Colors.white, fontSize: 12, fontWeight: FontWeight.w500),
|
|
|
+ style: TextStyle(
|
|
|
+ color: houseLevel != '' ? PRIMARY_COLOR : Colors.white,
|
|
|
+ fontSize: 12,
|
|
|
+ fontWeight: FontWeight.w500),
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
textAlign: TextAlign.center,
|
|
|
),
|
|
|
@@ -258,7 +333,7 @@ class RoomListState extends State<RoomList> {
|
|
|
setState(() {
|
|
|
houseLevel = value;
|
|
|
});
|
|
|
- currentPage=1;
|
|
|
+ currentPage = 1;
|
|
|
getRoomInfo();
|
|
|
},
|
|
|
itemBuilder: (BuildContext context) {
|
|
|
@@ -295,7 +370,10 @@ class RoomListState extends State<RoomList> {
|
|
|
flex: 1,
|
|
|
child: Text(
|
|
|
typeInfo['name'],
|
|
|
- style: TextStyle(color: houseType != '' ? PRIMARY_COLOR : Colors.white, fontSize: 12, fontWeight: FontWeight.w500),
|
|
|
+ style: TextStyle(
|
|
|
+ color: houseType != '' ? PRIMARY_COLOR : Colors.white,
|
|
|
+ fontSize: 12,
|
|
|
+ fontWeight: FontWeight.w500),
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
textAlign: TextAlign.center,
|
|
|
),
|
|
|
@@ -311,7 +389,7 @@ class RoomListState extends State<RoomList> {
|
|
|
setState(() {
|
|
|
houseType = value;
|
|
|
});
|
|
|
- currentPage=1;
|
|
|
+ currentPage = 1;
|
|
|
getRoomInfo();
|
|
|
},
|
|
|
itemBuilder: (BuildContext context) {
|
|
|
@@ -348,7 +426,10 @@ class RoomListState extends State<RoomList> {
|
|
|
flex: 1,
|
|
|
child: Text(
|
|
|
statusInfo['name'],
|
|
|
- style: TextStyle(color: statusFlag != '' ? PRIMARY_COLOR : Colors.white, fontSize: 12, fontWeight: FontWeight.w500),
|
|
|
+ style: TextStyle(
|
|
|
+ color: statusFlag != '' ? PRIMARY_COLOR : Colors.white,
|
|
|
+ fontSize: 12,
|
|
|
+ fontWeight: FontWeight.w500),
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
textAlign: TextAlign.center,
|
|
|
),
|
|
|
@@ -364,7 +445,7 @@ class RoomListState extends State<RoomList> {
|
|
|
setState(() {
|
|
|
statusFlag = value;
|
|
|
});
|
|
|
- currentPage=1;
|
|
|
+ currentPage = 1;
|
|
|
getRoomInfo();
|
|
|
},
|
|
|
itemBuilder: (BuildContext context) {
|
|
|
@@ -381,10 +462,10 @@ class RoomListState extends State<RoomList> {
|
|
|
}
|
|
|
|
|
|
Future<void> getRoomInfo() async {
|
|
|
-
|
|
|
Map<String, dynamic> data = {
|
|
|
'currentPage': currentPage,
|
|
|
'pageNumber': 20,
|
|
|
+ 'myUserId': StoreProvider.of<AppState>(context).state.userInfo.id
|
|
|
};
|
|
|
data['advancedQuery'] = '';
|
|
|
if (gameId != '') {
|
|
|
@@ -401,25 +482,34 @@ class RoomListState extends State<RoomList> {
|
|
|
} else {
|
|
|
data['statusStr'] = '0,4';
|
|
|
}
|
|
|
- List<HouseInfo> _allList=roomList;
|
|
|
- if(currentPage==1){
|
|
|
- _allList=[];
|
|
|
+ data['searchKey'] = searchKey;
|
|
|
+ List<HouseInfo> _allList = roomList;
|
|
|
+ if (currentPage == 1) {
|
|
|
+ _allList = [];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StoreProvider.of<AppState>(context).state.userInfo.recommender !=
|
|
|
+ null) {
|
|
|
+ data['recommender'] =
|
|
|
+ StoreProvider.of<AppState>(context).state.userInfo.recommender;
|
|
|
}
|
|
|
+
|
|
|
+ // myUserId=84705&recommender=84702
|
|
|
Result res = await HttpManager.get('houseInfo/page', data: data);
|
|
|
if (res.success && res.data['pp'] != null) {
|
|
|
for (var item in res.data['pp']) {
|
|
|
- HouseInfo _temHouse=HouseInfo.fromJson(item);
|
|
|
+ HouseInfo _temHouse = HouseInfo.fromJson(item);
|
|
|
_allList.add(_temHouse);
|
|
|
}
|
|
|
if (res.data['page']['currentPage'] < res.data['page']['totalPage']) {
|
|
|
- scrollFlag = true;
|
|
|
- } else {
|
|
|
- scrollFlag = false;
|
|
|
- }
|
|
|
- } else {}
|
|
|
+ scrollFlag = true;
|
|
|
+ } else {
|
|
|
+ scrollFlag = false;
|
|
|
+ }
|
|
|
+ } else {}
|
|
|
|
|
|
setState(() {
|
|
|
- roomList=_allList;
|
|
|
+ roomList = _allList;
|
|
|
});
|
|
|
|
|
|
// final response = await Dio().get(domain + 'houseInfo/page', data: data);
|
|
|
@@ -438,4 +528,67 @@ class RoomListState extends State<RoomList> {
|
|
|
// }
|
|
|
// }
|
|
|
}
|
|
|
+
|
|
|
+ Widget _searchInput() {
|
|
|
+ return Positioned(
|
|
|
+ child: Container(
|
|
|
+ padding: EdgeInsets.only(
|
|
|
+ top: MediaQueryData.fromWindow(window).padding.top, left: 15),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ gradient: LinearGradient(
|
|
|
+ colors: [Color(0xFFFFC30F), Color(0xFFFFA54C)],
|
|
|
+ begin: Alignment.topCenter,
|
|
|
+ end: Alignment.bottomCenter)),
|
|
|
+ height: MediaQueryData.fromWindow(window).padding.top + 56,
|
|
|
+ child: Row(
|
|
|
+ children: <Widget>[
|
|
|
+ Expanded(
|
|
|
+ flex: 1,
|
|
|
+ child: Container(
|
|
|
+ height: 34,
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: Colors.white,
|
|
|
+ borderRadius: BorderRadius.all(Radius.circular(100)),
|
|
|
+ ),
|
|
|
+ child: ITextField(
|
|
|
+ focusNode: _contentFocusNode,
|
|
|
+ autofocus: true,
|
|
|
+ hintText: '输入房间名称/房间号/创建人Code',
|
|
|
+ inputBorder: InputBorder.none,
|
|
|
+ hintStyle: TextStyle(
|
|
|
+ fontSize: 16,
|
|
|
+ color: Color(0xFF727785),
|
|
|
+ ),
|
|
|
+ textStyle: TextStyle(color: Colors.black),
|
|
|
+ contentPadding:
|
|
|
+ EdgeInsets.symmetric(vertical: 4, horizontal: 19),
|
|
|
+ fieldCallBack: (content) {
|
|
|
+ search(content);
|
|
|
+ },
|
|
|
+ counterStyle: TextStyle(color: BG_SUB_COLOR, fontSize: 0),
|
|
|
+ textInputAction: TextInputAction.search),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ InkWell(
|
|
|
+ child: Container(
|
|
|
+ padding: EdgeInsets.fromLTRB(16, 0, 15, 4),
|
|
|
+ child: Text('取消',
|
|
|
+ style: TextStyle(color: Colors.white, fontSize: 16)),
|
|
|
+ ),
|
|
|
+ onTap: () {
|
|
|
+ setState(() {
|
|
|
+ _showSearch = false;
|
|
|
+ currentPage = 1;
|
|
|
+ searchKey = '';
|
|
|
+ statusFlag = '0';
|
|
|
+ houseLevel = '';
|
|
|
+ houseType = '';
|
|
|
+ getRoomInfo();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ )),
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|