Editable post

This commit is contained in:
2024-11-10 18:37:34 +08:00
parent 60a34fed00
commit 3ffe3cb50f
18 changed files with 249 additions and 93 deletions

View File

@ -6,6 +6,8 @@ part 'post.g.dart';
@freezed
class SnPost with _$SnPost {
const SnPost._();
const factory SnPost({
required int id,
required DateTime createdAt,
@ -44,6 +46,11 @@ class SnPost with _$SnPost {
}) = _SnPost;
factory SnPost.fromJson(Map<String, Object?> json) => _$SnPostFromJson(json);
String get typePlural => switch (type) {
'story' => 'stories',
_ => '${type}s',
};
}
@freezed

View File

@ -577,7 +577,7 @@ class __$$SnPostImplCopyWithImpl<$Res>
/// @nodoc
@JsonSerializable()
class _$SnPostImpl implements _SnPost {
class _$SnPostImpl extends _SnPost {
const _$SnPostImpl(
{required this.id,
required this.createdAt,
@ -615,7 +615,8 @@ class _$SnPostImpl implements _SnPost {
this.preload})
: _body = body,
_tags = tags,
_categories = categories;
_categories = categories,
super._();
factory _$SnPostImpl.fromJson(Map<String, dynamic> json) =>
_$$SnPostImplFromJson(json);
@ -827,7 +828,7 @@ class _$SnPostImpl implements _SnPost {
}
}
abstract class _SnPost implements SnPost {
abstract class _SnPost extends SnPost {
const factory _SnPost(
{required final int id,
required final DateTime createdAt,
@ -863,6 +864,7 @@ abstract class _SnPost implements SnPost {
required final SnPublisher publisher,
required final SnMetric metric,
final SnPostPreload? preload}) = _$SnPostImpl;
const _SnPost._() : super._();
factory _SnPost.fromJson(Map<String, dynamic> json) = _$SnPostImpl.fromJson;