HomePage.dart 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. import 'package:flutter/material.dart';
  2. import 'package:wanna_battle/model/PlayerInfo.dart';
  3. import 'package:flutter/cupertino.dart';
  4. import 'GuidePage.dart';
  5. import 'MatchPage.dart';
  6. import 'RankList.dart';
  7. import '../widget/BottomTabs.dart';
  8. import 'UserPage.dart';
  9. import '../net/HttpManager.dart';
  10. import '../net/Result.dart';
  11. import '../widget/Dialog.dart';
  12. import 'Appeal.dart';
  13. import '../model/HouseInfo.dart';
  14. import 'RoomInfo.dart';
  15. class HomePage extends StatefulWidget {
  16. @override
  17. _HomePageState createState() => _HomePageState();
  18. }
  19. class _HomePageState extends State<HomePage> with SingleTickerProviderStateMixin {
  20. TabController controller;
  21. Future<void> checkErrorPlayerInfo() async {
  22. final Result res = await HttpManager.get('playerInfo/getErrorPlayerInfo');
  23. print('&********');
  24. print(res.error);
  25. if (res.success) {
  26. final PlayerInfo playerInfo = PlayerInfo.fromJson(res.data);
  27. // MyDialog.showDialog(
  28. // context,
  29. // '由于系统性能安全策略问题导致本次比赛结果上传失败,你可以上传本次比赛结果照片进行结果申诉',
  30. // isCancel: true,
  31. // onsubmit: () {
  32. // Navigator.push(context, CupertinoPageRoute(builder: (context) => Appeal(playerInfo)));
  33. // },
  34. // );
  35. final res1 = await HttpManager.get('houseInfo/getOne', data: {'id': playerInfo.houseId});
  36. if (res1.success && res1.data != null) {
  37. Navigator.push(
  38. context,
  39. CupertinoPageRoute(
  40. builder: (context) => RoomInfo(
  41. roomId:res1.data['id'].toString(),
  42. // playerInfo: playerInfo,
  43. // interrupted: true,
  44. ),
  45. ),
  46. );
  47. }
  48. } else {
  49. //引导页
  50. showGruide();
  51. }
  52. }
  53. @override
  54. void initState() {
  55. super.initState();
  56. controller = new TabController(length: 3, vsync: this);
  57. Future.delayed(Duration.zero, () {
  58. checkErrorPlayerInfo();
  59. });
  60. }
  61. @override
  62. void dispose() {
  63. controller.dispose();
  64. super.dispose();
  65. }
  66. @override
  67. Widget build(BuildContext context) {
  68. return Scaffold(
  69. body: WillPopScope(
  70. child: Container(
  71. color: Color(0xFF2E3049),
  72. child: new MyTabBarView(
  73. controller: controller,
  74. children: <Widget>[MatchPage(), RankList(), UserPage()],
  75. ),
  76. ),
  77. onWillPop: () {
  78. return Future.value(true);
  79. },
  80. ),
  81. bottomNavigationBar: new Container(
  82. color: Color(0xFF23253C),
  83. height: 49,
  84. child: new MyTabBar(
  85. controller: controller,
  86. labelColor: Theme.of(context).primaryColor,
  87. unselectedLabelColor: Color(0xFF46496C),
  88. indicatorColor: Color(0xFF171721),
  89. labelPadding: EdgeInsets.zero,
  90. labelStyle: TextStyle(fontSize: 11, height: 1),
  91. tabs: <Widget>[
  92. new MyTab(
  93. text: "赛事",
  94. icon: ImageIcon(AssetImage('images/tabbar_icon_01_pre.png'), size: 28),
  95. ),
  96. MyTab(
  97. text: "排行",
  98. icon: ImageIcon(AssetImage('images/tabbar_icon_02.png'), size: 28),
  99. ),
  100. new MyTab(
  101. text: "我的",
  102. icon: ImageIcon(AssetImage('images/tabbar_icon_03.png'), size: 28),
  103. ),
  104. ],
  105. ),
  106. )
  107. // floatingActionButton: floatWidget(),
  108. // floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
  109. );
  110. }
  111. void showGruide() {
  112. Navigator.of(context).push(PageRouteBuilder(
  113. opaque: false,
  114. transitionDuration: Duration(milliseconds: 300),
  115. transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
  116. return FadeTransition(
  117. opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
  118. child: child,
  119. );
  120. },
  121. pageBuilder: (BuildContext context, _, __) {
  122. return GuidePage();
  123. }));
  124. }
  125. }