glglove дней назад: 5
Родитель
Сommit
9511318070

+ 123 - 58
packages/cpt_community/lib/components/garage_card_header.dart

@@ -1,30 +1,38 @@
+import 'package:cs_resources/generated/assets.dart';
+import 'package:cs_resources/theme/app_colors_theme.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/widgets.dart';
+import 'package:flutter_hooks/flutter_hooks.dart';
+import 'package:hooks_riverpod/hooks_riverpod.dart';
 import 'package:shared/utils/color_utils.dart';
+import 'package:shared/utils/log_utils.dart';
 import 'package:widgets/ext/ex_widget.dart';
 import 'package:widgets/my_load_image.dart';
 import 'package:widgets/my_text_view.dart';
 
+import '../modules/garage/for_sale/for_sale_vm.dart';
+
 // 'id':1,
-// 'avator': Assets.communityCamera,
-// 'title': 'William Jefferson',
-// 'isFollow': false,
-// 'content': 'She said YES and our lives changed.Thank you all for coming to my propose today.We hope everyone can ……[More]',
-// 'imageUrls': ['https://img.alicdn.com/tfs/TB1h.o9O4MPMeJjy1XaXXcSsFXa-640-360.jpg','https://img.alicdn.com/tfs/TB1h.o9O4MPMeJjy1XaXXcSsFXa-640-360.jpg','https://img.alicdn.com/tfs/TB1h.o9O4MPMeJjy1XaXXcSsFXa-640-360.jpg'],
-// 'time': 'June 17,2016 at 7:23 p.m.',
-// 'likeno': 12
+// 'goods_img':  'https://img.alicdn.com/tfs/TB1h.o9O4MPMeJjy1XaXXcSsFXa-640-360.jpg',
+// 'title': 'Electronic keyboard',
+// 'price': '\$66',
+// 'isCollection': true,
+// 'collection_num': '12',
+// 'publisher': 'William Jefferson',
+// 'publish_time': 'June 17,2016 at 7:23 p.m.',
+// 'publisher_avator': Assets.communityCamera,'
+
+
+
+
 
 class GarageCardHeader extends StatelessWidget {
-  final String title;
-  final String avator;
-  final String time;
-  final VoidCallback? onTap;
+  Map<String, dynamic> itemObj;
+  final Function()? onTap;
 
-  const GarageCardHeader({
+  GarageCardHeader({
     Key? key,
-    required this.title,
-    required this.avator,
-    required this.time,
+    required this.itemObj,
     this.onTap,
   }) : super(key: key);
 
@@ -32,53 +40,110 @@ class GarageCardHeader extends StatelessWidget {
 
   @override
   Widget build(BuildContext context) {
+    return Column(
+      children: [
+        Row(
+          mainAxisAlignment: MainAxisAlignment.center,
+          crossAxisAlignment: CrossAxisAlignment.center,
+          children: [
+            Expanded(
+              child: MyLoadImage(
+                itemObj['goods_img'],
+                width: 166.5,
+                height: 102.5,
+                isCircle: false,
+                fit: BoxFit.cover,
+              ).onTap(() {
+                // 点击头像
+                // onTap?.call();
+              }),
+            ),
+          ],
+        ),
+        Row(
+          mainAxisAlignment: MainAxisAlignment.center,
+          children: [
+            Expanded(
+              child: MyTextView(
+                itemObj['title'],
+                maxLines: 1,
+                isTextEllipsis: true,
+                textAlign: TextAlign.center,
+                textColor: context.appColors.textBlack,
+                fontSize: 16,
+                isFontRegular: true,
+                marginLeft: 12,
+                marginRight: 12,
+              ),
+            ),
+          ],
+        ),
+        Row(
+          mainAxisAlignment: MainAxisAlignment.spaceAround,
+          crossAxisAlignment: CrossAxisAlignment.center,
+          children: [
+            Expanded(
+              child: MyTextView(
+                itemObj['price'],
+                maxLines: 1,
+                isTextEllipsis: true,
+                textAlign: TextAlign.start,
+                textColor: ColorUtils.string2Color('#4161D0'),
+                fontSize: 18,
+                isFontMedium: true,
+              ),
+            ),
+            // 动态的 收藏数
+            CollectionWidget(collectionNum: itemObj['collection_num'], isCollection: itemObj['isCollection']),
+          ],
+        ),
+      ],
+    );
+  }
+}
+
+
+
+class CollectionWidget extends HookConsumerWidget {
+  int collectionNum = 0;
+  bool isCollection = false;
+  CollectionWidget({
+    Key? key,
+    required this.collectionNum,
+    required this.isCollection,
+  }) : super(key: key);
+  @override
+  Widget build(BuildContext context, WidgetRef ref) {
+    final collectionNumState = useState(collectionNum);
+    final isCollectionState = useState(isCollection);
+
     return Container(
-      padding: const EdgeInsets.only(left: 16,right: 60),
+      width: 60,
+      height: 30,
+      alignment: Alignment.center,
+      decoration: BoxDecoration(
+        color: ColorUtils.string2Color('#E5E5E5'),
+        borderRadius: BorderRadius.circular(15),
+      ),
       child: Row(
-        mainAxisAlignment: MainAxisAlignment.start,
-        crossAxisAlignment: CrossAxisAlignment.start,
+        mainAxisAlignment: MainAxisAlignment.center,
         children: [
-          MyLoadImage(
-            avator,
-            width: 45,
-            height: 45,
-            isCircle: true,
-            fit: BoxFit.cover,
-          ).onTap(() {
-            // 点击头像
-            onTap?.call();
-          }),
-          Expanded(
-            child: Container(
-              padding: const EdgeInsets.only(left:15, right: 40),
-              // color: Colors.red,
-              child: Column(
-                mainAxisAlignment: MainAxisAlignment.start,
-                crossAxisAlignment: CrossAxisAlignment.start,
-                children: [
-                  MyTextView(
-                    title,
-                    isFontMedium: true,
-                    fontSize: 18,
-                    textColor: ColorUtils.string2Color('#000000'),
-                    maxLines: 1,
-                    isTextEllipsis: true,
-                  ),
-                  MyTextView(
-                    time,
-                    isFontRegular: true,
-                    fontSize: 13,
-                    marginTop: 8,
-                    textColor: ColorUtils.string2Color('#767676'),
-                    maxLines: 1,
-                    isTextEllipsis: true,
-                  ),
-                ],
-              ),
-            ),
+          MyTextView(
+            '${collectionNumState.value}',
+            textColor: ColorUtils.string2Color('#999999'),
+            fontSize: 14,
+            isFontRegular: true,
           ),
-        ],
-      ),
+          MyLoadImage(
+            isCollectionState.value? Assets.communityLikeActive: Assets.communityLike,
+            width: 14,
+            height: 14,
+          )
+        ]
+      ).onTap((){
+        // 点击 收餐/取消收藏
+        Log.d("点击了收藏按钮");
+      })
     );
   }
 }

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

@@ -3,7 +3,7 @@ class ForrentState {
   int? curPage =0;
   int? pageSize =10;
   int? filterCount =0;
-  List<String>? tabsList = ['News', 'Following', 'For You'];
+  List<String>? tabsList = ['For Sale', 'For Rent'];
   List<Map<String, dynamic>>? list = [];
 
   ForrentState({

+ 35 - 68
packages/cpt_community/lib/modules/garage/for_sale/for_sale_page.dart

@@ -38,7 +38,7 @@ class ForsalePage extends HookConsumerWidget {
   @override
   Widget build(BuildContext context, WidgetRef ref) {
     final vm = ref.read(forsaleVmProvider.notifier);
-    return const Scaffold(
+    return Scaffold(
       // appBar: MyAppBar.appBar(
       //   context,
       //   "Forsale",
@@ -48,20 +48,19 @@ class ForsalePage extends HookConsumerWidget {
       body: Column(
         children: [
             Expanded(
-              // child: EasyRefresh(
-              //   // 上拉加载
-              //   onLoad: () async{
-              //     Log.d("----onLoad");
-              //     vm.onLoadData();
-              //   },
-              //   // 下拉刷新
-              //   onRefresh: () async{
-              //     Log.d("----onRefresh");
-              //     vm.refreshListData();
-              //   },
-              //   child: _buildForsaleFeedList(context, ref, vm),
-              // ),
-              child: Text("for sale page"),
+              child: EasyRefresh(
+                // 上拉加载
+                onLoad: () async{
+                  Log.d("----onLoad");
+                  vm.onLoadData();
+                },
+                // 下拉刷新
+                onRefresh: () async{
+                  Log.d("----onRefresh");
+                  vm.refreshListData();
+                },
+                child: _buildForsaleFeedList(context, ref, vm),
+              ),
             )
         ],
       )
@@ -86,67 +85,35 @@ class ForsalePage extends HookConsumerWidget {
                   // 卡片头部(头像 标题 时间)
                   GarageCardHeader(
                     key: UniqueKey(),
-                    title: item['title'],
-                    avator: item['avator'],
-                    time: item['time'],
+                    itemObj: item,
                   ),
                   const SizedBox(height: 15),
                   // 卡片中间 (文字和图片)
-                  Expanded(
-                    child: GarageCardContent(
-                      key: UniqueKey(),
-                      content: item['content'],
-                      imageUrls: item['imageUrls'],
-                    ),
-                  ),
+                  // Expanded(
+                  //   child: GarageCardContent(
+                  //     key: UniqueKey(),
+                  //     content: item['content'],
+                  //     imageUrls: item['imageUrls'],
+                  //   ),
+                  // ),
                   const SizedBox(height: 26),
                   // // 卡片底部 (点赞 评论 分享)
-                  GarageCardFooter(
-                      key: UniqueKey(),
-                      isLike: item['isLike'],
-                      onLike: (){
-                        vm.handlerClickActionBtn('like', item);
-                      },
-                      onComment: (){
-                        vm.handlerClickActionBtn('comments', item);
-                      },
-                      onShare: (){
-                        vm.handlerClickActionBtn('share', item);
-                      },
-                  ),
+                  // GarageCardFooter(
+                  //     key: UniqueKey(),
+                  //     isLike: item['isLike'],
+                  //     onLike: (){
+                  //       vm.handlerClickActionBtn('like', item);
+                  //     },
+                  //     onComment: (){
+                  //       vm.handlerClickActionBtn('comments', item);
+                  //     },
+                  //     onShare: (){
+                  //       vm.handlerClickActionBtn('share', item);
+                  //     },
+                  // ),
                 ]
             ),
           ),
-          // 右上角 关注/取消关注 按钮
-          Visibility(
-            visible: !item['isFollow'],
-            child: Positioned(
-              right: 40,
-              top: 35,
-              child: Container(
-                width: 83.5,
-                height: 45.5,
-                alignment: Alignment.center,
-                // decoration: BoxDecoration(
-                //   color:  ColorUtils.string2Color('#4161D0'),
-                //   borderRadius: BorderRadius.circular(5),
-                // ),
-                child: MyButton(
-                  text: '+Follow',
-                  textColor: Colors.white,
-                  backgroundColor: ColorUtils.string2Color('#4161D0'),
-                  radius: 8,
-                  minHeight: 27.5,
-                  padding: const EdgeInsets.only(left: 5, right: 5,top:9,bottom:9),
-                  fontWeight: FontWeight.w400,
-                  fontSize: 14,
-                  onPressed: (){
-                    // Navigator.pop(context);
-                  },
-                ),
-              )
-            ),
-          )
         ],
       ),
     );

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

@@ -3,7 +3,7 @@ class ForsaleState {
   int? curPage =0;
   int? pageSize =10;
   int? filterCount =0;
-  List<String>? tabsList = ['Forsale', 'Following', 'For You'];
+  List<String>? tabsList = ['For Sale', 'For Rent'];
   List<Map<String, dynamic>>? list = [];
 
   ForsaleState({

+ 48 - 59
packages/cpt_community/lib/modules/garage/for_sale/for_sale_vm.dart

@@ -20,80 +20,69 @@ class ForsaleVm extends _$ForsaleVm {
       list: [
           {
             'id':1,
-            'avator': Assets.communityCamera,
-            'title': 'William Jefferson',
-            'isFollow': false,
-            'content': 'She said YES and our lives changed.Thank you all for coming to my propose today.We hope everyone can ……[More]',
-            'imageUrls': ['https://img.alicdn.com/tfs/TB1h.o9O4MPMeJjy1XaXXcSsFXa-640-360.jpg','https://img.alicdn.com/tfs/TB1h.o9O4MPMeJjy1XaXXcSsFXa-640-360.jpg','https://img.alicdn.com/tfs/TB1h.o9O4MPMeJjy1XaXXcSsFXa-640-360.jpg'],
-            'time': 'June 17,2016 at 7:23 p.m.',
-              'isLike': true,
-            'likeno': 12
+            'goods_img':  'https://img.alicdn.com/tfs/TB1h.o9O4MPMeJjy1XaXXcSsFXa-640-360.jpg',
+            'title': 'Electronic keyboard',
+            'price': '\$66',
+            'isCollection': true,
+            'collection_num': '12',
+            'publisher': 'William Jefferson',
+            'publish_time': 'June 17,2016 at 7:23 p.m.',
+            'publisher_avator': Assets.communityCamera
           },
           {
             'id':2,
-            'avator': Assets.communityCamera,
-            'title': 'William fdsaf的飞洒发生的',
-            'isFollow': true,
-            'content': 'She said YES and our lives changed.Thank you all for coming to my propose today.We hope everyone can ……[More]',
-            'imageUrls': [],
-            'time': 'June 17,2016 at 7:23 p.m.',
-            'isLike': true,
-            'likeno': 12
+            'goods_img':  'https://img.alicdn.com/tfs/TB1h.o9O4MPMeJjy1XaXXcSsFXa-640-360.jpg',
+            'title': 'Electronic keyboard',
+            'price': '\$88',
+            'isCollection': false,
+            'collection_num': '12',
+            'publisher': 'William Jefferson',
+            'publish_time': 'June 17,2016 at 7:23 p.m.',
+            'publisher_avator': Assets.communityCamera
           },
           {
             'id':3,
-            'avator': Assets.communityCamera,
-            'title': 'Fsjfkds  dfsk',
-            'isFollow': false,
-            'content': 'She said YES and our lives changed.Thank you all for coming to my propose today.We hope everyone can ……[More]',
-            'imageUrls': [],
-            'time': 'June 17,2016 at 7:23 p.m.',
-            'isLike': false,
-            'likeno': 12
+            'goods_img':  'https://img.alicdn.com/tfs/TB1h.o9O4MPMeJjy1XaXXcSsFXa-640-360.jpg',
+            'title': 'Electronic keyboard',
+            'price': '\$66',
+            'isCollection': true,
+            'collection_num': '12',
+            'publisher': 'William Jefferson',
+            'publish_time': 'June 17,2016 at 7:23 p.m.',
+            'publisher_avator': Assets.communityCamera
           },
           {
             'id':4,
-            'avator': Assets.communityCamera,
-            'title': 'Fsjfkds  dfsk',
-            'isFollow': false,
-            'content': 'She said YES and our lives changed.Thank you all for coming to my propose today.We hope everyone can ……[More]',
-            'imageUrls': [],
-            'time': 'June 17,2016 at 7:23 p.m.',
-            'isLike': false,
-            'likeno': 12
+            'goods_img':  'https://img.alicdn.com/tfs/TB1h.o9O4MPMeJjy1XaXXcSsFXa-640-360.jpg',
+            'title': 'Electronic keyboard',
+            'price': '\$88',
+            'isCollection': false,
+            'collection_num': '12',
+            'publisher': 'William Jefferson',
+            'publish_time': 'June 17,2016 at 7:23 p.m.',
+            'publisher_avator': Assets.communityCamera
           },
           {
             'id':5,
-            'avator': Assets.communityCamera,
-            'title': 'Fsjfkds  dfsk',
-            'isFollow': false,
-            'content': 'She said YES and our lives changed.Thank you all for coming to my propose today.We hope everyone can ……[More]',
-            'imageUrls': [],
-            'time': 'June 17,2016 at 7:23 p.m.',
-            'isLike': false,
-            'likeno': 12
+            'goods_img':  'https://img.alicdn.com/tfs/TB1h.o9O4MPMeJjy1XaXXcSsFXa-640-360.jpg',
+            'title': 'Electronic keyboard',
+            'price': '\$66',
+            'isCollection': true,
+            'collection_num': '12',
+            'publisher': 'William Jefferson',
+            'publish_time': 'June 17,2016 at 7:23 p.m.',
+            'publisher_avator': Assets.communityCamera
           },
           {
             'id':6,
-            'avator': Assets.communityCamera,
-            'title': 'Fsjfkds  dfsk',
-            'isFollow': false,
-            'content': 'She said YES and our lives changed.Thank you all for coming to my propose today.We hope everyone can ……[More]',
-            'imageUrls': [],
-            'time': 'June 17,2016 at 7:23 p.m.',
-            'isLike': false,
-            'likeno': 12
-          },
-          {
-            'id':7,
-            'avator': Assets.communityCamera,
-            'title': '放大发大水',
-            'isFollow': false,
-            'content': 'She said YES and our lives changed.Thank you all for coming to my propose today.We hope everyone can ……[More]',
-            'imageUrls': [],
-            'time': 'June 17,2016 at 7:23 p.m.',
-            'isLike': false,
-            'likeno': 12
+            'goods_img':  'https://img.alicdn.com/tfs/TB1h.o9O4MPMeJjy1XaXXcSsFXa-640-360.jpg',
+            'title': 'Electronic keyboard',
+            'price': '\$88',
+            'isCollection': false,
+            'collection_num': '12',
+            'publisher': 'William Jefferson',
+            'publish_time': 'June 17,2016 at 7:23 p.m.',
+            'publisher_avator': Assets.communityCamera
           },
       ]
     );