✨ Post visibility hint
This commit is contained in:
parent
f16053c475
commit
45f489dcb6
@ -62,7 +62,8 @@ class _AttachmentListState extends State<AttachmentList> {
|
|||||||
'audio' => 16 / 9,
|
'audio' => 16 / 9,
|
||||||
'video' => 16 / 9,
|
'video' => 16 / 9,
|
||||||
_ => 1,
|
_ => 1,
|
||||||
};
|
}
|
||||||
|
.toDouble();
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
constraints: ResponsiveBreakpoints.of(context).largerThan(MOBILE)
|
constraints: ResponsiveBreakpoints.of(context).largerThan(MOBILE)
|
||||||
|
@ -17,6 +17,7 @@ import 'package:surface/widgets/dialog.dart';
|
|||||||
import 'package:surface/widgets/markdown_content.dart';
|
import 'package:surface/widgets/markdown_content.dart';
|
||||||
import 'package:gap/gap.dart';
|
import 'package:gap/gap.dart';
|
||||||
import 'package:surface/widgets/post/post_comment_list.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/post_reaction.dart';
|
||||||
import 'package:surface/widgets/post/publisher_popover.dart';
|
import 'package:surface/widgets/post/publisher_popover.dart';
|
||||||
|
|
||||||
@ -69,6 +70,11 @@ class PostItem extends StatelessWidget {
|
|||||||
_PostQuoteContent(child: data.repostTo!).padding(
|
_PostQuoteContent(child: data.repostTo!).padding(
|
||||||
horizontal: 12,
|
horizontal: 12,
|
||||||
),
|
),
|
||||||
|
if (data.visibility > 0)
|
||||||
|
_PostVisibilityHint(data: data).padding(
|
||||||
|
horizontal: 16,
|
||||||
|
vertical: 4,
|
||||||
|
),
|
||||||
if (data.body['content_truncated'] == true)
|
if (data.body['content_truncated'] == true)
|
||||||
_PostTruncatedHint(data: data).padding(
|
_PostTruncatedHint(data: data).padding(
|
||||||
horizontal: 16,
|
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 {
|
class _PostTruncatedHint extends StatelessWidget {
|
||||||
final SnPost data;
|
final SnPost data;
|
||||||
const _PostTruncatedHint({super.key, required this.data});
|
const _PostTruncatedHint({super.key, required this.data});
|
||||||
@ -495,9 +525,9 @@ class _PostTruncatedHint extends StatelessWidget {
|
|||||||
const Gap(4),
|
const Gap(4),
|
||||||
Text('postReadEstimate').tr(args: [
|
Text('postReadEstimate').tr(args: [
|
||||||
'${Duration(
|
'${Duration(
|
||||||
seconds: ((data.body['content_length'] as num).toDouble() /
|
seconds: (data.body['content_length'] as num).toDouble() *
|
||||||
kHumanReadSpeed)
|
60 ~/
|
||||||
.round(),
|
kHumanReadSpeed,
|
||||||
).inSeconds}s',
|
).inSeconds}s',
|
||||||
]),
|
]),
|
||||||
],
|
],
|
||||||
|
@ -9,18 +9,18 @@ import 'package:surface/controllers/post_write_controller.dart';
|
|||||||
import 'package:surface/widgets/account/account_select.dart';
|
import 'package:surface/widgets/account/account_select.dart';
|
||||||
import 'package:surface/widgets/post/post_tags_field.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 {
|
class PostMetaEditor extends StatelessWidget {
|
||||||
final PostWriteController controller;
|
final PostWriteController controller;
|
||||||
const PostMetaEditor({super.key, required this.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(
|
Future<DateTime?> _selectDate(
|
||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
DateTime? initialDateTime,
|
DateTime? initialDateTime,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user