mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
check uploadPictureIconState
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import 'package:PiliPlus/common/widgets/text_field/controller.dart';
|
||||
import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart'
|
||||
show MainListReply, ReplyInfo, SubjectControl, Mode;
|
||||
show MainListReply, ReplyInfo, SubjectControl, Mode, EditorIconState;
|
||||
import 'package:PiliPlus/grpc/bilibili/pagination.pb.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/reply.dart';
|
||||
@@ -101,8 +101,11 @@ abstract class ReplyController<R> extends CommonListController<R, ReplyInfo> {
|
||||
onReload();
|
||||
}
|
||||
|
||||
(bool inputDisable, String? hint) get replyHint {
|
||||
(bool inputDisable, bool canUploadPic, String? hint) get replyHint {
|
||||
bool inputDisable = false;
|
||||
bool canUploadPic =
|
||||
subjectControl?.uploadPictureIconState !=
|
||||
EditorIconState.EditorIconState_DISABLE;
|
||||
String? hint;
|
||||
try {
|
||||
if (subjectControl != null && subjectControl!.hasRootText()) {
|
||||
@@ -116,7 +119,7 @@ abstract class ReplyController<R> extends CommonListController<R, ReplyInfo> {
|
||||
}
|
||||
}
|
||||
} catch (_) {}
|
||||
return (inputDisable, hint);
|
||||
return (inputDisable, canUploadPic, hint);
|
||||
}
|
||||
|
||||
void onReply(
|
||||
@@ -135,7 +138,7 @@ abstract class ReplyController<R> extends CommonListController<R, ReplyInfo> {
|
||||
|
||||
assert(replyItem != null || (oid != null && replyType != null));
|
||||
|
||||
final (bool inputDisable, String? hint) = replyHint;
|
||||
final (bool inputDisable, bool canUploadPic, String? hint) = replyHint;
|
||||
if (inputDisable) {
|
||||
return;
|
||||
}
|
||||
@@ -153,6 +156,7 @@ abstract class ReplyController<R> extends CommonListController<R, ReplyInfo> {
|
||||
replyType: replyItem?.type.toInt() ?? replyType!,
|
||||
replyItem: replyItem,
|
||||
items: savedReplies[key],
|
||||
canUploadPic: canUploadPic,
|
||||
onSave: (reply) {
|
||||
if (reply.isEmpty) {
|
||||
savedReplies.remove(key);
|
||||
|
||||
@@ -33,6 +33,7 @@ class ReplyPage extends CommonRichTextPubPage {
|
||||
final int replyType;
|
||||
final ReplyInfo? replyItem;
|
||||
final String? hint;
|
||||
final bool canUploadPic;
|
||||
|
||||
const ReplyPage({
|
||||
super.key,
|
||||
@@ -45,6 +46,7 @@ class ReplyPage extends CommonRichTextPubPage {
|
||||
required this.replyType,
|
||||
this.replyItem,
|
||||
this.hint,
|
||||
this.canUploadPic = true,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -183,8 +185,12 @@ class _ReplyPageState extends CommonRichTextPubPageState<ReplyPage> {
|
||||
ToolbarIconButton(
|
||||
tooltip: '图片',
|
||||
selected: false,
|
||||
icon: const Icon(Icons.image, size: 22),
|
||||
onPressed: onPickImage,
|
||||
icon: widget.canUploadPic
|
||||
? const Icon(Icons.image, size: 22)
|
||||
: const Icon(Icons.image_not_supported, size: 22),
|
||||
onPressed: widget.canUploadPic
|
||||
? onPickImage
|
||||
: () => SmartDialog.showToast('当前评论区不支持发送图片'),
|
||||
),
|
||||
],
|
||||
const SizedBox(width: 8),
|
||||
|
||||
@@ -166,7 +166,7 @@ class VideoReplyReplyController extends ReplyController
|
||||
}) {
|
||||
assert(replyItem != null && index != null);
|
||||
|
||||
final (bool inputDisable, String? hint) = replyHint;
|
||||
final (bool inputDisable, bool canUploadPic, String? hint) = replyHint;
|
||||
if (inputDisable) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user