refactor : rename files and update routes for poultry actions
feat : poultry kill registration and poultry OrderList ** Made With Nima **
This commit is contained in:
@@ -3,13 +3,13 @@ import 'package:flutter/material.dart';
|
||||
import '../../../core.dart';
|
||||
|
||||
GestureDetector dateFilterWidget({
|
||||
isFrom = true,
|
||||
bool isFrom = true,
|
||||
required Rx<Jalali> date,
|
||||
required Function(Jalali jalali) onChanged,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
Get.bottomSheet(modalDatePicker((value) => onChanged(value)));
|
||||
Get.bottomSheet(modalDatePicker(onDateSelected: (value) => onChanged(value)));
|
||||
},
|
||||
child: Container(
|
||||
height: 35,
|
||||
@@ -42,8 +42,8 @@ GestureDetector dateFilterWidget({
|
||||
);
|
||||
}
|
||||
|
||||
Container modalDatePicker(ValueChanged<Jalali> onDateSelected) {
|
||||
Jalali? tempPickedDate;
|
||||
Container modalDatePicker({required ValueChanged<Jalali> onDateSelected,Jalali? initialDate,}) {
|
||||
Jalali? datePicked;
|
||||
return Container(
|
||||
height: 250,
|
||||
color: Colors.white,
|
||||
@@ -58,7 +58,7 @@ Container modalDatePicker(ValueChanged<Jalali> onDateSelected) {
|
||||
width: 70,
|
||||
textStyle: AppFonts.yekan14.copyWith(color: Colors.white),
|
||||
onPressed: () {
|
||||
onDateSelected(tempPickedDate ?? Jalali.now());
|
||||
onDateSelected(initialDate ?? Jalali.now());
|
||||
Get.back();
|
||||
},
|
||||
text: 'تایید',
|
||||
@@ -70,7 +70,7 @@ Container modalDatePicker(ValueChanged<Jalali> onDateSelected) {
|
||||
backgroundColor: AppColor.error,
|
||||
textStyle: AppFonts.yekan14.copyWith(color: Colors.white),
|
||||
onPressed: () {
|
||||
onDateSelected(tempPickedDate ?? Jalali.now());
|
||||
onDateSelected(initialDate ?? Jalali.now());
|
||||
Get.back();
|
||||
},
|
||||
text: 'لغو',
|
||||
@@ -81,10 +81,10 @@ Container modalDatePicker(ValueChanged<Jalali> onDateSelected) {
|
||||
Divider(height: 0, thickness: 1),
|
||||
Expanded(
|
||||
child: PersianCupertinoDatePicker(
|
||||
initialDateTime: Jalali.now(),
|
||||
initialDateTime: initialDate ??Jalali.now(),
|
||||
mode: PersianCupertinoDatePickerMode.date,
|
||||
onDateTimeChanged: (dateTime) {
|
||||
tempPickedDate = dateTime;
|
||||
datePicked = dateTime;
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
@@ -108,3 +108,65 @@ class RFilterChips extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CheckBoxChips<T> extends StatelessWidget {
|
||||
const CheckBoxChips({
|
||||
super.key,
|
||||
this.isSelected = false,
|
||||
required this.title,
|
||||
required this.data,
|
||||
required this.onTap,
|
||||
this.selectedColor = AppColor.blueNormal,
|
||||
this.unSelectedColor = AppColor.textColor,
|
||||
});
|
||||
|
||||
final bool isSelected;
|
||||
final String title;
|
||||
final T data;
|
||||
final Function(T) onTap;
|
||||
final Color selectedColor;
|
||||
final Color unSelectedColor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
onTap.call(data);
|
||||
},
|
||||
child: Container(
|
||||
height: 32.h,
|
||||
padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 6.h),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: isSelected ? selectedColor : unSelectedColor, width: 1),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 12.w,
|
||||
height: 12.h,
|
||||
child: Checkbox(
|
||||
value: isSelected,
|
||||
onChanged: (value) {
|
||||
onTap.call(data);
|
||||
},
|
||||
visualDensity: VisualDensity.compact,
|
||||
activeColor: selectedColor,
|
||||
checkColor: Colors.white,
|
||||
side: BorderSide(color: isSelected ? selectedColor : unSelectedColor, width: 1),
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 12.w),
|
||||
Text(
|
||||
title,
|
||||
style: isSelected
|
||||
? AppFonts.yekan12Bold.copyWith(color: AppColor.blueNormal)
|
||||
: AppFonts.yekan12.copyWith(color: unSelectedColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,8 @@ Widget buildRowOnTapped({
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 2,
|
||||
child: titleWidget ??
|
||||
child:
|
||||
titleWidget ??
|
||||
Text(
|
||||
title ?? 'N/A',
|
||||
textAlign: TextAlign.right,
|
||||
@@ -60,7 +61,8 @@ Widget buildRowOnTapped({
|
||||
flex: 2,
|
||||
child: GestureDetector(
|
||||
onTap: onTap,
|
||||
child: valueWidget ??
|
||||
child:
|
||||
valueWidget ??
|
||||
Text(
|
||||
value ?? 'N/A',
|
||||
textAlign: TextAlign.left,
|
||||
@@ -72,3 +74,51 @@ Widget buildRowOnTapped({
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildUnitRow({
|
||||
required String title,
|
||||
String? value,
|
||||
required String unit,
|
||||
TextStyle? titleStyle,
|
||||
TextStyle? valueStyle,
|
||||
TextStyle? unitStyle,
|
||||
}) {
|
||||
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: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
spacing: 5,
|
||||
children: [
|
||||
Text(
|
||||
value == null || value.isEmpty ? '-' : value,
|
||||
textAlign: TextAlign.left,
|
||||
style: valueStyle ?? AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover),
|
||||
),
|
||||
Visibility(
|
||||
visible: value != null ||( value?.isNotEmpty ?? false),
|
||||
child: Text(
|
||||
unit,
|
||||
textAlign: TextAlign.left,
|
||||
style: valueStyle ?? AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class ResourceOverlayDropdown<T> extends StatefulWidget {
|
||||
final Resource<List<T>> items;
|
||||
final T? selectedItem;
|
||||
final T? initialValue;
|
||||
final int? height;
|
||||
final Color? background;
|
||||
final bool? hasDropIcon;
|
||||
final Widget Function(T item) itemBuilder;
|
||||
final Widget Function(T? selected) labelBuilder;
|
||||
final void Function(T selected)? onChanged;
|
||||
final EdgeInsets? contentPadding;
|
||||
final bool isDisabled;
|
||||
|
||||
const ResourceOverlayDropdown({
|
||||
super.key,
|
||||
required this.items,
|
||||
required this.itemBuilder,
|
||||
required this.labelBuilder,
|
||||
this.initialValue,
|
||||
this.onChanged,
|
||||
this.selectedItem,
|
||||
this.contentPadding,
|
||||
this.height,
|
||||
this.background,
|
||||
this.hasDropIcon = true,
|
||||
this.isDisabled = false,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ResourceOverlayDropdown<T>> createState() => _ResourceOverlayDropdownState<T>();
|
||||
}
|
||||
|
||||
class _ResourceOverlayDropdownState<T> extends State<ResourceOverlayDropdown<T>> {
|
||||
final GlobalKey _key = GlobalKey();
|
||||
OverlayEntry? _overlayEntry;
|
||||
bool _isOpen = false;
|
||||
T? selectedItem;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
selectedItem = widget.selectedItem ?? widget.initialValue;
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant ResourceOverlayDropdown<T> oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (widget.selectedItem != oldWidget.selectedItem) {
|
||||
setState(() {
|
||||
selectedItem = widget.selectedItem;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void _showOverlay() {
|
||||
if (_overlayEntry != null) return;
|
||||
|
||||
final renderBox = _key.currentContext!.findRenderObject() as RenderBox;
|
||||
final size = renderBox.size;
|
||||
final offset = renderBox.localToGlobal(Offset.zero);
|
||||
|
||||
_overlayEntry = OverlayEntry(
|
||||
builder: (_) => GestureDetector(
|
||||
onTap: _removeOverlay,
|
||||
behavior: HitTestBehavior.translucent,
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned(
|
||||
left: offset.dx,
|
||||
top: offset.dy + size.height + 4,
|
||||
width: size.width,
|
||||
child: Material(
|
||||
elevation: 4,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: widget.background ?? AppColor.bgLight,
|
||||
border: Border.all(color: AppColor.darkGreyLight),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
constraints: const BoxConstraints(maxHeight: 300),
|
||||
child: ListView(
|
||||
padding: EdgeInsets.zero,
|
||||
shrinkWrap: true,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
children:
|
||||
widget.items.data?.map((item) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
widget.onChanged?.call(item);
|
||||
setState(() {
|
||||
selectedItem = item;
|
||||
});
|
||||
_removeOverlay();
|
||||
},
|
||||
child: Padding(
|
||||
padding:
|
||||
widget.contentPadding ??
|
||||
const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
child: widget.itemBuilder(item),
|
||||
),
|
||||
);
|
||||
}).toList() ??
|
||||
[],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Overlay.of(context).insert(_overlayEntry!);
|
||||
setState(() => _isOpen = true);
|
||||
}
|
||||
|
||||
void _removeOverlay({bool fromDispose = false}) {
|
||||
_overlayEntry?.remove();
|
||||
_overlayEntry = null;
|
||||
if (!fromDispose && mounted) {
|
||||
setState(() => _isOpen = false);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_removeOverlay(fromDispose: true);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
return GestureDetector(
|
||||
key: _key,
|
||||
onTap: (widget.isDisabled || widget.items.status == ResourceStatus.loading)
|
||||
? null
|
||||
: () {
|
||||
_isOpen ? _removeOverlay() : _showOverlay();
|
||||
},
|
||||
child: Container(
|
||||
height: widget.height?.toDouble() ?? 40,
|
||||
width: constraints.maxWidth,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: widget.background ?? AppColor.bgLight,
|
||||
border: Border.all(color: AppColor.darkGreyLight),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: _buildWidget(widget.items),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget? _buildWidget(Resource<List<T>> items) {
|
||||
switch (items.status) {
|
||||
case ResourceStatus.initial:
|
||||
case ResourceStatus.loading:
|
||||
return CupertinoActivityIndicator();
|
||||
case ResourceStatus.success:
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(child: widget.labelBuilder(selectedItem)),
|
||||
if (widget.hasDropIcon ?? true)
|
||||
Icon(_isOpen ? CupertinoIcons.chevron_up : CupertinoIcons.chevron_down, size: 14),
|
||||
],
|
||||
);
|
||||
case ResourceStatus.error:
|
||||
return Text('Error', style: AppFonts.yekan12.copyWith(color: AppColor.redNormal));
|
||||
|
||||
case ResourceStatus.empty:
|
||||
return Text('بدون نتیجه', style: AppFonts.yekan12.copyWith(color: AppColor.textColor));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,8 @@ export 'loading_widget.dart';
|
||||
// other
|
||||
export 'logo_widget.dart';
|
||||
export 'marquee/r_marquee.dart';
|
||||
export 'overlay_dropdown_widget/view.dart';
|
||||
export 'overlay_dropdown_widget/overlay_dropdown.dart';
|
||||
export 'overlay_dropdown_widget/resource_overlay_dropdown.dart';
|
||||
export 'pagination/pagination_from_until.dart';
|
||||
export 'pagination/show_more.dart';
|
||||
export 'slider/slider.dart';
|
||||
|
||||
Reference in New Issue
Block a user