kidd3166 3 年 前
コミット
c2154e3361

+ 3 - 0
lib/bean/user_info.dart

@@ -46,6 +46,9 @@ class UserInfo {
 
   UserInfo.fromJson(Map<String, dynamic> json) {
     id = Converter.toInt(json['id']);
+    if(json.containsKey("uid")){
+      id = Converter.toInt(json['uid']);
+    }
     name = json['name'] ?? json['user_name'];
     avatar = json['avatar'] ?? json['user_avatar'];
     sportTargetId = json['sport_target_id'];

+ 4 - 2
lib/pages/home/consume_page.dart

@@ -55,7 +55,7 @@ class _PageState extends State<ConsumePage> with InjectApi {
 
   @override
   Widget build(BuildContext context) {
-    final double tabHeader = 80.0;
+    final double tabHeader = 90.0;
     final double statusBarHeight = MediaQuery.of(context).padding.top;
     final double pinnedHeaderHeight = tabHeader;
     final double headerHeight = 240.0;
@@ -101,7 +101,7 @@ class _PageState extends State<ConsumePage> with InjectApi {
                                           future: createFutureType(0, _valueNotifierNow.value),
                                           builder: (BuildContext context, AsyncSnapshot<SportDetail> snapshot) => Text(
                                             "${snapshot?.data?.recordsTodaySum?.consume ?? 0}",
-                                            style: Theme.of(context).textTheme.headline1.copyWith(fontSize: 40.0),
+                                            style: Theme.of(context).textTheme.headline1.copyWith(fontSize: 40.0, fontFamily: "DIN"),
                                             strutStyle: fixedLine,
                                           ),
                                         ),
@@ -159,6 +159,7 @@ class _PageState extends State<ConsumePage> with InjectApi {
                                 mainAxisSize: MainAxisSize.min,
                               ),
                             ),
+                            margin: EdgeInsets.only(top: 16.0),
                           ),
                         ),
                       ),
@@ -213,6 +214,7 @@ class _PageState extends State<ConsumePage> with InjectApi {
                                         .toList(),
                                   ),
                                 ),
+                                const SizedBox(height: 10.0,),
                                 Center(
                                   child: ValueListenableBuilder<DateTime>(
                                       valueListenable: _valueNotifierDate,

+ 1 - 1
lib/pages/home/duration_setting_page.dart

@@ -137,7 +137,7 @@ class _FormState extends State<_Form> {
               valueListenable: _valueTotal,
               builder: (_, value, ___) => Text(
                 "$value",
-                style: Theme.of(context).textTheme.headline1.copyWith(fontSize: 40.0),
+                style: Theme.of(context).textTheme.headline1.copyWith(fontSize: 40.0, fontFamily: "DIN"),
               ),
             ),
             Padding(

+ 2 - 2
lib/pages/home/step_page.dart

@@ -194,7 +194,7 @@ class _PageState extends State<StepPage> with TickerProviderStateMixin, InjectAp
                                           children: <Widget>[
                                             Text(
                                               "${_value?.sum?.stepDayAvg ?? _value?.sum?.step ?? 0}",
-                                              style: Theme.of(context).textTheme.headline1.copyWith(fontSize: 26.0, color: _color),
+                                              style: Theme.of(context).textTheme.headline1.copyWith(fontSize: 26.0, color: _color, fontFamily: "DIN"),
                                             ),
                                             Text(
                                               toType() == 0 ? "日总步数" : "日均步数",
@@ -240,7 +240,7 @@ class _PageState extends State<StepPage> with TickerProviderStateMixin, InjectAp
                                                     text: TextSpan(style: Theme.of(context).textTheme.subtitle2, children: <InlineSpan>[
                                                       TextSpan(
                                                           text:
-                                                              '${_value == null ? ".." : "${((_value.sum.stepDaily + _value.sum.stepGame) * .6).toStringAsFixed(1)}"}',
+                                                              '${_value == null ? ".." : "${((_value.sum.stepDaily + _value.sum.stepGame) * .762).toStringAsFixed(1)}"}',
                                                           style: Theme.of(context).textTheme.subtitle2.copyWith(fontWeight: FontWeight.bold, fontSize: 25)),
                                                       TextSpan(text: ' 米', style: Theme.of(context).textTheme.subtitle1),
                                                     ]),

+ 23 - 21
lib/pages/my/feedback_page.dart

@@ -177,7 +177,7 @@ class _PageState extends State<FeedbackPage> with InjectLoginApi, InjectApi {
                                                         ),
                                                         CustomPaint(
                                                           painter:
-                                                              _BubblePainter(),
+                                                              BubblePainter(),
                                                           child: Padding(
                                                             padding:
                                                                 const EdgeInsets
@@ -227,7 +227,7 @@ class _PageState extends State<FeedbackPage> with InjectLoginApi, InjectApi {
                                                             ),
                                                             CustomPaint(
                                                               painter:
-                                                                  _BubblePainter(),
+                                                                  BubblePainter(),
                                                               child: Padding(
                                                                 padding:
                                                                     const EdgeInsets
@@ -300,7 +300,7 @@ class _PageState extends State<FeedbackPage> with InjectLoginApi, InjectApi {
                                                                   ? <Widget>[
                                                                       CustomPaint(
                                                                           painter:
-                                                                              _BubblePainterRight(),
+                                                                              BubblePainterRight(),
                                                                           child:
                                                                               ConstrainedBox(
                                                                             constraints:
@@ -358,7 +358,7 @@ class _PageState extends State<FeedbackPage> with InjectLoginApi, InjectApi {
                                                                       ),
                                                                       CustomPaint(
                                                                           painter:
-                                                                              _BubblePainter(),
+                                                                              BubblePainter(),
                                                                           child:
                                                                               ConstrainedBox(
                                                                             constraints:
@@ -652,21 +652,23 @@ class PostActionState extends State<PostAction> with InjectApi {
 //  }
 //}
 
-class _BubblePainter extends CustomPainter {
+class BubblePainter extends CustomPainter {
   final circular = Radius.circular(10);
-  final Paint _paint = Paint()..color = Colors.white;
-  final double _bubbleWidth = 10;
+  final Paint _paint = Paint()
+    ..color = Colors.white
+  ..strokeJoin = StrokeJoin.round
+  ;
+  final double _bubbleWidth = 6;
 
   @override
   void paint(Canvas canvas, Size size) {
 //    Path path = Path()..moveTo(size.width,  size.height / 2)..quadraticBezierTo(size.width / 3*2, size.height / 2 + 50, 0, size.height / 2)
 //    ..quadraticBezierTo(size.width / 3, size.height,size.width,size.height)..close();
     Path path = Path()
-      ..moveTo(_bubbleWidth + 1, _bubbleWidth)
-      ..quadraticBezierTo(
-          _bubbleWidth / 3 * 2, _bubbleWidth + 4, 0, _bubbleWidth)
-      ..quadraticBezierTo(_bubbleWidth / 3, _bubbleWidth + _bubbleWidth / 2,
-          _bubbleWidth + 1, _bubbleWidth * 2)
+      ..moveTo(_bubbleWidth + 1, 10)
+      ..lineTo(0, 15)
+      ..lineTo(0, 16)
+      ..lineTo(_bubbleWidth + 1, 21)
       ..close();
     canvas.drawPath(path, _paint);
     canvas.drawRRect(
@@ -680,22 +682,22 @@ class _BubblePainter extends CustomPainter {
   }
 }
 
-class _BubblePainterRight extends CustomPainter {
+class BubblePainterRight extends CustomPainter {
   final circular = Radius.circular(10);
-  final Paint _paint = Paint()..color = Color(0xffffe400).withOpacity(0.7);
-  final double _bubbleWidth = 10;
+  final Paint _paint = Paint()..color = Color(0xffffe400).withOpacity(0.7)
+    ..strokeJoin = StrokeJoin.round;
+  final double _bubbleWidth = 6;
 
   @override
   void paint(Canvas canvas, Size size) {
 //    Path path = Path()..moveTo(size.width,  size.height / 2)..quadraticBezierTo(size.width / 3*2, size.height / 2 + 50, 0, size.height / 2)
 //    ..quadraticBezierTo(size.width / 3, size.height,size.width,size.height)..close();
-    double left = size.width - _bubbleWidth;
+    double left = size.width - _bubbleWidth - 1;
     Path path = Path()
-      ..moveTo(left, _bubbleWidth)
-      ..quadraticBezierTo(left + _bubbleWidth / 3 * 2, _bubbleWidth + 2,
-          size.width, _bubbleWidth)
-      ..quadraticBezierTo(left + _bubbleWidth / 3,
-          _bubbleWidth + _bubbleWidth / 2, left, _bubbleWidth * 2)
+      ..moveTo(left, 10)
+      ..lineTo(size.width, 15)
+      ..lineTo(size.width, 16)
+      ..lineTo(left, 21)
       ..close();
     canvas.drawPath(path, _paint);
     canvas.drawRRect(

+ 3 - 59
lib/pages/social/chat_page.dart

@@ -19,6 +19,7 @@ import 'package:sport/db/message_db.dart';
 import 'package:sport/pages/social/post_detail_page.dart';
 import 'package:sport/pages/social/share_webview.dart';
 import 'package:sport/pages/social/user_detail_page.dart';
+import 'package:sport/pages/my/feedback_page.dart';
 import 'package:sport/provider/lib/view_state_model.dart';
 import 'package:sport/provider/message_model.dart';
 import 'package:sport/provider/user_model.dart';
@@ -477,7 +478,7 @@ class _ChatPageState extends State<ChatPage>
       print("[data.type]:${data.type}--------------------");
       if(data.type != "image"){
         return CustomPaint(
-            painter: who == 1 ? _BubblePainterRight() : _BubblePainter(),
+            painter: who == 1 ? BubblePainterRight() : BubblePainter(),
             child: chatContent());
       }
       return chatContent();
@@ -530,7 +531,7 @@ class _ChatPageState extends State<ChatPage>
         appBar: AppBar(
           title: InkWell(
             child: Text(
-              "${widget.user.name}",
+              "${widget.user.name}${widget.user.id}",
               style: titleStyle,
             ),
             onTap: (){
@@ -581,60 +582,3 @@ class _ChatPageState extends State<ChatPage>
             )));
   }
 }
-
-class _BubblePainter extends CustomPainter {
-  final circular = Radius.circular(10);
-  final Paint _paint = Paint()..color = Colors.white;
-  final double _bubbleWidth = 10;
-
-  @override
-  void paint(Canvas canvas, Size size) {
-//    Path path = Path()..moveTo(size.width,  size.height / 2)..quadraticBezierTo(size.width / 3*2, size.height / 2 + 50, 0, size.height / 2)
-//    ..quadraticBezierTo(size.width / 3, size.height,size.width,size.height)..close();
-    Path path = Path()
-      ..moveTo(_bubbleWidth + 1, _bubbleWidth)
-      ..quadraticBezierTo(
-          _bubbleWidth / 3 * 2, _bubbleWidth + 4, 0, _bubbleWidth)
-      ..quadraticBezierTo(_bubbleWidth / 3, _bubbleWidth + _bubbleWidth / 2,
-          _bubbleWidth + 1, _bubbleWidth * 2)
-      ..close();
-    canvas.drawPath(path, _paint);
-    canvas.drawRRect(
-        RRect.fromLTRBR(_bubbleWidth, 0, size.width, size.height, circular),
-        _paint);
-  }
-
-  @override
-  bool shouldRepaint(CustomPainter oldDelegate) {
-    return oldDelegate != this;
-  }
-}
-
-class _BubblePainterRight extends CustomPainter {
-  final circular = Radius.circular(10);
-  final Paint _paint = Paint()..color = Color(0xffffe400).withOpacity(0.7);
-  final double _bubbleWidth = 10;
-
-  @override
-  void paint(Canvas canvas, Size size) {
-//    Path path = Path()..moveTo(size.width,  size.height / 2)..quadraticBezierTo(size.width / 3*2, size.height / 2 + 50, 0, size.height / 2)
-//    ..quadraticBezierTo(size.width / 3, size.height,size.width,size.height)..close();
-    double left = size.width - _bubbleWidth;
-    Path path = Path()
-      ..moveTo(left, _bubbleWidth)
-      ..quadraticBezierTo(left + _bubbleWidth / 3 * 2, _bubbleWidth + 2,
-          size.width, _bubbleWidth)
-      ..quadraticBezierTo(left + _bubbleWidth / 3,
-          _bubbleWidth + _bubbleWidth / 2, left, _bubbleWidth * 2)
-      ..close();
-    canvas.drawPath(path, _paint);
-    canvas.drawRRect(
-        RRect.fromLTRBR(0, 0, size.width - _bubbleWidth, size.height, circular),
-        _paint);
-  }
-
-  @override
-  bool shouldRepaint(CustomPainter oldDelegate) {
-    return oldDelegate != this;
-  }
-}

+ 3 - 12
lib/pages/social/user_friend_page.dart

@@ -278,18 +278,9 @@ class _PageDetailState
                               itemBuilder: (BuildContext context, int index) {
                                 return ListTile(
                                   leading: InkWell(
-                                    child: Container(
-                                      width: 44,
-                                      height: 44,
-                                      decoration: BoxDecoration(
-                                        shape: BoxShape.rectangle,
-                                        borderRadius:
-                                            BorderRadius.circular(4.0),
-                                        image: DecorationImage(
-                                            image: CachedNetworkImageProvider(
-                                          model.items[index].user.avatar,
-                                        )),
-                                      ),
+                                    child: CircleAvatar(
+                                      backgroundImage: userAvatarProvider(model.items[index].user.avatar),
+                                      radius: 22,
                                     ),
                                     onTap: () {
                                       NavigatorUtil.goPage(

+ 40 - 20
lib/widgets/chart.dart

@@ -21,11 +21,10 @@ class Chart extends CustomPainter {
     ..color = const Color(0xffDCDCDC)
     ..strokeWidth = 0.5
     ..isAntiAlias = true;
-  final Paint _linePaint = Paint()
+  final Paint _paintCurrent = Paint()
     ..color = const Color(0xffFFC400)
-    ..strokeWidth = 2
-    ..isAntiAlias = true
-    ..style = PaintingStyle.stroke;
+    ..strokeWidth = 0.5
+    ..isAntiAlias = true;
 
   static const Color _maxColor = Color(0xffFF5B1D);
   final Paint _maxPaint = Paint()
@@ -41,6 +40,8 @@ class Chart extends CustomPainter {
     textAlign: TextAlign.right,
     fontSize: 8,
   );
+  final Paint columnPaint = Paint()..color =  const Color(0xffFFC400)
+    ..isAntiAlias = true;
 
   double _zero = 0;
   double _paddingLeft = 35;
@@ -57,6 +58,7 @@ class Chart extends CustomPainter {
   bool drawMax = false;
   String unit = "kal";
   double _max = 750;
+  int _currentIndex = 0;
 
   Chart({this.type, this.records, this.dateTime, this.drawMax, this.unit});
 
@@ -66,14 +68,17 @@ class Chart extends CustomPainter {
     values = {};
     var records = this.records ?? [];
 
+    var now = DateTime.now();
+
     if (this.type == 0) {
       records.forEach((element) {
         var t = DateTime.parse(element.createdAt);
         values.update("${max(6, t.hour) - 5}", (value) => value + element.value, ifAbsent: () => Converter.toDouble(element.value));
       });
-      for (int i = 1; i <= 24; i++) {
+      for (int i = 6; i <= 24; i++) {
         values.putIfAbsent("$i", () => 0.0);
       }
+      _currentIndex = -1;
     } else if (this.type == 1) {
       records.forEach((element) {
         var t = DateTime.parse(element.createdAt);
@@ -82,6 +87,7 @@ class Chart extends CustomPainter {
       for (int i = 1; i <= 7; i++) {
         values.putIfAbsent("$i", () => 0.0);
       }
+      _currentIndex = (now.weekday == 0 ? 7 : now.weekday) - 1;
     } else if (this.type == 2) {
       records.forEach((element) {
         var t = DateTime.parse(element.createdAt);
@@ -90,6 +96,7 @@ class Chart extends CustomPainter {
       for (int i = 1; i <= 31; i++) {
         values.putIfAbsent("$i", () => 0.0);
       }
+      _currentIndex = now.day - 1;
     } else if (this.type == 3) {
       records.forEach((element) {
         values.update("${element.createdAt}", (value) => value + element.value, ifAbsent: () => Converter.toDouble(element.value));
@@ -97,6 +104,7 @@ class Chart extends CustomPainter {
       for (int i = 1; i <= 12; i++) {
         values.putIfAbsent("$i", () => 0.0);
       }
+      _currentIndex = now.month - 1;
     }
     values.values.forEach((element) {
       _max = max(maxValue, Converter.toDouble(element));
@@ -144,7 +152,7 @@ class Chart extends CustomPainter {
     // draw 数据列
     double left = _paddingLeft + 10;
     double width = size.width - _paddingRight - left; // 柱子的有效空间
-    double valueStroke = 20; // 柱子宽度
+    double valueStroke = 8; // 柱子宽度
     List<String> valueLabel = []; // 柱子数量
     int scaleCount = 0; // 刻度数量
     int scaleWeight = 3;
@@ -152,14 +160,14 @@ class Chart extends CustomPainter {
       // 日,按时间
       scaleWeight = 2;
       valueLabel = List.generate(10, (index) => "${6 + index * scaleWeight}:00");
-      valueStroke = width / valueLabel.length / scaleWeight - 5;
+      // valueStroke = width / valueLabel.length / scaleWeight - 5;
       scaleCount = 18;
     } else if (this.type == 1) {
       left += 20;
       width -= 40;
       scaleWeight = 1;
       valueLabel = List.generate(7, (index) => WEEK[index]);
-      valueStroke = 12;
+      // valueStroke = 12;
       scaleCount = 6;
     } else if (this.type == 2) {
       DateTime now = this.dateTime;
@@ -169,13 +177,14 @@ class Chart extends CustomPainter {
       int diffDay = endTime.difference(startTime).inDays;
       // List<int> days = [1, 8, 15, 22, diffDay == 28 ? 28:29];
       scaleCount = diffDay - 1;
-      scaleWeight = 2;
+      scaleWeight = 1;
       // valueLabel = days.map((e) => '$e/${now.month}').toList();
-      valueLabel = List.generate(diffDay ~/ scaleWeight + (scaleCount % scaleWeight == 0 ? 1 : 0), (index) => "${index * 2 + 1}");
+      // valueLabel = List.generate(diffDay ~/ scaleWeight + (scaleCount % scaleWeight == 0 ? 1 : 0), (index) => "${index * 2 + 1}");
+      valueLabel = List.generate(diffDay, (index) => '${index + 1}');
       valueStroke = 5;
     } else if (this.type == 3) {
       valueLabel = List.generate(12, (index) => '${index + 1}');
-      valueStroke = 12;
+      // valueStroke = 12;
       scaleCount = 12 - 1;
       scaleWeight = 1;
     }
@@ -192,15 +201,32 @@ class Chart extends CustomPainter {
     // }
 
     for (var i = 0; i < labelSize; i++) {
+      int index = i;
       String label = valueLabel[i];
+      if(type == 2 && i % 2 == 1) {
+        if(i != _currentIndex)
+        continue;
+      }
+      // print("1111111111111111111 $i $_currentIndex $label");
+      bool curr = i == _currentIndex;
       ParagraphBuilder pb = ParagraphBuilder(_labelStyle)
-        ..pushStyle(ui.TextStyle(color: Color(0xff999999)))
+        ..pushStyle(ui.TextStyle(color: curr ? const Color(0xffFFC400) : const Color(0xff999999)))
         ..addText(label);
       ParagraphConstraints constraints = ParagraphConstraints(width: labelSpace);
       Paragraph paragraph = pb.build()..layout(constraints);
       paragraph.computeLineMetrics().forEach((element) {
-        canvas.drawParagraph(paragraph, Offset(left + scaleWidth * scaleWeight * i - element.width / 2, zero + 5));
+        var x = left + scaleWidth * scaleWeight * index - element.width / 2;
+        var y = zero + 5;
+        canvas.drawParagraph(paragraph, Offset(x, y));
+        if(curr){
+          x = x + element.width / 2 ;
+          canvas.drawPath(Path()..moveTo(x, y + 11)..lineTo(x - 3, y + 14)..lineTo(x + 3, y + 14)..close(), _paintCurrent);
+        }
       });
+
+      if(type == 2){
+
+      }
 //
 //      double l = left + scaleWidth * scaleWeight * i - valueStroke / 2;
 //      Rect rect = Rect.fromLTRB(l, zero, l + valueStroke, 0);
@@ -224,13 +250,7 @@ class Chart extends CustomPainter {
       num value = values[key];
       double l = left + scaleWidth * i - valueStroke / 2;
       Rect rect = Rect.fromLTRB(l, zero, l + valueStroke, calValue(value));
-      Paint valuePaint = Paint()
-        ..shader = LinearGradient(
-          begin: Alignment.bottomCenter,
-          end: Alignment.topCenter,
-          colors: <Color>[Color(0xffFF9100), Color(0xffFFE600)],
-        ).createShader(rect);
-      canvas.drawRRect(RRect.fromRectAndRadius(rect, Radius.circular(100)), valuePaint);
+      canvas.drawRRect(RRect.fromRectAndRadius(rect, Radius.circular(100)), columnPaint);
 
       if (this.drawMax) {
         if (maxVal <= value) {

+ 2 - 2
lib/widgets/menu_bar.dart

@@ -440,8 +440,8 @@ class _MenuBarState extends State<MenuBar> with WidgetsBindingObserver, InjectAp
 
                               if (widget.menuIdentity.menuScene == "chat") {
                                 MessageInstance message = (await api.postChatSend(widget.menuIdentity.userId, "text", '{"text":"${_controller.text}"}')).data;
-
-                                await add(message); // await 是等待的标志 我等待完 在做后面的init 的事?
+                                if(message != null)
+                                  await add(message); // await 是等待的标志 我等待完 在做后面的init 的事?
                                 _controller.text = "";
                               }
                               if (widget.menuIdentity.menuScene == "feedback") {

+ 1 - 1
lib/widgets/refresh_header.dart

@@ -47,7 +47,7 @@ class ClassicalHeader extends Header {
     double extent = 60.0,
     double triggerDistance = 70.0,
     bool float = false,
-    Duration completeDuration = const Duration(seconds: 1),
+    Duration completeDuration = const Duration(milliseconds: 100),
     bool enableInfiniteRefresh = false,
     bool enableHapticFeedback = true,
     bool overScroll = true,