2024-05-25 05:19:16 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
import 'package:solian/exts.dart';
|
|
|
|
import 'package:solian/models/post.dart';
|
2024-07-09 14:39:44 +00:00
|
|
|
import 'package:solian/providers/content/feed.dart';
|
2024-07-12 08:19:54 +00:00
|
|
|
import 'package:solian/widgets/sized_container.dart';
|
2024-05-25 05:19:16 +00:00
|
|
|
import 'package:solian/widgets/posts/post_item.dart';
|
2024-05-25 09:21:27 +00:00
|
|
|
import 'package:solian/widgets/posts/post_replies.dart';
|
2024-05-25 05:19:16 +00:00
|
|
|
|
|
|
|
class PostDetailScreen extends StatefulWidget {
|
|
|
|
final String alias;
|
|
|
|
|
|
|
|
const PostDetailScreen({super.key, required this.alias});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<PostDetailScreen> createState() => _PostDetailScreenState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _PostDetailScreenState extends State<PostDetailScreen> {
|
|
|
|
Post? item;
|
|
|
|
|
|
|
|
Future<Post?> getDetail() async {
|
2024-07-09 14:39:44 +00:00
|
|
|
final FeedProvider provider = Get.find();
|
2024-05-25 05:19:16 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
final resp = await provider.getPost(widget.alias);
|
|
|
|
item = Post.fromJson(resp.body);
|
|
|
|
} catch (e) {
|
|
|
|
context.showErrorDialog(e).then((_) => Navigator.pop(context));
|
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Material(
|
|
|
|
color: Theme.of(context).colorScheme.surface,
|
|
|
|
child: FutureBuilder(
|
|
|
|
future: getDetail(),
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
if (!snapshot.hasData || snapshot.data == null) {
|
|
|
|
return const Center(
|
|
|
|
child: CircularProgressIndicator(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-05-29 12:13:53 +00:00
|
|
|
return CustomScrollView(
|
|
|
|
slivers: [
|
|
|
|
SliverToBoxAdapter(
|
2024-07-06 13:14:19 +00:00
|
|
|
child: CenteredContainer(
|
|
|
|
child: PostItem(
|
|
|
|
item: item!,
|
|
|
|
isClickable: true,
|
|
|
|
isFullDate: true,
|
|
|
|
isShowReply: false,
|
|
|
|
),
|
2024-05-29 12:13:53 +00:00
|
|
|
),
|
2024-05-25 05:19:16 +00:00
|
|
|
),
|
2024-07-06 13:14:19 +00:00
|
|
|
SliverToBoxAdapter(
|
|
|
|
child: const Divider(thickness: 0.3, height: 1)
|
|
|
|
.paddingOnly(top: 4),
|
2024-05-25 09:21:27 +00:00
|
|
|
),
|
2024-05-29 12:13:53 +00:00
|
|
|
SliverToBoxAdapter(
|
2024-07-06 13:14:19 +00:00
|
|
|
child: CenteredContainer(
|
|
|
|
child: Align(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
'postReplies'.tr,
|
|
|
|
style: Theme.of(context).textTheme.headlineSmall,
|
|
|
|
).paddingOnly(left: 24, right: 24, top: 16),
|
|
|
|
),
|
|
|
|
),
|
2024-05-29 12:13:53 +00:00
|
|
|
),
|
|
|
|
PostReplyList(item: item!),
|
2024-06-06 13:07:11 +00:00
|
|
|
SliverToBoxAdapter(
|
|
|
|
child: SizedBox(height: MediaQuery.of(context).padding.bottom),
|
|
|
|
),
|
2024-05-25 05:19:16 +00:00
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|