2021-09-11 01:04:15 +02:00
|
|
|
import 'package:flutter/gestures.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import '../../l10n/l10n.dart';
|
2021-11-25 18:12:36 +01:00
|
|
|
import '../../pages/community/community.dart';
|
2022-01-20 11:50:24 +01:00
|
|
|
import '../../pages/instance/instance.dart';
|
2021-09-11 01:04:15 +02:00
|
|
|
import '../../util/extensions/api.dart';
|
|
|
|
import '../../util/goto.dart';
|
|
|
|
import '../../util/observer_consumers.dart';
|
|
|
|
import '../avatar.dart';
|
|
|
|
import 'post_more_menu.dart';
|
|
|
|
import 'post_status.dart';
|
|
|
|
import 'post_store.dart';
|
|
|
|
|
2021-10-19 01:30:30 +02:00
|
|
|
class PostInfoSection extends StatelessWidget {
|
2021-09-11 01:04:15 +02:00
|
|
|
const PostInfoSection();
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ObserverBuilder<PostStore>(builder: (context, store) {
|
|
|
|
final fullPost = context.read<IsFullPost>();
|
|
|
|
final post = store.postView;
|
|
|
|
final instanceHost = store.postView.instanceHost;
|
|
|
|
final theme = Theme.of(context);
|
|
|
|
|
2021-11-03 22:50:03 +01:00
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.all(10),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Avatar(
|
|
|
|
url: post.community.icon,
|
|
|
|
padding: const EdgeInsets.only(right: 10),
|
2021-11-25 18:12:36 +01:00
|
|
|
onTap: () => Navigator.of(context).push(
|
|
|
|
CommunityPage.fromIdRoute(instanceHost, post.community.id)),
|
2021-11-03 22:50:03 +01:00
|
|
|
noBlank: true,
|
|
|
|
radius: 20,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
RichText(
|
|
|
|
overflow: TextOverflow.fade,
|
|
|
|
softWrap: false,
|
|
|
|
text: TextSpan(
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 15,
|
|
|
|
color: theme.textTheme.bodyText1?.color,
|
2021-09-11 01:04:15 +02:00
|
|
|
),
|
2021-11-03 22:50:03 +01:00
|
|
|
children: [
|
|
|
|
const TextSpan(
|
|
|
|
text: '!',
|
|
|
|
style: TextStyle(fontWeight: FontWeight.w300),
|
|
|
|
),
|
|
|
|
TextSpan(
|
|
|
|
text: post.community.name,
|
|
|
|
style: const TextStyle(fontWeight: FontWeight.w600),
|
|
|
|
recognizer: TapGestureRecognizer()
|
2021-11-25 18:12:36 +01:00
|
|
|
..onTap = () => Navigator.of(context).push(
|
|
|
|
CommunityPage.fromIdRoute(
|
|
|
|
instanceHost, post.community.id)),
|
2021-11-03 22:50:03 +01:00
|
|
|
),
|
|
|
|
const TextSpan(
|
|
|
|
text: '@',
|
|
|
|
style: TextStyle(fontWeight: FontWeight.w300),
|
|
|
|
),
|
|
|
|
TextSpan(
|
|
|
|
text: post.post.originInstanceHost,
|
|
|
|
style: const TextStyle(fontWeight: FontWeight.w600),
|
|
|
|
recognizer: TapGestureRecognizer()
|
2022-01-20 11:50:24 +01:00
|
|
|
..onTap = () => Navigator.of(context).push(
|
|
|
|
InstancePage.route(
|
|
|
|
post.post.originInstanceHost,
|
|
|
|
),
|
2021-11-03 22:50:03 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2021-10-19 01:30:30 +02:00
|
|
|
),
|
|
|
|
),
|
2021-11-03 22:50:03 +01:00
|
|
|
RichText(
|
|
|
|
overflow: TextOverflow.fade,
|
|
|
|
softWrap: false,
|
|
|
|
text: TextSpan(
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 13,
|
|
|
|
color: theme.textTheme.bodyText1?.color,
|
2021-10-19 01:30:30 +02:00
|
|
|
),
|
2021-11-03 22:50:03 +01:00
|
|
|
children: [
|
|
|
|
TextSpan(
|
2021-11-05 21:37:27 +01:00
|
|
|
text: L10n.of(context).by,
|
2021-11-03 22:50:03 +01:00
|
|
|
style: const TextStyle(fontWeight: FontWeight.w300),
|
|
|
|
),
|
|
|
|
TextSpan(
|
|
|
|
text: ' ${post.creator.originPreferredName}',
|
|
|
|
style: const TextStyle(fontWeight: FontWeight.w600),
|
|
|
|
recognizer: TapGestureRecognizer()
|
|
|
|
..onTap = () => goToUser.fromPersonSafe(
|
|
|
|
context,
|
|
|
|
post.creator,
|
|
|
|
),
|
|
|
|
),
|
2021-11-16 17:06:07 +01:00
|
|
|
TextSpan(
|
|
|
|
text:
|
|
|
|
' · ${post.post.published.timeagoShort(context)}',
|
|
|
|
),
|
2021-11-03 22:50:03 +01:00
|
|
|
if (post.post.locked) const TextSpan(text: ' · 🔒'),
|
|
|
|
if (post.post.stickied) const TextSpan(text: ' · 📌'),
|
|
|
|
if (post.post.nsfw) const TextSpan(text: ' · '),
|
|
|
|
if (post.post.nsfw)
|
2021-10-19 01:30:30 +02:00
|
|
|
TextSpan(
|
2021-11-05 21:37:27 +01:00
|
|
|
text: L10n.of(context).nsfw,
|
2021-11-03 22:50:03 +01:00
|
|
|
style: const TextStyle(color: Colors.red),
|
2021-09-11 01:04:15 +02:00
|
|
|
),
|
2021-11-03 22:50:03 +01:00
|
|
|
if (store.urlDomain != null)
|
|
|
|
TextSpan(text: ' · ${store.urlDomain}'),
|
|
|
|
if (post.post.removed)
|
|
|
|
const TextSpan(text: ' · REMOVED'),
|
|
|
|
if (post.post.deleted)
|
|
|
|
const TextSpan(text: ' · DELETED'),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
2021-09-11 01:04:15 +02:00
|
|
|
),
|
2021-11-03 22:50:03 +01:00
|
|
|
if (!fullPost) const PostMoreMenuButton(),
|
|
|
|
],
|
|
|
|
),
|
2021-09-11 01:04:15 +02:00
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|