|
@@ -1,6 +1,6 @@
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:flutter_swiper/flutter_swiper.dart';
|
|
import 'package:flutter_swiper/flutter_swiper.dart';
|
|
|
-import 'package:cached_network_image/cached_network_image.dart';
|
|
|
|
|
|
|
+import 'package:shared_preferences/shared_preferences.dart';
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
|
import '../styles/totast.dart';
|
|
import '../styles/totast.dart';
|
|
|
import '../net/HttpManager.dart';
|
|
import '../net/HttpManager.dart';
|
|
@@ -10,10 +10,8 @@ import 'package:flutter_redux/flutter_redux.dart';
|
|
|
import '../redux/AppState.dart';
|
|
import '../redux/AppState.dart';
|
|
|
import '../widget/LinearButton.dart';
|
|
import '../widget/LinearButton.dart';
|
|
|
import '../model/BannerInfo.dart';
|
|
import '../model/BannerInfo.dart';
|
|
|
-import '../widget/ITextInput.dart';
|
|
|
|
|
import '../widget/HouseItem.dart';
|
|
import '../widget/HouseItem.dart';
|
|
|
import '../model/HouseInfo.dart';
|
|
import '../model/HouseInfo.dart';
|
|
|
-import 'OpenRoom.dart';
|
|
|
|
|
import 'package:flutter_picker/flutter_picker.dart';
|
|
import 'package:flutter_picker/flutter_picker.dart';
|
|
|
import 'CompetitionInformation.dart';
|
|
import 'CompetitionInformation.dart';
|
|
|
import '../model/GameInfo.dart';
|
|
import '../model/GameInfo.dart';
|
|
@@ -22,6 +20,9 @@ import 'dart:convert';
|
|
|
import 'dart:ui';
|
|
import 'dart:ui';
|
|
|
import 'dart:math';
|
|
import 'dart:math';
|
|
|
import 'SelectRoom.dart';
|
|
import 'SelectRoom.dart';
|
|
|
|
|
+import 'package:flutter/services.dart';
|
|
|
|
|
+import 'PhotoView.dart';
|
|
|
|
|
+import '../model/PhoneInfo.dart';
|
|
|
|
|
|
|
|
class MatchPage extends StatefulWidget {
|
|
class MatchPage extends StatefulWidget {
|
|
|
@override
|
|
@override
|
|
@@ -41,6 +42,7 @@ class _MatchPageState extends State<MatchPage> with WidgetsBindingObserver {
|
|
|
String gameName = '全部游戏';
|
|
String gameName = '全部游戏';
|
|
|
bool isFirst = true;
|
|
bool isFirst = true;
|
|
|
FocusNode _focusNode = new FocusNode();
|
|
FocusNode _focusNode = new FocusNode();
|
|
|
|
|
+ List<PhoneInfo> phoneList = [];
|
|
|
|
|
|
|
|
//展示通知
|
|
//展示通知
|
|
|
void showNotice() {
|
|
void showNotice() {
|
|
@@ -168,6 +170,44 @@ class _MatchPageState extends State<MatchPage> with WidgetsBindingObserver {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ Future<void> getPhoneInfo() async {
|
|
|
|
|
+ List<PhoneInfo> _phoneList = [];
|
|
|
|
|
+ Result res = await HttpManager.get('phoneInfo/all');
|
|
|
|
|
+ if (res.success && res.data != null) {
|
|
|
|
|
+ for (var item in res.data) {
|
|
|
|
|
+ PhoneInfo phone = PhoneInfo.fromJson(item);
|
|
|
|
|
+ _phoneList.add(phone);
|
|
|
|
|
+ }
|
|
|
|
|
+ setState(() {
|
|
|
|
|
+ phoneList = _phoneList;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ final prefs = await SharedPreferences.getInstance();
|
|
|
|
|
+ var now = new DateTime.now();
|
|
|
|
|
+ var timeStr = now.year.toString() + '/' + now.month.toString() + '/' + now.day.toString();
|
|
|
|
|
+ prefs.setString('showPhoneInfo', timeStr);
|
|
|
|
|
+
|
|
|
|
|
+ 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 LoadingDialog(
|
|
|
|
|
+ text: '部分手机自动设置了省电策略,会将我们的app在游戏进程中从后台停掉,为了你的正常比赛,请点击你的手机型号查看具体设置',
|
|
|
|
|
+ phoneList: phoneList,
|
|
|
|
|
+ );
|
|
|
|
|
+ },
|
|
|
|
|
+ ),
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@override
|
|
@override
|
|
|
void initState() {
|
|
void initState() {
|
|
|
super.initState();
|
|
super.initState();
|
|
@@ -184,10 +224,16 @@ class _MatchPageState extends State<MatchPage> with WidgetsBindingObserver {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- Future.delayed(Duration.zero, () {
|
|
|
|
|
|
|
+ Future.delayed(Duration.zero, () async {
|
|
|
getBannerInfo();
|
|
getBannerInfo();
|
|
|
getGame();
|
|
getGame();
|
|
|
getRoomInfo();
|
|
getRoomInfo();
|
|
|
|
|
+ final prefs = await SharedPreferences.getInstance();
|
|
|
|
|
+ var now = new DateTime.now();
|
|
|
|
|
+ var timeStr = now.year.toString() + '/' + now.month.toString() + '/' + now.day.toString();
|
|
|
|
|
+ if (prefs.getString('showPhoneInfo') != timeStr) {
|
|
|
|
|
+ getPhoneInfo();
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -413,16 +459,16 @@ class _MatchPageState extends State<MatchPage> with WidgetsBindingObserver {
|
|
|
_focusNode.unfocus();
|
|
_focusNode.unfocus();
|
|
|
},
|
|
},
|
|
|
),
|
|
),
|
|
|
- onWillPop: () {
|
|
|
|
|
|
|
+ onWillPop: () async {
|
|
|
if (isFirst) {
|
|
if (isFirst) {
|
|
|
isFirst = false;
|
|
isFirst = false;
|
|
|
- Toast.show(context, '再次点击退出程序', 1500, 'info');
|
|
|
|
|
- Timer(Duration(seconds: 2), () {
|
|
|
|
|
|
|
+ Toast.show(context, '再次点击退出程序', 1000, 'info');
|
|
|
|
|
+ Timer(Duration(seconds: 1), () {
|
|
|
isFirst = true;
|
|
isFirst = true;
|
|
|
});
|
|
});
|
|
|
return Future.value(false);
|
|
return Future.value(false);
|
|
|
} else {
|
|
} else {
|
|
|
- return Future.value(true);
|
|
|
|
|
|
|
+ return await SystemChannels.platform.invokeMethod('SystemNavigator.pop');
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
);
|
|
);
|
|
@@ -465,3 +511,125 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
|
|
|
return maxHeight != oldDelegate.maxHeight || minHeight != oldDelegate.minHeight || child != oldDelegate.child;
|
|
return maxHeight != oldDelegate.maxHeight || minHeight != oldDelegate.minHeight || child != oldDelegate.child;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+typedef OnTapHomeMenu = void Function();
|
|
|
|
|
+
|
|
|
|
|
+class LoadingDialog extends Dialog {
|
|
|
|
|
+ String text;
|
|
|
|
|
+ final List<PhoneInfo> phoneList;
|
|
|
|
|
+
|
|
|
|
|
+ LoadingDialog({Key key, @required this.text, this.phoneList = const []}) : super(key: key);
|
|
|
|
|
+
|
|
|
|
|
+ @override
|
|
|
|
|
+ Widget build(BuildContext context) {
|
|
|
|
|
+ return WillPopScope(
|
|
|
|
|
+ child: Scaffold(
|
|
|
|
|
+ backgroundColor: Color(0xCC000000),
|
|
|
|
|
+ body: Container(
|
|
|
|
|
+ child: SizedBox.expand(
|
|
|
|
|
+ child: UnconstrainedBox(
|
|
|
|
|
+ child: Container(
|
|
|
|
|
+ width: 320,
|
|
|
|
|
+ // padding: EdgeInsets.symmetric(horizontal: 20, vertical: 25),
|
|
|
|
|
+ height: 360,
|
|
|
|
|
+ decoration: BoxDecoration(color: Color(0xFF15151D), border: Border.all(width: 1, color: Theme.of(context).primaryColor)),
|
|
|
|
|
+ child: Stack(
|
|
|
|
|
+ children: <Widget>[
|
|
|
|
|
+ Padding(
|
|
|
|
|
+ padding: EdgeInsets.symmetric(horizontal: 20, vertical: 25),
|
|
|
|
|
+ child: Column(
|
|
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
+ children: <Widget>[
|
|
|
|
|
+ Text(text, style: TextStyle(color: Color(0xFFC2524D), fontSize: 14), textAlign: TextAlign.center),
|
|
|
|
|
+ // Container(
|
|
|
|
|
+ // height: 30,
|
|
|
|
|
+ // ),
|
|
|
|
|
+ Container(
|
|
|
|
|
+ width: double.infinity,
|
|
|
|
|
+ height: 180,
|
|
|
|
|
+ margin: EdgeInsets.fromLTRB(0, 0, 0, 20),
|
|
|
|
|
+ child: GridView.builder(
|
|
|
|
|
+ gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
|
+ crossAxisCount: 2, //每行三列
|
|
|
|
|
+ childAspectRatio: 3.0 //显示区域宽高相等
|
|
|
|
|
+ ),
|
|
|
|
|
+ itemCount: phoneList.length,
|
|
|
|
|
+ itemBuilder: (context, index) {
|
|
|
|
|
+ //如果显示到最后一个并且Icon总数小于200时继续获取数据
|
|
|
|
|
+
|
|
|
|
|
+ return InkWell(
|
|
|
|
|
+ child: Container(
|
|
|
|
|
+ margin: EdgeInsets.all(5),
|
|
|
|
|
+ color: Colors.white,
|
|
|
|
|
+ child: Center(
|
|
|
|
|
+ child: Text(phoneList[index].phone),
|
|
|
|
|
+ ),
|
|
|
|
|
+ ),
|
|
|
|
|
+ onTap: () {
|
|
|
|
|
+ var list = phoneList[index].image.split(',');
|
|
|
|
|
+ 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 PhotoView(imageList: list);
|
|
|
|
|
+ },
|
|
|
|
|
+ ),
|
|
|
|
|
+ );
|
|
|
|
|
+ },
|
|
|
|
|
+ );
|
|
|
|
|
+ })),
|
|
|
|
|
+ Container(
|
|
|
|
|
+ child: LinearButton(
|
|
|
|
|
+ btntext: '关闭',
|
|
|
|
|
+ btnHeight: 36.0,
|
|
|
|
|
+ colorList: [Color(0xFF271A21), Color(0xFF271A21)],
|
|
|
|
|
+ textColor: Color(0xFFD4504B),
|
|
|
|
|
+ textWeight: FontWeight.w400,
|
|
|
|
|
+ onTapHomeMenu: () {
|
|
|
|
|
+ Navigator.of(context).pop();
|
|
|
|
|
+ },
|
|
|
|
|
+ ),
|
|
|
|
|
+ ),
|
|
|
|
|
+ // Container(
|
|
|
|
|
+ // height: 5,
|
|
|
|
|
+ // )
|
|
|
|
|
+ ],
|
|
|
|
|
+ ),
|
|
|
|
|
+ ),
|
|
|
|
|
+ Positioned(
|
|
|
|
|
+ top: 0,
|
|
|
|
|
+ left: 0,
|
|
|
|
|
+ child: Image.asset(
|
|
|
|
|
+ 'images/tancuang_shang.png',
|
|
|
|
|
+ // width: 131,
|
|
|
|
|
+ ),
|
|
|
|
|
+ ),
|
|
|
|
|
+ Positioned(
|
|
|
|
|
+ bottom: 0,
|
|
|
|
|
+ right: 4,
|
|
|
|
|
+ child: Image.asset(
|
|
|
|
|
+ 'images/tancuang_xia.png',
|
|
|
|
|
+ // width: 148,
|
|
|
|
|
+ ),
|
|
|
|
|
+ ),
|
|
|
|
|
+ ],
|
|
|
|
|
+ ),
|
|
|
|
|
+ ),
|
|
|
|
|
+ ),
|
|
|
|
|
+ ),
|
|
|
|
|
+ ),
|
|
|
|
|
+ ),
|
|
|
|
|
+ onWillPop: () {
|
|
|
|
|
+ return Future.value(false);
|
|
|
|
|
+ },
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+}
|