2025-09-08 14:52:32 +03:30
|
|
|
|
import 'package:flutter/material.dart';
|
2025-12-17 10:26:39 +03:30
|
|
|
|
=
|
|
|
|
|
|
import 'package:rasadyar_chicken/features/poultry_science/data/model/response/home_poultry_science/home_poultry_science_model.dart';
|
|
|
|
|
|
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/root/logic.dart';
|
2025-09-06 17:22:19 +03:30
|
|
|
|
import 'package:rasadyar_core/core.dart';
|
2025-09-09 11:38:20 +03:30
|
|
|
|
import 'package:rasadyar_core/presentation/widget/custom/information_card_widget.dart';
|
2025-09-06 17:22:19 +03:30
|
|
|
|
|
|
|
|
|
|
class PoultryScienceHomeLogic extends GetxController {
|
|
|
|
|
|
PoultryScienceRootLogic rootLogic = Get.find<PoultryScienceRootLogic>();
|
|
|
|
|
|
Rxn<HomePoultryScienceModel> homeInformation = Rxn();
|
|
|
|
|
|
RxBool isExpanded = false.obs;
|
2025-09-08 14:52:32 +03:30
|
|
|
|
RxMap<String, List<InformationTagData>> tagInfo = RxMap({
|
|
|
|
|
|
'first': [
|
|
|
|
|
|
InformationTagData(
|
|
|
|
|
|
labelTitle: 'کل فارم ها',
|
|
|
|
|
|
isLoading: true,
|
2025-09-09 13:29:27 +03:30
|
|
|
|
labelVecIcon: Assets.vec.cubeScanSvg.path,
|
2025-09-20 12:25:10 +03:30
|
|
|
|
iconColor: AppColor.blueFlashing,
|
|
|
|
|
|
blendMode: BlendMode.srcOut,
|
2025-09-08 14:52:32 +03:30
|
|
|
|
valueBgColor: Colors.white,
|
|
|
|
|
|
labelGradient: LinearGradient(
|
|
|
|
|
|
begin: Alignment.topCenter,
|
|
|
|
|
|
end: Alignment.bottomCenter,
|
|
|
|
|
|
colors: [AppColor.blueLight, Colors.white],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
InformationTagData(
|
|
|
|
|
|
labelTitle: 'تعداد جوجه ریزی',
|
|
|
|
|
|
isLoading: true,
|
|
|
|
|
|
labelVecIcon: Assets.vec.cubeCardSvg.path,
|
2025-09-09 13:29:27 +03:30
|
|
|
|
blendMode: BlendMode.dst,
|
2025-09-08 14:52:32 +03:30
|
|
|
|
valueBgColor: Colors.white,
|
|
|
|
|
|
labelGradient: LinearGradient(
|
|
|
|
|
|
begin: Alignment.topCenter,
|
|
|
|
|
|
end: Alignment.bottomCenter,
|
|
|
|
|
|
colors: [AppColor.greenLightHover, Colors.white],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
'second': [
|
|
|
|
|
|
InformationTagData(
|
|
|
|
|
|
labelTitle: 'حجم جوجه ریزی',
|
|
|
|
|
|
unit: 'قطعه',
|
|
|
|
|
|
isLoading: true,
|
|
|
|
|
|
labelVecIcon: Assets.vec.hashtagSvg.path,
|
2025-09-09 13:29:27 +03:30
|
|
|
|
iconColor: const Color(0xFF6C5D60),
|
|
|
|
|
|
labelBgColor: const Color(0xFFDDC0C7),
|
|
|
|
|
|
valueBgColor: const Color(0xFFEDDCE0),
|
2025-09-08 14:52:32 +03:30
|
|
|
|
),
|
|
|
|
|
|
InformationTagData(
|
|
|
|
|
|
labelTitle: 'مانده در سالن',
|
|
|
|
|
|
unit: 'قطعه',
|
|
|
|
|
|
isLoading: true,
|
|
|
|
|
|
labelVecIcon: Assets.vec.homeHashtagSvg.path,
|
2025-09-09 13:29:27 +03:30
|
|
|
|
labelBgColor: const Color(0xFFAFCBFF),
|
|
|
|
|
|
valueBgColor: const Color(0xFFCEDFFF),
|
2025-09-08 14:52:32 +03:30
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
'third': [
|
|
|
|
|
|
InformationTagData(
|
|
|
|
|
|
labelTitle: 'تلفات',
|
|
|
|
|
|
unit: 'قطعه',
|
|
|
|
|
|
isLoading: true,
|
|
|
|
|
|
labelVecIcon: Assets.vec.boxRemoveSvg.path,
|
2025-09-09 13:29:27 +03:30
|
|
|
|
|
|
|
|
|
|
iconColor: const Color(0xFF426060),
|
|
|
|
|
|
labelBgColor: const Color(0xFFA5D1D2),
|
|
|
|
|
|
valueBgColor: const Color(0xFFC7DFE0),
|
2025-09-08 14:52:32 +03:30
|
|
|
|
),
|
|
|
|
|
|
InformationTagData(
|
|
|
|
|
|
labelTitle: 'حجم کشتار شده',
|
|
|
|
|
|
unit: 'قطعه',
|
|
|
|
|
|
isLoading: true,
|
|
|
|
|
|
labelVecIcon: Assets.vec.closeSquareFilledSvg.path,
|
2025-09-09 13:29:27 +03:30
|
|
|
|
blendMode: BlendMode.dst,
|
|
|
|
|
|
labelBgColor: Color(0xFFC8B8D1),
|
|
|
|
|
|
valueBgColor: Color(0xFFDAD4DD),
|
2025-09-08 14:52:32 +03:30
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2025-09-09 11:38:20 +03:30
|
|
|
|
RxList<InformationCardData> ageCardData = [
|
|
|
|
|
|
InformationCardData(
|
|
|
|
|
|
labelTitle: 'بیشترین سن جوجه ریزی',
|
|
|
|
|
|
isLoading: true,
|
|
|
|
|
|
unit: 'روز',
|
|
|
|
|
|
labelVecIcon: Assets.vec.homeTrendUpSvg.path,
|
|
|
|
|
|
iconColor: const Color.fromRGBO(85, 97, 93, 1),
|
|
|
|
|
|
cardBgColor: const Color(0xFFE6FAF5),
|
|
|
|
|
|
labelBgColor: const Color(0xFFB0EFDF),
|
|
|
|
|
|
),
|
|
|
|
|
|
InformationCardData(
|
|
|
|
|
|
labelTitle: 'کمترین سن جوجه ریزی',
|
|
|
|
|
|
isLoading: true,
|
|
|
|
|
|
unit: 'روز',
|
|
|
|
|
|
labelVecIcon: Assets.vec.homeTrendDownSvg.path,
|
|
|
|
|
|
iconColor: const Color(0xFF6F6164),
|
|
|
|
|
|
cardBgColor: const Color(0xFFEDDCE0),
|
|
|
|
|
|
labelBgColor: const Color(0xFFE0BCC5),
|
|
|
|
|
|
),
|
|
|
|
|
|
].obs;
|
|
|
|
|
|
|
2025-09-06 17:22:19 +03:30
|
|
|
|
@override
|
|
|
|
|
|
void onReady() {
|
|
|
|
|
|
super.onReady();
|
|
|
|
|
|
getHomePoultryHatching();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> getHomePoultryHatching() async {
|
|
|
|
|
|
await safeCall<HomePoultryScienceModel?>(
|
2025-09-07 17:20:01 +03:30
|
|
|
|
call: () async => await rootLogic.poultryRepository.getHomePoultry(
|
2025-09-06 17:22:19 +03:30
|
|
|
|
token: rootLogic.tokenService.accessToken.value!,
|
|
|
|
|
|
type: 'home',
|
|
|
|
|
|
),
|
|
|
|
|
|
onSuccess: (result) {
|
|
|
|
|
|
if (result != null) {
|
|
|
|
|
|
homeInformation.value = result;
|
2025-09-08 14:52:32 +03:30
|
|
|
|
tagInfo['first'] = tagInfo['first']!.map((tag) {
|
|
|
|
|
|
if (tag.labelTitle == 'کل فارم ها') {
|
|
|
|
|
|
return tag.copyWith(
|
2025-09-16 15:47:35 +03:30
|
|
|
|
value: result.farmCount?.separatedByCommaFa ?? '0',
|
2025-09-08 14:52:32 +03:30
|
|
|
|
isLoading: false,
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (tag.labelTitle == 'تعداد جوجه ریزی') {
|
|
|
|
|
|
return tag.copyWith(
|
2025-09-16 15:47:35 +03:30
|
|
|
|
value: result.hatchingCount?.separatedByCommaFa ?? '0',
|
2025-09-08 14:52:32 +03:30
|
|
|
|
isLoading: false,
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
return tag;
|
|
|
|
|
|
}).toList();
|
|
|
|
|
|
|
|
|
|
|
|
// second
|
|
|
|
|
|
tagInfo['second'] = tagInfo['second']!.map((tag) {
|
|
|
|
|
|
switch (tag.labelTitle) {
|
|
|
|
|
|
case 'حجم جوجه ریزی':
|
|
|
|
|
|
return tag.copyWith(
|
2025-09-16 15:47:35 +03:30
|
|
|
|
value: result.hatchingQuantity?.separatedByCommaFa ?? '0',
|
2025-09-08 14:52:32 +03:30
|
|
|
|
isLoading: false,
|
|
|
|
|
|
);
|
|
|
|
|
|
case 'مانده در سالن':
|
|
|
|
|
|
return tag.copyWith(
|
2025-09-16 15:47:35 +03:30
|
|
|
|
value: result.hatchingLeftOver?.separatedByCommaFa ?? '0',
|
2025-09-08 14:52:32 +03:30
|
|
|
|
isLoading: false,
|
|
|
|
|
|
);
|
|
|
|
|
|
default:
|
|
|
|
|
|
return tag;
|
|
|
|
|
|
}
|
|
|
|
|
|
}).toList();
|
|
|
|
|
|
|
|
|
|
|
|
// third
|
|
|
|
|
|
tagInfo['third'] = tagInfo['third']!.map((tag) {
|
|
|
|
|
|
switch (tag.labelTitle) {
|
|
|
|
|
|
case 'تلفات':
|
|
|
|
|
|
return tag.copyWith(
|
2025-09-16 15:47:35 +03:30
|
|
|
|
value: result.hatchingLosses?.separatedByCommaFa ?? '0',
|
2025-09-08 14:52:32 +03:30
|
|
|
|
isLoading: false,
|
|
|
|
|
|
);
|
|
|
|
|
|
case 'حجم کشتار شده':
|
|
|
|
|
|
return tag.copyWith(
|
2025-12-17 10:26:39 +03:30
|
|
|
|
value:
|
|
|
|
|
|
result.hatchingKilledQuantity?.separatedByCommaFa ?? '0',
|
2025-09-08 14:52:32 +03:30
|
|
|
|
isLoading: false,
|
|
|
|
|
|
);
|
|
|
|
|
|
default:
|
|
|
|
|
|
return tag;
|
|
|
|
|
|
}
|
|
|
|
|
|
}).toList();
|
2025-09-09 11:38:20 +03:30
|
|
|
|
|
|
|
|
|
|
ageCardData.value = ageCardData.map((element) {
|
|
|
|
|
|
switch (element.labelTitle) {
|
|
|
|
|
|
case 'کمترین سن جوجه ریزی':
|
|
|
|
|
|
return element.copyWith(
|
2025-09-16 15:47:35 +03:30
|
|
|
|
value: result.hatchingMinAge?.separatedByCommaFa ?? '0',
|
2025-09-09 11:38:20 +03:30
|
|
|
|
isLoading: false,
|
|
|
|
|
|
);
|
|
|
|
|
|
case 'بیشترین سن جوجه ریزی':
|
|
|
|
|
|
return element.copyWith(
|
2025-09-16 15:47:35 +03:30
|
|
|
|
value: result.hatchingMaxAge?.separatedByCommaFa ?? '0',
|
2025-09-09 11:38:20 +03:30
|
|
|
|
isLoading: false,
|
|
|
|
|
|
);
|
|
|
|
|
|
default:
|
|
|
|
|
|
return element;
|
|
|
|
|
|
}
|
|
|
|
|
|
}).toList();
|
2025-09-06 17:22:19 +03:30
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
onError: (error, stackTrace) {},
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|