feat : list view item

This commit is contained in:
2025-06-30 16:57:27 +03:30
parent e8df5721cb
commit 18570e2f0b
2 changed files with 148 additions and 47 deletions

View File

@@ -7,6 +7,7 @@ import 'package:rasadyar_chicken/data/models/response/iran_province_city/iran_pr
import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart';
import 'package:rasadyar_chicken/data/models/response/steward_free_bar/steward_free_bar.dart';
import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart';
import 'package:rasadyar_chicken/presentation/widget/list_item/list_item.dart';
import 'package:rasadyar_core/core.dart';
import 'logic.dart';
@@ -22,21 +23,26 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
onSearchChanged: (data) => controller.setSearchValue(data),
filteringWidget: filterBottomSheet(),
widgets: [
ObxValue((data) {
return RPaginatedListView(
listType: ListType.separated,
resource: data.value,
padding: EdgeInsets.fromLTRB(8, 8, 18, 80),
itemBuilder: (context, index) => saleListItem(
expandList: controller.isExpandedList,
index: index,
item: data.value.data![index],
),
itemCount: data.value.data?.length ?? 0,
separatorBuilder: (context, index) => SizedBox(height: 8.h),
onLoadMore: () async {},
);
}, controller.purchaseOutOfProvinceList),
Expanded(
child: ObxValue((data) {
return RPaginatedListView(
listType: ListType.separated,
resource: data.value,
padding: EdgeInsets.fromLTRB(8, 8, 18, 80),
itemBuilder: (context, index) => ListItem(
expandList: controller.isExpandedList,
index: index,
child: Container(height: 40, color: Colors.red),
secondChild: Container(height: 80, color: Colors.blue),
labelColor: AppColor.lightGreyNormalHover,
labelIcon: Assets.vec.truckFastSvg.path,
),
itemCount: data.value.data?.length ?? 0,
separatorBuilder: (context, index) => SizedBox(height: 8.h),
onLoadMore: () async {},
);
}, controller.purchaseOutOfProvinceList),
),
],
floatingActionButton: RFab.add(
onPressed: () {
@@ -751,36 +757,4 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
),
);
}
/*ObxValue<RxBool> _buildSearchWidget() {
return ObxValue((data) {
return AnimatedContainer(
duration: Duration(milliseconds: 300),
padding: EdgeInsets.only(top: 5),
curve: Curves.easeInOut,
height: data.value ? 50 : 0,
child: Visibility(
visible: data.value,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: RTextField(
suffixIcon: Padding(
padding: const EdgeInsets.all(12.0),
child: Assets.vec.searchSvg.svg(
width: 10,
height: 10,
colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
),
),
hintText: 'جستجو',
onChanged: (value) {
controller.searchedValue.value = value;
},
controller: TextEditingController(),
),
),
),
);
}, controller.searchIsSelected);
}*/
}

View File

@@ -0,0 +1,127 @@
import 'package:flutter/material.dart';
import 'package:rasadyar_core/core.dart';
class ListItem extends StatelessWidget {
const ListItem({
super.key,
required this.expandList,
required this.index,
required this.child,
required this.secondChild,
required this.labelColor,
required this.labelIcon,
this.labelIconColor = AppColor.mediumGreyDarkHover,
});
final RxList<int> expandList;
final int index;
final Widget child;
final Widget secondChild;
final Color labelColor;
final String labelIcon;
final Color? labelIconColor;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
/*if (expandList.contains(index)) {
controller.isExpandedList.remove(index);
} else {
controller.isExpandedList.add(index);
}*/
},
child: Container(
width: Get.width,
margin: const EdgeInsets.fromLTRB(0, 0, 10, 0),
decoration: BoxDecoration(color: labelColor, borderRadius: BorderRadius.circular(8)),
child: AnimatedSize(
duration: Duration(milliseconds: 400),
alignment: Alignment.center,
child: Stack(
clipBehavior: Clip.none,
alignment: Alignment.centerRight,
children: [
AnimatedSize(
duration: Duration(milliseconds: 300),
child: Container(
width: Get.width - 30,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.circular(8),
border: Border.all(width: 2, color: Colors.red),
),
child: Row(
children: [
Expanded(
child: AnimatedCrossFade(
alignment: Alignment.center,
firstChild: Container(
height: 75,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
bottomLeft: Radius.zero,
bottomRight: Radius.circular(8),
topLeft: Radius.zero,
topRight: Radius.circular(8),
),
),
child: child,
),
secondChild: Container(
padding: EdgeInsets.fromLTRB(8, 12, 14, 12),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
),
child: secondChild,
),
crossFadeState: expandList.contains(index)
? CrossFadeState.showSecond
: CrossFadeState.showFirst,
duration: Duration(milliseconds: 300),
),
),
Container(
width: 20,
child: Center(
child: SvgGenImage.vec(labelIcon).svg(
width: 16.w,
height: 16.h,
colorFilter: ColorFilter.mode(labelColor, BlendMode.srcIn),
),
),
),
],
),
),
),
Positioned(
right: -12,
child: Container(
width: index < 999 ? 24 : null,
height: index < 999 ? 24 : null,
padding: EdgeInsets.all(2),
decoration: BoxDecoration(
color: AppColor.greenLightHover,
borderRadius: BorderRadius.circular(4),
border: Border.all(width: 0.50, color: AppColor.greenDarkActive),
),
alignment: Alignment.center,
child: Text(
(index + 1).toString(),
style: AppFonts.yekan12.copyWith(color: Colors.black),
),
),
),
],
),
),
),
);
}
}