|
@@ -0,0 +1,233 @@
|
|
|
+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:plugin_platform/engine/toast/toast_engine.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';
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+class GarageCard extends StatelessWidget {
|
|
|
+ Map<String, dynamic> itemObj;
|
|
|
+ double? cardHeight;
|
|
|
+ final Function()? onTap;
|
|
|
+ final Function(dynamic)? onClickColleciotn;
|
|
|
+
|
|
|
+ GarageCard({
|
|
|
+ Key? key,
|
|
|
+ required this.itemObj,
|
|
|
+ this.onTap,
|
|
|
+ this.onClickColleciotn,
|
|
|
+ double? cardHeight,
|
|
|
+ }) : super(key: key) {
|
|
|
+ this.cardHeight ??= 214;
|
|
|
+ }
|
|
|
+
|
|
|
+ @override
|
|
|
+ Widget build(BuildContext context) {
|
|
|
+ return Container(
|
|
|
+
|
|
|
+ child: Expanded(
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+
|
|
|
+ Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
+ children: [
|
|
|
+ Expanded(
|
|
|
+ child: ClipRRect(
|
|
|
+ borderRadius: const BorderRadius.only(topLeft: Radius.circular(8), topRight: Radius.circular(8),),
|
|
|
+ child: MyLoadImage(
|
|
|
+ itemObj['goods_img'],
|
|
|
+ width: 166.5,
|
|
|
+ height: 102.5,
|
|
|
+ isCircle: false,
|
|
|
+ fit: BoxFit.cover,
|
|
|
+ ).onTap(() {
|
|
|
+
|
|
|
+
|
|
|
+ }),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+
|
|
|
+ Padding(
|
|
|
+ padding: const EdgeInsets.only(left: 10, right: 10, top: 12, bottom: 12),
|
|
|
+ child: Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ children: [
|
|
|
+ Expanded(
|
|
|
+ child: MyTextView(
|
|
|
+ itemObj['title'],
|
|
|
+ maxLines: 1,
|
|
|
+ isTextEllipsis: true,
|
|
|
+ textAlign: TextAlign.left,
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
+ fontSize: 16,
|
|
|
+ isFontRegular: true,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+
|
|
|
+ Padding(
|
|
|
+ padding: const EdgeInsets.only(left: 10, right: 10,top: 10, bottom: 10),
|
|
|
+ child: 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'],
|
|
|
+ onClickColleciotn: onClickColleciotn,
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+
|
|
|
+ Expanded(
|
|
|
+ child: Padding(
|
|
|
+ padding: const EdgeInsets.only(left: 10, right: 10),
|
|
|
+ child: Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
+ children: [
|
|
|
+ MyLoadImage(
|
|
|
+ itemObj['publisher_avator'],
|
|
|
+ width: 30,
|
|
|
+ height: 30,
|
|
|
+ isCircle: true,
|
|
|
+ ),
|
|
|
+ Expanded(
|
|
|
+ child: Column(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ mainAxisSize: MainAxisSize.max,
|
|
|
+ children: [
|
|
|
+ MyTextView(
|
|
|
+ itemObj['publisher'],
|
|
|
+ maxLines: 1,
|
|
|
+ isTextEllipsis: true,
|
|
|
+ textAlign: TextAlign.start,
|
|
|
+ marginLeft: 13,
|
|
|
+ fontSize: 12,
|
|
|
+ textColor: ColorUtils.string2Color('#2956B7'),
|
|
|
+ isFontRegular: true,
|
|
|
+ ),
|
|
|
+ MyTextView(
|
|
|
+ itemObj['publish_time'],
|
|
|
+ maxLines: 1,
|
|
|
+ isTextEllipsis: true,
|
|
|
+ textAlign: TextAlign.start,
|
|
|
+ marginLeft: 13,
|
|
|
+ marginTop: 5,
|
|
|
+ fontSize: 10,
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
+ isFontRegular: true,
|
|
|
+ ),
|
|
|
+ ]
|
|
|
+ )
|
|
|
+ ),
|
|
|
+ ]
|
|
|
+ )
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+class CollectionWidget extends HookConsumerWidget {
|
|
|
+ int collectionNum = 0;
|
|
|
+ bool isCollection = false;
|
|
|
+ final Function(dynamic)? onClickColleciotn;
|
|
|
+ CollectionWidget({
|
|
|
+ Key? key,
|
|
|
+ required this.collectionNum,
|
|
|
+ required this.isCollection,
|
|
|
+ this.onClickColleciotn,
|
|
|
+ }) : super(key: key);
|
|
|
+ @override
|
|
|
+ Widget build(BuildContext context, WidgetRef ref) {
|
|
|
+ final collectionNumState = useState(collectionNum);
|
|
|
+ final isCollectionState = useState(isCollection);
|
|
|
+ return Container(
|
|
|
+ width: 60,
|
|
|
+ height: 30,
|
|
|
+ alignment: Alignment.center,
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ child: Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ children: [
|
|
|
+ MyTextView(
|
|
|
+ '${collectionNumState.value}',
|
|
|
+ textColor: ColorUtils.string2Color('#000000'),
|
|
|
+ fontSize: 14,
|
|
|
+ isFontRegular: true,
|
|
|
+ marginRight: 7,
|
|
|
+ ),
|
|
|
+ MyLoadImage(
|
|
|
+ isCollectionState.value? Assets.communityLikeActive: Assets.communityLike,
|
|
|
+ width: 15,
|
|
|
+ height: 14,
|
|
|
+ )
|
|
|
+ ]
|
|
|
+
|
|
|
+ ).onTap((){
|
|
|
+
|
|
|
+
|
|
|
+ bool result = onClickColleciotn?.call(isCollectionState.value);
|
|
|
+ if(result){
|
|
|
+ isCollectionState.value = !isCollectionState.value;
|
|
|
+ if(isCollectionState.value){
|
|
|
+ ToastEngine.show("Collect Success");
|
|
|
+ }else {
|
|
|
+ ToastEngine.show("Cancel Collect Success");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ );
|
|
|
+ }
|
|
|
+}
|