2019-11-02 11:46:17 +00:00
|
|
|
import 'package:comunic/helpers/posts_helper.dart';
|
|
|
|
import 'package:comunic/lists/posts_list.dart';
|
|
|
|
import 'package:comunic/ui/widgets/posts_list_widget.dart';
|
|
|
|
import 'package:comunic/utils/intl_utils.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
/// Single post route
|
|
|
|
///
|
|
|
|
/// @author Pierre HUBERT
|
|
|
|
|
|
|
|
class SinglePostRoute extends StatelessWidget {
|
|
|
|
final int postID;
|
|
|
|
|
|
|
|
const SinglePostRoute({
|
2022-03-10 18:39:57 +00:00
|
|
|
Key? key,
|
|
|
|
required this.postID,
|
2022-03-11 16:02:06 +00:00
|
|
|
}) : super(key: key);
|
2019-11-02 11:46:17 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
2022-03-10 18:39:57 +00:00
|
|
|
title: Text(tr("Post")!),
|
2019-11-02 11:46:17 +00:00
|
|
|
),
|
|
|
|
body: _SinglePostRouteBody(postID: postID),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _SinglePostRouteBody extends StatefulWidget {
|
|
|
|
final int postID;
|
|
|
|
|
|
|
|
const _SinglePostRouteBody({
|
2022-03-10 18:39:57 +00:00
|
|
|
Key? key,
|
|
|
|
required this.postID,
|
2022-03-11 16:02:06 +00:00
|
|
|
}) : super(key: key);
|
2019-11-02 11:46:17 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
__SinglePostRouteBodyState createState() => __SinglePostRouteBodyState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class __SinglePostRouteBodyState extends State<_SinglePostRouteBody> {
|
2022-03-10 18:39:57 +00:00
|
|
|
Future<PostsList?> _getPost() async {
|
2019-11-02 11:46:17 +00:00
|
|
|
try {
|
|
|
|
return PostsList()..add(await PostsHelper().getSingle(widget.postID));
|
|
|
|
} on Exception catch (e) {
|
|
|
|
print(e);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return PostsListWidget(
|
|
|
|
getPostsList: _getPost,
|
|
|
|
showPostsTarget: true,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|