Realm basis

This commit is contained in:
LittleSheep 2025-05-02 14:52:08 +08:00
parent d2c33dde5e
commit cce0be4fb2
19 changed files with 1399 additions and 118 deletions

View File

@ -32,6 +32,7 @@
"publishers": "Publishers", "publishers": "Publishers",
"managedPublisher": "Managed Publishers", "managedPublisher": "Managed Publishers",
"createPublisher": "Create a Publisher", "createPublisher": "Create a Publisher",
"createPublisherHint": "To create posts, collections, etc.",
"editPublisher": "Edit a Publisher", "editPublisher": "Edit a Publisher",
"syncPublisher": "Use Account Data", "syncPublisher": "Use Account Data",
"create": "Create", "create": "Create",
@ -49,5 +50,25 @@
"postCreateAccountNext2": "Log in to your account and start exploring the Solar Network!", "postCreateAccountNext2": "Log in to your account and start exploring the Solar Network!",
"postPlaceholder": "What's on your mind?", "postPlaceholder": "What's on your mind?",
"publishersEmpty": "No publishers yet", "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."
} }

26
lib/models/chat.dart Normal file
View File

@ -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<String, dynamic> json) => _$SnChatFromJson(json);
}

View File

@ -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>(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<SnChat> get copyWith => _$SnChatCopyWithImpl<SnChat>(this as SnChat, _$identity);
/// Serializes this SnChat to a JSON map.
Map<String, dynamic> 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<String, dynamic> 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<String, dynamic> 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

49
lib/models/chat.g.dart Normal file
View File

@ -0,0 +1,49 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'chat.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_SnChat _$SnChatFromJson(Map<String, dynamic> 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<String, dynamic>),
background:
json['background'] == null
? null
: SnCloudFile.fromJson(json['background'] as Map<String, dynamic>),
realmId: (json['realm_id'] as num?)?.toInt(),
realm:
json['realm'] == null
? null
: SnRealm.fromJson(json['realm'] as Map<String, dynamic>),
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<String, dynamic> _$SnChatToJson(_SnChat instance) => <String, dynamic>{
'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(),
};

View File

@ -33,10 +33,9 @@ abstract class SnPost with _$SnPost {
required List<dynamic> tags, required List<dynamic> tags,
required List<dynamic> categories, required List<dynamic> categories,
required List<dynamic> collections, required List<dynamic> collections,
required bool empty,
required DateTime createdAt, required DateTime createdAt,
required DateTime updatedAt, required DateTime updatedAt,
required dynamic deletedAt, required DateTime? deletedAt,
}) = _SnPost; }) = _SnPost;
factory SnPost.fromJson(Map<String, dynamic> json) => _$SnPostFromJson(json); factory SnPost.fromJson(Map<String, dynamic> json) => _$SnPostFromJson(json);

View File

@ -16,7 +16,7 @@ T _$identity<T>(T value) => value;
/// @nodoc /// @nodoc
mixin _$SnPost { mixin _$SnPost {
int get id; String? get title; String? get description; String? get language; DateTime? get editedAt; DateTime get publishedAt; int get visibility; List<dynamic>? get content; int get type; Map<String, dynamic>? 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<SnCloudFile> get attachments; SnPublisher get publisher; List<dynamic> get reactions; List<dynamic> get tags; List<dynamic> get categories; List<dynamic> 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<dynamic>? get content; int get type; Map<String, dynamic>? 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<SnCloudFile> get attachments; SnPublisher get publisher; List<dynamic> get reactions; List<dynamic> get tags; List<dynamic> get categories; List<dynamic> get collections; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt;
/// Create a copy of SnPost /// Create a copy of SnPost
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@ -29,16 +29,16 @@ $SnPostCopyWith<SnPost> get copyWith => _$SnPostCopyWithImpl<SnPost>(this as SnP
@override @override
bool operator ==(Object other) { 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) @JsonKey(includeFromJson: false, includeToJson: false)
@override @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 @override
String toString() { 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; factory $SnPostCopyWith(SnPost value, $Res Function(SnPost) _then) = _$SnPostCopyWithImpl;
@useResult @useResult
$Res call({ $Res call({
int id, String? title, String? description, String? language, DateTime? editedAt, DateTime publishedAt, int visibility, List<dynamic>? content, int type, Map<String, dynamic>? meta, int viewsUnique, int viewsTotal, int upvotes, int downvotes, dynamic threadedPostId, dynamic threadedPost, dynamic repliedPostId, dynamic repliedPost, dynamic forwardedPostId, dynamic forwardedPost, List<SnCloudFile> attachments, SnPublisher publisher, List<dynamic> reactions, List<dynamic> tags, List<dynamic> categories, List<dynamic> collections, bool empty, DateTime createdAt, DateTime updatedAt, dynamic deletedAt int id, String? title, String? description, String? language, DateTime? editedAt, DateTime publishedAt, int visibility, List<dynamic>? content, int type, Map<String, dynamic>? meta, int viewsUnique, int viewsTotal, int upvotes, int downvotes, dynamic threadedPostId, dynamic threadedPost, dynamic repliedPostId, dynamic repliedPost, dynamic forwardedPostId, dynamic forwardedPost, List<SnCloudFile> attachments, SnPublisher publisher, List<dynamic> reactions, List<dynamic> tags, List<dynamic> categories, List<dynamic> collections, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt
}); });
@ -66,7 +66,7 @@ class _$SnPostCopyWithImpl<$Res>
/// Create a copy of SnPost /// Create a copy of SnPost
/// with the given fields replaced by the non-null parameter values. /// 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( return _then(_self.copyWith(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable 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 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<dynamic>,tags: null == tags ? _self.tags : tags // ignore: cast_nullable_to_non_nullable as List<dynamic>,tags: null == tags ? _self.tags : tags // ignore: cast_nullable_to_non_nullable
as List<dynamic>,categories: null == categories ? _self.categories : categories // ignore: cast_nullable_to_non_nullable as List<dynamic>,categories: null == categories ? _self.categories : categories // ignore: cast_nullable_to_non_nullable
as List<dynamic>,collections: null == collections ? _self.collections : collections // ignore: cast_nullable_to_non_nullable as List<dynamic>,collections: null == collections ? _self.collections : collections // ignore: cast_nullable_to_non_nullable
as List<dynamic>,empty: null == empty ? _self.empty : empty // ignore: cast_nullable_to_non_nullable as List<dynamic>,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as bool,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,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,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable
as dynamic, as DateTime?,
)); ));
} }
/// Create a copy of SnPost /// Create a copy of SnPost
@ -118,7 +117,7 @@ $SnPublisherCopyWith<$Res> get publisher {
@JsonSerializable() @JsonSerializable()
class _SnPost implements SnPost { 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<dynamic>? content, required this.type, required final Map<String, dynamic>? 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<SnCloudFile> attachments, required this.publisher, required final List<dynamic> reactions, required final List<dynamic> tags, required final List<dynamic> categories, required final List<dynamic> 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<dynamic>? content, required this.type, required final Map<String, dynamic>? 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<SnCloudFile> attachments, required this.publisher, required final List<dynamic> reactions, required final List<dynamic> tags, required final List<dynamic> categories, required final List<dynamic> 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<String, dynamic> json) => _$SnPostFromJson(json); factory _SnPost.fromJson(Map<String, dynamic> json) => _$SnPostFromJson(json);
@override final int id; @override final int id;
@ -193,10 +192,9 @@ class _SnPost implements SnPost {
return EqualUnmodifiableListView(_collections); return EqualUnmodifiableListView(_collections);
} }
@override final bool empty;
@override final DateTime createdAt; @override final DateTime createdAt;
@override final DateTime updatedAt; @override final DateTime updatedAt;
@override final dynamic deletedAt; @override final DateTime? deletedAt;
/// Create a copy of SnPost /// Create a copy of SnPost
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@ -211,16 +209,16 @@ Map<String, dynamic> toJson() {
@override @override
bool operator ==(Object other) { 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) @JsonKey(includeFromJson: false, includeToJson: false)
@override @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 @override
String toString() { 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; factory _$SnPostCopyWith(_SnPost value, $Res Function(_SnPost) _then) = __$SnPostCopyWithImpl;
@override @useResult @override @useResult
$Res call({ $Res call({
int id, String? title, String? description, String? language, DateTime? editedAt, DateTime publishedAt, int visibility, List<dynamic>? content, int type, Map<String, dynamic>? meta, int viewsUnique, int viewsTotal, int upvotes, int downvotes, dynamic threadedPostId, dynamic threadedPost, dynamic repliedPostId, dynamic repliedPost, dynamic forwardedPostId, dynamic forwardedPost, List<SnCloudFile> attachments, SnPublisher publisher, List<dynamic> reactions, List<dynamic> tags, List<dynamic> categories, List<dynamic> collections, bool empty, DateTime createdAt, DateTime updatedAt, dynamic deletedAt int id, String? title, String? description, String? language, DateTime? editedAt, DateTime publishedAt, int visibility, List<dynamic>? content, int type, Map<String, dynamic>? meta, int viewsUnique, int viewsTotal, int upvotes, int downvotes, dynamic threadedPostId, dynamic threadedPost, dynamic repliedPostId, dynamic repliedPost, dynamic forwardedPostId, dynamic forwardedPost, List<SnCloudFile> attachments, SnPublisher publisher, List<dynamic> reactions, List<dynamic> tags, List<dynamic> categories, List<dynamic> collections, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt
}); });
@ -248,7 +246,7 @@ class __$SnPostCopyWithImpl<$Res>
/// Create a copy of SnPost /// Create a copy of SnPost
/// with the given fields replaced by the non-null parameter values. /// 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( return _then(_SnPost(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable 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 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<dynamic>,tags: null == tags ? _self._tags : tags // ignore: cast_nullable_to_non_nullable as List<dynamic>,tags: null == tags ? _self._tags : tags // ignore: cast_nullable_to_non_nullable
as List<dynamic>,categories: null == categories ? _self._categories : categories // ignore: cast_nullable_to_non_nullable as List<dynamic>,categories: null == categories ? _self._categories : categories // ignore: cast_nullable_to_non_nullable
as List<dynamic>,collections: null == collections ? _self._collections : collections // ignore: cast_nullable_to_non_nullable as List<dynamic>,collections: null == collections ? _self._collections : collections // ignore: cast_nullable_to_non_nullable
as List<dynamic>,empty: null == empty ? _self.empty : empty // ignore: cast_nullable_to_non_nullable as List<dynamic>,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as bool,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,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,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable
as dynamic, as DateTime?,
)); ));
} }

View File

@ -39,10 +39,12 @@ _SnPost _$SnPostFromJson(Map<String, dynamic> json) => _SnPost(
tags: json['tags'] as List<dynamic>, tags: json['tags'] as List<dynamic>,
categories: json['categories'] as List<dynamic>, categories: json['categories'] as List<dynamic>,
collections: json['collections'] as List<dynamic>, collections: json['collections'] as List<dynamic>,
empty: json['empty'] as bool,
createdAt: DateTime.parse(json['created_at'] as String), createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_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<String, dynamic> _$SnPostToJson(_SnPost instance) => <String, dynamic>{ Map<String, dynamic> _$SnPostToJson(_SnPost instance) => <String, dynamic>{
@ -72,10 +74,9 @@ Map<String, dynamic> _$SnPostToJson(_SnPost instance) => <String, dynamic>{
'tags': instance.tags, 'tags': instance.tags,
'categories': instance.categories, 'categories': instance.categories,
'collections': instance.collections, 'collections': instance.collections,
'empty': instance.empty,
'created_at': instance.createdAt.toIso8601String(), 'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(), 'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt, 'deleted_at': instance.deletedAt?.toIso8601String(),
}; };
_SnPublisher _$SnPublisherFromJson(Map<String, dynamic> json) => _SnPublisher( _SnPublisher _$SnPublisherFromJson(Map<String, dynamic> json) => _SnPublisher(

28
lib/models/realm.dart Normal file
View File

@ -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<String, dynamic> json) =>
_$SnRealmFromJson(json);
}

View File

@ -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>(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<SnRealm> get copyWith => _$SnRealmCopyWithImpl<SnRealm>(this as SnRealm, _$identity);
/// Serializes this SnRealm to a JSON map.
Map<String, dynamic> 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<String, dynamic> 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<String, dynamic> 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

53
lib/models/realm.g.dart Normal file
View File

@ -0,0 +1,53 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'realm.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_SnRealm _$SnRealmFromJson(Map<String, dynamic> 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<String, dynamic>),
background:
json['background'] == null
? null
: SnCloudFile.fromJson(json['background'] as Map<String, dynamic>),
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<String, dynamic> _$SnRealmToJson(_SnRealm instance) => <String, dynamic>{
'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(),
};

View File

@ -15,6 +15,7 @@ class AppRouter extends RootStackRouter {
children: [ children: [
AutoRoute(page: ExploreRoute.page, path: 'explore'), AutoRoute(page: ExploreRoute.page, path: 'explore'),
AutoRoute(page: AccountRoute.page, path: 'account'), AutoRoute(page: AccountRoute.page, path: 'account'),
AutoRoute(page: RealmListRoute.page, path: 'realms'),
], ],
), ),
AutoRoute(page: LoginRoute.page, path: '/auth/login'), 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: NewPublisherRoute.page, path: '/account/me/publishers/new'),
AutoRoute( AutoRoute(
page: EditPublisherRoute.page, page: EditPublisherRoute.page,
path: '/account/me/publishers/:id', path: '/account/me/publishers/:id/edit',
), ),
AutoRoute(page: PostComposeRoute.page, path: '/posts/compose'), AutoRoute(page: PostComposeRoute.page, path: '/posts/compose'),
AutoRoute(page: PostDetailRoute.page, path: '/posts/:id'), AutoRoute(page: PostDetailRoute.page, path: '/posts/:id'),
AutoRoute(page: PostEditRoute.page, path: '/posts/:id/edit'), AutoRoute(page: PostEditRoute.page, path: '/posts/:id/edit'),
AutoRoute(page: NewRealmRoute.page, path: '/realms/new'),
AutoRoute(page: EditRealmRoute.page, path: '/realms/:slug/edit'),
]; ];
} }

View File

@ -9,29 +9,30 @@
// coverage:ignore-file // coverage:ignore-file
// ignore_for_file: no_leading_underscores_for_library_prefixes // ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:auto_route/auto_route.dart' as _i11; import 'package:auto_route/auto_route.dart' as _i12;
import 'package:flutter/material.dart' as _i12; import 'package:flutter/material.dart' as _i13;
import 'package:island/models/post.dart' as _i13; import 'package:island/models/post.dart' as _i14;
import 'package:island/screens/account.dart' as _i1; 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/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/create_account.dart' as _i2;
import 'package:island/screens/auth/login.dart' as _i5; import 'package:island/screens/auth/login.dart' as _i6;
import 'package:island/screens/auth/tabs.dart' as _i9; import 'package:island/screens/auth/tabs.dart' as _i10;
import 'package:island/screens/explore.dart' as _i4; import 'package:island/screens/explore.dart' as _i5;
import 'package:island/screens/posts/compose.dart' as _i7; import 'package:island/screens/posts/compose.dart' as _i8;
import 'package:island/screens/posts/detail.dart' as _i8; import 'package:island/screens/posts/detail.dart' as _i9;
import 'package:island/screens/realm/realms.dart' as _i4;
/// generated route for /// generated route for
/// [_i1.AccountScreen] /// [_i1.AccountScreen]
class AccountRoute extends _i11.PageRouteInfo<void> { class AccountRoute extends _i12.PageRouteInfo<void> {
const AccountRoute({List<_i11.PageRouteInfo>? children}) const AccountRoute({List<_i12.PageRouteInfo>? children})
: super(AccountRoute.name, initialChildren: children); : super(AccountRoute.name, initialChildren: children);
static const String name = 'AccountRoute'; static const String name = 'AccountRoute';
static _i11.PageInfo page = _i11.PageInfo( static _i12.PageInfo page = _i12.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i1.AccountScreen(); return const _i1.AccountScreen();
@ -41,13 +42,13 @@ class AccountRoute extends _i11.PageRouteInfo<void> {
/// generated route for /// generated route for
/// [_i2.CreateAccountScreen] /// [_i2.CreateAccountScreen]
class CreateAccountRoute extends _i11.PageRouteInfo<void> { class CreateAccountRoute extends _i12.PageRouteInfo<void> {
const CreateAccountRoute({List<_i11.PageRouteInfo>? children}) const CreateAccountRoute({List<_i12.PageRouteInfo>? children})
: super(CreateAccountRoute.name, initialChildren: children); : super(CreateAccountRoute.name, initialChildren: children);
static const String name = 'CreateAccountRoute'; static const String name = 'CreateAccountRoute';
static _i11.PageInfo page = _i11.PageInfo( static _i12.PageInfo page = _i12.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i2.CreateAccountScreen(); return const _i2.CreateAccountScreen();
@ -57,11 +58,11 @@ class CreateAccountRoute extends _i11.PageRouteInfo<void> {
/// generated route for /// generated route for
/// [_i3.EditPublisherScreen] /// [_i3.EditPublisherScreen]
class EditPublisherRoute extends _i11.PageRouteInfo<EditPublisherRouteArgs> { class EditPublisherRoute extends _i12.PageRouteInfo<EditPublisherRouteArgs> {
EditPublisherRoute({ EditPublisherRoute({
_i12.Key? key, _i13.Key? key,
String? name, String? name,
List<_i11.PageRouteInfo>? children, List<_i12.PageRouteInfo>? children,
}) : super( }) : super(
EditPublisherRoute.name, EditPublisherRoute.name,
args: EditPublisherRouteArgs(key: key, name: name), args: EditPublisherRouteArgs(key: key, name: name),
@ -71,7 +72,7 @@ class EditPublisherRoute extends _i11.PageRouteInfo<EditPublisherRouteArgs> {
static const String name = 'EditPublisherRoute'; static const String name = 'EditPublisherRoute';
static _i11.PageInfo page = _i11.PageInfo( static _i12.PageInfo page = _i12.PageInfo(
name, name,
builder: (data) { builder: (data) {
final pathParams = data.inheritedPathParams; final pathParams = data.inheritedPathParams;
@ -86,7 +87,7 @@ class EditPublisherRoute extends _i11.PageRouteInfo<EditPublisherRouteArgs> {
class EditPublisherRouteArgs { class EditPublisherRouteArgs {
const EditPublisherRouteArgs({this.key, this.name}); const EditPublisherRouteArgs({this.key, this.name});
final _i12.Key? key; final _i13.Key? key;
final String? name; final String? name;
@ -97,46 +98,87 @@ class EditPublisherRouteArgs {
} }
/// generated route for /// generated route for
/// [_i4.ExploreScreen] /// [_i4.EditRealmScreen]
class ExploreRoute extends _i11.PageRouteInfo<void> { class EditRealmRoute extends _i12.PageRouteInfo<EditRealmRouteArgs> {
const ExploreRoute({List<_i11.PageRouteInfo>? children}) 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<EditRealmRouteArgs>(
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<void> {
const ExploreRoute({List<_i12.PageRouteInfo>? children})
: super(ExploreRoute.name, initialChildren: children); : super(ExploreRoute.name, initialChildren: children);
static const String name = 'ExploreRoute'; static const String name = 'ExploreRoute';
static _i11.PageInfo page = _i11.PageInfo( static _i12.PageInfo page = _i12.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i4.ExploreScreen(); return const _i5.ExploreScreen();
}, },
); );
} }
/// generated route for /// generated route for
/// [_i5.LoginScreen] /// [_i6.LoginScreen]
class LoginRoute extends _i11.PageRouteInfo<void> { class LoginRoute extends _i12.PageRouteInfo<void> {
const LoginRoute({List<_i11.PageRouteInfo>? children}) const LoginRoute({List<_i12.PageRouteInfo>? children})
: super(LoginRoute.name, initialChildren: children); : super(LoginRoute.name, initialChildren: children);
static const String name = 'LoginRoute'; static const String name = 'LoginRoute';
static _i11.PageInfo page = _i11.PageInfo( static _i12.PageInfo page = _i12.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i5.LoginScreen(); return const _i6.LoginScreen();
}, },
); );
} }
/// generated route for /// generated route for
/// [_i3.ManagedPublisherScreen] /// [_i3.ManagedPublisherScreen]
class ManagedPublisherRoute extends _i11.PageRouteInfo<void> { class ManagedPublisherRoute extends _i12.PageRouteInfo<void> {
const ManagedPublisherRoute({List<_i11.PageRouteInfo>? children}) const ManagedPublisherRoute({List<_i12.PageRouteInfo>? children})
: super(ManagedPublisherRoute.name, initialChildren: children); : super(ManagedPublisherRoute.name, initialChildren: children);
static const String name = 'ManagedPublisherRoute'; static const String name = 'ManagedPublisherRoute';
static _i11.PageInfo page = _i11.PageInfo( static _i12.PageInfo page = _i12.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i3.ManagedPublisherScreen(); return const _i3.ManagedPublisherScreen();
@ -145,30 +187,30 @@ class ManagedPublisherRoute extends _i11.PageRouteInfo<void> {
} }
/// generated route for /// generated route for
/// [_i6.MyselfProfileScreen] /// [_i7.MyselfProfileScreen]
class MyselfProfileRoute extends _i11.PageRouteInfo<void> { class MyselfProfileRoute extends _i12.PageRouteInfo<void> {
const MyselfProfileRoute({List<_i11.PageRouteInfo>? children}) const MyselfProfileRoute({List<_i12.PageRouteInfo>? children})
: super(MyselfProfileRoute.name, initialChildren: children); : super(MyselfProfileRoute.name, initialChildren: children);
static const String name = 'MyselfProfileRoute'; static const String name = 'MyselfProfileRoute';
static _i11.PageInfo page = _i11.PageInfo( static _i12.PageInfo page = _i12.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i6.MyselfProfileScreen(); return const _i7.MyselfProfileScreen();
}, },
); );
} }
/// generated route for /// generated route for
/// [_i3.NewPublisherScreen] /// [_i3.NewPublisherScreen]
class NewPublisherRoute extends _i11.PageRouteInfo<void> { class NewPublisherRoute extends _i12.PageRouteInfo<void> {
const NewPublisherRoute({List<_i11.PageRouteInfo>? children}) const NewPublisherRoute({List<_i12.PageRouteInfo>? children})
: super(NewPublisherRoute.name, initialChildren: children); : super(NewPublisherRoute.name, initialChildren: children);
static const String name = 'NewPublisherRoute'; static const String name = 'NewPublisherRoute';
static _i11.PageInfo page = _i11.PageInfo( static _i12.PageInfo page = _i12.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i3.NewPublisherScreen(); return const _i3.NewPublisherScreen();
@ -177,12 +219,28 @@ class NewPublisherRoute extends _i11.PageRouteInfo<void> {
} }
/// generated route for /// generated route for
/// [_i7.PostComposeScreen] /// [_i4.NewRealmScreen]
class PostComposeRoute extends _i11.PageRouteInfo<PostComposeRouteArgs> { class NewRealmRoute extends _i12.PageRouteInfo<void> {
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<PostComposeRouteArgs> {
PostComposeRoute({ PostComposeRoute({
_i12.Key? key, _i13.Key? key,
_i13.SnPost? originalPost, _i14.SnPost? originalPost,
List<_i11.PageRouteInfo>? children, List<_i12.PageRouteInfo>? children,
}) : super( }) : super(
PostComposeRoute.name, PostComposeRoute.name,
args: PostComposeRouteArgs(key: key, originalPost: originalPost), args: PostComposeRouteArgs(key: key, originalPost: originalPost),
@ -191,13 +249,13 @@ class PostComposeRoute extends _i11.PageRouteInfo<PostComposeRouteArgs> {
static const String name = 'PostComposeRoute'; static const String name = 'PostComposeRoute';
static _i11.PageInfo page = _i11.PageInfo( static _i12.PageInfo page = _i12.PageInfo(
name, name,
builder: (data) { builder: (data) {
final args = data.argsAs<PostComposeRouteArgs>( final args = data.argsAs<PostComposeRouteArgs>(
orElse: () => const PostComposeRouteArgs(), orElse: () => const PostComposeRouteArgs(),
); );
return _i7.PostComposeScreen( return _i8.PostComposeScreen(
key: args.key, key: args.key,
originalPost: args.originalPost, originalPost: args.originalPost,
); );
@ -208,9 +266,9 @@ class PostComposeRoute extends _i11.PageRouteInfo<PostComposeRouteArgs> {
class PostComposeRouteArgs { class PostComposeRouteArgs {
const PostComposeRouteArgs({this.key, this.originalPost}); const PostComposeRouteArgs({this.key, this.originalPost});
final _i12.Key? key; final _i13.Key? key;
final _i13.SnPost? originalPost; final _i14.SnPost? originalPost;
@override @override
String toString() { String toString() {
@ -219,12 +277,12 @@ class PostComposeRouteArgs {
} }
/// generated route for /// generated route for
/// [_i8.PostDetailScreen] /// [_i9.PostDetailScreen]
class PostDetailRoute extends _i11.PageRouteInfo<PostDetailRouteArgs> { class PostDetailRoute extends _i12.PageRouteInfo<PostDetailRouteArgs> {
PostDetailRoute({ PostDetailRoute({
_i12.Key? key, _i13.Key? key,
required int id, required int id,
List<_i11.PageRouteInfo>? children, List<_i12.PageRouteInfo>? children,
}) : super( }) : super(
PostDetailRoute.name, PostDetailRoute.name,
args: PostDetailRouteArgs(key: key, id: id), args: PostDetailRouteArgs(key: key, id: id),
@ -234,14 +292,14 @@ class PostDetailRoute extends _i11.PageRouteInfo<PostDetailRouteArgs> {
static const String name = 'PostDetailRoute'; static const String name = 'PostDetailRoute';
static _i11.PageInfo page = _i11.PageInfo( static _i12.PageInfo page = _i12.PageInfo(
name, name,
builder: (data) { builder: (data) {
final pathParams = data.inheritedPathParams; final pathParams = data.inheritedPathParams;
final args = data.argsAs<PostDetailRouteArgs>( final args = data.argsAs<PostDetailRouteArgs>(
orElse: () => PostDetailRouteArgs(id: pathParams.getInt('id')), 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<PostDetailRouteArgs> {
class PostDetailRouteArgs { class PostDetailRouteArgs {
const PostDetailRouteArgs({this.key, required this.id}); const PostDetailRouteArgs({this.key, required this.id});
final _i12.Key? key; final _i13.Key? key;
final int id; final int id;
@ -260,12 +318,12 @@ class PostDetailRouteArgs {
} }
/// generated route for /// generated route for
/// [_i7.PostEditScreen] /// [_i8.PostEditScreen]
class PostEditRoute extends _i11.PageRouteInfo<PostEditRouteArgs> { class PostEditRoute extends _i12.PageRouteInfo<PostEditRouteArgs> {
PostEditRoute({ PostEditRoute({
_i12.Key? key, _i13.Key? key,
required int id, required int id,
List<_i11.PageRouteInfo>? children, List<_i12.PageRouteInfo>? children,
}) : super( }) : super(
PostEditRoute.name, PostEditRoute.name,
args: PostEditRouteArgs(key: key, id: id), args: PostEditRouteArgs(key: key, id: id),
@ -275,14 +333,14 @@ class PostEditRoute extends _i11.PageRouteInfo<PostEditRouteArgs> {
static const String name = 'PostEditRoute'; static const String name = 'PostEditRoute';
static _i11.PageInfo page = _i11.PageInfo( static _i12.PageInfo page = _i12.PageInfo(
name, name,
builder: (data) { builder: (data) {
final pathParams = data.inheritedPathParams; final pathParams = data.inheritedPathParams;
final args = data.argsAs<PostEditRouteArgs>( final args = data.argsAs<PostEditRouteArgs>(
orElse: () => PostEditRouteArgs(id: pathParams.getInt('id')), 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<PostEditRouteArgs> {
class PostEditRouteArgs { class PostEditRouteArgs {
const PostEditRouteArgs({this.key, required this.id}); const PostEditRouteArgs({this.key, required this.id});
final _i12.Key? key; final _i13.Key? key;
final int id; final int id;
@ -301,33 +359,49 @@ class PostEditRouteArgs {
} }
/// generated route for /// generated route for
/// [_i9.TabsScreen] /// [_i4.RealmListScreen]
class TabsRoute extends _i11.PageRouteInfo<void> { class RealmListRoute extends _i12.PageRouteInfo<void> {
const TabsRoute({List<_i11.PageRouteInfo>? children}) const RealmListRoute({List<_i12.PageRouteInfo>? children})
: super(TabsRoute.name, initialChildren: 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, name,
builder: (data) { builder: (data) {
return const _i9.TabsScreen(); return const _i4.RealmListScreen();
}, },
); );
} }
/// generated route for /// generated route for
/// [_i10.UpdateProfileScreen] /// [_i10.TabsScreen]
class UpdateProfileRoute extends _i11.PageRouteInfo<void> { class TabsRoute extends _i12.PageRouteInfo<void> {
const UpdateProfileRoute({List<_i11.PageRouteInfo>? children}) 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<void> {
const UpdateProfileRoute({List<_i12.PageRouteInfo>? children})
: super(UpdateProfileRoute.name, initialChildren: children); : super(UpdateProfileRoute.name, initialChildren: children);
static const String name = 'UpdateProfileRoute'; static const String name = 'UpdateProfileRoute';
static _i11.PageInfo page = _i11.PageInfo( static _i12.PageInfo page = _i12.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i10.UpdateProfileScreen(); return const _i11.UpdateProfileScreen();
}, },
); );
} }

View File

@ -1,8 +1,11 @@
import 'package:auto_route/auto_route.dart'; import 'package:auto_route/auto_route.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:gap/gap.dart'; import 'package:gap/gap.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:island/pods/network.dart';
import 'package:island/pods/userinfo.dart'; import 'package:island/pods/userinfo.dart';
import 'package:island/route.gr.dart'; import 'package:island/route.gr.dart';
import 'package:island/widgets/app_scaffold.dart'; import 'package:island/widgets/app_scaffold.dart';
@ -29,7 +32,7 @@ class AccountScreen extends HookConsumerWidget {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
if (user.value!.profile.background != null) if (user.value?.profile.background != null)
ClipRRect( ClipRRect(
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
topLeft: Radius.circular(8), topLeft: Radius.circular(8),
@ -94,7 +97,20 @@ class AccountScreen extends HookConsumerWidget {
context.router.push(UpdateProfileRoute()); 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( ListTile(
minTileHeight: 48, minTileHeight: 48,
leading: const Icon(Symbols.logout), leading: const Icon(Symbols.logout),

View File

@ -51,8 +51,8 @@ class ManagedPublisherScreen extends HookConsumerWidget {
children: [ children: [
ListTile( ListTile(
leading: const Icon(Symbols.add), leading: const Icon(Symbols.add),
title: Text('Create a publisher').tr(), title: Text('createPublisher').tr(),
subtitle: Text('To create posts, collections, etc.'), subtitle: Text('createPublisherHint').tr(),
trailing: const Icon(Symbols.chevron_right), trailing: const Icon(Symbols.chevron_right),
contentPadding: const EdgeInsets.symmetric(horizontal: 24), contentPadding: const EdgeInsets.symmetric(horizontal: 24),
onTap: () { onTap: () {
@ -79,7 +79,7 @@ class ManagedPublisherScreen extends HookConsumerWidget {
IconButton( IconButton(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
visualDensity: VisualDensity.compact, visualDensity: VisualDensity.compact,
icon: Icon(Symbols.delete, size: 16), icon: Icon(Symbols.delete),
onPressed: () { onPressed: () {
showConfirmAlert( showConfirmAlert(
'deletePublisherHint'.tr(), 'deletePublisherHint'.tr(),
@ -102,7 +102,7 @@ class ManagedPublisherScreen extends HookConsumerWidget {
IconButton( IconButton(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
visualDensity: VisualDensity.compact, visualDensity: VisualDensity.compact,
icon: Icon(Symbols.edit, size: 16), icon: Icon(Symbols.edit),
onPressed: () { onPressed: () {
context.router context.router
.push( .push(

View File

@ -19,6 +19,17 @@ import 'package:material_symbols_icons/symbols.dart';
import 'package:styled_widget/styled_widget.dart'; import 'package:styled_widget/styled_widget.dart';
import 'package:url_launcher/url_launcher_string.dart'; import 'package:url_launcher/url_launcher_string.dart';
final Map<int, (String, String, IconData)> kFactorTypes = {
0: ('authFactorPassword', 'authFactorPasswordDescription', Symbols.password),
1: ('authFactorEmail', 'authFactorEmailDescription', Symbols.email),
2: ('authFactorTOTP', 'authFactorTOTPDescription', Symbols.timer),
3: (
'authFactorInAppNotify',
'authFactorInAppNotifyDescription',
Symbols.notifications_active,
),
};
@RoutePage() @RoutePage()
class LoginScreen extends HookConsumerWidget { class LoginScreen extends HookConsumerWidget {
const LoginScreen({super.key}); const LoginScreen({super.key});
@ -274,8 +285,10 @@ class _LoginPickerScreen extends HookConsumerWidget {
shape: const RoundedRectangleBorder( shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(8)), borderRadius: BorderRadius.all(Radius.circular(8)),
), ),
secondary: const Icon(Symbols.question_mark), secondary: Icon(
title: Text('unknown').tr(), kFactorTypes[x.type]?.$3 ?? Symbols.question_mark,
),
title: Text(kFactorTypes[x.type]?.$1 ?? 'unknown').tr(),
enabled: !ticket!.blacklistFactors.contains(x.id), enabled: !ticket!.blacklistFactors.contains(x.id),
value: factorPicked.value == x.id, value: factorPicked.value == x.id,
onChanged: (value) { onChanged: (value) {

View File

@ -1,4 +1,5 @@
import 'package:auto_route/auto_route.dart'; import 'package:auto_route/auto_route.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:island/route.gr.dart'; import 'package:island/route.gr.dart';
import 'package:material_symbols_icons/symbols.dart'; import 'package:material_symbols_icons/symbols.dart';
@ -10,7 +11,7 @@ class TabsScreen extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AutoTabsRouter.pageView( return AutoTabsRouter.pageView(
routes: const [ExploreRoute(), AccountRoute()], routes: const [ExploreRoute(), RealmListRoute(), AccountRoute()],
builder: (context, child, _) { builder: (context, child, _) {
final tabsRouter = AutoTabsRouter.of(context); final tabsRouter = AutoTabsRouter.of(context);
return Scaffold( return Scaffold(
@ -22,11 +23,15 @@ class TabsScreen extends StatelessWidget {
onDestinationSelected: tabsRouter.setActiveIndex, onDestinationSelected: tabsRouter.setActiveIndex,
destinations: [ destinations: [
NavigationDestination( NavigationDestination(
label: 'Explore', label: 'explore'.tr(),
icon: const Icon(Symbols.explore), icon: const Icon(Symbols.explore),
), ),
NavigationDestination( NavigationDestination(
label: 'Account', label: 'realms'.tr(),
icon: const Icon(Symbols.workspaces),
),
NavigationDestination(
label: 'account'.tr(),
icon: const Icon(Symbols.account_circle), icon: const Icon(Symbols.account_circle),
), ),
], ],

View File

@ -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<List<SnRealm>> realmsJoined(Ref ref) async {
final client = ref.watch(apiClientProvider);
final resp = await client.get('/realms');
return resp.data.map((e) => SnRealm.fromJson(e)).cast<SnRealm>().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<SnRealm?> 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<SnCloudFile?>(null);
final background = useState<SnCloudFile?>(null);
final slugController = useTextEditingController();
final nameController = useTextEditingController();
final descriptionController = useTextEditingController();
final formKey = useMemoized(GlobalKey<FormState>.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<void> 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),
),
],
),
);
}
}

View File

@ -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<List<SnRealm>>.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<List<SnRealm>>;
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<AsyncValue<SnRealm?>> {
/// 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<ProviderOrFamily>? _dependencies = null;
@override
Iterable<ProviderOrFamily>? get dependencies => _dependencies;
static const Iterable<ProviderOrFamily>? _allTransitiveDependencies = null;
@override
Iterable<ProviderOrFamily>? get allTransitiveDependencies =>
_allTransitiveDependencies;
@override
String? get name => r'realmProvider';
}
/// See also [realm].
class RealmProvider extends AutoDisposeFutureProvider<SnRealm?> {
/// 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<SnRealm?> 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<SnRealm?> 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<SnRealm?> {
/// The parameter `identifier` of this provider.
String? get identifier;
}
class _RealmProviderElement extends AutoDisposeFutureProviderElement<SnRealm?>
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

View File

@ -44,7 +44,13 @@ class CloudFileWidget extends ConsumerWidget {
class ProfilePictureWidget extends ConsumerWidget { class ProfilePictureWidget extends ConsumerWidget {
final SnCloudFile? item; final SnCloudFile? item;
final double radius; 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 @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
@ -56,7 +62,10 @@ class ProfilePictureWidget extends ConsumerWidget {
color: Theme.of(context).colorScheme.primaryContainer, color: Theme.of(context).colorScheme.primaryContainer,
child: child:
item == null item == null
? Icon(Symbols.account_circle, size: radius).center() ? Icon(
fallbackIcon ?? Symbols.account_circle,
size: radius,
).center()
: CloudFileWidget(item: item!), : CloudFileWidget(item: item!),
), ),
); );