opt: reply panel

This commit is contained in:
bggRGjQaUbCoE
2024-10-14 08:49:11 +08:00
parent e24f214051
commit e4ae8961e4
3 changed files with 50 additions and 43 deletions

View File

@@ -156,16 +156,18 @@ abstract class ReplyController extends CommonController {
.then( .then(
(value) { (value) {
// TODO: data cast // TODO: data cast
if (value != null && value['data'] is ReplyInfo) { if (value != null && value['data'] != null) {
savedReplies[key] = null; savedReplies[key] = null;
MainListReply response = if (value['data'] is ReplyInfo) {
(loadingState.value as Success?)?.response ?? MainListReply(); MainListReply response =
if (oid != null) { (loadingState.value as Success?)?.response ?? MainListReply();
response.replies.insert(0, value['data']); if (oid != null) {
} else { response.replies.insert(0, value['data']);
response.replies[index].replies.add(value['data']); } else {
response.replies[index].replies.add(value['data']);
}
loadingState.value = LoadingState.success(response);
} }
loadingState.value = LoadingState.success(response);
} }
}, },
); );

View File

@@ -349,35 +349,38 @@ class _ReplyPageState extends State<ReplyPage>
selected: !snapshot.data!, selected: !snapshot.data!,
), ),
), ),
const SizedBox(width: 20), if (widget.root == 0) ...[
ToolbarIconButton( const SizedBox(width: 20),
tooltip: '图片', ToolbarIconButton(
selected: false, tooltip: '图片',
icon: const Icon(Icons.image, size: 22), selected: false,
onPressed: () async { icon: const Icon(Icons.image, size: 22),
List<XFile> pickedFiles = await _imagePicker.pickMultiImage( onPressed: () async {
limit: 9, List<XFile> pickedFiles =
imageQuality: 100, await _imagePicker.pickMultiImage(
); limit: 9,
if (pickedFiles.isNotEmpty) { imageQuality: 100,
for (int i = 0; i < pickedFiles.length; i++) { );
if (_pathList.length == 9) { if (pickedFiles.isNotEmpty) {
SmartDialog.showToast('最多选择9张图片'); for (int i = 0; i < pickedFiles.length; i++) {
if (i != 0) { if (_pathList.length == 9) {
_pathStream.add(_pathList); SmartDialog.showToast('最多选择9张图片');
} if (i != 0) {
break; _pathStream.add(_pathList);
} else { }
_pathList.add(pickedFiles[i].path); break;
if (i == pickedFiles.length - 1) { } else {
SmartDialog.dismiss(); _pathList.add(pickedFiles[i].path);
_pathStream.add(_pathList); if (i == pickedFiles.length - 1) {
SmartDialog.dismiss();
_pathStream.add(_pathList);
}
} }
} }
} }
} },
}, ),
), ],
const Spacer(), const Spacer(),
StreamBuilder( StreamBuilder(
initialData: _enablePublish, initialData: _enablePublish,

View File

@@ -255,16 +255,18 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
) )
.then((value) { .then((value) {
// 完成评论,数据添加 // TODO: data cast // 完成评论,数据添加 // TODO: data cast
if (value != null && value['data'] is ReplyInfo) { if (value != null && value['data'] != null) {
_savedReplies[key] = null; _savedReplies[key] = null;
List<ReplyInfo> list = if (value['data'] is ReplyInfo) {
_videoReplyReplyController.loadingState.value is Success List<ReplyInfo> list =
? (_videoReplyReplyController.loadingState.value as Success) _videoReplyReplyController.loadingState.value is Success
.response ? (_videoReplyReplyController.loadingState.value as Success)
: <ReplyInfo>[]; .response
list.add(value['data']); : <ReplyInfo>[];
_videoReplyReplyController.loadingState.value = list.add(value['data']);
LoadingState.success(list); _videoReplyReplyController.loadingState.value =
LoadingState.success(list);
}
} }
}); });
} }