From 70f58259de5b7a548a3443600af6b8d3fb9ab18c Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 14 May 2025 00:49:54 +0800 Subject: [PATCH] :sparkles: Publisher profile basis --- lib/route.dart | 4 + lib/route.gr.dart | 332 ++++++++++++++----------- lib/screens/account/me/publishers.dart | 6 +- lib/screens/account/profile.dart | 23 +- lib/screens/posts/pub_profile.dart | 135 ++++++++++ lib/screens/posts/pub_profile.g.dart | 149 +++++++++++ lib/widgets/post/post_item.dart | 11 +- lib/widgets/post/post_list.dart | 130 ++++++++++ 8 files changed, 632 insertions(+), 158 deletions(-) create mode 100644 lib/screens/posts/pub_profile.dart create mode 100644 lib/screens/posts/pub_profile.g.dart create mode 100644 lib/widgets/post/post_list.dart diff --git a/lib/route.dart b/lib/route.dart index ffac467..ae272dd 100644 --- a/lib/route.dart +++ b/lib/route.dart @@ -35,6 +35,10 @@ class AppRouter extends RootStackRouter { path: '/account/me/publishers/:id/edit', ), AutoRoute(page: AccountProfileRoute.page, path: '/account/:name'), + AutoRoute( + page: PublisherProfileRoute.page, + path: '/account/:name/calendar', + ), AutoRoute(page: PostComposeRoute.page, path: '/posts/compose'), AutoRoute(page: PostDetailRoute.page, path: '/posts/:id'), AutoRoute(page: PostEditRoute.page, path: '/posts/:id/edit'), diff --git a/lib/route.gr.dart b/lib/route.gr.dart index 494b2c3..d1dc0da 100644 --- a/lib/route.gr.dart +++ b/lib/route.gr.dart @@ -9,18 +9,18 @@ // coverage:ignore-file // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'package:auto_route/auto_route.dart' as _i22; -import 'package:flutter/material.dart' as _i23; -import 'package:island/models/post.dart' as _i24; +import 'package:auto_route/auto_route.dart' as _i23; +import 'package:flutter/material.dart' as _i24; +import 'package:island/models/post.dart' as _i25; import 'package:island/screens/account.dart' as _i2; import 'package:island/screens/account/me.dart' as _i15; import 'package:island/screens/account/me/event_calendar.dart' as _i14; import 'package:island/screens/account/me/publishers.dart' as _i8; -import 'package:island/screens/account/me/update.dart' as _i21; +import 'package:island/screens/account/me/update.dart' as _i22; import 'package:island/screens/account/profile.dart' as _i1; import 'package:island/screens/auth/create_account.dart' as _i6; import 'package:island/screens/auth/login.dart' as _i13; -import 'package:island/screens/auth/tabs.dart' as _i20; +import 'package:island/screens/auth/tabs.dart' as _i21; import 'package:island/screens/chat/chat.dart' as _i4; import 'package:island/screens/chat/room.dart' as _i5; import 'package:island/screens/chat/room_detail.dart' as _i3; @@ -30,17 +30,18 @@ import 'package:island/screens/creators/stickers/stickers.dart' as _i10; import 'package:island/screens/explore.dart' as _i12; import 'package:island/screens/posts/compose.dart' as _i16; import 'package:island/screens/posts/detail.dart' as _i17; -import 'package:island/screens/realm/detail.dart' as _i18; +import 'package:island/screens/posts/pub_profile.dart' as _i18; +import 'package:island/screens/realm/detail.dart' as _i19; import 'package:island/screens/realm/realms.dart' as _i9; -import 'package:island/screens/settings.dart' as _i19; +import 'package:island/screens/settings.dart' as _i20; /// generated route for /// [_i1.AccountProfileScreen] -class AccountProfileRoute extends _i22.PageRouteInfo { +class AccountProfileRoute extends _i23.PageRouteInfo { AccountProfileRoute({ - _i23.Key? key, + _i24.Key? key, required String name, - List<_i22.PageRouteInfo>? children, + List<_i23.PageRouteInfo>? children, }) : super( AccountProfileRoute.name, args: AccountProfileRouteArgs(key: key, name: name), @@ -50,7 +51,7 @@ class AccountProfileRoute extends _i22.PageRouteInfo { static const String name = 'AccountProfileRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -66,7 +67,7 @@ class AccountProfileRoute extends _i22.PageRouteInfo { class AccountProfileRouteArgs { const AccountProfileRouteArgs({this.key, required this.name}); - final _i23.Key? key; + final _i24.Key? key; final String name; @@ -78,13 +79,13 @@ class AccountProfileRouteArgs { /// generated route for /// [_i2.AccountScreen] -class AccountRoute extends _i22.PageRouteInfo { - const AccountRoute({List<_i22.PageRouteInfo>? children}) +class AccountRoute extends _i23.PageRouteInfo { + const AccountRoute({List<_i23.PageRouteInfo>? children}) : super(AccountRoute.name, initialChildren: children); static const String name = 'AccountRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { return const _i2.AccountScreen(); @@ -94,11 +95,11 @@ class AccountRoute extends _i22.PageRouteInfo { /// generated route for /// [_i3.ChatDetailScreen] -class ChatDetailRoute extends _i22.PageRouteInfo { +class ChatDetailRoute extends _i23.PageRouteInfo { ChatDetailRoute({ - _i23.Key? key, + _i24.Key? key, required int id, - List<_i22.PageRouteInfo>? children, + List<_i23.PageRouteInfo>? children, }) : super( ChatDetailRoute.name, args: ChatDetailRouteArgs(key: key, id: id), @@ -108,7 +109,7 @@ class ChatDetailRoute extends _i22.PageRouteInfo { static const String name = 'ChatDetailRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -123,7 +124,7 @@ class ChatDetailRoute extends _i22.PageRouteInfo { class ChatDetailRouteArgs { const ChatDetailRouteArgs({this.key, required this.id}); - final _i23.Key? key; + final _i24.Key? key; final int id; @@ -135,13 +136,13 @@ class ChatDetailRouteArgs { /// generated route for /// [_i4.ChatListScreen] -class ChatListRoute extends _i22.PageRouteInfo { - const ChatListRoute({List<_i22.PageRouteInfo>? children}) +class ChatListRoute extends _i23.PageRouteInfo { + const ChatListRoute({List<_i23.PageRouteInfo>? children}) : super(ChatListRoute.name, initialChildren: children); static const String name = 'ChatListRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { return const _i4.ChatListScreen(); @@ -151,11 +152,11 @@ class ChatListRoute extends _i22.PageRouteInfo { /// generated route for /// [_i5.ChatRoomScreen] -class ChatRoomRoute extends _i22.PageRouteInfo { +class ChatRoomRoute extends _i23.PageRouteInfo { ChatRoomRoute({ - _i23.Key? key, + _i24.Key? key, required int id, - List<_i22.PageRouteInfo>? children, + List<_i23.PageRouteInfo>? children, }) : super( ChatRoomRoute.name, args: ChatRoomRouteArgs(key: key, id: id), @@ -165,7 +166,7 @@ class ChatRoomRoute extends _i22.PageRouteInfo { static const String name = 'ChatRoomRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -180,7 +181,7 @@ class ChatRoomRoute extends _i22.PageRouteInfo { class ChatRoomRouteArgs { const ChatRoomRouteArgs({this.key, required this.id}); - final _i23.Key? key; + final _i24.Key? key; final int id; @@ -192,13 +193,13 @@ class ChatRoomRouteArgs { /// generated route for /// [_i6.CreateAccountScreen] -class CreateAccountRoute extends _i22.PageRouteInfo { - const CreateAccountRoute({List<_i22.PageRouteInfo>? children}) +class CreateAccountRoute extends _i23.PageRouteInfo { + const CreateAccountRoute({List<_i23.PageRouteInfo>? children}) : super(CreateAccountRoute.name, initialChildren: children); static const String name = 'CreateAccountRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { return const _i6.CreateAccountScreen(); @@ -208,13 +209,13 @@ class CreateAccountRoute extends _i22.PageRouteInfo { /// generated route for /// [_i7.CreatorHubScreen] -class CreatorHubRoute extends _i22.PageRouteInfo { - const CreatorHubRoute({List<_i22.PageRouteInfo>? children}) +class CreatorHubRoute extends _i23.PageRouteInfo { + const CreatorHubRoute({List<_i23.PageRouteInfo>? children}) : super(CreatorHubRoute.name, initialChildren: children); static const String name = 'CreatorHubRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { return const _i7.CreatorHubScreen(); @@ -224,8 +225,8 @@ class CreatorHubRoute extends _i22.PageRouteInfo { /// generated route for /// [_i4.EditChatScreen] -class EditChatRoute extends _i22.PageRouteInfo { - EditChatRoute({_i23.Key? key, int? id, List<_i22.PageRouteInfo>? children}) +class EditChatRoute extends _i23.PageRouteInfo { + EditChatRoute({_i24.Key? key, int? id, List<_i23.PageRouteInfo>? children}) : super( EditChatRoute.name, args: EditChatRouteArgs(key: key, id: id), @@ -235,7 +236,7 @@ class EditChatRoute extends _i22.PageRouteInfo { static const String name = 'EditChatRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -250,7 +251,7 @@ class EditChatRoute extends _i22.PageRouteInfo { class EditChatRouteArgs { const EditChatRouteArgs({this.key, this.id}); - final _i23.Key? key; + final _i24.Key? key; final int? id; @@ -262,11 +263,11 @@ class EditChatRouteArgs { /// generated route for /// [_i8.EditPublisherScreen] -class EditPublisherRoute extends _i22.PageRouteInfo { +class EditPublisherRoute extends _i23.PageRouteInfo { EditPublisherRoute({ - _i23.Key? key, + _i24.Key? key, String? name, - List<_i22.PageRouteInfo>? children, + List<_i23.PageRouteInfo>? children, }) : super( EditPublisherRoute.name, args: EditPublisherRouteArgs(key: key, name: name), @@ -276,7 +277,7 @@ class EditPublisherRoute extends _i22.PageRouteInfo { static const String name = 'EditPublisherRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -291,7 +292,7 @@ class EditPublisherRoute extends _i22.PageRouteInfo { class EditPublisherRouteArgs { const EditPublisherRouteArgs({this.key, this.name}); - final _i23.Key? key; + final _i24.Key? key; final String? name; @@ -303,11 +304,11 @@ class EditPublisherRouteArgs { /// generated route for /// [_i9.EditRealmScreen] -class EditRealmRoute extends _i22.PageRouteInfo { +class EditRealmRoute extends _i23.PageRouteInfo { EditRealmRoute({ - _i23.Key? key, + _i24.Key? key, String? slug, - List<_i22.PageRouteInfo>? children, + List<_i23.PageRouteInfo>? children, }) : super( EditRealmRoute.name, args: EditRealmRouteArgs(key: key, slug: slug), @@ -317,7 +318,7 @@ class EditRealmRoute extends _i22.PageRouteInfo { static const String name = 'EditRealmRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -332,7 +333,7 @@ class EditRealmRoute extends _i22.PageRouteInfo { class EditRealmRouteArgs { const EditRealmRouteArgs({this.key, this.slug}); - final _i23.Key? key; + final _i24.Key? key; final String? slug; @@ -345,12 +346,12 @@ class EditRealmRouteArgs { /// generated route for /// [_i10.EditStickerPacksScreen] class EditStickerPacksRoute - extends _i22.PageRouteInfo { + extends _i23.PageRouteInfo { EditStickerPacksRoute({ - _i23.Key? key, + _i24.Key? key, required String pubName, String? packId, - List<_i22.PageRouteInfo>? children, + List<_i23.PageRouteInfo>? children, }) : super( EditStickerPacksRoute.name, args: EditStickerPacksRouteArgs( @@ -364,7 +365,7 @@ class EditStickerPacksRoute static const String name = 'EditStickerPacksRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -391,7 +392,7 @@ class EditStickerPacksRouteArgs { this.packId, }); - final _i23.Key? key; + final _i24.Key? key; final String pubName; @@ -405,12 +406,12 @@ class EditStickerPacksRouteArgs { /// generated route for /// [_i11.EditStickersScreen] -class EditStickersRoute extends _i22.PageRouteInfo { +class EditStickersRoute extends _i23.PageRouteInfo { EditStickersRoute({ - _i23.Key? key, + _i24.Key? key, required String packId, required String? id, - List<_i22.PageRouteInfo>? children, + List<_i23.PageRouteInfo>? children, }) : super( EditStickersRoute.name, args: EditStickersRouteArgs(key: key, packId: packId, id: id), @@ -420,7 +421,7 @@ class EditStickersRoute extends _i22.PageRouteInfo { static const String name = 'EditStickersRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -447,7 +448,7 @@ class EditStickersRouteArgs { required this.id, }); - final _i23.Key? key; + final _i24.Key? key; final String packId; @@ -461,13 +462,13 @@ class EditStickersRouteArgs { /// generated route for /// [_i12.ExploreScreen] -class ExploreRoute extends _i22.PageRouteInfo { - const ExploreRoute({List<_i22.PageRouteInfo>? children}) +class ExploreRoute extends _i23.PageRouteInfo { + const ExploreRoute({List<_i23.PageRouteInfo>? children}) : super(ExploreRoute.name, initialChildren: children); static const String name = 'ExploreRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { return const _i12.ExploreScreen(); @@ -477,13 +478,13 @@ class ExploreRoute extends _i22.PageRouteInfo { /// generated route for /// [_i13.LoginScreen] -class LoginRoute extends _i22.PageRouteInfo { - const LoginRoute({List<_i22.PageRouteInfo>? children}) +class LoginRoute extends _i23.PageRouteInfo { + const LoginRoute({List<_i23.PageRouteInfo>? children}) : super(LoginRoute.name, initialChildren: children); static const String name = 'LoginRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { return const _i13.LoginScreen(); @@ -493,13 +494,13 @@ class LoginRoute extends _i22.PageRouteInfo { /// generated route for /// [_i8.ManagedPublisherScreen] -class ManagedPublisherRoute extends _i22.PageRouteInfo { - const ManagedPublisherRoute({List<_i22.PageRouteInfo>? children}) +class ManagedPublisherRoute extends _i23.PageRouteInfo { + const ManagedPublisherRoute({List<_i23.PageRouteInfo>? children}) : super(ManagedPublisherRoute.name, initialChildren: children); static const String name = 'ManagedPublisherRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { return const _i8.ManagedPublisherScreen(); @@ -509,13 +510,13 @@ class ManagedPublisherRoute extends _i22.PageRouteInfo { /// generated route for /// [_i14.MyselfEventCalendarScreen] -class MyselfEventCalendarRoute extends _i22.PageRouteInfo { - const MyselfEventCalendarRoute({List<_i22.PageRouteInfo>? children}) +class MyselfEventCalendarRoute extends _i23.PageRouteInfo { + const MyselfEventCalendarRoute({List<_i23.PageRouteInfo>? children}) : super(MyselfEventCalendarRoute.name, initialChildren: children); static const String name = 'MyselfEventCalendarRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { return const _i14.MyselfEventCalendarScreen(); @@ -525,13 +526,13 @@ class MyselfEventCalendarRoute extends _i22.PageRouteInfo { /// generated route for /// [_i15.MyselfProfileScreen] -class MyselfProfileRoute extends _i22.PageRouteInfo { - const MyselfProfileRoute({List<_i22.PageRouteInfo>? children}) +class MyselfProfileRoute extends _i23.PageRouteInfo { + const MyselfProfileRoute({List<_i23.PageRouteInfo>? children}) : super(MyselfProfileRoute.name, initialChildren: children); static const String name = 'MyselfProfileRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { return const _i15.MyselfProfileScreen(); @@ -541,13 +542,13 @@ class MyselfProfileRoute extends _i22.PageRouteInfo { /// generated route for /// [_i4.NewChatScreen] -class NewChatRoute extends _i22.PageRouteInfo { - const NewChatRoute({List<_i22.PageRouteInfo>? children}) +class NewChatRoute extends _i23.PageRouteInfo { + const NewChatRoute({List<_i23.PageRouteInfo>? children}) : super(NewChatRoute.name, initialChildren: children); static const String name = 'NewChatRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { return const _i4.NewChatScreen(); @@ -557,13 +558,13 @@ class NewChatRoute extends _i22.PageRouteInfo { /// generated route for /// [_i8.NewPublisherScreen] -class NewPublisherRoute extends _i22.PageRouteInfo { - const NewPublisherRoute({List<_i22.PageRouteInfo>? children}) +class NewPublisherRoute extends _i23.PageRouteInfo { + const NewPublisherRoute({List<_i23.PageRouteInfo>? children}) : super(NewPublisherRoute.name, initialChildren: children); static const String name = 'NewPublisherRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { return const _i8.NewPublisherScreen(); @@ -573,13 +574,13 @@ class NewPublisherRoute extends _i22.PageRouteInfo { /// generated route for /// [_i9.NewRealmScreen] -class NewRealmRoute extends _i22.PageRouteInfo { - const NewRealmRoute({List<_i22.PageRouteInfo>? children}) +class NewRealmRoute extends _i23.PageRouteInfo { + const NewRealmRoute({List<_i23.PageRouteInfo>? children}) : super(NewRealmRoute.name, initialChildren: children); static const String name = 'NewRealmRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { return const _i9.NewRealmScreen(); @@ -590,11 +591,11 @@ class NewRealmRoute extends _i22.PageRouteInfo { /// generated route for /// [_i10.NewStickerPacksScreen] class NewStickerPacksRoute - extends _i22.PageRouteInfo { + extends _i23.PageRouteInfo { NewStickerPacksRoute({ - _i23.Key? key, + _i24.Key? key, required String pubName, - List<_i22.PageRouteInfo>? children, + List<_i23.PageRouteInfo>? children, }) : super( NewStickerPacksRoute.name, args: NewStickerPacksRouteArgs(key: key, pubName: pubName), @@ -604,7 +605,7 @@ class NewStickerPacksRoute static const String name = 'NewStickerPacksRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -621,7 +622,7 @@ class NewStickerPacksRoute class NewStickerPacksRouteArgs { const NewStickerPacksRouteArgs({this.key, required this.pubName}); - final _i23.Key? key; + final _i24.Key? key; final String pubName; @@ -633,11 +634,11 @@ class NewStickerPacksRouteArgs { /// generated route for /// [_i11.NewStickersScreen] -class NewStickersRoute extends _i22.PageRouteInfo { +class NewStickersRoute extends _i23.PageRouteInfo { NewStickersRoute({ - _i23.Key? key, + _i24.Key? key, required String packId, - List<_i22.PageRouteInfo>? children, + List<_i23.PageRouteInfo>? children, }) : super( NewStickersRoute.name, args: NewStickersRouteArgs(key: key, packId: packId), @@ -647,7 +648,7 @@ class NewStickersRoute extends _i22.PageRouteInfo { static const String name = 'NewStickersRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -663,7 +664,7 @@ class NewStickersRoute extends _i22.PageRouteInfo { class NewStickersRouteArgs { const NewStickersRouteArgs({this.key, required this.packId}); - final _i23.Key? key; + final _i24.Key? key; final String packId; @@ -675,11 +676,11 @@ class NewStickersRouteArgs { /// generated route for /// [_i16.PostComposeScreen] -class PostComposeRoute extends _i22.PageRouteInfo { +class PostComposeRoute extends _i23.PageRouteInfo { PostComposeRoute({ - _i23.Key? key, - _i24.SnPost? originalPost, - List<_i22.PageRouteInfo>? children, + _i24.Key? key, + _i25.SnPost? originalPost, + List<_i23.PageRouteInfo>? children, }) : super( PostComposeRoute.name, args: PostComposeRouteArgs(key: key, originalPost: originalPost), @@ -688,7 +689,7 @@ class PostComposeRoute extends _i22.PageRouteInfo { static const String name = 'PostComposeRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { final args = data.argsAs( @@ -705,9 +706,9 @@ class PostComposeRoute extends _i22.PageRouteInfo { class PostComposeRouteArgs { const PostComposeRouteArgs({this.key, this.originalPost}); - final _i23.Key? key; + final _i24.Key? key; - final _i24.SnPost? originalPost; + final _i25.SnPost? originalPost; @override String toString() { @@ -717,11 +718,11 @@ class PostComposeRouteArgs { /// generated route for /// [_i17.PostDetailScreen] -class PostDetailRoute extends _i22.PageRouteInfo { +class PostDetailRoute extends _i23.PageRouteInfo { PostDetailRoute({ - _i23.Key? key, + _i24.Key? key, required int id, - List<_i22.PageRouteInfo>? children, + List<_i23.PageRouteInfo>? children, }) : super( PostDetailRoute.name, args: PostDetailRouteArgs(key: key, id: id), @@ -731,7 +732,7 @@ class PostDetailRoute extends _i22.PageRouteInfo { static const String name = 'PostDetailRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -746,7 +747,7 @@ class PostDetailRoute extends _i22.PageRouteInfo { class PostDetailRouteArgs { const PostDetailRouteArgs({this.key, required this.id}); - final _i23.Key? key; + final _i24.Key? key; final int id; @@ -758,11 +759,11 @@ class PostDetailRouteArgs { /// generated route for /// [_i16.PostEditScreen] -class PostEditRoute extends _i22.PageRouteInfo { +class PostEditRoute extends _i23.PageRouteInfo { PostEditRoute({ - _i23.Key? key, + _i24.Key? key, required int id, - List<_i22.PageRouteInfo>? children, + List<_i23.PageRouteInfo>? children, }) : super( PostEditRoute.name, args: PostEditRouteArgs(key: key, id: id), @@ -772,7 +773,7 @@ class PostEditRoute extends _i22.PageRouteInfo { static const String name = 'PostEditRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -787,7 +788,7 @@ class PostEditRoute extends _i22.PageRouteInfo { class PostEditRouteArgs { const PostEditRouteArgs({this.key, required this.id}); - final _i23.Key? key; + final _i24.Key? key; final int id; @@ -798,12 +799,55 @@ class PostEditRouteArgs { } /// generated route for -/// [_i18.RealmDetailScreen] -class RealmDetailRoute extends _i22.PageRouteInfo { +/// [_i18.PublisherProfileScreen] +class PublisherProfileRoute + extends _i23.PageRouteInfo { + PublisherProfileRoute({ + _i24.Key? key, + required String name, + List<_i23.PageRouteInfo>? children, + }) : super( + PublisherProfileRoute.name, + args: PublisherProfileRouteArgs(key: key, name: name), + rawPathParams: {'name': name}, + initialChildren: children, + ); + + static const String name = 'PublisherProfileRoute'; + + static _i23.PageInfo page = _i23.PageInfo( + name, + builder: (data) { + final pathParams = data.inheritedPathParams; + final args = data.argsAs( + orElse: + () => PublisherProfileRouteArgs(name: pathParams.getString('name')), + ); + return _i18.PublisherProfileScreen(key: args.key, name: args.name); + }, + ); +} + +class PublisherProfileRouteArgs { + const PublisherProfileRouteArgs({this.key, required this.name}); + + final _i24.Key? key; + + final String name; + + @override + String toString() { + return 'PublisherProfileRouteArgs{key: $key, name: $name}'; + } +} + +/// generated route for +/// [_i19.RealmDetailScreen] +class RealmDetailRoute extends _i23.PageRouteInfo { RealmDetailRoute({ - _i23.Key? key, + _i24.Key? key, required String slug, - List<_i22.PageRouteInfo>? children, + List<_i23.PageRouteInfo>? children, }) : super( RealmDetailRoute.name, args: RealmDetailRouteArgs(key: key, slug: slug), @@ -813,14 +857,14 @@ class RealmDetailRoute extends _i22.PageRouteInfo { static const String name = 'RealmDetailRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; final args = data.argsAs( orElse: () => RealmDetailRouteArgs(slug: pathParams.getString('slug')), ); - return _i18.RealmDetailScreen(key: args.key, slug: args.slug); + return _i19.RealmDetailScreen(key: args.key, slug: args.slug); }, ); } @@ -828,7 +872,7 @@ class RealmDetailRoute extends _i22.PageRouteInfo { class RealmDetailRouteArgs { const RealmDetailRouteArgs({this.key, required this.slug}); - final _i23.Key? key; + final _i24.Key? key; final String slug; @@ -840,13 +884,13 @@ class RealmDetailRouteArgs { /// generated route for /// [_i9.RealmListScreen] -class RealmListRoute extends _i22.PageRouteInfo { - const RealmListRoute({List<_i22.PageRouteInfo>? children}) +class RealmListRoute extends _i23.PageRouteInfo { + const RealmListRoute({List<_i23.PageRouteInfo>? children}) : super(RealmListRoute.name, initialChildren: children); static const String name = 'RealmListRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { return const _i9.RealmListScreen(); @@ -855,17 +899,17 @@ class RealmListRoute extends _i22.PageRouteInfo { } /// generated route for -/// [_i19.SettingsScreen] -class SettingsRoute extends _i22.PageRouteInfo { - const SettingsRoute({List<_i22.PageRouteInfo>? children}) +/// [_i20.SettingsScreen] +class SettingsRoute extends _i23.PageRouteInfo { + const SettingsRoute({List<_i23.PageRouteInfo>? children}) : super(SettingsRoute.name, initialChildren: children); static const String name = 'SettingsRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { - return const _i19.SettingsScreen(); + return const _i20.SettingsScreen(); }, ); } @@ -873,12 +917,12 @@ class SettingsRoute extends _i22.PageRouteInfo { /// generated route for /// [_i11.StickerPackDetailScreen] class StickerPackDetailRoute - extends _i22.PageRouteInfo { + extends _i23.PageRouteInfo { StickerPackDetailRoute({ - _i23.Key? key, + _i24.Key? key, required String pubName, required String id, - List<_i22.PageRouteInfo>? children, + List<_i23.PageRouteInfo>? children, }) : super( StickerPackDetailRoute.name, args: StickerPackDetailRouteArgs(key: key, pubName: pubName, id: id), @@ -888,7 +932,7 @@ class StickerPackDetailRoute static const String name = 'StickerPackDetailRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -915,7 +959,7 @@ class StickerPackDetailRouteArgs { required this.id, }); - final _i23.Key? key; + final _i24.Key? key; final String pubName; @@ -929,11 +973,11 @@ class StickerPackDetailRouteArgs { /// generated route for /// [_i10.StickersScreen] -class StickersRoute extends _i22.PageRouteInfo { +class StickersRoute extends _i23.PageRouteInfo { StickersRoute({ - _i23.Key? key, + _i24.Key? key, required String pubName, - List<_i22.PageRouteInfo>? children, + List<_i23.PageRouteInfo>? children, }) : super( StickersRoute.name, args: StickersRouteArgs(key: key, pubName: pubName), @@ -943,7 +987,7 @@ class StickersRoute extends _i22.PageRouteInfo { static const String name = 'StickersRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -958,7 +1002,7 @@ class StickersRoute extends _i22.PageRouteInfo { class StickersRouteArgs { const StickersRouteArgs({this.key, required this.pubName}); - final _i23.Key? key; + final _i24.Key? key; final String pubName; @@ -969,33 +1013,33 @@ class StickersRouteArgs { } /// generated route for -/// [_i20.TabsScreen] -class TabsRoute extends _i22.PageRouteInfo { - const TabsRoute({List<_i22.PageRouteInfo>? children}) +/// [_i21.TabsScreen] +class TabsRoute extends _i23.PageRouteInfo { + const TabsRoute({List<_i23.PageRouteInfo>? children}) : super(TabsRoute.name, initialChildren: children); static const String name = 'TabsRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { - return const _i20.TabsScreen(); + return const _i21.TabsScreen(); }, ); } /// generated route for -/// [_i21.UpdateProfileScreen] -class UpdateProfileRoute extends _i22.PageRouteInfo { - const UpdateProfileRoute({List<_i22.PageRouteInfo>? children}) +/// [_i22.UpdateProfileScreen] +class UpdateProfileRoute extends _i23.PageRouteInfo { + const UpdateProfileRoute({List<_i23.PageRouteInfo>? children}) : super(UpdateProfileRoute.name, initialChildren: children); static const String name = 'UpdateProfileRoute'; - static _i22.PageInfo page = _i22.PageInfo( + static _i23.PageInfo page = _i23.PageInfo( name, builder: (data) { - return const _i21.UpdateProfileScreen(); + return const _i22.UpdateProfileScreen(); }, ); } diff --git a/lib/screens/account/me/publishers.dart b/lib/screens/account/me/publishers.dart index 5163d1e..3d1ee07 100644 --- a/lib/screens/account/me/publishers.dart +++ b/lib/screens/account/me/publishers.dart @@ -272,7 +272,11 @@ class EditPublisherScreen extends HookConsumerWidget { try { final client = ref.watch(apiClientProvider); final resp = await client.request( - name == null ? '/publishers/individual' : '/publishers/$name', + name == null + ? currentRealm.value == null + ? '/publishers/individual' + : '/publishers/organization/${currentRealm.value!.slug}' + : '/publishers/$name', data: { 'name': nameController.text, 'nick': nickController.text, diff --git a/lib/screens/account/profile.dart b/lib/screens/account/profile.dart index bab682c..ffbc99e 100644 --- a/lib/screens/account/profile.dart +++ b/lib/screens/account/profile.dart @@ -31,7 +31,7 @@ class AccountProfileScreen extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - final accountAsync = ref.watch(accountProvider(name)); + final account = ref.watch(accountProvider(name)); final iconShadow = Shadow( color: Colors.black54, @@ -39,7 +39,7 @@ class AccountProfileScreen extends HookConsumerWidget { offset: Offset(1.0, 1.0), ); - return accountAsync.when( + return account.when( data: (data) => AppScaffold( body: CustomScrollView( @@ -110,17 +110,16 @@ class AccountProfileScreen extends HookConsumerWidget { SliverToBoxAdapter( child: const Divider(height: 1).padding(bottom: 24), ), - SliverToBoxAdapter( - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Text('bio').tr().bold(), - if (data.profile.bio != null && - data.profile.bio!.isNotEmpty) + if (data.profile.bio != null && data.profile.bio!.isNotEmpty) + SliverToBoxAdapter( + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text('bio').tr().bold(), Text(data.profile.bio!), - ], - ).padding(horizontal: 24), - ), + ], + ).padding(horizontal: 24), + ), ], ), ), diff --git a/lib/screens/posts/pub_profile.dart b/lib/screens/posts/pub_profile.dart new file mode 100644 index 0000000..cb42b6d --- /dev/null +++ b/lib/screens/posts/pub_profile.dart @@ -0,0 +1,135 @@ +import 'package:auto_route/annotations.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/models/post.dart'; +import 'package:island/pods/network.dart'; +import 'package:island/widgets/account/status.dart'; +import 'package:island/widgets/app_scaffold.dart'; +import 'package:island/widgets/content/cloud_files.dart'; +import 'package:island/widgets/post/post_list.dart'; +import 'package:riverpod_annotation/riverpod_annotation.dart'; +import 'package:styled_widget/styled_widget.dart'; + +part 'pub_profile.g.dart'; + +@riverpod +Future publisher(Ref ref, String uname) async { + final apiClient = ref.watch(apiClientProvider); + final resp = await apiClient.get("/publishers/$uname"); + return SnPublisher.fromJson(resp.data); +} + +@RoutePage() +class PublisherProfileScreen extends HookConsumerWidget { + final String name; + const PublisherProfileScreen({ + super.key, + @PathParam("name") required this.name, + }); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final publisher = ref.watch(publisherProvider(name)); + + final iconShadow = Shadow( + color: Colors.black54, + blurRadius: 5.0, + offset: Offset(1.0, 1.0), + ); + + return publisher.when( + data: + (data) => AppScaffold( + body: CustomScrollView( + slivers: [ + SliverAppBar( + expandedHeight: 180, + pinned: true, + leading: PageBackButton(shadows: [iconShadow]), + flexibleSpace: FlexibleSpaceBar( + background: + data.backgroundId != null + ? CloudImageWidget(fileId: data.backgroundId!) + : Container( + color: + Theme.of(context).appBarTheme.backgroundColor, + ), + title: Text( + data.nick, + style: TextStyle( + color: Theme.of(context).appBarTheme.foregroundColor, + shadows: [iconShadow], + ), + ), + ), + ), + SliverToBoxAdapter( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + spacing: 20, + children: [ + ProfilePictureWidget(fileId: data.pictureId!, radius: 32), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Row( + spacing: 6, + children: [ + Text(data.nick).fontSize(20), + Text( + '@${data.name}', + ).fontSize(14).opacity(0.85), + ], + ), + if (data.publisherType == 0) + AccountStatusWidget( + uname: name, + padding: EdgeInsets.zero, + ), + ], + ), + ), + ], + ).padding(horizontal: 24, top: 24, bottom: 24), + ), + // if (data.badges.isNotEmpty) + // SliverToBoxAdapter( + // child: BadgeList( + // badges: data.badges, + // ).padding(horizontal: 24, bottom: 24), + // ) + // else + // const Gap(16), + SliverToBoxAdapter(child: const Divider(height: 1)), + if (data.bio.isNotEmpty) + SliverToBoxAdapter( + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [Text('bio').tr().bold(), Text(data.bio)], + ).padding(horizontal: 24, top: 24), + ), + if (data.bio.isNotEmpty) + SliverToBoxAdapter( + child: const Divider(height: 1).padding(top: 24), + ), + SliverPostList(pubName: name), + SliverGap(MediaQuery.of(context).padding.bottom + 16), + ], + ), + ), + error: + (error, stackTrace) => AppScaffold( + appBar: AppBar(leading: const PageBackButton()), + body: Center(child: Text(error.toString())), + ), + loading: + () => AppScaffold( + appBar: AppBar(leading: const PageBackButton()), + body: Center(child: CircularProgressIndicator()), + ), + ); + } +} diff --git a/lib/screens/posts/pub_profile.g.dart b/lib/screens/posts/pub_profile.g.dart new file mode 100644 index 0000000..26eba9d --- /dev/null +++ b/lib/screens/posts/pub_profile.g.dart @@ -0,0 +1,149 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'pub_profile.dart'; + +// ************************************************************************** +// RiverpodGenerator +// ************************************************************************** + +String _$publisherHash() => r'3a7ae4d48765170aea42c7d6f4502d68f984dfab'; + +/// 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> { + /// See also [publisher]. + const PublisherFamily(); + + /// See also [publisher]. + PublisherProvider call(String uname) { + return PublisherProvider(uname); + } + + @override + PublisherProvider getProviderOverride(covariant PublisherProvider provider) { + return call(provider.uname); + } + + static const Iterable? _dependencies = null; + + @override + Iterable? get dependencies => _dependencies; + + static const Iterable? _allTransitiveDependencies = null; + + @override + Iterable? get allTransitiveDependencies => + _allTransitiveDependencies; + + @override + String? get name => r'publisherProvider'; +} + +/// See also [publisher]. +class PublisherProvider extends AutoDisposeFutureProvider { + /// See also [publisher]. + PublisherProvider(String uname) + : this._internal( + (ref) => publisher(ref as PublisherRef, uname), + from: publisherProvider, + name: r'publisherProvider', + debugGetCreateSourceHash: + const bool.fromEnvironment('dart.vm.product') + ? null + : _$publisherHash, + dependencies: PublisherFamily._dependencies, + allTransitiveDependencies: PublisherFamily._allTransitiveDependencies, + uname: uname, + ); + + PublisherProvider._internal( + super._createNotifier, { + required super.name, + required super.dependencies, + required super.allTransitiveDependencies, + required super.debugGetCreateSourceHash, + required super.from, + required this.uname, + }) : super.internal(); + + final String uname; + + @override + Override overrideWith( + FutureOr 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, + uname: uname, + ), + ); + } + + @override + AutoDisposeFutureProviderElement createElement() { + return _PublisherProviderElement(this); + } + + @override + bool operator ==(Object other) { + return other is PublisherProvider && other.uname == uname; + } + + @override + int get hashCode { + var hash = _SystemHash.combine(0, runtimeType.hashCode); + hash = _SystemHash.combine(hash, uname.hashCode); + + return _SystemHash.finish(hash); + } +} + +@Deprecated('Will be removed in 3.0. Use Ref instead') +// ignore: unused_element +mixin PublisherRef on AutoDisposeFutureProviderRef { + /// The parameter `uname` of this provider. + String get uname; +} + +class _PublisherProviderElement + extends AutoDisposeFutureProviderElement + with PublisherRef { + _PublisherProviderElement(super.provider); + + @override + String get uname => (origin as PublisherProvider).uname; +} + +// ignore_for_file: type=lint +// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/lib/widgets/post/post_item.dart b/lib/widgets/post/post_item.dart index 3d65f85..6135765 100644 --- a/lib/widgets/post/post_item.dart +++ b/lib/widgets/post/post_item.dart @@ -106,7 +106,16 @@ class PostItem extends HookConsumerWidget { crossAxisAlignment: CrossAxisAlignment.start, spacing: 12, children: [ - ProfilePictureWidget(fileId: item.publisher.pictureId), + GestureDetector( + child: ProfilePictureWidget( + fileId: item.publisher.pictureId, + ), + onTap: () { + context.router.push( + PublisherProfileRoute(name: item.publisher.name), + ); + }, + ), Expanded( child: GestureDetector( child: Column( diff --git a/lib/widgets/post/post_list.dart b/lib/widgets/post/post_list.dart new file mode 100644 index 0000000..f2b8296 --- /dev/null +++ b/lib/widgets/post/post_list.dart @@ -0,0 +1,130 @@ +import 'package:flutter/material.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:dio/dio.dart'; +import 'package:island/models/post.dart'; +import 'package:island/pods/network.dart'; +import 'package:island/widgets/post/post_item.dart'; +import 'package:styled_widget/styled_widget.dart'; +import 'package:very_good_infinite_list/very_good_infinite_list.dart'; + +// State class to hold posts and pagination info +class PostListState { + final List posts; + final bool isLoading; + final String? error; + final int total; + final bool hasMore; + + const PostListState({ + this.posts = const [], + this.isLoading = false, + this.error, + this.total = 0, + this.hasMore = true, + }); + + PostListState copyWith({ + List? posts, + bool? isLoading, + String? error, + int? total, + bool? hasMore, + }) { + return PostListState( + posts: posts ?? this.posts, + isLoading: isLoading ?? this.isLoading, + error: error, + total: total ?? this.total, + hasMore: hasMore ?? this.hasMore, + ); + } +} + +// Provider for managing post list state +final postListProvider = + StateNotifierProvider.family(( + ref, + pubName, + ) { + final dio = ref.watch(apiClientProvider); + return PostListNotifier(dio, pubName); + }); + +class PostListNotifier extends StateNotifier { + final Dio _dio; + final String? pubName; + static const int _pageSize = 20; + + PostListNotifier(this._dio, this.pubName) : super(const PostListState()) { + loadInitialPosts(); + } + + Future loadInitialPosts() async { + state = state.copyWith(isLoading: true, error: null); + try { + final result = await _fetchPosts(0); + state = PostListState( + posts: result.posts, + total: result.total, + hasMore: result.posts.length < result.total, + isLoading: false, + ); + } catch (e) { + state = state.copyWith(isLoading: false, error: e.toString()); + } + } + + Future loadMorePosts() async { + if (state.isLoading || !state.hasMore) return; + + state = state.copyWith(isLoading: true, error: null); + try { + final result = await _fetchPosts(state.posts.length); + state = state.copyWith( + posts: [...state.posts, ...result.posts], + total: result.total, + hasMore: state.posts.length + result.posts.length < result.total, + isLoading: false, + ); + } catch (e) { + state = state.copyWith(isLoading: false, error: e.toString()); + } + } + + Future<({List posts, int total})> _fetchPosts(int offset) async { + final queryParams = { + 'offset': offset, + 'take': _pageSize, + if (pubName != null) 'pub': pubName, + }; + + final response = await _dio.get('/posts', queryParameters: queryParams); + final total = int.parse(response.headers.value('X-Total') ?? '0'); + final List data = response.data; + final posts = data.map((json) => SnPost.fromJson(json)).toList(); + + return (posts: posts, total: total); + } +} + +class SliverPostList extends HookConsumerWidget { + final String? pubName; + const SliverPostList({super.key, this.pubName}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final state = ref.watch(postListProvider(pubName)); + final notifier = ref.read(postListProvider(pubName).notifier); + + return SliverInfiniteList( + onFetchData: notifier.loadMorePosts, + itemCount: state.posts.length, + hasReachedMax: !state.hasMore, + isLoading: state.isLoading, + itemBuilder: (context, index) { + return PostItem(item: state.posts[index]); + }, + separatorBuilder: (_, __) => const Divider(height: 1), + ); + } +}