x1ongzhu пре 6 година
родитељ
комит
d2c384c341
5 измењених фајлова са 49 додато и 96 уклоњено
  1. 2 2
      lib/main.dart
  2. 1 1
      lib/pages/CreateRoom.dart
  3. 17 9
      lib/pages/HomePage.dart
  4. 1 2
      lib/pages/loginSecond.dart
  5. 28 82
      lib/pages/openRoom.dart

+ 2 - 2
lib/main.dart

@@ -52,6 +52,7 @@ class MobileCyberGamesApp extends StatelessWidget {
               splashColor: Color(0xFF9B4040),
             )),
         home: store.state.userInfo != null ? HomePage() : LoginFirst(),
+        routes: {"/home": (BuildContext context) => HomePage()},
       ),
     );
   }
@@ -69,8 +70,7 @@ void main() async {
     production: true,
     debug: true,
   );
-  jpush.applyPushAuthority(
-      new NotificationSettingsIOS(sound: true, alert: true, badge: true));
+  jpush.applyPushAuthority(new NotificationSettingsIOS(sound: true, alert: true, badge: true));
   final prefs = await SharedPreferences.getInstance();
   print(prefs.getString('token'));
   HttpManager.token = prefs.getString('token') ?? "";

+ 1 - 1
lib/pages/CreateRoom.dart

@@ -48,7 +48,7 @@ class _CreateRoomBtn extends StatelessWidget {
   Widget build(BuildContext context) {
     return GestureDetector(
       onTap: () {
-        Navigator.push(
+        Navigator.pushReplacement(
             context,
             new CupertinoPageRoute(
                 builder: (context) => new OpenRoom(

+ 17 - 9
lib/pages/HomePage.dart

@@ -122,15 +122,20 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
   Widget build(BuildContext context) {
     return Scaffold(
       drawer: HomeDrawer(),
-      body: Container(
-        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)),
-        child: SafeArea(
-          child: centerWidget(context),
+      body: WillPopScope(
+        child: Container(
+          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)),
+          child: SafeArea(
+            child: centerWidget(context),
+          ),
         ),
+        onWillPop: () {
+          Future.value(true);
+        },
       ),
     );
   }
@@ -149,7 +154,10 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
                           scrollDirection: Axis.horizontal,
                           loop: false,
                           onTap: (index) {
-                            Navigator.push(context, new CupertinoPageRoute(builder: (context) => new RankList(raceId: seasonList[index].id,gameId:seasonList[index].competitionSeason.gameId)));
+                            Navigator.push(
+                                context,
+                                new CupertinoPageRoute(
+                                    builder: (context) => new RankList(raceId: seasonList[index].id, gameId: seasonList[index].competitionSeason.gameId)));
                           },
                           onIndexChanged: (index) {
                             setState(() {

+ 1 - 2
lib/pages/loginSecond.dart

@@ -143,10 +143,9 @@ class LoginSecondState extends State<LoginSecond> {
                                       StoreProvider.of<AppState>(context).dispatch(UpdateUserAction(UserInfo.fromJson(res.data)));
 
                                       Toast.show(context, '登录成功', 1500, 'success');
-                                      Navigator.pushAndRemoveUntil(
+                                      Navigator.pushReplacement(
                                         context,
                                         new CupertinoPageRoute(builder: (context) => new HomePage()),
-                                        ModalRoute.withName('/'),
                                       );
                                     } else {
                                       Toast.show(context, res.error, 1500, 'info');

+ 28 - 82
lib/pages/openRoom.dart

@@ -26,14 +26,9 @@ class OpenRoom extends StatefulWidget {
 
 class OpenRoomState extends State<OpenRoom> {
   TextStyle titleStyle = TextStyle(color: Colors.white, fontSize: 14);
-  TextStyle valStyle =
-      TextStyle(color: Colors.white, fontSize: 15, fontWeight: FontWeight.w500);
+  TextStyle valStyle = TextStyle(color: Colors.white, fontSize: 15, fontWeight: FontWeight.w500);
 
-  Map<String, dynamic> editRoomInfo = {
-    "gameId": 1,
-    "houseLevel": 1,
-    "maxNumber": 10
-  };
+  Map<String, dynamic> editRoomInfo = {"gameId": 1, "houseLevel": 1, "maxNumber": 10};
   List<GameInfo> gameList = [];
   List<HouseLevel> levelList = [];
 
@@ -65,36 +60,23 @@ class OpenRoomState extends State<OpenRoom> {
       Toast.show(context, '请选择房间等级', 1500, 'info');
       return;
     }
-    if (editRoomInfo['houseType'] == '1' &&
-        (editRoomInfo['gameHouseId'] == null ||
-            editRoomInfo['gameHouseId'] == '')) {
+    if (editRoomInfo['houseType'] == '1' && (editRoomInfo['gameHouseId'] == null || editRoomInfo['gameHouseId'] == '')) {
       Toast.show(context, '请录入游戏房间号', 1500, 'info');
       return;
     }
-    if (editRoomInfo['houseType'] == '1' &&
-        (editRoomInfo['gameHousePassword'] == null ||
-            editRoomInfo['gameHousePassword'] == '')) {
+    if (editRoomInfo['houseType'] == '1' && (editRoomInfo['gameHousePassword'] == null || editRoomInfo['gameHousePassword'] == '')) {
       Toast.show(context, '请录入游戏房间密码', 1500, 'info');
       return;
     }
-    editRoomInfo['createUser'] =
-        StoreProvider.of<AppState>(context).state.userInfo.id;
+    editRoomInfo['createUser'] = StoreProvider.of<AppState>(context).state.userInfo.id;
     Toast.show(context, '加载中', -1, 'loading');
     Result res = await HttpManager.post("houseInfo/save", data: editRoomInfo);
     Toast.hide();
     if (res.success) {
-      HttpManager.post("houseInfo/join", data: {
-        "houseId": res.data,
-        "userId": StoreProvider.of<AppState>(context).state.userInfo.id
-      });
+      HttpManager.post("houseInfo/join", data: {"houseId": res.data, "userId": StoreProvider.of<AppState>(context).state.userInfo.id});
       Toast.show(context, '创建成功', 1500, 'success');
       Future.delayed(Duration(milliseconds: 1500), () {
-        Navigator.pushAndRemoveUntil(
-            context,
-            new CupertinoPageRoute(
-                builder: (context) =>
-                    new RoomInfo(roomId: res.data.toString())),
-            ModalRoute.withName('/'));
+        Navigator.pushReplacement(context, new CupertinoPageRoute(builder: (context) => new RoomInfo(roomId: res.data.toString())));
       });
     } else {}
   }
@@ -111,15 +93,12 @@ class OpenRoomState extends State<OpenRoom> {
         gameList = _list;
         if (res.data.length > 0) {
           editRoomInfo['gameId'] = res.data[0]['id'];
-          editRoomInfo['houseName'] =
-              StoreProvider.of<AppState>(context).state.userInfo.nickname +'的'+
-                  res.data[0]['shortName']+'房间';
-                  editRoomInfo['houseAbstract']=res.data[0]['profile']??'';
+          editRoomInfo['houseName'] = StoreProvider.of<AppState>(context).state.userInfo.nickname + '的' + res.data[0]['shortName'] + '房间';
+          editRoomInfo['houseAbstract'] = res.data[0]['profile'] ?? '';
         }
       });
     } else {}
 
-
     Result res2 = await HttpManager.get("houseLevel/all");
     Toast.hide();
     if (res2.success) {
@@ -175,8 +154,7 @@ class OpenRoomState extends State<OpenRoom> {
                 child: FlatButton(
                   highlightColor: PRIMARY_COLOR,
                   padding: EdgeInsets.only(right: 0),
-                  child: Text('规则',
-                      style: TextStyle(color: Colors.white, fontSize: 13)),
+                  child: Text('规则', style: TextStyle(color: Colors.white, fontSize: 13)),
                   onPressed: () {},
                 ),
               )
@@ -237,11 +215,8 @@ class OpenRoomState extends State<OpenRoom> {
                           Padding(
                             padding: EdgeInsets.only(top: 12),
                             child: Text(
-                              editRoomInfo.containsKey('video')
-                                  ? '已选择'
-                                  : '不上传则自动使用官方默认视频',
-                              style: TextStyle(
-                                  color: Color(0xFF9BA0AE), fontSize: 13),
+                              editRoomInfo.containsKey('video') ? '已选择' : '不上传则自动使用官方默认视频',
+                              style: TextStyle(color: Color(0xFF9BA0AE), fontSize: 13),
                             ),
                           )
                         ],
@@ -283,7 +258,7 @@ class OpenRoomState extends State<OpenRoom> {
                       color: BG_SUB_COLOR,
                     ),
                     //房间简介
-                     InputContent(
+                    InputContent(
                         title: '房间简介',
                         value: editRoomInfo['houseAbstract'],
                         onTextChange: (value) {
@@ -351,24 +326,17 @@ class OpenRoomState extends State<OpenRoom> {
                           children: <Widget>[
                             Padding(
                               padding: EdgeInsets.only(right: 6),
-                              child: Image.asset('images/icon_jinbi_da_bai.png',
-                                  width: 20),
+                              child: Image.asset('images/icon_jinbi_da_bai.png', width: 20),
                             ),
                             Text(
                               'X' + (chooseLevelInfo.entryCoin ?? 0).toString(),
-                              style: TextStyle(
-                                  color: Colors.white,
-                                  fontSize: 16,
-                                  fontWeight: FontWeight.w500),
+                              style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
                             ),
                             Padding(
                               padding: EdgeInsets.only(left: 20),
                               child: Text(
                                 '创建房间',
-                                style: TextStyle(
-                                    color: Colors.white,
-                                    fontSize: 16,
-                                    fontWeight: FontWeight.w500),
+                                style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
                               ),
                             )
                           ],
@@ -465,16 +433,15 @@ class OpenRoomState extends State<OpenRoom> {
     new Picker(
         confirmText: '确定',
         cancelText: "取消",
-        adapter: PickerDataAdapter<String>(
-            pickerdata: new JsonDecoder().convert(PickerData)),
+        adapter: PickerDataAdapter<String>(pickerdata: new JsonDecoder().convert(PickerData)),
         changeToFirst: true,
         textAlign: TextAlign.left,
         columnPadding: const EdgeInsets.all(8.0),
         onConfirm: (Picker picker, List value) {
           setState(() {
             editRoomInfo['gameId'] = gameList[value[0]].id;
-            editRoomInfo['houseName']=StoreProvider.of<AppState>(context).state.userInfo.nickname +'的'+gameList[value[0]].shortName+'房间';
-            editRoomInfo['houseAbstract']=gameList[value[0]].profile??'';
+            editRoomInfo['houseName'] = StoreProvider.of<AppState>(context).state.userInfo.nickname + '的' + gameList[value[0]].shortName + '房间';
+            editRoomInfo['houseAbstract'] = gameList[value[0]].profile ?? '';
           });
         }).showModal(this.context);
   }
@@ -489,8 +456,7 @@ class OpenRoomState extends State<OpenRoom> {
     new Picker(
         confirmText: '确定',
         cancelText: "取消",
-        adapter: PickerDataAdapter<String>(
-            pickerdata: new JsonDecoder().convert(PickerData)),
+        adapter: PickerDataAdapter<String>(pickerdata: new JsonDecoder().convert(PickerData)),
         changeToFirst: true,
         textAlign: TextAlign.left,
         columnPadding: const EdgeInsets.all(8.0),
@@ -510,8 +476,7 @@ class OpenRoomState extends State<OpenRoom> {
     new Picker(
         confirmText: '确定',
         cancelText: "取消",
-        adapter: PickerDataAdapter<String>(
-            pickerdata: new JsonDecoder().convert(PickerData)),
+        adapter: PickerDataAdapter<String>(pickerdata: new JsonDecoder().convert(PickerData)),
         changeToFirst: true,
         textAlign: TextAlign.left,
         columnPadding: const EdgeInsets.all(8.0),
@@ -527,14 +492,7 @@ typedef int OnTapHomeMenu();
 typedef ValueChanged<T> = void Function(T value);
 
 class ChooseContent extends StatelessWidget {
-  ChooseContent(
-      {Key key,
-      this.title,
-      this.val,
-      this.chooseLevelInfo,
-      this.isLevel = false,
-      this.onTapHomeMenu})
-      : super(key: key);
+  ChooseContent({Key key, this.title, this.val, this.chooseLevelInfo, this.isLevel = false, this.onTapHomeMenu}) : super(key: key);
   final String title;
   final String val;
   final OnTapHomeMenu onTapHomeMenu;
@@ -569,24 +527,15 @@ class ChooseContent extends StatelessWidget {
                         ),
                         Padding(
                           padding: EdgeInsets.only(left: 20, right: 2),
-                          child: Image.asset('images/icon_jinbi_da_bai.png',
-                              width: 20),
+                          child: Image.asset('images/icon_jinbi_da_bai.png', width: 20),
                         ),
                         Text(
                           'X' + (chooseLevelInfo.entryCoin ?? 0).toString(),
-                          style: TextStyle(
-                              color: Colors.white,
-                              fontSize: 15,
-                              fontWeight: FontWeight.w500),
+                          style: TextStyle(color: Colors.white, fontSize: 15, fontWeight: FontWeight.w500),
                         )
                       ],
                     )
-                  : Text(val ?? '',
-                      style: TextStyle(
-                          fontSize: 15,
-                          color: Colors.white,
-                          fontWeight: FontWeight.w500),
-                      textAlign: TextAlign.right),
+                  : Text(val ?? '', style: TextStyle(fontSize: 15, color: Colors.white, fontWeight: FontWeight.w500), textAlign: TextAlign.right),
             ),
             Image.asset('images/icon_inter.png', width: 24)
           ],
@@ -598,8 +547,7 @@ class ChooseContent extends StatelessWidget {
 }
 
 class InputContent extends StatefulWidget {
-  InputContent({Key key, this.title, this.value, this.onTextChange})
-      : super(key: key);
+  InputContent({Key key, this.title, this.value, this.onTextChange}) : super(key: key);
   final String title;
   final String value;
   final ValueChanged onTextChange;
@@ -632,16 +580,14 @@ class InputContentState extends State<InputContent> {
       child: TextField(
         controller: _controller,
         textAlign: TextAlign.end,
-        style: TextStyle(
-            fontSize: 15, color: Colors.white, fontWeight: FontWeight.w500),
+        style: TextStyle(fontSize: 15, color: Colors.white, fontWeight: FontWeight.w500),
         maxLength: 10,
         decoration: InputDecoration(
             hintText: "请输入" + widget.title,
             hintStyle: TextStyle(color: Color(0xFF727785), fontSize: 13),
             prefixIcon: Padding(
               padding: EdgeInsets.symmetric(vertical: 12),
-              child: Text(widget.title,
-                  style: TextStyle(fontSize: 14, color: Colors.white)),
+              child: Text(widget.title, style: TextStyle(fontSize: 14, color: Colors.white)),
             ),
             border: InputBorder.none,
             counterStyle: TextStyle(fontSize: 0)),