feat : list view item in out of the province

This commit is contained in:
2025-07-01 15:43:47 +03:30
parent 3d6d3d7b08
commit 666f6326e5
21 changed files with 15522 additions and 458 deletions

View File

@@ -5,9 +5,9 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:rasadyar_chicken/data/models/response/iran_province_city/iran_province_city_model.dart';
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_chicken/presentation/widget/list_row_item.dart';
import 'package:rasadyar_core/core.dart';
import 'logic.dart';
@@ -28,15 +28,247 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
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,
),
padding: EdgeInsets.fromLTRB(8, 8, 8, 80),
itemBuilder: (context, index) {
var item = data.value.data![index];
return ObxValue((val) {
return ListItem2(
selected: val.contains(index),
onTap: () => controller.isExpandedList.toggle(index),
index: index,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SizedBox(width: 20),
Expanded(
flex: 2,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 3,
children: [
Text(
item.killHouseName ?? 'N/A',
textAlign: TextAlign.start,
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
),
Text(
item.date?.formattedJalaliDate ?? 'N/A',
textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(color: AppColor.bgDark),
),
],
),
),
Expanded(
flex: 3,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
spacing: 3,
children: [
Visibility(
visible: item.product?.name?.contains('مرغ گرم') ?? false,
child: Assets.vec.hotChickenSvg.svg(
width: 24,
height: 24,
colorFilter: ColorFilter.mode(
AppColor.blueNormal,
BlendMode.srcIn,
),
),
),
Text(
'${item.weightOfCarcasses?.separatedByComma}kg',
textAlign: TextAlign.left,
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
),
],
),
SizedBox(height: 2),
Text(
'${item.province}',
textAlign: TextAlign.center,
style: AppFonts.yekan12.copyWith(color: AppColor.bgDark),
),
],
),
),
Expanded(
flex: 1,
child: Assets.vec.scanSvg.svg(
width: 32.w,
height: 32.h,
colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
),
),
],
),
secondChild: Container(
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
),
child: Column(
spacing: 8,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
'${item.province}-${item.city}',
textAlign: TextAlign.center,
style: AppFonts.yekan16.copyWith(color: AppColor.greenDark),
),
],
),
Container(
height: 32,
padding: EdgeInsets.symmetric(horizontal: 4),
decoration: ShapeDecoration(
color: AppColor.blueLight,
shape: RoundedRectangleBorder(
side: BorderSide(width: 1, color: AppColor.blueLightHover),
borderRadius: BorderRadius.circular(8),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
spacing: 3,
children: [
Text(
item.date?.toJalali.formatter.wN ?? 'N/A',
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
),
Text(
'${item.date?.toJalali.formatter.d} ${item.date?.toJalali.formatter.mN ?? 'N/A'}',
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
),
],
),
Text(
'${item.date?.toJalali.formatter.y}',
style: AppFonts.yekan20.copyWith(color: AppColor.textColor),
),
Text(
'${item.date?.toJalali.formatter.tHH}:${item.date?.toJalali.formatter.tMM ?? 'N/A'}',
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
),
],
),
),
buildRow(title: 'مشخصات فروشنده', value: item.killHouseName ?? 'N/A'),
buildRow(
title: 'تلفن فروشنده',
value: item.killHouseMobile ?? 'N/A',
valueStyle: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
),
buildRow(title: 'محصول', value: item.product?.name ?? 'N/A'),
buildRow(
title: 'وزن خریداری شده',
value: '${item.weightOfCarcasses?.separatedByComma} کیلوگرم',
),
buildRowOnTapped(
title: 'مشاهده بارنامه',
titleStyle: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
valueWidget: Assets.vec.clipboardEyeSvg.svg(
width: 20,
height: 24,
colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
),
onTap: () {
Get.bottomSheet(
BaseBottomSheet(
height: 400,
child: Column(
spacing: 16,
children: [
Text(
'بارنامه',
style: AppFonts.yekan16Bold.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
Image.network(
item.barImage ?? '',
fit: BoxFit.cover,
height: 300,
errorBuilder: (context, error, stackTrace) {
eLog(error.toString());
return Center(child: Text('خطایی پیش آمده!'));
},
loadingBuilder: (context, child, loadingProgress) {
if (loadingProgress == null) return child;
print('Loading progress: $loadingProgress');
return CupertinoActivityIndicator();
},
),
],
),
),
);
},
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 16.w,
children: [
RElevated(
text: 'ویرایش',
width: 150.w,
height: 40.h,
onPressed: () {
controller.setEditData(item);
Get.bottomSheet(
addPurchasedInformationBottomSheet(true),
isScrollControlled: true,
).whenComplete(() {
controller.resetSubmitForm();
});
},
textStyle: AppFonts.yekan20.copyWith(color: Colors.white),
backgroundColor: AppColor.greenNormal,
),
ROutlinedElevated(
text: 'حذف',
textStyle: AppFonts.yekan20.copyWith(color: AppColor.redNormal),
width: 150.w,
height: 40.h,
onPressed: () {
buildDeleteDialog(
onConfirm: () =>
controller.deleteStewardPurchaseOutOfProvince(item.key!),
);
},
borderColor: AppColor.redNormal,
),
],
),
],
),
),
labelColor: AppColor.blueLight,
labelIcon: Assets.vec.truckFastOutlinedSvg.path,
);
}, controller.isExpandedList);
},
itemCount: data.value.data?.length ?? 0,
separatorBuilder: (context, index) => SizedBox(height: 8.h),
onLoadMore: () async {},
@@ -53,325 +285,6 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
);
}
Widget saleListWidget() {
return ObxValue((data) {
switch (data.value.status) {
case Status.initial:
case Status.loading:
return Center(child: CupertinoActivityIndicator());
case Status.success:
return ListView.separated(
shrinkWrap: true,
physics: BouncingScrollPhysics(),
padding: EdgeInsets.fromLTRB(8, 8, 18, 80),
itemBuilder: (context, index) {
return ObxValue(
(expandList) => saleListItem(
expandList: expandList,
index: index,
item: data.value.data![index],
),
controller.isExpandedList,
);
},
separatorBuilder: (context, index) => SizedBox(height: 8),
itemCount: data.value.data?.length ?? 0,
);
case Status.error:
return Center(
child: Text(
data.value.message ?? 'خطا در دریافت اطلاعات',
style: AppFonts.yekan16.copyWith(color: AppColor.error),
),
);
case Status.empty:
return emptyWidget();
}
}, controller.purchaseOutOfProvinceList);
}
Widget emptyWidget() {
return Center(
child: Text(
'داده ای دریافت نشد!',
style: AppFonts.yekan16.copyWith(color: AppColor.darkGreyDarkHover),
),
);
}
GestureDetector saleListItem({
required RxList<int> expandList,
required int index,
required StewardFreeBar item,
}) {
return GestureDetector(
onTap: () {
if (expandList.contains(index)) {
controller.isExpandedList.remove(index);
} else {
controller.isExpandedList.add(index);
}
},
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: 0.5, color: AppColor.darkGreyNormal),
),
child: AnimatedCrossFade(
alignment: Alignment.center,
firstChild: Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SizedBox(width: 12),
Expanded(
flex: 2,
child: Text(
item.date?.formattedJalaliDate ?? 'N/A',
textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(color: AppColor.bgDark),
),
),
Expanded(
flex: 3,
child: Text(
item.killHouseName ?? 'N/A',
textAlign: TextAlign.center,
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
),
),
SizedBox(width: 8),
Expanded(
flex: 2,
child: Column(
children: [
Text(
'${item.weightOfCarcasses?.separatedByComma}kg',
textAlign: TextAlign.left,
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
),
SizedBox(height: 2),
Visibility(
visible: item.product?.name?.contains('مرغ گرم') ?? false,
child: Assets.vec.hotChickenSvg.svg(
width: 24,
height: 24,
colorFilter: ColorFilter.mode(
AppColor.blueNormal,
BlendMode.srcIn,
),
),
),
],
),
),
Expanded(
flex: 2,
child: Text(
'${item.province}\n${item.city}',
textAlign: TextAlign.center,
style: AppFonts.yekan12.copyWith(color: AppColor.bgDark),
),
),
Icon(CupertinoIcons.chevron_down, size: 12),
SizedBox(width: 8),
],
),
),
secondChild: Container(
padding: EdgeInsets.fromLTRB(8, 12, 14, 12),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
),
child: Column(
spacing: 8,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
onTap: () {
controller.setEditData(item);
Get.bottomSheet(
addPurchasedInformationBottomSheet(true),
isScrollControlled: true,
).whenComplete(() {
controller.resetSubmitForm();
});
},
child: Assets.vec.editSvg.svg(
width: 20,
height: 20,
colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
),
),
Text(
'${item.province}-${item.city}',
textAlign: TextAlign.center,
style: AppFonts.yekan16.copyWith(color: AppColor.greenDark),
),
GestureDetector(
onTap: () {
buildDeleteDialog(
onConfirm: () =>
controller.deleteStewardPurchaseOutOfProvince(item.key!),
);
},
child: Assets.vec.trashSvg.svg(
width: 20,
height: 20,
colorFilter: ColorFilter.mode(AppColor.error, BlendMode.srcIn),
),
),
],
),
Container(
height: 32,
padding: EdgeInsets.symmetric(horizontal: 4),
decoration: ShapeDecoration(
color: AppColor.blueLight,
shape: RoundedRectangleBorder(
side: BorderSide(width: 1, color: AppColor.blueLightHover),
borderRadius: BorderRadius.circular(8),
),
),
child: buildRow('تاریخ', item.date?.formattedJalaliDateYHMS ?? 'N/A'),
),
buildRow(
'مشخصات فروشنده',
'${item.killHouseName} - ${item.killHouseMobile ?? 'N/A'}',
),
buildRow('محصول', item.product?.name ?? 'N/A'),
buildRow(
'وزن خریداری شده',
'${item.weightOfCarcasses?.separatedByComma} کیلوگرم',
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
onTap: () {
Get.bottomSheet(
BaseBottomSheet(
height: 400,
child: Column(
spacing: 16,
children: [
Text(
'بارنامه',
style: AppFonts.yekan16Bold.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
Image.network(
item.barImage ?? '',
fit: BoxFit.cover,
height: 300,
errorBuilder: (context, error, stackTrace) {
eLog(error.toString());
return Center(child: Text('خطایی پیش آمده!'));
},
loadingBuilder: (context, child, loadingProgress) {
if (loadingProgress == null) return child;
print('Loading progress: $loadingProgress');
return CupertinoActivityIndicator();
},
),
],
),
),
);
},
child: Text(
'مشاهده بارنامه',
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
),
),
Icon(CupertinoIcons.chevron_up, size: 12),
],
),
],
),
),
crossFadeState: expandList.contains(index)
? CrossFadeState.showSecond
: CrossFadeState.showFirst,
duration: Duration(milliseconds: 300),
),
),
),
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),
),
),
),
],
),
),
);
}
Widget buildRow(String title, String value) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
flex: 2,
child: Text(
title,
textAlign: TextAlign.right,
style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover),
),
),
Flexible(
flex: 2,
child: Text(
value,
textAlign: TextAlign.left,
style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover),
),
),
],
),
);
}
Widget addPurchasedInformationBottomSheet([bool isOnEdit = false]) {
return BaseBottomSheet(
child: SingleChildScrollView(
@@ -389,6 +302,8 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
controller: controller.sellerNameController,
label: 'نام فروشنده',
borderColor: AppColor.darkGreyLight,
filled: true,
filledColor: AppColor.bgLight,
),
RTextField(
controller: controller.sellerPhoneController,
@@ -396,6 +311,8 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
keyboardType: TextInputType.phone,
borderColor: AppColor.darkGreyLight,
maxLength: 11,
filled: true,
filledColor: AppColor.bgLight,
validator: (value) {
if (value == null || value.isEmpty) {
return 'لطفاً شماره موبایل را وارد کنید';
@@ -415,7 +332,13 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
_cityWidget(),
RTextField(
controller: controller.carcassWeightController,
label: 'وزن لاشه',
label: 'وزن',
filled: true,
suffixIcon: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Assets.vec.killogramSvg.svg(),
),
filledColor: AppColor.bgLight,
keyboardType: TextInputType.number,
borderColor: AppColor.darkGreyLight,
inputFormatters: [
@@ -437,6 +360,8 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
return ObxValue((data) {
return RElevated(
text: isOnEdit ? 'ویرایش' : 'ثبت خرید',
width: Get.width,
backgroundColor: AppColor.greenNormal,
onPressed: data.value
? () async {
var res = await controller.createStewardPurchaseOutOfProvince();
@@ -459,8 +384,16 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
},
selectedItem: controller.selectedProduct.value,
initialValue: controller.selectedProduct.value,
itemBuilder: (item) => Text(item.name ?? 'بدون نام'),
labelBuilder: (item) => Text(item?.name ?? 'انتخاب محصول'),
itemBuilder: (item) => Text(
item.name ?? 'بدون نام',
style: AppFonts.yekan14.copyWith(color: AppColor.lightGreyDarker),
),
labelBuilder: (item) => item?.name != null
? Text(item!.name!, style: AppFonts.yekan14.copyWith(color: AppColor.textColor))
: Text(
'انتخاب محصول',
style: AppFonts.yekan14.copyWith(color: AppColor.textColorLight),
),
);
});
}
@@ -474,8 +407,16 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
print('Selected Product: ${value.name}');
},
selectedItem: controller.selectedProvince.value,
itemBuilder: (item) => Text(item.name ?? 'بدون نام'),
labelBuilder: (item) => Text(item?.name ?? 'انتخاب استان'),
itemBuilder: (item) => Text(
item.name ?? 'بدون نام',
style: AppFonts.yekan14.copyWith(color: AppColor.lightGreyDarker),
),
labelBuilder: (item) => item?.name != null
? Text(item!.name!, style: AppFonts.yekan14.copyWith(color: AppColor.textColor))
: Text(
'انتخاب استان',
style: AppFonts.yekan14.copyWith(color: AppColor.textColorLight),
),
);
});
}
@@ -486,11 +427,15 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
items: data,
onChanged: (value) {
controller.selectedCity.value = value;
print('Selected Product: ${value.name}');
},
selectedItem: controller.selectedCity.value,
itemBuilder: (item) => Text(item.name ?? 'بدون نام'),
labelBuilder: (item) => Text(item?.name ?? 'انتخاب شهر'),
itemBuilder: (item) => Text(
item.name ?? 'بدون نام',
style: AppFonts.yekan14.copyWith(color: AppColor.lightGreyDarker),
),
labelBuilder: (item) => item?.name != null
? Text(item!.name!, style: AppFonts.yekan14.copyWith(color: AppColor.textColor))
: Text('انتخاب شهر', style: AppFonts.yekan14.copyWith(color: AppColor.textColorLight)),
);
}, controller.cites);
}
@@ -498,96 +443,73 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
SizedBox _imageCarcasesWidget(bool isOnEdit) {
return SizedBox(
width: Get.width,
height: 250,
height: 370,
child: Card(
color: Colors.white,
child: Padding(
padding: const EdgeInsets.all(16.0),
padding: const EdgeInsets.all(4.0),
child: Column(
spacing: 8,
children: [
Text('بارنامه', style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal)),
Expanded(
child: ObxValue((data) {
return Container(
width: Get.width,
height: 270,
decoration: BoxDecoration(
color: AppColor.lightGreyNormal,
borderRadius: BorderRadius.circular(8),
border: Border.all(width: 1, color: AppColor.blackLight),
),
child: Center(
child: isOnEdit
? Image.network(controller.editImageUrl.value ?? '')
: data.value == null
? Assets.images.placeHolder.image(height: 150, width: 200)
? Padding(
padding: const EdgeInsets.fromLTRB(30, 10, 10, 30),
child: Assets.vec.placeHolderSvg.svg(width: 200.w, height: 150.h),
)
: Image.file(File(data.value!.path), fit: BoxFit.cover),
),
);
}, controller.selectedImage),
),
SizedBox(height: 15),
Container(
width: Get.width,
height: 40,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'تصویر بار',
style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal),
),
Spacer(),
GestureDetector(
onTap: () async {
controller.selectedImage.value = await controller.imagePicker.pickImage(
source: ImageSource.camera,
imageQuality: 60,
maxWidth: 1080,
maxHeight: 720,
);
},
child: Container(
decoration: ShapeDecoration(
color: AppColor.blueNormal,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
),
padding: EdgeInsetsGeometry.symmetric(horizontal: 6, vertical: 4),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text('دوربین', style: AppFonts.yekan14.copyWith(color: Colors.white)),
SizedBox(width: 8),
Icon(CupertinoIcons.camera, color: Colors.white),
],
),
),
),
SizedBox(width: 16),
GestureDetector(
onTap: () async {
controller.selectedImage.value = await controller.imagePicker.pickImage(
source: ImageSource.gallery,
imageQuality: 60,
maxWidth: 1080,
maxHeight: 720,
);
},
child: Container(
decoration: ShapeDecoration(
color: AppColor.blueNormal,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
),
padding: EdgeInsetsGeometry.symmetric(horizontal: 6, vertical: 4),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text('گالری', style: AppFonts.yekan14.copyWith(color: Colors.white)),
SizedBox(width: 8),
Icon(CupertinoIcons.photo, color: Colors.white),
],
),
),
),
],
),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
RElevated(
text: 'گالری',
width: 150.w,
height: 40.h,
textStyle: AppFonts.yekan20.copyWith(color: Colors.white),
onPressed: () async {
controller.selectedImage.value = await controller.imagePicker.pickImage(
source: ImageSource.gallery,
imageQuality: 60,
maxWidth: 1080,
maxHeight: 720,
);
},
),
SizedBox(width: 16),
ROutlinedElevated(
text: 'دوربین',
width: 150.w,
height: 40.h,
textStyle: AppFonts.yekan20.copyWith(color: AppColor.blueNormal),
onPressed: () async {
controller.selectedImage.value = await controller.imagePicker.pickImage(
source: ImageSource.camera,
imageQuality: 60,
maxWidth: 1080,
maxHeight: 720,
);
},
),
],
),
],
),

View File

@@ -4,33 +4,29 @@ 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,
required this.onTap,
required this.selected,
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;
final VoidCallback onTap;
final bool selected;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
/*if (expandList.contains(index)) {
controller.isExpandedList.remove(index);
} else {
controller.isExpandedList.add(index);
}*/
},
onTap: onTap,
child: Container(
width: Get.width,
margin: const EdgeInsets.fromLTRB(0, 0, 10, 0),
@@ -83,7 +79,7 @@ class ListItem extends StatelessWidget {
),
child: secondChild,
),
crossFadeState: expandList.contains(index)
crossFadeState: selected
? CrossFadeState.showSecond
: CrossFadeState.showFirst,
duration: Duration(milliseconds: 300),
@@ -129,3 +125,115 @@ class ListItem extends StatelessWidget {
);
}
}
class ListItem2 extends StatelessWidget {
const ListItem2({
super.key,
required this.index,
required this.child,
required this.secondChild,
required this.labelColor,
required this.labelIcon,
required this.onTap,
required this.selected,
this.labelIconColor = AppColor.mediumGreyDarkHover,
});
final int index;
final Widget child;
final Widget secondChild;
final Color labelColor;
final String labelIcon;
final Color? labelIconColor;
final VoidCallback onTap;
final bool selected;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: Container(
width: Get.width,
margin: const EdgeInsets.fromLTRB(0, 0, 10, 0),
decoration: BoxDecoration(
color: labelColor,
borderRadius: BorderRadius.circular(8),
border: Border.all(width: 1, color: AppColor.lightGreyNormalHover),
),
child: AnimatedSize(
duration: Duration(milliseconds: 400),
alignment: Alignment.center,
child: Stack(
clipBehavior: Clip.none,
alignment: Alignment.centerRight,
children: [
AnimatedCrossFade(
firstChild: Row(
children: [
Expanded(
child: 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),
),
),
clipBehavior: Clip.antiAlias,
child: child,
),
),
Container(
width: 20,
child: Center(
child: SvgGenImage.vec(labelIcon).svg(
width: 16.w,
height: 16.h,
//TODO
colorFilter: ColorFilter.mode(labelIconColor ?? AppColor.mediumGreyDarkActive, BlendMode.srcIn),
),
),
),
],
),
secondChild: Container(
padding: EdgeInsets.fromLTRB(8, 8, 12, 12),
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
),
child: secondChild,
),
crossFadeState: selected ? CrossFadeState.showSecond : CrossFadeState.showFirst,
duration: Duration(milliseconds: 300),
),
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),
),
),
),
],
),
),
),
);
}
}

View File

@@ -0,0 +1,76 @@
import 'package:flutter/material.dart';
import 'package:rasadyar_core/core.dart';
Widget buildRow({
required String title,
required String value,
TextStyle? titleStyle,
TextStyle? valueStyle,
}) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
flex: 2,
child: Text(
title,
textAlign: TextAlign.right,
style: titleStyle ?? AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover),
),
),
Flexible(
flex: 2,
child: Text(
value,
textAlign: TextAlign.left,
style: valueStyle ?? AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover),
),
),
],
),
);
}
Widget buildRowOnTapped({
String? title,
String? value,
Widget? titleWidget,
Widget? valueWidget,
TextStyle? titleStyle,
TextStyle? valueStyle,
required VoidCallback onTap,
}) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
flex: 2,
child:
titleWidget ??
Text(
title ?? 'N/A',
textAlign: TextAlign.right,
style: titleStyle ?? AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover),
),
),
GestureDetector(
onTap: onTap,
child: Flexible(
flex: 2,
child:
valueWidget ??
Text(
value ?? 'N/A',
textAlign: TextAlign.left,
style: valueStyle ?? AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover),
),
),
),
],
),
);
}