Compare commits
2 Commits
f16053c475
...
599dd4827b
Author | SHA1 | Date | |
---|---|---|---|
599dd4827b | |||
45f489dcb6 |
@ -62,7 +62,8 @@ class _AttachmentListState extends State<AttachmentList> {
|
||||
'audio' => 16 / 9,
|
||||
'video' => 16 / 9,
|
||||
_ => 1,
|
||||
};
|
||||
}
|
||||
.toDouble();
|
||||
|
||||
return Container(
|
||||
constraints: ResponsiveBreakpoints.of(context).largerThan(MOBILE)
|
||||
|
@ -11,12 +11,14 @@ import 'package:styled_widget/styled_widget.dart';
|
||||
import 'package:surface/providers/sn_network.dart';
|
||||
import 'package:surface/providers/userinfo.dart';
|
||||
import 'package:surface/types/post.dart';
|
||||
import 'package:surface/types/reaction.dart';
|
||||
import 'package:surface/widgets/account/account_image.dart';
|
||||
import 'package:surface/widgets/attachment/attachment_list.dart';
|
||||
import 'package:surface/widgets/dialog.dart';
|
||||
import 'package:surface/widgets/markdown_content.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:surface/widgets/post/post_comment_list.dart';
|
||||
import 'package:surface/widgets/post/post_meta_editor.dart';
|
||||
import 'package:surface/widgets/post/post_reaction.dart';
|
||||
import 'package:surface/widgets/post/publisher_popover.dart';
|
||||
|
||||
@ -69,6 +71,11 @@ class PostItem extends StatelessWidget {
|
||||
_PostQuoteContent(child: data.repostTo!).padding(
|
||||
horizontal: 12,
|
||||
),
|
||||
if (data.visibility > 0)
|
||||
_PostVisibilityHint(data: data).padding(
|
||||
horizontal: 16,
|
||||
vertical: 4,
|
||||
),
|
||||
if (data.body['content_truncated'] == true)
|
||||
_PostTruncatedHint(data: data).padding(
|
||||
horizontal: 16,
|
||||
@ -121,6 +128,13 @@ class _PostBottomAction extends StatelessWidget {
|
||||
final iconColor = Theme.of(context).colorScheme.onSurface.withAlpha(
|
||||
(255 * 0.8).round(),
|
||||
);
|
||||
|
||||
final String? mostTypicalReaction = data.metric.reactionList.isNotEmpty
|
||||
? data.metric.reactionList.entries
|
||||
.reduce((a, b) => a.value > b.value ? a : b)
|
||||
.key
|
||||
: null;
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@ -131,7 +145,18 @@ class _PostBottomAction extends StatelessWidget {
|
||||
InkWell(
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Symbols.add_reaction, size: 20, color: iconColor),
|
||||
if (mostTypicalReaction == null ||
|
||||
kTemplateReactions[mostTypicalReaction] == null)
|
||||
Icon(Symbols.add_reaction, size: 20, color: iconColor)
|
||||
else
|
||||
Text(
|
||||
kTemplateReactions[mostTypicalReaction]!.icon,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
height: 1.2,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
const Gap(8),
|
||||
if (data.totalUpvote > 0 &&
|
||||
data.totalUpvote >= data.totalDownvote)
|
||||
@ -478,6 +503,30 @@ class _PostTagsList extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class _PostVisibilityHint extends StatelessWidget {
|
||||
final SnPost data;
|
||||
const _PostVisibilityHint({super.key, required this.data});
|
||||
|
||||
static const List<IconData> kVisibilityIcons = [
|
||||
Symbols.public,
|
||||
Symbols.group,
|
||||
Symbols.person_check,
|
||||
Symbols.person_remove,
|
||||
Symbols.lock,
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Icon(kVisibilityIcons[data.visibility], size: 20),
|
||||
const Gap(4),
|
||||
Text(kPostVisibilityLevel[data.visibility] ?? 'postVisibilityAll').tr(),
|
||||
],
|
||||
).opacity(0.75);
|
||||
}
|
||||
}
|
||||
|
||||
class _PostTruncatedHint extends StatelessWidget {
|
||||
final SnPost data;
|
||||
const _PostTruncatedHint({super.key, required this.data});
|
||||
@ -495,9 +544,9 @@ class _PostTruncatedHint extends StatelessWidget {
|
||||
const Gap(4),
|
||||
Text('postReadEstimate').tr(args: [
|
||||
'${Duration(
|
||||
seconds: ((data.body['content_length'] as num).toDouble() /
|
||||
kHumanReadSpeed)
|
||||
.round(),
|
||||
seconds: (data.body['content_length'] as num).toDouble() *
|
||||
60 ~/
|
||||
kHumanReadSpeed,
|
||||
).inSeconds}s',
|
||||
]),
|
||||
],
|
||||
|
@ -9,11 +9,7 @@ import 'package:surface/controllers/post_write_controller.dart';
|
||||
import 'package:surface/widgets/account/account_select.dart';
|
||||
import 'package:surface/widgets/post/post_tags_field.dart';
|
||||
|
||||
class PostMetaEditor extends StatelessWidget {
|
||||
final PostWriteController controller;
|
||||
const PostMetaEditor({super.key, required this.controller});
|
||||
|
||||
static Map<int, String> kPostVisibilityLevel = {
|
||||
const Map<int, String> kPostVisibilityLevel = {
|
||||
0: 'postVisibilityAll',
|
||||
1: 'postVisibilityFriends',
|
||||
2: 'postVisibilitySelected',
|
||||
@ -21,6 +17,10 @@ class PostMetaEditor extends StatelessWidget {
|
||||
4: 'postVisibilityNone',
|
||||
};
|
||||
|
||||
class PostMetaEditor extends StatelessWidget {
|
||||
final PostWriteController controller;
|
||||
const PostMetaEditor({super.key, required this.controller});
|
||||
|
||||
Future<DateTime?> _selectDate(
|
||||
BuildContext context, {
|
||||
DateTime? initialDateTime,
|
||||
|
Loading…
x
Reference in New Issue
Block a user