feat : farms in poultry science
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:rasadyar_chicken/data/models/response/hatching/hatching_models.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/hatching_report/hatching_report.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/poultry/poultry_farm.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/poultry_science/home_poultry_science/home_poultry_science_model.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
@@ -20,9 +21,13 @@ abstract class PoultryScienceRemoteDatasource {
|
||||
ProgressCallback? onSendProgress,
|
||||
});
|
||||
|
||||
|
||||
Future<PaginationModel<HatchingReport>?> getPoultryScienceReport({
|
||||
required String token,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
});
|
||||
|
||||
Future<PaginationModel<PoultryFarm>?> getPoultryScienceFarmList({
|
||||
required String token,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:rasadyar_chicken/data/models/response/hatching/hatching_models.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/hatching_report/hatching_report.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/poultry/poultry_farm.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/poultry_science/home_poultry_science/home_poultry_science_model.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
@@ -72,4 +73,21 @@ class PoultryScienceRemoteDatasourceImp implements PoultryScienceRemoteDatasourc
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PaginationModel<PoultryFarm>?> getPoultryScienceFarmList({
|
||||
required String token,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
}) async{
|
||||
var res = await _httpClient.get(
|
||||
'/poultry_and_hatching_for_poultry_science/',
|
||||
headers: {'Authorization': 'Bearer $token'},
|
||||
queryParameters: queryParameters,
|
||||
fromJson: (json) => PaginationModel<PoultryFarm>.fromJson(
|
||||
json,
|
||||
(json) => PoultryFarm.fromJson(json as Map<String, dynamic>),
|
||||
),
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'poultry_farm.freezed.dart';
|
||||
part 'poultry_farm.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class PoultryFarm with _$PoultryFarm {
|
||||
const factory PoultryFarm({
|
||||
int? id,
|
||||
User? user,
|
||||
Address? address,
|
||||
List<dynamic>? hatching,
|
||||
VetFarm? vetFarm,
|
||||
String? key,
|
||||
bool? trash,
|
||||
int? ownerIdForeignKey,
|
||||
int? userIdForeignKey,
|
||||
int? addressIdForeignKey,
|
||||
bool? hasChainCompany,
|
||||
int? userBankIdForeignKey,
|
||||
dynamic cityOperator,
|
||||
String? unitName,
|
||||
String? gisCode,
|
||||
int? operatingLicenceCapacity,
|
||||
int? numberOfHalls,
|
||||
bool? tenant,
|
||||
bool? hasTenant,
|
||||
dynamic personType,
|
||||
dynamic economicCode,
|
||||
String? systemCode,
|
||||
String? epidemiologicalCode,
|
||||
String? breedingUniqueId,
|
||||
int? totalCapacity,
|
||||
String? licenceNumber,
|
||||
String? healthCertificateNumber,
|
||||
int? numberOfRequests,
|
||||
String? hatchingDate,
|
||||
String? lastPartyDate,
|
||||
int? numberOfIncubators,
|
||||
int? herdAgeByDay,
|
||||
int? herdAgeByWeek,
|
||||
int? numberOfParty,
|
||||
dynamic communicationType,
|
||||
dynamic cooperative,
|
||||
String? dateOfRegister,
|
||||
dynamic unitStatus,
|
||||
bool? active,
|
||||
dynamic identityDocuments,
|
||||
dynamic samasatUserCode,
|
||||
dynamic baseOrder,
|
||||
String? incubationDate,
|
||||
int? walletAmount,
|
||||
int? city,
|
||||
int? cityNumber,
|
||||
String? cityName,
|
||||
int? provinceNumber,
|
||||
String? provinceName,
|
||||
int? walletIdForeignKey,
|
||||
int? poultryIdKey,
|
||||
double? lat,
|
||||
double? long,
|
||||
dynamic date,
|
||||
int? killingAveAge,
|
||||
int? activeLeftOver,
|
||||
int? killingAveCount,
|
||||
int? killingAveWeight,
|
||||
int? killingLiveWeight,
|
||||
int? killingCarcassesWeight,
|
||||
int? killingLossWeightPercent,
|
||||
double? realKillingAveWeight,
|
||||
double? realKillingLiveWeight,
|
||||
double? realKillingCarcassesWeight,
|
||||
double? realKillingLossWeightPercent,
|
||||
dynamic interestLicenseId,
|
||||
bool? orderLimit,
|
||||
dynamic owner,
|
||||
dynamic userBankInfo,
|
||||
int? wallet,
|
||||
HatchingInfo? hatchingInfo,
|
||||
}) = _PoultryFarm;
|
||||
|
||||
factory PoultryFarm.fromJson(Map<String, dynamic> json) =>
|
||||
_$PoultryFarmFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class User with _$User {
|
||||
const factory User({
|
||||
String? fullname,
|
||||
String? mobile,
|
||||
}) = _User;
|
||||
|
||||
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class Address with _$Address {
|
||||
const factory Address({
|
||||
Province? province,
|
||||
City? city,
|
||||
String? address,
|
||||
String? postalCode,
|
||||
}) = _Address;
|
||||
|
||||
factory Address.fromJson(Map<String, dynamic> json) =>
|
||||
_$AddressFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class Province with _$Province {
|
||||
const factory Province({
|
||||
String? key,
|
||||
String? name,
|
||||
}) = _Province;
|
||||
|
||||
factory Province.fromJson(Map<String, dynamic> json) =>
|
||||
_$ProvinceFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class City with _$City {
|
||||
const factory City({
|
||||
String? key,
|
||||
String? name,
|
||||
}) = _City;
|
||||
|
||||
factory City.fromJson(Map<String, dynamic> json) => _$CityFromJson(json);
|
||||
}
|
||||
|
||||
|
||||
@freezed
|
||||
abstract class VetFarm with _$VetFarm{
|
||||
const factory VetFarm({
|
||||
String? fullName,
|
||||
String? mobile,
|
||||
String? city,
|
||||
String? province,
|
||||
}) = _VetFarm;
|
||||
|
||||
factory VetFarm.fromJson(Map<String, dynamic> json) => _$VetFarmFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class HatchingInfo with _$HatchingInfo{
|
||||
const factory HatchingInfo({
|
||||
int? period,
|
||||
bool? activeHatching,
|
||||
}) = _HatchingInfo;
|
||||
|
||||
factory HatchingInfo.fromJson(Map<String, dynamic> json) => _$HatchingInfoFromJson(json);
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,238 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'poultry_farm.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_PoultryFarm _$PoultryFarmFromJson(Map<String, dynamic> json) => _PoultryFarm(
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
user: json['user'] == null
|
||||
? null
|
||||
: User.fromJson(json['user'] as Map<String, dynamic>),
|
||||
address: json['address'] == null
|
||||
? null
|
||||
: Address.fromJson(json['address'] as Map<String, dynamic>),
|
||||
hatching: json['hatching'] as List<dynamic>?,
|
||||
vetFarm: json['vet_farm'] == null
|
||||
? null
|
||||
: VetFarm.fromJson(json['vet_farm'] as Map<String, dynamic>),
|
||||
key: json['key'] as String?,
|
||||
trash: json['trash'] as bool?,
|
||||
ownerIdForeignKey: (json['owner_id_foreign_key'] as num?)?.toInt(),
|
||||
userIdForeignKey: (json['user_id_foreign_key'] as num?)?.toInt(),
|
||||
addressIdForeignKey: (json['address_id_foreign_key'] as num?)?.toInt(),
|
||||
hasChainCompany: json['has_chain_company'] as bool?,
|
||||
userBankIdForeignKey: (json['user_bank_id_foreign_key'] as num?)?.toInt(),
|
||||
cityOperator: json['city_operator'],
|
||||
unitName: json['unit_name'] as String?,
|
||||
gisCode: json['gis_code'] as String?,
|
||||
operatingLicenceCapacity: (json['operating_licence_capacity'] as num?)
|
||||
?.toInt(),
|
||||
numberOfHalls: (json['number_of_halls'] as num?)?.toInt(),
|
||||
tenant: json['tenant'] as bool?,
|
||||
hasTenant: json['has_tenant'] as bool?,
|
||||
personType: json['person_type'],
|
||||
economicCode: json['economic_code'],
|
||||
systemCode: json['system_code'] as String?,
|
||||
epidemiologicalCode: json['epidemiological_code'] as String?,
|
||||
breedingUniqueId: json['breeding_unique_id'] as String?,
|
||||
totalCapacity: (json['total_capacity'] as num?)?.toInt(),
|
||||
licenceNumber: json['licence_number'] as String?,
|
||||
healthCertificateNumber: json['health_certificate_number'] as String?,
|
||||
numberOfRequests: (json['number_of_requests'] as num?)?.toInt(),
|
||||
hatchingDate: json['hatching_date'] as String?,
|
||||
lastPartyDate: json['last_party_date'] as String?,
|
||||
numberOfIncubators: (json['number_of_incubators'] as num?)?.toInt(),
|
||||
herdAgeByDay: (json['herd_age_by_day'] as num?)?.toInt(),
|
||||
herdAgeByWeek: (json['herd_age_by_week'] as num?)?.toInt(),
|
||||
numberOfParty: (json['number_of_party'] as num?)?.toInt(),
|
||||
communicationType: json['communication_type'],
|
||||
cooperative: json['cooperative'],
|
||||
dateOfRegister: json['date_of_register'] as String?,
|
||||
unitStatus: json['unit_status'],
|
||||
active: json['active'] as bool?,
|
||||
identityDocuments: json['identity_documents'],
|
||||
samasatUserCode: json['samasat_user_code'],
|
||||
baseOrder: json['base_order'],
|
||||
incubationDate: json['incubation_date'] as String?,
|
||||
walletAmount: (json['wallet_amount'] as num?)?.toInt(),
|
||||
city: (json['city'] as num?)?.toInt(),
|
||||
cityNumber: (json['city_number'] as num?)?.toInt(),
|
||||
cityName: json['city_name'] as String?,
|
||||
provinceNumber: (json['province_number'] as num?)?.toInt(),
|
||||
provinceName: json['province_name'] as String?,
|
||||
walletIdForeignKey: (json['wallet_id_foreign_key'] as num?)?.toInt(),
|
||||
poultryIdKey: (json['poultry_id_key'] as num?)?.toInt(),
|
||||
lat: (json['lat'] as num?)?.toDouble(),
|
||||
long: (json['long'] as num?)?.toDouble(),
|
||||
date: json['date'],
|
||||
killingAveAge: (json['killing_ave_age'] as num?)?.toInt(),
|
||||
activeLeftOver: (json['active_left_over'] as num?)?.toInt(),
|
||||
killingAveCount: (json['killing_ave_count'] as num?)?.toInt(),
|
||||
killingAveWeight: (json['killing_ave_weight'] as num?)?.toInt(),
|
||||
killingLiveWeight: (json['killing_live_weight'] as num?)?.toInt(),
|
||||
killingCarcassesWeight: (json['killing_carcasses_weight'] as num?)?.toInt(),
|
||||
killingLossWeightPercent: (json['killing_loss_weight_percent'] as num?)
|
||||
?.toInt(),
|
||||
realKillingAveWeight: (json['real_killing_ave_weight'] as num?)?.toDouble(),
|
||||
realKillingLiveWeight: (json['real_killing_live_weight'] as num?)?.toDouble(),
|
||||
realKillingCarcassesWeight: (json['real_killing_carcasses_weight'] as num?)
|
||||
?.toDouble(),
|
||||
realKillingLossWeightPercent:
|
||||
(json['real_killing_loss_weight_percent'] as num?)?.toDouble(),
|
||||
interestLicenseId: json['interest_license_id'],
|
||||
orderLimit: json['order_limit'] as bool?,
|
||||
owner: json['owner'],
|
||||
userBankInfo: json['user_bank_info'],
|
||||
wallet: (json['wallet'] as num?)?.toInt(),
|
||||
hatchingInfo: json['hatching_info'] == null
|
||||
? null
|
||||
: HatchingInfo.fromJson(json['hatching_info'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$PoultryFarmToJson(_PoultryFarm instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'user': instance.user,
|
||||
'address': instance.address,
|
||||
'hatching': instance.hatching,
|
||||
'vet_farm': instance.vetFarm,
|
||||
'key': instance.key,
|
||||
'trash': instance.trash,
|
||||
'owner_id_foreign_key': instance.ownerIdForeignKey,
|
||||
'user_id_foreign_key': instance.userIdForeignKey,
|
||||
'address_id_foreign_key': instance.addressIdForeignKey,
|
||||
'has_chain_company': instance.hasChainCompany,
|
||||
'user_bank_id_foreign_key': instance.userBankIdForeignKey,
|
||||
'city_operator': instance.cityOperator,
|
||||
'unit_name': instance.unitName,
|
||||
'gis_code': instance.gisCode,
|
||||
'operating_licence_capacity': instance.operatingLicenceCapacity,
|
||||
'number_of_halls': instance.numberOfHalls,
|
||||
'tenant': instance.tenant,
|
||||
'has_tenant': instance.hasTenant,
|
||||
'person_type': instance.personType,
|
||||
'economic_code': instance.economicCode,
|
||||
'system_code': instance.systemCode,
|
||||
'epidemiological_code': instance.epidemiologicalCode,
|
||||
'breeding_unique_id': instance.breedingUniqueId,
|
||||
'total_capacity': instance.totalCapacity,
|
||||
'licence_number': instance.licenceNumber,
|
||||
'health_certificate_number': instance.healthCertificateNumber,
|
||||
'number_of_requests': instance.numberOfRequests,
|
||||
'hatching_date': instance.hatchingDate,
|
||||
'last_party_date': instance.lastPartyDate,
|
||||
'number_of_incubators': instance.numberOfIncubators,
|
||||
'herd_age_by_day': instance.herdAgeByDay,
|
||||
'herd_age_by_week': instance.herdAgeByWeek,
|
||||
'number_of_party': instance.numberOfParty,
|
||||
'communication_type': instance.communicationType,
|
||||
'cooperative': instance.cooperative,
|
||||
'date_of_register': instance.dateOfRegister,
|
||||
'unit_status': instance.unitStatus,
|
||||
'active': instance.active,
|
||||
'identity_documents': instance.identityDocuments,
|
||||
'samasat_user_code': instance.samasatUserCode,
|
||||
'base_order': instance.baseOrder,
|
||||
'incubation_date': instance.incubationDate,
|
||||
'wallet_amount': instance.walletAmount,
|
||||
'city': instance.city,
|
||||
'city_number': instance.cityNumber,
|
||||
'city_name': instance.cityName,
|
||||
'province_number': instance.provinceNumber,
|
||||
'province_name': instance.provinceName,
|
||||
'wallet_id_foreign_key': instance.walletIdForeignKey,
|
||||
'poultry_id_key': instance.poultryIdKey,
|
||||
'lat': instance.lat,
|
||||
'long': instance.long,
|
||||
'date': instance.date,
|
||||
'killing_ave_age': instance.killingAveAge,
|
||||
'active_left_over': instance.activeLeftOver,
|
||||
'killing_ave_count': instance.killingAveCount,
|
||||
'killing_ave_weight': instance.killingAveWeight,
|
||||
'killing_live_weight': instance.killingLiveWeight,
|
||||
'killing_carcasses_weight': instance.killingCarcassesWeight,
|
||||
'killing_loss_weight_percent': instance.killingLossWeightPercent,
|
||||
'real_killing_ave_weight': instance.realKillingAveWeight,
|
||||
'real_killing_live_weight': instance.realKillingLiveWeight,
|
||||
'real_killing_carcasses_weight': instance.realKillingCarcassesWeight,
|
||||
'real_killing_loss_weight_percent': instance.realKillingLossWeightPercent,
|
||||
'interest_license_id': instance.interestLicenseId,
|
||||
'order_limit': instance.orderLimit,
|
||||
'owner': instance.owner,
|
||||
'user_bank_info': instance.userBankInfo,
|
||||
'wallet': instance.wallet,
|
||||
'hatching_info': instance.hatchingInfo,
|
||||
};
|
||||
|
||||
_User _$UserFromJson(Map<String, dynamic> json) => _User(
|
||||
fullname: json['fullname'] as String?,
|
||||
mobile: json['mobile'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$UserToJson(_User instance) => <String, dynamic>{
|
||||
'fullname': instance.fullname,
|
||||
'mobile': instance.mobile,
|
||||
};
|
||||
|
||||
_Address _$AddressFromJson(Map<String, dynamic> json) => _Address(
|
||||
province: json['province'] == null
|
||||
? null
|
||||
: Province.fromJson(json['province'] as Map<String, dynamic>),
|
||||
city: json['city'] == null
|
||||
? null
|
||||
: City.fromJson(json['city'] as Map<String, dynamic>),
|
||||
address: json['address'] as String?,
|
||||
postalCode: json['postal_code'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$AddressToJson(_Address instance) => <String, dynamic>{
|
||||
'province': instance.province,
|
||||
'city': instance.city,
|
||||
'address': instance.address,
|
||||
'postal_code': instance.postalCode,
|
||||
};
|
||||
|
||||
_Province _$ProvinceFromJson(Map<String, dynamic> json) =>
|
||||
_Province(key: json['key'] as String?, name: json['name'] as String?);
|
||||
|
||||
Map<String, dynamic> _$ProvinceToJson(_Province instance) => <String, dynamic>{
|
||||
'key': instance.key,
|
||||
'name': instance.name,
|
||||
};
|
||||
|
||||
_City _$CityFromJson(Map<String, dynamic> json) =>
|
||||
_City(key: json['key'] as String?, name: json['name'] as String?);
|
||||
|
||||
Map<String, dynamic> _$CityToJson(_City instance) => <String, dynamic>{
|
||||
'key': instance.key,
|
||||
'name': instance.name,
|
||||
};
|
||||
|
||||
_VetFarm _$VetFarmFromJson(Map<String, dynamic> json) => _VetFarm(
|
||||
fullName: json['full_name'] as String?,
|
||||
mobile: json['mobile'] as String?,
|
||||
city: json['city'] as String?,
|
||||
province: json['province'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$VetFarmToJson(_VetFarm instance) => <String, dynamic>{
|
||||
'full_name': instance.fullName,
|
||||
'mobile': instance.mobile,
|
||||
'city': instance.city,
|
||||
'province': instance.province,
|
||||
};
|
||||
|
||||
_HatchingInfo _$HatchingInfoFromJson(Map<String, dynamic> json) =>
|
||||
_HatchingInfo(
|
||||
period: (json['period'] as num?)?.toInt(),
|
||||
activeHatching: json['active_hatching'] as bool?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$HatchingInfoToJson(_HatchingInfo instance) =>
|
||||
<String, dynamic>{
|
||||
'period': instance.period,
|
||||
'active_hatching': instance.activeHatching,
|
||||
};
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:rasadyar_chicken/data/models/response/hatching/hatching_models.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/hatching_report/hatching_report.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/poultry/poultry_farm.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/poultry_science/home_poultry_science/home_poultry_science_model.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
@@ -24,4 +25,9 @@ abstract class PoultryScienceRepository {
|
||||
Map<String, dynamic>? queryParameters,
|
||||
});
|
||||
|
||||
Future<PaginationModel<PoultryFarm>?> getPoultryScienceFarmList({
|
||||
required String token,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:rasadyar_chicken/data/data_source/remote/poultry_science/poultry_science_remote.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/hatching/hatching_models.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/hatching_report/hatching_report.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/poultry/poultry_farm.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/poultry_science/home_poultry_science/home_poultry_science_model.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
@@ -41,4 +42,15 @@ class PoultryScienceRepositoryImp implements PoultryScienceRepository {
|
||||
}) async {
|
||||
return await datasource.getPoultryScienceReport(token: token, queryParameters: queryParameters);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PaginationModel<PoultryFarm>?> getPoultryScienceFarmList({
|
||||
required String token,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
}) async {
|
||||
return await datasource.getPoultryScienceFarmList(
|
||||
token: token,
|
||||
queryParameters: queryParameters,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/poultry/poultry_farm.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/poultry_science/home/logic.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/poultry_science/root/logic.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class FarmLogic extends GetxController {
|
||||
List<String> routes = ['اقدام', 'فارم ها'];
|
||||
PoultryScienceRootLogic rootLogic = Get.find<PoultryScienceRootLogic>();
|
||||
final PoultryScienceHomeLogic _homeLogic = Get.find<PoultryScienceHomeLogic>();
|
||||
RxList<InformationTagData> tagInfo = <InformationTagData>[
|
||||
InformationTagData(
|
||||
labelTitle: 'کل فارم ها',
|
||||
isLoading: true,
|
||||
labelVecIcon: Assets.vec.cubeScanSvg.path,
|
||||
blendMode: BlendMode.dst,
|
||||
valueBgColor: Colors.white,
|
||||
labelGradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [AppColor.blueLight, Colors.white],
|
||||
),
|
||||
),
|
||||
InformationTagData(
|
||||
labelTitle: 'حجم جوجه ریزی',
|
||||
unit: 'قطعه',
|
||||
isLoading: true,
|
||||
labelVecIcon: Assets.vec.cubeCardSvg.path,
|
||||
blendMode: BlendMode.dst,
|
||||
valueBgColor: Colors.white,
|
||||
labelGradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [AppColor.greenLightHover, Colors.white],
|
||||
),
|
||||
),
|
||||
].obs;
|
||||
Rx<Resource<PaginationModel<PoultryFarm>>> farmList =
|
||||
Resource<PaginationModel<PoultryFarm>>.loading().obs;
|
||||
|
||||
RxInt currentPage = 1.obs;
|
||||
final RxBool isLoadingMoreList = false.obs;
|
||||
RxList<int> isExpandedList = <int>[].obs;
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
tagInfo[0] = tagInfo[0].copyWith(
|
||||
isLoading: false,
|
||||
value: _homeLogic.tagInfo['first']!.first.value,
|
||||
);
|
||||
tagInfo[1] = tagInfo[1].copyWith(
|
||||
isLoading: false,
|
||||
value: _homeLogic.tagInfo['second']!.first.value,
|
||||
);
|
||||
|
||||
getFarmList();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
Future<void> getFarmList([bool isLoadingMore = false]) async {
|
||||
if (isLoadingMore) {
|
||||
isLoadingMoreList.value = true;
|
||||
} else {
|
||||
farmList.value = Resource<PaginationModel<PoultryFarm>>.loading();
|
||||
}
|
||||
await safeCall(
|
||||
call: () async => await rootLogic.poultryRepository.getPoultryScienceFarmList(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(
|
||||
queryParams: {'type': 'farm'},
|
||||
role: 'PoultryScience',
|
||||
pageSize: 50,
|
||||
search: 'filter',
|
||||
value: '',
|
||||
page: currentPage.value,
|
||||
),
|
||||
),
|
||||
onSuccess: (res) {
|
||||
if ((res?.count ?? 0) == 0) {
|
||||
farmList.value = Resource<PaginationModel<PoultryFarm>>.empty();
|
||||
} else {
|
||||
farmList.value = Resource<PaginationModel<PoultryFarm>>.success(
|
||||
PaginationModel<PoultryFarm>(
|
||||
count: res?.count ?? 0,
|
||||
next: res?.next,
|
||||
previous: res?.previous,
|
||||
results: [
|
||||
...(farmList.value.data?.results ?? []),
|
||||
...?(res?.results as List<PoultryFarm>?),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/poultry/poultry_farm.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
class FarmPage extends GetView<FarmLogic> {
|
||||
const FarmPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BasePage(
|
||||
routes: controller.routes,
|
||||
hasFilter: false,
|
||||
hasSearch: false,
|
||||
widgets: [firstTagInformation(), farmListWidget()],
|
||||
);
|
||||
}
|
||||
|
||||
Widget firstTagInformation() {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 0, 13),
|
||||
child: ObxValue((data) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20.w),
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: List.generate(
|
||||
data.length,
|
||||
(index) => Expanded(child: InformationTag(data: data[index])),
|
||||
),
|
||||
),
|
||||
);
|
||||
}, controller.tagInfo),
|
||||
);
|
||||
}
|
||||
|
||||
Widget farmListWidget() {
|
||||
return Expanded(
|
||||
child: ObxValue((data) {
|
||||
return RPaginatedListView(
|
||||
listType: ListType.separated,
|
||||
resource: data.value,
|
||||
hasMore: data.value.data?.next != null,
|
||||
padding: EdgeInsets.fromLTRB(8, 8, 8, 80),
|
||||
itemBuilder: (context, index) {
|
||||
var item = data.value.data!.results![index];
|
||||
return ObxValue((val) {
|
||||
return ExpandableListItem2(
|
||||
selected: val.contains(index),
|
||||
onTap: () => controller.isExpandedList.toggle(index),
|
||||
index: index,
|
||||
child: itemListWidget(item),
|
||||
secondChild: itemListExpandedWidget(item),
|
||||
labelColor: AppColor.blueLight,
|
||||
labelIcon: Assets.vec.checkSquareSvg.path,
|
||||
);
|
||||
}, controller.isExpandedList);
|
||||
},
|
||||
itemCount: data.value.data?.results?.length ?? 0,
|
||||
separatorBuilder: (context, index) => SizedBox(height: 8.h),
|
||||
onLoadMore: () async => controller.getFarmList(true),
|
||||
onRefresh: () async {
|
||||
controller.currentPage.value = 1;
|
||||
await controller.getFarmList();
|
||||
},
|
||||
);
|
||||
}, controller.farmList),
|
||||
);
|
||||
}
|
||||
|
||||
Container itemListExpandedWidget(PoultryFarm item) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
|
||||
child: Column(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.unitName ?? 'N/A',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan16.copyWith(color: AppColor.greenDark),
|
||||
),
|
||||
Spacer(),
|
||||
|
||||
Visibility(
|
||||
child: Text(
|
||||
'${item.address?.province?.name} / ${item.address?.city?.name}',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
height: 32,
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: ShapeDecoration(
|
||||
color: AppColor.blueLight,
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(width: 1, color: AppColor.blueLightHover),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'تعاونی : ${item.cityOperator ?? 'ندارد'}',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
|
||||
Text(
|
||||
' تعداد سالن : ${item.numberOfHalls}',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
buildRow(title: 'مالک/ تلفن', value: '${item.user?.fullname} (${item.user?.mobile})'),
|
||||
buildRow(title: 'شناسه یکتا', value: item.breedingUniqueId ?? 'N/A'),
|
||||
buildRow(title: 'کد اپیدمیولوژیک', value: item.epidemiologicalCode ?? 'N/A'),
|
||||
buildRow(title: 'کد بهداشتی', value: item.healthCertificateNumber ?? 'N/A'),
|
||||
buildRow(
|
||||
title: 'دامپزشک فارم',
|
||||
value: '${item.vetFarm?.fullName ?? '-'} (${item.vetFarm?.mobile ?? '-'})',
|
||||
),
|
||||
buildRow(title: 'ظرفیت فارم', value: item.totalCapacity.separatedByComma),
|
||||
buildRow(
|
||||
title: 'جوجه ریزی فعال (تعداد دوره) ',
|
||||
value:
|
||||
'${(item.hatchingInfo?.activeHatching ?? false) ? 'دارد' : 'ندارد'} (${item.hatchingInfo?.period ?? 0})',
|
||||
),
|
||||
|
||||
/* buildRow(
|
||||
title: 'شرح بازرسی',
|
||||
value: item.reportInfo?.image == false ? 'ارسال تصویر جوجه ریزی فارم ' : 'تکمیل شده',
|
||||
titleStyle: AppFonts.yekan14.copyWith(
|
||||
color: (item.reportInfo?.image ?? false) ? AppColor.greenNormal : AppColor.redDark,
|
||||
),
|
||||
valueStyle: AppFonts.yekan14.copyWith(
|
||||
color: (item.reportInfo?.image ?? false) ? AppColor.greenNormal : AppColor.redDark,
|
||||
),
|
||||
),*/
|
||||
/* Visibility(
|
||||
visible: (item.reportInfo?.image == false),
|
||||
child: RElevated(
|
||||
text: 'ثبت بازرسی',
|
||||
isFullWidth: true,
|
||||
width: 150.w,
|
||||
height: 40.h,
|
||||
onPressed: () {
|
||||
cameraBottomSheet(item.id!);
|
||||
},
|
||||
textStyle: AppFonts.yekan20.copyWith(color: Colors.white),
|
||||
backgroundColor: AppColor.greenNormal,
|
||||
),
|
||||
),*/
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget itemListWidget(PoultryFarm item) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SizedBox(width: 20),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
spacing: 3,
|
||||
children: [
|
||||
Text(
|
||||
item.unitName ?? 'N/A',
|
||||
textAlign: TextAlign.start,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Text(
|
||||
item.user?.mobile ?? 'N/A',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.bgDark),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Column(
|
||||
spacing: 3,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'شناسه یکتا: ${item.breedingUniqueId}',
|
||||
textAlign: TextAlign.start,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Text(
|
||||
'${item.address?.province?.name}/${item.address?.city?.name}',
|
||||
textAlign: TextAlign.left,
|
||||
|
||||
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),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ class PoultryScienceHomeLogic extends GetxController {
|
||||
PoultryScienceRootLogic rootLogic = Get.find<PoultryScienceRootLogic>();
|
||||
Rxn<HomePoultryScienceModel> homeInformation = Rxn();
|
||||
RxBool isExpanded = false.obs;
|
||||
|
||||
RxMap<String, List<InformationTagData>> tagInfo = RxMap({
|
||||
'first': [
|
||||
InformationTagData(
|
||||
@@ -55,7 +54,6 @@ class PoultryScienceHomeLogic extends GetxController {
|
||||
valueBgColor: const Color(0xFFCEDFFF),
|
||||
),
|
||||
],
|
||||
|
||||
'third': [
|
||||
InformationTagData(
|
||||
labelTitle: 'تلفات',
|
||||
|
||||
@@ -80,6 +80,7 @@ class InspectionPoultryScienceLogic extends GetxController {
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(
|
||||
queryParams: {'type': 'hatching', 'report': true},
|
||||
role: 'PoultryScience',
|
||||
pageSize: 50,
|
||||
page: currentPage.value,
|
||||
),
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:rasadyar_chicken/presentation/pages/auth/logic.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/auth/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/poultry_science/farm/logic.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/poultry_science/farm/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/poultry_science/home/logic.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/poultry_science/inspection/logic.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/poultry_science/inspection/view.dart';
|
||||
@@ -176,6 +178,17 @@ sealed class ChickenPages {
|
||||
Get.lazyPut(() => PoultryActionLogic());
|
||||
}),
|
||||
),
|
||||
|
||||
GetPage(
|
||||
name: ChickenRoutes.farmPoultryScience,
|
||||
page: () => FarmPage(),
|
||||
middlewares: [AuthMiddleware()],
|
||||
binding: BindingsBuilder(() {
|
||||
Get.lazyPut(() => FarmLogic());
|
||||
Get.lazyPut(() => PoultryScienceHomeLogic());
|
||||
Get.lazyPut(() => PoultryScienceRootLogic());
|
||||
}),
|
||||
),
|
||||
//endregion
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_core/data/model/pagination_model/pagination_model.dart';
|
||||
|
||||
enum ListType { builder, separated }
|
||||
|
||||
@@ -72,6 +71,8 @@ class RPaginatedListView<T> extends StatelessWidget {
|
||||
},
|
||||
child: RefreshIndicator(
|
||||
color: AppColor.blueNormal,
|
||||
triggerMode: RefreshIndicatorTriggerMode.anywhere,
|
||||
|
||||
onRefresh: onRefresh ?? () async {},
|
||||
child: listType == ListType.separated
|
||||
? ListView.separated(
|
||||
|
||||
Reference in New Issue
Block a user