diff --git a/assets/i18n/en-US.json b/assets/i18n/en-US.json index 9481cfc..08e0c71 100644 --- a/assets/i18n/en-US.json +++ b/assets/i18n/en-US.json @@ -32,6 +32,7 @@ "publishers": "Publishers", "managedPublisher": "Managed Publishers", "createPublisher": "Create a Publisher", + "createPublisherHint": "To create posts, collections, etc.", "editPublisher": "Edit a Publisher", "syncPublisher": "Use Account Data", "create": "Create", @@ -49,5 +50,25 @@ "postCreateAccountNext2": "Log in to your account and start exploring the Solar Network!", "postPlaceholder": "What's on your mind?", "publishersEmpty": "No publishers yet", - "publishersEmptyDescription": "You can need to create a publisher to start publishing your posts." + "publishersEmptyDescription": "You can need to create a publisher to start publishing your posts.", + "authFactorPassword": "Password", + "authFactorPasswordDescription": "The password you set when you registered.", + "authFactorEmail": "Email verification code", + "authFactorEmailDescription": "An one-time code sent to the email address you set when you registered.", + "authFactorTOTP": "Time-based OTP", + "authFactorTOTPDescription": "A one-time code generated by a TOTP authenticator such as Google Authenticator or Authy.", + "authFactorInAppNotify": "In-app notification", + "authFactorInAppNotifyDescription": "A one-time code sent via in-app notification.", + "realms": "Realms", + "createRealm": "Create a Realm", + "createRealmHint": "Meet friends with same interests, build communities, and more.", + "editRealm": "Edit a Realm", + "deleteRealm": "Delete Realm {}", + "deleteRealmHint": "Are you sure to delete this realm? This will also deleted all the channels, publishers, and posts under this realm.", + "explore": "Explore", + "account": "Account", + "name": "Name", + "description": "Description", + "slug": "Slug", + "slugHint": "The slug will be used in the URL to access this resource, it should be unique and URL safe." } diff --git a/lib/models/chat.dart b/lib/models/chat.dart new file mode 100644 index 0000000..7cbbf04 --- /dev/null +++ b/lib/models/chat.dart @@ -0,0 +1,26 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:island/models/file.dart'; +import 'package:island/models/realm.dart'; + +part 'chat.freezed.dart'; +part 'chat.g.dart'; + +@freezed +abstract class SnChat with _$SnChat { + const factory SnChat({ + required int id, + required String name, + required String description, + required int type, + required bool isPublic, + required SnCloudFile? picture, + required SnCloudFile? background, + required int? realmId, + required SnRealm? realm, + required DateTime createdAt, + required DateTime updatedAt, + required DateTime? deletedAt, + }) = _SnChat; + + factory SnChat.fromJson(Map json) => _$SnChatFromJson(json); +} diff --git a/lib/models/chat.freezed.dart b/lib/models/chat.freezed.dart new file mode 100644 index 0000000..42ca4c9 --- /dev/null +++ b/lib/models/chat.freezed.dart @@ -0,0 +1,253 @@ +// dart format width=80 +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// 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 'chat.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; + +/// @nodoc +mixin _$SnChat { + + int get id; String get name; String get description; int get type; bool get isPublic; SnCloudFile? get picture; SnCloudFile? get background; int? get realmId; SnRealm? get realm; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; +/// Create a copy of SnChat +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$SnChatCopyWith get copyWith => _$SnChatCopyWithImpl(this as SnChat, _$identity); + + /// Serializes this SnChat to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is SnChat&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.type, type) || other.type == type)&&(identical(other.isPublic, isPublic) || other.isPublic == isPublic)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.background, background) || other.background == background)&&(identical(other.realmId, realmId) || other.realmId == realmId)&&(identical(other.realm, realm) || other.realm == realm)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,name,description,type,isPublic,picture,background,realmId,realm,createdAt,updatedAt,deletedAt); + +@override +String toString() { + return 'SnChat(id: $id, name: $name, description: $description, type: $type, isPublic: $isPublic, picture: $picture, background: $background, realmId: $realmId, realm: $realm, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; +} + + +} + +/// @nodoc +abstract mixin class $SnChatCopyWith<$Res> { + factory $SnChatCopyWith(SnChat value, $Res Function(SnChat) _then) = _$SnChatCopyWithImpl; +@useResult +$Res call({ + int id, String name, String description, int type, bool isPublic, SnCloudFile? picture, SnCloudFile? background, int? realmId, SnRealm? realm, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt +}); + + +$SnCloudFileCopyWith<$Res>? get picture;$SnCloudFileCopyWith<$Res>? get background;$SnRealmCopyWith<$Res>? get realm; + +} +/// @nodoc +class _$SnChatCopyWithImpl<$Res> + implements $SnChatCopyWith<$Res> { + _$SnChatCopyWithImpl(this._self, this._then); + + final SnChat _self; + final $Res Function(SnChat) _then; + +/// Create a copy of SnChat +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? name = null,Object? description = null,Object? type = null,Object? isPublic = null,Object? picture = freezed,Object? background = freezed,Object? realmId = freezed,Object? realm = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { + return _then(_self.copyWith( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as int,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable +as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as int,isPublic: null == isPublic ? _self.isPublic : isPublic // ignore: cast_nullable_to_non_nullable +as bool,picture: freezed == picture ? _self.picture : picture // ignore: cast_nullable_to_non_nullable +as SnCloudFile?,background: freezed == background ? _self.background : background // ignore: cast_nullable_to_non_nullable +as SnCloudFile?,realmId: freezed == realmId ? _self.realmId : realmId // ignore: cast_nullable_to_non_nullable +as int?,realm: freezed == realm ? _self.realm : realm // ignore: cast_nullable_to_non_nullable +as SnRealm?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable +as DateTime,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); +} +/// Create a copy of SnChat +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$SnCloudFileCopyWith<$Res>? get picture { + if (_self.picture == null) { + return null; + } + + return $SnCloudFileCopyWith<$Res>(_self.picture!, (value) { + return _then(_self.copyWith(picture: value)); + }); +}/// Create a copy of SnChat +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$SnCloudFileCopyWith<$Res>? get background { + if (_self.background == null) { + return null; + } + + return $SnCloudFileCopyWith<$Res>(_self.background!, (value) { + return _then(_self.copyWith(background: value)); + }); +}/// Create a copy of SnChat +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$SnRealmCopyWith<$Res>? get realm { + if (_self.realm == null) { + return null; + } + + return $SnRealmCopyWith<$Res>(_self.realm!, (value) { + return _then(_self.copyWith(realm: value)); + }); +} +} + + +/// @nodoc +@JsonSerializable() + +class _SnChat implements SnChat { + const _SnChat({required this.id, required this.name, required this.description, required this.type, required this.isPublic, required this.picture, required this.background, required this.realmId, required this.realm, required this.createdAt, required this.updatedAt, required this.deletedAt}); + factory _SnChat.fromJson(Map json) => _$SnChatFromJson(json); + +@override final int id; +@override final String name; +@override final String description; +@override final int type; +@override final bool isPublic; +@override final SnCloudFile? picture; +@override final SnCloudFile? background; +@override final int? realmId; +@override final SnRealm? realm; +@override final DateTime createdAt; +@override final DateTime updatedAt; +@override final DateTime? deletedAt; + +/// Create a copy of SnChat +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$SnChatCopyWith<_SnChat> get copyWith => __$SnChatCopyWithImpl<_SnChat>(this, _$identity); + +@override +Map toJson() { + return _$SnChatToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnChat&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.type, type) || other.type == type)&&(identical(other.isPublic, isPublic) || other.isPublic == isPublic)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.background, background) || other.background == background)&&(identical(other.realmId, realmId) || other.realmId == realmId)&&(identical(other.realm, realm) || other.realm == realm)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,name,description,type,isPublic,picture,background,realmId,realm,createdAt,updatedAt,deletedAt); + +@override +String toString() { + return 'SnChat(id: $id, name: $name, description: $description, type: $type, isPublic: $isPublic, picture: $picture, background: $background, realmId: $realmId, realm: $realm, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; +} + + +} + +/// @nodoc +abstract mixin class _$SnChatCopyWith<$Res> implements $SnChatCopyWith<$Res> { + factory _$SnChatCopyWith(_SnChat value, $Res Function(_SnChat) _then) = __$SnChatCopyWithImpl; +@override @useResult +$Res call({ + int id, String name, String description, int type, bool isPublic, SnCloudFile? picture, SnCloudFile? background, int? realmId, SnRealm? realm, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt +}); + + +@override $SnCloudFileCopyWith<$Res>? get picture;@override $SnCloudFileCopyWith<$Res>? get background;@override $SnRealmCopyWith<$Res>? get realm; + +} +/// @nodoc +class __$SnChatCopyWithImpl<$Res> + implements _$SnChatCopyWith<$Res> { + __$SnChatCopyWithImpl(this._self, this._then); + + final _SnChat _self; + final $Res Function(_SnChat) _then; + +/// Create a copy of SnChat +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? name = null,Object? description = null,Object? type = null,Object? isPublic = null,Object? picture = freezed,Object? background = freezed,Object? realmId = freezed,Object? realm = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { + return _then(_SnChat( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as int,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable +as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as int,isPublic: null == isPublic ? _self.isPublic : isPublic // ignore: cast_nullable_to_non_nullable +as bool,picture: freezed == picture ? _self.picture : picture // ignore: cast_nullable_to_non_nullable +as SnCloudFile?,background: freezed == background ? _self.background : background // ignore: cast_nullable_to_non_nullable +as SnCloudFile?,realmId: freezed == realmId ? _self.realmId : realmId // ignore: cast_nullable_to_non_nullable +as int?,realm: freezed == realm ? _self.realm : realm // ignore: cast_nullable_to_non_nullable +as SnRealm?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable +as DateTime,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); +} + +/// Create a copy of SnChat +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$SnCloudFileCopyWith<$Res>? get picture { + if (_self.picture == null) { + return null; + } + + return $SnCloudFileCopyWith<$Res>(_self.picture!, (value) { + return _then(_self.copyWith(picture: value)); + }); +}/// Create a copy of SnChat +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$SnCloudFileCopyWith<$Res>? get background { + if (_self.background == null) { + return null; + } + + return $SnCloudFileCopyWith<$Res>(_self.background!, (value) { + return _then(_self.copyWith(background: value)); + }); +}/// Create a copy of SnChat +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$SnRealmCopyWith<$Res>? get realm { + if (_self.realm == null) { + return null; + } + + return $SnRealmCopyWith<$Res>(_self.realm!, (value) { + return _then(_self.copyWith(realm: value)); + }); +} +} + +// dart format on diff --git a/lib/models/chat.g.dart b/lib/models/chat.g.dart new file mode 100644 index 0000000..128f21e --- /dev/null +++ b/lib/models/chat.g.dart @@ -0,0 +1,49 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'chat.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_SnChat _$SnChatFromJson(Map json) => _SnChat( + id: (json['id'] as num).toInt(), + name: json['name'] as String, + description: json['description'] as String, + type: (json['type'] as num).toInt(), + isPublic: json['is_public'] as bool, + picture: + json['picture'] == null + ? null + : SnCloudFile.fromJson(json['picture'] as Map), + background: + json['background'] == null + ? null + : SnCloudFile.fromJson(json['background'] as Map), + realmId: (json['realm_id'] as num?)?.toInt(), + realm: + json['realm'] == null + ? null + : SnRealm.fromJson(json['realm'] as Map), + createdAt: DateTime.parse(json['created_at'] as String), + updatedAt: DateTime.parse(json['updated_at'] as String), + deletedAt: + json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), +); + +Map _$SnChatToJson(_SnChat instance) => { + 'id': instance.id, + 'name': instance.name, + 'description': instance.description, + 'type': instance.type, + 'is_public': instance.isPublic, + 'picture': instance.picture?.toJson(), + 'background': instance.background?.toJson(), + 'realm_id': instance.realmId, + 'realm': instance.realm?.toJson(), + 'created_at': instance.createdAt.toIso8601String(), + 'updated_at': instance.updatedAt.toIso8601String(), + 'deleted_at': instance.deletedAt?.toIso8601String(), +}; diff --git a/lib/models/post.dart b/lib/models/post.dart index 1101782..e0b1c6e 100644 --- a/lib/models/post.dart +++ b/lib/models/post.dart @@ -33,10 +33,9 @@ abstract class SnPost with _$SnPost { required List tags, required List categories, required List collections, - required bool empty, required DateTime createdAt, required DateTime updatedAt, - required dynamic deletedAt, + required DateTime? deletedAt, }) = _SnPost; factory SnPost.fromJson(Map json) => _$SnPostFromJson(json); diff --git a/lib/models/post.freezed.dart b/lib/models/post.freezed.dart index ae3d95b..3a811e6 100644 --- a/lib/models/post.freezed.dart +++ b/lib/models/post.freezed.dart @@ -16,7 +16,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$SnPost { - int get id; String? get title; String? get description; String? get language; DateTime? get editedAt; DateTime get publishedAt; int get visibility; List? get content; int get type; Map? get meta; int get viewsUnique; int get viewsTotal; int get upvotes; int get downvotes; dynamic get threadedPostId; dynamic get threadedPost; dynamic get repliedPostId; dynamic get repliedPost; dynamic get forwardedPostId; dynamic get forwardedPost; List get attachments; SnPublisher get publisher; List get reactions; List get tags; List get categories; List get collections; bool get empty; DateTime get createdAt; DateTime get updatedAt; dynamic get deletedAt; + int get id; String? get title; String? get description; String? get language; DateTime? get editedAt; DateTime get publishedAt; int get visibility; List? get content; int get type; Map? get meta; int get viewsUnique; int get viewsTotal; int get upvotes; int get downvotes; dynamic get threadedPostId; dynamic get threadedPost; dynamic get repliedPostId; dynamic get repliedPost; dynamic get forwardedPostId; dynamic get forwardedPost; List get attachments; SnPublisher get publisher; List get reactions; List get tags; List get categories; List get collections; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; /// Create a copy of SnPost /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -29,16 +29,16 @@ $SnPostCopyWith get copyWith => _$SnPostCopyWithImpl(this as SnP @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is SnPost&&(identical(other.id, id) || other.id == id)&&(identical(other.title, title) || other.title == title)&&(identical(other.description, description) || other.description == description)&&(identical(other.language, language) || other.language == language)&&(identical(other.editedAt, editedAt) || other.editedAt == editedAt)&&(identical(other.publishedAt, publishedAt) || other.publishedAt == publishedAt)&&(identical(other.visibility, visibility) || other.visibility == visibility)&&const DeepCollectionEquality().equals(other.content, content)&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other.meta, meta)&&(identical(other.viewsUnique, viewsUnique) || other.viewsUnique == viewsUnique)&&(identical(other.viewsTotal, viewsTotal) || other.viewsTotal == viewsTotal)&&(identical(other.upvotes, upvotes) || other.upvotes == upvotes)&&(identical(other.downvotes, downvotes) || other.downvotes == downvotes)&&const DeepCollectionEquality().equals(other.threadedPostId, threadedPostId)&&const DeepCollectionEquality().equals(other.threadedPost, threadedPost)&&const DeepCollectionEquality().equals(other.repliedPostId, repliedPostId)&&const DeepCollectionEquality().equals(other.repliedPost, repliedPost)&&const DeepCollectionEquality().equals(other.forwardedPostId, forwardedPostId)&&const DeepCollectionEquality().equals(other.forwardedPost, forwardedPost)&&const DeepCollectionEquality().equals(other.attachments, attachments)&&(identical(other.publisher, publisher) || other.publisher == publisher)&&const DeepCollectionEquality().equals(other.reactions, reactions)&&const DeepCollectionEquality().equals(other.tags, tags)&&const DeepCollectionEquality().equals(other.categories, categories)&&const DeepCollectionEquality().equals(other.collections, collections)&&(identical(other.empty, empty) || other.empty == empty)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&const DeepCollectionEquality().equals(other.deletedAt, deletedAt)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is SnPost&&(identical(other.id, id) || other.id == id)&&(identical(other.title, title) || other.title == title)&&(identical(other.description, description) || other.description == description)&&(identical(other.language, language) || other.language == language)&&(identical(other.editedAt, editedAt) || other.editedAt == editedAt)&&(identical(other.publishedAt, publishedAt) || other.publishedAt == publishedAt)&&(identical(other.visibility, visibility) || other.visibility == visibility)&&const DeepCollectionEquality().equals(other.content, content)&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other.meta, meta)&&(identical(other.viewsUnique, viewsUnique) || other.viewsUnique == viewsUnique)&&(identical(other.viewsTotal, viewsTotal) || other.viewsTotal == viewsTotal)&&(identical(other.upvotes, upvotes) || other.upvotes == upvotes)&&(identical(other.downvotes, downvotes) || other.downvotes == downvotes)&&const DeepCollectionEquality().equals(other.threadedPostId, threadedPostId)&&const DeepCollectionEquality().equals(other.threadedPost, threadedPost)&&const DeepCollectionEquality().equals(other.repliedPostId, repliedPostId)&&const DeepCollectionEquality().equals(other.repliedPost, repliedPost)&&const DeepCollectionEquality().equals(other.forwardedPostId, forwardedPostId)&&const DeepCollectionEquality().equals(other.forwardedPost, forwardedPost)&&const DeepCollectionEquality().equals(other.attachments, attachments)&&(identical(other.publisher, publisher) || other.publisher == publisher)&&const DeepCollectionEquality().equals(other.reactions, reactions)&&const DeepCollectionEquality().equals(other.tags, tags)&&const DeepCollectionEquality().equals(other.categories, categories)&&const DeepCollectionEquality().equals(other.collections, collections)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hashAll([runtimeType,id,title,description,language,editedAt,publishedAt,visibility,const DeepCollectionEquality().hash(content),type,const DeepCollectionEquality().hash(meta),viewsUnique,viewsTotal,upvotes,downvotes,const DeepCollectionEquality().hash(threadedPostId),const DeepCollectionEquality().hash(threadedPost),const DeepCollectionEquality().hash(repliedPostId),const DeepCollectionEquality().hash(repliedPost),const DeepCollectionEquality().hash(forwardedPostId),const DeepCollectionEquality().hash(forwardedPost),const DeepCollectionEquality().hash(attachments),publisher,const DeepCollectionEquality().hash(reactions),const DeepCollectionEquality().hash(tags),const DeepCollectionEquality().hash(categories),const DeepCollectionEquality().hash(collections),empty,createdAt,updatedAt,const DeepCollectionEquality().hash(deletedAt)]); +int get hashCode => Object.hashAll([runtimeType,id,title,description,language,editedAt,publishedAt,visibility,const DeepCollectionEquality().hash(content),type,const DeepCollectionEquality().hash(meta),viewsUnique,viewsTotal,upvotes,downvotes,const DeepCollectionEquality().hash(threadedPostId),const DeepCollectionEquality().hash(threadedPost),const DeepCollectionEquality().hash(repliedPostId),const DeepCollectionEquality().hash(repliedPost),const DeepCollectionEquality().hash(forwardedPostId),const DeepCollectionEquality().hash(forwardedPost),const DeepCollectionEquality().hash(attachments),publisher,const DeepCollectionEquality().hash(reactions),const DeepCollectionEquality().hash(tags),const DeepCollectionEquality().hash(categories),const DeepCollectionEquality().hash(collections),createdAt,updatedAt,deletedAt]); @override String toString() { - return 'SnPost(id: $id, title: $title, description: $description, language: $language, editedAt: $editedAt, publishedAt: $publishedAt, visibility: $visibility, content: $content, type: $type, meta: $meta, viewsUnique: $viewsUnique, viewsTotal: $viewsTotal, upvotes: $upvotes, downvotes: $downvotes, threadedPostId: $threadedPostId, threadedPost: $threadedPost, repliedPostId: $repliedPostId, repliedPost: $repliedPost, forwardedPostId: $forwardedPostId, forwardedPost: $forwardedPost, attachments: $attachments, publisher: $publisher, reactions: $reactions, tags: $tags, categories: $categories, collections: $collections, empty: $empty, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; + return 'SnPost(id: $id, title: $title, description: $description, language: $language, editedAt: $editedAt, publishedAt: $publishedAt, visibility: $visibility, content: $content, type: $type, meta: $meta, viewsUnique: $viewsUnique, viewsTotal: $viewsTotal, upvotes: $upvotes, downvotes: $downvotes, threadedPostId: $threadedPostId, threadedPost: $threadedPost, repliedPostId: $repliedPostId, repliedPost: $repliedPost, forwardedPostId: $forwardedPostId, forwardedPost: $forwardedPost, attachments: $attachments, publisher: $publisher, reactions: $reactions, tags: $tags, categories: $categories, collections: $collections, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; } @@ -49,7 +49,7 @@ abstract mixin class $SnPostCopyWith<$Res> { factory $SnPostCopyWith(SnPost value, $Res Function(SnPost) _then) = _$SnPostCopyWithImpl; @useResult $Res call({ - int id, String? title, String? description, String? language, DateTime? editedAt, DateTime publishedAt, int visibility, List? content, int type, Map? meta, int viewsUnique, int viewsTotal, int upvotes, int downvotes, dynamic threadedPostId, dynamic threadedPost, dynamic repliedPostId, dynamic repliedPost, dynamic forwardedPostId, dynamic forwardedPost, List attachments, SnPublisher publisher, List reactions, List tags, List categories, List collections, bool empty, DateTime createdAt, DateTime updatedAt, dynamic deletedAt + int id, String? title, String? description, String? language, DateTime? editedAt, DateTime publishedAt, int visibility, List? content, int type, Map? meta, int viewsUnique, int viewsTotal, int upvotes, int downvotes, dynamic threadedPostId, dynamic threadedPost, dynamic repliedPostId, dynamic repliedPost, dynamic forwardedPostId, dynamic forwardedPost, List attachments, SnPublisher publisher, List reactions, List tags, List categories, List collections, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt }); @@ -66,7 +66,7 @@ class _$SnPostCopyWithImpl<$Res> /// Create a copy of SnPost /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? title = freezed,Object? description = freezed,Object? language = freezed,Object? editedAt = freezed,Object? publishedAt = null,Object? visibility = null,Object? content = freezed,Object? type = null,Object? meta = freezed,Object? viewsUnique = null,Object? viewsTotal = null,Object? upvotes = null,Object? downvotes = null,Object? threadedPostId = freezed,Object? threadedPost = freezed,Object? repliedPostId = freezed,Object? repliedPost = freezed,Object? forwardedPostId = freezed,Object? forwardedPost = freezed,Object? attachments = null,Object? publisher = null,Object? reactions = null,Object? tags = null,Object? categories = null,Object? collections = null,Object? empty = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? title = freezed,Object? description = freezed,Object? language = freezed,Object? editedAt = freezed,Object? publishedAt = null,Object? visibility = null,Object? content = freezed,Object? type = null,Object? meta = freezed,Object? viewsUnique = null,Object? viewsTotal = null,Object? upvotes = null,Object? downvotes = null,Object? threadedPostId = freezed,Object? threadedPost = freezed,Object? repliedPostId = freezed,Object? repliedPost = freezed,Object? forwardedPostId = freezed,Object? forwardedPost = freezed,Object? attachments = null,Object? publisher = null,Object? reactions = null,Object? tags = null,Object? categories = null,Object? collections = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { return _then(_self.copyWith( id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as int,title: freezed == title ? _self.title : title // ignore: cast_nullable_to_non_nullable @@ -94,11 +94,10 @@ as SnPublisher,reactions: null == reactions ? _self.reactions : reactions // ign as List,tags: null == tags ? _self.tags : tags // ignore: cast_nullable_to_non_nullable as List,categories: null == categories ? _self.categories : categories // ignore: cast_nullable_to_non_nullable as List,collections: null == collections ? _self.collections : collections // ignore: cast_nullable_to_non_nullable -as List,empty: null == empty ? _self.empty : empty // ignore: cast_nullable_to_non_nullable -as bool,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as List,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable as DateTime,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable -as dynamic, +as DateTime?, )); } /// Create a copy of SnPost @@ -118,7 +117,7 @@ $SnPublisherCopyWith<$Res> get publisher { @JsonSerializable() class _SnPost implements SnPost { - const _SnPost({required this.id, required this.title, required this.description, required this.language, required this.editedAt, required this.publishedAt, required this.visibility, required final List? content, required this.type, required final Map? meta, required this.viewsUnique, required this.viewsTotal, required this.upvotes, required this.downvotes, required this.threadedPostId, required this.threadedPost, required this.repliedPostId, required this.repliedPost, required this.forwardedPostId, required this.forwardedPost, required final List attachments, required this.publisher, required final List reactions, required final List tags, required final List categories, required final List collections, required this.empty, required this.createdAt, required this.updatedAt, required this.deletedAt}): _content = content,_meta = meta,_attachments = attachments,_reactions = reactions,_tags = tags,_categories = categories,_collections = collections; + const _SnPost({required this.id, required this.title, required this.description, required this.language, required this.editedAt, required this.publishedAt, required this.visibility, required final List? content, required this.type, required final Map? meta, required this.viewsUnique, required this.viewsTotal, required this.upvotes, required this.downvotes, required this.threadedPostId, required this.threadedPost, required this.repliedPostId, required this.repliedPost, required this.forwardedPostId, required this.forwardedPost, required final List attachments, required this.publisher, required final List reactions, required final List tags, required final List categories, required final List collections, required this.createdAt, required this.updatedAt, required this.deletedAt}): _content = content,_meta = meta,_attachments = attachments,_reactions = reactions,_tags = tags,_categories = categories,_collections = collections; factory _SnPost.fromJson(Map json) => _$SnPostFromJson(json); @override final int id; @@ -193,10 +192,9 @@ class _SnPost implements SnPost { return EqualUnmodifiableListView(_collections); } -@override final bool empty; @override final DateTime createdAt; @override final DateTime updatedAt; -@override final dynamic deletedAt; +@override final DateTime? deletedAt; /// Create a copy of SnPost /// with the given fields replaced by the non-null parameter values. @@ -211,16 +209,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnPost&&(identical(other.id, id) || other.id == id)&&(identical(other.title, title) || other.title == title)&&(identical(other.description, description) || other.description == description)&&(identical(other.language, language) || other.language == language)&&(identical(other.editedAt, editedAt) || other.editedAt == editedAt)&&(identical(other.publishedAt, publishedAt) || other.publishedAt == publishedAt)&&(identical(other.visibility, visibility) || other.visibility == visibility)&&const DeepCollectionEquality().equals(other._content, _content)&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other._meta, _meta)&&(identical(other.viewsUnique, viewsUnique) || other.viewsUnique == viewsUnique)&&(identical(other.viewsTotal, viewsTotal) || other.viewsTotal == viewsTotal)&&(identical(other.upvotes, upvotes) || other.upvotes == upvotes)&&(identical(other.downvotes, downvotes) || other.downvotes == downvotes)&&const DeepCollectionEquality().equals(other.threadedPostId, threadedPostId)&&const DeepCollectionEquality().equals(other.threadedPost, threadedPost)&&const DeepCollectionEquality().equals(other.repliedPostId, repliedPostId)&&const DeepCollectionEquality().equals(other.repliedPost, repliedPost)&&const DeepCollectionEquality().equals(other.forwardedPostId, forwardedPostId)&&const DeepCollectionEquality().equals(other.forwardedPost, forwardedPost)&&const DeepCollectionEquality().equals(other._attachments, _attachments)&&(identical(other.publisher, publisher) || other.publisher == publisher)&&const DeepCollectionEquality().equals(other._reactions, _reactions)&&const DeepCollectionEquality().equals(other._tags, _tags)&&const DeepCollectionEquality().equals(other._categories, _categories)&&const DeepCollectionEquality().equals(other._collections, _collections)&&(identical(other.empty, empty) || other.empty == empty)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&const DeepCollectionEquality().equals(other.deletedAt, deletedAt)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnPost&&(identical(other.id, id) || other.id == id)&&(identical(other.title, title) || other.title == title)&&(identical(other.description, description) || other.description == description)&&(identical(other.language, language) || other.language == language)&&(identical(other.editedAt, editedAt) || other.editedAt == editedAt)&&(identical(other.publishedAt, publishedAt) || other.publishedAt == publishedAt)&&(identical(other.visibility, visibility) || other.visibility == visibility)&&const DeepCollectionEquality().equals(other._content, _content)&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other._meta, _meta)&&(identical(other.viewsUnique, viewsUnique) || other.viewsUnique == viewsUnique)&&(identical(other.viewsTotal, viewsTotal) || other.viewsTotal == viewsTotal)&&(identical(other.upvotes, upvotes) || other.upvotes == upvotes)&&(identical(other.downvotes, downvotes) || other.downvotes == downvotes)&&const DeepCollectionEquality().equals(other.threadedPostId, threadedPostId)&&const DeepCollectionEquality().equals(other.threadedPost, threadedPost)&&const DeepCollectionEquality().equals(other.repliedPostId, repliedPostId)&&const DeepCollectionEquality().equals(other.repliedPost, repliedPost)&&const DeepCollectionEquality().equals(other.forwardedPostId, forwardedPostId)&&const DeepCollectionEquality().equals(other.forwardedPost, forwardedPost)&&const DeepCollectionEquality().equals(other._attachments, _attachments)&&(identical(other.publisher, publisher) || other.publisher == publisher)&&const DeepCollectionEquality().equals(other._reactions, _reactions)&&const DeepCollectionEquality().equals(other._tags, _tags)&&const DeepCollectionEquality().equals(other._categories, _categories)&&const DeepCollectionEquality().equals(other._collections, _collections)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hashAll([runtimeType,id,title,description,language,editedAt,publishedAt,visibility,const DeepCollectionEquality().hash(_content),type,const DeepCollectionEquality().hash(_meta),viewsUnique,viewsTotal,upvotes,downvotes,const DeepCollectionEquality().hash(threadedPostId),const DeepCollectionEquality().hash(threadedPost),const DeepCollectionEquality().hash(repliedPostId),const DeepCollectionEquality().hash(repliedPost),const DeepCollectionEquality().hash(forwardedPostId),const DeepCollectionEquality().hash(forwardedPost),const DeepCollectionEquality().hash(_attachments),publisher,const DeepCollectionEquality().hash(_reactions),const DeepCollectionEquality().hash(_tags),const DeepCollectionEquality().hash(_categories),const DeepCollectionEquality().hash(_collections),empty,createdAt,updatedAt,const DeepCollectionEquality().hash(deletedAt)]); +int get hashCode => Object.hashAll([runtimeType,id,title,description,language,editedAt,publishedAt,visibility,const DeepCollectionEquality().hash(_content),type,const DeepCollectionEquality().hash(_meta),viewsUnique,viewsTotal,upvotes,downvotes,const DeepCollectionEquality().hash(threadedPostId),const DeepCollectionEquality().hash(threadedPost),const DeepCollectionEquality().hash(repliedPostId),const DeepCollectionEquality().hash(repliedPost),const DeepCollectionEquality().hash(forwardedPostId),const DeepCollectionEquality().hash(forwardedPost),const DeepCollectionEquality().hash(_attachments),publisher,const DeepCollectionEquality().hash(_reactions),const DeepCollectionEquality().hash(_tags),const DeepCollectionEquality().hash(_categories),const DeepCollectionEquality().hash(_collections),createdAt,updatedAt,deletedAt]); @override String toString() { - return 'SnPost(id: $id, title: $title, description: $description, language: $language, editedAt: $editedAt, publishedAt: $publishedAt, visibility: $visibility, content: $content, type: $type, meta: $meta, viewsUnique: $viewsUnique, viewsTotal: $viewsTotal, upvotes: $upvotes, downvotes: $downvotes, threadedPostId: $threadedPostId, threadedPost: $threadedPost, repliedPostId: $repliedPostId, repliedPost: $repliedPost, forwardedPostId: $forwardedPostId, forwardedPost: $forwardedPost, attachments: $attachments, publisher: $publisher, reactions: $reactions, tags: $tags, categories: $categories, collections: $collections, empty: $empty, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; + return 'SnPost(id: $id, title: $title, description: $description, language: $language, editedAt: $editedAt, publishedAt: $publishedAt, visibility: $visibility, content: $content, type: $type, meta: $meta, viewsUnique: $viewsUnique, viewsTotal: $viewsTotal, upvotes: $upvotes, downvotes: $downvotes, threadedPostId: $threadedPostId, threadedPost: $threadedPost, repliedPostId: $repliedPostId, repliedPost: $repliedPost, forwardedPostId: $forwardedPostId, forwardedPost: $forwardedPost, attachments: $attachments, publisher: $publisher, reactions: $reactions, tags: $tags, categories: $categories, collections: $collections, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; } @@ -231,7 +229,7 @@ abstract mixin class _$SnPostCopyWith<$Res> implements $SnPostCopyWith<$Res> { factory _$SnPostCopyWith(_SnPost value, $Res Function(_SnPost) _then) = __$SnPostCopyWithImpl; @override @useResult $Res call({ - int id, String? title, String? description, String? language, DateTime? editedAt, DateTime publishedAt, int visibility, List? content, int type, Map? meta, int viewsUnique, int viewsTotal, int upvotes, int downvotes, dynamic threadedPostId, dynamic threadedPost, dynamic repliedPostId, dynamic repliedPost, dynamic forwardedPostId, dynamic forwardedPost, List attachments, SnPublisher publisher, List reactions, List tags, List categories, List collections, bool empty, DateTime createdAt, DateTime updatedAt, dynamic deletedAt + int id, String? title, String? description, String? language, DateTime? editedAt, DateTime publishedAt, int visibility, List? content, int type, Map? meta, int viewsUnique, int viewsTotal, int upvotes, int downvotes, dynamic threadedPostId, dynamic threadedPost, dynamic repliedPostId, dynamic repliedPost, dynamic forwardedPostId, dynamic forwardedPost, List attachments, SnPublisher publisher, List reactions, List tags, List categories, List collections, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt }); @@ -248,7 +246,7 @@ class __$SnPostCopyWithImpl<$Res> /// Create a copy of SnPost /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? title = freezed,Object? description = freezed,Object? language = freezed,Object? editedAt = freezed,Object? publishedAt = null,Object? visibility = null,Object? content = freezed,Object? type = null,Object? meta = freezed,Object? viewsUnique = null,Object? viewsTotal = null,Object? upvotes = null,Object? downvotes = null,Object? threadedPostId = freezed,Object? threadedPost = freezed,Object? repliedPostId = freezed,Object? repliedPost = freezed,Object? forwardedPostId = freezed,Object? forwardedPost = freezed,Object? attachments = null,Object? publisher = null,Object? reactions = null,Object? tags = null,Object? categories = null,Object? collections = null,Object? empty = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? title = freezed,Object? description = freezed,Object? language = freezed,Object? editedAt = freezed,Object? publishedAt = null,Object? visibility = null,Object? content = freezed,Object? type = null,Object? meta = freezed,Object? viewsUnique = null,Object? viewsTotal = null,Object? upvotes = null,Object? downvotes = null,Object? threadedPostId = freezed,Object? threadedPost = freezed,Object? repliedPostId = freezed,Object? repliedPost = freezed,Object? forwardedPostId = freezed,Object? forwardedPost = freezed,Object? attachments = null,Object? publisher = null,Object? reactions = null,Object? tags = null,Object? categories = null,Object? collections = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { return _then(_SnPost( id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as int,title: freezed == title ? _self.title : title // ignore: cast_nullable_to_non_nullable @@ -276,11 +274,10 @@ as SnPublisher,reactions: null == reactions ? _self._reactions : reactions // ig as List,tags: null == tags ? _self._tags : tags // ignore: cast_nullable_to_non_nullable as List,categories: null == categories ? _self._categories : categories // ignore: cast_nullable_to_non_nullable as List,collections: null == collections ? _self._collections : collections // ignore: cast_nullable_to_non_nullable -as List,empty: null == empty ? _self.empty : empty // ignore: cast_nullable_to_non_nullable -as bool,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as List,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable as DateTime,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable -as dynamic, +as DateTime?, )); } diff --git a/lib/models/post.g.dart b/lib/models/post.g.dart index 8eb5afd..322a0e8 100644 --- a/lib/models/post.g.dart +++ b/lib/models/post.g.dart @@ -39,10 +39,12 @@ _SnPost _$SnPostFromJson(Map json) => _SnPost( tags: json['tags'] as List, categories: json['categories'] as List, collections: json['collections'] as List, - empty: json['empty'] as bool, createdAt: DateTime.parse(json['created_at'] as String), updatedAt: DateTime.parse(json['updated_at'] as String), - deletedAt: json['deleted_at'], + deletedAt: + json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), ); Map _$SnPostToJson(_SnPost instance) => { @@ -72,10 +74,9 @@ Map _$SnPostToJson(_SnPost instance) => { 'tags': instance.tags, 'categories': instance.categories, 'collections': instance.collections, - 'empty': instance.empty, 'created_at': instance.createdAt.toIso8601String(), 'updated_at': instance.updatedAt.toIso8601String(), - 'deleted_at': instance.deletedAt, + 'deleted_at': instance.deletedAt?.toIso8601String(), }; _SnPublisher _$SnPublisherFromJson(Map json) => _SnPublisher( diff --git a/lib/models/realm.dart b/lib/models/realm.dart new file mode 100644 index 0000000..0c131ef --- /dev/null +++ b/lib/models/realm.dart @@ -0,0 +1,28 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:island/models/file.dart'; + +part 'realm.freezed.dart'; +part 'realm.g.dart'; + +@freezed +abstract class SnRealm with _$SnRealm { + const factory SnRealm({ + required int id, + required String slug, + required String name, + required String description, + required String? verifiedAs, + required DateTime? verifiedAt, + required bool isCommunity, + required bool isPublic, + required SnCloudFile? picture, + required SnCloudFile? background, + required int accountId, + required DateTime createdAt, + required DateTime updatedAt, + required DateTime? deletedAt, + }) = _SnRealm; + + factory SnRealm.fromJson(Map json) => + _$SnRealmFromJson(json); +} diff --git a/lib/models/realm.freezed.dart b/lib/models/realm.freezed.dart new file mode 100644 index 0000000..7643b5b --- /dev/null +++ b/lib/models/realm.freezed.dart @@ -0,0 +1,235 @@ +// dart format width=80 +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// 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 'realm.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; + +/// @nodoc +mixin _$SnRealm { + + int get id; String get slug; String get name; String get description; String? get verifiedAs; DateTime? get verifiedAt; bool get isCommunity; bool get isPublic; SnCloudFile? get picture; SnCloudFile? get background; int get accountId; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; +/// Create a copy of SnRealm +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$SnRealmCopyWith get copyWith => _$SnRealmCopyWithImpl(this as SnRealm, _$identity); + + /// Serializes this SnRealm to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is SnRealm&&(identical(other.id, id) || other.id == id)&&(identical(other.slug, slug) || other.slug == slug)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.verifiedAs, verifiedAs) || other.verifiedAs == verifiedAs)&&(identical(other.verifiedAt, verifiedAt) || other.verifiedAt == verifiedAt)&&(identical(other.isCommunity, isCommunity) || other.isCommunity == isCommunity)&&(identical(other.isPublic, isPublic) || other.isPublic == isPublic)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.background, background) || other.background == background)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,slug,name,description,verifiedAs,verifiedAt,isCommunity,isPublic,picture,background,accountId,createdAt,updatedAt,deletedAt); + +@override +String toString() { + return 'SnRealm(id: $id, slug: $slug, name: $name, description: $description, verifiedAs: $verifiedAs, verifiedAt: $verifiedAt, isCommunity: $isCommunity, isPublic: $isPublic, picture: $picture, background: $background, accountId: $accountId, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; +} + + +} + +/// @nodoc +abstract mixin class $SnRealmCopyWith<$Res> { + factory $SnRealmCopyWith(SnRealm value, $Res Function(SnRealm) _then) = _$SnRealmCopyWithImpl; +@useResult +$Res call({ + int id, String slug, String name, String description, String? verifiedAs, DateTime? verifiedAt, bool isCommunity, bool isPublic, SnCloudFile? picture, SnCloudFile? background, int accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt +}); + + +$SnCloudFileCopyWith<$Res>? get picture;$SnCloudFileCopyWith<$Res>? get background; + +} +/// @nodoc +class _$SnRealmCopyWithImpl<$Res> + implements $SnRealmCopyWith<$Res> { + _$SnRealmCopyWithImpl(this._self, this._then); + + final SnRealm _self; + final $Res Function(SnRealm) _then; + +/// Create a copy of SnRealm +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? slug = null,Object? name = null,Object? description = null,Object? verifiedAs = freezed,Object? verifiedAt = freezed,Object? isCommunity = null,Object? isPublic = null,Object? picture = freezed,Object? background = freezed,Object? accountId = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { + return _then(_self.copyWith( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as int,slug: null == slug ? _self.slug : slug // ignore: cast_nullable_to_non_nullable +as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable +as String,verifiedAs: freezed == verifiedAs ? _self.verifiedAs : verifiedAs // ignore: cast_nullable_to_non_nullable +as String?,verifiedAt: freezed == verifiedAt ? _self.verifiedAt : verifiedAt // ignore: cast_nullable_to_non_nullable +as DateTime?,isCommunity: null == isCommunity ? _self.isCommunity : isCommunity // ignore: cast_nullable_to_non_nullable +as bool,isPublic: null == isPublic ? _self.isPublic : isPublic // ignore: cast_nullable_to_non_nullable +as bool,picture: freezed == picture ? _self.picture : picture // ignore: cast_nullable_to_non_nullable +as SnCloudFile?,background: freezed == background ? _self.background : background // ignore: cast_nullable_to_non_nullable +as SnCloudFile?,accountId: null == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable +as int,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable +as DateTime,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); +} +/// Create a copy of SnRealm +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$SnCloudFileCopyWith<$Res>? get picture { + if (_self.picture == null) { + return null; + } + + return $SnCloudFileCopyWith<$Res>(_self.picture!, (value) { + return _then(_self.copyWith(picture: value)); + }); +}/// Create a copy of SnRealm +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$SnCloudFileCopyWith<$Res>? get background { + if (_self.background == null) { + return null; + } + + return $SnCloudFileCopyWith<$Res>(_self.background!, (value) { + return _then(_self.copyWith(background: value)); + }); +} +} + + +/// @nodoc +@JsonSerializable() + +class _SnRealm implements SnRealm { + const _SnRealm({required this.id, required this.slug, required this.name, required this.description, required this.verifiedAs, required this.verifiedAt, required this.isCommunity, required this.isPublic, required this.picture, required this.background, required this.accountId, required this.createdAt, required this.updatedAt, required this.deletedAt}); + factory _SnRealm.fromJson(Map json) => _$SnRealmFromJson(json); + +@override final int id; +@override final String slug; +@override final String name; +@override final String description; +@override final String? verifiedAs; +@override final DateTime? verifiedAt; +@override final bool isCommunity; +@override final bool isPublic; +@override final SnCloudFile? picture; +@override final SnCloudFile? background; +@override final int accountId; +@override final DateTime createdAt; +@override final DateTime updatedAt; +@override final DateTime? deletedAt; + +/// Create a copy of SnRealm +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$SnRealmCopyWith<_SnRealm> get copyWith => __$SnRealmCopyWithImpl<_SnRealm>(this, _$identity); + +@override +Map toJson() { + return _$SnRealmToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnRealm&&(identical(other.id, id) || other.id == id)&&(identical(other.slug, slug) || other.slug == slug)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.verifiedAs, verifiedAs) || other.verifiedAs == verifiedAs)&&(identical(other.verifiedAt, verifiedAt) || other.verifiedAt == verifiedAt)&&(identical(other.isCommunity, isCommunity) || other.isCommunity == isCommunity)&&(identical(other.isPublic, isPublic) || other.isPublic == isPublic)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.background, background) || other.background == background)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,slug,name,description,verifiedAs,verifiedAt,isCommunity,isPublic,picture,background,accountId,createdAt,updatedAt,deletedAt); + +@override +String toString() { + return 'SnRealm(id: $id, slug: $slug, name: $name, description: $description, verifiedAs: $verifiedAs, verifiedAt: $verifiedAt, isCommunity: $isCommunity, isPublic: $isPublic, picture: $picture, background: $background, accountId: $accountId, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; +} + + +} + +/// @nodoc +abstract mixin class _$SnRealmCopyWith<$Res> implements $SnRealmCopyWith<$Res> { + factory _$SnRealmCopyWith(_SnRealm value, $Res Function(_SnRealm) _then) = __$SnRealmCopyWithImpl; +@override @useResult +$Res call({ + int id, String slug, String name, String description, String? verifiedAs, DateTime? verifiedAt, bool isCommunity, bool isPublic, SnCloudFile? picture, SnCloudFile? background, int accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt +}); + + +@override $SnCloudFileCopyWith<$Res>? get picture;@override $SnCloudFileCopyWith<$Res>? get background; + +} +/// @nodoc +class __$SnRealmCopyWithImpl<$Res> + implements _$SnRealmCopyWith<$Res> { + __$SnRealmCopyWithImpl(this._self, this._then); + + final _SnRealm _self; + final $Res Function(_SnRealm) _then; + +/// Create a copy of SnRealm +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? slug = null,Object? name = null,Object? description = null,Object? verifiedAs = freezed,Object? verifiedAt = freezed,Object? isCommunity = null,Object? isPublic = null,Object? picture = freezed,Object? background = freezed,Object? accountId = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { + return _then(_SnRealm( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as int,slug: null == slug ? _self.slug : slug // ignore: cast_nullable_to_non_nullable +as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable +as String,verifiedAs: freezed == verifiedAs ? _self.verifiedAs : verifiedAs // ignore: cast_nullable_to_non_nullable +as String?,verifiedAt: freezed == verifiedAt ? _self.verifiedAt : verifiedAt // ignore: cast_nullable_to_non_nullable +as DateTime?,isCommunity: null == isCommunity ? _self.isCommunity : isCommunity // ignore: cast_nullable_to_non_nullable +as bool,isPublic: null == isPublic ? _self.isPublic : isPublic // ignore: cast_nullable_to_non_nullable +as bool,picture: freezed == picture ? _self.picture : picture // ignore: cast_nullable_to_non_nullable +as SnCloudFile?,background: freezed == background ? _self.background : background // ignore: cast_nullable_to_non_nullable +as SnCloudFile?,accountId: null == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable +as int,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable +as DateTime,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); +} + +/// Create a copy of SnRealm +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$SnCloudFileCopyWith<$Res>? get picture { + if (_self.picture == null) { + return null; + } + + return $SnCloudFileCopyWith<$Res>(_self.picture!, (value) { + return _then(_self.copyWith(picture: value)); + }); +}/// Create a copy of SnRealm +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$SnCloudFileCopyWith<$Res>? get background { + if (_self.background == null) { + return null; + } + + return $SnCloudFileCopyWith<$Res>(_self.background!, (value) { + return _then(_self.copyWith(background: value)); + }); +} +} + +// dart format on diff --git a/lib/models/realm.g.dart b/lib/models/realm.g.dart new file mode 100644 index 0000000..3932969 --- /dev/null +++ b/lib/models/realm.g.dart @@ -0,0 +1,53 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'realm.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_SnRealm _$SnRealmFromJson(Map json) => _SnRealm( + id: (json['id'] as num).toInt(), + slug: json['slug'] as String, + name: json['name'] as String, + description: json['description'] as String, + verifiedAs: json['verified_as'] as String?, + verifiedAt: + json['verified_at'] == null + ? null + : DateTime.parse(json['verified_at'] as String), + isCommunity: json['is_community'] as bool, + isPublic: json['is_public'] as bool, + picture: + json['picture'] == null + ? null + : SnCloudFile.fromJson(json['picture'] as Map), + background: + json['background'] == null + ? null + : SnCloudFile.fromJson(json['background'] as Map), + accountId: (json['account_id'] as num).toInt(), + createdAt: DateTime.parse(json['created_at'] as String), + updatedAt: DateTime.parse(json['updated_at'] as String), + deletedAt: + json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), +); + +Map _$SnRealmToJson(_SnRealm instance) => { + 'id': instance.id, + 'slug': instance.slug, + 'name': instance.name, + 'description': instance.description, + 'verified_as': instance.verifiedAs, + 'verified_at': instance.verifiedAt?.toIso8601String(), + 'is_community': instance.isCommunity, + 'is_public': instance.isPublic, + 'picture': instance.picture?.toJson(), + 'background': instance.background?.toJson(), + 'account_id': instance.accountId, + 'created_at': instance.createdAt.toIso8601String(), + 'updated_at': instance.updatedAt.toIso8601String(), + 'deleted_at': instance.deletedAt?.toIso8601String(), +}; diff --git a/lib/route.dart b/lib/route.dart index 8dd1022..5b25f16 100644 --- a/lib/route.dart +++ b/lib/route.dart @@ -15,6 +15,7 @@ class AppRouter extends RootStackRouter { children: [ AutoRoute(page: ExploreRoute.page, path: 'explore'), AutoRoute(page: AccountRoute.page, path: 'account'), + AutoRoute(page: RealmListRoute.page, path: 'realms'), ], ), AutoRoute(page: LoginRoute.page, path: '/auth/login'), @@ -25,10 +26,12 @@ class AppRouter extends RootStackRouter { AutoRoute(page: NewPublisherRoute.page, path: '/account/me/publishers/new'), AutoRoute( page: EditPublisherRoute.page, - path: '/account/me/publishers/:id', + path: '/account/me/publishers/:id/edit', ), AutoRoute(page: PostComposeRoute.page, path: '/posts/compose'), AutoRoute(page: PostDetailRoute.page, path: '/posts/:id'), AutoRoute(page: PostEditRoute.page, path: '/posts/:id/edit'), + AutoRoute(page: NewRealmRoute.page, path: '/realms/new'), + AutoRoute(page: EditRealmRoute.page, path: '/realms/:slug/edit'), ]; } diff --git a/lib/route.gr.dart b/lib/route.gr.dart index 08522f2..12aa68b 100644 --- a/lib/route.gr.dart +++ b/lib/route.gr.dart @@ -9,29 +9,30 @@ // coverage:ignore-file // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'package:auto_route/auto_route.dart' as _i11; -import 'package:flutter/material.dart' as _i12; -import 'package:island/models/post.dart' as _i13; +import 'package:auto_route/auto_route.dart' as _i12; +import 'package:flutter/material.dart' as _i13; +import 'package:island/models/post.dart' as _i14; import 'package:island/screens/account.dart' as _i1; -import 'package:island/screens/account/me.dart' as _i6; +import 'package:island/screens/account/me.dart' as _i7; import 'package:island/screens/account/me/publishers.dart' as _i3; -import 'package:island/screens/account/me/update.dart' as _i10; +import 'package:island/screens/account/me/update.dart' as _i11; import 'package:island/screens/auth/create_account.dart' as _i2; -import 'package:island/screens/auth/login.dart' as _i5; -import 'package:island/screens/auth/tabs.dart' as _i9; -import 'package:island/screens/explore.dart' as _i4; -import 'package:island/screens/posts/compose.dart' as _i7; -import 'package:island/screens/posts/detail.dart' as _i8; +import 'package:island/screens/auth/login.dart' as _i6; +import 'package:island/screens/auth/tabs.dart' as _i10; +import 'package:island/screens/explore.dart' as _i5; +import 'package:island/screens/posts/compose.dart' as _i8; +import 'package:island/screens/posts/detail.dart' as _i9; +import 'package:island/screens/realm/realms.dart' as _i4; /// generated route for /// [_i1.AccountScreen] -class AccountRoute extends _i11.PageRouteInfo { - const AccountRoute({List<_i11.PageRouteInfo>? children}) +class AccountRoute extends _i12.PageRouteInfo { + const AccountRoute({List<_i12.PageRouteInfo>? children}) : super(AccountRoute.name, initialChildren: children); static const String name = 'AccountRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { return const _i1.AccountScreen(); @@ -41,13 +42,13 @@ class AccountRoute extends _i11.PageRouteInfo { /// generated route for /// [_i2.CreateAccountScreen] -class CreateAccountRoute extends _i11.PageRouteInfo { - const CreateAccountRoute({List<_i11.PageRouteInfo>? children}) +class CreateAccountRoute extends _i12.PageRouteInfo { + const CreateAccountRoute({List<_i12.PageRouteInfo>? children}) : super(CreateAccountRoute.name, initialChildren: children); static const String name = 'CreateAccountRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { return const _i2.CreateAccountScreen(); @@ -57,11 +58,11 @@ class CreateAccountRoute extends _i11.PageRouteInfo { /// generated route for /// [_i3.EditPublisherScreen] -class EditPublisherRoute extends _i11.PageRouteInfo { +class EditPublisherRoute extends _i12.PageRouteInfo { EditPublisherRoute({ - _i12.Key? key, + _i13.Key? key, String? name, - List<_i11.PageRouteInfo>? children, + List<_i12.PageRouteInfo>? children, }) : super( EditPublisherRoute.name, args: EditPublisherRouteArgs(key: key, name: name), @@ -71,7 +72,7 @@ class EditPublisherRoute extends _i11.PageRouteInfo { static const String name = 'EditPublisherRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -86,7 +87,7 @@ class EditPublisherRoute extends _i11.PageRouteInfo { class EditPublisherRouteArgs { const EditPublisherRouteArgs({this.key, this.name}); - final _i12.Key? key; + final _i13.Key? key; final String? name; @@ -97,46 +98,87 @@ class EditPublisherRouteArgs { } /// generated route for -/// [_i4.ExploreScreen] -class ExploreRoute extends _i11.PageRouteInfo { - const ExploreRoute({List<_i11.PageRouteInfo>? children}) +/// [_i4.EditRealmScreen] +class EditRealmRoute extends _i12.PageRouteInfo { + EditRealmRoute({ + _i13.Key? key, + String? slug, + List<_i12.PageRouteInfo>? children, + }) : super( + EditRealmRoute.name, + args: EditRealmRouteArgs(key: key, slug: slug), + rawPathParams: {'slug': slug}, + initialChildren: children, + ); + + static const String name = 'EditRealmRoute'; + + static _i12.PageInfo page = _i12.PageInfo( + name, + builder: (data) { + final pathParams = data.inheritedPathParams; + final args = data.argsAs( + orElse: () => EditRealmRouteArgs(slug: pathParams.optString('slug')), + ); + return _i4.EditRealmScreen(key: args.key, slug: args.slug); + }, + ); +} + +class EditRealmRouteArgs { + const EditRealmRouteArgs({this.key, this.slug}); + + final _i13.Key? key; + + final String? slug; + + @override + String toString() { + return 'EditRealmRouteArgs{key: $key, slug: $slug}'; + } +} + +/// generated route for +/// [_i5.ExploreScreen] +class ExploreRoute extends _i12.PageRouteInfo { + const ExploreRoute({List<_i12.PageRouteInfo>? children}) : super(ExploreRoute.name, initialChildren: children); static const String name = 'ExploreRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { - return const _i4.ExploreScreen(); + return const _i5.ExploreScreen(); }, ); } /// generated route for -/// [_i5.LoginScreen] -class LoginRoute extends _i11.PageRouteInfo { - const LoginRoute({List<_i11.PageRouteInfo>? children}) +/// [_i6.LoginScreen] +class LoginRoute extends _i12.PageRouteInfo { + const LoginRoute({List<_i12.PageRouteInfo>? children}) : super(LoginRoute.name, initialChildren: children); static const String name = 'LoginRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { - return const _i5.LoginScreen(); + return const _i6.LoginScreen(); }, ); } /// generated route for /// [_i3.ManagedPublisherScreen] -class ManagedPublisherRoute extends _i11.PageRouteInfo { - const ManagedPublisherRoute({List<_i11.PageRouteInfo>? children}) +class ManagedPublisherRoute extends _i12.PageRouteInfo { + const ManagedPublisherRoute({List<_i12.PageRouteInfo>? children}) : super(ManagedPublisherRoute.name, initialChildren: children); static const String name = 'ManagedPublisherRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { return const _i3.ManagedPublisherScreen(); @@ -145,30 +187,30 @@ class ManagedPublisherRoute extends _i11.PageRouteInfo { } /// generated route for -/// [_i6.MyselfProfileScreen] -class MyselfProfileRoute extends _i11.PageRouteInfo { - const MyselfProfileRoute({List<_i11.PageRouteInfo>? children}) +/// [_i7.MyselfProfileScreen] +class MyselfProfileRoute extends _i12.PageRouteInfo { + const MyselfProfileRoute({List<_i12.PageRouteInfo>? children}) : super(MyselfProfileRoute.name, initialChildren: children); static const String name = 'MyselfProfileRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { - return const _i6.MyselfProfileScreen(); + return const _i7.MyselfProfileScreen(); }, ); } /// generated route for /// [_i3.NewPublisherScreen] -class NewPublisherRoute extends _i11.PageRouteInfo { - const NewPublisherRoute({List<_i11.PageRouteInfo>? children}) +class NewPublisherRoute extends _i12.PageRouteInfo { + const NewPublisherRoute({List<_i12.PageRouteInfo>? children}) : super(NewPublisherRoute.name, initialChildren: children); static const String name = 'NewPublisherRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { return const _i3.NewPublisherScreen(); @@ -177,12 +219,28 @@ class NewPublisherRoute extends _i11.PageRouteInfo { } /// generated route for -/// [_i7.PostComposeScreen] -class PostComposeRoute extends _i11.PageRouteInfo { +/// [_i4.NewRealmScreen] +class NewRealmRoute extends _i12.PageRouteInfo { + const NewRealmRoute({List<_i12.PageRouteInfo>? children}) + : super(NewRealmRoute.name, initialChildren: children); + + static const String name = 'NewRealmRoute'; + + static _i12.PageInfo page = _i12.PageInfo( + name, + builder: (data) { + return const _i4.NewRealmScreen(); + }, + ); +} + +/// generated route for +/// [_i8.PostComposeScreen] +class PostComposeRoute extends _i12.PageRouteInfo { PostComposeRoute({ - _i12.Key? key, - _i13.SnPost? originalPost, - List<_i11.PageRouteInfo>? children, + _i13.Key? key, + _i14.SnPost? originalPost, + List<_i12.PageRouteInfo>? children, }) : super( PostComposeRoute.name, args: PostComposeRouteArgs(key: key, originalPost: originalPost), @@ -191,13 +249,13 @@ class PostComposeRoute extends _i11.PageRouteInfo { static const String name = 'PostComposeRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { final args = data.argsAs( orElse: () => const PostComposeRouteArgs(), ); - return _i7.PostComposeScreen( + return _i8.PostComposeScreen( key: args.key, originalPost: args.originalPost, ); @@ -208,9 +266,9 @@ class PostComposeRoute extends _i11.PageRouteInfo { class PostComposeRouteArgs { const PostComposeRouteArgs({this.key, this.originalPost}); - final _i12.Key? key; + final _i13.Key? key; - final _i13.SnPost? originalPost; + final _i14.SnPost? originalPost; @override String toString() { @@ -219,12 +277,12 @@ class PostComposeRouteArgs { } /// generated route for -/// [_i8.PostDetailScreen] -class PostDetailRoute extends _i11.PageRouteInfo { +/// [_i9.PostDetailScreen] +class PostDetailRoute extends _i12.PageRouteInfo { PostDetailRoute({ - _i12.Key? key, + _i13.Key? key, required int id, - List<_i11.PageRouteInfo>? children, + List<_i12.PageRouteInfo>? children, }) : super( PostDetailRoute.name, args: PostDetailRouteArgs(key: key, id: id), @@ -234,14 +292,14 @@ class PostDetailRoute extends _i11.PageRouteInfo { static const String name = 'PostDetailRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; final args = data.argsAs( orElse: () => PostDetailRouteArgs(id: pathParams.getInt('id')), ); - return _i8.PostDetailScreen(key: args.key, id: args.id); + return _i9.PostDetailScreen(key: args.key, id: args.id); }, ); } @@ -249,7 +307,7 @@ class PostDetailRoute extends _i11.PageRouteInfo { class PostDetailRouteArgs { const PostDetailRouteArgs({this.key, required this.id}); - final _i12.Key? key; + final _i13.Key? key; final int id; @@ -260,12 +318,12 @@ class PostDetailRouteArgs { } /// generated route for -/// [_i7.PostEditScreen] -class PostEditRoute extends _i11.PageRouteInfo { +/// [_i8.PostEditScreen] +class PostEditRoute extends _i12.PageRouteInfo { PostEditRoute({ - _i12.Key? key, + _i13.Key? key, required int id, - List<_i11.PageRouteInfo>? children, + List<_i12.PageRouteInfo>? children, }) : super( PostEditRoute.name, args: PostEditRouteArgs(key: key, id: id), @@ -275,14 +333,14 @@ class PostEditRoute extends _i11.PageRouteInfo { static const String name = 'PostEditRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; final args = data.argsAs( orElse: () => PostEditRouteArgs(id: pathParams.getInt('id')), ); - return _i7.PostEditScreen(key: args.key, id: args.id); + return _i8.PostEditScreen(key: args.key, id: args.id); }, ); } @@ -290,7 +348,7 @@ class PostEditRoute extends _i11.PageRouteInfo { class PostEditRouteArgs { const PostEditRouteArgs({this.key, required this.id}); - final _i12.Key? key; + final _i13.Key? key; final int id; @@ -301,33 +359,49 @@ class PostEditRouteArgs { } /// generated route for -/// [_i9.TabsScreen] -class TabsRoute extends _i11.PageRouteInfo { - const TabsRoute({List<_i11.PageRouteInfo>? children}) - : super(TabsRoute.name, initialChildren: children); +/// [_i4.RealmListScreen] +class RealmListRoute extends _i12.PageRouteInfo { + const RealmListRoute({List<_i12.PageRouteInfo>? children}) + : super(RealmListRoute.name, initialChildren: children); - static const String name = 'TabsRoute'; + static const String name = 'RealmListRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { - return const _i9.TabsScreen(); + return const _i4.RealmListScreen(); }, ); } /// generated route for -/// [_i10.UpdateProfileScreen] -class UpdateProfileRoute extends _i11.PageRouteInfo { - const UpdateProfileRoute({List<_i11.PageRouteInfo>? children}) +/// [_i10.TabsScreen] +class TabsRoute extends _i12.PageRouteInfo { + const TabsRoute({List<_i12.PageRouteInfo>? children}) + : super(TabsRoute.name, initialChildren: children); + + static const String name = 'TabsRoute'; + + static _i12.PageInfo page = _i12.PageInfo( + name, + builder: (data) { + return const _i10.TabsScreen(); + }, + ); +} + +/// generated route for +/// [_i11.UpdateProfileScreen] +class UpdateProfileRoute extends _i12.PageRouteInfo { + const UpdateProfileRoute({List<_i12.PageRouteInfo>? children}) : super(UpdateProfileRoute.name, initialChildren: children); static const String name = 'UpdateProfileRoute'; - static _i11.PageInfo page = _i11.PageInfo( + static _i12.PageInfo page = _i12.PageInfo( name, builder: (data) { - return const _i10.UpdateProfileScreen(); + return const _i11.UpdateProfileScreen(); }, ); } diff --git a/lib/screens/account.dart b/lib/screens/account.dart index 868b474..a8389ff 100644 --- a/lib/screens/account.dart +++ b/lib/screens/account.dart @@ -1,8 +1,11 @@ import 'package:auto_route/auto_route.dart'; import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:island/pods/network.dart'; import 'package:island/pods/userinfo.dart'; import 'package:island/route.gr.dart'; import 'package:island/widgets/app_scaffold.dart'; @@ -29,7 +32,7 @@ class AccountScreen extends HookConsumerWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - if (user.value!.profile.background != null) + if (user.value?.profile.background != null) ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(8), @@ -94,7 +97,20 @@ class AccountScreen extends HookConsumerWidget { context.router.push(UpdateProfileRoute()); }, ), - const Divider(height: 1).padding(vertical: 4), + if (kDebugMode) const Divider(height: 1).padding(vertical: 8), + if (kDebugMode) + ListTile( + minTileHeight: 48, + leading: const Icon(Symbols.copy_all), + trailing: const Icon(Symbols.chevron_right), + contentPadding: EdgeInsets.symmetric(horizontal: 24), + title: Text('Copy access token'), + onTap: () async { + final tk = ref.watch(tokenPairProvider); + Clipboard.setData(ClipboardData(text: tk!.accessToken)); + }, + ), + const Divider(height: 1).padding(vertical: 8), ListTile( minTileHeight: 48, leading: const Icon(Symbols.logout), diff --git a/lib/screens/account/me/publishers.dart b/lib/screens/account/me/publishers.dart index 4c4d44f..36f733b 100644 --- a/lib/screens/account/me/publishers.dart +++ b/lib/screens/account/me/publishers.dart @@ -51,8 +51,8 @@ class ManagedPublisherScreen extends HookConsumerWidget { children: [ ListTile( leading: const Icon(Symbols.add), - title: Text('Create a publisher').tr(), - subtitle: Text('To create posts, collections, etc.'), + title: Text('createPublisher').tr(), + subtitle: Text('createPublisherHint').tr(), trailing: const Icon(Symbols.chevron_right), contentPadding: const EdgeInsets.symmetric(horizontal: 24), onTap: () { @@ -79,7 +79,7 @@ class ManagedPublisherScreen extends HookConsumerWidget { IconButton( padding: EdgeInsets.zero, visualDensity: VisualDensity.compact, - icon: Icon(Symbols.delete, size: 16), + icon: Icon(Symbols.delete), onPressed: () { showConfirmAlert( 'deletePublisherHint'.tr(), @@ -102,7 +102,7 @@ class ManagedPublisherScreen extends HookConsumerWidget { IconButton( padding: EdgeInsets.zero, visualDensity: VisualDensity.compact, - icon: Icon(Symbols.edit, size: 16), + icon: Icon(Symbols.edit), onPressed: () { context.router .push( diff --git a/lib/screens/auth/login.dart b/lib/screens/auth/login.dart index 57dfc4a..e49ca19 100644 --- a/lib/screens/auth/login.dart +++ b/lib/screens/auth/login.dart @@ -19,6 +19,17 @@ import 'package:material_symbols_icons/symbols.dart'; import 'package:styled_widget/styled_widget.dart'; import 'package:url_launcher/url_launcher_string.dart'; +final Map kFactorTypes = { + 0: ('authFactorPassword', 'authFactorPasswordDescription', Symbols.password), + 1: ('authFactorEmail', 'authFactorEmailDescription', Symbols.email), + 2: ('authFactorTOTP', 'authFactorTOTPDescription', Symbols.timer), + 3: ( + 'authFactorInAppNotify', + 'authFactorInAppNotifyDescription', + Symbols.notifications_active, + ), +}; + @RoutePage() class LoginScreen extends HookConsumerWidget { const LoginScreen({super.key}); @@ -274,8 +285,10 @@ class _LoginPickerScreen extends HookConsumerWidget { shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(8)), ), - secondary: const Icon(Symbols.question_mark), - title: Text('unknown').tr(), + secondary: Icon( + kFactorTypes[x.type]?.$3 ?? Symbols.question_mark, + ), + title: Text(kFactorTypes[x.type]?.$1 ?? 'unknown').tr(), enabled: !ticket!.blacklistFactors.contains(x.id), value: factorPicked.value == x.id, onChanged: (value) { diff --git a/lib/screens/auth/tabs.dart b/lib/screens/auth/tabs.dart index b0c3e59..7ec429b 100644 --- a/lib/screens/auth/tabs.dart +++ b/lib/screens/auth/tabs.dart @@ -1,4 +1,5 @@ import 'package:auto_route/auto_route.dart'; +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:island/route.gr.dart'; import 'package:material_symbols_icons/symbols.dart'; @@ -10,7 +11,7 @@ class TabsScreen extends StatelessWidget { @override Widget build(BuildContext context) { return AutoTabsRouter.pageView( - routes: const [ExploreRoute(), AccountRoute()], + routes: const [ExploreRoute(), RealmListRoute(), AccountRoute()], builder: (context, child, _) { final tabsRouter = AutoTabsRouter.of(context); return Scaffold( @@ -22,11 +23,15 @@ class TabsScreen extends StatelessWidget { onDestinationSelected: tabsRouter.setActiveIndex, destinations: [ NavigationDestination( - label: 'Explore', + label: 'explore'.tr(), icon: const Icon(Symbols.explore), ), NavigationDestination( - label: 'Account', + label: 'realms'.tr(), + icon: const Icon(Symbols.workspaces), + ), + NavigationDestination( + label: 'account'.tr(), icon: const Icon(Symbols.account_circle), ), ], diff --git a/lib/screens/realm/realms.dart b/lib/screens/realm/realms.dart new file mode 100644 index 0000000..5b22dc1 --- /dev/null +++ b/lib/screens/realm/realms.dart @@ -0,0 +1,339 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:dio/dio.dart'; +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:image_picker/image_picker.dart'; +import 'package:island/models/file.dart'; +import 'package:island/models/realm.dart'; +import 'package:island/pods/config.dart'; +import 'package:island/pods/network.dart'; +import 'package:island/route.gr.dart'; +import 'package:island/screens/account/me/publishers.dart'; +import 'package:island/services/file.dart'; +import 'package:island/widgets/alert.dart'; +import 'package:island/widgets/app_scaffold.dart'; +import 'package:island/widgets/content/cloud_files.dart'; +import 'package:material_symbols_icons/symbols.dart'; +import 'package:riverpod_annotation/riverpod_annotation.dart'; +import 'package:styled_widget/styled_widget.dart'; + +part 'realms.g.dart'; + +@riverpod +Future> realmsJoined(Ref ref) async { + final client = ref.watch(apiClientProvider); + final resp = await client.get('/realms'); + return resp.data.map((e) => SnRealm.fromJson(e)).cast().toList(); +} + +@RoutePage() +class RealmListScreen extends HookConsumerWidget { + const RealmListScreen({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final realms = ref.watch(realmsJoinedProvider); + + return AppScaffold( + appBar: AppBar(title: const Text('realms').tr()), + floatingActionButton: FloatingActionButton( + child: const Icon(Symbols.add), + onPressed: () { + context.router.push(NewRealmRoute()); + }, + ), + body: RefreshIndicator( + child: realms.when( + data: + (value) => Column( + children: [ + Expanded( + child: ListView.builder( + padding: EdgeInsets.only( + bottom: MediaQuery.of(context).padding.bottom, + ), + itemCount: value.length, + itemBuilder: (context, item) { + return ListTile( + leading: ProfilePictureWidget( + item: value[item].picture, + fallbackIcon: Symbols.group, + ), + title: Text(value[item].name), + subtitle: Text(value[item].description), + trailing: Row( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + padding: EdgeInsets.zero, + visualDensity: VisualDensity.compact, + icon: Icon(Symbols.delete), + onPressed: () { + showConfirmAlert( + 'deleteRealmHint'.tr(), + 'deleteRealm'.tr(args: [value[item].name]), + ).then((confirm) { + if (confirm) { + final client = ref.watch( + apiClientProvider, + ); + client.delete( + '/realms/${value[item].slug}', + ); + ref.invalidate(publishersManagedProvider); + } + }); + }, + ), + IconButton( + padding: EdgeInsets.zero, + visualDensity: VisualDensity.compact, + icon: Icon(Symbols.edit), + onPressed: () { + context.router + .push( + EditRealmRoute(slug: value[item].slug), + ) + .then((value) { + if (value != null) { + ref.invalidate(realmsJoinedProvider); + } + }); + }, + ), + ], + ), + contentPadding: EdgeInsets.only(left: 16, right: 14), + ); + }, + ), + ), + ], + ), + loading: () => const Center(child: CircularProgressIndicator()), + error: + (e, _) => GestureDetector( + child: Center( + child: Text('Error: $e', textAlign: TextAlign.center), + ), + onTap: () { + ref.invalidate(realmsJoinedProvider); + }, + ), + ), + onRefresh: () => ref.refresh(realmsJoinedProvider.future), + ), + ); + } +} + +@riverpod +Future realm(Ref ref, String? identifier) async { + if (identifier == null) return null; + final client = ref.watch(apiClientProvider); + final resp = await client.get('/realms/$identifier'); + return SnRealm.fromJson(resp.data); +} + +@RoutePage() +class NewRealmScreen extends StatelessWidget { + const NewRealmScreen({super.key}); + + @override + Widget build(BuildContext context) { + return const EditRealmScreen(); + } +} + +@RoutePage() +class EditRealmScreen extends HookConsumerWidget { + final String? slug; + const EditRealmScreen({super.key, @PathParam('slug') this.slug}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final submitting = useState(false); + + final picture = useState(null); + final background = useState(null); + + final slugController = useTextEditingController(); + final nameController = useTextEditingController(); + final descriptionController = useTextEditingController(); + + final formKey = useMemoized(GlobalKey.new, const []); + + final realm = ref.watch(realmProvider(slug)); + + useEffect(() { + if (realm.value != null) { + picture.value = realm.value!.picture; + background.value = realm.value!.background; + slugController.text = realm.value!.slug; + nameController.text = realm.value!.name; + descriptionController.text = realm.value!.description; + } + return null; + }, [realm]); + + void setPicture(String position) async { + final result = await ref + .read(imagePickerProvider) + .pickImage(source: ImageSource.gallery); + if (result == null) return; + + submitting.value = true; + try { + final baseUrl = ref.watch(serverUrlProvider); + final atk = await getFreshAtk( + ref.watch(tokenPairProvider), + baseUrl, + onRefreshed: (atk, rtk) { + setTokenPair(ref.watch(sharedPreferencesProvider), atk, rtk); + ref.invalidate(tokenPairProvider); + }, + ); + if (atk == null) throw ArgumentError('Access token is null'); + final cloudFile = + await putMediaToCloud( + fileData: result, + atk: atk, + baseUrl: baseUrl, + filename: result.name, + mimetype: result.mimeType ?? 'image/jpeg', + ).future; + if (cloudFile == null) { + throw ArgumentError('Failed to upload the file...'); + } + switch (position) { + case 'picture': + picture.value = cloudFile; + case 'background': + background.value = cloudFile; + } + } catch (err) { + showErrorAlert(err); + } finally { + submitting.value = false; + } + } + + Future performAction() async { + if (!formKey.currentState!.validate()) return; + + submitting.value = true; + try { + final client = ref.watch(apiClientProvider); + final resp = await client.request( + slug == null ? '/realms' : '/realms/$slug', + data: { + 'slug': slugController.text, + 'name': nameController.text, + 'description': descriptionController.text, + 'background_id': background.value?.id, + 'picture_id': picture.value?.id, + }, + options: Options(method: slug == null ? 'POST' : 'PATCH'), + ); + if (context.mounted) { + context.maybePop(SnRealm.fromJson(resp.data)); + } + } catch (err) { + showErrorAlert(err); + } finally { + submitting.value = false; + } + } + + return AppScaffold( + appBar: AppBar( + title: Text(slug == null ? 'createRealm'.tr() : 'editRealm'.tr()), + leading: const PageBackButton(), + ), + body: Column( + children: [ + AspectRatio( + aspectRatio: 16 / 7, + child: Stack( + clipBehavior: Clip.none, + fit: StackFit.expand, + children: [ + GestureDetector( + child: Container( + color: Theme.of(context).colorScheme.surfaceContainerHigh, + child: + background.value != null + ? CloudFileWidget( + item: background.value!, + fit: BoxFit.cover, + ) + : const SizedBox.shrink(), + ), + onTap: () { + setPicture('background'); + }, + ), + Positioned( + left: 20, + bottom: -32, + child: GestureDetector( + child: ProfilePictureWidget( + item: picture.value, + radius: 40, + fallbackIcon: Symbols.group, + ), + onTap: () { + setPicture('picture'); + }, + ), + ), + ], + ), + ).padding(bottom: 32), + Form( + key: formKey, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + spacing: 16, + children: [ + TextFormField( + controller: slugController, + decoration: InputDecoration( + labelText: 'slug'.tr(), + helperText: 'slugHint'.tr(), + ), + onTapOutside: + (_) => FocusManager.instance.primaryFocus?.unfocus(), + ), + TextFormField( + controller: nameController, + decoration: InputDecoration(labelText: 'name'.tr()), + onTapOutside: + (_) => FocusManager.instance.primaryFocus?.unfocus(), + ), + TextFormField( + controller: descriptionController, + decoration: InputDecoration(labelText: 'description'.tr()), + minLines: 3, + maxLines: null, + onTapOutside: + (_) => FocusManager.instance.primaryFocus?.unfocus(), + ), + Align( + alignment: Alignment.centerRight, + child: TextButton.icon( + onPressed: submitting.value ? null : performAction, + label: Text('saveChanges'.tr()), + icon: const Icon(Symbols.save), + ), + ), + ], + ).padding(all: 24), + ), + ], + ), + ); + } +} diff --git a/lib/screens/realm/realms.g.dart b/lib/screens/realm/realms.g.dart new file mode 100644 index 0000000..b3cdc84 --- /dev/null +++ b/lib/screens/realm/realms.g.dart @@ -0,0 +1,160 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'realms.dart'; + +// ************************************************************************** +// RiverpodGenerator +// ************************************************************************** + +String _$realmsJoinedHash() => r'7c3367db97079365ec9973733cad9db6d8d50800'; + +/// See also [realmsJoined]. +@ProviderFor(realmsJoined) +final realmsJoinedProvider = AutoDisposeFutureProvider>.internal( + realmsJoined, + name: r'realmsJoinedProvider', + debugGetCreateSourceHash: + const bool.fromEnvironment('dart.vm.product') ? null : _$realmsJoinedHash, + dependencies: null, + allTransitiveDependencies: null, +); + +@Deprecated('Will be removed in 3.0. Use Ref instead') +// ignore: unused_element +typedef RealmsJoinedRef = AutoDisposeFutureProviderRef>; +String _$realmHash() => r'369d2f3dd80de9ab91457a772727ee89a0759c74'; + +/// Copied from Dart SDK +class _SystemHash { + _SystemHash._(); + + static int combine(int hash, int value) { + // ignore: parameter_assignments + hash = 0x1fffffff & (hash + value); + // ignore: parameter_assignments + hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); + return hash ^ (hash >> 6); + } + + static int finish(int hash) { + // ignore: parameter_assignments + hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); + // ignore: parameter_assignments + hash = hash ^ (hash >> 11); + return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); + } +} + +/// See also [realm]. +@ProviderFor(realm) +const realmProvider = RealmFamily(); + +/// See also [realm]. +class RealmFamily extends Family> { + /// See also [realm]. + const RealmFamily(); + + /// See also [realm]. + RealmProvider call(String? identifier) { + return RealmProvider(identifier); + } + + @override + RealmProvider getProviderOverride(covariant RealmProvider provider) { + return call(provider.identifier); + } + + static const Iterable? _dependencies = null; + + @override + Iterable? get dependencies => _dependencies; + + static const Iterable? _allTransitiveDependencies = null; + + @override + Iterable? get allTransitiveDependencies => + _allTransitiveDependencies; + + @override + String? get name => r'realmProvider'; +} + +/// See also [realm]. +class RealmProvider extends AutoDisposeFutureProvider { + /// See also [realm]. + RealmProvider(String? identifier) + : this._internal( + (ref) => realm(ref as RealmRef, identifier), + from: realmProvider, + name: r'realmProvider', + debugGetCreateSourceHash: + const bool.fromEnvironment('dart.vm.product') ? null : _$realmHash, + dependencies: RealmFamily._dependencies, + allTransitiveDependencies: RealmFamily._allTransitiveDependencies, + identifier: identifier, + ); + + RealmProvider._internal( + super._createNotifier, { + required super.name, + required super.dependencies, + required super.allTransitiveDependencies, + required super.debugGetCreateSourceHash, + required super.from, + required this.identifier, + }) : super.internal(); + + final String? identifier; + + @override + Override overrideWith(FutureOr Function(RealmRef provider) create) { + return ProviderOverride( + origin: this, + override: RealmProvider._internal( + (ref) => create(ref as RealmRef), + from: from, + name: null, + dependencies: null, + allTransitiveDependencies: null, + debugGetCreateSourceHash: null, + identifier: identifier, + ), + ); + } + + @override + AutoDisposeFutureProviderElement createElement() { + return _RealmProviderElement(this); + } + + @override + bool operator ==(Object other) { + return other is RealmProvider && other.identifier == identifier; + } + + @override + int get hashCode { + var hash = _SystemHash.combine(0, runtimeType.hashCode); + hash = _SystemHash.combine(hash, identifier.hashCode); + + return _SystemHash.finish(hash); + } +} + +@Deprecated('Will be removed in 3.0. Use Ref instead') +// ignore: unused_element +mixin RealmRef on AutoDisposeFutureProviderRef { + /// The parameter `identifier` of this provider. + String? get identifier; +} + +class _RealmProviderElement extends AutoDisposeFutureProviderElement + with RealmRef { + _RealmProviderElement(super.provider); + + @override + String? get identifier => (origin as RealmProvider).identifier; +} + +// ignore_for_file: type=lint +// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/lib/widgets/content/cloud_files.dart b/lib/widgets/content/cloud_files.dart index e6e99ff..d382091 100644 --- a/lib/widgets/content/cloud_files.dart +++ b/lib/widgets/content/cloud_files.dart @@ -44,7 +44,13 @@ class CloudFileWidget extends ConsumerWidget { class ProfilePictureWidget extends ConsumerWidget { final SnCloudFile? item; final double radius; - const ProfilePictureWidget({super.key, required this.item, this.radius = 20}); + final IconData? fallbackIcon; + const ProfilePictureWidget({ + super.key, + required this.item, + this.radius = 20, + this.fallbackIcon, + }); @override Widget build(BuildContext context, WidgetRef ref) { @@ -56,7 +62,10 @@ class ProfilePictureWidget extends ConsumerWidget { color: Theme.of(context).colorScheme.primaryContainer, child: item == null - ? Icon(Symbols.account_circle, size: radius).center() + ? Icon( + fallbackIcon ?? Symbols.account_circle, + size: radius, + ).center() : CloudFileWidget(item: item!), ), );