|
|
@@ -12,6 +12,9 @@ import '../styles/totast.dart';
|
|
|
import '../net/HttpManager.dart';
|
|
|
import '../net/Result.dart';
|
|
|
import 'TipList.dart';
|
|
|
+import 'package:flutter_redux/flutter_redux.dart';
|
|
|
+import '../redux/AppState.dart';
|
|
|
+import '../model/UserInfo.dart';
|
|
|
|
|
|
class HomePage extends StatefulWidget {
|
|
|
@override
|
|
|
@@ -22,6 +25,7 @@ class _HomePageState extends State<HomePage> {
|
|
|
List<CompetitionSeason> seasonList = [];
|
|
|
int nowIndex = 0;
|
|
|
PageController _pageController;
|
|
|
+ bool showBadge = false;
|
|
|
|
|
|
void getSeasonInfo() async {
|
|
|
Toast.show(context, '加载中', -1, 'loading');
|
|
|
@@ -66,23 +70,46 @@ class _HomePageState extends State<HomePage> {
|
|
|
|
|
|
void getOneRoom() async {
|
|
|
Toast.show(context, '加载中', -1, 'loading');
|
|
|
- Result res = await HttpManager.get("houseInfo/getOne", data: {'statusFlag': 0});
|
|
|
+ Result res =
|
|
|
+ await HttpManager.get("houseInfo/getOne", data: {'statusFlag': 0});
|
|
|
Toast.hide();
|
|
|
if (res.success) {
|
|
|
if (res.data != null) {
|
|
|
- Navigator.push(context, new CupertinoPageRoute(builder: (context) => new RoomInfo(roomId: res.data['id'].toString())));
|
|
|
+ Navigator.push(
|
|
|
+ context,
|
|
|
+ new CupertinoPageRoute(
|
|
|
+ builder: (context) =>
|
|
|
+ new RoomInfo(roomId: res.data['id'].toString())));
|
|
|
} else {
|
|
|
showBackDialog();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ void getShowBadge() async {
|
|
|
+ Result res = await HttpManager.get("systemNotice/unread", data: {
|
|
|
+ 'userId': StoreProvider.of<AppState>(context).state.userInfo.id
|
|
|
+ });
|
|
|
+ if (res.success&&res.data!=null) {
|
|
|
+ if (res.data>0) {
|
|
|
+ setState(() {
|
|
|
+ showBadge = true;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ setState(() {
|
|
|
+ showBadge = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@override
|
|
|
void initState() {
|
|
|
super.initState();
|
|
|
_pageController = PageController(initialPage: 0);
|
|
|
Future.delayed(Duration.zero, () {
|
|
|
getSeasonInfo();
|
|
|
+ getShowBadge();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -94,8 +121,10 @@ class _HomePageState extends State<HomePage> {
|
|
|
width: double.infinity,
|
|
|
height: double.infinity,
|
|
|
decoration: BoxDecoration(
|
|
|
- gradient: LinearGradient(
|
|
|
- colors: [Color.fromARGB(255, 177, 59, 56), Color.fromARGB(255, 147, 64, 61)], begin: Alignment.topCenter, end: Alignment.bottomCenter)),
|
|
|
+ gradient: LinearGradient(colors: [
|
|
|
+ Color.fromARGB(255, 177, 59, 56),
|
|
|
+ Color.fromARGB(255, 147, 64, 61)
|
|
|
+ ], begin: Alignment.topCenter, end: Alignment.bottomCenter)),
|
|
|
child: SafeArea(
|
|
|
child: centerWidget(context),
|
|
|
),
|
|
|
@@ -117,7 +146,11 @@ class _HomePageState extends State<HomePage> {
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
loop: true,
|
|
|
onTap: (index) {
|
|
|
- Navigator.push(context, new CupertinoPageRoute(builder: (context) => new RankList(raceId: seasonList[index].id)));
|
|
|
+ Navigator.push(
|
|
|
+ context,
|
|
|
+ new CupertinoPageRoute(
|
|
|
+ builder: (context) => new RankList(
|
|
|
+ raceId: seasonList[index].id)));
|
|
|
},
|
|
|
onIndexChanged: (index) {
|
|
|
setState(() {
|
|
|
@@ -134,12 +167,15 @@ class _HomePageState extends State<HomePage> {
|
|
|
Image.asset("images/home_icon_yuan.png"),
|
|
|
Center(
|
|
|
child: Row(
|
|
|
- mainAxisAlignment: MainAxisAlignment.center,
|
|
|
- crossAxisAlignment: CrossAxisAlignment.baseline,
|
|
|
+ mainAxisAlignment:
|
|
|
+ MainAxisAlignment.center,
|
|
|
+ crossAxisAlignment:
|
|
|
+ CrossAxisAlignment.baseline,
|
|
|
textBaseline: TextBaseline.alphabetic,
|
|
|
children: <Widget>[
|
|
|
Text(
|
|
|
- (seasonList[index].bonus / 1000).toStringAsFixed(1),
|
|
|
+ (seasonList[index].bonus / 1000)
|
|
|
+ .toStringAsFixed(1),
|
|
|
style: TextStyle(
|
|
|
color: Colors.white,
|
|
|
fontSize: 68,
|
|
|
@@ -211,7 +247,10 @@ class _HomePageState extends State<HomePage> {
|
|
|
color: Colors.transparent,
|
|
|
child: InkWell(
|
|
|
onTap: () {
|
|
|
- Navigator.push(context, new CupertinoPageRoute(builder: (context) => new Setting()));
|
|
|
+ Navigator.push(
|
|
|
+ context,
|
|
|
+ new CupertinoPageRoute(
|
|
|
+ builder: (context) => new Setting()));
|
|
|
},
|
|
|
child: Padding(
|
|
|
padding: EdgeInsets.all(12),
|
|
|
@@ -233,7 +272,9 @@ class _HomePageState extends State<HomePage> {
|
|
|
style: TextStyle(color: Colors.white, fontSize: 14),
|
|
|
),
|
|
|
Text(
|
|
|
- seasonList.length > 0 ? seasonList[nowIndex].gameInfo.gameName : '',
|
|
|
+ seasonList.length > 0
|
|
|
+ ? seasonList[nowIndex].gameInfo.gameName
|
|
|
+ : '',
|
|
|
style: TextStyle(color: Colors.white, fontSize: 14),
|
|
|
)
|
|
|
],
|
|
|
@@ -255,9 +296,13 @@ class _HomePageState extends State<HomePage> {
|
|
|
Navigator.of(context).push(PageRouteBuilder(
|
|
|
opaque: false,
|
|
|
transitionDuration: Duration(milliseconds: 300),
|
|
|
- transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
|
|
|
+ transitionsBuilder: (BuildContext context,
|
|
|
+ Animation<double> animation,
|
|
|
+ Animation<double> secondaryAnimation,
|
|
|
+ Widget child) {
|
|
|
return FadeTransition(
|
|
|
- opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
|
|
|
+ opacity: CurvedAnimation(
|
|
|
+ parent: animation, curve: Curves.linear),
|
|
|
child: child,
|
|
|
);
|
|
|
},
|
|
|
@@ -277,16 +322,22 @@ class _HomePageState extends State<HomePage> {
|
|
|
"images/home_icon_sousuo.png",
|
|
|
"搜索",
|
|
|
onTapHomeMenu: () {
|
|
|
- Navigator.push(context, new CupertinoPageRoute(builder: (context) => new RoomList()));
|
|
|
+ Navigator.push(
|
|
|
+ context,
|
|
|
+ new CupertinoPageRoute(
|
|
|
+ builder: (context) => new RoomList()));
|
|
|
},
|
|
|
),
|
|
|
HomeMenu(
|
|
|
"images/home_icon_youjian.png",
|
|
|
"邮件",
|
|
|
onTapHomeMenu: () {
|
|
|
- Navigator.push(context, new CupertinoPageRoute(builder: (context) => new TipList()));
|
|
|
+ Navigator.push(
|
|
|
+ context,
|
|
|
+ new CupertinoPageRoute(
|
|
|
+ builder: (context) => new TipList()));
|
|
|
},
|
|
|
- showBadge: false,
|
|
|
+ showBadge: showBadge,
|
|
|
),
|
|
|
],
|
|
|
),
|
|
|
@@ -307,8 +358,11 @@ class HomeMenu extends StatelessWidget {
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
return Container(
|
|
|
- decoration:
|
|
|
- BoxDecoration(gradient: LinearGradient(begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [Color(0xFF626C85), Color(0xFF3D3E6C)])),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ gradient: LinearGradient(
|
|
|
+ begin: Alignment.topCenter,
|
|
|
+ end: Alignment.bottomCenter,
|
|
|
+ colors: [Color(0xFF626C85), Color(0xFF3D3E6C)])),
|
|
|
child: AspectRatio(
|
|
|
aspectRatio: 1,
|
|
|
child: Container(
|
|
|
@@ -341,7 +395,10 @@ class HomeMenu extends StatelessWidget {
|
|
|
child: Container(
|
|
|
width: showBadge ? 10 : 0,
|
|
|
height: showBadge ? 10 : 0,
|
|
|
- decoration: BoxDecoration(color: Color.fromARGB(255, 239, 0, 9), borderRadius: BorderRadius.all(Radius.circular(10))),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: Color.fromARGB(255, 239, 0, 9),
|
|
|
+ borderRadius:
|
|
|
+ BorderRadius.all(Radius.circular(10))),
|
|
|
),
|
|
|
)
|
|
|
],
|