Commit 3174d80c70d073d0e6c7f9e3202bdb0740aa57fc

Authored by 刘宏哲
1 parent ed605492

feat(app): bug fixed

@@ -12,7 +12,6 @@ import 'package:doublefeel_flutter/core/util/app_toast.dart'; @@ -12,7 +12,6 @@ import 'package:doublefeel_flutter/core/util/app_toast.dart';
12 import 'package:doublefeel_flutter/data/models/health/health_v2_models.dart'; 12 import 'package:doublefeel_flutter/data/models/health/health_v2_models.dart';
13 import 'package:doublefeel_flutter/l10n/l10n_extensions.dart'; 13 import 'package:doublefeel_flutter/l10n/l10n_extensions.dart';
14 import 'package:doublefeel_flutter/pigeon/platform_api.g.dart'; 14 import 'package:doublefeel_flutter/pigeon/platform_api.g.dart';
15 -import 'package:doublefeel_flutter/pigeon/wear_engine_api.g.dart';  
16 import 'package:get/get.dart'; 15 import 'package:get/get.dart';
17 16
18 import '../data/friends_repository.dart'; 17 import '../data/friends_repository.dart';
@@ -139,8 +138,7 @@ class FriendsController extends GetxController { @@ -139,8 +138,7 @@ class FriendsController extends GetxController {
139 if (userId == null) return; 138 if (userId == null) return;
140 try { 139 try {
141 await _repository.updateRemark(userId, remark); 140 await _repository.updateRemark(userId, remark);
142 - final index = friends.indexOf(friend);  
143 - if (index >= 0) friends[index] = friend.copyWith(remark: remark); 141 + await loadFriends();
144 } catch (error, stackTrace) { 142 } catch (error, stackTrace) {
145 if (error is AppError) { 143 if (error is AppError) {
146 AppToast.show(error.displayMessage); 144 AppToast.show(error.displayMessage);
@@ -161,14 +159,7 @@ class FriendsController extends GetxController { @@ -161,14 +159,7 @@ class FriendsController extends GetxController {
161 } 159 }
162 try { 160 try {
163 await _repository.selectWatchFaceFriend(friendUserId); 161 await _repository.selectWatchFaceFriend(friendUserId);
164 - final updatedFriends = friends  
165 - .map(  
166 - (friend) => friend.userId == friendUserId  
167 - ? friend.copyWith(isOnWatchFace: true)  
168 - : friend,  
169 - )  
170 - .toList(growable: false);  
171 - friends.assignAll(updatedFriends); 162 + await loadFriends();
172 await _updateWatchOtherUserInfo( 163 await _updateWatchOtherUserInfo(
173 WatchAppOtherInfo( 164 WatchAppOtherInfo(
174 userId: friendUserId, 165 userId: friendUserId,
1 import 'package:doublefeel_flutter/app/modules/hrv_report/models/hrv_report_models.dart'; 1 import 'package:doublefeel_flutter/app/modules/hrv_report/models/hrv_report_models.dart';
  2 +import 'package:doublefeel_flutter/app/modules/home/widgets/df_tab_bar.dart';
2 import 'package:doublefeel_flutter/app/routes/app_pages.dart'; 3 import 'package:doublefeel_flutter/app/routes/app_pages.dart';
3 import 'package:doublefeel_flutter/core/constants/intent_keys.dart'; 4 import 'package:doublefeel_flutter/core/constants/intent_keys.dart';
4 -import 'package:doublefeel_flutter/core/util/size_extensions.dart';  
5 import 'package:doublefeel_flutter/data/local/user_preferences_storage.dart'; 5 import 'package:doublefeel_flutter/data/local/user_preferences_storage.dart';
6 import 'package:doublefeel_flutter/l10n/l10n_extensions.dart'; 6 import 'package:doublefeel_flutter/l10n/l10n_extensions.dart';
7 import 'package:doublefeel_flutter/r.dart'; 7 import 'package:doublefeel_flutter/r.dart';
@@ -16,6 +16,8 @@ import '../widgets/friend_health_card.dart'; @@ -16,6 +16,8 @@ import '../widgets/friend_health_card.dart';
16 class FriendsTab extends GetView<FriendsController> { 16 class FriendsTab extends GetView<FriendsController> {
17 const FriendsTab({super.key}); 17 const FriendsTab({super.key});
18 18
  19 + static const double _floatingAddButtonGap = 23;
  20 +
19 @override 21 @override
20 Widget build(BuildContext context) { 22 Widget build(BuildContext context) {
21 final userPreferences = Get.find<UserPreferencesStorage>(); 23 final userPreferences = Get.find<UserPreferencesStorage>();
@@ -161,7 +163,12 @@ class FriendsTab extends GetView<FriendsController> { @@ -161,7 +163,12 @@ class FriendsTab extends GetView<FriendsController> {
161 onRefresh: controller.refreshData, 163 onRefresh: controller.refreshData,
162 child: ListView( 164 child: ListView(
163 physics: const AlwaysScrollableScrollPhysics(), 165 physics: const AlwaysScrollableScrollPhysics(),
164 - padding: EdgeInsets.fromLTRB(0, 0, 0, 188.dp), 166 + padding: EdgeInsets.fromLTRB(
  167 + 0,
  168 + 0,
  169 + 0,
  170 + _friendsListBottomPadding(context, isFull: isFull),
  171 + ),
165 children: [ 172 children: [
166 selfHealthCard, 173 selfHealthCard,
167 const SizedBox(height: 12), 174 const SizedBox(height: 12),
@@ -213,23 +220,28 @@ class FriendsTab extends GetView<FriendsController> { @@ -213,23 +220,28 @@ class FriendsTab extends GetView<FriendsController> {
213 } 220 }
214 221
215 double _floatingAddButtonBottom(BuildContext context) { 222 double _floatingAddButtonBottom(BuildContext context) {
216 - return _tabBarAvoidanceBottom(context) + 23.dp; 223 + return _tabBarAvoidanceBottom(context) + _floatingAddButtonGap;
217 } 224 }
218 225
219 double _tabBarAvoidanceBottom(BuildContext context) { 226 double _tabBarAvoidanceBottom(BuildContext context) {
220 - const tabBarHeight = 56.0;  
221 - const tabBarBottomPadding = 8.0;  
222 return MediaQuery.viewPaddingOf(context).bottom + 227 return MediaQuery.viewPaddingOf(context).bottom +
223 - tabBarHeight +  
224 - tabBarBottomPadding; 228 + DfTabBar.height +
  229 + DfTabBar.bottomMargin;
  230 + }
  231 +
  232 + double _friendsListBottomPadding(
  233 + BuildContext context, {
  234 + required bool isFull,
  235 + }) {
  236 + return _floatingAddButtonBottom(context) + (isFull ? 100 : 72);
225 } 237 }
226 238
227 Future<void> _handleAddFriend() async { 239 Future<void> _handleAddFriend() async {
228 final Type type = FriendsTab; 240 final Type type = FriendsTab;
229 final String name = type.toString(); 241 final String name = type.toString();
230 - final didAddFriend = await Get.toNamed(AppRoutes.bindPartner, 242 + await Get.toNamed(AppRoutes.bindPartner,
231 arguments: {IntentKeys.keyFrom: name}); 243 arguments: {IntentKeys.keyFrom: name});
232 - if (didAddFriend == true) await controller.loadFriends(); 244 + await controller.loadFriends();
233 } 245 }
234 246
235 void _openFriendHome(FriendHealthData friend) { 247 void _openFriendHome(FriendHealthData friend) {
@@ -12,6 +12,9 @@ class DfTabBar extends StatelessWidget { @@ -12,6 +12,9 @@ class DfTabBar extends StatelessWidget {
12 required this.onTap, 12 required this.onTap,
13 }); 13 });
14 14
  15 + static const double height = 56;
  16 + static const double bottomMargin = 8;
  17 +
15 static const _selectedBgColor = Color(0xFFF3F3F3); 18 static const _selectedBgColor = Color(0xFFF3F3F3);
16 19
17 static const _tabIcons = [ 20 static const _tabIcons = [
@@ -41,9 +44,9 @@ class DfTabBar extends StatelessWidget { @@ -41,9 +44,9 @@ class DfTabBar extends StatelessWidget {
41 return SafeArea( 44 return SafeArea(
42 top: false, 45 top: false,
43 child: Padding( 46 child: Padding(
44 - padding: const EdgeInsets.fromLTRB(16, 0, 16, 8), 47 + padding: const EdgeInsets.fromLTRB(16, 0, 16, bottomMargin),
45 child: Container( 48 child: Container(
46 - height: 56, 49 + height: height,
47 decoration: BoxDecoration( 50 decoration: BoxDecoration(
48 color: Colors.white, 51 color: Colors.white,
49 borderRadius: BorderRadius.circular(28), 52 borderRadius: BorderRadius.circular(28),
@@ -389,9 +389,9 @@ @@ -389,9 +389,9 @@
389 "friendsWaitingForData": "Waiting for data", 389 "friendsWaitingForData": "Waiting for data",
390 "friendsSleepQuality": "Sleep quality", 390 "friendsSleepQuality": "Sleep quality",
391 "friendsTodaySteps": "Steps today", 391 "friendsTodaySteps": "Steps today",
392 - "friendsSleepQualityExcellent": "Excellent",  
393 - "friendsSleepQualityNormal": "Normal",  
394 - "friendsSleepQualityAttention": "Needs attention", 392 + "friendsSleepQualityExcellent": "Slept great",
  393 + "friendsSleepQualityNormal": "Slept well",
  394 + "friendsSleepQualityAttention": "Slept poorly",
395 "friendsRemove": "Remove", 395 "friendsRemove": "Remove",
396 "friendsEditRemark": "Edit nickname", 396 "friendsEditRemark": "Edit nickname",
397 "friendsShowOnWatchFace": "Show on watch face", 397 "friendsShowOnWatchFace": "Show on watch face",
@@ -495,4 +495,4 @@ @@ -495,4 +495,4 @@
495 "appReviewFeedbackSendAction": "Send Feedback", 495 "appReviewFeedbackSendAction": "Send Feedback",
496 "appReviewFeedbackLaterAction": "Maybe Later", 496 "appReviewFeedbackLaterAction": "Maybe Later",
497 "appReviewIllustrationPlaceholder": "Illustration Placeholder" 497 "appReviewIllustrationPlaceholder": "Illustration Placeholder"
498 -}  
  498 +}
@@ -653,9 +653,9 @@ @@ -653,9 +653,9 @@
653 "friendsWaitingForData": "等待数据", 653 "friendsWaitingForData": "等待数据",
654 "friendsSleepQuality": "睡眠质量", 654 "friendsSleepQuality": "睡眠质量",
655 "friendsTodaySteps": "今日步数", 655 "friendsTodaySteps": "今日步数",
656 - "friendsSleepQualityExcellent": "优秀",  
657 - "friendsSleepQualityNormal": "正常",  
658 - "friendsSleepQualityAttention": "注意", 656 + "friendsSleepQualityExcellent": "睡的很棒",
  657 + "friendsSleepQualityNormal": "睡得不错",
  658 + "friendsSleepQualityAttention": "睡得差",
659 "friendsRemove": "删除Ta", 659 "friendsRemove": "删除Ta",
660 "friendsEditRemark": "修改备注", 660 "friendsEditRemark": "修改备注",
661 "friendsShowOnWatchFace": "在表盘显示", 661 "friendsShowOnWatchFace": "在表盘显示",
@@ -780,4 +780,4 @@ @@ -780,4 +780,4 @@
780 "appReviewFeedbackSendAction": "发送反馈", 780 "appReviewFeedbackSendAction": "发送反馈",
781 "appReviewFeedbackLaterAction": "稍后再说", 781 "appReviewFeedbackLaterAction": "稍后再说",
782 "appReviewIllustrationPlaceholder": "插图占位" 782 "appReviewIllustrationPlaceholder": "插图占位"
783 -}  
  783 +}
@@ -2436,19 +2436,19 @@ abstract class AppLocalizations { @@ -2436,19 +2436,19 @@ abstract class AppLocalizations {
2436 /// No description provided for @friendsSleepQualityExcellent. 2436 /// No description provided for @friendsSleepQualityExcellent.
2437 /// 2437 ///
2438 /// In zh, this message translates to: 2438 /// In zh, this message translates to:
2439 - /// **'优秀'** 2439 + /// **'睡的很棒'**
2440 String get friendsSleepQualityExcellent; 2440 String get friendsSleepQualityExcellent;
2441 2441
2442 /// No description provided for @friendsSleepQualityNormal. 2442 /// No description provided for @friendsSleepQualityNormal.
2443 /// 2443 ///
2444 /// In zh, this message translates to: 2444 /// In zh, this message translates to:
2445 - /// **'正常'** 2445 + /// **'睡得不错'**
2446 String get friendsSleepQualityNormal; 2446 String get friendsSleepQualityNormal;
2447 2447
2448 /// No description provided for @friendsSleepQualityAttention. 2448 /// No description provided for @friendsSleepQualityAttention.
2449 /// 2449 ///
2450 /// In zh, this message translates to: 2450 /// In zh, this message translates to:
2451 - /// **'注意'** 2451 + /// **'睡得差'**
2452 String get friendsSleepQualityAttention; 2452 String get friendsSleepQualityAttention;
2453 2453
2454 /// No description provided for @friendsRemove. 2454 /// No description provided for @friendsRemove.
@@ -1343,13 +1343,13 @@ class AppLocalizationsEn extends AppLocalizations { @@ -1343,13 +1343,13 @@ class AppLocalizationsEn extends AppLocalizations {
1343 String get friendsTodaySteps => 'Steps today'; 1343 String get friendsTodaySteps => 'Steps today';
1344 1344
1345 @override 1345 @override
1346 - String get friendsSleepQualityExcellent => 'Excellent'; 1346 + String get friendsSleepQualityExcellent => 'Slept great';
1347 1347
1348 @override 1348 @override
1349 - String get friendsSleepQualityNormal => 'Normal'; 1349 + String get friendsSleepQualityNormal => 'Slept well';
1350 1350
1351 @override 1351 @override
1352 - String get friendsSleepQualityAttention => 'Needs attention'; 1352 + String get friendsSleepQualityAttention => 'Slept poorly';
1353 1353
1354 @override 1354 @override
1355 String get friendsRemove => 'Remove'; 1355 String get friendsRemove => 'Remove';
@@ -1280,13 +1280,13 @@ class AppLocalizationsZh extends AppLocalizations { @@ -1280,13 +1280,13 @@ class AppLocalizationsZh extends AppLocalizations {
1280 String get friendsTodaySteps => '今日步数'; 1280 String get friendsTodaySteps => '今日步数';
1281 1281
1282 @override 1282 @override
1283 - String get friendsSleepQualityExcellent => '优秀'; 1283 + String get friendsSleepQualityExcellent => '睡的很棒';
1284 1284
1285 @override 1285 @override
1286 - String get friendsSleepQualityNormal => '正常'; 1286 + String get friendsSleepQualityNormal => '睡得不错';
1287 1287
1288 @override 1288 @override
1289 - String get friendsSleepQualityAttention => '注意'; 1289 + String get friendsSleepQualityAttention => '睡得差';
1290 1290
1291 @override 1291 @override
1292 String get friendsRemove => '删除Ta'; 1292 String get friendsRemove => '删除Ta';