lemmur-app-android/lib/widgets/post/post_info_section.dart

133 lines
5.2 KiB
Dart
Raw Normal View History

2021-09-11 01:04:15 +02:00
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import '../../l10n/l10n.dart';
import '../../pages/community/community.dart';
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';
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);
return Padding(
padding: const EdgeInsets.all(10),
child: Row(
children: [
Avatar(
url: post.community.icon,
padding: const EdgeInsets.only(right: 10),
onTap: () => Navigator.of(context).push(
CommunityPage.fromIdRoute(instanceHost, post.community.id)),
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
),
children: [
const TextSpan(
text: '!',
style: TextStyle(fontWeight: FontWeight.w300),
),
TextSpan(
text: post.community.name,
style: const TextStyle(fontWeight: FontWeight.w600),
recognizer: TapGestureRecognizer()
..onTap = () => Navigator.of(context).push(
CommunityPage.fromIdRoute(
instanceHost, post.community.id)),
),
const TextSpan(
text: '@',
style: TextStyle(fontWeight: FontWeight.w300),
),
TextSpan(
text: post.post.originInstanceHost,
style: const TextStyle(fontWeight: FontWeight.w600),
recognizer: TapGestureRecognizer()
..onTap = () => Navigator.of(context).push(
InstancePage.route(
post.post.originInstanceHost,
),
),
),
],
),
),
RichText(
overflow: TextOverflow.fade,
softWrap: false,
text: TextSpan(
style: TextStyle(
fontSize: 13,
color: theme.textTheme.bodyText1?.color,
),
children: [
TextSpan(
text: L10n.of(context).by,
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,
),
),
TextSpan(
text:
' · ${post.post.published.timeagoShort(context)}',
),
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)
TextSpan(
text: L10n.of(context).nsfw,
style: const TextStyle(color: Colors.red),
2021-09-11 01:04:15 +02: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
),
if (!fullPost) const PostMoreMenuButton(),
],
),
2021-09-11 01:04:15 +02:00
);
});
}
}