feat : information_tag_widget and use it in poultry since

This commit is contained in:
2025-09-08 14:52:32 +03:30
parent 26c2437240
commit 58bbe767fb
4 changed files with 499 additions and 485 deletions

View File

@@ -0,0 +1,232 @@
import 'package:flutter/cupertino.dart';
import 'package:rasadyar_core/core.dart';
class InformationTagData {
//label
final String? labelVecIcon;
final String? labelSvgIcon;
final String? labelTitle;
final Color? iconColor;
final Color? labelBgColor;
final Color? labelTitleColor;
final TextStyle? labelTitleStyle;
final LinearGradient? labelGradient;
final int? widthIcon;
final int? heightIcon;
//value
final String? value;
final TextStyle? valueStyle;
final Color? valueColor;
final Color? valueBgColor;
final LinearGradient? valueGradient;
final bool isLoading;
//unit
final String? unit;
final TextStyle? unitStyle;
final Color? unitColor;
//global
final int? width;
final int? height;
InformationTagData({
this.labelVecIcon,
this.labelSvgIcon,
this.labelTitle,
this.iconColor,
this.labelBgColor,
this.labelTitleColor,
this.labelTitleStyle,
this.labelGradient,
this.value,
this.valueStyle,
this.valueColor,
this.valueBgColor,
this.valueGradient,
this.isLoading = false,
this.unit,
this.unitStyle,
this.unitColor,
this.width,
this.height,
this.heightIcon,
this.widthIcon,
}) : assert(
(labelVecIcon != null) ^ (labelSvgIcon != null),
'Either labelVecIcon or labelSvgIcon must be provided, but not both.',
),
assert(isLoading || value != null, 'When isLoading is false, value must not be null.'),
assert(
(labelBgColor != null) ^ (labelGradient != null),
'Either labelBgColor or labelGradient must be provided, but not both.',
),
assert(
(valueBgColor != null) ^ (valueGradient != null),
'Either valueBgColor or valueGradient must be provided, but not both.',
);
/// copyWith method
InformationTagData copyWith({
String? labelVecIcon,
String? labelSvgIcon,
String? labelTitle,
Color? iconColor,
Color? labelBgColor,
Color? labelTitleColor,
TextStyle? labelTitleStyle,
LinearGradient? labelGradient,
int? widthIcon,
int? heightIcon,
String? value,
TextStyle? valueStyle,
Color? valueColor,
Color? valueBgColor,
LinearGradient? valueGradient,
bool? isLoading,
String? unit,
TextStyle? unitStyle,
Color? unitColor,
int? width,
int? height,
}) {
return InformationTagData(
labelVecIcon: labelVecIcon ?? this.labelVecIcon,
labelSvgIcon: labelSvgIcon ?? this.labelSvgIcon,
labelTitle: labelTitle ?? this.labelTitle,
iconColor: iconColor ?? this.iconColor,
labelBgColor: labelBgColor ?? this.labelBgColor,
labelTitleColor: labelTitleColor ?? this.labelTitleColor,
labelTitleStyle: labelTitleStyle ?? this.labelTitleStyle,
labelGradient: labelGradient ?? this.labelGradient,
widthIcon: widthIcon ?? this.widthIcon,
heightIcon: heightIcon ?? this.heightIcon,
value: value ?? this.value,
valueStyle: valueStyle ?? this.valueStyle,
valueColor: valueColor ?? this.valueColor,
valueBgColor: valueBgColor ?? this.valueBgColor,
valueGradient: valueGradient ?? this.valueGradient,
isLoading: isLoading ?? this.isLoading,
unit: unit ?? this.unit,
unitStyle: unitStyle ?? this.unitStyle,
unitColor: unitColor ?? this.unitColor,
width: width ?? this.width,
height: height ?? this.height,
);
}
}
class InformationTag extends StatelessWidget {
const InformationTag({super.key, required this.data});
final InformationTagData data;
@override
Widget build(BuildContext context) {
return Container(
height: (data.height ?? 82).h,
decoration: BoxDecoration(borderRadius: BorderRadius.circular(8)),
clipBehavior: Clip.hardEdge,
child: Row(
children: [
// Left side with icon and title
Expanded(
child: Container(
height: 82,
decoration: BoxDecoration(
color: data.labelBgColor,
borderRadius: BorderRadius.only(
topRight: Radius.circular(8),
bottomRight: Radius.circular(8),
),
gradient: data.labelGradient,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 4,
children: [
data.labelVecIcon != null
? SvgGenImage.vec(data.labelVecIcon!).svg(
width: (data.widthIcon ?? 24).w,
height: (data.heightIcon ?? 24).h,
colorFilter: ColorFilter.mode(
data.iconColor ?? AppColor.mediumGreyDarkActive,
BlendMode.srcIn,
),
)
: SvgGenImage(data.labelSvgIcon!).svg(
width: (data.widthIcon ?? 24).w,
height: (data.heightIcon ?? 24).h,
colorFilter: ColorFilter.mode(
data.iconColor ?? AppColor.mediumGreyDarkActive,
BlendMode.srcIn,
),
),
Visibility(
visible: data.labelTitle != null,
child: Text(
data.labelTitle!,
textAlign: TextAlign.right,
style:
data.labelTitleStyle ??
AppFonts.yekan10.copyWith(
color: data.labelTitleColor ?? AppColor.mediumGreyDarkActive,
),
),
),
],
),
),
),
// Right side with description and unit
Expanded(
child: Container(
decoration: BoxDecoration(
color: data.valueBgColor,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
bottomLeft: Radius.circular(8),
),
gradient: data.valueGradient,
),
child: data.isLoading
? Center(child: CupertinoActivityIndicator())
: Column(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 4,
children: [
Visibility(
visible: data.value != null,
child: Text(
data.value!,
textAlign: TextAlign.center,
style:
data.valueStyle ??
AppFonts.yekan12.copyWith(
color: data.valueColor ?? AppColor.mediumGreyDarkActive,
),
),
),
Visibility(
visible: data.unit != null,
child: Text(
data.unit ?? '',
textAlign: TextAlign.center,
style:
data.unitStyle ??
AppFonts.yekan12.copyWith(
color: data.unitColor ?? AppColor.mediumGreyDarkActive,
),
),
),
],
),
),
),
],
),
);
}
}

View File

@@ -7,6 +7,8 @@ export 'bottom_sheet/date_picker_bottom_sheet.dart';
export 'buttons/buttons.dart';
export 'card/card_icon_widget.dart';
export 'chips/r_chips.dart';
//custom
export 'custom/information_tag_widget.dart';
export 'dialog/dialog.dart';
export 'draggable_bottom_sheet/bottom_sheet_manger.dart';
export 'draggable_bottom_sheet/draggable_bottom_sheet.dart';
@@ -28,8 +30,8 @@ export 'marquee/r_marquee.dart';
export 'overlay_dropdown_widget/view.dart';
export 'pagination/pagination_from_until.dart';
export 'pagination/show_more.dart';
export 'slider/slider.dart';
export 'tabs/new_tab.dart';
export 'tabs/r_segment.dart';
export 'tabs/tab.dart';
export 'vec_widget.dart';
export 'slider/slider.dart';