Primroses %!s(int64=4) %!d(string=hai) anos
pai
achega
6db31902c2

+ 1 - 0
lib/app.dart

@@ -24,6 +24,7 @@ class MyApp extends StatelessWidget {
       providers: [
         ChangeNotifierProvider<UserModel>(
           create: (_) => UserModel(),
+          lazy: false,
         ),
         ChangeNotifierProvider<Bluetooth>(
           create: (_) => Bluetooth(),

+ 9 - 0
lib/bean/login.dart

@@ -137,4 +137,13 @@ class User {
     }
     return data;
   }
+
+  Map<String, dynamic> toJsonSimple() {
+    final Map<String, dynamic> data = new Map<String, dynamic>();
+    data['id'] = this.id;
+    data['nickname'] = this.name;
+    data['gender'] = this.gender;
+    data['avatar'] = this.avatar;
+    return data;
+  }
 }

+ 36 - 19
lib/pages/game/game_detail.dart

@@ -1,4 +1,5 @@
 import 'dart:async';
+import 'dart:convert';
 import 'dart:io';
 import 'dart:math';
 
@@ -283,30 +284,45 @@ class _GameDetailPageState extends State<GameDetailsPage> with TickerProviderSta
                               ),
                               Platform.isAndroid
                                   ? PositionedBottom(_data, (start) async {
-                                      request(context, () async {
-                                        await api
-                                            .postAddGame(
-                                                widget.details.id,
-                                                Random().nextDouble() * 100,
-                                                (Random().nextDouble() * 40).toInt(),
-                                                Random().nextInt(300),
-                                                start,
-                                                (Random().nextDouble() * 100).toInt(),
-                                                (Random().nextDouble() * 100).toInt(),
-                                                (Random().nextDouble() * 100).toInt(),
-                                                (Random().nextDouble() * 200).toInt())
-                                            .catchError((err) {});
-                                        ToastUtil.show("提交信息成功");
-                                      });
+                                      // request(context, () async {
+                                      //   await api
+                                      //       .postAddGame(
+                                      //           widget.details.id,
+                                      //           Random().nextDouble() * 100,
+                                      //           (Random().nextDouble() * 40).toInt(),
+                                      //           Random().nextInt(300),
+                                      //           start,
+                                      //           (Random().nextDouble() * 100).toInt(),
+                                      //           (Random().nextDouble() * 100).toInt(),
+                                      //           (Random().nextDouble() * 100).toInt(),
+                                      //           (Random().nextDouble() * 200).toInt())
+                                      //       .catchError((err) {});
+                                      //   ToastUtil.show("提交信息成功");
+                                      // });
                                       if (Platform.isAndroid) {
                                         SharedPreferences prefs = await SharedPreferences.getInstance();
                                         String token = prefs.getString("token");
 
+                                        // AndroidIntent intent = AndroidIntent(
+                                        //     action: "android.intent.action.MAIN",
+                                        //     package: _data.packageNameAndroid,
+                                        //     componentName: "${_data.packageNameAndroid}.sdk.UnityPlayerActivity",
+                                        //     data: "oujgame://${_data.packageNameAndroid}",
+                                        //     flags: [
+                                        //       Flag.FLAG_ACTIVITY_NEW_TASK
+                                        //     ],
+                                        //     arguments: {
+                                        //       'token': token,
+                                        //       'mac': Provider.of<Bluetooth>(context, listen: false)?.device?.id?.toString() ?? '',
+                                        //       'game_id': "${_data.id}",
+                                        //       'user_id': Provider.of<UserModel>(context, listen: false)?.user?.id?.toString() ?? '',
+                                        //       'user': Provider.of<UserModel>(context, listen: false)?.user?.toJsonSimple() ?? ''
+                                        //     });
                                         AndroidIntent intent = AndroidIntent(
                                             action: "android.intent.action.MAIN",
                                             package: _data.packageNameAndroid,
-                                            componentName: "${_data.packageNameAndroid}.sdk.UnityPlayerActivity",
-                                            data: "oujgame://${_data.packageNameAndroid}",
+                                            componentName: "com.ouj.shoe.sdklibrary.GameActivity",
+                                            data: "oujgame://com.ouj.shoe",
                                             flags: [
                                               Flag.FLAG_ACTIVITY_NEW_TASK
                                             ],
@@ -314,13 +330,14 @@ class _GameDetailPageState extends State<GameDetailsPage> with TickerProviderSta
                                               'token': token,
                                               'mac': Provider.of<Bluetooth>(context, listen: false)?.device?.id?.toString() ?? '',
                                               'game_id': "${_data.id}",
-                                              'user_id': Provider.of<UserModel>(context, listen: false)?.user?.id?.toString() ?? ''
+                                              'user_id': Provider.of<UserModel>(context, listen: false)?.user?.id?.toString() ?? '',
+                                              'user': json.encode(Provider.of<UserModel>(context, listen: false)?.user?.toJsonSimple() ?? '{}')
                                             });
                                         intent.launch();
                                         // app.DeviceApps.openApp(_data.packageNameAndroid)
                                       }
 
-                                      ToastUtil.show("正在打开... ${_data.name}");
+                                      ToastUtil.show("正在打开... ${_data.name} ${_data.packageNameAndroid}");
                                     })
                                   : Container(
                                       width: double.infinity,

+ 1 - 1
lib/pages/game/rank_people_detail.dart

@@ -106,7 +106,7 @@ class _RankPeopleDetailsPageState extends State<RankPeopleDetailsPage> with Inje
                                   height: 35,
                                   callback: () {
                                     // 先尝试换一下
-                                    NavigatorUtil.goPage(context, (context) => ChatPage(user.name,user.id));
+                                    NavigatorUtil.goPage(context, (context) => ChatPage(user));
                                     // NavigatorUtil.goPage(context, (context) => PrivateMessagePage(user));
                                   },
                                   content: '',

+ 60 - 46
lib/pages/login/login_widget.dart

@@ -10,6 +10,7 @@ import 'package:sport/pages/login/license.dart';
 import 'package:sport/provider/user_model.dart';
 import 'package:sport/services/api/inject_api.dart';
 import 'package:sport/widgets/button_primary.dart';
+import 'package:sport/widgets/dialog/request_dialog.dart';
 
 class Input extends StatefulWidget {
   String labelText;
@@ -62,28 +63,41 @@ class _InputState extends State<Input> {
               if (widget.textInputType == TextInputType.phone) WhitelistingTextInputFormatter(RegExp("[0-9*#]")),
             ],
             decoration: InputDecoration(
-              counterText: "",
-              contentPadding: EdgeInsets.symmetric(vertical: widget.height >= 40 ? 14.0: 9.0, horizontal: 16.0),
-              border: OutlineInputBorder(
-                borderSide: BorderSide(color: Color.fromRGBO(206, 206, 206, 1),width: 0.5),
-                borderRadius: BorderRadius.all(Radius.circular(44.0)),
-              ),
-              focusedBorder: OutlineInputBorder(
-                borderSide: BorderSide(color: Theme.of(context).accentColor,width:1.0),
-                borderRadius: BorderRadius.all(Radius.circular(44.0)),
-              ),
-              enabledBorder: OutlineInputBorder(
-                borderSide: BorderSide(color: Color.fromRGBO(206, 206, 206, 1),width: 0.5),
-                borderRadius: BorderRadius.all(Radius.circular(44.0)),
-              ),
-              labelText: widget.labelText,
-              labelStyle: TextStyle(fontSize: 14.0, color: Color(0xffc2c2c2)),
-              floatingLabelBehavior: FloatingLabelBehavior.never,
-             prefixIcon:  widget.textInputType == TextInputType.phone ?Row(children: <Widget>[Padding(
-               padding: const EdgeInsets.only(left: 12.0, right: 4.0),
-               child: Text("+86", style: Theme.of(context).textTheme.subtitle1,),
-             ), VerticalDivider(indent: 8.0, endIndent: 8.0,)],mainAxisSize: MainAxisSize.min,):null
-            ),
+                counterText: "",
+                contentPadding: EdgeInsets.symmetric(vertical: widget.height >= 40 ? 14.0 : 9.0, horizontal: 16.0),
+                border: OutlineInputBorder(
+                  borderSide: BorderSide(color: Color.fromRGBO(206, 206, 206, 1), width: 0.5),
+                  borderRadius: BorderRadius.all(Radius.circular(44.0)),
+                ),
+                focusedBorder: OutlineInputBorder(
+                  borderSide: BorderSide(color: Theme.of(context).accentColor, width: 1.0),
+                  borderRadius: BorderRadius.all(Radius.circular(44.0)),
+                ),
+                enabledBorder: OutlineInputBorder(
+                  borderSide: BorderSide(color: Color.fromRGBO(206, 206, 206, 1), width: 0.5),
+                  borderRadius: BorderRadius.all(Radius.circular(44.0)),
+                ),
+                labelText: widget.labelText,
+                labelStyle: TextStyle(fontSize: 14.0, color: Color(0xffc2c2c2)),
+                floatingLabelBehavior: FloatingLabelBehavior.never,
+                prefixIcon: widget.textInputType == TextInputType.phone
+                    ? Row(
+                        children: <Widget>[
+                          Padding(
+                            padding: const EdgeInsets.only(left: 12.0, right: 4.0),
+                            child: Text(
+                              "+86",
+                              style: Theme.of(context).textTheme.subtitle1,
+                            ),
+                          ),
+                          VerticalDivider(
+                            indent: 8.0,
+                            endIndent: 8.0,
+                          )
+                        ],
+                        mainAxisSize: MainAxisSize.min,
+                      )
+                    : null),
             onChanged: widget.callBack));
   }
 }
@@ -137,7 +151,7 @@ class _BuildCroppingImagePageState extends State<BuildCroppingImagePage> with In
   @override
   void initState() {
     super.initState();
-    _openImage();
+    _openImage().then((value) => setState(() {}));
   }
 
   @override
@@ -148,12 +162,12 @@ class _BuildCroppingImagePageState extends State<BuildCroppingImagePage> with In
     _lastCropped?.delete();
   }
 
-  Future<void> _cropImage() async {
+  Future<String> _cropImage() async {
     final scale = cropKey.currentState.scale;
     final area = cropKey.currentState.area;
     if (area == null) {
       // cannot crop, widget is not setup
-      return;
+      return null;
     }
 
     // scale up to use maximum possible number of pixels
@@ -173,21 +187,14 @@ class _BuildCroppingImagePageState extends State<BuildCroppingImagePage> with In
 
     _lastCropped?.delete();
     _lastCropped = file;
-    setState(() {
-      _sample = null;
-    });
+
     print(_file);
-    fetchUploadProductBanner(_file);
-    Navigator.pop(context, _lastCropped);
+    return await fetchUploadProductBanner(_file);
   }
 
-  void fetchUploadProductBanner(File path) async {
-    SharedPreferences prefs = await SharedPreferences.getInstance();
-
+  Future<String> fetchUploadProductBanner(File path) async {
     var resp = await loginApi.setAvatar(path);
-    String uploadUrl = resp.data;
-    Provider.of<UserModel>(context, listen: false).saveUserInfoAvator(uploadUrl);
-    prefs.setString('avatar', uploadUrl);
+    return resp.data;
   }
 
   Future<void> _openImage() async {
@@ -204,10 +211,8 @@ class _BuildCroppingImagePageState extends State<BuildCroppingImagePage> with In
     _sample?.delete();
     _file?.delete();
 
-    setState(() {
-      _sample = sample;
-      _file = file;
-    });
+    _sample = sample;
+    _file = file;
   }
 
   @override
@@ -227,12 +232,21 @@ class _BuildCroppingImagePageState extends State<BuildCroppingImagePage> with In
                   mainAxisAlignment: MainAxisAlignment.spaceAround,
                   children: <Widget>[
                     FlatButton(
-                      child: Text(
-                        '确定',
-                        style: Theme.of(context).textTheme.button.copyWith(color: Colors.white),
-                      ),
-                      onPressed: () => _cropImage(),
-                    ),
+                        child: Text(
+                          '确定',
+                          style: Theme.of(context).textTheme.button.copyWith(color: Colors.white),
+                        ),
+                        onPressed: () async {
+                          await request(context, () async {
+                            var url = await _cropImage();
+                            if (url?.isNotEmpty == true) {
+                              SharedPreferences prefs = await SharedPreferences.getInstance();
+                              prefs.setString('avatar', url);
+                              Provider.of<UserModel>(context, listen: false).saveUserInfoAvator(url);
+                              Navigator.pop(context, _file);
+                            }
+                          });
+                        }),
                   ],
                 ),
               )

+ 3 - 5
lib/pages/my/feedback_page.dart

@@ -1,6 +1,5 @@
 import 'dart:convert';
 import 'dart:io';
-import 'dart:math';
 
 import 'package:cached_network_image/cached_network_image.dart';
 import 'package:flutter/material.dart';
@@ -21,7 +20,6 @@ import 'package:sport/utils/toast.dart';
 import 'package:sport/widgets/appbar.dart';
 import 'package:sport/widgets/button_primary.dart';
 import 'package:sport/widgets/decoration.dart';
-import 'package:sport/widgets/dialog/request_dialog.dart';
 import 'package:sport/widgets/image.dart';
 import 'package:sport/widgets/loading.dart';
 import 'package:sport/widgets/space.dart';
@@ -335,9 +333,9 @@ class _PageState extends State<FeedbackPage> with InjectLoginApi, InjectApi {
                           maxLines: 3,
                           maxLength: 200,
                           onChanged: (value) {
-                            setState(() {
-                              _textFieldValue = value;
-                            });
+                            // setState(() {
+                            _textFieldValue = value;
+                            // });
                           },
                           decoration: InputDecoration(
                               counterText: "", hintText: "提交你的反馈...", contentPadding: EdgeInsets.symmetric(vertical: 16.0), border: InputBorder.none),

+ 0 - 10
lib/pages/my/user_info_page.dart

@@ -47,16 +47,6 @@ class _PageState extends State<UserInfoPage> with InjectLoginApi {
     super.dispose();
   }
 
-  void fetchUploadProductBanner(File path) async {
-    SharedPreferences prefs = await SharedPreferences.getInstance();
-
-    var resp = await loginApi.setAvatar(path);
-    String uploadUrl = resp.data;
-    prefs.setString('avatar', uploadUrl);
-    Provider.of<UserModel>(context, listen: false)
-        .saveUserInfoAvator(uploadUrl);
-  }
-
   @override
   Widget build(BuildContext context) {
     return Scaffold(

+ 46 - 52
lib/pages/social/chat_page.dart

@@ -10,6 +10,7 @@ import 'package:shared_preferences/shared_preferences.dart';
 import 'package:sport/bean/message.dart';
 import 'package:sport/bean/post.dart';
 import 'package:sport/bean/post_user.dart';
+import 'package:sport/bean/user_info.dart';
 import 'package:sport/db/message_db.dart';
 import 'package:sport/pages/social/post_detail_page.dart';
 import 'package:sport/pages/social/share_webview.dart';
@@ -46,11 +47,10 @@ final List<String> avatarList = [
 ];
 
 class ChatPage extends StatefulWidget {
-  final String userName;
-  final int userId;
+  final UserInfo user;
   final Post post;
 
-  ChatPage(this.userName, this.userId, {this.post});
+  ChatPage(this.user, {this.post});
 
   @override
   State<StatefulWidget> createState() => _ChatPageState();
@@ -63,7 +63,7 @@ class _ChatPageState extends State<ChatPage>
 
   StreamSubscription _streamSubscription;
   List<MessageItem> messageList = [];
-
+//  String othersAvatarUrl = "";
   GlobalKey SCROLLVIEW = new GlobalKey();
 
   dispose() {
@@ -85,13 +85,13 @@ class _ChatPageState extends State<ChatPage>
   initMessageList() async {
 //    List<MessageItem> messageList = [];
     List<MessageItem> data = [];
-    var list = await MessageDB().getMessageForUserId(widget.userId);
+    var list = await MessageDB().getMessageForUserId(widget.user.id);
     for (var item in list) {
       MessageItem _item = MessageItem.fromJson(item);
       data.add(_item);
     }
     // 读过就操作一手...
-    await MessageDB().updateStatus(widget.userId);
+    await MessageDB().updateStatus(widget.user.id);
 
 //    messageList.addAll(data);
     data.forEach((element) {
@@ -108,11 +108,11 @@ class _ChatPageState extends State<ChatPage>
     if (widget.post != null) {
       // 拿到后还得 存
       MessageInstance _instance = (await api.shareForwardSubject(
-              int.parse(widget.post.id), widget.userId))
+              int.parse(widget.post.id), widget.user.id))
           .data;
 
       await MessageDB().insert(new MessageItem(
-          message: _instance, status: 0, curId: 0, userId: widget.userId));
+          message: _instance, status: 0, curId: 0, userId: widget.user.id));
 
       addMessageToPage(_instance);
     }
@@ -127,7 +127,7 @@ class _ChatPageState extends State<ChatPage>
       for (MessageInstance item in list) {
         addMessageToPage(item);
       }
-      await MessageDB().updateStatus(widget.userId);
+      await MessageDB().updateStatus(widget.user.id);
     });
   }
 //
@@ -159,15 +159,6 @@ class _ChatPageState extends State<ChatPage>
     });
   }
 
-//  @override
-//  void didChangeMetrics() {
-//    super.didChangeMetrics();
-//    WidgetsBinding.instance.addPostFrameCallback((_) {
-//      // 当前是安卓系统并且在焦点聚焦的情况下
-////      _menuController.scrollToBottom();
-//    });
-//  }
-
 // 封装的聊天msg
 // @who  判断是用户自己的还是 聊的那个人
 // @msg  信息 聊天的那个
@@ -303,35 +294,36 @@ class _ChatPageState extends State<ChatPage>
       // 链接..
       if (type == "link") {
         return InkWell(
-            child: Row(
-                crossAxisAlignment: CrossAxisAlignment.start,
-                children: <Widget>[
-              CachedNetworkImage(
-                imageUrl: data.data.logo,
-                width: 60.0,
-                height: 60.0,
-              ),
-              Space(
-                width: 5.0,
-              ),
-              Expanded(
-                child: RichText(
-                  text: TextSpan(children: [
-                    TextSpan(
-                        text: data.data.user.name,
-                        style: Theme.of(context)
-                            .textTheme
-                            .headline6
-                            .copyWith(color: Color(0xFFFFC400))),
-                    TextSpan(
-                        text: data.data.text,
-                        style: Theme.of(context).textTheme.subtitle1),
-                  ]),
+          child: Row(
+              crossAxisAlignment: CrossAxisAlignment.start,
+              children: <Widget>[
+                CachedNetworkImage(
+                  imageUrl: data.data.logo,
+                  width: 60.0,
+                  height: 60.0,
                 ),
-              )
-            ]),
-          onTap: () async{
-              await NavigatorUtil.goPage(context, (context) => WebViewSharePage(data.data.url));
+                Space(
+                  width: 5.0,
+                ),
+                Expanded(
+                  child: RichText(
+                    text: TextSpan(children: [
+                      TextSpan(
+                          text: data.data.user.name,
+                          style: Theme.of(context)
+                              .textTheme
+                              .headline6
+                              .copyWith(color: Color(0xFFFFC400))),
+                      TextSpan(
+                          text: data.data.text,
+                          style: Theme.of(context).textTheme.subtitle1),
+                    ]),
+                  ),
+                )
+              ]),
+          onTap: () async {
+            await NavigatorUtil.goPage(
+                context, (context) => WebViewSharePage(data.data.url));
           },
         );
       }
@@ -422,6 +414,10 @@ class _ChatPageState extends State<ChatPage>
       width: 12,
     );
 
+    String avatarUrl = data.fromUser?.id == int.parse(selfId)
+        ? Provider.of<UserModel>(context, listen: false).user.avatar
+        : widget.user.avatar;
+
     Widget avatar = InkWell(
       onTap: () async {
         await NavigatorUtil.goPage(
@@ -429,12 +425,10 @@ class _ChatPageState extends State<ChatPage>
             (context) => UserDetailPage(PostUser(
                 id: "${data.fromUser?.id}",
                 name: data.fromUser?.name,
-                avatar: data.fromUser?.id == selfId
-                    ? Provider.of<UserModel>(context, listen: false).user.avatar
-                    : data.fromUser.avatar)));
+                avatar: avatarUrl)));
       },
       child: CircleAvatar(
-        backgroundImage: CachedNetworkImageProvider(userAvatar),
+        backgroundImage: CachedNetworkImageProvider(avatarUrl),
         radius: 20,
       ),
     );
@@ -458,7 +452,7 @@ class _ChatPageState extends State<ChatPage>
     return Scaffold(
         appBar: AppBar(
           title: Text(
-            "${widget.userName}",
+            "${widget.user.name}",
             style: titleStyle,
           ),
           leading: buildBackButton(context),
@@ -484,7 +478,7 @@ class _ChatPageState extends State<ChatPage>
             ],
           ),
           menuIdentity:
-              new MenuIdentity(menuScene: "chat", userId: widget.userId),
+              new MenuIdentity(menuScene: "chat", userId: widget.user.id),
           inputField: "",
 //          scrollToBottom: _menuController.scrollToBottom, // 暂时可以废弃...
           sendCallBack: addMessageToPage,

+ 3 - 1
lib/pages/social/message_page.dart

@@ -9,6 +9,7 @@ import 'package:sport/bean/message.dart';
 import 'package:sport/bean/notice.dart';
 import 'package:sport/bean/post_user.dart';
 import 'package:sport/bean/user_friend.dart';
+import 'package:sport/bean/user_info.dart';
 import 'package:sport/db/message_db.dart';
 import 'package:sport/pages/social/chat_page.dart';
 import 'package:sport/pages/social/message_notice_detail_page.dart';
@@ -454,8 +455,9 @@ class _PageState extends State<MessagePage>
 
                                     return InkWell(
                                       onTap: () async {
+                                        UserInfo info = (await api.getUserInfo("$id")).data;
                                         await NavigatorUtil.goPage(context,
-                                            (context) => ChatPage(name, id));
+                                            (context) => ChatPage(info));
                                         getChatIndex();
                                       },
                                       child: Padding(

+ 28 - 2
lib/pages/social/post_detail_page.dart

@@ -46,7 +46,7 @@ class PostDetailPage extends StatefulWidget {
   State<StatefulWidget> createState() => _PageState();
 }
 
-class _PageState extends ViewStateLifecycle<PostDetailPage, PostDetailModel> with UserId {
+class _PageState extends ViewStateLifecycle<PostDetailPage, PostDetailModel> with UserId, TickerProviderStateMixin {
   FocusNode _focusNode;
   ScrollController _controller;
   int _inputType = 0;
@@ -63,6 +63,8 @@ class _PageState extends ViewStateLifecycle<PostDetailPage, PostDetailModel> wit
   );
 
   var _scrollListener;
+  var _animationController;
+  var _iconAnimation;
 
   Comment _toComment;
   PostUser _toUser;
@@ -97,6 +99,17 @@ class _PageState extends ViewStateLifecycle<PostDetailPage, PostDetailModel> wit
         FocusScope.of(context).requestFocus(_focusNode);
       });
     }
+
+    _animationController =
+        AnimationController(duration: Duration(milliseconds: 300), vsync: this);
+
+    _iconAnimation = TweenSequence([
+      TweenSequenceItem(
+          tween: Tween(begin: 1.0, end: 1.5)
+              .chain(CurveTween(curve: Curves.easeIn)),
+          weight: 50),
+      TweenSequenceItem(tween: Tween(begin: 1.5, end: 1.0), weight: 50),
+    ]).animate(_animationController);
   }
 
   void _scrollToComment() {
@@ -671,14 +684,27 @@ class _PageState extends ViewStateLifecycle<PostDetailPage, PostDetailModel> wit
                                     await (post.isLiked ?? false
                                         ? model.api.postForumUnLike(post.id, "subject_id")
                                         : model.api.postForumLike(post.id, "subject_id"));
+
+                                    if (_iconAnimation.status == AnimationStatus.forward ||
+                                        _iconAnimation.status == AnimationStatus.reverse) {
+                                      return;
+                                    }
                                     setState(() {
                                       _updatePost(2, 0);
                                     });
+                                    if (_iconAnimation.status == AnimationStatus.dismissed) {
+                                      _animationController.forward();
+                                    } else if (_iconAnimation.status == AnimationStatus.completed) {
+                                      _animationController.reverse();
+                                    }
                                   },
                                   child: Center(
                                     child: Row(
                                       children: <Widget>[
-                                        Image.asset("lib/assets/img/bbs_icon_like${_post.isLiked ?? false ? "_complete" : ""}.png"),
+                                      ScaleTransition(
+                                      scale: _iconAnimation,
+                                      child:
+                                      Image.asset("lib/assets/img/bbs_icon_like${_post.isLiked ?? false ? "_complete" : ""}.png")),
                                         _padding,
                                         Text(
                                           "${_post.likeCount}",

+ 1 - 2
lib/pages/social/post_share_page.dart

@@ -181,8 +181,7 @@ class _PostShareFriendsPageState extends State<PostShareFriendsPage>
                           bool result = await NavigatorUtil.goPage(
                               context,
                               (context) => ChatPage(
-                                    list[index].socialInfo.name,
-                                    list[index].socialInfo.id,
+                                    list[index].socialInfo,
                                     post: widget.post,
                                   ));
                           if (result == true) {

+ 1 - 1
lib/pages/social/user_detail_page.dart

@@ -244,7 +244,7 @@ class _PageState extends ViewStateLifecycle<UserDetailPage, UserDetailModel> wit
                                                       height: 35,
                                                       callback: () {
                                                         // 先尝试换一下
-                                                        NavigatorUtil.goPage(context, (context) => ChatPage(user.name,user.id));
+                                                        NavigatorUtil.goPage(context, (context) => ChatPage(user));
                                                         // NavigatorUtil.goPage(context, (context) => PrivateMessagePage(user));
                                                       },
                                                       content: '',

+ 19 - 13
lib/provider/bluetooth.dart

@@ -57,6 +57,7 @@ class Bluetooth with ChangeNotifier, InjectApi {
   final ValueNotifier<int> stepNotifier = ValueNotifier<int>(0);
   final ValueNotifier<int> stepTotalNotifier = ValueNotifier<int>(0);
   final ValueNotifier<int> actionNotifier = ValueNotifier<int>(0);
+  final ValueNotifier<List<int>> byteNotifier = ValueNotifier<List<int>>([]);
   PartInfo _partInfo;
 
   bool get isConnected => _online;
@@ -226,6 +227,7 @@ class Bluetooth with ChangeNotifier, InjectApi {
             if (succ) {
               characteristicSubscription = characteristic.value.listen((event) {
                 print("characteristic change --> $event");
+                byteNotifier.value = event;
                 parse(event);
               });
             }
@@ -241,23 +243,23 @@ class Bluetooth with ChangeNotifier, InjectApi {
     reader.add(event);
 
     int flagAA = reader.readUint8();
-    int flagBB = reader.readUint8();
-    int flagCC = reader.readUint8();
+    // int flagBB = reader.readUint8();
+    // int flagCC = reader.readUint8();
 
     int len = reader.readUint8();
     int len1 = 0xFF - reader.readUint8();
 
-    int index = reader.readUint8();
+    // int index = reader.readUint8();
     int cmd = reader.readUint8();
 
-    print("                         change --> ${flagAA} ${flagBB} ${flagCC}");
-    print("                         change --> ${len} ${~len} ${len1}");
-    print("                         change --> ${index} ${cmd}");
+    print("                         change --> ${flagAA} ${len} ${~len} ${cmd}");
+    // print("                         change --> ${len} ${~len} ${len1}");
+    // print("                         change --> ${index} ${cmd}");
 
-    if (!(flagAA == 0xAA && flagBB == 0xBB && flagCC == 0xCC)) return;
+    if (!(flagAA == 0xAA)) return;
     if (len != len1) return;
 
-    parseCmd(cmd, reader.read(event.length - 8));
+    parseCmd(cmd, reader.read(event.length - 5));
   }
 
   void parseCmd(int cmd, Uint8List byteArray) {
@@ -427,6 +429,10 @@ class Bluetooth with ChangeNotifier, InjectApi {
     await write(0xA1, createTime(0x02));
   }
 
+  Future setupGameMode(bool mode) async {
+    await write(0xA2, mode? Uint8List.fromList([0x01]): Uint8List.fromList([0x00]));
+  }
+
   Uint8List createTime(int cmd) {
     DateTime now = DateTime.now();
     DateTime offset = DateTime(now.year, now.month, now.day, now.hour);
@@ -447,16 +453,16 @@ class Bluetooth with ChangeNotifier, InjectApi {
     }
     if (_writeCharacteristic == null) return;
 
-    int length = data.length + 8;
+    int length = data.length + 5;
     ByteDataWriter writer = ByteDataWriter();
     writer.writeUint8(0xAA);
-    writer.writeUint8(0xBB);
-    writer.writeUint8(0xCC);
+    // writer.writeUint8(0xBB);
+    // writer.writeUint8(0xCC);
     writer.writeUint8(length);
     writer.writeUint8(0xFF - length);
-    writer.writeUint8(0x00);
+    // writer.writeUint8(0x00);
     writer.writeUint8(cmd);
-    writer.write(data);
+    if (data.isNotEmpty) writer.write(data);
     int ver = writer.toBytes().reduce((value, element) => value + element);
     writer.writeUint8(ver);
     Uint8List out = writer.toBytes();

+ 1 - 1
lib/router/routes.dart

@@ -104,7 +104,7 @@ class Routes {
     }));
 
     router.define(chat, handler: Handler(handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
-      return ChatPage(params['userName'].first,params['userId'].first,post: params['post'].first,);
+      return ChatPage(params['user'].first,post: params['post'].first,);
     }));
 
     // home

+ 16 - 0
lib/widgets/dialog/search_device.dart

@@ -497,6 +497,18 @@ class DeviceScreen extends StatelessWidget {
               },
               child: Text("清零"),
             ),
+            RaisedButton(
+              onPressed: () {
+                Provider.of<Bluetooth>(context, listen: false).setupGameMode(true);
+              },
+              child: Text("游戏模式开"),
+            ),
+            RaisedButton(
+              onPressed: () {
+                Provider.of<Bluetooth>(context, listen: false).setupGameMode(false);
+              },
+              child: Text("游戏模式关"),
+            ),
             ValueListenableBuilder(
               valueListenable: Provider.of<Bluetooth>(context, listen: false).actionNotifier,
               builder: (BuildContext context, int value, Widget child) => Text("当前动作: $value"),
@@ -509,6 +521,10 @@ class DeviceScreen extends StatelessWidget {
               valueListenable: Provider.of<Bluetooth>(context, listen: false).stepNotifier,
               builder: (BuildContext context, int value, Widget child) => Text("相对步数: $value"),
             ),
+            ValueListenableBuilder(
+              valueListenable: Provider.of<Bluetooth>(context, listen: false).byteNotifier,
+              builder: (BuildContext context, List<int> value, Widget child) => Text("接收: $value"),
+            ),
           ],
         ),
       ),