merge wrapper and proper FullPost since the separation is not needed anymore
This commit is contained in:
parent
43f2a73ad8
commit
fb78c5654b
|
@ -23,7 +23,8 @@ import '../../widgets/write_comment.dart';
|
|||
import 'comment_section.dart';
|
||||
import 'full_post_store.dart';
|
||||
|
||||
class FullPostPage extends StatelessWidget {
|
||||
/// Displays a post with its comment section
|
||||
class FullPostPage extends HookWidget {
|
||||
final String? instanceHost;
|
||||
final int? id;
|
||||
final PostView? postView;
|
||||
|
@ -45,6 +46,11 @@ class FullPostPage extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final scrollController = useScrollController();
|
||||
|
||||
final loggedInAction =
|
||||
useLoggedInAction(context.read<FullPostStore>().instanceHost);
|
||||
|
||||
return AsyncStoreListener(
|
||||
asyncStore: context.read<FullPostStore>().fullPostState,
|
||||
child: AsyncStoreListener<BlockedCommunity>(
|
||||
|
@ -53,54 +59,7 @@ class FullPostPage extends StatelessWidget {
|
|||
final name = data.communityView.community.originPreferredName;
|
||||
return '${data.blocked ? 'Blocked' : 'Unblocked'} $name';
|
||||
},
|
||||
child: const _FullPostPage(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static Jwt? _tryGetJwt(BuildContext context, String instanceHost) {
|
||||
return context.read<AccountsStore>().defaultUserDataFor(instanceHost)?.jwt;
|
||||
}
|
||||
|
||||
static Route route(int id, String instanceHost) => MaterialPageRoute(
|
||||
builder: (context) => Provider(
|
||||
create: (context) =>
|
||||
FullPostStore(instanceHost: instanceHost, postId: id)
|
||||
..refresh(_tryGetJwt(context, instanceHost)),
|
||||
child: FullPostPage._(
|
||||
id: id,
|
||||
instanceHost: instanceHost,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
static Route fromPostViewRoute(PostView postView) => MaterialPageRoute(
|
||||
builder: (context) => Provider(
|
||||
create: (context) => FullPostStore.fromPostView(postView)
|
||||
..refresh(_tryGetJwt(context, postView.instanceHost)),
|
||||
child: FullPostPage._fromPostView(postView),
|
||||
),
|
||||
);
|
||||
static Route fromPostStoreRoute(PostStore postStore) => MaterialPageRoute(
|
||||
builder: (context) => Provider(
|
||||
create: (context) => FullPostStore.fromPostStore(postStore)
|
||||
..refresh(_tryGetJwt(context, postStore.postView.instanceHost)),
|
||||
child: FullPostPage._fromPostStore(postStore)),
|
||||
);
|
||||
}
|
||||
|
||||
/// Displays a post with its comment section
|
||||
class _FullPostPage extends HookWidget {
|
||||
const _FullPostPage();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final scrollController = useScrollController();
|
||||
|
||||
final loggedInAction =
|
||||
useLoggedInAction(context.read<FullPostStore>().instanceHost);
|
||||
|
||||
return AsyncStoreListener(
|
||||
child: AsyncStoreListener(
|
||||
asyncStore: context.read<FullPostStore>().fullPostState,
|
||||
child: AsyncStoreListener<BlockedCommunity>(
|
||||
asyncStore: context.read<FullPostStore>().communityBlockingState,
|
||||
|
@ -196,8 +155,40 @@ class _FullPostPage extends HookWidget {
|
|||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static Jwt? _tryGetJwt(BuildContext context, String instanceHost) {
|
||||
return context.read<AccountsStore>().defaultUserDataFor(instanceHost)?.jwt;
|
||||
}
|
||||
|
||||
static Route route(int id, String instanceHost) => MaterialPageRoute(
|
||||
builder: (context) => Provider(
|
||||
create: (context) =>
|
||||
FullPostStore(instanceHost: instanceHost, postId: id)
|
||||
..refresh(_tryGetJwt(context, instanceHost)),
|
||||
child: FullPostPage._(
|
||||
id: id,
|
||||
instanceHost: instanceHost,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
static Route fromPostViewRoute(PostView postView) => MaterialPageRoute(
|
||||
builder: (context) => Provider(
|
||||
create: (context) => FullPostStore.fromPostView(postView)
|
||||
..refresh(_tryGetJwt(context, postView.instanceHost)),
|
||||
child: FullPostPage._fromPostView(postView),
|
||||
),
|
||||
);
|
||||
static Route fromPostStoreRoute(PostStore postStore) => MaterialPageRoute(
|
||||
builder: (context) => Provider(
|
||||
create: (context) => FullPostStore.fromPostStore(postStore)
|
||||
..refresh(_tryGetJwt(context, postStore.postView.instanceHost)),
|
||||
child: FullPostPage._fromPostStore(postStore)),
|
||||
);
|
||||
}
|
||||
|
||||
class FailedToLoad extends StatelessWidget {
|
||||
|
|
Loading…
Reference in New Issue