Browse Source

Merge remote-tracking branch 'origin/dev' into dev

liukai 2 days ago
parent
commit
e9046fe4a3

+ 70 - 25
packages/cpt_community/lib/modules/community/community_page.dart

@@ -90,7 +90,11 @@ class CommunityPage extends HookConsumerWidget with WidgetsBindingObserver {
     Widget build(BuildContext context, WidgetRef ref) {
         final vm = ref.read(communityVmProvider.notifier);
         final state = ref.watch(communityVmProvider);
-
+        final newsIsCollection = useState<int?>(null);
+        final followIsCollection = useState<int?>(null);
+        final foryouIsCollection = useState<int?>(null);
+        final saleIsCollection = useState<int?>(null);
+        final rentIsCollection = useState<int?>(null);
         useEffect(() {
           // 监听窗口
           WidgetsBinding.instance.addObserver(this);
@@ -117,33 +121,74 @@ class CommunityPage extends HookConsumerWidget with WidgetsBindingObserver {
         },[]);
 
         return Scaffold(
-            appBar: MyAppBar.searchAppBar(
-              context,
-              value: vm.getCurrentQueryParams('keyword'),
-              actions: [
-                 const MyAssetImage(
-                  Assets.communityLikeActive,
+          appBar: state.currentCategoryIdx == 0 ?MyAppBar.appBar(
+            context,
+            S.current.community,
+            backgroundColor: context.appColors.backgroundWhite,
+            actions: [
+              if(state.currentPageViewIdx == 0)
+                MyAssetImage(
+                  newsIsCollection.value ==1? Assets.communityLikeActive : Assets.communityLike,
                   width: 21.5,
                   height: 21.5,
                 ).onTap((){
-                  vm.handlerClickNavbarLikeBtn(context);
-                 }),
-                SizedBox(width: state.currentCategoryIdx ==0 ? 15:20),
-                state.currentCategoryIdx ==1 ?
-                  const MyAssetImage(
-                    Assets.communityFillterIcon,
-                    width: 21,
-                    height: 21,
-                  ).onTap((){
-                    vm.handlerClickNavbarFilterBtn(context);
-                  }) : const SizedBox.shrink(),
-                const SizedBox(width: 15),
-              ],
-              backgroundColor: context.appColors.backgroundWhite,
-              onSearch: (value) {
-                vm.handlerSearch(value);
-              }
-            ),
+                  newsIsCollection.value = newsIsCollection.value == 1 ? null:1;
+                  vm.handlerClickNavbarLikeBtn(context, newsIsCollection.value);
+                }),
+              if(state.currentPageViewIdx == 1)
+                MyAssetImage(
+                  followIsCollection.value ==1? Assets.communityLikeActive : Assets.communityLike,
+                  width: 21.5,
+                  height: 21.5,
+                ).onTap((){
+                  followIsCollection.value = followIsCollection.value == 1 ? null:1;
+                  vm.handlerClickNavbarLikeBtn(context, followIsCollection.value);
+                }),
+               if(state.currentPageViewIdx == 2)
+                MyAssetImage(
+                  foryouIsCollection.value ==1? Assets.communityLikeActive : Assets.communityLike,
+                  width: 21.5,
+                  height: 21.5,
+                ).onTap((){
+                  foryouIsCollection.value = foryouIsCollection.value == 1 ? null:1;
+                  vm.handlerClickNavbarLikeBtn(context, foryouIsCollection.value);
+                }),
+              const SizedBox(width:15),
+            ],
+          ):MyAppBar.searchAppBar(
+            context,
+            value: vm.getCurrentQueryParams('keyword'),
+            actions: [
+              state.currentPageViewIdx == 3 ? MyAssetImage(
+                saleIsCollection.value ==1? Assets.communityLikeActive : Assets.communityLike,
+                width: 21.5,
+                height: 21.5,
+              ).onTap((){
+                saleIsCollection.value = saleIsCollection.value == 1 ? null:1;
+                vm.handlerClickNavbarLikeBtn(context, saleIsCollection.value);
+              }): MyAssetImage(
+                rentIsCollection.value ==1? Assets.communityLikeActive : Assets.communityLike,
+                width: 21.5,
+                height: 21.5,
+              ).onTap((){
+                rentIsCollection.value = rentIsCollection.value == 1 ? null:1;
+                vm.handlerClickNavbarLikeBtn(context, rentIsCollection.value);
+               }),
+              const SizedBox(width:15),
+              const MyAssetImage(
+                Assets.communityFillterIcon,
+                width: 21,
+                height: 21,
+              ).onTap((){
+                vm.handlerClickNavbarFilterBtn(context);
+              }),
+              SizedBox(width:15),
+            ],
+            backgroundColor: context.appColors.backgroundWhite,
+            onSearch: (value) {
+              vm.handlerSearch(value);
+            }
+          ),
           backgroundColor: context.appColors.backgroundDefault,
           body:  ExtendedNestedScrollView(
             key: extendedNestedScrollViewKey,

+ 5 - 5
packages/cpt_community/lib/modules/community/community_vm.dart

@@ -76,7 +76,7 @@ class CommunityVm extends _$CommunityVm {
     COMMUNITY_TABS_LIST.asMap().forEach((index, value) {
       _queryParams[index] = {
         'keyword': "",
-        'is_liked': "",
+        'liked': "",
         'category_id': "",
         'category_name': "",
         'page_view_idx': index,
@@ -335,7 +335,7 @@ class CommunityVm extends _$CommunityVm {
   }
 
   // 点击了导航栏的 like btn
-  handlerClickNavbarLikeBtn(BuildContext? context){
+  handlerClickNavbarLikeBtn(BuildContext? context, int? liked){
     if(state.currentCategoryIdx ==0){
       //
       // ToastEngine.show("点击了 newsfeed like");
@@ -346,15 +346,15 @@ class CommunityVm extends _$CommunityVm {
 
     }
 
-    _queryParams[state.currentPageViewIdx]?['is_liked'] = !(_queryParams?[state.currentPageViewIdx]?['is_liked']??false);
-
+    _queryParams[state.currentPageViewIdx]?['liked'] = liked;
 
+    Log.d("9999  ${_queryParams[state.currentPageViewIdx]?['liked']}");
     // 控制外层滚动和内层滚动
     handlerNestedScrollViewScroll();
 
     providerMap[state.currentPageViewIdx]
       ..setCurrentQueryParams({
-        "is_liked": _queryParams?[state.currentPageViewIdx]?['is_liked'],
+        "liked": _queryParams?[state.currentPageViewIdx]?['liked'],
       })
       ..directRefresh();
 

+ 3 - 2
packages/cpt_community/lib/modules/community/following/following_vm.dart

@@ -26,8 +26,8 @@ class FollowingVm extends _$FollowingVm {
   int _count = 0; // 总条数
 
   Map<String, dynamic> _queryParams = {
-    'keyword': null,
-    'is_liked': null,
+    'keyword': "",
+    'liked': "",
   };
   
   bool _needShowPlaceholder = false; //是否展示LoadingView
@@ -124,6 +124,7 @@ class FollowingVm extends _$FollowingVm {
       Map<String, dynamic>  params = {
         "page": _page,
         "limit": _limit,
+        "liked": _queryParams['liked']?? "",
       };
       Log.d("请求参数------$params");
       final result = await commonNewsFeedRespositoryInstance.fetchFollowingList(params);

+ 3 - 2
packages/cpt_community/lib/modules/community/foryou/foryou_vm.dart

@@ -28,8 +28,8 @@ class ForyouVm extends _$ForyouVm {
   int _count = 0; // 总条数
 
   Map<String, dynamic> _queryParams = {
-    'keyword': null,
-    'is_liked': null,
+    'keyword': "",
+    'liked': "",
   };
 
   // Refresh 控制器
@@ -126,6 +126,7 @@ class ForyouVm extends _$ForyouVm {
       Map<String, dynamic>  params = {
         "page": _page,
         "limit": _limit,
+        "liked": _queryParams['liked']?? "",
       };
       Log.d("请求参数------$params");
       final result = await commonNewsFeedRespositoryInstance.fetchForyouList(params);

+ 3 - 2
packages/cpt_community/lib/modules/community/news/news_vm.dart

@@ -30,8 +30,8 @@ class NewsVm extends _$NewsVm {
   int _count = 0; // 总条数
 
   Map<String, dynamic> _queryParams = {
-    'keyword': null,
-    'is_liked': null,
+    'keyword': "",
+    'liked': "",
   };
   
   bool _needShowPlaceholder = false; //是否展示LoadingView
@@ -131,6 +131,7 @@ class NewsVm extends _$NewsVm {
       Map<String, dynamic>  params = {
         "page": _page,
         "limit": _limit,
+        "liked": _queryParams['liked']?? "",
       };
       Log.d("请求参数------$params");
       final result = await commonNewsFeedRespositoryInstance.fetchNewsList(params);

+ 2 - 1
packages/cpt_community/lib/modules/garage/for_rent/for_rent_vm.dart

@@ -28,7 +28,7 @@ class ForrentVm extends _$ForrentVm {
   Map<String, dynamic> _queryParams = {
     'category_id': '',
     'keyword': '',
-    'is_liked': '',
+    'liked': '',
   };
 
   // Refresh 控制器
@@ -165,6 +165,7 @@ class ForrentVm extends _$ForrentVm {
         "type": 2,  // 类型(1=Sale,2=Rent)
         "category_id": _queryParams['category_id'],
         "keyword": _queryParams['keyword'],
+        "liked": _queryParams['liked']?? "",
         "page": _page,
         "limit": _limit,
       };

+ 2 - 1
packages/cpt_community/lib/modules/garage/for_sale/for_sale_vm.dart

@@ -30,7 +30,7 @@ class ForsaleVm extends _$ForsaleVm {
   Map<String, dynamic> _queryParams = {
     'category_id': '',
     'keyword': '',
-    'is_liked': '',
+    'liked': '',
   };
 
   // Refresh 控制器
@@ -127,6 +127,7 @@ class ForsaleVm extends _$ForsaleVm {
         "type": 1,  // 类型(1=Sale,2=Rent)
         "category_id": _queryParams['category_id'],
         "keyword": _queryParams['keyword'],
+        "liked": _queryParams['liked']?? "",
         "page": _page,
         "limit": _limit,
       };

+ 2 - 1
packages/cpt_services/lib/modules/services/homeService/home_service_vm.dart

@@ -60,7 +60,7 @@ class HomeServiceVm extends _$HomeServiceVm {
     'keyword': '',
     'sort': defaultSortType.name, // 排序(desc=降序,asc=升序)
     'sort_by': defaultSortByType.name, // 排序(likes_count=点赞量,orders_count=下单量,clicks_count=点击量)
-    'is_liked': '',
+    'liked': '',
   };
 
   // Refresh 控制器
@@ -201,6 +201,7 @@ class HomeServiceVm extends _$HomeServiceVm {
         "sort_by": _queryParams['sort_by']?? SortByType.clicks_count.name,  // 排序(likes_count=点赞量,orders_count=下单量,clicks_count=点击量)
         "category_id": _queryParams['category_id']??'',
         "keyword": _queryParams['keyword']??'',
+        "liked": _queryParams['liked']??'',
         "page": _page,
         "limit": _limit,
       };

+ 1 - 1
packages/cpt_services/lib/modules/services/inProgress/in_progress_vm.dart

@@ -31,7 +31,7 @@ class InProgressVm extends _$InProgressVm with DioCancelableMixin {
   Map<String, dynamic> _queryParams = {
     'category_id': '',
     'keyword': '',
-    'is_liked': '',
+    'liked': '',
   };
 
   // Refresh 控制器

+ 5 - 3
packages/cpt_services/lib/modules/services/repair/repair_page.dart

@@ -91,6 +91,7 @@ class RepairPage extends HookConsumerWidget with WidgetsBindingObserver {
     final vm = ref.read(repairVmProvider.notifier);
     final state = ref.watch(repairVmProvider);
     final currentPageIdx = tabsRouterKey.currentState?.controller?.activeIndex ?? 0;
+    final isCollection = useState<int?>(null);
 
     useEffect(() {
       Log.d("4343   $parentCategoryId");
@@ -124,12 +125,13 @@ class RepairPage extends HookConsumerWidget with WidgetsBindingObserver {
             value: vm.getCurrentQueryParams('keyword'),
             actions: [
               (state.currentPageViewIdx == 0) ? Container(
-                child: const MyAssetImage(
-                  Assets.serviceServiceScoreYes,
+                child: MyAssetImage(
+                  isCollection.value ==1? Assets.serviceServiceScoreYes : Assets.serviceServiceScoreNo,
                   width: 21.5,
                   height: 21.5,
                 ).onTap((){
-                  vm.handlerClickNavbarLikeBtn(context);
+                  isCollection.value = isCollection.value == 1 ? null:1;
+                  vm.handlerClickNavbarLikeBtn(context, isCollection.value);
                 }),
               ):const SizedBox.shrink(),
               const SizedBox(width: 15),

+ 8 - 8
packages/cpt_services/lib/modules/services/repair/repair_vm.dart

@@ -51,7 +51,7 @@ class RepairVm extends _$RepairVm {
     repairEntriesList.asMap().forEach((index, value) {
       _queryParams[index] = {
         'keyword': '',
-        'is_liked': '',
+        'liked': '',
         'page_view_idx': index,
         'page_view_name': value,
       };
@@ -217,16 +217,16 @@ class RepairVm extends _$RepairVm {
   }
 
   // 点击了导航栏的 like btn
-  handlerClickNavbarLikeBtn(BuildContext? context){
-    _queryParams[state.currentPageViewIdx]?['is_liked'] = !(_queryParams?[state.currentPageViewIdx]?['is_liked']??false);
+  handlerClickNavbarLikeBtn(BuildContext? context, int? liked){
+    _queryParams[state.currentPageViewIdx]?['liked'] = liked;
     // 控制外层滚动和内层滚动
     handlerNestedScrollViewScroll();
 
-    // providerMap[state.currentPageViewIdx]
-    //   ..setCurrentQueryParams({
-    //     "is_liked": _queryParams?[state.currentPageViewIdx]?['is_liked'],
-    //   })
-    //   ..directRefresh();
+    providerMap[state.currentPageViewIdx]
+      ..setCurrentQueryParams({
+        "liked": _queryParams?[state.currentPageViewIdx]?['liked'],
+      })
+      ..directRefresh();
   }
 
   handlerNestedScrollViewScroll({double? outerOffset, double? innerOffset=0.0, bool? isOuterScrollAnimated=false, bool? isInnerScrollAnimated=false}){

+ 3 - 2
packages/cpt_services/lib/modules/services/repair_homeService/home_service_vm.dart

@@ -39,10 +39,10 @@ class RepairHomeServiceVm extends _$RepairHomeServiceVm {
   bool _isSingleSelect = true;
   List<Map<String, dynamic>> _currentSelectedCategory = [];
 
-  Map<String, dynamic> _queryParams = {
+  final Map<String, dynamic> _queryParams = {
     'category_id': '',
     'keyword': '',
-    'is_liked': '',
+    'liked': '',
   };
 
   // Refresh 控制器
@@ -178,6 +178,7 @@ class RepairHomeServiceVm extends _$RepairHomeServiceVm {
         "sort_by": _queryParams['sort_by']?? SortByType.clicks_count.name,  // 排序(likes_count=点赞量,orders_count=下单量,clicks_count=点击量)
         "category_id": _queryParams['category_id']??'',
         "keyword": _queryParams['keyword']??'',
+        "liked": _queryParams['liked']??'',
         "page": _page,
         "limit": _limit,
       };

+ 5 - 3
packages/cpt_services/lib/modules/services/services_page.dart

@@ -91,6 +91,7 @@ class ServicesPage extends HookConsumerWidget with WidgetsBindingObserver {
     final vm = ref.read(servicesVmProvider.notifier);
     final state = ref.watch(servicesVmProvider);
     final currentPageIdx = tabsRouterKey.currentState?.controller?.activeIndex ?? 0;
+    final isCollection = useState<int?>(null);
 
     useEffect(() {
       vm.setInitPageData(context, parentCategoryId);
@@ -126,12 +127,13 @@ class ServicesPage extends HookConsumerWidget with WidgetsBindingObserver {
             value: vm.getCurrentQueryParams('keyword'),
             actions: [
               (state.currentPageViewIdx == 0) ? Container(
-                 child: const MyAssetImage(
-                    Assets.serviceServiceScoreYes,
+                 child: MyAssetImage(
+                   isCollection.value ==1? Assets.serviceServiceScoreYes : Assets.serviceServiceScoreNo,
                     width: 21.5,
                     height: 21.5,
                  ).onTap((){
-                    vm.handlerClickNavbarLikeBtn(context);
+                   isCollection.value = isCollection.value == 1 ? null:1;
+                    vm.handlerClickNavbarLikeBtn(context, isCollection.value);
                  }),
                ):const SizedBox.shrink(),
               const SizedBox(width: 15),

+ 8 - 8
packages/cpt_services/lib/modules/services/services_vm.dart

@@ -54,7 +54,7 @@ class ServicesVm extends _$ServicesVm {
     servicesEntriesList.asMap().forEach((index, value) {
       _queryParams[index] = {
         'keyword': '',
-        'is_liked': '',
+        'liked': '',
         'page_view_idx': index,
         'page_view_name': value,
       };
@@ -230,16 +230,16 @@ class ServicesVm extends _$ServicesVm {
   }
 
   // 点击了导航栏的 like btn
-  handlerClickNavbarLikeBtn(BuildContext? context){
-    _queryParams[state.currentPageViewIdx]?['is_liked'] = !(_queryParams?[state.currentPageViewIdx]?['is_liked']??false);
+  handlerClickNavbarLikeBtn(BuildContext? context, int? liked){
+    _queryParams[state.currentPageViewIdx]?['liked'] = liked;
     // 控制外层滚动和内层滚动
     handlerNestedScrollViewScroll();
 
-    // providerMap[state.currentPageViewIdx]
-    //   ..setCurrentQueryParams({
-    //     "is_liked": _queryParams?[state.currentPageViewIdx]?['is_liked'],
-    //   })
-    //   ..directRefresh();
+    providerMap[state.currentPageViewIdx]
+      ..setCurrentQueryParams({
+        "liked": _queryParams?[state.currentPageViewIdx]?['liked'],
+      })
+      ..directRefresh();
   }
 
   handlerNestedScrollViewScroll({double? outerOffset, double? innerOffset=0.0, bool? isOuterScrollAnimated=false, bool? isInnerScrollAnimated=false}){