From fa974bc4a2ecc54d11043c6776c9c92a878c3f30 Mon Sep 17 00:00:00 2001 From: llsajjad Date: Sat, 27 Sep 2025 13:02:12 +0330 Subject: [PATCH 1/2] added new response data from notifications api --- .../notification_response_model.dart | 35 +- .../notification_response_model.freezed.dart | 473 +++++++++++-- .../notification_response_model.g.dart | 62 +- .../notification_data/notification_data.dart | 46 -- .../notification_data.freezed.dart | 645 ------------------ .../notification_data.g.dart | 71 -- .../notification_recipient.dart | 38 ++ .../notification_recipient.freezed.dart | 584 ++++++++++++++++ .../notification_recipient.g.dart | 49 ++ lib/view_models/notification_view_model.dart | 60 +- .../pages/m_notification_page.dart | 4 +- .../widgets/notification_all_tab.dart | 2 +- .../widgets/notification_card.dart | 4 +- .../widgets/notification_important_tab.dart | 4 +- .../widgets/notification_unread_tab.dart | 2 +- pubspec.lock | 16 +- 16 files changed, 1226 insertions(+), 869 deletions(-) delete mode 100644 lib/data/services/model/notification_data/notification_data.dart delete mode 100644 lib/data/services/model/notification_data/notification_data.freezed.dart delete mode 100644 lib/data/services/model/notification_data/notification_data.g.dart create mode 100644 lib/data/services/model/notification_data/notification_recipient.dart create mode 100644 lib/data/services/model/notification_data/notification_recipient.freezed.dart create mode 100644 lib/data/services/model/notification_data/notification_recipient.g.dart diff --git a/lib/data/services/model/notification__response/notification_response_model.dart b/lib/data/services/model/notification__response/notification_response_model.dart index ea41993..94a5b0a 100644 --- a/lib/data/services/model/notification__response/notification_response_model.dart +++ b/lib/data/services/model/notification__response/notification_response_model.dart @@ -2,7 +2,8 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:tm_app/data/services/model/error/error_model.dart'; -import 'package:tm_app/data/services/model/notification_data/notification_data.dart'; +import 'package:tm_app/data/services/model/meta/meta.dart'; +import 'package:tm_app/data/services/model/notification_data/notification_recipient.dart'; part 'notification_response_model.freezed.dart'; part 'notification_response_model.g.dart'; @@ -12,10 +13,40 @@ abstract class NotificationResponseModel with _$NotificationResponseModel { const factory NotificationResponseModel({ required bool? success, required String? message, - required NotificationData? data, + required List? data, required ErrorModel? error, + required Meta? meta, }) = _NotificationResponseModel; factory NotificationResponseModel.fromJson(Map json) => _$NotificationResponseModelFromJson(json); } + +@freezed +abstract class NotificationItem with _$NotificationItem { + const factory NotificationItem({ + required String? id, + @JsonKey(name: 'user_id') required String? userId, + required Recipient? recipient, + required String? title, + required String? message, + required String? link, + required String? image, + required String? priority, + required String? type, + @JsonKey(name: 'event_type') required String? eventType, + required String? status, + required Map? methods, + required Map? metadata, + @JsonKey(name: 'schedule_at') required int? scheduleAt, + @JsonKey(name: 'created_at') required int? createdAt, + @JsonKey(name: 'updated_at') required int? updatedAt, + required bool? seen, + @JsonKey(name: 'seen_at') required int? seenAt, + @JsonKey(name: 'is_scheduled') required bool? isScheduled, + @JsonKey(name: 'scheduled_at') required int? scheduledAt, + }) = _NotificationItem; + + factory NotificationItem.fromJson(Map json) => + _$NotificationItemFromJson(json); +} diff --git a/lib/data/services/model/notification__response/notification_response_model.freezed.dart b/lib/data/services/model/notification__response/notification_response_model.freezed.dart index 4e576b6..22ef060 100644 --- a/lib/data/services/model/notification__response/notification_response_model.freezed.dart +++ b/lib/data/services/model/notification__response/notification_response_model.freezed.dart @@ -15,7 +15,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$NotificationResponseModel { - bool? get success; String? get message; NotificationData? get data; ErrorModel? get error; + bool? get success; String? get message; List? get data; ErrorModel? get error; Meta? get meta; /// Create a copy of NotificationResponseModel /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -28,16 +28,16 @@ $NotificationResponseModelCopyWith get copyWith => _$ @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is NotificationResponseModel&&(identical(other.success, success) || other.success == success)&&(identical(other.message, message) || other.message == message)&&(identical(other.data, data) || other.data == data)&&(identical(other.error, error) || other.error == error)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is NotificationResponseModel&&(identical(other.success, success) || other.success == success)&&(identical(other.message, message) || other.message == message)&&const DeepCollectionEquality().equals(other.data, data)&&(identical(other.error, error) || other.error == error)&&(identical(other.meta, meta) || other.meta == meta)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,success,message,data,error); +int get hashCode => Object.hash(runtimeType,success,message,const DeepCollectionEquality().hash(data),error,meta); @override String toString() { - return 'NotificationResponseModel(success: $success, message: $message, data: $data, error: $error)'; + return 'NotificationResponseModel(success: $success, message: $message, data: $data, error: $error, meta: $meta)'; } @@ -48,11 +48,11 @@ abstract mixin class $NotificationResponseModelCopyWith<$Res> { factory $NotificationResponseModelCopyWith(NotificationResponseModel value, $Res Function(NotificationResponseModel) _then) = _$NotificationResponseModelCopyWithImpl; @useResult $Res call({ - bool? success, String? message, NotificationData? data, ErrorModel? error + bool? success, String? message, List? data, ErrorModel? error, Meta? meta }); -$NotificationDataCopyWith<$Res>? get data;$ErrorModelCopyWith<$Res>? get error; +$ErrorModelCopyWith<$Res>? get error;$MetaCopyWith<$Res>? get meta; } /// @nodoc @@ -65,31 +65,20 @@ class _$NotificationResponseModelCopyWithImpl<$Res> /// Create a copy of NotificationResponseModel /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? success = freezed,Object? message = freezed,Object? data = freezed,Object? error = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? success = freezed,Object? message = freezed,Object? data = freezed,Object? error = freezed,Object? meta = freezed,}) { return _then(_self.copyWith( success: freezed == success ? _self.success : success // ignore: cast_nullable_to_non_nullable as bool?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable as String?,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable -as NotificationData?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable -as ErrorModel?, +as List?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable +as ErrorModel?,meta: freezed == meta ? _self.meta : meta // ignore: cast_nullable_to_non_nullable +as Meta?, )); } /// Create a copy of NotificationResponseModel /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') -$NotificationDataCopyWith<$Res>? get data { - if (_self.data == null) { - return null; - } - - return $NotificationDataCopyWith<$Res>(_self.data!, (value) { - return _then(_self.copyWith(data: value)); - }); -}/// Create a copy of NotificationResponseModel -/// with the given fields replaced by the non-null parameter values. -@override -@pragma('vm:prefer-inline') $ErrorModelCopyWith<$Res>? get error { if (_self.error == null) { return null; @@ -98,6 +87,18 @@ $ErrorModelCopyWith<$Res>? get error { return $ErrorModelCopyWith<$Res>(_self.error!, (value) { return _then(_self.copyWith(error: value)); }); +}/// Create a copy of NotificationResponseModel +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$MetaCopyWith<$Res>? get meta { + if (_self.meta == null) { + return null; + } + + return $MetaCopyWith<$Res>(_self.meta!, (value) { + return _then(_self.copyWith(meta: value)); + }); } } @@ -180,10 +181,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( bool? success, String? message, NotificationData? data, ErrorModel? error)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( bool? success, String? message, List? data, ErrorModel? error, Meta? meta)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _NotificationResponseModel() when $default != null: -return $default(_that.success,_that.message,_that.data,_that.error);case _: +return $default(_that.success,_that.message,_that.data,_that.error,_that.meta);case _: return orElse(); } @@ -201,10 +202,10 @@ return $default(_that.success,_that.message,_that.data,_that.error);case _: /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( bool? success, String? message, NotificationData? data, ErrorModel? error) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( bool? success, String? message, List? data, ErrorModel? error, Meta? meta) $default,) {final _that = this; switch (_that) { case _NotificationResponseModel(): -return $default(_that.success,_that.message,_that.data,_that.error);case _: +return $default(_that.success,_that.message,_that.data,_that.error,_that.meta);case _: throw StateError('Unexpected subclass'); } @@ -221,10 +222,10 @@ return $default(_that.success,_that.message,_that.data,_that.error);case _: /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( bool? success, String? message, NotificationData? data, ErrorModel? error)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( bool? success, String? message, List? data, ErrorModel? error, Meta? meta)? $default,) {final _that = this; switch (_that) { case _NotificationResponseModel() when $default != null: -return $default(_that.success,_that.message,_that.data,_that.error);case _: +return $default(_that.success,_that.message,_that.data,_that.error,_that.meta);case _: return null; } @@ -236,13 +237,22 @@ return $default(_that.success,_that.message,_that.data,_that.error);case _: @JsonSerializable() class _NotificationResponseModel implements NotificationResponseModel { - const _NotificationResponseModel({required this.success, required this.message, required this.data, required this.error}); + const _NotificationResponseModel({required this.success, required this.message, required final List? data, required this.error, required this.meta}): _data = data; factory _NotificationResponseModel.fromJson(Map json) => _$NotificationResponseModelFromJson(json); @override final bool? success; @override final String? message; -@override final NotificationData? data; + final List? _data; +@override List? get data { + final value = _data; + if (value == null) return null; + if (_data is EqualUnmodifiableListView) return _data; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); +} + @override final ErrorModel? error; +@override final Meta? meta; /// Create a copy of NotificationResponseModel /// with the given fields replaced by the non-null parameter values. @@ -257,16 +267,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _NotificationResponseModel&&(identical(other.success, success) || other.success == success)&&(identical(other.message, message) || other.message == message)&&(identical(other.data, data) || other.data == data)&&(identical(other.error, error) || other.error == error)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _NotificationResponseModel&&(identical(other.success, success) || other.success == success)&&(identical(other.message, message) || other.message == message)&&const DeepCollectionEquality().equals(other._data, _data)&&(identical(other.error, error) || other.error == error)&&(identical(other.meta, meta) || other.meta == meta)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,success,message,data,error); +int get hashCode => Object.hash(runtimeType,success,message,const DeepCollectionEquality().hash(_data),error,meta); @override String toString() { - return 'NotificationResponseModel(success: $success, message: $message, data: $data, error: $error)'; + return 'NotificationResponseModel(success: $success, message: $message, data: $data, error: $error, meta: $meta)'; } @@ -277,11 +287,11 @@ abstract mixin class _$NotificationResponseModelCopyWith<$Res> implements $Notif factory _$NotificationResponseModelCopyWith(_NotificationResponseModel value, $Res Function(_NotificationResponseModel) _then) = __$NotificationResponseModelCopyWithImpl; @override @useResult $Res call({ - bool? success, String? message, NotificationData? data, ErrorModel? error + bool? success, String? message, List? data, ErrorModel? error, Meta? meta }); -@override $NotificationDataCopyWith<$Res>? get data;@override $ErrorModelCopyWith<$Res>? get error; +@override $ErrorModelCopyWith<$Res>? get error;@override $MetaCopyWith<$Res>? get meta; } /// @nodoc @@ -294,13 +304,14 @@ class __$NotificationResponseModelCopyWithImpl<$Res> /// Create a copy of NotificationResponseModel /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? success = freezed,Object? message = freezed,Object? data = freezed,Object? error = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? success = freezed,Object? message = freezed,Object? data = freezed,Object? error = freezed,Object? meta = freezed,}) { return _then(_NotificationResponseModel( success: freezed == success ? _self.success : success // ignore: cast_nullable_to_non_nullable as bool?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable -as String?,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable -as NotificationData?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable -as ErrorModel?, +as String?,data: freezed == data ? _self._data : data // ignore: cast_nullable_to_non_nullable +as List?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable +as ErrorModel?,meta: freezed == meta ? _self.meta : meta // ignore: cast_nullable_to_non_nullable +as Meta?, )); } @@ -308,18 +319,6 @@ as ErrorModel?, /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') -$NotificationDataCopyWith<$Res>? get data { - if (_self.data == null) { - return null; - } - - return $NotificationDataCopyWith<$Res>(_self.data!, (value) { - return _then(_self.copyWith(data: value)); - }); -}/// Create a copy of NotificationResponseModel -/// with the given fields replaced by the non-null parameter values. -@override -@pragma('vm:prefer-inline') $ErrorModelCopyWith<$Res>? get error { if (_self.error == null) { return null; @@ -328,6 +327,380 @@ $ErrorModelCopyWith<$Res>? get error { return $ErrorModelCopyWith<$Res>(_self.error!, (value) { return _then(_self.copyWith(error: value)); }); +}/// Create a copy of NotificationResponseModel +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$MetaCopyWith<$Res>? get meta { + if (_self.meta == null) { + return null; + } + + return $MetaCopyWith<$Res>(_self.meta!, (value) { + return _then(_self.copyWith(meta: value)); + }); +} +} + + +/// @nodoc +mixin _$NotificationItem { + + String? get id;@JsonKey(name: 'user_id') String? get userId; Recipient? get recipient;// ✅ اضافه شد + String? get title; String? get message; String? get link; String? get image; String? get priority; String? get type;@JsonKey(name: 'event_type') String? get eventType; String? get status; Map? get methods; Map? get metadata;@JsonKey(name: 'schedule_at') int? get scheduleAt;@JsonKey(name: 'created_at') int? get createdAt;@JsonKey(name: 'updated_at') int? get updatedAt; bool? get seen;@JsonKey(name: 'seen_at') int? get seenAt;@JsonKey(name: 'is_scheduled') bool? get isScheduled;@JsonKey(name: 'scheduled_at') int? get scheduledAt; +/// Create a copy of NotificationItem +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$NotificationItemCopyWith get copyWith => _$NotificationItemCopyWithImpl(this as NotificationItem, _$identity); + + /// Serializes this NotificationItem to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is NotificationItem&&(identical(other.id, id) || other.id == id)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.recipient, recipient) || other.recipient == recipient)&&(identical(other.title, title) || other.title == title)&&(identical(other.message, message) || other.message == message)&&(identical(other.link, link) || other.link == link)&&(identical(other.image, image) || other.image == image)&&(identical(other.priority, priority) || other.priority == priority)&&(identical(other.type, type) || other.type == type)&&(identical(other.eventType, eventType) || other.eventType == eventType)&&(identical(other.status, status) || other.status == status)&&const DeepCollectionEquality().equals(other.methods, methods)&&const DeepCollectionEquality().equals(other.metadata, metadata)&&(identical(other.scheduleAt, scheduleAt) || other.scheduleAt == scheduleAt)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.seen, seen) || other.seen == seen)&&(identical(other.seenAt, seenAt) || other.seenAt == seenAt)&&(identical(other.isScheduled, isScheduled) || other.isScheduled == isScheduled)&&(identical(other.scheduledAt, scheduledAt) || other.scheduledAt == scheduledAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hashAll([runtimeType,id,userId,recipient,title,message,link,image,priority,type,eventType,status,const DeepCollectionEquality().hash(methods),const DeepCollectionEquality().hash(metadata),scheduleAt,createdAt,updatedAt,seen,seenAt,isScheduled,scheduledAt]); + +@override +String toString() { + return 'NotificationItem(id: $id, userId: $userId, recipient: $recipient, title: $title, message: $message, link: $link, image: $image, priority: $priority, type: $type, eventType: $eventType, status: $status, methods: $methods, metadata: $metadata, scheduleAt: $scheduleAt, createdAt: $createdAt, updatedAt: $updatedAt, seen: $seen, seenAt: $seenAt, isScheduled: $isScheduled, scheduledAt: $scheduledAt)'; +} + + +} + +/// @nodoc +abstract mixin class $NotificationItemCopyWith<$Res> { + factory $NotificationItemCopyWith(NotificationItem value, $Res Function(NotificationItem) _then) = _$NotificationItemCopyWithImpl; +@useResult +$Res call({ + String? id,@JsonKey(name: 'user_id') String? userId, Recipient? recipient, String? title, String? message, String? link, String? image, String? priority, String? type,@JsonKey(name: 'event_type') String? eventType, String? status, Map? methods, Map? metadata,@JsonKey(name: 'schedule_at') int? scheduleAt,@JsonKey(name: 'created_at') int? createdAt,@JsonKey(name: 'updated_at') int? updatedAt, bool? seen,@JsonKey(name: 'seen_at') int? seenAt,@JsonKey(name: 'is_scheduled') bool? isScheduled,@JsonKey(name: 'scheduled_at') int? scheduledAt +}); + + +$RecipientCopyWith<$Res>? get recipient; + +} +/// @nodoc +class _$NotificationItemCopyWithImpl<$Res> + implements $NotificationItemCopyWith<$Res> { + _$NotificationItemCopyWithImpl(this._self, this._then); + + final NotificationItem _self; + final $Res Function(NotificationItem) _then; + +/// Create a copy of NotificationItem +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? userId = freezed,Object? recipient = freezed,Object? title = freezed,Object? message = freezed,Object? link = freezed,Object? image = freezed,Object? priority = freezed,Object? type = freezed,Object? eventType = freezed,Object? status = freezed,Object? methods = freezed,Object? metadata = freezed,Object? scheduleAt = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,Object? seen = freezed,Object? seenAt = freezed,Object? isScheduled = freezed,Object? scheduledAt = freezed,}) { + return _then(_self.copyWith( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable +as String?,recipient: freezed == recipient ? _self.recipient : recipient // ignore: cast_nullable_to_non_nullable +as Recipient?,title: freezed == title ? _self.title : title // ignore: cast_nullable_to_non_nullable +as String?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String?,link: freezed == link ? _self.link : link // ignore: cast_nullable_to_non_nullable +as String?,image: freezed == image ? _self.image : image // ignore: cast_nullable_to_non_nullable +as String?,priority: freezed == priority ? _self.priority : priority // ignore: cast_nullable_to_non_nullable +as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as String?,eventType: freezed == eventType ? _self.eventType : eventType // ignore: cast_nullable_to_non_nullable +as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String?,methods: freezed == methods ? _self.methods : methods // ignore: cast_nullable_to_non_nullable +as Map?,metadata: freezed == metadata ? _self.metadata : metadata // ignore: cast_nullable_to_non_nullable +as Map?,scheduleAt: freezed == scheduleAt ? _self.scheduleAt : scheduleAt // ignore: cast_nullable_to_non_nullable +as int?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as int?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable +as int?,seen: freezed == seen ? _self.seen : seen // ignore: cast_nullable_to_non_nullable +as bool?,seenAt: freezed == seenAt ? _self.seenAt : seenAt // ignore: cast_nullable_to_non_nullable +as int?,isScheduled: freezed == isScheduled ? _self.isScheduled : isScheduled // ignore: cast_nullable_to_non_nullable +as bool?,scheduledAt: freezed == scheduledAt ? _self.scheduledAt : scheduledAt // ignore: cast_nullable_to_non_nullable +as int?, + )); +} +/// Create a copy of NotificationItem +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$RecipientCopyWith<$Res>? get recipient { + if (_self.recipient == null) { + return null; + } + + return $RecipientCopyWith<$Res>(_self.recipient!, (value) { + return _then(_self.copyWith(recipient: value)); + }); +} +} + + +/// Adds pattern-matching-related methods to [NotificationItem]. +extension NotificationItemPatterns on NotificationItem { +/// 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 Function( _NotificationItem value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _NotificationItem() 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 Function( _NotificationItem value) $default,){ +final _that = this; +switch (_that) { +case _NotificationItem(): +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? Function( _NotificationItem value)? $default,){ +final _that = this; +switch (_that) { +case _NotificationItem() 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 Function( String? id, @JsonKey(name: 'user_id') String? userId, Recipient? recipient, String? title, String? message, String? link, String? image, String? priority, String? type, @JsonKey(name: 'event_type') String? eventType, String? status, Map? methods, Map? metadata, @JsonKey(name: 'schedule_at') int? scheduleAt, @JsonKey(name: 'created_at') int? createdAt, @JsonKey(name: 'updated_at') int? updatedAt, bool? seen, @JsonKey(name: 'seen_at') int? seenAt, @JsonKey(name: 'is_scheduled') bool? isScheduled, @JsonKey(name: 'scheduled_at') int? scheduledAt)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _NotificationItem() when $default != null: +return $default(_that.id,_that.userId,_that.recipient,_that.title,_that.message,_that.link,_that.image,_that.priority,_that.type,_that.eventType,_that.status,_that.methods,_that.metadata,_that.scheduleAt,_that.createdAt,_that.updatedAt,_that.seen,_that.seenAt,_that.isScheduled,_that.scheduledAt);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 Function( String? id, @JsonKey(name: 'user_id') String? userId, Recipient? recipient, String? title, String? message, String? link, String? image, String? priority, String? type, @JsonKey(name: 'event_type') String? eventType, String? status, Map? methods, Map? metadata, @JsonKey(name: 'schedule_at') int? scheduleAt, @JsonKey(name: 'created_at') int? createdAt, @JsonKey(name: 'updated_at') int? updatedAt, bool? seen, @JsonKey(name: 'seen_at') int? seenAt, @JsonKey(name: 'is_scheduled') bool? isScheduled, @JsonKey(name: 'scheduled_at') int? scheduledAt) $default,) {final _that = this; +switch (_that) { +case _NotificationItem(): +return $default(_that.id,_that.userId,_that.recipient,_that.title,_that.message,_that.link,_that.image,_that.priority,_that.type,_that.eventType,_that.status,_that.methods,_that.metadata,_that.scheduleAt,_that.createdAt,_that.updatedAt,_that.seen,_that.seenAt,_that.isScheduled,_that.scheduledAt);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? Function( String? id, @JsonKey(name: 'user_id') String? userId, Recipient? recipient, String? title, String? message, String? link, String? image, String? priority, String? type, @JsonKey(name: 'event_type') String? eventType, String? status, Map? methods, Map? metadata, @JsonKey(name: 'schedule_at') int? scheduleAt, @JsonKey(name: 'created_at') int? createdAt, @JsonKey(name: 'updated_at') int? updatedAt, bool? seen, @JsonKey(name: 'seen_at') int? seenAt, @JsonKey(name: 'is_scheduled') bool? isScheduled, @JsonKey(name: 'scheduled_at') int? scheduledAt)? $default,) {final _that = this; +switch (_that) { +case _NotificationItem() when $default != null: +return $default(_that.id,_that.userId,_that.recipient,_that.title,_that.message,_that.link,_that.image,_that.priority,_that.type,_that.eventType,_that.status,_that.methods,_that.metadata,_that.scheduleAt,_that.createdAt,_that.updatedAt,_that.seen,_that.seenAt,_that.isScheduled,_that.scheduledAt);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _NotificationItem implements NotificationItem { + const _NotificationItem({required this.id, @JsonKey(name: 'user_id') required this.userId, required this.recipient, required this.title, required this.message, required this.link, required this.image, required this.priority, required this.type, @JsonKey(name: 'event_type') required this.eventType, required this.status, required final Map? methods, required final Map? metadata, @JsonKey(name: 'schedule_at') required this.scheduleAt, @JsonKey(name: 'created_at') required this.createdAt, @JsonKey(name: 'updated_at') required this.updatedAt, required this.seen, @JsonKey(name: 'seen_at') required this.seenAt, @JsonKey(name: 'is_scheduled') required this.isScheduled, @JsonKey(name: 'scheduled_at') required this.scheduledAt}): _methods = methods,_metadata = metadata; + factory _NotificationItem.fromJson(Map json) => _$NotificationItemFromJson(json); + +@override final String? id; +@override@JsonKey(name: 'user_id') final String? userId; +@override final Recipient? recipient; +// ✅ اضافه شد +@override final String? title; +@override final String? message; +@override final String? link; +@override final String? image; +@override final String? priority; +@override final String? type; +@override@JsonKey(name: 'event_type') final String? eventType; +@override final String? status; + final Map? _methods; +@override Map? get methods { + final value = _methods; + if (value == null) return null; + if (_methods is EqualUnmodifiableMapView) return _methods; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); +} + + final Map? _metadata; +@override Map? get metadata { + final value = _metadata; + if (value == null) return null; + if (_metadata is EqualUnmodifiableMapView) return _metadata; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); +} + +@override@JsonKey(name: 'schedule_at') final int? scheduleAt; +@override@JsonKey(name: 'created_at') final int? createdAt; +@override@JsonKey(name: 'updated_at') final int? updatedAt; +@override final bool? seen; +@override@JsonKey(name: 'seen_at') final int? seenAt; +@override@JsonKey(name: 'is_scheduled') final bool? isScheduled; +@override@JsonKey(name: 'scheduled_at') final int? scheduledAt; + +/// Create a copy of NotificationItem +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$NotificationItemCopyWith<_NotificationItem> get copyWith => __$NotificationItemCopyWithImpl<_NotificationItem>(this, _$identity); + +@override +Map toJson() { + return _$NotificationItemToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _NotificationItem&&(identical(other.id, id) || other.id == id)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.recipient, recipient) || other.recipient == recipient)&&(identical(other.title, title) || other.title == title)&&(identical(other.message, message) || other.message == message)&&(identical(other.link, link) || other.link == link)&&(identical(other.image, image) || other.image == image)&&(identical(other.priority, priority) || other.priority == priority)&&(identical(other.type, type) || other.type == type)&&(identical(other.eventType, eventType) || other.eventType == eventType)&&(identical(other.status, status) || other.status == status)&&const DeepCollectionEquality().equals(other._methods, _methods)&&const DeepCollectionEquality().equals(other._metadata, _metadata)&&(identical(other.scheduleAt, scheduleAt) || other.scheduleAt == scheduleAt)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.seen, seen) || other.seen == seen)&&(identical(other.seenAt, seenAt) || other.seenAt == seenAt)&&(identical(other.isScheduled, isScheduled) || other.isScheduled == isScheduled)&&(identical(other.scheduledAt, scheduledAt) || other.scheduledAt == scheduledAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hashAll([runtimeType,id,userId,recipient,title,message,link,image,priority,type,eventType,status,const DeepCollectionEquality().hash(_methods),const DeepCollectionEquality().hash(_metadata),scheduleAt,createdAt,updatedAt,seen,seenAt,isScheduled,scheduledAt]); + +@override +String toString() { + return 'NotificationItem(id: $id, userId: $userId, recipient: $recipient, title: $title, message: $message, link: $link, image: $image, priority: $priority, type: $type, eventType: $eventType, status: $status, methods: $methods, metadata: $metadata, scheduleAt: $scheduleAt, createdAt: $createdAt, updatedAt: $updatedAt, seen: $seen, seenAt: $seenAt, isScheduled: $isScheduled, scheduledAt: $scheduledAt)'; +} + + +} + +/// @nodoc +abstract mixin class _$NotificationItemCopyWith<$Res> implements $NotificationItemCopyWith<$Res> { + factory _$NotificationItemCopyWith(_NotificationItem value, $Res Function(_NotificationItem) _then) = __$NotificationItemCopyWithImpl; +@override @useResult +$Res call({ + String? id,@JsonKey(name: 'user_id') String? userId, Recipient? recipient, String? title, String? message, String? link, String? image, String? priority, String? type,@JsonKey(name: 'event_type') String? eventType, String? status, Map? methods, Map? metadata,@JsonKey(name: 'schedule_at') int? scheduleAt,@JsonKey(name: 'created_at') int? createdAt,@JsonKey(name: 'updated_at') int? updatedAt, bool? seen,@JsonKey(name: 'seen_at') int? seenAt,@JsonKey(name: 'is_scheduled') bool? isScheduled,@JsonKey(name: 'scheduled_at') int? scheduledAt +}); + + +@override $RecipientCopyWith<$Res>? get recipient; + +} +/// @nodoc +class __$NotificationItemCopyWithImpl<$Res> + implements _$NotificationItemCopyWith<$Res> { + __$NotificationItemCopyWithImpl(this._self, this._then); + + final _NotificationItem _self; + final $Res Function(_NotificationItem) _then; + +/// Create a copy of NotificationItem +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? userId = freezed,Object? recipient = freezed,Object? title = freezed,Object? message = freezed,Object? link = freezed,Object? image = freezed,Object? priority = freezed,Object? type = freezed,Object? eventType = freezed,Object? status = freezed,Object? methods = freezed,Object? metadata = freezed,Object? scheduleAt = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,Object? seen = freezed,Object? seenAt = freezed,Object? isScheduled = freezed,Object? scheduledAt = freezed,}) { + return _then(_NotificationItem( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable +as String?,recipient: freezed == recipient ? _self.recipient : recipient // ignore: cast_nullable_to_non_nullable +as Recipient?,title: freezed == title ? _self.title : title // ignore: cast_nullable_to_non_nullable +as String?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String?,link: freezed == link ? _self.link : link // ignore: cast_nullable_to_non_nullable +as String?,image: freezed == image ? _self.image : image // ignore: cast_nullable_to_non_nullable +as String?,priority: freezed == priority ? _self.priority : priority // ignore: cast_nullable_to_non_nullable +as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as String?,eventType: freezed == eventType ? _self.eventType : eventType // ignore: cast_nullable_to_non_nullable +as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String?,methods: freezed == methods ? _self._methods : methods // ignore: cast_nullable_to_non_nullable +as Map?,metadata: freezed == metadata ? _self._metadata : metadata // ignore: cast_nullable_to_non_nullable +as Map?,scheduleAt: freezed == scheduleAt ? _self.scheduleAt : scheduleAt // ignore: cast_nullable_to_non_nullable +as int?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as int?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable +as int?,seen: freezed == seen ? _self.seen : seen // ignore: cast_nullable_to_non_nullable +as bool?,seenAt: freezed == seenAt ? _self.seenAt : seenAt // ignore: cast_nullable_to_non_nullable +as int?,isScheduled: freezed == isScheduled ? _self.isScheduled : isScheduled // ignore: cast_nullable_to_non_nullable +as bool?,scheduledAt: freezed == scheduledAt ? _self.scheduledAt : scheduledAt // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + +/// Create a copy of NotificationItem +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$RecipientCopyWith<$Res>? get recipient { + if (_self.recipient == null) { + return null; + } + + return $RecipientCopyWith<$Res>(_self.recipient!, (value) { + return _then(_self.copyWith(recipient: value)); + }); } } diff --git a/lib/data/services/model/notification__response/notification_response_model.g.dart b/lib/data/services/model/notification__response/notification_response_model.g.dart index a5fe2f3..83c2ef4 100644 --- a/lib/data/services/model/notification__response/notification_response_model.g.dart +++ b/lib/data/services/model/notification__response/notification_response_model.g.dart @@ -12,13 +12,17 @@ _NotificationResponseModel _$NotificationResponseModelFromJson( success: json['success'] as bool?, message: json['message'] as String?, data: - json['data'] == null - ? null - : NotificationData.fromJson(json['data'] as Map), + (json['data'] as List?) + ?.map((e) => NotificationItem.fromJson(e as Map)) + .toList(), error: json['error'] == null ? null : ErrorModel.fromJson(json['error'] as Map), + meta: + json['meta'] == null + ? null + : Meta.fromJson(json['meta'] as Map), ); Map _$NotificationResponseModelToJson( @@ -28,4 +32,56 @@ Map _$NotificationResponseModelToJson( 'message': instance.message, 'data': instance.data, 'error': instance.error, + 'meta': instance.meta, }; + +_NotificationItem _$NotificationItemFromJson(Map json) => + _NotificationItem( + id: json['id'] as String?, + userId: json['user_id'] as String?, + recipient: + json['recipient'] == null + ? null + : Recipient.fromJson(json['recipient'] as Map), + title: json['title'] as String?, + message: json['message'] as String?, + link: json['link'] as String?, + image: json['image'] as String?, + priority: json['priority'] as String?, + type: json['type'] as String?, + eventType: json['event_type'] as String?, + status: json['status'] as String?, + methods: json['methods'] as Map?, + metadata: json['metadata'] as Map?, + scheduleAt: (json['schedule_at'] as num?)?.toInt(), + createdAt: (json['created_at'] as num?)?.toInt(), + updatedAt: (json['updated_at'] as num?)?.toInt(), + seen: json['seen'] as bool?, + seenAt: (json['seen_at'] as num?)?.toInt(), + isScheduled: json['is_scheduled'] as bool?, + scheduledAt: (json['scheduled_at'] as num?)?.toInt(), + ); + +Map _$NotificationItemToJson(_NotificationItem instance) => + { + 'id': instance.id, + 'user_id': instance.userId, + 'recipient': instance.recipient, + 'title': instance.title, + 'message': instance.message, + 'link': instance.link, + 'image': instance.image, + 'priority': instance.priority, + 'type': instance.type, + 'event_type': instance.eventType, + 'status': instance.status, + 'methods': instance.methods, + 'metadata': instance.metadata, + 'schedule_at': instance.scheduleAt, + 'created_at': instance.createdAt, + 'updated_at': instance.updatedAt, + 'seen': instance.seen, + 'seen_at': instance.seenAt, + 'is_scheduled': instance.isScheduled, + 'scheduled_at': instance.scheduledAt, + }; diff --git a/lib/data/services/model/notification_data/notification_data.dart b/lib/data/services/model/notification_data/notification_data.dart deleted file mode 100644 index 4a12eca..0000000 --- a/lib/data/services/model/notification_data/notification_data.dart +++ /dev/null @@ -1,46 +0,0 @@ -// ignore_for_file: invalid_annotation_target - -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:tm_app/data/services/model/meta/meta.dart'; - -part 'notification_data.freezed.dart'; -part 'notification_data.g.dart'; - -@freezed -abstract class NotificationData with _$NotificationData { - const factory NotificationData({ - required List? notifications, - required Meta? meta, - }) = _NotificationData; - - factory NotificationData.fromJson(Map json) => - _$NotificationDataFromJson(json); -} - -@freezed -abstract class NotificationItem with _$NotificationItem { - const factory NotificationItem({ - required String? id, - @JsonKey(name: 'user_id') required String? userId, - required String? title, - required String? message, - required String? link, - required String? image, - required String? priority, - required String? type, - @JsonKey(name: 'event_type') required String? eventType, - required String? status, - required Map? methods, - required Map? metadata, - @JsonKey(name: 'schedule_at') required int? scheduleAt, - @JsonKey(name: 'created_at') required String? createdAt, - @JsonKey(name: 'updated_at') required String? updatedAt, - required bool? seen, - @JsonKey(name: 'seen_at') required int? seenAt, - @JsonKey(name: 'is_scheduled') required bool? isScheduled, - @JsonKey(name: 'scheduled_at') required int? scheduledAt, - }) = _NotificationItem; - - factory NotificationItem.fromJson(Map json) => - _$NotificationItemFromJson(json); -} \ No newline at end of file diff --git a/lib/data/services/model/notification_data/notification_data.freezed.dart b/lib/data/services/model/notification_data/notification_data.freezed.dart deleted file mode 100644 index ff6ff1e..0000000 --- a/lib/data/services/model/notification_data/notification_data.freezed.dart +++ /dev/null @@ -1,645 +0,0 @@ -// 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 'notification_data.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; - -/// @nodoc -mixin _$NotificationData { - - List? get notifications; Meta? get meta; -/// Create a copy of NotificationData -/// with the given fields replaced by the non-null parameter values. -@JsonKey(includeFromJson: false, includeToJson: false) -@pragma('vm:prefer-inline') -$NotificationDataCopyWith get copyWith => _$NotificationDataCopyWithImpl(this as NotificationData, _$identity); - - /// Serializes this NotificationData to a JSON map. - Map toJson(); - - -@override -bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is NotificationData&&const DeepCollectionEquality().equals(other.notifications, notifications)&&(identical(other.meta, meta) || other.meta == meta)); -} - -@JsonKey(includeFromJson: false, includeToJson: false) -@override -int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(notifications),meta); - -@override -String toString() { - return 'NotificationData(notifications: $notifications, meta: $meta)'; -} - - -} - -/// @nodoc -abstract mixin class $NotificationDataCopyWith<$Res> { - factory $NotificationDataCopyWith(NotificationData value, $Res Function(NotificationData) _then) = _$NotificationDataCopyWithImpl; -@useResult -$Res call({ - List? notifications, Meta? meta -}); - - -$MetaCopyWith<$Res>? get meta; - -} -/// @nodoc -class _$NotificationDataCopyWithImpl<$Res> - implements $NotificationDataCopyWith<$Res> { - _$NotificationDataCopyWithImpl(this._self, this._then); - - final NotificationData _self; - final $Res Function(NotificationData) _then; - -/// Create a copy of NotificationData -/// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? notifications = freezed,Object? meta = freezed,}) { - return _then(_self.copyWith( -notifications: freezed == notifications ? _self.notifications : notifications // ignore: cast_nullable_to_non_nullable -as List?,meta: freezed == meta ? _self.meta : meta // ignore: cast_nullable_to_non_nullable -as Meta?, - )); -} -/// Create a copy of NotificationData -/// with the given fields replaced by the non-null parameter values. -@override -@pragma('vm:prefer-inline') -$MetaCopyWith<$Res>? get meta { - if (_self.meta == null) { - return null; - } - - return $MetaCopyWith<$Res>(_self.meta!, (value) { - return _then(_self.copyWith(meta: value)); - }); -} -} - - -/// Adds pattern-matching-related methods to [NotificationData]. -extension NotificationDataPatterns on NotificationData { -/// 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 Function( _NotificationData value)? $default,{required TResult orElse(),}){ -final _that = this; -switch (_that) { -case _NotificationData() 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 Function( _NotificationData value) $default,){ -final _that = this; -switch (_that) { -case _NotificationData(): -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? Function( _NotificationData value)? $default,){ -final _that = this; -switch (_that) { -case _NotificationData() 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 Function( List? notifications, Meta? meta)? $default,{required TResult orElse(),}) {final _that = this; -switch (_that) { -case _NotificationData() when $default != null: -return $default(_that.notifications,_that.meta);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 Function( List? notifications, Meta? meta) $default,) {final _that = this; -switch (_that) { -case _NotificationData(): -return $default(_that.notifications,_that.meta);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? Function( List? notifications, Meta? meta)? $default,) {final _that = this; -switch (_that) { -case _NotificationData() when $default != null: -return $default(_that.notifications,_that.meta);case _: - return null; - -} -} - -} - -/// @nodoc -@JsonSerializable() - -class _NotificationData implements NotificationData { - const _NotificationData({required final List? notifications, required this.meta}): _notifications = notifications; - factory _NotificationData.fromJson(Map json) => _$NotificationDataFromJson(json); - - final List? _notifications; -@override List? get notifications { - final value = _notifications; - if (value == null) return null; - if (_notifications is EqualUnmodifiableListView) return _notifications; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(value); -} - -@override final Meta? meta; - -/// Create a copy of NotificationData -/// with the given fields replaced by the non-null parameter values. -@override @JsonKey(includeFromJson: false, includeToJson: false) -@pragma('vm:prefer-inline') -_$NotificationDataCopyWith<_NotificationData> get copyWith => __$NotificationDataCopyWithImpl<_NotificationData>(this, _$identity); - -@override -Map toJson() { - return _$NotificationDataToJson(this, ); -} - -@override -bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _NotificationData&&const DeepCollectionEquality().equals(other._notifications, _notifications)&&(identical(other.meta, meta) || other.meta == meta)); -} - -@JsonKey(includeFromJson: false, includeToJson: false) -@override -int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_notifications),meta); - -@override -String toString() { - return 'NotificationData(notifications: $notifications, meta: $meta)'; -} - - -} - -/// @nodoc -abstract mixin class _$NotificationDataCopyWith<$Res> implements $NotificationDataCopyWith<$Res> { - factory _$NotificationDataCopyWith(_NotificationData value, $Res Function(_NotificationData) _then) = __$NotificationDataCopyWithImpl; -@override @useResult -$Res call({ - List? notifications, Meta? meta -}); - - -@override $MetaCopyWith<$Res>? get meta; - -} -/// @nodoc -class __$NotificationDataCopyWithImpl<$Res> - implements _$NotificationDataCopyWith<$Res> { - __$NotificationDataCopyWithImpl(this._self, this._then); - - final _NotificationData _self; - final $Res Function(_NotificationData) _then; - -/// Create a copy of NotificationData -/// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? notifications = freezed,Object? meta = freezed,}) { - return _then(_NotificationData( -notifications: freezed == notifications ? _self._notifications : notifications // ignore: cast_nullable_to_non_nullable -as List?,meta: freezed == meta ? _self.meta : meta // ignore: cast_nullable_to_non_nullable -as Meta?, - )); -} - -/// Create a copy of NotificationData -/// with the given fields replaced by the non-null parameter values. -@override -@pragma('vm:prefer-inline') -$MetaCopyWith<$Res>? get meta { - if (_self.meta == null) { - return null; - } - - return $MetaCopyWith<$Res>(_self.meta!, (value) { - return _then(_self.copyWith(meta: value)); - }); -} -} - - -/// @nodoc -mixin _$NotificationItem { - - String? get id;@JsonKey(name: 'user_id') String? get userId; String? get title; String? get message; String? get link; String? get image; String? get priority; String? get type;@JsonKey(name: 'event_type') String? get eventType; String? get status; Map? get methods; Map? get metadata;@JsonKey(name: 'schedule_at') int? get scheduleAt;@JsonKey(name: 'created_at') String? get createdAt;@JsonKey(name: 'updated_at') String? get updatedAt; bool? get seen;@JsonKey(name: 'seen_at') int? get seenAt;@JsonKey(name: 'is_scheduled') bool? get isScheduled;@JsonKey(name: 'scheduled_at') int? get scheduledAt; -/// Create a copy of NotificationItem -/// with the given fields replaced by the non-null parameter values. -@JsonKey(includeFromJson: false, includeToJson: false) -@pragma('vm:prefer-inline') -$NotificationItemCopyWith get copyWith => _$NotificationItemCopyWithImpl(this as NotificationItem, _$identity); - - /// Serializes this NotificationItem to a JSON map. - Map toJson(); - - -@override -bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is NotificationItem&&(identical(other.id, id) || other.id == id)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.title, title) || other.title == title)&&(identical(other.message, message) || other.message == message)&&(identical(other.link, link) || other.link == link)&&(identical(other.image, image) || other.image == image)&&(identical(other.priority, priority) || other.priority == priority)&&(identical(other.type, type) || other.type == type)&&(identical(other.eventType, eventType) || other.eventType == eventType)&&(identical(other.status, status) || other.status == status)&&const DeepCollectionEquality().equals(other.methods, methods)&&const DeepCollectionEquality().equals(other.metadata, metadata)&&(identical(other.scheduleAt, scheduleAt) || other.scheduleAt == scheduleAt)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.seen, seen) || other.seen == seen)&&(identical(other.seenAt, seenAt) || other.seenAt == seenAt)&&(identical(other.isScheduled, isScheduled) || other.isScheduled == isScheduled)&&(identical(other.scheduledAt, scheduledAt) || other.scheduledAt == scheduledAt)); -} - -@JsonKey(includeFromJson: false, includeToJson: false) -@override -int get hashCode => Object.hashAll([runtimeType,id,userId,title,message,link,image,priority,type,eventType,status,const DeepCollectionEquality().hash(methods),const DeepCollectionEquality().hash(metadata),scheduleAt,createdAt,updatedAt,seen,seenAt,isScheduled,scheduledAt]); - -@override -String toString() { - return 'NotificationItem(id: $id, userId: $userId, title: $title, message: $message, link: $link, image: $image, priority: $priority, type: $type, eventType: $eventType, status: $status, methods: $methods, metadata: $metadata, scheduleAt: $scheduleAt, createdAt: $createdAt, updatedAt: $updatedAt, seen: $seen, seenAt: $seenAt, isScheduled: $isScheduled, scheduledAt: $scheduledAt)'; -} - - -} - -/// @nodoc -abstract mixin class $NotificationItemCopyWith<$Res> { - factory $NotificationItemCopyWith(NotificationItem value, $Res Function(NotificationItem) _then) = _$NotificationItemCopyWithImpl; -@useResult -$Res call({ - String? id,@JsonKey(name: 'user_id') String? userId, String? title, String? message, String? link, String? image, String? priority, String? type,@JsonKey(name: 'event_type') String? eventType, String? status, Map? methods, Map? metadata,@JsonKey(name: 'schedule_at') int? scheduleAt,@JsonKey(name: 'created_at') String? createdAt,@JsonKey(name: 'updated_at') String? updatedAt, bool? seen,@JsonKey(name: 'seen_at') int? seenAt,@JsonKey(name: 'is_scheduled') bool? isScheduled,@JsonKey(name: 'scheduled_at') int? scheduledAt -}); - - - - -} -/// @nodoc -class _$NotificationItemCopyWithImpl<$Res> - implements $NotificationItemCopyWith<$Res> { - _$NotificationItemCopyWithImpl(this._self, this._then); - - final NotificationItem _self; - final $Res Function(NotificationItem) _then; - -/// Create a copy of NotificationItem -/// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? userId = freezed,Object? title = freezed,Object? message = freezed,Object? link = freezed,Object? image = freezed,Object? priority = freezed,Object? type = freezed,Object? eventType = freezed,Object? status = freezed,Object? methods = freezed,Object? metadata = freezed,Object? scheduleAt = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,Object? seen = freezed,Object? seenAt = freezed,Object? isScheduled = freezed,Object? scheduledAt = freezed,}) { - return _then(_self.copyWith( -id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable -as String?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable -as String?,title: freezed == title ? _self.title : title // ignore: cast_nullable_to_non_nullable -as String?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable -as String?,link: freezed == link ? _self.link : link // ignore: cast_nullable_to_non_nullable -as String?,image: freezed == image ? _self.image : image // ignore: cast_nullable_to_non_nullable -as String?,priority: freezed == priority ? _self.priority : priority // ignore: cast_nullable_to_non_nullable -as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable -as String?,eventType: freezed == eventType ? _self.eventType : eventType // ignore: cast_nullable_to_non_nullable -as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable -as String?,methods: freezed == methods ? _self.methods : methods // ignore: cast_nullable_to_non_nullable -as Map?,metadata: freezed == metadata ? _self.metadata : metadata // ignore: cast_nullable_to_non_nullable -as Map?,scheduleAt: freezed == scheduleAt ? _self.scheduleAt : scheduleAt // ignore: cast_nullable_to_non_nullable -as int?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable -as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable -as String?,seen: freezed == seen ? _self.seen : seen // ignore: cast_nullable_to_non_nullable -as bool?,seenAt: freezed == seenAt ? _self.seenAt : seenAt // ignore: cast_nullable_to_non_nullable -as int?,isScheduled: freezed == isScheduled ? _self.isScheduled : isScheduled // ignore: cast_nullable_to_non_nullable -as bool?,scheduledAt: freezed == scheduledAt ? _self.scheduledAt : scheduledAt // ignore: cast_nullable_to_non_nullable -as int?, - )); -} - -} - - -/// Adds pattern-matching-related methods to [NotificationItem]. -extension NotificationItemPatterns on NotificationItem { -/// 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 Function( _NotificationItem value)? $default,{required TResult orElse(),}){ -final _that = this; -switch (_that) { -case _NotificationItem() 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 Function( _NotificationItem value) $default,){ -final _that = this; -switch (_that) { -case _NotificationItem(): -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? Function( _NotificationItem value)? $default,){ -final _that = this; -switch (_that) { -case _NotificationItem() 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 Function( String? id, @JsonKey(name: 'user_id') String? userId, String? title, String? message, String? link, String? image, String? priority, String? type, @JsonKey(name: 'event_type') String? eventType, String? status, Map? methods, Map? metadata, @JsonKey(name: 'schedule_at') int? scheduleAt, @JsonKey(name: 'created_at') String? createdAt, @JsonKey(name: 'updated_at') String? updatedAt, bool? seen, @JsonKey(name: 'seen_at') int? seenAt, @JsonKey(name: 'is_scheduled') bool? isScheduled, @JsonKey(name: 'scheduled_at') int? scheduledAt)? $default,{required TResult orElse(),}) {final _that = this; -switch (_that) { -case _NotificationItem() when $default != null: -return $default(_that.id,_that.userId,_that.title,_that.message,_that.link,_that.image,_that.priority,_that.type,_that.eventType,_that.status,_that.methods,_that.metadata,_that.scheduleAt,_that.createdAt,_that.updatedAt,_that.seen,_that.seenAt,_that.isScheduled,_that.scheduledAt);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 Function( String? id, @JsonKey(name: 'user_id') String? userId, String? title, String? message, String? link, String? image, String? priority, String? type, @JsonKey(name: 'event_type') String? eventType, String? status, Map? methods, Map? metadata, @JsonKey(name: 'schedule_at') int? scheduleAt, @JsonKey(name: 'created_at') String? createdAt, @JsonKey(name: 'updated_at') String? updatedAt, bool? seen, @JsonKey(name: 'seen_at') int? seenAt, @JsonKey(name: 'is_scheduled') bool? isScheduled, @JsonKey(name: 'scheduled_at') int? scheduledAt) $default,) {final _that = this; -switch (_that) { -case _NotificationItem(): -return $default(_that.id,_that.userId,_that.title,_that.message,_that.link,_that.image,_that.priority,_that.type,_that.eventType,_that.status,_that.methods,_that.metadata,_that.scheduleAt,_that.createdAt,_that.updatedAt,_that.seen,_that.seenAt,_that.isScheduled,_that.scheduledAt);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? Function( String? id, @JsonKey(name: 'user_id') String? userId, String? title, String? message, String? link, String? image, String? priority, String? type, @JsonKey(name: 'event_type') String? eventType, String? status, Map? methods, Map? metadata, @JsonKey(name: 'schedule_at') int? scheduleAt, @JsonKey(name: 'created_at') String? createdAt, @JsonKey(name: 'updated_at') String? updatedAt, bool? seen, @JsonKey(name: 'seen_at') int? seenAt, @JsonKey(name: 'is_scheduled') bool? isScheduled, @JsonKey(name: 'scheduled_at') int? scheduledAt)? $default,) {final _that = this; -switch (_that) { -case _NotificationItem() when $default != null: -return $default(_that.id,_that.userId,_that.title,_that.message,_that.link,_that.image,_that.priority,_that.type,_that.eventType,_that.status,_that.methods,_that.metadata,_that.scheduleAt,_that.createdAt,_that.updatedAt,_that.seen,_that.seenAt,_that.isScheduled,_that.scheduledAt);case _: - return null; - -} -} - -} - -/// @nodoc -@JsonSerializable() - -class _NotificationItem implements NotificationItem { - const _NotificationItem({required this.id, @JsonKey(name: 'user_id') required this.userId, required this.title, required this.message, required this.link, required this.image, required this.priority, required this.type, @JsonKey(name: 'event_type') required this.eventType, required this.status, required final Map? methods, required final Map? metadata, @JsonKey(name: 'schedule_at') required this.scheduleAt, @JsonKey(name: 'created_at') required this.createdAt, @JsonKey(name: 'updated_at') required this.updatedAt, required this.seen, @JsonKey(name: 'seen_at') required this.seenAt, @JsonKey(name: 'is_scheduled') required this.isScheduled, @JsonKey(name: 'scheduled_at') required this.scheduledAt}): _methods = methods,_metadata = metadata; - factory _NotificationItem.fromJson(Map json) => _$NotificationItemFromJson(json); - -@override final String? id; -@override@JsonKey(name: 'user_id') final String? userId; -@override final String? title; -@override final String? message; -@override final String? link; -@override final String? image; -@override final String? priority; -@override final String? type; -@override@JsonKey(name: 'event_type') final String? eventType; -@override final String? status; - final Map? _methods; -@override Map? get methods { - final value = _methods; - if (value == null) return null; - if (_methods is EqualUnmodifiableMapView) return _methods; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); -} - - final Map? _metadata; -@override Map? get metadata { - final value = _metadata; - if (value == null) return null; - if (_metadata is EqualUnmodifiableMapView) return _metadata; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); -} - -@override@JsonKey(name: 'schedule_at') final int? scheduleAt; -@override@JsonKey(name: 'created_at') final String? createdAt; -@override@JsonKey(name: 'updated_at') final String? updatedAt; -@override final bool? seen; -@override@JsonKey(name: 'seen_at') final int? seenAt; -@override@JsonKey(name: 'is_scheduled') final bool? isScheduled; -@override@JsonKey(name: 'scheduled_at') final int? scheduledAt; - -/// Create a copy of NotificationItem -/// with the given fields replaced by the non-null parameter values. -@override @JsonKey(includeFromJson: false, includeToJson: false) -@pragma('vm:prefer-inline') -_$NotificationItemCopyWith<_NotificationItem> get copyWith => __$NotificationItemCopyWithImpl<_NotificationItem>(this, _$identity); - -@override -Map toJson() { - return _$NotificationItemToJson(this, ); -} - -@override -bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _NotificationItem&&(identical(other.id, id) || other.id == id)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.title, title) || other.title == title)&&(identical(other.message, message) || other.message == message)&&(identical(other.link, link) || other.link == link)&&(identical(other.image, image) || other.image == image)&&(identical(other.priority, priority) || other.priority == priority)&&(identical(other.type, type) || other.type == type)&&(identical(other.eventType, eventType) || other.eventType == eventType)&&(identical(other.status, status) || other.status == status)&&const DeepCollectionEquality().equals(other._methods, _methods)&&const DeepCollectionEquality().equals(other._metadata, _metadata)&&(identical(other.scheduleAt, scheduleAt) || other.scheduleAt == scheduleAt)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.seen, seen) || other.seen == seen)&&(identical(other.seenAt, seenAt) || other.seenAt == seenAt)&&(identical(other.isScheduled, isScheduled) || other.isScheduled == isScheduled)&&(identical(other.scheduledAt, scheduledAt) || other.scheduledAt == scheduledAt)); -} - -@JsonKey(includeFromJson: false, includeToJson: false) -@override -int get hashCode => Object.hashAll([runtimeType,id,userId,title,message,link,image,priority,type,eventType,status,const DeepCollectionEquality().hash(_methods),const DeepCollectionEquality().hash(_metadata),scheduleAt,createdAt,updatedAt,seen,seenAt,isScheduled,scheduledAt]); - -@override -String toString() { - return 'NotificationItem(id: $id, userId: $userId, title: $title, message: $message, link: $link, image: $image, priority: $priority, type: $type, eventType: $eventType, status: $status, methods: $methods, metadata: $metadata, scheduleAt: $scheduleAt, createdAt: $createdAt, updatedAt: $updatedAt, seen: $seen, seenAt: $seenAt, isScheduled: $isScheduled, scheduledAt: $scheduledAt)'; -} - - -} - -/// @nodoc -abstract mixin class _$NotificationItemCopyWith<$Res> implements $NotificationItemCopyWith<$Res> { - factory _$NotificationItemCopyWith(_NotificationItem value, $Res Function(_NotificationItem) _then) = __$NotificationItemCopyWithImpl; -@override @useResult -$Res call({ - String? id,@JsonKey(name: 'user_id') String? userId, String? title, String? message, String? link, String? image, String? priority, String? type,@JsonKey(name: 'event_type') String? eventType, String? status, Map? methods, Map? metadata,@JsonKey(name: 'schedule_at') int? scheduleAt,@JsonKey(name: 'created_at') String? createdAt,@JsonKey(name: 'updated_at') String? updatedAt, bool? seen,@JsonKey(name: 'seen_at') int? seenAt,@JsonKey(name: 'is_scheduled') bool? isScheduled,@JsonKey(name: 'scheduled_at') int? scheduledAt -}); - - - - -} -/// @nodoc -class __$NotificationItemCopyWithImpl<$Res> - implements _$NotificationItemCopyWith<$Res> { - __$NotificationItemCopyWithImpl(this._self, this._then); - - final _NotificationItem _self; - final $Res Function(_NotificationItem) _then; - -/// Create a copy of NotificationItem -/// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? userId = freezed,Object? title = freezed,Object? message = freezed,Object? link = freezed,Object? image = freezed,Object? priority = freezed,Object? type = freezed,Object? eventType = freezed,Object? status = freezed,Object? methods = freezed,Object? metadata = freezed,Object? scheduleAt = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,Object? seen = freezed,Object? seenAt = freezed,Object? isScheduled = freezed,Object? scheduledAt = freezed,}) { - return _then(_NotificationItem( -id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable -as String?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable -as String?,title: freezed == title ? _self.title : title // ignore: cast_nullable_to_non_nullable -as String?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable -as String?,link: freezed == link ? _self.link : link // ignore: cast_nullable_to_non_nullable -as String?,image: freezed == image ? _self.image : image // ignore: cast_nullable_to_non_nullable -as String?,priority: freezed == priority ? _self.priority : priority // ignore: cast_nullable_to_non_nullable -as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable -as String?,eventType: freezed == eventType ? _self.eventType : eventType // ignore: cast_nullable_to_non_nullable -as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable -as String?,methods: freezed == methods ? _self._methods : methods // ignore: cast_nullable_to_non_nullable -as Map?,metadata: freezed == metadata ? _self._metadata : metadata // ignore: cast_nullable_to_non_nullable -as Map?,scheduleAt: freezed == scheduleAt ? _self.scheduleAt : scheduleAt // ignore: cast_nullable_to_non_nullable -as int?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable -as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable -as String?,seen: freezed == seen ? _self.seen : seen // ignore: cast_nullable_to_non_nullable -as bool?,seenAt: freezed == seenAt ? _self.seenAt : seenAt // ignore: cast_nullable_to_non_nullable -as int?,isScheduled: freezed == isScheduled ? _self.isScheduled : isScheduled // ignore: cast_nullable_to_non_nullable -as bool?,scheduledAt: freezed == scheduledAt ? _self.scheduledAt : scheduledAt // ignore: cast_nullable_to_non_nullable -as int?, - )); -} - - -} - -// dart format on diff --git a/lib/data/services/model/notification_data/notification_data.g.dart b/lib/data/services/model/notification_data/notification_data.g.dart deleted file mode 100644 index 1b8e249..0000000 --- a/lib/data/services/model/notification_data/notification_data.g.dart +++ /dev/null @@ -1,71 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'notification_data.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_NotificationData _$NotificationDataFromJson(Map json) => - _NotificationData( - notifications: - (json['notifications'] as List?) - ?.map((e) => NotificationItem.fromJson(e as Map)) - .toList(), - meta: - json['meta'] == null - ? null - : Meta.fromJson(json['meta'] as Map), - ); - -Map _$NotificationDataToJson(_NotificationData instance) => - { - 'notifications': instance.notifications, - 'meta': instance.meta, - }; - -_NotificationItem _$NotificationItemFromJson(Map json) => - _NotificationItem( - id: json['id'] as String?, - userId: json['user_id'] as String?, - title: json['title'] as String?, - message: json['message'] as String?, - link: json['link'] as String?, - image: json['image'] as String?, - priority: json['priority'] as String?, - type: json['type'] as String?, - eventType: json['event_type'] as String?, - status: json['status'] as String?, - methods: json['methods'] as Map?, - metadata: json['metadata'] as Map?, - scheduleAt: (json['schedule_at'] as num?)?.toInt(), - createdAt: json['created_at'] as String?, - updatedAt: json['updated_at'] as String?, - seen: json['seen'] as bool?, - seenAt: (json['seen_at'] as num?)?.toInt(), - isScheduled: json['is_scheduled'] as bool?, - scheduledAt: (json['scheduled_at'] as num?)?.toInt(), - ); - -Map _$NotificationItemToJson(_NotificationItem instance) => - { - 'id': instance.id, - 'user_id': instance.userId, - 'title': instance.title, - 'message': instance.message, - 'link': instance.link, - 'image': instance.image, - 'priority': instance.priority, - 'type': instance.type, - 'event_type': instance.eventType, - 'status': instance.status, - 'methods': instance.methods, - 'metadata': instance.metadata, - 'schedule_at': instance.scheduleAt, - 'created_at': instance.createdAt, - 'updated_at': instance.updatedAt, - 'seen': instance.seen, - 'seen_at': instance.seenAt, - 'is_scheduled': instance.isScheduled, - 'scheduled_at': instance.scheduledAt, - }; diff --git a/lib/data/services/model/notification_data/notification_recipient.dart b/lib/data/services/model/notification_data/notification_recipient.dart new file mode 100644 index 0000000..3b62fd2 --- /dev/null +++ b/lib/data/services/model/notification_data/notification_recipient.dart @@ -0,0 +1,38 @@ +// ignore_for_file: invalid_annotation_target + +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'notification_recipient.freezed.dart'; +part 'notification_recipient.g.dart'; + +@freezed +abstract class Recipient with _$Recipient { + const factory Recipient({ + required String? id, + @JsonKey(name: 'full_name') required String? fullName, + required String? username, + required String? email, + required String? status, + required String? type, + required String? role, + required String? phone, + @JsonKey(name: 'updated_at') required int? updatedAt, + @JsonKey(name: 'created_at') required int? createdAt, + @JsonKey(name: 'last_login_at') required int? lastLoginAt, + required List? companies, + }) = _Recipient; + + factory Recipient.fromJson(Map json) => + _$RecipientFromJson(json); +} + +@freezed +abstract class Company with _$Company { + const factory Company({ + required String? id, + required String? name, + }) = _Company; + + factory Company.fromJson(Map json) => + _$CompanyFromJson(json); +} diff --git a/lib/data/services/model/notification_data/notification_recipient.freezed.dart b/lib/data/services/model/notification_data/notification_recipient.freezed.dart new file mode 100644 index 0000000..25d29fb --- /dev/null +++ b/lib/data/services/model/notification_data/notification_recipient.freezed.dart @@ -0,0 +1,584 @@ +// 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 'notification_recipient.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; + +/// @nodoc +mixin _$Recipient { + + String? get id;@JsonKey(name: 'full_name') String? get fullName; String? get username; String? get email; String? get status; String? get type; String? get role; String? get phone;@JsonKey(name: 'updated_at') int? get updatedAt;@JsonKey(name: 'created_at') int? get createdAt;@JsonKey(name: 'last_login_at') int? get lastLoginAt; List? get companies; +/// Create a copy of Recipient +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$RecipientCopyWith get copyWith => _$RecipientCopyWithImpl(this as Recipient, _$identity); + + /// Serializes this Recipient to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Recipient&&(identical(other.id, id) || other.id == id)&&(identical(other.fullName, fullName) || other.fullName == fullName)&&(identical(other.username, username) || other.username == username)&&(identical(other.email, email) || other.email == email)&&(identical(other.status, status) || other.status == status)&&(identical(other.type, type) || other.type == type)&&(identical(other.role, role) || other.role == role)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.lastLoginAt, lastLoginAt) || other.lastLoginAt == lastLoginAt)&&const DeepCollectionEquality().equals(other.companies, companies)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,fullName,username,email,status,type,role,phone,updatedAt,createdAt,lastLoginAt,const DeepCollectionEquality().hash(companies)); + +@override +String toString() { + return 'Recipient(id: $id, fullName: $fullName, username: $username, email: $email, status: $status, type: $type, role: $role, phone: $phone, updatedAt: $updatedAt, createdAt: $createdAt, lastLoginAt: $lastLoginAt, companies: $companies)'; +} + + +} + +/// @nodoc +abstract mixin class $RecipientCopyWith<$Res> { + factory $RecipientCopyWith(Recipient value, $Res Function(Recipient) _then) = _$RecipientCopyWithImpl; +@useResult +$Res call({ + String? id,@JsonKey(name: 'full_name') String? fullName, String? username, String? email, String? status, String? type, String? role, String? phone,@JsonKey(name: 'updated_at') int? updatedAt,@JsonKey(name: 'created_at') int? createdAt,@JsonKey(name: 'last_login_at') int? lastLoginAt, List? companies +}); + + + + +} +/// @nodoc +class _$RecipientCopyWithImpl<$Res> + implements $RecipientCopyWith<$Res> { + _$RecipientCopyWithImpl(this._self, this._then); + + final Recipient _self; + final $Res Function(Recipient) _then; + +/// Create a copy of Recipient +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? fullName = freezed,Object? username = freezed,Object? email = freezed,Object? status = freezed,Object? type = freezed,Object? role = freezed,Object? phone = freezed,Object? updatedAt = freezed,Object? createdAt = freezed,Object? lastLoginAt = freezed,Object? companies = freezed,}) { + return _then(_self.copyWith( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,fullName: freezed == fullName ? _self.fullName : fullName // ignore: cast_nullable_to_non_nullable +as String?,username: freezed == username ? _self.username : username // ignore: cast_nullable_to_non_nullable +as String?,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable +as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as String?,role: freezed == role ? _self.role : role // ignore: cast_nullable_to_non_nullable +as String?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable +as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable +as int?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as int?,lastLoginAt: freezed == lastLoginAt ? _self.lastLoginAt : lastLoginAt // ignore: cast_nullable_to_non_nullable +as int?,companies: freezed == companies ? _self.companies : companies // ignore: cast_nullable_to_non_nullable +as List?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [Recipient]. +extension RecipientPatterns on Recipient { +/// 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 Function( _Recipient value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Recipient() 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 Function( _Recipient value) $default,){ +final _that = this; +switch (_that) { +case _Recipient(): +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? Function( _Recipient value)? $default,){ +final _that = this; +switch (_that) { +case _Recipient() 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 Function( String? id, @JsonKey(name: 'full_name') String? fullName, String? username, String? email, String? status, String? type, String? role, String? phone, @JsonKey(name: 'updated_at') int? updatedAt, @JsonKey(name: 'created_at') int? createdAt, @JsonKey(name: 'last_login_at') int? lastLoginAt, List? companies)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Recipient() when $default != null: +return $default(_that.id,_that.fullName,_that.username,_that.email,_that.status,_that.type,_that.role,_that.phone,_that.updatedAt,_that.createdAt,_that.lastLoginAt,_that.companies);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 Function( String? id, @JsonKey(name: 'full_name') String? fullName, String? username, String? email, String? status, String? type, String? role, String? phone, @JsonKey(name: 'updated_at') int? updatedAt, @JsonKey(name: 'created_at') int? createdAt, @JsonKey(name: 'last_login_at') int? lastLoginAt, List? companies) $default,) {final _that = this; +switch (_that) { +case _Recipient(): +return $default(_that.id,_that.fullName,_that.username,_that.email,_that.status,_that.type,_that.role,_that.phone,_that.updatedAt,_that.createdAt,_that.lastLoginAt,_that.companies);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? Function( String? id, @JsonKey(name: 'full_name') String? fullName, String? username, String? email, String? status, String? type, String? role, String? phone, @JsonKey(name: 'updated_at') int? updatedAt, @JsonKey(name: 'created_at') int? createdAt, @JsonKey(name: 'last_login_at') int? lastLoginAt, List? companies)? $default,) {final _that = this; +switch (_that) { +case _Recipient() when $default != null: +return $default(_that.id,_that.fullName,_that.username,_that.email,_that.status,_that.type,_that.role,_that.phone,_that.updatedAt,_that.createdAt,_that.lastLoginAt,_that.companies);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _Recipient implements Recipient { + const _Recipient({required this.id, @JsonKey(name: 'full_name') required this.fullName, required this.username, required this.email, required this.status, required this.type, required this.role, required this.phone, @JsonKey(name: 'updated_at') required this.updatedAt, @JsonKey(name: 'created_at') required this.createdAt, @JsonKey(name: 'last_login_at') required this.lastLoginAt, required final List? companies}): _companies = companies; + factory _Recipient.fromJson(Map json) => _$RecipientFromJson(json); + +@override final String? id; +@override@JsonKey(name: 'full_name') final String? fullName; +@override final String? username; +@override final String? email; +@override final String? status; +@override final String? type; +@override final String? role; +@override final String? phone; +@override@JsonKey(name: 'updated_at') final int? updatedAt; +@override@JsonKey(name: 'created_at') final int? createdAt; +@override@JsonKey(name: 'last_login_at') final int? lastLoginAt; + final List? _companies; +@override List? get companies { + final value = _companies; + if (value == null) return null; + if (_companies is EqualUnmodifiableListView) return _companies; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); +} + + +/// Create a copy of Recipient +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$RecipientCopyWith<_Recipient> get copyWith => __$RecipientCopyWithImpl<_Recipient>(this, _$identity); + +@override +Map toJson() { + return _$RecipientToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Recipient&&(identical(other.id, id) || other.id == id)&&(identical(other.fullName, fullName) || other.fullName == fullName)&&(identical(other.username, username) || other.username == username)&&(identical(other.email, email) || other.email == email)&&(identical(other.status, status) || other.status == status)&&(identical(other.type, type) || other.type == type)&&(identical(other.role, role) || other.role == role)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.lastLoginAt, lastLoginAt) || other.lastLoginAt == lastLoginAt)&&const DeepCollectionEquality().equals(other._companies, _companies)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,fullName,username,email,status,type,role,phone,updatedAt,createdAt,lastLoginAt,const DeepCollectionEquality().hash(_companies)); + +@override +String toString() { + return 'Recipient(id: $id, fullName: $fullName, username: $username, email: $email, status: $status, type: $type, role: $role, phone: $phone, updatedAt: $updatedAt, createdAt: $createdAt, lastLoginAt: $lastLoginAt, companies: $companies)'; +} + + +} + +/// @nodoc +abstract mixin class _$RecipientCopyWith<$Res> implements $RecipientCopyWith<$Res> { + factory _$RecipientCopyWith(_Recipient value, $Res Function(_Recipient) _then) = __$RecipientCopyWithImpl; +@override @useResult +$Res call({ + String? id,@JsonKey(name: 'full_name') String? fullName, String? username, String? email, String? status, String? type, String? role, String? phone,@JsonKey(name: 'updated_at') int? updatedAt,@JsonKey(name: 'created_at') int? createdAt,@JsonKey(name: 'last_login_at') int? lastLoginAt, List? companies +}); + + + + +} +/// @nodoc +class __$RecipientCopyWithImpl<$Res> + implements _$RecipientCopyWith<$Res> { + __$RecipientCopyWithImpl(this._self, this._then); + + final _Recipient _self; + final $Res Function(_Recipient) _then; + +/// Create a copy of Recipient +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? fullName = freezed,Object? username = freezed,Object? email = freezed,Object? status = freezed,Object? type = freezed,Object? role = freezed,Object? phone = freezed,Object? updatedAt = freezed,Object? createdAt = freezed,Object? lastLoginAt = freezed,Object? companies = freezed,}) { + return _then(_Recipient( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,fullName: freezed == fullName ? _self.fullName : fullName // ignore: cast_nullable_to_non_nullable +as String?,username: freezed == username ? _self.username : username // ignore: cast_nullable_to_non_nullable +as String?,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable +as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as String?,role: freezed == role ? _self.role : role // ignore: cast_nullable_to_non_nullable +as String?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable +as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable +as int?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as int?,lastLoginAt: freezed == lastLoginAt ? _self.lastLoginAt : lastLoginAt // ignore: cast_nullable_to_non_nullable +as int?,companies: freezed == companies ? _self._companies : companies // ignore: cast_nullable_to_non_nullable +as List?, + )); +} + + +} + + +/// @nodoc +mixin _$Company { + + String? get id; String? get name; +/// Create a copy of Company +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CompanyCopyWith get copyWith => _$CompanyCopyWithImpl(this as Company, _$identity); + + /// Serializes this Company to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Company&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,name); + +@override +String toString() { + return 'Company(id: $id, name: $name)'; +} + + +} + +/// @nodoc +abstract mixin class $CompanyCopyWith<$Res> { + factory $CompanyCopyWith(Company value, $Res Function(Company) _then) = _$CompanyCopyWithImpl; +@useResult +$Res call({ + String? id, String? name +}); + + + + +} +/// @nodoc +class _$CompanyCopyWithImpl<$Res> + implements $CompanyCopyWith<$Res> { + _$CompanyCopyWithImpl(this._self, this._then); + + final Company _self; + final $Res Function(Company) _then; + +/// Create a copy of Company +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? name = freezed,}) { + return _then(_self.copyWith( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [Company]. +extension CompanyPatterns on Company { +/// 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 Function( _Company value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Company() 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 Function( _Company value) $default,){ +final _that = this; +switch (_that) { +case _Company(): +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? Function( _Company value)? $default,){ +final _that = this; +switch (_that) { +case _Company() 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 Function( String? id, String? name)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Company() when $default != null: +return $default(_that.id,_that.name);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 Function( String? id, String? name) $default,) {final _that = this; +switch (_that) { +case _Company(): +return $default(_that.id,_that.name);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? Function( String? id, String? name)? $default,) {final _that = this; +switch (_that) { +case _Company() when $default != null: +return $default(_that.id,_that.name);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _Company implements Company { + const _Company({required this.id, required this.name}); + factory _Company.fromJson(Map json) => _$CompanyFromJson(json); + +@override final String? id; +@override final String? name; + +/// Create a copy of Company +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CompanyCopyWith<_Company> get copyWith => __$CompanyCopyWithImpl<_Company>(this, _$identity); + +@override +Map toJson() { + return _$CompanyToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Company&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,name); + +@override +String toString() { + return 'Company(id: $id, name: $name)'; +} + + +} + +/// @nodoc +abstract mixin class _$CompanyCopyWith<$Res> implements $CompanyCopyWith<$Res> { + factory _$CompanyCopyWith(_Company value, $Res Function(_Company) _then) = __$CompanyCopyWithImpl; +@override @useResult +$Res call({ + String? id, String? name +}); + + + + +} +/// @nodoc +class __$CompanyCopyWithImpl<$Res> + implements _$CompanyCopyWith<$Res> { + __$CompanyCopyWithImpl(this._self, this._then); + + final _Company _self; + final $Res Function(_Company) _then; + +/// Create a copy of Company +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? name = freezed,}) { + return _then(_Company( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + +// dart format on diff --git a/lib/data/services/model/notification_data/notification_recipient.g.dart b/lib/data/services/model/notification_data/notification_recipient.g.dart new file mode 100644 index 0000000..3da00df --- /dev/null +++ b/lib/data/services/model/notification_data/notification_recipient.g.dart @@ -0,0 +1,49 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'notification_recipient.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_Recipient _$RecipientFromJson(Map json) => _Recipient( + id: json['id'] as String?, + fullName: json['full_name'] as String?, + username: json['username'] as String?, + email: json['email'] as String?, + status: json['status'] as String?, + type: json['type'] as String?, + role: json['role'] as String?, + phone: json['phone'] as String?, + updatedAt: (json['updated_at'] as num?)?.toInt(), + createdAt: (json['created_at'] as num?)?.toInt(), + lastLoginAt: (json['last_login_at'] as num?)?.toInt(), + companies: + (json['companies'] as List?) + ?.map((e) => Company.fromJson(e as Map)) + .toList(), +); + +Map _$RecipientToJson(_Recipient instance) => + { + 'id': instance.id, + 'full_name': instance.fullName, + 'username': instance.username, + 'email': instance.email, + 'status': instance.status, + 'type': instance.type, + 'role': instance.role, + 'phone': instance.phone, + 'updated_at': instance.updatedAt, + 'created_at': instance.createdAt, + 'last_login_at': instance.lastLoginAt, + 'companies': instance.companies, + }; + +_Company _$CompanyFromJson(Map json) => + _Company(id: json['id'] as String?, name: json['name'] as String?); + +Map _$CompanyToJson(_Company instance) => { + 'id': instance.id, + 'name': instance.name, +}; diff --git a/lib/view_models/notification_view_model.dart b/lib/view_models/notification_view_model.dart index 24e3ac8..3fe9d17 100644 --- a/lib/view_models/notification_view_model.dart +++ b/lib/view_models/notification_view_model.dart @@ -87,11 +87,9 @@ class NotificationViewModel with ChangeNotifier { case Ok(): final data = result.value; if (isPagination && allNotificationResponse != null) { - final old = allNotificationResponse?.data?.notifications ?? []; - final fresh = data.data?.notifications ?? []; - allNotificationResponse = data.copyWith( - data: data.data?.copyWith(notifications: [...old, ...fresh]), - ); + final old = allNotificationResponse?.data ?? []; + final fresh = data.data ?? []; + allNotificationResponse = data.copyWith(data: [...old, ...fresh]); } else { allNotificationResponse = data; } @@ -99,8 +97,8 @@ class NotificationViewModel with ChangeNotifier { _updateImportantFromAll(); currentPageAll = page; - totalPagesAll = data.data?.meta?.pages ?? 1; - hasMoreAll = (data.data?.notifications?.length ?? 0) >= _pageSize; + totalPagesAll = data.meta?.pages ?? 1; + hasMoreAll = (data.data?.length ?? 0) >= _pageSize; break; case Error(): @@ -134,18 +132,16 @@ class NotificationViewModel with ChangeNotifier { case Ok(): final data = result.value; if (isPagination && unreadNotificationResponse != null) { - final old = unreadNotificationResponse?.data?.notifications ?? []; - final fresh = data.data?.notifications ?? []; - unreadNotificationResponse = data.copyWith( - data: data.data?.copyWith(notifications: [...old, ...fresh]), - ); + final old = unreadNotificationResponse?.data ?? []; + final fresh = data.data ?? []; + unreadNotificationResponse = data.copyWith(data: [...old, ...fresh]); } else { unreadNotificationResponse = data; } currentPageUnread = page; - totalPagesUnread = data.data?.meta?.pages ?? 1; - hasMoreUnread = (data.data?.notifications?.length ?? 0) >= _pageSize; + totalPagesUnread = data.meta?.pages ?? 1; + hasMoreUnread = (data.data?.length ?? 0) >= _pageSize; break; case Error(): @@ -180,18 +176,18 @@ class NotificationViewModel with ChangeNotifier { case Ok(): final data = result.value; if (isPagination && importantNotificationResponse != null) { - final old = importantNotificationResponse?.data?.notifications ?? []; - final fresh = data.data?.notifications ?? []; + final old = importantNotificationResponse?.data ?? []; + final fresh = data.data ?? []; importantNotificationResponse = data.copyWith( - data: data.data?.copyWith(notifications: [...old, ...fresh]), + data: [...old, ...fresh], ); } else { importantNotificationResponse = data; } currentPageImportant = page; - totalPagesImportant = data.data?.meta?.pages ?? 1; - hasMoreImportant = (data.data?.notifications?.length ?? 0) >= _pageSize; + totalPagesImportant = data.meta?.pages ?? 1; + hasMoreImportant = (data.data?.length ?? 0) >= _pageSize; break; case Error(): @@ -207,7 +203,7 @@ class NotificationViewModel with ChangeNotifier { } void _updateImportantFromAll() { - final all = allNotificationResponse?.data?.notifications ?? []; + final all = allNotificationResponse?.data ?? []; final filtered = (all.where((n) { final p = n.priority ?? ''; @@ -216,7 +212,7 @@ class NotificationViewModel with ChangeNotifier { if (allNotificationResponse != null) { importantNotificationResponse = allNotificationResponse!.copyWith( - data: allNotificationResponse!.data!.copyWith(notifications: filtered), + data: filtered, ); } else { importantNotificationResponse = null; @@ -264,36 +260,28 @@ class NotificationViewModel with ChangeNotifier { NotificationStrings.unknownResponse; if (success) { - if (allNotificationResponse?.data?.notifications != null) { + if (allNotificationResponse?.data != null) { final updatedNotifications = - allNotificationResponse!.data!.notifications! + allNotificationResponse!.data! .map((n) => n.copyWith(seen: true)) .toList(); allNotificationResponse = allNotificationResponse!.copyWith( - data: allNotificationResponse!.data!.copyWith( - notifications: updatedNotifications, - ), + data: updatedNotifications, ); unreadNotificationResponse = unreadNotificationResponse?.copyWith( - data: unreadNotificationResponse?.data?.copyWith( - notifications: [], - ), + data: [], ); - if (importantNotificationResponse?.data?.notifications != null) { + if (importantNotificationResponse?.data != null) { final updatedImportant = - importantNotificationResponse!.data!.notifications! + importantNotificationResponse!.data! .map((n) => n.copyWith(seen: true)) .toList(); importantNotificationResponse = importantNotificationResponse! - .copyWith( - data: importantNotificationResponse!.data!.copyWith( - notifications: updatedImportant, - ), - ); + .copyWith(data: updatedImportant); } } diff --git a/lib/views/notification/pages/m_notification_page.dart b/lib/views/notification/pages/m_notification_page.dart index 89802ab..9e91d32 100644 --- a/lib/views/notification/pages/m_notification_page.dart +++ b/lib/views/notification/pages/m_notification_page.dart @@ -143,9 +143,9 @@ class _MobileNotificationPageState extends State ), if ((viewModel.isLoadingAll && - (viewModel.allNotificationResponse?.data?.notifications?.isEmpty ?? true)) || + (viewModel.allNotificationResponse?.data?.isEmpty ?? true)) || (viewModel.isLoadingUnread && - (viewModel.unreadNotificationResponse?.data?.notifications?.isEmpty ?? true))) + (viewModel.unreadNotificationResponse?.data?.isEmpty ?? true))) const Expanded( child: Center( child: CircularProgressIndicator(color: AppColors.secondary50), diff --git a/lib/views/notification/widgets/notification_all_tab.dart b/lib/views/notification/widgets/notification_all_tab.dart index ba9e361..6df4c93 100644 --- a/lib/views/notification/widgets/notification_all_tab.dart +++ b/lib/views/notification/widgets/notification_all_tab.dart @@ -13,7 +13,7 @@ class NotificationAllTab extends StatelessWidget { Widget build(BuildContext context) { final viewModel = context.watch(); final notifications = - viewModel.allNotificationResponse?.data?.notifications ?? []; + viewModel.allNotificationResponse?.data ?? []; return ListView.builder( controller: scrollController, diff --git a/lib/views/notification/widgets/notification_card.dart b/lib/views/notification/widgets/notification_card.dart index 0d97fdf..8f8bdd9 100644 --- a/lib/views/notification/widgets/notification_card.dart +++ b/lib/views/notification/widgets/notification_card.dart @@ -4,7 +4,7 @@ import 'package:provider/provider.dart'; import 'package:tm_app/core/constants/assets.dart'; import 'package:tm_app/core/theme/colors.dart'; import 'package:tm_app/core/utils/size_config.dart'; -import 'package:tm_app/data/services/model/notification_data/notification_data.dart'; +import 'package:tm_app/data/services/model/notification__response/notification_response_model.dart'; import 'package:tm_app/view_models/notification_view_model.dart'; import '../strings/notification_strings.dart'; @@ -102,7 +102,7 @@ class NotificationCard extends StatelessWidget { SvgPicture.asset(AssetsManager.calendar), SizedBox(width: 4.0.w()), Text( - viewModel.timeAgo(notification.createdAt!), + viewModel.timeAgo(notification.createdAt!.toString()), style: TextStyle( fontSize: 12.0.sp(), fontWeight: FontWeight.w400, diff --git a/lib/views/notification/widgets/notification_important_tab.dart b/lib/views/notification/widgets/notification_important_tab.dart index ea20bd5..cc00dbe 100644 --- a/lib/views/notification/widgets/notification_important_tab.dart +++ b/lib/views/notification/widgets/notification_important_tab.dart @@ -17,9 +17,9 @@ class NotificationImportantTab extends StatelessWidget { return const Center(child: CircularProgressIndicator()); } - final importantFromApi = viewModel.importantNotificationResponse?.data?.notifications ?? []; + final importantFromApi = viewModel.importantNotificationResponse?.data ?? []; - final allNotifications = viewModel.allNotificationResponse?.data?.notifications ?? []; + final allNotifications = viewModel.allNotificationResponse?.data ?? []; final source = importantFromApi.isNotEmpty ? importantFromApi : allNotifications; diff --git a/lib/views/notification/widgets/notification_unread_tab.dart b/lib/views/notification/widgets/notification_unread_tab.dart index 0026638..af714ce 100644 --- a/lib/views/notification/widgets/notification_unread_tab.dart +++ b/lib/views/notification/widgets/notification_unread_tab.dart @@ -19,7 +19,7 @@ class NotificationUnreadTab extends StatelessWidget { } final notifications = - viewModel.unreadNotificationResponse?.data?.notifications ?? []; + viewModel.unreadNotificationResponse?.data ?? []; if (notifications.isEmpty) { return const Center(child: Text(NotificationStrings.noUnreadNotifications,)); diff --git a/pubspec.lock b/pubspec.lock index e8b0d53..386acf0 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -45,10 +45,10 @@ packages: dependency: transitive description: name: async - sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" + sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 url: "https://pub.dev" source: hosted - version: "2.13.0" + version: "2.12.0" boolean_selector: dependency: transitive description: @@ -269,10 +269,10 @@ packages: dependency: transitive description: name: fake_async - sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc" url: "https://pub.dev" source: hosted - version: "1.3.3" + version: "1.3.2" ffi: dependency: transitive description: @@ -572,10 +572,10 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0" + sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec url: "https://pub.dev" source: hosted - version: "10.0.9" + version: "10.0.8" leak_tracker_flutter_testing: dependency: transitive description: @@ -1049,10 +1049,10 @@ packages: dependency: transitive description: name: vm_service - sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02 + sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14" url: "https://pub.dev" source: hosted - version: "15.0.0" + version: "14.3.1" watcher: dependency: transitive description: From 835a6f865dfb761d5f62b1cc659cdabcabbb5e14 Mon Sep 17 00:00:00 2001 From: llsajjad Date: Sat, 27 Sep 2025 13:35:05 +0330 Subject: [PATCH 2/2] hide notification circular when call mark as read --- lib/view_models/home_view_model.dart | 8 +++++++- lib/view_models/notification_view_model.dart | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/view_models/home_view_model.dart b/lib/view_models/home_view_model.dart index e2708f9..cfdf3fc 100644 --- a/lib/view_models/home_view_model.dart +++ b/lib/view_models/home_view_model.dart @@ -220,8 +220,14 @@ class HomeViewModel with ChangeNotifier { break; case Error>(): _hasUnreadNotification = false; - break; + break; } notifyListeners(); } + + void serUnreadNotificationFalse(){ + _hasUnreadNotification = false; + notifyListeners(); + + } } diff --git a/lib/view_models/notification_view_model.dart b/lib/view_models/notification_view_model.dart index 3fe9d17..c888f33 100644 --- a/lib/view_models/notification_view_model.dart +++ b/lib/view_models/notification_view_model.dart @@ -1,8 +1,10 @@ import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import 'package:tm_app/core/utils/app_toast.dart'; import 'package:tm_app/core/utils/result.dart'; import 'package:tm_app/data/repositories/notification_repository.dart'; import 'package:tm_app/data/services/model/notification__response/notification_response_model.dart'; +import 'package:tm_app/view_models/home_view_model.dart'; import 'package:tm_app/views/notification/strings/notification_strings.dart'; class NotificationViewModel with ChangeNotifier { @@ -291,6 +293,8 @@ class NotificationViewModel with ChangeNotifier { NotificationStrings.allNotificationMarkedAsRead, ); } + final homeViewModel = context.read(); + homeViewModel.serUnreadNotificationFalse(); } else { _errorMessage = message; if (context.mounted) {