mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-30 23:58:13 +08:00
mod: add reply: data cast
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -106,6 +106,7 @@ class NetworkImgLayer extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget placeholder(BuildContext context) {
|
Widget placeholder(BuildContext context) {
|
||||||
|
int cacheWidth = width.cacheSize(context);
|
||||||
return Container(
|
return Container(
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
@@ -127,7 +128,7 @@ class NetworkImgLayer extends StatelessWidget {
|
|||||||
: 'assets/images/loading.png',
|
: 'assets/images/loading.png',
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
cacheWidth: width.cacheSize(context),
|
cacheWidth: cacheWidth == 0 ? null : cacheWidth,
|
||||||
// cacheHeight: height.cacheSize(context),
|
// cacheHeight: height.cacheSize(context),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:PiliPalaX/models/common/reply_type.dart';
|
|||||||
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
||||||
import 'package:PiliPalaX/pages/video/detail/reply_new/reply_page.dart';
|
import 'package:PiliPalaX/pages/video/detail/reply_new/reply_page.dart';
|
||||||
import 'package:PiliPalaX/utils/extension.dart';
|
import 'package:PiliPalaX/utils/extension.dart';
|
||||||
|
import 'package:PiliPalaX/utils/utils.dart';
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -155,20 +156,18 @@ abstract class ReplyController extends CommonController {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
(value) {
|
(res) {
|
||||||
// TODO: data cast
|
if (res != null) {
|
||||||
if (value != null && value['data'] != null) {
|
|
||||||
savedReplies[key] = null;
|
savedReplies[key] = null;
|
||||||
if (value['data'] is ReplyInfo) {
|
ReplyInfo replyInfo = Utils.replyCast(res);
|
||||||
MainListReply response =
|
MainListReply response =
|
||||||
(loadingState.value as Success?)?.response ?? MainListReply();
|
(loadingState.value as Success?)?.response ?? MainListReply();
|
||||||
if (oid != null) {
|
if (oid != null) {
|
||||||
response.replies.insert(0, value['data']);
|
response.replies.insert(0, replyInfo);
|
||||||
} else {
|
} else {
|
||||||
response.replies[index].replies.add(value['data']);
|
response.replies[index].replies.add(replyInfo);
|
||||||
}
|
|
||||||
loadingState.value = LoadingState.success(response);
|
|
||||||
}
|
}
|
||||||
|
loadingState.value = LoadingState.success(response);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import 'package:get/get.dart';
|
|||||||
import 'package:PiliPalaX/http/video.dart';
|
import 'package:PiliPalaX/http/video.dart';
|
||||||
import 'package:PiliPalaX/models/common/reply_type.dart';
|
import 'package:PiliPalaX/models/common/reply_type.dart';
|
||||||
import 'package:PiliPalaX/models/video/reply/emote.dart';
|
import 'package:PiliPalaX/models/video/reply/emote.dart';
|
||||||
import 'package:PiliPalaX/models/video/reply/item.dart';
|
|
||||||
import 'package:PiliPalaX/pages/emote/index.dart';
|
import 'package:PiliPalaX/pages/emote/index.dart';
|
||||||
import 'package:PiliPalaX/utils/feed_back.dart';
|
import 'package:PiliPalaX/utils/feed_back.dart';
|
||||||
import 'package:PiliPalaX/pages/emote/view.dart';
|
import 'package:PiliPalaX/pages/emote/view.dart';
|
||||||
@@ -517,9 +516,7 @@ class _ReplyPageState extends State<ReplyPage>
|
|||||||
);
|
);
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
SmartDialog.showToast(result['data']['success_toast']);
|
SmartDialog.showToast(result['data']['success_toast']);
|
||||||
Get.back(result: {
|
Get.back(result: result['data']['reply']);
|
||||||
'data': ReplyItemModel.fromJson(result['data']['reply'], ''),
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast(result['msg']);
|
SmartDialog.showToast(result['msg']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:PiliPalaX/grpc/app/main/community/reply/v1/reply.pb.dart';
|
|||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
import 'package:PiliPalaX/pages/video/detail/reply/widgets/reply_item_grpc.dart';
|
import 'package:PiliPalaX/pages/video/detail/reply/widgets/reply_item_grpc.dart';
|
||||||
import 'package:PiliPalaX/pages/video/detail/reply_new/reply_page.dart';
|
import 'package:PiliPalaX/pages/video/detail/reply_new/reply_page.dart';
|
||||||
|
import 'package:PiliPalaX/utils/utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPalaX/common/skeleton/video_reply.dart';
|
import 'package:PiliPalaX/common/skeleton/video_reply.dart';
|
||||||
@@ -158,7 +159,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
replyType: widget.replyType,
|
replyType: widget.replyType,
|
||||||
needDivider: false,
|
needDivider: false,
|
||||||
onReply: () {
|
onReply: () {
|
||||||
_onReply(firstFloor!);
|
_onReply(firstFloor!, -1);
|
||||||
},
|
},
|
||||||
upMid: _videoReplyReplyController.upMid,
|
upMid: _videoReplyReplyController.upMid,
|
||||||
);
|
);
|
||||||
@@ -237,7 +238,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
void _onReply(ReplyInfo? item) {
|
void _onReply(ReplyInfo? item, int index) {
|
||||||
dynamic oid = item?.oid.toInt();
|
dynamic oid = item?.oid.toInt();
|
||||||
dynamic root = item?.id.toInt();
|
dynamic root = item?.id.toInt();
|
||||||
dynamic parent = item?.id.toInt();
|
dynamic parent = item?.id.toInt();
|
||||||
@@ -274,20 +275,16 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.then((value) {
|
.then((res) {
|
||||||
// 完成评论,数据添加 // TODO: data cast
|
if (res != null) {
|
||||||
if (value != null && value['data'] != null) {
|
|
||||||
_savedReplies[key] = null;
|
_savedReplies[key] = null;
|
||||||
if (value['data'] is ReplyInfo) {
|
ReplyInfo replyInfo = Utils.replyCast(res);
|
||||||
List<ReplyInfo> list =
|
List list = (_videoReplyReplyController.loadingState.value as Success?)
|
||||||
_videoReplyReplyController.loadingState.value is Success
|
?.response ??
|
||||||
? (_videoReplyReplyController.loadingState.value as Success)
|
<ReplyInfo>[];
|
||||||
.response
|
list.insert(index + 1, replyInfo);
|
||||||
: <ReplyInfo>[];
|
_videoReplyReplyController.loadingState.value =
|
||||||
list.add(value['data']);
|
LoadingState.success(list);
|
||||||
_videoReplyReplyController.loadingState.value =
|
|
||||||
LoadingState.success(list);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -320,11 +317,11 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
return ColoredBox(
|
return ColoredBox(
|
||||||
color: _videoReplyReplyController.colorAnimation?.value ??
|
color: _videoReplyReplyController.colorAnimation?.value ??
|
||||||
Theme.of(Get.context!).colorScheme.onInverseSurface,
|
Theme.of(Get.context!).colorScheme.onInverseSurface,
|
||||||
child: _replyItem(loadingState.response[index]),
|
child: _replyItem(loadingState.response[index], index),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
: _replyItem(loadingState.response[index]);
|
: _replyItem(loadingState.response[index], index);
|
||||||
}
|
}
|
||||||
} else if (loadingState is Error) {
|
} else if (loadingState is Error) {
|
||||||
return CustomScrollView(
|
return CustomScrollView(
|
||||||
@@ -355,14 +352,14 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _replyItem(replyItem) {
|
Widget _replyItem(replyItem, index) {
|
||||||
return ReplyItemGrpc(
|
return ReplyItemGrpc(
|
||||||
replyItem: replyItem,
|
replyItem: replyItem,
|
||||||
replyLevel: widget.isDialogue ? '3' : '2',
|
replyLevel: widget.isDialogue ? '3' : '2',
|
||||||
showReplyRow: false,
|
showReplyRow: false,
|
||||||
replyType: widget.replyType,
|
replyType: widget.replyType,
|
||||||
onReply: () {
|
onReply: () {
|
||||||
_onReply(replyItem);
|
_onReply(replyItem, index);
|
||||||
},
|
},
|
||||||
onDelete: (rpid, frpid) {
|
onDelete: (rpid, frpid) {
|
||||||
List list =
|
List list =
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'dart:async';
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
import 'package:PiliPalaX/grpc/app/main/community/reply/v1/reply.pb.dart';
|
||||||
import 'package:PiliPalaX/http/member.dart';
|
import 'package:PiliPalaX/http/member.dart';
|
||||||
import 'package:PiliPalaX/http/search.dart';
|
import 'package:PiliPalaX/http/search.dart';
|
||||||
import 'package:PiliPalaX/http/video.dart';
|
import 'package:PiliPalaX/http/video.dart';
|
||||||
@@ -25,6 +26,27 @@ import 'package:url_launcher/url_launcher.dart';
|
|||||||
class Utils {
|
class Utils {
|
||||||
static final Random random = Random();
|
static final Random random = Random();
|
||||||
|
|
||||||
|
static ReplyInfo replyCast(res) {
|
||||||
|
Map emote = res['content']['emote'];
|
||||||
|
emote.forEach((key, value) {
|
||||||
|
value['size'] = value['meta']['size'];
|
||||||
|
});
|
||||||
|
return ReplyInfo.create()
|
||||||
|
..mergeFromProto3Json(
|
||||||
|
res
|
||||||
|
..['id'] = res['rpid']
|
||||||
|
..['member']['name'] = res['member']['uname']
|
||||||
|
..['member']['face'] = res['member']['avatar']
|
||||||
|
..['member']['level'] = res['member']['level_info']['current_level']
|
||||||
|
..['member']['vipStatus'] = res['member']['vip']['vipStatus']
|
||||||
|
..['member']['vipType'] = res['member']['vip']['vipType']
|
||||||
|
..['member']['officialVerifyType'] =
|
||||||
|
res['member']['official_verify']['type']
|
||||||
|
..['content']['emote'] = emote,
|
||||||
|
ignoreUnknownFields: true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
static bool isDefault(int attr) {
|
static bool isDefault(int attr) {
|
||||||
return (attr & 2) == 0;
|
return (attr & 2) == 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user