x1ongzhu 6 rokov pred
rodič
commit
607ea8bad0

+ 1 - 1
android/app/build.gradle

@@ -39,7 +39,7 @@ android {
         versionName flutterVersionName
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
         ndk {
-            abiFilters 'armeabi-v7a'
+            // abiFilters 'armeabi-v7a'
         }
         manifestPlaceholders = [
             JPUSH_PKGNAME : applicationId,

BIN
fonts/DINEngschrift.ttf


+ 102 - 94
lib/pages/HomePage.dart

@@ -108,8 +108,8 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
 
   @override
   void dispose() {
-    WidgetsBinding.instance.removeObserver(this);
     super.dispose();
+    WidgetsBinding.instance.removeObserver(this);
   }
 
   @override
@@ -176,7 +176,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
                                               style: TextStyle(
                                                 color: Colors.white,
                                                 fontSize: 68,
-                                                fontFamily: 'AgencyFB',
+                                                fontFamily: 'DINEngschrift',
                                               ),
                                             ),
                                             Text(
@@ -184,7 +184,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
                                               style: TextStyle(
                                                 color: Colors.white,
                                                 fontSize: 36,
-                                                fontFamily: 'AgencyFB',
+                                                fontFamily: 'DINEngschrift',
                                               ),
                                             )
                                           ],
@@ -275,55 +275,66 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
             ],
           ),
         ),
-        Container(
-          child: GridView.count(
-            physics: new BouncingScrollPhysics(),
-            shrinkWrap: true,
-            crossAxisCount: 2,
-            children: <Widget>[
-              HomeMenu(
-                "images/home_icon_fangjian.png",
-                "创建房间",
-                onTapHomeMenu: () {
-                  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 CreateRoom();
-                      }));
-                },
-              ),
-              HomeMenu(
-                "images/home_icon_kuaisu.png",
-                "快速进入",
-                onTapHomeMenu: () {
-                  getOneRoom();
-                },
-              ),
-              HomeMenu(
-                "images/home_icon_sousuo.png",
-                "搜索",
-                onTapHomeMenu: () {
-                  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()));
-                },
-                showBadge: showBadge,
+        Builder(
+          builder: (BuildContext context) {
+            double width = MediaQuery.of(context).size.width;
+            double height = MediaQuery.of(context).size.height;
+            double aspectRatio = 1;
+            if (height / width < 17 / 9) {
+              aspectRatio = width / (height - 334);
+            }
+            return Container(
+              child: GridView.count(
+                physics: new BouncingScrollPhysics(),
+                shrinkWrap: true,
+                crossAxisCount: 2,
+                childAspectRatio: aspectRatio,
+                children: <Widget>[
+                  HomeMenu(
+                    "images/home_icon_fangjian.png",
+                    "创建房间",
+                    onTapHomeMenu: () {
+                      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 CreateRoom();
+                          }));
+                    },
+                  ),
+                  HomeMenu(
+                    "images/home_icon_kuaisu.png",
+                    "快速进入",
+                    onTapHomeMenu: () {
+                      getOneRoom();
+                    },
+                  ),
+                  HomeMenu(
+                    "images/home_icon_sousuo.png",
+                    "搜索",
+                    onTapHomeMenu: () {
+                      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()));
+                    },
+                    showBadge: showBadge,
+                  ),
+                ],
               ),
-            ],
-          ),
-        )
+            );
+          },
+        ),
       ],
     );
   }
@@ -342,51 +353,48 @@ class HomeMenu extends StatelessWidget {
     return Container(
       decoration:
           BoxDecoration(gradient: LinearGradient(begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [Color(0xFF626C85), Color(0xFF3D3E6C)])),
-      child: AspectRatio(
-        aspectRatio: 1,
-        child: Container(
-          decoration: BoxDecoration(
-              border: Border(
-                  left: BorderSide(width: 0.5, color: Color(0x80000000)),
-                  right: BorderSide(width: 0.5, color: Color(0x80000000)),
-                  bottom: BorderSide(width: 1, color: Color(0x80000000)))),
-          child: Material(
-            color: Colors.transparent,
-            child: InkWell(
-              onTap: onTapHomeMenu,
-              child: Column(
-                mainAxisAlignment: MainAxisAlignment.center,
-                children: <Widget>[
-                  Container(
-                    width: 44,
-                    height: 34,
-                    child: Stack(
-                      children: <Widget>[
-                        Image.asset(
-                          icon,
-                          fit: BoxFit.contain,
-                          width: 44,
-                          height: 34,
+      child: Container(
+        decoration: BoxDecoration(
+            border: Border(
+                left: BorderSide(width: 0.5, color: Color(0x80000000)),
+                right: BorderSide(width: 0.5, color: Color(0x80000000)),
+                bottom: BorderSide(width: 1, color: Color(0x80000000)))),
+        child: Material(
+          color: Colors.transparent,
+          child: InkWell(
+            onTap: onTapHomeMenu,
+            child: Column(
+              mainAxisAlignment: MainAxisAlignment.center,
+              children: <Widget>[
+                Container(
+                  width: 44,
+                  height: 34,
+                  child: Stack(
+                    children: <Widget>[
+                      Image.asset(
+                        icon,
+                        fit: BoxFit.contain,
+                        width: 44,
+                        height: 34,
+                      ),
+                      Positioned(
+                        right: 0,
+                        top: 0,
+                        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))),
                         ),
-                        Positioned(
-                          right: 0,
-                          top: 0,
-                          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))),
-                          ),
-                        )
-                      ],
-                    ),
+                      )
+                    ],
                   ),
-                  Text(
-                    title,
-                    style: TextStyle(color: Colors.white, fontSize: 14),
-                    textAlign: TextAlign.center,
-                  )
-                ],
-              ),
+                ),
+                Text(
+                  title,
+                  style: TextStyle(color: Colors.white, fontSize: 14),
+                  textAlign: TextAlign.center,
+                )
+              ],
             ),
           ),
         ),

+ 25 - 7
lib/pages/loginSecond.dart

@@ -1,3 +1,5 @@
+import 'dart:async';
+
 import 'package:flutter/material.dart';
 import 'package:shared_preferences/shared_preferences.dart';
 import 'package:flutter/cupertino.dart';
@@ -26,6 +28,7 @@ class LoginSecondState extends State<LoginSecond> {
   int sendTime = 0;
   String inputCode;
   String useToken;
+  Timer timer;
 
   @override
   void initState() {
@@ -75,6 +78,9 @@ class LoginSecondState extends State<LoginSecond> {
                                     onPressed: isSend
                                         ? null
                                         : () {
+                                            if (timer != null) {
+                                              timer.cancel();
+                                            }
                                             sendMsg();
                                           },
                                   )
@@ -128,6 +134,9 @@ class LoginSecondState extends State<LoginSecond> {
                                         data: {"phone": widget.phone, "code": inputCode, "sessionId": _sessionID, "requireToken": true});
                                     Toast.hide();
                                     if (res.success) {
+                                      if (timer != null) {
+                                        timer.cancel();
+                                      }
                                       final prefs = await SharedPreferences.getInstance();
                                       await prefs.setString('token', res.token);
                                       HttpManager.token = res.token;
@@ -135,11 +144,10 @@ class LoginSecondState extends State<LoginSecond> {
 
                                       Toast.show(context, '登录成功', 1500, 'success');
                                       Navigator.pushAndRemoveUntil(
-                                          context,
-                                          new CupertinoPageRoute(
-                                            builder: (context) => new HomePage(),
-                                          ),
-                                          ModalRoute.withName('/'));
+                                        context,
+                                        new CupertinoPageRoute(builder: (context) => new HomePage()),
+                                        ModalRoute.withName('/'),
+                                      );
                                     } else {
                                       Toast.show(context, res.error, 1500, 'info');
                                     }
@@ -172,8 +180,18 @@ class LoginSecondState extends State<LoginSecond> {
       setState(() {
         isSend = true;
       });
-      sendTime = 61;
-      getTime();
+      sendTime = 60;
+      timer = Timer.periodic(new Duration(seconds: 1), (timer) {
+        if (sendTime == 0) {
+          setState(() {
+            isSend = false;
+          });
+        } else {
+          setState(() {
+            sendTime = sendTime - 1;
+          });
+        }
+      });
     } else {
       Toast.show(context, res.error, 1500, 'info');
     }

+ 11 - 6
lib/pages/setting.dart

@@ -4,7 +4,9 @@ import 'package:flutter/cupertino.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
 import 'package:dio/dio.dart';
 import 'package:intl/intl.dart';
+import 'package:jpush_flutter/jpush_flutter.dart';
 import 'package:package_info/package_info.dart';
+import 'package:shared_preferences/shared_preferences.dart';
 import '../styles/colors.dart';
 import 'dart:io';
 import 'dart:async';
@@ -151,13 +153,16 @@ class SettingState extends State<Setting> {
                             "退出登录",
                             style: TextStyle(fontSize: 16, fontWeight: FontWeight.w700),
                           ),
-                          onPressed: () {
-                            Future.delayed(const Duration(seconds: 1), () {
-                              StoreProvider.of<AppState>(context).dispatch(UpdateUserAction(null));
-                            });
-
+                          onPressed: () async {
                             Toast.show(context, '退出成功', 1500, 'success');
                             Navigator.push(context, new MaterialPageRoute(builder: (context) => new LoginFirst()));
+                            final prefs = await SharedPreferences.getInstance();
+                            prefs.remove('token');
+                            JPush jpush = JPush();
+                            jpush.deleteAlias();
+                            // Future.delayed(const Duration(seconds: 1), () {
+                            //   StoreProvider.of<AppState>(context).dispatch(UpdateUserAction(null));
+                            // });
                           }),
                     )
                   ],
@@ -181,7 +186,7 @@ class SettingState extends State<Setting> {
     final Result res = await HttpManager.post('userInfo/update', data: {"id": userInfo.id, key: value});
     Toast.hide();
     if (res.success) {
-      Toast.show(context, '修改成', 1500, 'success');
+      Toast.show(context, '修改成���', 1500, 'success');
       getUserInfo();
     } else {
       Toast.show(context, res.error, 1500, 'info');

+ 1 - 1
lib/redux/UserRedux.dart

@@ -18,7 +18,7 @@ final userReducer = combineReducers<UserInfo>([
 UserInfo _updateLoaded(UserInfo userInfo, action) {
   JPush jpush = JPush();
   if (action.userInfo != null) {
-    if (userInfo.id != action.userInfo.id) {
+    if (userInfo == null || (userInfo.id != action.userInfo.id)) {
       jpush.setAlias(action.userInfo.id.toString()).then((map) {});
     }
   } else {