feat : home page

This commit is contained in:
2025-09-06 17:22:19 +03:30
parent 34609d22a1
commit d2e74e6627
18 changed files with 2084 additions and 2 deletions

View File

@@ -0,0 +1,8 @@
import 'package:rasadyar_chicken/data/models/response/poultry_science/home_poultry_science/home_poultry_science_model.dart';
abstract class PoultryScienceRemoteDatasource {
Future<HomePoultryScienceModel?> getHomePoultryScience({
required String token,
required String type,
});
}

View File

@@ -0,0 +1,25 @@
import 'package:rasadyar_chicken/data/models/response/poultry_science/home_poultry_science/home_poultry_science_model.dart';
import 'package:rasadyar_core/core.dart';
import 'poultry_science_remote.dart';
class PoultryScienceRemoteDatasourceImp implements PoultryScienceRemoteDatasource {
final DioRemote _httpClient;
PoultryScienceRemoteDatasourceImp(this._httpClient);
@override
Future<HomePoultryScienceModel?> getHomePoultryScience({
required String token,
required String type,
}) async {
var res = await _httpClient.get(
'poultry_and_hatching_for_poultry_science/',
queryParameters: {'type': type},
headers: {'Authorization': 'Bearer $token'},
fromJson: (json) => HomePoultryScienceModel.fromJson(json),
);
return res.data;
}
}

View File

@@ -6,10 +6,14 @@ import 'package:rasadyar_chicken/data/data_source/remote/auth/auth_remote.dart';
import 'package:rasadyar_chicken/data/data_source/remote/auth/auth_remote_imp.dart';
import 'package:rasadyar_chicken/data/data_source/remote/chicken/chicken_remote.dart';
import 'package:rasadyar_chicken/data/data_source/remote/chicken/chicken_remote_imp.dart';
import 'package:rasadyar_chicken/data/data_source/remote/poultry_science/poultry_science_remote.dart';
import 'package:rasadyar_chicken/data/data_source/remote/poultry_science/poultry_science_remote_imp.dart';
import 'package:rasadyar_chicken/data/repositories/auth/auth_repository.dart';
import 'package:rasadyar_chicken/data/repositories/auth/auth_repository_imp.dart';
import 'package:rasadyar_chicken/data/repositories/chicken/chicken_repository.dart';
import 'package:rasadyar_chicken/data/repositories/chicken/chicken_repository_imp.dart';
import 'package:rasadyar_chicken/data/repositories/poultry_science/poultry_science_repository.dart';
import 'package:rasadyar_chicken/data/repositories/poultry_science/poultry_science_repository_imp.dart';
import 'package:rasadyar_core/core.dart';
GetIt diChicken = GetIt.asNewInstance();
@@ -67,6 +71,14 @@ Future<void> setupChickenDI() async {
local: diChicken.get<ChickenLocalDataSource>(),
),
);
diChicken.registerLazySingleton<PoultryScienceRemoteDatasource>(
() => PoultryScienceRemoteDatasourceImp(diChicken.get<DioRemote>()),
);
diChicken.registerLazySingleton<PoultryScienceRepository>(
() => PoultryScienceRepositoryImp(diChicken.get<PoultryScienceRemoteDatasource>()),
);
}
Future<void> newSetupAuthDI(String newUrl) async {
@@ -117,6 +129,13 @@ Future<void> newSetupAuthDI(String newUrl) async {
local: diChicken.get<ChickenLocalDataSource>(),
),
);
await reRegister<PoultryScienceRemoteDatasource>(
() => PoultryScienceRemoteDatasourceImp(dioRemote),
);
await reRegister<PoultryScienceRepository>(
() => PoultryScienceRepositoryImp(diChicken.get<PoultryScienceRemoteDatasource>()),
);
}
Future<void> reRegister<T extends Object>(T Function() factory) async {

View File

@@ -8,7 +8,7 @@ part of 'widely_used_local_model.dart';
class WidelyUsedLocalModelAdapter extends TypeAdapter<WidelyUsedLocalModel> {
@override
final typeId = 2;
final typeId = 4;
@override
WidelyUsedLocalModel read(BinaryReader reader) {
@@ -45,7 +45,7 @@ class WidelyUsedLocalModelAdapter extends TypeAdapter<WidelyUsedLocalModel> {
class WidelyUsedLocalItemAdapter extends TypeAdapter<WidelyUsedLocalItem> {
@override
final typeId = 3;
final typeId = 5;
@override
WidelyUsedLocalItem read(BinaryReader reader) {

View File

@@ -0,0 +1,21 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'home_poultry_science_model.freezed.dart';
part 'home_poultry_science_model.g.dart';
@freezed
abstract class HomePoultryScienceModel with _$HomePoultryScienceModel {
const factory HomePoultryScienceModel({
int? farmCount,
int? hatchingCount,
int? hatchingQuantity,
int? hatchingLeftOver,
int? hatchingLosses,
int? hatchingKilledQuantity,
int? hatchingMaxAge,
int? hatchingMinAge,
}) = _HomePoultryScienceModel;
factory HomePoultryScienceModel.fromJson(Map<String, dynamic> json) =>
_$HomePoultryScienceModelFromJson(json);
}

View File

@@ -0,0 +1,298 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'home_poultry_science_model.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$HomePoultryScienceModel {
int? get farmCount; int? get hatchingCount; int? get hatchingQuantity; int? get hatchingLeftOver; int? get hatchingLosses; int? get hatchingKilledQuantity; int? get hatchingMaxAge; int? get hatchingMinAge;
/// Create a copy of HomePoultryScienceModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$HomePoultryScienceModelCopyWith<HomePoultryScienceModel> get copyWith => _$HomePoultryScienceModelCopyWithImpl<HomePoultryScienceModel>(this as HomePoultryScienceModel, _$identity);
/// Serializes this HomePoultryScienceModel to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is HomePoultryScienceModel&&(identical(other.farmCount, farmCount) || other.farmCount == farmCount)&&(identical(other.hatchingCount, hatchingCount) || other.hatchingCount == hatchingCount)&&(identical(other.hatchingQuantity, hatchingQuantity) || other.hatchingQuantity == hatchingQuantity)&&(identical(other.hatchingLeftOver, hatchingLeftOver) || other.hatchingLeftOver == hatchingLeftOver)&&(identical(other.hatchingLosses, hatchingLosses) || other.hatchingLosses == hatchingLosses)&&(identical(other.hatchingKilledQuantity, hatchingKilledQuantity) || other.hatchingKilledQuantity == hatchingKilledQuantity)&&(identical(other.hatchingMaxAge, hatchingMaxAge) || other.hatchingMaxAge == hatchingMaxAge)&&(identical(other.hatchingMinAge, hatchingMinAge) || other.hatchingMinAge == hatchingMinAge));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,farmCount,hatchingCount,hatchingQuantity,hatchingLeftOver,hatchingLosses,hatchingKilledQuantity,hatchingMaxAge,hatchingMinAge);
@override
String toString() {
return 'HomePoultryScienceModel(farmCount: $farmCount, hatchingCount: $hatchingCount, hatchingQuantity: $hatchingQuantity, hatchingLeftOver: $hatchingLeftOver, hatchingLosses: $hatchingLosses, hatchingKilledQuantity: $hatchingKilledQuantity, hatchingMaxAge: $hatchingMaxAge, hatchingMinAge: $hatchingMinAge)';
}
}
/// @nodoc
abstract mixin class $HomePoultryScienceModelCopyWith<$Res> {
factory $HomePoultryScienceModelCopyWith(HomePoultryScienceModel value, $Res Function(HomePoultryScienceModel) _then) = _$HomePoultryScienceModelCopyWithImpl;
@useResult
$Res call({
int? farmCount, int? hatchingCount, int? hatchingQuantity, int? hatchingLeftOver, int? hatchingLosses, int? hatchingKilledQuantity, int? hatchingMaxAge, int? hatchingMinAge
});
}
/// @nodoc
class _$HomePoultryScienceModelCopyWithImpl<$Res>
implements $HomePoultryScienceModelCopyWith<$Res> {
_$HomePoultryScienceModelCopyWithImpl(this._self, this._then);
final HomePoultryScienceModel _self;
final $Res Function(HomePoultryScienceModel) _then;
/// Create a copy of HomePoultryScienceModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? farmCount = freezed,Object? hatchingCount = freezed,Object? hatchingQuantity = freezed,Object? hatchingLeftOver = freezed,Object? hatchingLosses = freezed,Object? hatchingKilledQuantity = freezed,Object? hatchingMaxAge = freezed,Object? hatchingMinAge = freezed,}) {
return _then(_self.copyWith(
farmCount: freezed == farmCount ? _self.farmCount : farmCount // ignore: cast_nullable_to_non_nullable
as int?,hatchingCount: freezed == hatchingCount ? _self.hatchingCount : hatchingCount // ignore: cast_nullable_to_non_nullable
as int?,hatchingQuantity: freezed == hatchingQuantity ? _self.hatchingQuantity : hatchingQuantity // ignore: cast_nullable_to_non_nullable
as int?,hatchingLeftOver: freezed == hatchingLeftOver ? _self.hatchingLeftOver : hatchingLeftOver // ignore: cast_nullable_to_non_nullable
as int?,hatchingLosses: freezed == hatchingLosses ? _self.hatchingLosses : hatchingLosses // ignore: cast_nullable_to_non_nullable
as int?,hatchingKilledQuantity: freezed == hatchingKilledQuantity ? _self.hatchingKilledQuantity : hatchingKilledQuantity // ignore: cast_nullable_to_non_nullable
as int?,hatchingMaxAge: freezed == hatchingMaxAge ? _self.hatchingMaxAge : hatchingMaxAge // ignore: cast_nullable_to_non_nullable
as int?,hatchingMinAge: freezed == hatchingMinAge ? _self.hatchingMinAge : hatchingMinAge // ignore: cast_nullable_to_non_nullable
as int?,
));
}
}
/// Adds pattern-matching-related methods to [HomePoultryScienceModel].
extension HomePoultryScienceModelPatterns on HomePoultryScienceModel {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _HomePoultryScienceModel value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _HomePoultryScienceModel() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _HomePoultryScienceModel value) $default,){
final _that = this;
switch (_that) {
case _HomePoultryScienceModel():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _HomePoultryScienceModel value)? $default,){
final _that = this;
switch (_that) {
case _HomePoultryScienceModel() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( int? farmCount, int? hatchingCount, int? hatchingQuantity, int? hatchingLeftOver, int? hatchingLosses, int? hatchingKilledQuantity, int? hatchingMaxAge, int? hatchingMinAge)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _HomePoultryScienceModel() when $default != null:
return $default(_that.farmCount,_that.hatchingCount,_that.hatchingQuantity,_that.hatchingLeftOver,_that.hatchingLosses,_that.hatchingKilledQuantity,_that.hatchingMaxAge,_that.hatchingMinAge);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( int? farmCount, int? hatchingCount, int? hatchingQuantity, int? hatchingLeftOver, int? hatchingLosses, int? hatchingKilledQuantity, int? hatchingMaxAge, int? hatchingMinAge) $default,) {final _that = this;
switch (_that) {
case _HomePoultryScienceModel():
return $default(_that.farmCount,_that.hatchingCount,_that.hatchingQuantity,_that.hatchingLeftOver,_that.hatchingLosses,_that.hatchingKilledQuantity,_that.hatchingMaxAge,_that.hatchingMinAge);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( int? farmCount, int? hatchingCount, int? hatchingQuantity, int? hatchingLeftOver, int? hatchingLosses, int? hatchingKilledQuantity, int? hatchingMaxAge, int? hatchingMinAge)? $default,) {final _that = this;
switch (_that) {
case _HomePoultryScienceModel() when $default != null:
return $default(_that.farmCount,_that.hatchingCount,_that.hatchingQuantity,_that.hatchingLeftOver,_that.hatchingLosses,_that.hatchingKilledQuantity,_that.hatchingMaxAge,_that.hatchingMinAge);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _HomePoultryScienceModel implements HomePoultryScienceModel {
const _HomePoultryScienceModel({this.farmCount, this.hatchingCount, this.hatchingQuantity, this.hatchingLeftOver, this.hatchingLosses, this.hatchingKilledQuantity, this.hatchingMaxAge, this.hatchingMinAge});
factory _HomePoultryScienceModel.fromJson(Map<String, dynamic> json) => _$HomePoultryScienceModelFromJson(json);
@override final int? farmCount;
@override final int? hatchingCount;
@override final int? hatchingQuantity;
@override final int? hatchingLeftOver;
@override final int? hatchingLosses;
@override final int? hatchingKilledQuantity;
@override final int? hatchingMaxAge;
@override final int? hatchingMinAge;
/// Create a copy of HomePoultryScienceModel
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$HomePoultryScienceModelCopyWith<_HomePoultryScienceModel> get copyWith => __$HomePoultryScienceModelCopyWithImpl<_HomePoultryScienceModel>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$HomePoultryScienceModelToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _HomePoultryScienceModel&&(identical(other.farmCount, farmCount) || other.farmCount == farmCount)&&(identical(other.hatchingCount, hatchingCount) || other.hatchingCount == hatchingCount)&&(identical(other.hatchingQuantity, hatchingQuantity) || other.hatchingQuantity == hatchingQuantity)&&(identical(other.hatchingLeftOver, hatchingLeftOver) || other.hatchingLeftOver == hatchingLeftOver)&&(identical(other.hatchingLosses, hatchingLosses) || other.hatchingLosses == hatchingLosses)&&(identical(other.hatchingKilledQuantity, hatchingKilledQuantity) || other.hatchingKilledQuantity == hatchingKilledQuantity)&&(identical(other.hatchingMaxAge, hatchingMaxAge) || other.hatchingMaxAge == hatchingMaxAge)&&(identical(other.hatchingMinAge, hatchingMinAge) || other.hatchingMinAge == hatchingMinAge));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,farmCount,hatchingCount,hatchingQuantity,hatchingLeftOver,hatchingLosses,hatchingKilledQuantity,hatchingMaxAge,hatchingMinAge);
@override
String toString() {
return 'HomePoultryScienceModel(farmCount: $farmCount, hatchingCount: $hatchingCount, hatchingQuantity: $hatchingQuantity, hatchingLeftOver: $hatchingLeftOver, hatchingLosses: $hatchingLosses, hatchingKilledQuantity: $hatchingKilledQuantity, hatchingMaxAge: $hatchingMaxAge, hatchingMinAge: $hatchingMinAge)';
}
}
/// @nodoc
abstract mixin class _$HomePoultryScienceModelCopyWith<$Res> implements $HomePoultryScienceModelCopyWith<$Res> {
factory _$HomePoultryScienceModelCopyWith(_HomePoultryScienceModel value, $Res Function(_HomePoultryScienceModel) _then) = __$HomePoultryScienceModelCopyWithImpl;
@override @useResult
$Res call({
int? farmCount, int? hatchingCount, int? hatchingQuantity, int? hatchingLeftOver, int? hatchingLosses, int? hatchingKilledQuantity, int? hatchingMaxAge, int? hatchingMinAge
});
}
/// @nodoc
class __$HomePoultryScienceModelCopyWithImpl<$Res>
implements _$HomePoultryScienceModelCopyWith<$Res> {
__$HomePoultryScienceModelCopyWithImpl(this._self, this._then);
final _HomePoultryScienceModel _self;
final $Res Function(_HomePoultryScienceModel) _then;
/// Create a copy of HomePoultryScienceModel
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? farmCount = freezed,Object? hatchingCount = freezed,Object? hatchingQuantity = freezed,Object? hatchingLeftOver = freezed,Object? hatchingLosses = freezed,Object? hatchingKilledQuantity = freezed,Object? hatchingMaxAge = freezed,Object? hatchingMinAge = freezed,}) {
return _then(_HomePoultryScienceModel(
farmCount: freezed == farmCount ? _self.farmCount : farmCount // ignore: cast_nullable_to_non_nullable
as int?,hatchingCount: freezed == hatchingCount ? _self.hatchingCount : hatchingCount // ignore: cast_nullable_to_non_nullable
as int?,hatchingQuantity: freezed == hatchingQuantity ? _self.hatchingQuantity : hatchingQuantity // ignore: cast_nullable_to_non_nullable
as int?,hatchingLeftOver: freezed == hatchingLeftOver ? _self.hatchingLeftOver : hatchingLeftOver // ignore: cast_nullable_to_non_nullable
as int?,hatchingLosses: freezed == hatchingLosses ? _self.hatchingLosses : hatchingLosses // ignore: cast_nullable_to_non_nullable
as int?,hatchingKilledQuantity: freezed == hatchingKilledQuantity ? _self.hatchingKilledQuantity : hatchingKilledQuantity // ignore: cast_nullable_to_non_nullable
as int?,hatchingMaxAge: freezed == hatchingMaxAge ? _self.hatchingMaxAge : hatchingMaxAge // ignore: cast_nullable_to_non_nullable
as int?,hatchingMinAge: freezed == hatchingMinAge ? _self.hatchingMinAge : hatchingMinAge // ignore: cast_nullable_to_non_nullable
as int?,
));
}
}
// dart format on

View File

@@ -0,0 +1,33 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'home_poultry_science_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_HomePoultryScienceModel _$HomePoultryScienceModelFromJson(
Map<String, dynamic> json,
) => _HomePoultryScienceModel(
farmCount: (json['farm_count'] as num?)?.toInt(),
hatchingCount: (json['hatching_count'] as num?)?.toInt(),
hatchingQuantity: (json['hatching_quantity'] as num?)?.toInt(),
hatchingLeftOver: (json['hatching_left_over'] as num?)?.toInt(),
hatchingLosses: (json['hatching_losses'] as num?)?.toInt(),
hatchingKilledQuantity: (json['hatching_killed_quantity'] as num?)?.toInt(),
hatchingMaxAge: (json['hatching_max_age'] as num?)?.toInt(),
hatchingMinAge: (json['hatching_min_age'] as num?)?.toInt(),
);
Map<String, dynamic> _$HomePoultryScienceModelToJson(
_HomePoultryScienceModel instance,
) => <String, dynamic>{
'farm_count': instance.farmCount,
'hatching_count': instance.hatchingCount,
'hatching_quantity': instance.hatchingQuantity,
'hatching_left_over': instance.hatchingLeftOver,
'hatching_losses': instance.hatchingLosses,
'hatching_killed_quantity': instance.hatchingKilledQuantity,
'hatching_max_age': instance.hatchingMaxAge,
'hatching_min_age': instance.hatchingMinAge,
};

View File

@@ -27,6 +27,8 @@ import '../../models/request/create_steward_free_bar/create_steward_free_bar.dar
abstract class ChickenRepository {
//region Remote
//region Steward
Future<List<InventoryModel>?> getInventory({required String token, CancelToken? cancelToken});
Future<KillHouseDistributionInfo?> getKillHouseDistributionInfo({required String token});
@@ -156,6 +158,11 @@ abstract class ChickenRepository {
Future<SegmentationModel?> deleteSegmentation({required String token, required String key});
//endregion
//endregion
//region local

View File

@@ -0,0 +1,8 @@
import 'package:rasadyar_chicken/data/models/response/poultry_science/home_poultry_science/home_poultry_science_model.dart';
abstract class PoultryScienceRepository {
Future<HomePoultryScienceModel?> getHomePoultryScience({
required String token,
required String type,
});
}

View File

@@ -0,0 +1,17 @@
import 'package:rasadyar_chicken/data/data_source/remote/poultry_science/poultry_science_remote.dart';
import 'package:rasadyar_chicken/data/models/response/poultry_science/home_poultry_science/home_poultry_science_model.dart';
import 'poultry_science_repository.dart';
class PoultryScienceRepositoryImp implements PoultryScienceRepository {
final PoultryScienceRemoteDatasource datasource;
PoultryScienceRepositoryImp(this.datasource);
@override
Future<HomePoultryScienceModel?> getHomePoultryScience({
required String token,
required String type,
}) async => await datasource.getHomePoultryScience(token: token, type: type);
}