feat : latest News in module page

This commit is contained in:
2025-09-01 10:58:17 +03:30
parent 5af5d63a1e
commit c2f5e36fd7
5 changed files with 44 additions and 35 deletions

View File

@@ -5,11 +5,7 @@ part 'slider_model.g.dart';
@freezed
abstract class SliderModel with _$SliderModel {
const factory SliderModel({
List<String>? up,
List<String>? down,
}) = _SliderModel;
const factory SliderModel({List<String>? up, List<String>? down, String? middle}) = _SliderModel;
factory SliderModel.fromJson(Map<String, dynamic> json) =>
_$SliderModelFromJson(json);
factory SliderModel.fromJson(Map<String, dynamic> json) => _$SliderModelFromJson(json);
}

View File

@@ -15,7 +15,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$SliderModel {
List<String>? get up; List<String>? get down;
List<String>? get up; List<String>? get down; String? get middle;
/// Create a copy of SliderModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -28,16 +28,16 @@ $SliderModelCopyWith<SliderModel> get copyWith => _$SliderModelCopyWithImpl<Slid
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is SliderModel&&const DeepCollectionEquality().equals(other.up, up)&&const DeepCollectionEquality().equals(other.down, down));
return identical(this, other) || (other.runtimeType == runtimeType&&other is SliderModel&&const DeepCollectionEquality().equals(other.up, up)&&const DeepCollectionEquality().equals(other.down, down)&&(identical(other.middle, middle) || other.middle == middle));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(up),const DeepCollectionEquality().hash(down));
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(up),const DeepCollectionEquality().hash(down),middle);
@override
String toString() {
return 'SliderModel(up: $up, down: $down)';
return 'SliderModel(up: $up, down: $down, middle: $middle)';
}
@@ -48,7 +48,7 @@ abstract mixin class $SliderModelCopyWith<$Res> {
factory $SliderModelCopyWith(SliderModel value, $Res Function(SliderModel) _then) = _$SliderModelCopyWithImpl;
@useResult
$Res call({
List<String>? up, List<String>? down
List<String>? up, List<String>? down, String? middle
});
@@ -65,11 +65,12 @@ class _$SliderModelCopyWithImpl<$Res>
/// Create a copy of SliderModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? up = freezed,Object? down = freezed,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? up = freezed,Object? down = freezed,Object? middle = freezed,}) {
return _then(_self.copyWith(
up: freezed == up ? _self.up : up // ignore: cast_nullable_to_non_nullable
as List<String>?,down: freezed == down ? _self.down : down // ignore: cast_nullable_to_non_nullable
as List<String>?,
as List<String>?,middle: freezed == middle ? _self.middle : middle // ignore: cast_nullable_to_non_nullable
as String?,
));
}
@@ -154,10 +155,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<String>? up, List<String>? down)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<String>? up, List<String>? down, String? middle)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _SliderModel() when $default != null:
return $default(_that.up,_that.down);case _:
return $default(_that.up,_that.down,_that.middle);case _:
return orElse();
}
@@ -175,10 +176,10 @@ return $default(_that.up,_that.down);case _:
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<String>? up, List<String>? down) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<String>? up, List<String>? down, String? middle) $default,) {final _that = this;
switch (_that) {
case _SliderModel():
return $default(_that.up,_that.down);case _:
return $default(_that.up,_that.down,_that.middle);case _:
throw StateError('Unexpected subclass');
}
@@ -195,10 +196,10 @@ return $default(_that.up,_that.down);case _:
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<String>? up, List<String>? down)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<String>? up, List<String>? down, String? middle)? $default,) {final _that = this;
switch (_that) {
case _SliderModel() when $default != null:
return $default(_that.up,_that.down);case _:
return $default(_that.up,_that.down,_that.middle);case _:
return null;
}
@@ -210,7 +211,7 @@ return $default(_that.up,_that.down);case _:
@JsonSerializable()
class _SliderModel implements SliderModel {
const _SliderModel({final List<String>? up, final List<String>? down}): _up = up,_down = down;
const _SliderModel({final List<String>? up, final List<String>? down, this.middle}): _up = up,_down = down;
factory _SliderModel.fromJson(Map<String, dynamic> json) => _$SliderModelFromJson(json);
final List<String>? _up;
@@ -231,6 +232,7 @@ class _SliderModel implements SliderModel {
return EqualUnmodifiableListView(value);
}
@override final String? middle;
/// Create a copy of SliderModel
/// with the given fields replaced by the non-null parameter values.
@@ -245,16 +247,16 @@ Map<String, dynamic> toJson() {
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SliderModel&&const DeepCollectionEquality().equals(other._up, _up)&&const DeepCollectionEquality().equals(other._down, _down));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SliderModel&&const DeepCollectionEquality().equals(other._up, _up)&&const DeepCollectionEquality().equals(other._down, _down)&&(identical(other.middle, middle) || other.middle == middle));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_up),const DeepCollectionEquality().hash(_down));
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_up),const DeepCollectionEquality().hash(_down),middle);
@override
String toString() {
return 'SliderModel(up: $up, down: $down)';
return 'SliderModel(up: $up, down: $down, middle: $middle)';
}
@@ -265,7 +267,7 @@ abstract mixin class _$SliderModelCopyWith<$Res> implements $SliderModelCopyWith
factory _$SliderModelCopyWith(_SliderModel value, $Res Function(_SliderModel) _then) = __$SliderModelCopyWithImpl;
@override @useResult
$Res call({
List<String>? up, List<String>? down
List<String>? up, List<String>? down, String? middle
});
@@ -282,11 +284,12 @@ class __$SliderModelCopyWithImpl<$Res>
/// Create a copy of SliderModel
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? up = freezed,Object? down = freezed,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? up = freezed,Object? down = freezed,Object? middle = freezed,}) {
return _then(_SliderModel(
up: freezed == up ? _self._up : up // ignore: cast_nullable_to_non_nullable
as List<String>?,down: freezed == down ? _self._down : down // ignore: cast_nullable_to_non_nullable
as List<String>?,
as List<String>?,middle: freezed == middle ? _self.middle : middle // ignore: cast_nullable_to_non_nullable
as String?,
));
}

View File

@@ -9,7 +9,12 @@ part of 'slider_model.dart';
_SliderModel _$SliderModelFromJson(Map<String, dynamic> json) => _SliderModel(
up: (json['up'] as List<dynamic>?)?.map((e) => e as String).toList(),
down: (json['down'] as List<dynamic>?)?.map((e) => e as String).toList(),
middle: json['middle'] as String?,
);
Map<String, dynamic> _$SliderModelToJson(_SliderModel instance) =>
<String, dynamic>{'up': instance.up, 'down': instance.down};
<String, dynamic>{
'up': instance.up,
'down': instance.down,
'middle': instance.middle,
};

View File

@@ -7,6 +7,7 @@ class ModulesLogic extends GetxController {
TokenStorageService tokenService = Get.find<TokenStorageService>();
SliderLogic upSlider = Get.find<SliderLogic>(tag: "up");
SliderLogic downSlider = Get.find<SliderLogic>(tag: "down");
RxnString latestNews = RxnString();
RxBool isLoading = false.obs;
List<ModuleModel> moduleList = [
@@ -125,6 +126,7 @@ class ModulesLogic extends GetxController {
SliderModel sliderModel = SliderModel.fromJson(res.data);
upSlider.onSuccess(sliderModel.up ?? []);
downSlider.onSuccess(sliderModel.down ?? []);
latestNews.value = sliderModel.middle;
}
}
}

View File

@@ -84,15 +84,18 @@ class ModulesPage extends GetView<ModulesLogic> {
height: 1.90,
),
),
Text(
'اخبار مربوط به جوجه ریزی استان از آخرین روند مطلع شوید اخبار مربوط به جوجه ریزی استان از ',
maxLines: 2,
style: AppFonts.yekan12.copyWith(
color: Color(0xFF5B5B5B),
height: 1.5,
overflow: TextOverflow.ellipsis,
ObxValue(
(data) => Text(
data.value ??
'اخبار مربوط به جوجه ریزی استان از آخرین روند مطلع شوید...',
maxLines: 2,
style: AppFonts.yekan12.copyWith(
color: Color(0xFF5B5B5B),
height: 1.5,
overflow: TextOverflow.ellipsis,
),
),
controller.latestNews,
),
],
),