Publishers manage

This commit is contained in:
LittleSheep 2025-04-26 00:43:48 +08:00
parent aed2160760
commit 7cf2c1a0df
14 changed files with 881 additions and 111 deletions

View File

@ -27,6 +27,13 @@
"logout": "Logout",
"updateYourProfile": "Edit Profile",
"accountBasicInfo": "Basic Info",
"accountProfile": "Profile",
"saveChanges": "Save Changes"
"saveChanges": "Save Changes",
"publishers": "Publishers",
"managedPublisher": "Managed Publishers",
"createPublisher": "Create a Publisher",
"editPublisher": "Edit a Publisher",
"syncPublisher": "Use Account Data",
"create": "Create",
"edit": "Edit",
"delete": "Delete"
}

View File

@ -16,7 +16,7 @@ abstract class SnPost with _$SnPost {
required int visibility,
required String content,
required int type,
required dynamic meta,
required Map<String, dynamic>? meta,
required int viewsUnique,
required int viewsTotal,
required int upvotes,
@ -50,8 +50,8 @@ abstract class SnPublisher with _$SnPublisher {
required String name,
required String nick,
required String bio,
required SnCloudFile picture,
required SnCloudFile background,
required SnCloudFile? picture,
required SnCloudFile? background,
required int accountId,
required DateTime createdAt,
required DateTime updatedAt,

View File

@ -16,7 +16,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$SnPost {
int get id; String get title; String get description; dynamic get language; dynamic get editedAt; DateTime get publishedAt; int get visibility; String get content; int get type; 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; dynamic get language; dynamic get editedAt; DateTime get publishedAt; int get visibility; String 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;
/// Create a copy of SnPost
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@ -49,7 +49,7 @@ abstract mixin class $SnPostCopyWith<$Res> {
factory $SnPostCopyWith(SnPost value, $Res Function(SnPost) _then) = _$SnPostCopyWithImpl;
@useResult
$Res call({
int id, String title, String description, dynamic language, dynamic editedAt, DateTime publishedAt, int visibility, String content, int type, 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, dynamic language, dynamic editedAt, DateTime publishedAt, int visibility, String 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
});
@ -78,7 +78,7 @@ as DateTime,visibility: null == visibility ? _self.visibility : visibility // ig
as int,content: null == content ? _self.content : content // ignore: cast_nullable_to_non_nullable
as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as int,meta: freezed == meta ? _self.meta : meta // ignore: cast_nullable_to_non_nullable
as dynamic,viewsUnique: null == viewsUnique ? _self.viewsUnique : viewsUnique // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,viewsUnique: null == viewsUnique ? _self.viewsUnique : viewsUnique // ignore: cast_nullable_to_non_nullable
as int,viewsTotal: null == viewsTotal ? _self.viewsTotal : viewsTotal // ignore: cast_nullable_to_non_nullable
as int,upvotes: null == upvotes ? _self.upvotes : upvotes // ignore: cast_nullable_to_non_nullable
as int,downvotes: null == downvotes ? _self.downvotes : downvotes // ignore: cast_nullable_to_non_nullable
@ -118,7 +118,7 @@ $SnPublisherCopyWith<$Res> get publisher {
@JsonSerializable()
class _SnPost implements SnPost {
const _SnPost({required this.id, required this.title, required this.description, required this.language, required this.editedAt, required this.publishedAt, required this.visibility, required this.content, required this.type, required this.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}): _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 this.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}): _meta = meta,_attachments = attachments,_reactions = reactions,_tags = tags,_categories = categories,_collections = collections;
factory _SnPost.fromJson(Map<String, dynamic> json) => _$SnPostFromJson(json);
@override final int id;
@ -130,7 +130,15 @@ class _SnPost implements SnPost {
@override final int visibility;
@override final String content;
@override final int type;
@override final dynamic meta;
final Map<String, dynamic>? _meta;
@override Map<String, dynamic>? get meta {
final value = _meta;
if (value == null) return null;
if (_meta is EqualUnmodifiableMapView) return _meta;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(value);
}
@override final int viewsUnique;
@override final int viewsTotal;
@override final int upvotes;
@ -195,12 +203,12 @@ Map<String, dynamic> toJson() {
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnPost&&(identical(other.id, id) || other.id == id)&&(identical(other.title, title) || other.title == title)&&(identical(other.description, description) || other.description == description)&&const DeepCollectionEquality().equals(other.language, language)&&const DeepCollectionEquality().equals(other.editedAt, editedAt)&&(identical(other.publishedAt, publishedAt) || other.publishedAt == publishedAt)&&(identical(other.visibility, visibility) || other.visibility == visibility)&&(identical(other.content, content) || 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)&&const DeepCollectionEquality().equals(other.language, language)&&const DeepCollectionEquality().equals(other.editedAt, editedAt)&&(identical(other.publishedAt, publishedAt) || other.publishedAt == publishedAt)&&(identical(other.visibility, visibility) || other.visibility == visibility)&&(identical(other.content, content) || 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));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hashAll([runtimeType,id,title,description,const DeepCollectionEquality().hash(language),const DeepCollectionEquality().hash(editedAt),publishedAt,visibility,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,const DeepCollectionEquality().hash(language),const DeepCollectionEquality().hash(editedAt),publishedAt,visibility,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)]);
@override
String toString() {
@ -215,7 +223,7 @@ abstract mixin class _$SnPostCopyWith<$Res> implements $SnPostCopyWith<$Res> {
factory _$SnPostCopyWith(_SnPost value, $Res Function(_SnPost) _then) = __$SnPostCopyWithImpl;
@override @useResult
$Res call({
int id, String title, String description, dynamic language, dynamic editedAt, DateTime publishedAt, int visibility, String content, int type, 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, dynamic language, dynamic editedAt, DateTime publishedAt, int visibility, String 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
});
@ -243,8 +251,8 @@ as dynamic,publishedAt: null == publishedAt ? _self.publishedAt : publishedAt //
as DateTime,visibility: null == visibility ? _self.visibility : visibility // ignore: cast_nullable_to_non_nullable
as int,content: null == content ? _self.content : content // ignore: cast_nullable_to_non_nullable
as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as int,meta: freezed == meta ? _self.meta : meta // ignore: cast_nullable_to_non_nullable
as dynamic,viewsUnique: null == viewsUnique ? _self.viewsUnique : viewsUnique // ignore: cast_nullable_to_non_nullable
as int,meta: freezed == meta ? _self._meta : meta // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,viewsUnique: null == viewsUnique ? _self.viewsUnique : viewsUnique // ignore: cast_nullable_to_non_nullable
as int,viewsTotal: null == viewsTotal ? _self.viewsTotal : viewsTotal // ignore: cast_nullable_to_non_nullable
as int,upvotes: null == upvotes ? _self.upvotes : upvotes // ignore: cast_nullable_to_non_nullable
as int,downvotes: null == downvotes ? _self.downvotes : downvotes // ignore: cast_nullable_to_non_nullable
@ -284,7 +292,7 @@ $SnPublisherCopyWith<$Res> get publisher {
/// @nodoc
mixin _$SnPublisher {
int get id; int get publisherType; String get name; String get nick; String get bio; SnCloudFile get picture; SnCloudFile get background; int get accountId; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt;
int get id; int get publisherType; String get name; String get nick; String get bio; SnCloudFile? get picture; SnCloudFile? get background; int get accountId; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt;
/// Create a copy of SnPublisher
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@ -317,11 +325,11 @@ abstract mixin class $SnPublisherCopyWith<$Res> {
factory $SnPublisherCopyWith(SnPublisher value, $Res Function(SnPublisher) _then) = _$SnPublisherCopyWithImpl;
@useResult
$Res call({
int id, int publisherType, String name, String nick, String bio, SnCloudFile picture, SnCloudFile background, int accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt
int id, int publisherType, String name, String nick, String bio, SnCloudFile? picture, SnCloudFile? background, int accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt
});
$SnCloudFileCopyWith<$Res> get picture;$SnCloudFileCopyWith<$Res> get background;
$SnCloudFileCopyWith<$Res>? get picture;$SnCloudFileCopyWith<$Res>? get background;
}
/// @nodoc
@ -334,16 +342,16 @@ class _$SnPublisherCopyWithImpl<$Res>
/// Create a copy of SnPublisher
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? publisherType = null,Object? name = null,Object? nick = null,Object? bio = null,Object? picture = null,Object? background = null,Object? accountId = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? publisherType = null,Object? name = null,Object? nick = null,Object? bio = 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,publisherType: null == publisherType ? _self.publisherType : publisherType // ignore: cast_nullable_to_non_nullable
as int,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
as String,nick: null == nick ? _self.nick : nick // ignore: cast_nullable_to_non_nullable
as String,bio: null == bio ? _self.bio : bio // ignore: cast_nullable_to_non_nullable
as String,picture: null == picture ? _self.picture : picture // ignore: cast_nullable_to_non_nullable
as SnCloudFile,background: null == 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 String,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
@ -354,18 +362,24 @@ as DateTime?,
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$SnCloudFileCopyWith<$Res> get picture {
return $SnCloudFileCopyWith<$Res>(_self.picture, (value) {
$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 SnPublisher
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$SnCloudFileCopyWith<$Res> get background {
return $SnCloudFileCopyWith<$Res>(_self.background, (value) {
$SnCloudFileCopyWith<$Res>? get background {
if (_self.background == null) {
return null;
}
return $SnCloudFileCopyWith<$Res>(_self.background!, (value) {
return _then(_self.copyWith(background: value));
});
}
@ -384,8 +398,8 @@ class _SnPublisher implements SnPublisher {
@override final String name;
@override final String nick;
@override final String bio;
@override final SnCloudFile picture;
@override final SnCloudFile background;
@override final SnCloudFile? picture;
@override final SnCloudFile? background;
@override final int accountId;
@override final DateTime createdAt;
@override final DateTime updatedAt;
@ -424,11 +438,11 @@ abstract mixin class _$SnPublisherCopyWith<$Res> implements $SnPublisherCopyWith
factory _$SnPublisherCopyWith(_SnPublisher value, $Res Function(_SnPublisher) _then) = __$SnPublisherCopyWithImpl;
@override @useResult
$Res call({
int id, int publisherType, String name, String nick, String bio, SnCloudFile picture, SnCloudFile background, int accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt
int id, int publisherType, String name, String nick, String bio, SnCloudFile? picture, SnCloudFile? background, int accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt
});
@override $SnCloudFileCopyWith<$Res> get picture;@override $SnCloudFileCopyWith<$Res> get background;
@override $SnCloudFileCopyWith<$Res>? get picture;@override $SnCloudFileCopyWith<$Res>? get background;
}
/// @nodoc
@ -441,16 +455,16 @@ class __$SnPublisherCopyWithImpl<$Res>
/// Create a copy of SnPublisher
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? publisherType = null,Object? name = null,Object? nick = null,Object? bio = null,Object? picture = null,Object? background = null,Object? accountId = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? publisherType = null,Object? name = null,Object? nick = null,Object? bio = null,Object? picture = freezed,Object? background = freezed,Object? accountId = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) {
return _then(_SnPublisher(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as int,publisherType: null == publisherType ? _self.publisherType : publisherType // ignore: cast_nullable_to_non_nullable
as int,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
as String,nick: null == nick ? _self.nick : nick // ignore: cast_nullable_to_non_nullable
as String,bio: null == bio ? _self.bio : bio // ignore: cast_nullable_to_non_nullable
as String,picture: null == picture ? _self.picture : picture // ignore: cast_nullable_to_non_nullable
as SnCloudFile,background: null == 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 String,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
@ -462,18 +476,24 @@ as DateTime?,
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$SnCloudFileCopyWith<$Res> get picture {
return $SnCloudFileCopyWith<$Res>(_self.picture, (value) {
$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 SnPublisher
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$SnCloudFileCopyWith<$Res> get background {
return $SnCloudFileCopyWith<$Res>(_self.background, (value) {
$SnCloudFileCopyWith<$Res>? get background {
if (_self.background == null) {
return null;
}
return $SnCloudFileCopyWith<$Res>(_self.background!, (value) {
return _then(_self.copyWith(background: value));
});
}

View File

@ -16,7 +16,7 @@ _SnPost _$SnPostFromJson(Map<String, dynamic> json) => _SnPost(
visibility: (json['visibility'] as num).toInt(),
content: json['content'] as String,
type: (json['type'] as num).toInt(),
meta: json['meta'],
meta: json['meta'] as Map<String, dynamic>?,
viewsUnique: (json['views_unique'] as num).toInt(),
viewsTotal: (json['views_total'] as num).toInt(),
upvotes: (json['upvotes'] as num).toInt(),
@ -81,8 +81,14 @@ _SnPublisher _$SnPublisherFromJson(Map<String, dynamic> json) => _SnPublisher(
name: json['name'] as String,
nick: json['nick'] as String,
bio: json['bio'] as String,
picture: SnCloudFile.fromJson(json['picture'] as Map<String, dynamic>),
background: SnCloudFile.fromJson(json['background'] as Map<String, dynamic>),
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),
@ -99,8 +105,8 @@ Map<String, dynamic> _$SnPublisherToJson(_SnPublisher instance) =>
'name': instance.name,
'nick': instance.nick,
'bio': instance.bio,
'picture': instance.picture.toJson(),
'background': instance.background.toJson(),
'picture': instance.picture?.toJson(),
'background': instance.background?.toJson(),
'account_id': instance.accountId,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),

View File

@ -21,5 +21,11 @@ class AppRouter extends RootStackRouter {
AutoRoute(page: CreateAccountRoute.page, path: '/auth/create-account'),
AutoRoute(page: MyselfProfileRoute.page, path: '/account/me'),
AutoRoute(page: UpdateProfileRoute.page, path: '/account/me/update'),
AutoRoute(page: ManagedPublisherRoute.page, path: '/account/me/publishers'),
AutoRoute(page: NewPublisherRoute.page, path: '/account/me/publishers/new'),
AutoRoute(
page: EditPublisherRoute.page,
path: '/account/me/publishers/:id',
),
];
}

View File

@ -9,24 +9,26 @@
// coverage:ignore-file
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:auto_route/auto_route.dart' as _i8;
import 'package:auto_route/auto_route.dart' as _i9;
import 'package:flutter/material.dart' as _i10;
import 'package:island/screens/account.dart' as _i1;
import 'package:island/screens/auth/account/me.dart' as _i5;
import 'package:island/screens/auth/account/me/update.dart' as _i7;
import 'package:island/screens/auth/account/me.dart' as _i6;
import 'package:island/screens/auth/account/me/publishers.dart' as _i3;
import 'package:island/screens/auth/account/me/update.dart' as _i8;
import 'package:island/screens/auth/create_account.dart' as _i2;
import 'package:island/screens/auth/login.dart' as _i4;
import 'package:island/screens/auth/tabs.dart' as _i6;
import 'package:island/screens/explore.dart' as _i3;
import 'package:island/screens/auth/login.dart' as _i5;
import 'package:island/screens/auth/tabs.dart' as _i7;
import 'package:island/screens/explore.dart' as _i4;
/// generated route for
/// [_i1.AccountScreen]
class AccountRoute extends _i8.PageRouteInfo<void> {
const AccountRoute({List<_i8.PageRouteInfo>? children})
class AccountRoute extends _i9.PageRouteInfo<void> {
const AccountRoute({List<_i9.PageRouteInfo>? children})
: super(AccountRoute.name, initialChildren: children);
static const String name = 'AccountRoute';
static _i8.PageInfo page = _i8.PageInfo(
static _i9.PageInfo page = _i9.PageInfo(
name,
builder: (data) {
return const _i1.AccountScreen();
@ -36,13 +38,13 @@ class AccountRoute extends _i8.PageRouteInfo<void> {
/// generated route for
/// [_i2.CreateAccountScreen]
class CreateAccountRoute extends _i8.PageRouteInfo<void> {
const CreateAccountRoute({List<_i8.PageRouteInfo>? children})
class CreateAccountRoute extends _i9.PageRouteInfo<void> {
const CreateAccountRoute({List<_i9.PageRouteInfo>? children})
: super(CreateAccountRoute.name, initialChildren: children);
static const String name = 'CreateAccountRoute';
static _i8.PageInfo page = _i8.PageInfo(
static _i9.PageInfo page = _i9.PageInfo(
name,
builder: (data) {
return const _i2.CreateAccountScreen();
@ -51,81 +53,154 @@ class CreateAccountRoute extends _i8.PageRouteInfo<void> {
}
/// generated route for
/// [_i3.ExploreScreen]
class ExploreRoute extends _i8.PageRouteInfo<void> {
const ExploreRoute({List<_i8.PageRouteInfo>? children})
/// [_i3.EditPublisherScreen]
class EditPublisherRoute extends _i9.PageRouteInfo<EditPublisherRouteArgs> {
EditPublisherRoute({
_i10.Key? key,
String? name,
List<_i9.PageRouteInfo>? children,
}) : super(
EditPublisherRoute.name,
args: EditPublisherRouteArgs(key: key, name: name),
rawPathParams: {'id': name},
initialChildren: children,
);
static const String name = 'EditPublisherRoute';
static _i9.PageInfo page = _i9.PageInfo(
name,
builder: (data) {
final pathParams = data.inheritedPathParams;
final args = data.argsAs<EditPublisherRouteArgs>(
orElse: () => EditPublisherRouteArgs(name: pathParams.optString('id')),
);
return _i3.EditPublisherScreen(key: args.key, name: args.name);
},
);
}
class EditPublisherRouteArgs {
const EditPublisherRouteArgs({this.key, this.name});
final _i10.Key? key;
final String? name;
@override
String toString() {
return 'EditPublisherRouteArgs{key: $key, name: $name}';
}
}
/// generated route for
/// [_i4.ExploreScreen]
class ExploreRoute extends _i9.PageRouteInfo<void> {
const ExploreRoute({List<_i9.PageRouteInfo>? children})
: super(ExploreRoute.name, initialChildren: children);
static const String name = 'ExploreRoute';
static _i8.PageInfo page = _i8.PageInfo(
static _i9.PageInfo page = _i9.PageInfo(
name,
builder: (data) {
return const _i3.ExploreScreen();
return const _i4.ExploreScreen();
},
);
}
/// generated route for
/// [_i4.LoginScreen]
class LoginRoute extends _i8.PageRouteInfo<void> {
const LoginRoute({List<_i8.PageRouteInfo>? children})
/// [_i5.LoginScreen]
class LoginRoute extends _i9.PageRouteInfo<void> {
const LoginRoute({List<_i9.PageRouteInfo>? children})
: super(LoginRoute.name, initialChildren: children);
static const String name = 'LoginRoute';
static _i8.PageInfo page = _i8.PageInfo(
static _i9.PageInfo page = _i9.PageInfo(
name,
builder: (data) {
return const _i4.LoginScreen();
return const _i5.LoginScreen();
},
);
}
/// generated route for
/// [_i5.MyselfProfileScreen]
class MyselfProfileRoute extends _i8.PageRouteInfo<void> {
const MyselfProfileRoute({List<_i8.PageRouteInfo>? children})
/// [_i3.ManagedPublisherScreen]
class ManagedPublisherRoute extends _i9.PageRouteInfo<void> {
const ManagedPublisherRoute({List<_i9.PageRouteInfo>? children})
: super(ManagedPublisherRoute.name, initialChildren: children);
static const String name = 'ManagedPublisherRoute';
static _i9.PageInfo page = _i9.PageInfo(
name,
builder: (data) {
return const _i3.ManagedPublisherScreen();
},
);
}
/// generated route for
/// [_i6.MyselfProfileScreen]
class MyselfProfileRoute extends _i9.PageRouteInfo<void> {
const MyselfProfileRoute({List<_i9.PageRouteInfo>? children})
: super(MyselfProfileRoute.name, initialChildren: children);
static const String name = 'MyselfProfileRoute';
static _i8.PageInfo page = _i8.PageInfo(
static _i9.PageInfo page = _i9.PageInfo(
name,
builder: (data) {
return const _i5.MyselfProfileScreen();
return const _i6.MyselfProfileScreen();
},
);
}
/// generated route for
/// [_i6.TabsScreen]
class TabsRoute extends _i8.PageRouteInfo<void> {
const TabsRoute({List<_i8.PageRouteInfo>? children})
/// [_i3.NewPublisherScreen]
class NewPublisherRoute extends _i9.PageRouteInfo<void> {
const NewPublisherRoute({List<_i9.PageRouteInfo>? children})
: super(NewPublisherRoute.name, initialChildren: children);
static const String name = 'NewPublisherRoute';
static _i9.PageInfo page = _i9.PageInfo(
name,
builder: (data) {
return const _i3.NewPublisherScreen();
},
);
}
/// generated route for
/// [_i7.TabsScreen]
class TabsRoute extends _i9.PageRouteInfo<void> {
const TabsRoute({List<_i9.PageRouteInfo>? children})
: super(TabsRoute.name, initialChildren: children);
static const String name = 'TabsRoute';
static _i8.PageInfo page = _i8.PageInfo(
static _i9.PageInfo page = _i9.PageInfo(
name,
builder: (data) {
return const _i6.TabsScreen();
return const _i7.TabsScreen();
},
);
}
/// generated route for
/// [_i7.UpdateProfileScreen]
class UpdateProfileRoute extends _i8.PageRouteInfo<void> {
const UpdateProfileRoute({List<_i8.PageRouteInfo>? children})
/// [_i8.UpdateProfileScreen]
class UpdateProfileRoute extends _i9.PageRouteInfo<void> {
const UpdateProfileRoute({List<_i9.PageRouteInfo>? children})
: super(UpdateProfileRoute.name, initialChildren: children);
static const String name = 'UpdateProfileRoute';
static _i8.PageInfo page = _i8.PageInfo(
static _i9.PageInfo page = _i9.PageInfo(
name,
builder: (data) {
return const _i7.UpdateProfileScreen();
return const _i8.UpdateProfileScreen();
},
);
}

View File

@ -1,6 +1,7 @@
import 'package:auto_route/auto_route.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:island/pods/userinfo.dart';
import 'package:island/route.gr.dart';
@ -71,34 +72,42 @@ class AccountScreen extends HookConsumerWidget {
).padding(horizontal: 16, vertical: 16),
],
),
).padding(horizontal: 8),
const Gap(8),
ListTile(
minTileHeight: 48,
leading: const Icon(LucideIcons.bookOpen),
trailing: const Icon(LucideIcons.chevronRight),
contentPadding: EdgeInsets.symmetric(horizontal: 24),
title: Text('managedPublisher').tr(),
onTap: () {
context.router.push(ManagedPublisherRoute());
},
),
ListTile(
minTileHeight: 48,
leading: const Icon(LucideIcons.edit),
trailing: const Icon(LucideIcons.chevronRight),
contentPadding: EdgeInsets.symmetric(horizontal: 24),
title: Text('accountProfile').tr(),
subtitle: Text('Update your profile.'),
title: Text('updateYourProfile').tr(),
onTap: () {
context.router.push(UpdateProfileRoute());
},
),
const Divider(height: 1).padding(vertical: 4),
ListTile(
minTileHeight: 48,
leading: const Icon(LucideIcons.logOut),
trailing: const Icon(LucideIcons.chevronRight),
contentPadding: EdgeInsets.symmetric(horizontal: 24),
title: Text('logout').tr(),
subtitle: Text('Log out of your account.'),
onTap: () {
final userNotifier = ref.read(userInfoProvider.notifier);
userNotifier.logOut();
},
),
],
).padding(
horizontal: 8,
top: 8,
bottom: MediaQuery.of(context).padding.bottom,
),
).padding(top: 8, bottom: MediaQuery.of(context).padding.bottom),
),
);
}

View File

@ -0,0 +1,349 @@
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/post.dart';
import 'package:island/pods/config.dart';
import 'package:island/pods/network.dart';
import 'package:island/pods/userinfo.dart';
import 'package:island/route.gr.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:lucide_icons/lucide_icons.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:styled_widget/styled_widget.dart';
part 'publishers.g.dart';
@riverpod
Future<List<SnPublisher>> publishersManaged(Ref ref) async {
final client = ref.watch(apiClientProvider);
final resp = await client.get('/publishers');
return resp.data
.map((e) => SnPublisher.fromJson(e))
.cast<SnPublisher>()
.toList();
}
@RoutePage()
class ManagedPublisherScreen extends HookConsumerWidget {
const ManagedPublisherScreen({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final publishers = ref.watch(publishersManagedProvider);
return AppScaffold(
appBar: AppBar(
title: Text('publishers').tr(),
leading: const PageBackButton(),
),
body: RefreshIndicator(
child: publishers.when(
data:
(value) => Column(
children: [
ListTile(
leading: const Icon(LucideIcons.plus),
title: Text('Create a publisher').tr(),
subtitle: Text('To create posts, collections, etc.'),
trailing: const Icon(LucideIcons.chevronRight),
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
onTap: () {
context.router.push(NewPublisherRoute());
},
),
const Divider(height: 1),
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,
),
title: Text(value[item].nick),
subtitle: Text('@${value[item].name}'),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
padding: EdgeInsets.zero,
icon: Icon(LucideIcons.edit, size: 16),
onPressed: () {
context.router
.push(
EditPublisherRoute(
name: value[item].name,
),
)
.then((value) {
if (value != null) {
ref.invalidate(
publishersManagedProvider,
);
}
});
},
),
],
),
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(publishersManagedProvider);
},
),
),
onRefresh: () => ref.refresh(publishersManagedProvider.future),
),
);
}
}
@riverpod
Future<SnPublisher?> publisher(Ref ref, String? identifier) async {
if (identifier == null) return null;
final client = ref.watch(apiClientProvider);
final resp = await client.get('/publishers/$identifier');
return SnPublisher.fromJson(resp.data);
}
@RoutePage()
class NewPublisherScreen extends StatelessWidget {
const NewPublisherScreen({super.key});
@override
Widget build(BuildContext context) {
return EditPublisherScreen(key: key);
}
}
@RoutePage()
class EditPublisherScreen extends HookConsumerWidget {
final String? name;
const EditPublisherScreen({super.key, @PathParam('id') this.name});
@override
Widget build(BuildContext context, WidgetRef ref) {
final submitting = useState(false);
final picture = useState<SnCloudFile?>(null);
final background = useState<SnCloudFile?>(null);
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;
}
}
final publisher = ref.watch(publisherProvider(name));
final formKey = useMemoized(GlobalKey<FormState>.new, const []);
final nameController = useTextEditingController(
text: publisher.value?.name,
);
final nickController = useTextEditingController(
text: publisher.value?.nick,
);
final bioController = useTextEditingController(text: publisher.value?.bio);
useEffect(() {
if (publisher.value != null) {
picture.value = publisher.value!.picture;
background.value = publisher.value!.background;
nameController.text = publisher.value!.name;
nickController.text = publisher.value!.nick;
bioController.text = publisher.value!.bio;
}
return null;
}, [publisher]);
Future<void> performAction() async {
if (!formKey.currentState!.validate()) return;
submitting.value = true;
try {
final client = ref.watch(apiClientProvider);
final resp = await client.request(
name == null ? '/publishers' : '/publishers/$name',
data: {
'name': nameController.text,
'nick': nickController.text,
'bio': bioController.text,
'picture_id': picture.value?.id,
'background_id': background.value?.id,
},
options: Options(method: name == null ? 'POST' : 'PATCH'),
);
if (context.mounted) {
context.maybePop(SnPublisher.fromJson(resp.data));
}
} catch (err) {
showErrorAlert(err);
} finally {
submitting.value = false;
}
}
return AppScaffold(
appBar: AppBar(
title: Text(name == null ? 'createPublisher' : 'editPublisher').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,
),
onTap: () {
setPicture('picture');
},
),
),
],
),
).padding(bottom: 32),
Form(
key: formKey,
child: Column(
spacing: 16,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextFormField(
controller: nameController,
decoration: InputDecoration(
labelText: 'username'.tr(),
helperText: 'usernameCannotChangeHint'.tr(),
prefixText: '@',
),
readOnly: name != null,
onTapOutside:
(_) => FocusManager.instance.primaryFocus?.unfocus(),
),
TextFormField(
controller: nickController,
decoration: InputDecoration(labelText: 'nickname'.tr()),
onTapOutside:
(_) => FocusManager.instance.primaryFocus?.unfocus(),
),
TextFormField(
controller: bioController,
decoration: InputDecoration(labelText: 'bio'.tr()),
minLines: 3,
maxLines: null,
onTapOutside:
(_) => FocusManager.instance.primaryFocus?.unfocus(),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
TextButton.icon(
onPressed: () {
final user = ref.watch(userInfoProvider);
nameController.text = user.value!.name;
nickController.text = user.value!.nick;
bioController.text = user.value!.profile.bio ?? '';
picture.value = user.value!.profile.picture;
background.value = user.value!.profile.background;
},
label: Text('syncPublisher'.tr()),
icon: const Icon(LucideIcons.refreshCcw),
),
TextButton.icon(
onPressed: submitting.value ? null : performAction,
label: Text('saveChanges'.tr()),
icon: const Icon(LucideIcons.save),
),
],
),
],
).padding(horizontal: 24),
),
],
),
);
}
}

View File

@ -0,0 +1,168 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'publishers.dart';
// **************************************************************************
// RiverpodGenerator
// **************************************************************************
String _$publishersManagedHash() => r'1ea611c8d45c46002976c99bf4ee7f60bd6dbf8e';
/// See also [publishersManaged].
@ProviderFor(publishersManaged)
final publishersManagedProvider =
AutoDisposeFutureProvider<List<SnPublisher>>.internal(
publishersManaged,
name: r'publishersManagedProvider',
debugGetCreateSourceHash:
const bool.fromEnvironment('dart.vm.product')
? null
: _$publishersManagedHash,
dependencies: null,
allTransitiveDependencies: null,
);
@Deprecated('Will be removed in 3.0. Use Ref instead')
// ignore: unused_element
typedef PublishersManagedRef = AutoDisposeFutureProviderRef<List<SnPublisher>>;
String _$publisherHash() => r'd66f2efba7ae449b9b460a4da34ce48cf3b16fe5';
/// 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 [publisher].
@ProviderFor(publisher)
const publisherProvider = PublisherFamily();
/// See also [publisher].
class PublisherFamily extends Family<AsyncValue<SnPublisher?>> {
/// See also [publisher].
const PublisherFamily();
/// See also [publisher].
PublisherProvider call(String? identifier) {
return PublisherProvider(identifier);
}
@override
PublisherProvider getProviderOverride(covariant PublisherProvider 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'publisherProvider';
}
/// See also [publisher].
class PublisherProvider extends AutoDisposeFutureProvider<SnPublisher?> {
/// See also [publisher].
PublisherProvider(String? identifier)
: this._internal(
(ref) => publisher(ref as PublisherRef, identifier),
from: publisherProvider,
name: r'publisherProvider',
debugGetCreateSourceHash:
const bool.fromEnvironment('dart.vm.product')
? null
: _$publisherHash,
dependencies: PublisherFamily._dependencies,
allTransitiveDependencies: PublisherFamily._allTransitiveDependencies,
identifier: identifier,
);
PublisherProvider._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<SnPublisher?> Function(PublisherRef provider) create,
) {
return ProviderOverride(
origin: this,
override: PublisherProvider._internal(
(ref) => create(ref as PublisherRef),
from: from,
name: null,
dependencies: null,
allTransitiveDependencies: null,
debugGetCreateSourceHash: null,
identifier: identifier,
),
);
}
@override
AutoDisposeFutureProviderElement<SnPublisher?> createElement() {
return _PublisherProviderElement(this);
}
@override
bool operator ==(Object other) {
return other is PublisherProvider && 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 PublisherRef on AutoDisposeFutureProviderRef<SnPublisher?> {
/// The parameter `identifier` of this provider.
String? get identifier;
}
class _PublisherProviderElement
extends AutoDisposeFutureProviderElement<SnPublisher?>
with PublisherRef {
_PublisherProviderElement(super.provider);
@override
String? get identifier => (origin as PublisherProvider).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

@ -20,20 +20,33 @@ class ExploreScreen extends ConsumerWidget {
appBar: AppBar(title: const Text('Explore')),
body: postAsync.when(
data:
(controller) => InfiniteList(
padding: EdgeInsets.zero,
itemCount: controller.posts.length,
isLoading: controller.isLoading,
hasReachedMax: controller.hasReachedMax,
onFetchData: controller.fetchMore,
itemBuilder: (context, index) {
final post = controller.posts[index];
return PostItem(item: post);
},
separatorBuilder: (_, __) => const Divider(height: 1),
(controller) => RefreshIndicator(
onRefresh: controller.refresh,
child: InfiniteList(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).padding.bottom,
),
itemCount: controller.posts.length,
isLoading: controller.isLoading,
hasReachedMax: controller.hasReachedMax,
onFetchData: controller.fetchMore,
itemBuilder: (context, index) {
final post = controller.posts[index];
return PostItem(item: post);
},
separatorBuilder: (_, __) => const Divider(height: 1),
),
),
loading: () => const Center(child: CircularProgressIndicator()),
error: (e, _) => Center(child: Text('Error: $e')),
error:
(e, _) => GestureDetector(
child: Center(
child: Text('Error: $e', textAlign: TextAlign.center),
),
onTap: () {
postAsync.value?.refresh();
},
),
),
);
}
@ -57,6 +70,13 @@ class _PostListController {
final int take = 20;
int total = 0;
Future<void> refresh() async {
hasReachedMax = false;
offset = 0;
posts.clear();
await fetchMore();
}
Future<void> fetchMore() async {
if (isLoading || hasReachedMax) return;
isLoading = true;

View File

@ -17,3 +17,13 @@ void showInfoAlert(String message, String title) async {
iconStyle: IconStyle.information,
);
}
Future<bool> showConfirmAlert(String message, String title) async {
final result = await FlutterPlatformAlert.showAlert(
windowTitle: title,
text: message,
alertStyle: AlertButtonStyle.okCancel,
iconStyle: IconStyle.question,
);
return result == AlertButton.okButton;
}

View File

@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:island/models/file.dart';
import 'package:island/pods/config.dart';
import 'package:lucide_icons/lucide_icons.dart';
import 'package:styled_widget/styled_widget.dart';
import 'image.dart';
import 'video.dart';
@ -43,11 +44,10 @@ class CloudFileWidget extends ConsumerWidget {
class ProfilePictureWidget extends ConsumerWidget {
final SnCloudFile? item;
final double radius;
const ProfilePictureWidget({super.key, required this.item, this.radius = 24});
const ProfilePictureWidget({super.key, required this.item, this.radius = 20});
@override
Widget build(BuildContext context, WidgetRef ref) {
if (item == null) return const SizedBox.shrink();
return ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(radius)),
child: Container(
@ -56,7 +56,7 @@ class ProfilePictureWidget extends ConsumerWidget {
color: Theme.of(context).colorScheme.primaryContainer,
child:
item == null
? Icon(LucideIcons.userCircle)
? Icon(LucideIcons.userCircle, size: radius).center()
: CloudFileWidget(item: item!),
),
);

View File

@ -5,18 +5,26 @@ packages:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: e55636ed79578b9abca5fecf9437947798f5ef7456308b5cb85720b793eac92f
sha256: dc27559385e905ad30838356c5f5d574014ba39872d732111cd07ac0beff4c57
url: "https://pub.dev"
source: hosted
version: "82.0.0"
version: "80.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
sha256: "13c1e6c6fd460522ea840abec3f677cc226f5fec7872c04ad7b425517ccf54f7"
sha256: "192d1c5b944e7e53b24b5586db760db934b177d4147c42fbca8c8c5f1eb8d11e"
url: "https://pub.dev"
source: hosted
version: "7.4.4"
version: "7.3.0"
analyzer_plugin:
dependency: transitive
description:
name: analyzer_plugin
sha256: b3075265c5ab222f8b3188342dcb50b476286394a40323e85d1fa725035d40a4
url: "https://pub.dev"
source: hosted
version: "0.13.0"
animations:
dependency: "direct main"
description:
@ -217,6 +225,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.3"
ci:
dependency: transitive
description:
name: ci
sha256: "145d095ce05cddac4d797a158bc4cf3b6016d1fe63d8c3d2fbd7212590adca13"
url: "https://pub.dev"
source: hosted
version: "0.1.0"
cli_util:
dependency: transitive
description:
name: cli_util
sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c
url: "https://pub.dev"
source: hosted
version: "0.4.2"
clock:
dependency: transitive
description:
@ -273,6 +297,38 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.8"
custom_lint:
dependency: "direct dev"
description:
name: custom_lint
sha256: "409c485fd14f544af1da965d5a0d160ee57cd58b63eeaa7280a4f28cf5bda7f1"
url: "https://pub.dev"
source: hosted
version: "0.7.5"
custom_lint_builder:
dependency: transitive
description:
name: custom_lint_builder
sha256: "107e0a43606138015777590ee8ce32f26ba7415c25b722ff0908a6f5d7a4c228"
url: "https://pub.dev"
source: hosted
version: "0.7.5"
custom_lint_core:
dependency: transitive
description:
name: custom_lint_core
sha256: "31110af3dde9d29fb10828ca33f1dce24d2798477b167675543ce3d208dee8be"
url: "https://pub.dev"
source: hosted
version: "0.7.5"
custom_lint_visitor:
dependency: transitive
description:
name: custom_lint_visitor
sha256: "36282d85714af494ee2d7da8c8913630aa6694da99f104fb2ed4afcf8fc857d8"
url: "https://pub.dev"
source: hosted
version: "1.0.0+7.3.0"
dart_style:
dependency: transitive
description:
@ -669,6 +725,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.6.1"
hotreloader:
dependency: transitive
description:
name: hotreloader
sha256: bc167a1163807b03bada490bfe2df25b0d744df359227880220a5cbd04e5734b
url: "https://pub.dev"
source: hosted
version: "4.3.0"
http:
dependency: transitive
description:
@ -1149,6 +1213,38 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.6.1"
riverpod_analyzer_utils:
dependency: transitive
description:
name: riverpod_analyzer_utils
sha256: "03a17170088c63aab6c54c44456f5ab78876a1ddb6032ffde1662ddab4959611"
url: "https://pub.dev"
source: hosted
version: "0.5.10"
riverpod_annotation:
dependency: "direct main"
description:
name: riverpod_annotation
sha256: e14b0bf45b71326654e2705d462f21b958f987087be850afd60578fcd502d1b8
url: "https://pub.dev"
source: hosted
version: "2.6.1"
riverpod_generator:
dependency: "direct dev"
description:
name: riverpod_generator
sha256: "44a0992d54473eb199ede00e2260bd3c262a86560e3c6f6374503d86d0580e36"
url: "https://pub.dev"
source: hosted
version: "2.6.5"
riverpod_lint:
dependency: "direct dev"
description:
name: riverpod_lint
sha256: "89a52b7334210dbff8605c3edf26cfe69b15062beed5cbfeff2c3812c33c9e35"
url: "https://pub.dev"
source: hosted
version: "2.6.5"
rxdart:
dependency: transitive
description:

View File

@ -75,6 +75,7 @@ dependencies:
cross_file: ^0.3.4+2
image_picker: ^1.1.2
file_picker: ^10.1.2
riverpod_annotation: ^2.6.1
dev_dependencies:
flutter_test:
@ -90,6 +91,9 @@ dev_dependencies:
build_runner: ^2.4.15
freezed: ^3.0.6
json_serializable: ^6.9.5
riverpod_generator: ^2.6.5
custom_lint: ^0.7.5
riverpod_lint: ^2.6.5
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec