Post visibility hint

This commit is contained in:
LittleSheep 2024-12-06 00:21:48 +08:00
parent f16053c475
commit 45f489dcb6
3 changed files with 43 additions and 12 deletions

View File

@ -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)

View File

@ -17,6 +17,7 @@ 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 +70,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,
@ -478,6 +484,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 +525,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',
]),
],

View File

@ -9,18 +9,18 @@ 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';
const Map<int, String> kPostVisibilityLevel = {
0: 'postVisibilityAll',
1: 'postVisibilityFriends',
2: 'postVisibilitySelected',
3: 'postVisibilityFiltered',
4: 'postVisibilityNone',
};
class PostMetaEditor extends StatelessWidget {
final PostWriteController controller;
const PostMetaEditor({super.key, required this.controller});
static Map<int, String> kPostVisibilityLevel = {
0: 'postVisibilityAll',
1: 'postVisibilityFriends',
2: 'postVisibilitySelected',
3: 'postVisibilityFiltered',
4: 'postVisibilityNone',
};
Future<DateTime?> _selectDate(
BuildContext context, {
DateTime? initialDateTime,