diff --git a/lib/data/model/response/slider/slider_model.dart b/lib/data/model/response/slider/slider_model.dart index ee7832a..da64c8c 100644 --- a/lib/data/model/response/slider/slider_model.dart +++ b/lib/data/model/response/slider/slider_model.dart @@ -5,11 +5,7 @@ part 'slider_model.g.dart'; @freezed abstract class SliderModel with _$SliderModel { - const factory SliderModel({ - List? up, - List? down, - }) = _SliderModel; + const factory SliderModel({List? up, List? down, String? middle}) = _SliderModel; - factory SliderModel.fromJson(Map json) => - _$SliderModelFromJson(json); + factory SliderModel.fromJson(Map json) => _$SliderModelFromJson(json); } diff --git a/lib/data/model/response/slider/slider_model.freezed.dart b/lib/data/model/response/slider/slider_model.freezed.dart index ff8f57a..225749e 100644 --- a/lib/data/model/response/slider/slider_model.freezed.dart +++ b/lib/data/model/response/slider/slider_model.freezed.dart @@ -15,7 +15,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$SliderModel { - List? get up; List? get down; + List? get up; List? 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 get copyWith => _$SliderModelCopyWithImpl 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? up, List? down + List? up, List? 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?,down: freezed == down ? _self.down : down // ignore: cast_nullable_to_non_nullable -as List?, +as List?,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 Function( List? up, List? down)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( List? up, List? 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 Function( List? up, List? down) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( List? up, List? 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? Function( List? up, List? down)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( List? up, List? 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? up, final List? down}): _up = up,_down = down; + const _SliderModel({final List? up, final List? down, this.middle}): _up = up,_down = down; factory _SliderModel.fromJson(Map json) => _$SliderModelFromJson(json); final List? _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 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? up, List? down + List? up, List? 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?,down: freezed == down ? _self._down : down // ignore: cast_nullable_to_non_nullable -as List?, +as List?,middle: freezed == middle ? _self.middle : middle // ignore: cast_nullable_to_non_nullable +as String?, )); } diff --git a/lib/data/model/response/slider/slider_model.g.dart b/lib/data/model/response/slider/slider_model.g.dart index bd1d453..3fb67f0 100644 --- a/lib/data/model/response/slider/slider_model.g.dart +++ b/lib/data/model/response/slider/slider_model.g.dart @@ -9,7 +9,12 @@ part of 'slider_model.dart'; _SliderModel _$SliderModelFromJson(Map json) => _SliderModel( up: (json['up'] as List?)?.map((e) => e as String).toList(), down: (json['down'] as List?)?.map((e) => e as String).toList(), + middle: json['middle'] as String?, ); Map _$SliderModelToJson(_SliderModel instance) => - {'up': instance.up, 'down': instance.down}; + { + 'up': instance.up, + 'down': instance.down, + 'middle': instance.middle, + }; diff --git a/lib/presentation/pages/modules/logic.dart b/lib/presentation/pages/modules/logic.dart index 906f7fc..5efc079 100644 --- a/lib/presentation/pages/modules/logic.dart +++ b/lib/presentation/pages/modules/logic.dart @@ -7,6 +7,7 @@ class ModulesLogic extends GetxController { TokenStorageService tokenService = Get.find(); SliderLogic upSlider = Get.find(tag: "up"); SliderLogic downSlider = Get.find(tag: "down"); + RxnString latestNews = RxnString(); RxBool isLoading = false.obs; List 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; } } } diff --git a/lib/presentation/pages/modules/view.dart b/lib/presentation/pages/modules/view.dart index 8dda9d2..830bd57 100644 --- a/lib/presentation/pages/modules/view.dart +++ b/lib/presentation/pages/modules/view.dart @@ -84,15 +84,18 @@ class ModulesPage extends GetView { 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, ), ], ),