make FullPostPage a bit easier to expand in the future
This commit is contained in:
parent
ee57a0de07
commit
cca679d6ef
|
@ -25,19 +25,35 @@ import '../../widgets/reveal_after_scroll.dart';
|
||||||
import '../../widgets/write_comment.dart';
|
import '../../widgets/write_comment.dart';
|
||||||
|
|
||||||
class FullPostPage extends StatelessWidget {
|
class FullPostPage extends StatelessWidget {
|
||||||
final FullPostStore fullPostStore;
|
final String? instanceHost;
|
||||||
|
final int? id;
|
||||||
|
final PostView? postView;
|
||||||
|
final PostStore? postStore;
|
||||||
|
|
||||||
FullPostPage({required int id, required String instanceHost})
|
const FullPostPage({required int this.id, required String this.instanceHost})
|
||||||
: fullPostStore = FullPostStore(instanceHost: instanceHost, postId: id);
|
: postView = null,
|
||||||
FullPostPage.fromPostView(PostView postView)
|
postStore = null;
|
||||||
: fullPostStore = FullPostStore.fromPostView(postView);
|
const FullPostPage.fromPostView(PostView this.postView)
|
||||||
FullPostPage.fromPostStore(PostStore postStore)
|
: id = null,
|
||||||
: fullPostStore = FullPostStore.fromPostStore(postStore);
|
instanceHost = null,
|
||||||
|
postStore = null;
|
||||||
|
const FullPostPage.fromPostStore(PostStore this.postStore)
|
||||||
|
: id = null,
|
||||||
|
instanceHost = null,
|
||||||
|
postView = null;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Provider(
|
return Provider(
|
||||||
create: (context) => fullPostStore,
|
create: (context) {
|
||||||
|
if (postStore != null) {
|
||||||
|
return FullPostStore.fromPostStore(postStore!);
|
||||||
|
} else if (postView != null) {
|
||||||
|
return FullPostStore.fromPostView(postView!);
|
||||||
|
} else {
|
||||||
|
return FullPostStore(instanceHost: instanceHost!, postId: id!);
|
||||||
|
}
|
||||||
|
},
|
||||||
builder: (context, store) => AsyncStoreListener(
|
builder: (context, store) => AsyncStoreListener(
|
||||||
asyncStore: context.read<FullPostStore>().fullPostState,
|
asyncStore: context.read<FullPostStore>().fullPostState,
|
||||||
child: AsyncStoreListener<BlockedCommunity>(
|
child: AsyncStoreListener<BlockedCommunity>(
|
||||||
|
|
Loading…
Reference in New Issue