✨ Basic post visibility
This commit is contained in:
parent
ac06d35c10
commit
06f2c9ecc2
@ -64,6 +64,13 @@
|
|||||||
"one": "{} character",
|
"one": "{} character",
|
||||||
"other": "{} characters"
|
"other": "{} characters"
|
||||||
},
|
},
|
||||||
|
"postVisibility": "Visibility",
|
||||||
|
"postVisibilityDescription": "Post visibility determines who can see this post.",
|
||||||
|
"postVisibilityAll": "Everyone",
|
||||||
|
"postVisibilityFriends": "Friends",
|
||||||
|
"postVisibilitySelected": "Selected User",
|
||||||
|
"postVisibilityFiltered": "Unselected User",
|
||||||
|
"postVisibilityNone": "Only Me",
|
||||||
"fieldUsername": "Username",
|
"fieldUsername": "Username",
|
||||||
"fieldNickname": "Nickname",
|
"fieldNickname": "Nickname",
|
||||||
"fieldEmail": "Email address",
|
"fieldEmail": "Email address",
|
||||||
|
@ -121,6 +121,13 @@
|
|||||||
"postPublish": "发布",
|
"postPublish": "发布",
|
||||||
"postPublishedAt": "发布于",
|
"postPublishedAt": "发布于",
|
||||||
"postPublishedUntil": "取消发布于",
|
"postPublishedUntil": "取消发布于",
|
||||||
|
"postVisibility": "可见性",
|
||||||
|
"postVisibilityDescription": "帖子可见性决定了谁能查看该篇帖子。",
|
||||||
|
"postVisibilityAll": "所有人可见",
|
||||||
|
"postVisibilityFriends": "仅限好友可见",
|
||||||
|
"postVisibilitySelected": "选定的用户可见",
|
||||||
|
"postVisibilityFiltered": "选定用户不可见",
|
||||||
|
"postVisibilityNone": "仅自己可见",
|
||||||
"postEditingNotice": "你正在修改由 {} 发布的帖子。",
|
"postEditingNotice": "你正在修改由 {} 发布的帖子。",
|
||||||
"postReplyingNotice": "你正在回复由 {} 发布的帖子。",
|
"postReplyingNotice": "你正在回复由 {} 发布的帖子。",
|
||||||
"postRepostingNotice": "你正在转发由 {} 发布的帖子。",
|
"postRepostingNotice": "你正在转发由 {} 发布的帖子。",
|
||||||
|
@ -172,6 +172,7 @@ class PostWriteController extends ChangeNotifier {
|
|||||||
SnPublisher? publisher;
|
SnPublisher? publisher;
|
||||||
SnPost? editingPost, repostingPost, replyingPost;
|
SnPost? editingPost, repostingPost, replyingPost;
|
||||||
|
|
||||||
|
int visibility = 0;
|
||||||
List<String> tags = List.empty();
|
List<String> tags = List.empty();
|
||||||
List<PostWriteMedia> attachments = List.empty(growable: true);
|
List<PostWriteMedia> attachments = List.empty(growable: true);
|
||||||
DateTime? publishedAt, publishedUntil;
|
DateTime? publishedAt, publishedUntil;
|
||||||
@ -196,6 +197,7 @@ class PostWriteController extends ChangeNotifier {
|
|||||||
contentController.text = post.body['content'] ?? '';
|
contentController.text = post.body['content'] ?? '';
|
||||||
publishedAt = post.publishedAt;
|
publishedAt = post.publishedAt;
|
||||||
publishedUntil = post.publishedUntil;
|
publishedUntil = post.publishedUntil;
|
||||||
|
visibility = post.visibility;
|
||||||
tags = List.from(post.tags.map((ele) => ele.alias));
|
tags = List.from(post.tags.map((ele) => ele.alias));
|
||||||
attachments.addAll(
|
attachments.addAll(
|
||||||
post.preload?.attachments?.map((ele) => PostWriteMedia(ele)) ?? [],
|
post.preload?.attachments?.map((ele) => PostWriteMedia(ele)) ?? [],
|
||||||
@ -293,6 +295,7 @@ class PostWriteController extends ChangeNotifier {
|
|||||||
.map((e) => e.attachment!.rid)
|
.map((e) => e.attachment!.rid)
|
||||||
.toList(),
|
.toList(),
|
||||||
'tags': tags.map((ele) => {'alias': ele}).toList(),
|
'tags': tags.map((ele) => {'alias': ele}).toList(),
|
||||||
|
'visibility': visibility,
|
||||||
if (publishedAt != null)
|
if (publishedAt != null)
|
||||||
'published_at': publishedAt!.toUtc().toIso8601String(),
|
'published_at': publishedAt!.toUtc().toIso8601String(),
|
||||||
if (publishedUntil != null)
|
if (publishedUntil != null)
|
||||||
@ -359,6 +362,11 @@ class PostWriteController extends ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setVisibility(int value) {
|
||||||
|
visibility = value;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
void setIsBusy(bool value) {
|
void setIsBusy(bool value) {
|
||||||
isBusy = value;
|
isBusy = value;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:dropdown_button2/dropdown_button2.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -11,6 +12,14 @@ 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,
|
||||||
@ -79,6 +88,45 @@ class PostMetaEditor extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
).padding(horizontal: 24),
|
).padding(horizontal: 24),
|
||||||
const Gap(12),
|
const Gap(12),
|
||||||
|
ListTile(
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
||||||
|
leading: const Icon(Symbols.visibility),
|
||||||
|
title: Text('postVisibility').tr(),
|
||||||
|
subtitle: Text('postVisibilityDescription').tr(),
|
||||||
|
trailing: SizedBox(
|
||||||
|
width: 180,
|
||||||
|
child: DropdownButtonHideUnderline(
|
||||||
|
child: DropdownButton2<int>(
|
||||||
|
isExpanded: true,
|
||||||
|
items: kPostVisibilityLevel.entries
|
||||||
|
.map(
|
||||||
|
(entry) => DropdownMenuItem<int>(
|
||||||
|
value: entry.key,
|
||||||
|
child: Text(
|
||||||
|
entry.value,
|
||||||
|
style: const TextStyle(fontSize: 14),
|
||||||
|
).tr(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
value: controller.visibility,
|
||||||
|
onChanged: (int? value) {
|
||||||
|
if (value != null) {
|
||||||
|
controller.setVisibility(value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
buttonStyleData: const ButtonStyleData(
|
||||||
|
height: 40,
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: 4,
|
||||||
|
vertical: 8,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
menuItemStyleData: const MenuItemStyleData(height: 40),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: const Icon(Symbols.event_available),
|
leading: const Icon(Symbols.event_available),
|
||||||
title: Text('postPublishedAt').tr(),
|
title: Text('postPublishedAt').tr(),
|
||||||
|
Loading…
Reference in New Issue
Block a user