From e1bfd73ca1d0437fd8a0133637132451f132034d Mon Sep 17 00:00:00 2001 From: 21pages Date: Wed, 14 Dec 2022 12:27:57 +0800 Subject: [PATCH 1/2] fix group model pull error Signed-off-by: 21pages --- flutter/lib/models/group_model.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flutter/lib/models/group_model.dart b/flutter/lib/models/group_model.dart index 4dfcf189b..98dc57086 100644 --- a/flutter/lib/models/group_model.dart +++ b/flutter/lib/models/group_model.dart @@ -65,7 +65,7 @@ class GroupModel { if (json.containsKey('error')) { throw json['error']; } else { - total = json['total']; + if (total == 0) total = json['total']; if (json.containsKey('data')) { final data = json['data']; if (data is List) { @@ -76,7 +76,7 @@ class GroupModel { } } } - } while (current < total); + } while (current < total + 1); } catch (err) { debugPrint('$err'); userLoadError.value = err.toString(); @@ -115,7 +115,7 @@ class GroupModel { if (json.containsKey('error')) { throw json['error']; } else { - total = json['total']; + if (total == 0) total = json['total']; if (json.containsKey('data')) { final data = json['data']; if (data is List) { @@ -128,7 +128,7 @@ class GroupModel { } } } - } while (current < total); + } while (current < total + 1); } catch (err) { debugPrint('$err'); peerLoadError.value = err.toString(); From 099029f5e2799fc7879466a5d6c3345bc8049d46 Mon Sep 17 00:00:00 2001 From: 21pages Date: Wed, 14 Dec 2022 12:47:08 +0800 Subject: [PATCH 2/2] add group peer card mobile compatibility like address book Signed-off-by: 21pages --- flutter/lib/common/widgets/my_group.dart | 118 +++++++++++++++-------- 1 file changed, 80 insertions(+), 38 deletions(-) diff --git a/flutter/lib/common/widgets/my_group.dart b/flutter/lib/common/widgets/my_group.dart index 77ddf779b..65eaba40f 100644 --- a/flutter/lib/common/widgets/my_group.dart +++ b/flutter/lib/common/widgets/my_group.dart @@ -45,18 +45,11 @@ class _MyGroupState extends State { if (gFFI.groupModel.userLoadError.isNotEmpty) { return _buildShowError(gFFI.groupModel.userLoadError.value); } - return Row( - children: [ - _buildLeftDesktop(), - Expanded( - child: Align( - alignment: Alignment.topLeft, - child: MyGroupPeerView( - menuPadding: widget.menuPadding, - initPeers: gFFI.groupModel.peersShow.value)), - ) - ], - ); + if (isDesktop) { + return _buildDesktop(); + } else { + return _buildMobile(); + } }); } @@ -75,37 +68,86 @@ class _MyGroupState extends State { )); } - Widget _buildLeftDesktop() { - return Row( - children: [ - Card( - margin: EdgeInsets.symmetric(horizontal: 4.0), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12), - side: - BorderSide(color: Theme.of(context).scaffoldBackgroundColor)), - child: Container( - width: 200, - height: double.infinity, - padding: - const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0), - child: Column( - children: [ - _buildLeftHeader(), - Expanded( - child: Container( + Widget _buildDesktop() { + return Obx( + () => Row( + children: [ + Card( + margin: EdgeInsets.symmetric(horizontal: 4.0), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + side: BorderSide( + color: Theme.of(context).scaffoldBackgroundColor)), + child: Container( + width: 200, + height: double.infinity, + padding: + const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0), + child: Column( + children: [ + _buildLeftHeader(), + Expanded( + child: Container( + width: double.infinity, + height: double.infinity, + decoration: + BoxDecoration(borderRadius: BorderRadius.circular(2)), + child: _buildUserContacts(), + ).marginSymmetric(vertical: 8.0), + ) + ], + ), + ), + ).marginOnly(right: 8.0), + Expanded( + child: Align( + alignment: Alignment.topLeft, + child: MyGroupPeerView( + menuPadding: widget.menuPadding, + initPeers: gFFI.groupModel.peersShow.value)), + ) + ], + ), + ); + } + + Widget _buildMobile() { + return Obx( + () => Column( + children: [ + Card( + margin: EdgeInsets.symmetric(horizontal: 4.0), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + side: BorderSide( + color: Theme.of(context).scaffoldBackgroundColor)), + child: Container( + padding: + const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + _buildLeftHeader(), + Container( width: double.infinity, - height: double.infinity, decoration: - BoxDecoration(borderRadius: BorderRadius.circular(2)), + BoxDecoration(borderRadius: BorderRadius.circular(4)), child: _buildUserContacts(), - ).marginSymmetric(vertical: 8.0), - ) - ], + ).marginSymmetric(vertical: 8.0) + ], + ), ), ), - ).marginOnly(right: 8.0), - ], + Divider(), + Expanded( + child: Align( + alignment: Alignment.topLeft, + child: MyGroupPeerView( + menuPadding: widget.menuPadding, + initPeers: gFFI.groupModel.peersShow.value)), + ) + ], + ), ); }