mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: custom grpc reply (#25)
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -70,7 +70,7 @@ class ReplyHttp {
|
|||||||
|
|
||||||
static Future<LoadingState> replyReplyList({
|
static Future<LoadingState> replyReplyList({
|
||||||
required int oid,
|
required int oid,
|
||||||
required String root,
|
required int root,
|
||||||
required int pageNum,
|
required int pageNum,
|
||||||
required int type,
|
required int type,
|
||||||
int sort = 1,
|
int sort = 1,
|
||||||
|
|||||||
@@ -111,11 +111,16 @@ class BlackListController extends CommonController {
|
|||||||
@override
|
@override
|
||||||
bool customHandleResponse(Success response) {
|
bool customHandleResponse(Success response) {
|
||||||
total.value = response.response.total;
|
total.value = response.response.total;
|
||||||
isEnd = response.response.list.isEmpty;
|
if (response.response.list.isEmpty) {
|
||||||
|
isEnd = true;
|
||||||
|
}
|
||||||
if (currentPage != 1 && loadingState.value is Success) {
|
if (currentPage != 1 && loadingState.value is Success) {
|
||||||
response.response.list
|
response.response.list
|
||||||
?.insertAll(0, (loadingState.value as Success).response);
|
?.insertAll(0, (loadingState.value as Success).response);
|
||||||
}
|
}
|
||||||
|
if (response.response.list.length >= total.value) {
|
||||||
|
isEnd = true;
|
||||||
|
}
|
||||||
loadingState.value = LoadingState.success(response.response.list);
|
loadingState.value = LoadingState.success(response.response.list);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
import 'package:PiliPalaX/grpc/app/main/community/reply/v1/reply.pb.dart';
|
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/models/common/reply_type.dart';
|
import 'package:PiliPalaX/models/common/reply_type.dart';
|
||||||
|
import 'package:PiliPalaX/models/video/reply/data.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/global_data.dart';
|
||||||
import 'package:PiliPalaX/utils/utils.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';
|
||||||
@@ -14,11 +17,9 @@ import 'package:PiliPalaX/utils/storage.dart';
|
|||||||
import 'package:get/get_navigation/src/dialog/dialog_route.dart';
|
import 'package:get/get_navigation/src/dialog/dialog_route.dart';
|
||||||
|
|
||||||
abstract class ReplyController extends CommonController {
|
abstract class ReplyController extends CommonController {
|
||||||
String nextOffset = "";
|
String nextOffset = '';
|
||||||
bool isLoadingMore = false;
|
bool isLoadingMore = false;
|
||||||
RxInt count = (-1).obs;
|
RxInt count = (-1).obs;
|
||||||
// 当前回复的回复
|
|
||||||
ReplyItemModel? currentReplyItem;
|
|
||||||
|
|
||||||
ReplySortType sortType = ReplySortType.time;
|
ReplySortType sortType = ReplySortType.time;
|
||||||
RxString sortTypeTitle = ReplySortType.time.titles.obs;
|
RxString sortTypeTitle = ReplySortType.time.titles.obs;
|
||||||
@@ -26,10 +27,10 @@ abstract class ReplyController extends CommonController {
|
|||||||
|
|
||||||
late final savedReplies = {};
|
late final savedReplies = {};
|
||||||
|
|
||||||
bool isLogin = GStorage.userInfo.get('userInfoCache') != null;
|
late bool isLogin = GStorage.userInfo.get('userInfoCache') != null;
|
||||||
|
|
||||||
CursorReply? cursor;
|
CursorReply? cursor;
|
||||||
Mode mode = Mode.MAIN_LIST_HOT;
|
late Mode mode = Mode.MAIN_LIST_HOT;
|
||||||
bool hasUpTop = false;
|
bool hasUpTop = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -58,23 +59,53 @@ abstract class ReplyController extends CommonController {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool customHandleResponse(Success response) {
|
bool customHandleResponse(Success response) {
|
||||||
MainListReply replies = response.response;
|
if (GlobalData().grpcReply) {
|
||||||
if (cursor == null) {
|
MainListReply replies = response.response;
|
||||||
count.value = replies.subjectControl.count.toInt();
|
if (cursor == null) {
|
||||||
hasUpTop = replies.hasUpTop();
|
count.value = replies.subjectControl.count.toInt();
|
||||||
if (replies.hasUpTop()) {
|
hasUpTop = replies.hasUpTop();
|
||||||
replies.replies.insert(0, replies.upTop);
|
if (replies.hasUpTop()) {
|
||||||
|
replies.replies.insert(0, replies.upTop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
cursor = replies.cursor;
|
||||||
|
if (currentPage != 1 && loadingState.value is Success) {
|
||||||
|
replies.replies
|
||||||
|
.insertAll(0, (loadingState.value as Success).response.replies);
|
||||||
|
}
|
||||||
|
isEnd = replies.replies.isEmpty ||
|
||||||
|
replies.cursor.isEnd ||
|
||||||
|
replies.replies.length >= count.value;
|
||||||
|
loadingState.value = LoadingState.success(replies);
|
||||||
|
} else {
|
||||||
|
List<ReplyItemModel> replies = response.response.replies;
|
||||||
|
if (isLogin.not) {
|
||||||
|
nextOffset = response.response.cursor.paginationReply.nextOffset ?? '';
|
||||||
|
}
|
||||||
|
count.value = isLogin.not
|
||||||
|
? response.response.cursor.allCount
|
||||||
|
: response.response.page.count ?? 0;
|
||||||
|
if (replies.isEmpty) {
|
||||||
|
isEnd = true;
|
||||||
|
}
|
||||||
|
if (currentPage == 1) {
|
||||||
|
if (response.response.upper.top != null) {
|
||||||
|
final bool flag = response.response.topReplies.any(
|
||||||
|
(ReplyItemModel reply) =>
|
||||||
|
reply.rpid == response.response.upper.top.rpid) as bool;
|
||||||
|
if (!flag) {
|
||||||
|
replies.insert(0, response.response.upper.top);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
replies.insertAll(0, response.response.topReplies);
|
||||||
|
} else if (loadingState.value is Success) {
|
||||||
|
replies.insertAll(0, (loadingState.value as Success).response.replies);
|
||||||
|
}
|
||||||
|
if (replies.length >= count.value) {
|
||||||
|
isEnd = true;
|
||||||
|
}
|
||||||
|
loadingState.value = LoadingState.success(response.response);
|
||||||
}
|
}
|
||||||
cursor = replies.cursor;
|
|
||||||
if (currentPage != 1 && loadingState.value is Success) {
|
|
||||||
replies.replies
|
|
||||||
.insertAll(0, (loadingState.value as Success).response.replies);
|
|
||||||
}
|
|
||||||
isEnd = replies.replies.isEmpty ||
|
|
||||||
replies.cursor.isEnd ||
|
|
||||||
replies.replies.length >= count.value;
|
|
||||||
loadingState.value = LoadingState.success(replies);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +126,7 @@ abstract class ReplyController extends CommonController {
|
|||||||
}
|
}
|
||||||
sortTypeTitle.value = sortType.titles;
|
sortTypeTitle.value = sortType.titles;
|
||||||
sortTypeLabel.value = sortType.labels;
|
sortTypeLabel.value = sortType.labels;
|
||||||
nextOffset = "";
|
nextOffset = '';
|
||||||
loadingState.value = LoadingState.loading();
|
loadingState.value = LoadingState.loading();
|
||||||
onRefresh();
|
onRefresh();
|
||||||
});
|
});
|
||||||
@@ -108,24 +139,40 @@ abstract class ReplyController extends CommonController {
|
|||||||
int index = 0,
|
int index = 0,
|
||||||
ReplyType? replyType,
|
ReplyType? replyType,
|
||||||
}) {
|
}) {
|
||||||
dynamic key = oid ?? replyItem.oid + replyItem.id;
|
dynamic key = oid ??
|
||||||
|
replyItem.oid +
|
||||||
|
(GlobalData().grpcReply ? replyItem.id : replyItem.rpid);
|
||||||
Navigator.of(context)
|
Navigator.of(context)
|
||||||
.push(
|
.push(
|
||||||
GetDialogRoute(
|
GetDialogRoute(
|
||||||
pageBuilder: (buildContext, animation, secondaryAnimation) {
|
pageBuilder: (buildContext, animation, secondaryAnimation) {
|
||||||
return ReplyPage(
|
return GlobalData().grpcReply
|
||||||
oid: oid ?? replyItem.oid.toInt(),
|
? ReplyPage(
|
||||||
root: oid != null ? 0 : replyItem.id.toInt(),
|
oid: oid ?? replyItem.oid.toInt(),
|
||||||
parent: oid != null ? 0 : replyItem.id.toInt(),
|
root: oid != null ? 0 : replyItem.id.toInt(),
|
||||||
replyType: replyItem != null
|
parent: oid != null ? 0 : replyItem.id.toInt(),
|
||||||
? ReplyType.values[replyItem.type.toInt()]
|
replyType: replyItem != null
|
||||||
: replyType,
|
? ReplyType.values[replyItem.type.toInt()]
|
||||||
replyItem: replyItem,
|
: replyType,
|
||||||
savedReply: savedReplies[key],
|
replyItem: replyItem,
|
||||||
onSaveReply: (reply) {
|
savedReply: savedReplies[key],
|
||||||
savedReplies[key] = reply;
|
onSaveReply: (reply) {
|
||||||
},
|
savedReplies[key] = reply;
|
||||||
);
|
},
|
||||||
|
)
|
||||||
|
: ReplyPage(
|
||||||
|
oid: oid ?? replyItem.oid,
|
||||||
|
root: oid != null ? 0 : replyItem.rpid,
|
||||||
|
parent: oid != null ? 0 : replyItem.rpid,
|
||||||
|
replyType: replyItem != null
|
||||||
|
? ReplyType.values[replyItem.type.toInt()]
|
||||||
|
: replyType,
|
||||||
|
replyItem: replyItem,
|
||||||
|
savedReply: savedReplies[key],
|
||||||
|
onSaveReply: (reply) {
|
||||||
|
savedReplies[key] = reply;
|
||||||
|
},
|
||||||
|
);
|
||||||
},
|
},
|
||||||
transitionDuration: const Duration(milliseconds: 500),
|
transitionDuration: const Duration(milliseconds: 500),
|
||||||
transitionBuilder: (context, animation, secondaryAnimation, child) {
|
transitionBuilder: (context, animation, secondaryAnimation, child) {
|
||||||
@@ -147,37 +194,72 @@ abstract class ReplyController extends CommonController {
|
|||||||
(res) {
|
(res) {
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
savedReplies[key] = null;
|
savedReplies[key] = null;
|
||||||
ReplyInfo replyInfo = Utils.replyCast(res);
|
if (GlobalData().grpcReply) {
|
||||||
MainListReply response =
|
ReplyInfo replyInfo = Utils.replyCast(res);
|
||||||
(loadingState.value as Success?)?.response ?? MainListReply();
|
MainListReply response =
|
||||||
if (oid != null) {
|
(loadingState.value as Success?)?.response ?? MainListReply();
|
||||||
response.replies.insert(hasUpTop ? 1 : 0, replyInfo);
|
if (oid != null) {
|
||||||
|
response.replies.insert(hasUpTop ? 1 : 0, replyInfo);
|
||||||
|
} else {
|
||||||
|
response.replies[index].replies.add(replyInfo);
|
||||||
|
}
|
||||||
|
count.value += 1;
|
||||||
|
loadingState.value = LoadingState.success(response);
|
||||||
} else {
|
} else {
|
||||||
response.replies[index].replies.add(replyInfo);
|
ReplyData response =
|
||||||
|
(loadingState.value as Success?)?.response ?? ReplyData();
|
||||||
|
response.replies ??= <ReplyItemModel>[];
|
||||||
|
if (oid != null) {
|
||||||
|
response.replies
|
||||||
|
?.insert(hasUpTop ? 1 : 0, ReplyItemModel.fromJson(res, ''));
|
||||||
|
} else {
|
||||||
|
response.replies?[index].replies ??= <ReplyItemModel>[];
|
||||||
|
response.replies?[index].replies
|
||||||
|
?.add(ReplyItemModel.fromJson(res, ''));
|
||||||
|
}
|
||||||
|
count.value += 1;
|
||||||
|
loadingState.value = LoadingState.success(response);
|
||||||
}
|
}
|
||||||
count.value += 1;
|
|
||||||
loadingState.value = LoadingState.success(response);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onMDelete(rpid, frpid) {
|
onMDelete(rpid, frpid) {
|
||||||
MainListReply response = (loadingState.value as Success).response;
|
if (GlobalData().grpcReply) {
|
||||||
if (frpid == null) {
|
MainListReply response = (loadingState.value as Success).response;
|
||||||
response.replies.removeWhere((item) {
|
if (frpid == null) {
|
||||||
return item.id.toInt() == rpid;
|
response.replies.removeWhere((item) {
|
||||||
});
|
return item.id.toInt() == rpid;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
response.replies.map((item) {
|
||||||
|
if (item.id == frpid) {
|
||||||
|
return item
|
||||||
|
..replies.removeWhere((reply) => reply.id.toInt() == rpid);
|
||||||
|
} else {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
count.value -= 1;
|
||||||
|
loadingState.value = LoadingState.success(response);
|
||||||
} else {
|
} else {
|
||||||
response.replies.map((item) {
|
ReplyData response = (loadingState.value as Success).response;
|
||||||
if (item.id == frpid) {
|
response.replies = frpid == null
|
||||||
return item..replies.removeWhere((reply) => reply.id.toInt() == rpid);
|
? response.replies?.where((item) => item.rpid != rpid).toList()
|
||||||
} else {
|
: response.replies?.map((item) {
|
||||||
return item;
|
if (item.rpid == frpid) {
|
||||||
}
|
return item
|
||||||
}).toList();
|
..replies = item.replies
|
||||||
|
?.where((reply) => reply.rpid != rpid)
|
||||||
|
.toList();
|
||||||
|
} else {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}).toList();
|
||||||
|
count.value -= 1;
|
||||||
|
loadingState.value = LoadingState.success(response);
|
||||||
}
|
}
|
||||||
count.value -= 1;
|
|
||||||
loadingState.value = LoadingState.success(response);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:PiliPalaX/grpc/app/main/community/reply/v1/reply.pb.dart';
|
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/common/reply_controller.dart';
|
import 'package:PiliPalaX/pages/common/reply_controller.dart';
|
||||||
|
import 'package:PiliPalaX/utils/global_data.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPalaX/http/html.dart';
|
import 'package:PiliPalaX/http/html.dart';
|
||||||
import 'package:PiliPalaX/http/reply.dart';
|
import 'package:PiliPalaX/http/reply.dart';
|
||||||
@@ -34,23 +35,22 @@ class DynamicDetailController extends ReplyController {
|
|||||||
queryData();
|
queryData();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @override
|
|
||||||
// Future<LoadingState> customGetData() => ReplyHttp.replyList(
|
|
||||||
// isLogin: isLogin,
|
|
||||||
// oid: oid!,
|
|
||||||
// nextOffset: nextOffset,
|
|
||||||
// type: type!,
|
|
||||||
// sort: sortType.index,
|
|
||||||
// page: currentPage,
|
|
||||||
// );
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<LoadingState> customGetData() => ReplyHttp.replyListGrpc(
|
Future<LoadingState> customGetData() => GlobalData().grpcReply
|
||||||
type: type ?? 1,
|
? ReplyHttp.replyListGrpc(
|
||||||
oid: oid!,
|
type: type ?? 1,
|
||||||
cursor: CursorReq(
|
oid: oid!,
|
||||||
next: cursor?.next ?? $fixnum.Int64(0),
|
cursor: CursorReq(
|
||||||
mode: mode,
|
next: cursor?.next ?? $fixnum.Int64(0),
|
||||||
),
|
mode: mode,
|
||||||
);
|
),
|
||||||
|
)
|
||||||
|
: ReplyHttp.replyList(
|
||||||
|
isLogin: isLogin,
|
||||||
|
oid: oid!,
|
||||||
|
nextOffset: nextOffset,
|
||||||
|
type: type!,
|
||||||
|
sort: sortType.index,
|
||||||
|
page: currentPage,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,12 @@ import 'dart:math';
|
|||||||
|
|
||||||
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPalaX/common/widgets/refresh_indicator.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.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/utils/extension.dart';
|
import 'package:PiliPalaX/utils/extension.dart';
|
||||||
|
import 'package:PiliPalaX/utils/global_data.dart';
|
||||||
import 'package:PiliPalaX/utils/utils.dart';
|
import 'package:PiliPalaX/utils/utils.dart';
|
||||||
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -110,23 +113,25 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
|
|
||||||
// 查看二级评论
|
// 查看二级评论
|
||||||
void replyReply(replyItem, id, isTop) {
|
void replyReply(replyItem, id, isTop) {
|
||||||
int oid = replyItem.oid.toInt();
|
EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () {
|
||||||
int rpid = replyItem.id.toInt()!;
|
int oid = replyItem.oid.toInt();
|
||||||
Get.to(
|
int rpid = GlobalData().grpcReply ? replyItem.id.toInt() : replyItem.rpid;
|
||||||
() => Scaffold(
|
Get.to(
|
||||||
resizeToAvoidBottomInset: false,
|
() => Scaffold(
|
||||||
appBar: AppBar(title: Text('评论详情')),
|
resizeToAvoidBottomInset: false,
|
||||||
body: VideoReplyReplyPanel(
|
appBar: AppBar(title: Text('评论详情')),
|
||||||
id: id,
|
body: VideoReplyReplyPanel(
|
||||||
oid: oid,
|
id: id,
|
||||||
rpid: rpid,
|
oid: oid,
|
||||||
source: 'dynamic',
|
rpid: rpid,
|
||||||
replyType: ReplyType.values[replyType],
|
source: 'dynamic',
|
||||||
firstFloor: replyItem,
|
replyType: ReplyType.values[replyType],
|
||||||
isTop: isTop,
|
firstFloor: replyItem,
|
||||||
|
isTop: isTop ?? false,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 滑动事件监听
|
// 滑动事件监听
|
||||||
@@ -386,23 +391,40 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return ReplyItemGrpc(
|
return GlobalData().grpcReply
|
||||||
replyItem: loadingState.response.replies[index],
|
? ReplyItemGrpc(
|
||||||
showReplyRow: true,
|
replyItem: loadingState.response.replies[index],
|
||||||
replyLevel: '1',
|
showReplyRow: true,
|
||||||
replyReply: replyReply,
|
replyLevel: '1',
|
||||||
replyType: ReplyType.values[replyType],
|
replyReply: replyReply,
|
||||||
onReply: () {
|
replyType: ReplyType.values[replyType],
|
||||||
_dynamicDetailController.onReply(
|
onReply: () {
|
||||||
context,
|
_dynamicDetailController.onReply(
|
||||||
replyItem: loadingState.response.replies[index],
|
context,
|
||||||
index: index,
|
replyItem: loadingState.response.replies[index],
|
||||||
);
|
index: index,
|
||||||
},
|
);
|
||||||
onDelete: _dynamicDetailController.onMDelete,
|
},
|
||||||
isTop: _dynamicDetailController.hasUpTop && index == 0,
|
onDelete: _dynamicDetailController.onMDelete,
|
||||||
upMid: loadingState.response.subjectControl.upMid,
|
isTop:
|
||||||
);
|
_dynamicDetailController.hasUpTop && index == 0,
|
||||||
|
upMid: loadingState.response.subjectControl.upMid,
|
||||||
|
)
|
||||||
|
: ReplyItem(
|
||||||
|
replyItem: loadingState.response.replies[index],
|
||||||
|
showReplyRow: true,
|
||||||
|
replyLevel: '1',
|
||||||
|
replyReply: replyReply,
|
||||||
|
replyType: ReplyType.values[replyType],
|
||||||
|
onReply: () {
|
||||||
|
_dynamicDetailController.onReply(
|
||||||
|
context,
|
||||||
|
replyItem: loadingState.response.replies[index],
|
||||||
|
index: index,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onDelete: _dynamicDetailController.onMDelete,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
childCount: loadingState.response.replies.length + 1,
|
childCount: loadingState.response.replies.length + 1,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
||||||
import 'package:PiliPalaX/utils/extension.dart';
|
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:PiliPalaX/http/user.dart';
|
import 'package:PiliPalaX/http/user.dart';
|
||||||
import 'package:PiliPalaX/models/user/info.dart';
|
import 'package:PiliPalaX/models/user/info.dart';
|
||||||
@@ -10,7 +9,6 @@ class FavController extends CommonController {
|
|||||||
Box userInfoCache = GStorage.userInfo;
|
Box userInfoCache = GStorage.userInfo;
|
||||||
late final UserInfoData? userInfo = userInfoCache.get('userInfoCache');
|
late final UserInfoData? userInfo = userInfoCache.get('userInfoCache');
|
||||||
int pageSize = 10;
|
int pageSize = 10;
|
||||||
bool hasMore = true;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@@ -24,16 +22,14 @@ class FavController extends CommonController {
|
|||||||
loadingState.value = LoadingState.error('账号未登录');
|
loadingState.value = LoadingState.error('账号未登录');
|
||||||
return Future.value();
|
return Future.value();
|
||||||
}
|
}
|
||||||
if (isRefresh.not && hasMore.not) {
|
|
||||||
return Future.value();
|
|
||||||
}
|
|
||||||
return super.queryData(isRefresh);
|
return super.queryData(isRefresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool customHandleResponse(Success response) {
|
bool customHandleResponse(Success response) {
|
||||||
hasMore = response.response.hasMore;
|
if (!response.response.hasMore || response.response.list.isEmpty) {
|
||||||
isEnd = response.response.list.isEmpty;
|
isEnd = true;
|
||||||
|
}
|
||||||
if (currentPage != 1 && loadingState.value is Success) {
|
if (currentPage != 1 && loadingState.value is Success) {
|
||||||
response.response.list
|
response.response.list
|
||||||
.insertAll(0, (loadingState.value as Success).response);
|
.insertAll(0, (loadingState.value as Success).response);
|
||||||
|
|||||||
@@ -35,16 +35,19 @@ class FavDetailController extends MultiSelectController {
|
|||||||
isOwner.value = response.response.info.mid ==
|
isOwner.value = response.response.info.mid ==
|
||||||
GStorage.userInfo.get('userInfoCache')?.mid;
|
GStorage.userInfo.get('userInfoCache')?.mid;
|
||||||
}
|
}
|
||||||
|
if (response.response.medias.isEmpty) {
|
||||||
|
isEnd = true;
|
||||||
|
}
|
||||||
if (currentPage != 1 && loadingState.value is Success) {
|
if (currentPage != 1 && loadingState.value is Success) {
|
||||||
response.response.medias?.insertAll(
|
response.response.medias?.insertAll(
|
||||||
0,
|
0,
|
||||||
List<FavDetailItemData>.from((loadingState.value as Success).response),
|
List<FavDetailItemData>.from((loadingState.value as Success).response),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
loadingState.value = LoadingState.success(response.response.medias);
|
|
||||||
if (response.response.medias.length >= response.response.info.mediaCount) {
|
if (response.response.medias.length >= response.response.info.mediaCount) {
|
||||||
isEnd = true;
|
isEnd = true;
|
||||||
}
|
}
|
||||||
|
loadingState.value = LoadingState.success(response.response.medias);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,10 +56,10 @@ class FavSearchController extends CommonController {
|
|||||||
: (currentPage == 1
|
: (currentPage == 1
|
||||||
? response.response.list
|
? response.response.list
|
||||||
: currentList + response.response.list);
|
: currentList + response.response.list);
|
||||||
loadingState.value = LoadingState.success(dataList);
|
|
||||||
isEnd = searchType == SearchType.fav
|
isEnd = searchType == SearchType.fav
|
||||||
? !response.response.hasMore
|
? !response.response.hasMore
|
||||||
: response.response.list.isEmpty;
|
: response.response.list.isEmpty;
|
||||||
|
loadingState.value = LoadingState.success(dataList);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:PiliPalaX/grpc/app/main/community/reply/v1/reply.pb.dart';
|
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/common/reply_controller.dart';
|
import 'package:PiliPalaX/pages/common/reply_controller.dart';
|
||||||
|
import 'package:PiliPalaX/utils/global_data.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPalaX/http/html.dart';
|
import 'package:PiliPalaX/http/html.dart';
|
||||||
import 'package:PiliPalaX/http/reply.dart';
|
import 'package:PiliPalaX/http/reply.dart';
|
||||||
@@ -44,23 +45,22 @@ class HtmlRenderController extends ReplyController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @override
|
|
||||||
// Future<LoadingState> customGetData() => ReplyHttp.replyList(
|
|
||||||
// isLogin: isLogin,
|
|
||||||
// oid: oid.value,
|
|
||||||
// nextOffset: nextOffset,
|
|
||||||
// type: type,
|
|
||||||
// sort: sortType.index,
|
|
||||||
// page: currentPage,
|
|
||||||
// );
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<LoadingState> customGetData() => ReplyHttp.replyListGrpc(
|
Future<LoadingState> customGetData() => GlobalData().grpcReply
|
||||||
type: type,
|
? ReplyHttp.replyListGrpc(
|
||||||
oid: oid.value,
|
type: type,
|
||||||
cursor: CursorReq(
|
oid: oid.value,
|
||||||
next: cursor?.next ?? $fixnum.Int64(0),
|
cursor: CursorReq(
|
||||||
mode: mode,
|
next: cursor?.next ?? $fixnum.Int64(0),
|
||||||
),
|
mode: mode,
|
||||||
);
|
),
|
||||||
|
)
|
||||||
|
: ReplyHttp.replyList(
|
||||||
|
isLogin: isLogin,
|
||||||
|
oid: oid.value,
|
||||||
|
nextOffset: nextOffset,
|
||||||
|
type: type,
|
||||||
|
sort: sortType.index,
|
||||||
|
page: currentPage,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,11 @@ import 'dart:math';
|
|||||||
import 'package:PiliPalaX/common/widgets/article_content.dart';
|
import 'package:PiliPalaX/common/widgets/article_content.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
import 'package:PiliPalaX/common/widgets/http_error.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.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/utils/extension.dart';
|
import 'package:PiliPalaX/utils/extension.dart';
|
||||||
|
import 'package:PiliPalaX/utils/global_data.dart';
|
||||||
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@@ -101,25 +104,27 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
void replyReply(replyItem, id, isTop) {
|
void replyReply(replyItem, id, isTop) {
|
||||||
int oid = replyItem.oid.toInt();
|
EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () {
|
||||||
int rpid = replyItem.id.toInt();
|
int oid = replyItem.oid.toInt();
|
||||||
Get.to(
|
int rpid = GlobalData().grpcReply ? replyItem.id.toInt() : replyItem.rpid;
|
||||||
() => Scaffold(
|
Get.to(
|
||||||
resizeToAvoidBottomInset: false,
|
() => Scaffold(
|
||||||
appBar: AppBar(
|
resizeToAvoidBottomInset: false,
|
||||||
title: Text('评论详情'),
|
appBar: AppBar(
|
||||||
|
title: Text('评论详情'),
|
||||||
|
),
|
||||||
|
body: VideoReplyReplyPanel(
|
||||||
|
id: id,
|
||||||
|
oid: oid,
|
||||||
|
rpid: rpid,
|
||||||
|
source: 'dynamic',
|
||||||
|
replyType: ReplyType.values[type],
|
||||||
|
firstFloor: replyItem,
|
||||||
|
isTop: isTop ?? false,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
body: VideoReplyReplyPanel(
|
);
|
||||||
id: id,
|
});
|
||||||
oid: oid,
|
|
||||||
rpid: rpid,
|
|
||||||
source: 'dynamic',
|
|
||||||
replyType: ReplyType.values[type],
|
|
||||||
firstFloor: replyItem,
|
|
||||||
isTop: isTop,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -345,23 +350,39 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return ReplyItemGrpc(
|
return GlobalData().grpcReply
|
||||||
replyItem: loadingState.response.replies[index],
|
? ReplyItemGrpc(
|
||||||
showReplyRow: true,
|
replyItem: loadingState.response.replies[index],
|
||||||
replyLevel: '1',
|
showReplyRow: true,
|
||||||
replyReply: replyReply,
|
replyLevel: '1',
|
||||||
replyType: ReplyType.values[type],
|
replyReply: replyReply,
|
||||||
onReply: () {
|
replyType: ReplyType.values[type],
|
||||||
_htmlRenderCtr.onReply(
|
onReply: () {
|
||||||
context,
|
_htmlRenderCtr.onReply(
|
||||||
replyItem: loadingState.response.replies[index],
|
context,
|
||||||
index: index,
|
replyItem: loadingState.response.replies[index],
|
||||||
);
|
index: index,
|
||||||
},
|
);
|
||||||
onDelete: _htmlRenderCtr.onMDelete,
|
},
|
||||||
isTop: _htmlRenderCtr.hasUpTop && index == 0,
|
onDelete: _htmlRenderCtr.onMDelete,
|
||||||
upMid: loadingState.response.subjectControl.upMid,
|
isTop: _htmlRenderCtr.hasUpTop && index == 0,
|
||||||
);
|
upMid: loadingState.response.subjectControl.upMid,
|
||||||
|
)
|
||||||
|
: ReplyItem(
|
||||||
|
replyItem: loadingState.response.replies[index],
|
||||||
|
showReplyRow: true,
|
||||||
|
replyLevel: '1',
|
||||||
|
replyReply: replyReply,
|
||||||
|
replyType: ReplyType.values[type],
|
||||||
|
onReply: () {
|
||||||
|
_htmlRenderCtr.onReply(
|
||||||
|
context,
|
||||||
|
replyItem: loadingState.response.replies[index],
|
||||||
|
index: index,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onDelete: _htmlRenderCtr.onMDelete,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -17,8 +17,9 @@ class LaterController extends MultiSelectController {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool customHandleResponse(Success response) {
|
bool customHandleResponse(Success response) {
|
||||||
if (currentPage == 1) {
|
count.value = response.response['count'];
|
||||||
count.value = response.response['count'];
|
if (response.response['list'].isEmpty) {
|
||||||
|
isEnd = true;
|
||||||
}
|
}
|
||||||
if (currentPage != 1 && loadingState.value is Success) {
|
if (currentPage != 1 && loadingState.value is Success) {
|
||||||
response.response['list'].insertAll(
|
response.response['list'].insertAll(
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:PiliPalaX/http/loading_state.dart';
|
|||||||
import 'package:PiliPalaX/http/member.dart';
|
import 'package:PiliPalaX/http/member.dart';
|
||||||
import 'package:PiliPalaX/models/space_article/data.dart';
|
import 'package:PiliPalaX/models/space_article/data.dart';
|
||||||
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
||||||
|
import 'package:PiliPalaX/utils/extension.dart';
|
||||||
|
|
||||||
class MemberArticleCtr extends CommonController {
|
class MemberArticleCtr extends CommonController {
|
||||||
MemberArticleCtr({
|
MemberArticleCtr({
|
||||||
@@ -21,12 +22,17 @@ class MemberArticleCtr extends CommonController {
|
|||||||
@override
|
@override
|
||||||
bool customHandleResponse(Success response) {
|
bool customHandleResponse(Success response) {
|
||||||
Data data = response.response;
|
Data data = response.response;
|
||||||
|
if (data.item.isNullOrEmpty) {
|
||||||
|
isEnd = true;
|
||||||
|
}
|
||||||
if (currentPage == 1) {
|
if (currentPage == 1) {
|
||||||
count = data.count ?? -1;
|
count = data.count ?? -1;
|
||||||
} else if (loadingState.value is Success) {
|
} else if (loadingState.value is Success) {
|
||||||
data.item?.insertAll(0, (loadingState.value as Success).response);
|
data.item?.insertAll(0, (loadingState.value as Success).response);
|
||||||
}
|
}
|
||||||
isEnd = (data.item?.length ?? -1) >= count;
|
if ((data.item?.length ?? -1) >= count) {
|
||||||
|
isEnd = true;
|
||||||
|
}
|
||||||
loadingState.value = LoadingState.success(data.item);
|
loadingState.value = LoadingState.success(data.item);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:PiliPalaX/pages/common/common_controller.dart';
|
|||||||
import 'package:PiliPalaX/pages/member/new/content/member_contribute/member_contribute.dart'
|
import 'package:PiliPalaX/pages/member/new/content/member_contribute/member_contribute.dart'
|
||||||
show ContributeType;
|
show ContributeType;
|
||||||
import 'package:PiliPalaX/pages/member/new/controller.dart';
|
import 'package:PiliPalaX/pages/member/new/controller.dart';
|
||||||
|
import 'package:PiliPalaX/utils/extension.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
class MemberBangumiCtr extends CommonController {
|
class MemberBangumiCtr extends CommonController {
|
||||||
@@ -31,10 +32,15 @@ class MemberBangumiCtr extends CommonController {
|
|||||||
@override
|
@override
|
||||||
bool customHandleResponse(Success response) {
|
bool customHandleResponse(Success response) {
|
||||||
Data data = response.response;
|
Data data = response.response;
|
||||||
|
if (data.item.isNullOrEmpty) {
|
||||||
|
isEnd = true;
|
||||||
|
}
|
||||||
if (currentPage != 1 && loadingState.value is Success) {
|
if (currentPage != 1 && loadingState.value is Success) {
|
||||||
data.item?.insertAll(0, (loadingState.value as Success).response);
|
data.item?.insertAll(0, (loadingState.value as Success).response);
|
||||||
}
|
}
|
||||||
isEnd = data.item!.length >= count;
|
if (data.item!.length >= count) {
|
||||||
|
isEnd = true;
|
||||||
|
}
|
||||||
loadingState.value = LoadingState.success(data.item);
|
loadingState.value = LoadingState.success(data.item);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:PiliPalaX/pages/main/controller.dart';
|
import 'package:PiliPalaX/pages/main/controller.dart';
|
||||||
import 'package:PiliPalaX/pages/member/new/controller.dart'
|
import 'package:PiliPalaX/pages/member/new/controller.dart'
|
||||||
show MemberTabType, MemberTabTypeExt;
|
show MemberTabType, MemberTabTypeExt;
|
||||||
|
import 'package:PiliPalaX/utils/global_data.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -152,7 +153,7 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
|||||||
leading: Icon(Icons.notifications_none),
|
leading: Icon(Icons.notifications_none),
|
||||||
setKey: SettingBoxKey.checkDynamic,
|
setKey: SettingBoxKey.checkDynamic,
|
||||||
defaultVal: true,
|
defaultVal: true,
|
||||||
callFn: (value) {
|
onChanged: (value) {
|
||||||
Get.find<MainController>().checkDynamic = value;
|
Get.find<MainController>().checkDynamic = value;
|
||||||
},
|
},
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@@ -201,6 +202,16 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
SetSwitchItem(
|
||||||
|
title: '使用gRPC加载评论',
|
||||||
|
subTitle: '如无法加载评论,可关闭\n非gRPC楼中楼无法定位评论、按热度/时间排序、查看对话',
|
||||||
|
leading: Icon(Icons.reply),
|
||||||
|
setKey: SettingBoxKey.grpcReply,
|
||||||
|
defaultVal: true,
|
||||||
|
onChanged: (value) {
|
||||||
|
GlobalData().grpcReply = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
Obx(
|
Obx(
|
||||||
() => ListTile(
|
() => ListTile(
|
||||||
enableFeedback: true,
|
enableFeedback: true,
|
||||||
@@ -238,7 +249,7 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
|||||||
leading: const Icon(Icons.whatshot_outlined),
|
leading: const Icon(Icons.whatshot_outlined),
|
||||||
setKey: SettingBoxKey.enableSearchWord,
|
setKey: SettingBoxKey.enableSearchWord,
|
||||||
defaultVal: true,
|
defaultVal: true,
|
||||||
callFn: (val) {
|
onChanged: (val) {
|
||||||
Get.find<HomeController>().defaultSearch.value = '';
|
Get.find<HomeController>().defaultSearch.value = '';
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
|
|||||||
subTitle: '根据默认倍速长按时自动双倍',
|
subTitle: '根据默认倍速长按时自动双倍',
|
||||||
setKey: SettingBoxKey.enableAutoLongPressSpeed,
|
setKey: SettingBoxKey.enableAutoLongPressSpeed,
|
||||||
defaultVal: enableAutoLongPressSpeed,
|
defaultVal: enableAutoLongPressSpeed,
|
||||||
callFn: (val) {
|
onChanged: (val) {
|
||||||
Map newItem = sheetMenu[1];
|
Map newItem = sheetMenu[1];
|
||||||
val ? newItem['show'] = false : newItem['show'] = true;
|
val ? newItem['show'] = false : newItem['show'] = true;
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ class _PlaySettingState extends State<PlaySetting> {
|
|||||||
leading: const Icon(Icons.picture_in_picture_outlined),
|
leading: const Icon(Icons.picture_in_picture_outlined),
|
||||||
setKey: SettingBoxKey.autoPiP,
|
setKey: SettingBoxKey.autoPiP,
|
||||||
defaultVal: false,
|
defaultVal: false,
|
||||||
callFn: (val) {
|
onChanged: (val) {
|
||||||
if (val &&
|
if (val &&
|
||||||
!setting.get(SettingBoxKey.enableBackgroundPlay,
|
!setting.get(SettingBoxKey.enableBackgroundPlay,
|
||||||
defaultValue: true)) {
|
defaultValue: true)) {
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ class _RecommendSettingState extends State<RecommendSetting> {
|
|||||||
leading: const Icon(Icons.favorite_border_outlined),
|
leading: const Icon(Icons.favorite_border_outlined),
|
||||||
setKey: SettingBoxKey.exemptFilterForFollowed,
|
setKey: SettingBoxKey.exemptFilterForFollowed,
|
||||||
defaultVal: true,
|
defaultVal: true,
|
||||||
callFn: (_) => {RecommendFilter.update},
|
onChanged: (_) => {RecommendFilter.update},
|
||||||
),
|
),
|
||||||
// ListTile(
|
// ListTile(
|
||||||
// dense: false,
|
// dense: false,
|
||||||
@@ -267,7 +267,7 @@ class _RecommendSettingState extends State<RecommendSetting> {
|
|||||||
leading: const Icon(Icons.explore_outlined),
|
leading: const Icon(Icons.explore_outlined),
|
||||||
setKey: SettingBoxKey.applyFilterToRelatedVideos,
|
setKey: SettingBoxKey.applyFilterToRelatedVideos,
|
||||||
defaultVal: true,
|
defaultVal: true,
|
||||||
callFn: (_) => {RecommendFilter.update},
|
onChanged: (_) => {RecommendFilter.update},
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
dense: true,
|
dense: true,
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class _StyleSettingState extends State<StyleSetting> {
|
|||||||
leading: const Icon(Icons.phonelink_outlined),
|
leading: const Icon(Icons.phonelink_outlined),
|
||||||
setKey: SettingBoxKey.horizontalScreen,
|
setKey: SettingBoxKey.horizontalScreen,
|
||||||
defaultVal: false,
|
defaultVal: false,
|
||||||
callFn: (value) {
|
onChanged: (value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
autoScreen();
|
autoScreen();
|
||||||
// SmartDialog.showToast('已开启横屏适配');
|
// SmartDialog.showToast('已开启横屏适配');
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:hive/hive.dart';
|
|
||||||
import 'package:PiliPalaX/utils/storage.dart';
|
import 'package:PiliPalaX/utils/storage.dart';
|
||||||
|
|
||||||
class SetSwitchItem extends StatefulWidget {
|
class SetSwitchItem extends StatefulWidget {
|
||||||
@@ -8,7 +7,7 @@ class SetSwitchItem extends StatefulWidget {
|
|||||||
final String? subTitle;
|
final String? subTitle;
|
||||||
final String? setKey;
|
final String? setKey;
|
||||||
final bool? defaultVal;
|
final bool? defaultVal;
|
||||||
final Function? callFn;
|
final ValueChanged<bool>? onChanged;
|
||||||
final bool? needReboot;
|
final bool? needReboot;
|
||||||
final Widget? leading;
|
final Widget? leading;
|
||||||
final GestureTapCallback? onTap;
|
final GestureTapCallback? onTap;
|
||||||
@@ -18,7 +17,7 @@ class SetSwitchItem extends StatefulWidget {
|
|||||||
this.subTitle,
|
this.subTitle,
|
||||||
this.setKey,
|
this.setKey,
|
||||||
this.defaultVal,
|
this.defaultVal,
|
||||||
this.callFn,
|
this.onChanged,
|
||||||
this.needReboot,
|
this.needReboot,
|
||||||
this.leading,
|
this.leading,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
@@ -30,24 +29,23 @@ class SetSwitchItem extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _SetSwitchItemState extends State<SetSwitchItem> {
|
class _SetSwitchItemState extends State<SetSwitchItem> {
|
||||||
// ignore: non_constant_identifier_names
|
|
||||||
Box Setting = GStorage.setting;
|
|
||||||
late bool val;
|
late bool val;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
val = Setting.get(widget.setKey, defaultValue: widget.defaultVal ?? false);
|
val = GStorage.setting
|
||||||
|
.get(widget.setKey, defaultValue: widget.defaultVal ?? false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void switchChange(value) async {
|
void switchChange(value) async {
|
||||||
val = value ?? !val;
|
val = value ?? !val;
|
||||||
await Setting.put(widget.setKey, val);
|
await GStorage.setting.put(widget.setKey, val);
|
||||||
// if (widget.setKey == SettingBoxKey.autoUpdate && value == true) {
|
// if (widget.setKey == SettingBoxKey.autoUpdate && value == true) {
|
||||||
// Utils.checkUpdate();
|
// Utils.checkUpdate();
|
||||||
// }
|
// }
|
||||||
if (widget.callFn != null) {
|
if (widget.onChanged != null) {
|
||||||
widget.callFn!.call(val);
|
widget.onChanged!.call(val);
|
||||||
}
|
}
|
||||||
if (widget.needReboot != null && widget.needReboot!) {
|
if (widget.needReboot != null && widget.needReboot!) {
|
||||||
SmartDialog.showToast('重启生效');
|
SmartDialog.showToast('重启生效');
|
||||||
@@ -87,7 +85,7 @@ class _SetSwitchItemState extends State<SetSwitchItem> {
|
|||||||
return null; // All other states will use the default thumbIcon.
|
return null; // All other states will use the default thumbIcon.
|
||||||
}),
|
}),
|
||||||
value: val,
|
value: val,
|
||||||
onChanged: (val) => switchChange(val),
|
onChanged: switchChange,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import 'package:PiliPalaX/grpc/app/main/community/reply/v1/reply.pb.dart';
|
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/models/common/reply_type.dart';
|
||||||
import 'package:PiliPalaX/pages/common/reply_controller.dart';
|
import 'package:PiliPalaX/pages/common/reply_controller.dart';
|
||||||
import 'package:PiliPalaX/http/reply.dart';
|
import 'package:PiliPalaX/http/reply.dart';
|
||||||
|
import 'package:PiliPalaX/utils/global_data.dart';
|
||||||
import 'package:fixnum/fixnum.dart' as $fixnum;
|
import 'package:fixnum/fixnum.dart' as $fixnum;
|
||||||
|
|
||||||
class VideoReplyController extends ReplyController {
|
class VideoReplyController extends ReplyController {
|
||||||
@@ -18,11 +20,20 @@ class VideoReplyController extends ReplyController {
|
|||||||
String? rpid;
|
String? rpid;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<LoadingState> customGetData() => ReplyHttp.replyListGrpc(
|
Future<LoadingState> customGetData() => GlobalData().grpcReply
|
||||||
oid: aid!,
|
? ReplyHttp.replyListGrpc(
|
||||||
cursor: CursorReq(
|
oid: aid!,
|
||||||
next: cursor?.next ?? $fixnum.Int64(0),
|
cursor: CursorReq(
|
||||||
mode: mode,
|
next: cursor?.next ?? $fixnum.Int64(0),
|
||||||
),
|
mode: mode,
|
||||||
);
|
),
|
||||||
|
)
|
||||||
|
: ReplyHttp.replyList(
|
||||||
|
isLogin: isLogin,
|
||||||
|
oid: aid!,
|
||||||
|
nextOffset: nextOffset,
|
||||||
|
type: ReplyType.video.index,
|
||||||
|
sort: sortType.index,
|
||||||
|
page: currentPage,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
import 'package:PiliPalaX/common/widgets/http_error.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.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/utils/extension.dart';
|
import 'package:PiliPalaX/utils/extension.dart';
|
||||||
|
import 'package:PiliPalaX/utils/global_data.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -228,24 +230,43 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return ReplyItemGrpc(
|
return GlobalData().grpcReply
|
||||||
replyItem: loadingState.response.replies[index],
|
? ReplyItemGrpc(
|
||||||
showReplyRow: true,
|
replyItem: loadingState.response.replies[index],
|
||||||
replyLevel: replyLevel,
|
showReplyRow: true,
|
||||||
replyReply: widget.replyReply,
|
replyLevel: replyLevel,
|
||||||
replyType: ReplyType.video,
|
replyReply: widget.replyReply,
|
||||||
onReply: () {
|
replyType: ReplyType.video,
|
||||||
_videoReplyController.onReply(
|
onReply: () {
|
||||||
context,
|
_videoReplyController.onReply(
|
||||||
replyItem: loadingState.response.replies[index],
|
context,
|
||||||
index: index,
|
replyItem: loadingState.response.replies[index],
|
||||||
);
|
index: index,
|
||||||
},
|
);
|
||||||
onDelete: _videoReplyController.onMDelete,
|
},
|
||||||
isTop: _videoReplyController.hasUpTop && index == 0,
|
onDelete: _videoReplyController.onMDelete,
|
||||||
upMid: loadingState.response.subjectControl.upMid,
|
isTop: _videoReplyController.hasUpTop && index == 0,
|
||||||
getTag: () => heroTag,
|
upMid: loadingState.response.subjectControl.upMid,
|
||||||
);
|
getTag: () => heroTag,
|
||||||
|
)
|
||||||
|
: ReplyItem(
|
||||||
|
replyItem: loadingState.response.replies[index],
|
||||||
|
showReplyRow: true,
|
||||||
|
replyLevel: replyLevel,
|
||||||
|
replyReply: widget.replyReply,
|
||||||
|
replyType: ReplyType.video,
|
||||||
|
onReply: () {
|
||||||
|
_videoReplyController.onReply(
|
||||||
|
context,
|
||||||
|
replyItem: loadingState.response.replies[index],
|
||||||
|
index: index,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onDelete: _videoReplyController.onMDelete,
|
||||||
|
// isTop: _videoReplyController.hasUpTop && index == 0,
|
||||||
|
// upMid: loadingState.response.subjectControl.upMid,
|
||||||
|
// getTag: () => heroTag,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
childCount: loadingState.response.replies.length + 1,
|
childCount: loadingState.response.replies.length + 1,
|
||||||
@@ -256,7 +277,8 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
|||||||
callback: _videoReplyController.onReload,
|
callback: _videoReplyController.onReload,
|
||||||
),
|
),
|
||||||
Error() => HttpError(
|
Error() => HttpError(
|
||||||
errMsg: loadingState.errMsg,
|
errMsg:
|
||||||
|
'如无法加载评论:\n1.关闭代理\n2.设置中关闭使用gRPC加载评论\n\n${loadingState.errMsg}',
|
||||||
callback: _videoReplyController.onReload,
|
callback: _videoReplyController.onReload,
|
||||||
),
|
),
|
||||||
LoadingState() => throw UnimplementedError(),
|
LoadingState() => throw UnimplementedError(),
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class ReplyItem extends StatelessWidget {
|
|||||||
// 点击整个评论区 评论详情/回复
|
// 点击整个评论区 评论详情/回复
|
||||||
onTap: () {
|
onTap: () {
|
||||||
feedBack();
|
feedBack();
|
||||||
replyReply?.call(replyItem);
|
replyReply?.call(replyItem, null, null);
|
||||||
},
|
},
|
||||||
onLongPress: () {
|
onLongPress: () {
|
||||||
feedBack();
|
feedBack();
|
||||||
@@ -425,7 +425,7 @@ class ReplyItemRow extends StatelessWidget {
|
|||||||
for (int i = 0; i < replies!.length; i++) ...[
|
for (int i = 0; i < replies!.length; i++) ...[
|
||||||
InkWell(
|
InkWell(
|
||||||
// 一楼点击评论展开评论详情
|
// 一楼点击评论展开评论详情
|
||||||
onTap: () => replyReply?.call(replyItem),
|
onTap: () => replyReply?.call(replyItem, null, null),
|
||||||
onLongPress: () {
|
onLongPress: () {
|
||||||
feedBack();
|
feedBack();
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
@@ -525,7 +525,7 @@ class ReplyItemRow extends StatelessWidget {
|
|||||||
if (extraRow == 1)
|
if (extraRow == 1)
|
||||||
InkWell(
|
InkWell(
|
||||||
// 一楼点击【共xx条回复】展开评论详情
|
// 一楼点击【共xx条回复】展开评论详情
|
||||||
onTap: () => replyReply?.call(replyItem),
|
onTap: () => replyReply?.call(replyItem, null, null),
|
||||||
child: Container(
|
child: Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
padding: const EdgeInsets.fromLTRB(8, 5, 8, 8),
|
padding: const EdgeInsets.fromLTRB(8, 5, 8, 8),
|
||||||
|
|||||||
@@ -2,9 +2,8 @@ import 'dart:async';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:PiliPalaX/grpc/app/main/community/reply/v1/reply.pb.dart'
|
|
||||||
as reply;
|
|
||||||
import 'package:PiliPalaX/http/msg.dart';
|
import 'package:PiliPalaX/http/msg.dart';
|
||||||
|
import 'package:PiliPalaX/utils/global_data.dart';
|
||||||
import 'package:chat_bottom_container/chat_bottom_container.dart';
|
import 'package:chat_bottom_container/chat_bottom_container.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';
|
||||||
@@ -26,7 +25,7 @@ class ReplyPage extends StatefulWidget {
|
|||||||
final int? root;
|
final int? root;
|
||||||
final int? parent;
|
final int? parent;
|
||||||
final ReplyType? replyType;
|
final ReplyType? replyType;
|
||||||
final reply.ReplyInfo? replyItem;
|
final dynamic replyItem;
|
||||||
final String? savedReply;
|
final String? savedReply;
|
||||||
final Function(String reply)? onSaveReply;
|
final Function(String reply)? onSaveReply;
|
||||||
|
|
||||||
@@ -507,8 +506,8 @@ class _ReplyPageState extends State<ReplyPage>
|
|||||||
oid: widget.oid!,
|
oid: widget.oid!,
|
||||||
root: widget.root!,
|
root: widget.root!,
|
||||||
parent: widget.parent!,
|
parent: widget.parent!,
|
||||||
message: widget.replyItem != null && widget.replyItem!.root != 0
|
message: widget.replyItem != null && widget.replyItem.root != 0
|
||||||
? ' 回复 @${widget.replyItem!.member.name} : $message'
|
? ' 回复 @${GlobalData().grpcReply ? widget.replyItem.member.name : widget.replyItem.member.uname} : $message'
|
||||||
: message,
|
: message,
|
||||||
pictures: pictures,
|
pictures: pictures,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import 'package:PiliPalaX/grpc/app/main/community/reply/v1/reply.pb.dart';
|
import 'package:PiliPalaX/grpc/app/main/community/reply/v1/reply.pb.dart';
|
||||||
import 'package:PiliPalaX/grpc/grpc_repo.dart';
|
import 'package:PiliPalaX/grpc/grpc_repo.dart';
|
||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
|
import 'package:PiliPalaX/models/video/reply/item.dart';
|
||||||
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
||||||
|
import 'package:PiliPalaX/utils/global_data.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPalaX/http/reply.dart';
|
import 'package:PiliPalaX/http/reply.dart';
|
||||||
@@ -29,8 +31,6 @@ class VideoReplyReplyController extends CommonController
|
|||||||
// rpid 请求楼中楼回复
|
// rpid 请求楼中楼回复
|
||||||
int? rpid;
|
int? rpid;
|
||||||
ReplyType replyType; // = ReplyType.video;
|
ReplyType replyType; // = ReplyType.video;
|
||||||
// 当前回复的回复
|
|
||||||
ReplyInfo? currentReplyItem;
|
|
||||||
|
|
||||||
CursorReply? cursor;
|
CursorReply? cursor;
|
||||||
Rx<Mode> mode = Mode.MAIN_LIST_TIME.obs;
|
Rx<Mode> mode = Mode.MAIN_LIST_TIME.obs;
|
||||||
@@ -41,7 +41,7 @@ class VideoReplyReplyController extends CommonController
|
|||||||
AnimationController? controller;
|
AnimationController? controller;
|
||||||
Animation<Color?>? colorAnimation;
|
Animation<Color?>? colorAnimation;
|
||||||
|
|
||||||
ReplyInfo? firstFloor;
|
dynamic firstFloor;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@@ -49,34 +49,6 @@ class VideoReplyReplyController extends CommonController
|
|||||||
queryData();
|
queryData();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @override
|
|
||||||
// bool customHandleResponse(Success response) {
|
|
||||||
// if (response.response.root != null) root = response.response.root;
|
|
||||||
// List<ReplyItemModel> replies = response.response.replies;
|
|
||||||
// if (replies.isNotEmpty) {
|
|
||||||
// noMore.value = '加载中...';
|
|
||||||
// if (replies.length == response.response.page.count) {
|
|
||||||
// noMore.value = '没有更多了';
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// // 未登录状态replies可能返回null
|
|
||||||
// noMore.value = currentPage == 1 ? '还没有评论' : '没有更多了';
|
|
||||||
// }
|
|
||||||
// if (currentPage != 1) {
|
|
||||||
// List<ReplyItemModel> list = loadingState.value is Success
|
|
||||||
// ? (loadingState.value as Success).response
|
|
||||||
// : <ReplyItemModel>[];
|
|
||||||
// // 每次回复之后,翻页请求有且只有相同的一条回复数据
|
|
||||||
// if (replies.length == 1 && replies.last.rpid == list.last.rpid) {
|
|
||||||
// return true;
|
|
||||||
// } else {
|
|
||||||
// replies.insertAll(0, list);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// loadingState.value = LoadingState.success(replies);
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future queryData([bool isRefresh = true]) async {
|
Future queryData([bool isRefresh = true]) async {
|
||||||
if (!isDialogue &&
|
if (!isDialogue &&
|
||||||
@@ -95,14 +67,6 @@ class VideoReplyReplyController extends CommonController
|
|||||||
return super.queryData(isRefresh);
|
return super.queryData(isRefresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @override
|
|
||||||
// Future<LoadingState> customGetData() => ReplyHttp.replyReplyList(
|
|
||||||
// oid: aid!,
|
|
||||||
// root: rpid!,
|
|
||||||
// pageNum: currentPage,
|
|
||||||
// type: replyType.index,
|
|
||||||
// );
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future onRefresh() {
|
Future onRefresh() {
|
||||||
cursor = null;
|
cursor = null;
|
||||||
@@ -111,61 +75,89 @@ class VideoReplyReplyController extends CommonController
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool customHandleResponse(Success response) {
|
bool customHandleResponse(Success response) {
|
||||||
dynamic replies = response.response;
|
if (GlobalData().grpcReply) {
|
||||||
if (replies is DetailListReply && cursor == null) {
|
dynamic replies = response.response;
|
||||||
count.value = replies.root.count.toInt();
|
if (replies is DetailListReply && cursor == null) {
|
||||||
if (id != null) {
|
count.value = replies.root.count.toInt();
|
||||||
index = replies.root.replies
|
if (id != null) {
|
||||||
.map((item) => item.id.toInt())
|
index = replies.root.replies
|
||||||
.toList()
|
.map((item) => item.id.toInt())
|
||||||
.indexOf(id!);
|
.toList()
|
||||||
if (index != -1) {
|
.indexOf(id!);
|
||||||
controller = AnimationController(
|
if (index != -1) {
|
||||||
duration: const Duration(milliseconds: 300),
|
controller = AnimationController(
|
||||||
vsync: this,
|
duration: const Duration(milliseconds: 300),
|
||||||
);
|
vsync: this,
|
||||||
colorAnimation = ColorTween(
|
|
||||||
begin: Theme.of(Get.context!).colorScheme.onInverseSurface,
|
|
||||||
end: Theme.of(Get.context!).colorScheme.surface,
|
|
||||||
).animate(controller!);
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
|
||||||
itemScrollCtr.jumpTo(
|
|
||||||
index: hasRoot ? index! + 3 : index! + 1,
|
|
||||||
alignment: 0.25,
|
|
||||||
);
|
);
|
||||||
await Future.delayed(const Duration(milliseconds: 800));
|
colorAnimation = ColorTween(
|
||||||
await controller?.forward();
|
begin: Theme.of(Get.context!).colorScheme.onInverseSurface,
|
||||||
index = null;
|
end: Theme.of(Get.context!).colorScheme.surface,
|
||||||
});
|
).animate(controller!);
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||||
|
itemScrollCtr.jumpTo(
|
||||||
|
index: hasRoot ? index! + 3 : index! + 1,
|
||||||
|
alignment: 0.25,
|
||||||
|
);
|
||||||
|
await Future.delayed(const Duration(milliseconds: 800));
|
||||||
|
await controller?.forward();
|
||||||
|
index = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
id = null;
|
||||||
}
|
}
|
||||||
id = null;
|
|
||||||
}
|
}
|
||||||
}
|
upMid ??= replies.subjectControl.upMid.toInt();
|
||||||
upMid ??= replies.subjectControl.upMid.toInt();
|
cursor = replies.cursor;
|
||||||
cursor = replies.cursor;
|
|
||||||
if (currentPage != 1) {
|
|
||||||
List<ReplyInfo> list = loadingState.value is Success
|
|
||||||
? (loadingState.value as Success).response
|
|
||||||
: <ReplyInfo>[];
|
|
||||||
if (isDialogue) {
|
if (isDialogue) {
|
||||||
replies.replies.insertAll(0, list);
|
if (replies.replies.isEmpty) {
|
||||||
|
isEnd = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
replies.root.replies.insertAll(0, list);
|
if (replies.root.replies.isEmpty) {
|
||||||
|
isEnd = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (currentPage != 1) {
|
||||||
|
List<ReplyInfo> list = loadingState.value is Success
|
||||||
|
? (loadingState.value as Success).response
|
||||||
|
: <ReplyInfo>[];
|
||||||
|
if (isDialogue) {
|
||||||
|
replies.replies.insertAll(0, list);
|
||||||
|
} else {
|
||||||
|
replies.root.replies.insertAll(0, list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isDialogue) {
|
||||||
|
if (replies.cursor.isEnd || replies.replies.length >= count.value) {
|
||||||
|
isEnd = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (replies.cursor.isEnd ||
|
||||||
|
replies.root.replies.length >= count.value) {
|
||||||
|
isEnd = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isDialogue) {
|
||||||
|
loadingState.value = LoadingState.success(replies.replies);
|
||||||
|
} else {
|
||||||
|
loadingState.value = LoadingState.success(replies.root.replies);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (isDialogue) {
|
|
||||||
isEnd = replies.replies.isEmpty ||
|
|
||||||
replies.cursor.isEnd ||
|
|
||||||
replies.replies.length >= count.value;
|
|
||||||
} else {
|
} else {
|
||||||
isEnd = replies.root.replies.isEmpty ||
|
if (response.response.root != null) {
|
||||||
replies.cursor.isEnd ||
|
firstFloor = response.response.root;
|
||||||
replies.root.replies.length >= count.value;
|
}
|
||||||
}
|
List<ReplyItemModel> replies = response.response.replies;
|
||||||
if (isDialogue) {
|
count.value = response.response.page.count;
|
||||||
loadingState.value = LoadingState.success(replies.replies);
|
if (replies.isEmpty) {
|
||||||
} else {
|
isEnd = true;
|
||||||
loadingState.value = LoadingState.success(replies.root.replies);
|
}
|
||||||
|
if (currentPage != 1 && loadingState.value is Success) {
|
||||||
|
replies.insertAll(0, (loadingState.value as Success).response);
|
||||||
|
}
|
||||||
|
if (replies.length >= response.response.page.count) {
|
||||||
|
isEnd = true;
|
||||||
|
}
|
||||||
|
loadingState.value = LoadingState.success(replies);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -182,16 +174,23 @@ class VideoReplyReplyController extends CommonController
|
|||||||
mode: mode.value,
|
mode: mode.value,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: ReplyHttp.replyReplyListGrpc(
|
: GlobalData().grpcReply
|
||||||
type: replyType.index,
|
? ReplyHttp.replyReplyListGrpc(
|
||||||
oid: oid!,
|
type: replyType.index,
|
||||||
root: rpid!,
|
oid: oid!,
|
||||||
rpid: id ?? 0,
|
root: rpid!,
|
||||||
cursor: CursorReq(
|
rpid: id ?? 0,
|
||||||
next: cursor?.next,
|
cursor: CursorReq(
|
||||||
mode: mode.value,
|
next: cursor?.next,
|
||||||
),
|
mode: mode.value,
|
||||||
);
|
),
|
||||||
|
)
|
||||||
|
: ReplyHttp.replyReplyList(
|
||||||
|
oid: oid!,
|
||||||
|
root: rpid!,
|
||||||
|
pageNum: currentPage,
|
||||||
|
type: replyType.index,
|
||||||
|
);
|
||||||
|
|
||||||
queryBySort() {
|
queryBySort() {
|
||||||
mode.value = mode.value == Mode.MAIN_LIST_HOT
|
mode.value = mode.value == Mode.MAIN_LIST_HOT
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
||||||
import 'package:PiliPalaX/grpc/app/main/community/reply/v1/reply.pb.dart';
|
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/models/video/reply/item.dart';
|
||||||
|
import 'package:PiliPalaX/pages/video/detail/reply/widgets/reply_item.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/extension.dart';
|
import 'package:PiliPalaX/utils/extension.dart';
|
||||||
|
import 'package:PiliPalaX/utils/global_data.dart';
|
||||||
import 'package:PiliPalaX/utils/utils.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';
|
||||||
@@ -17,7 +20,6 @@ import 'controller.dart';
|
|||||||
|
|
||||||
class VideoReplyReplyPanel extends StatefulWidget {
|
class VideoReplyReplyPanel extends StatefulWidget {
|
||||||
const VideoReplyReplyPanel({
|
const VideoReplyReplyPanel({
|
||||||
// this.rcount,
|
|
||||||
this.id,
|
this.id,
|
||||||
this.oid,
|
this.oid,
|
||||||
this.rpid,
|
this.rpid,
|
||||||
@@ -29,12 +31,11 @@ class VideoReplyReplyPanel extends StatefulWidget {
|
|||||||
this.isTop = false,
|
this.isTop = false,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
// final dynamic rcount;
|
|
||||||
final int? id;
|
final int? id;
|
||||||
final int? oid;
|
final int? oid;
|
||||||
final int? rpid;
|
final int? rpid;
|
||||||
final int? dialog;
|
final int? dialog;
|
||||||
final ReplyInfo? firstFloor;
|
final dynamic firstFloor;
|
||||||
final String? source;
|
final String? source;
|
||||||
final ReplyType? replyType;
|
final ReplyType? replyType;
|
||||||
final bool isDialogue;
|
final bool isDialogue;
|
||||||
@@ -50,7 +51,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
late final itemPositionsListener = ItemPositionsListener.create();
|
late final itemPositionsListener = ItemPositionsListener.create();
|
||||||
late final _key = GlobalKey<ScaffoldState>();
|
late final _key = GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
ReplyInfo? get firstFloor =>
|
dynamic get firstFloor =>
|
||||||
widget.firstFloor ?? _videoReplyReplyController.firstFloor;
|
widget.firstFloor ?? _videoReplyReplyController.firstFloor;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -155,18 +156,29 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
index);
|
index);
|
||||||
} else if (firstFloor != null) {
|
} else if (firstFloor != null) {
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
return ReplyItemGrpc(
|
return GlobalData().grpcReply
|
||||||
replyItem: firstFloor!,
|
? ReplyItemGrpc(
|
||||||
replyLevel: '2',
|
replyItem: firstFloor,
|
||||||
showReplyRow: false,
|
replyLevel: '2',
|
||||||
replyType: widget.replyType,
|
showReplyRow: false,
|
||||||
needDivider: false,
|
replyType: widget.replyType,
|
||||||
onReply: () {
|
needDivider: false,
|
||||||
_onReply(firstFloor!, -1);
|
onReply: () {
|
||||||
},
|
_onReply(firstFloor, -1);
|
||||||
upMid: _videoReplyReplyController.upMid,
|
},
|
||||||
isTop: widget.isTop,
|
upMid: _videoReplyReplyController.upMid,
|
||||||
);
|
isTop: widget.isTop,
|
||||||
|
)
|
||||||
|
: ReplyItem(
|
||||||
|
replyItem: firstFloor,
|
||||||
|
replyLevel: '2',
|
||||||
|
showReplyRow: false,
|
||||||
|
replyType: widget.replyType,
|
||||||
|
needDivider: false,
|
||||||
|
onReply: () {
|
||||||
|
_onReply(firstFloor, -1);
|
||||||
|
},
|
||||||
|
);
|
||||||
} else if (index == 1) {
|
} else if (index == 1) {
|
||||||
return Divider(
|
return Divider(
|
||||||
height: 20,
|
height: 20,
|
||||||
@@ -223,30 +235,32 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
)
|
)
|
||||||
: const SizedBox.shrink(),
|
: const SizedBox.shrink(),
|
||||||
),
|
),
|
||||||
SizedBox(
|
if (GlobalData().grpcReply)
|
||||||
height: 35,
|
SizedBox(
|
||||||
child: TextButton.icon(
|
height: 35,
|
||||||
onPressed: () => _videoReplyReplyController.queryBySort(),
|
child: TextButton.icon(
|
||||||
icon: const Icon(Icons.sort, size: 16),
|
onPressed: () => _videoReplyReplyController.queryBySort(),
|
||||||
label: Obx(
|
icon: const Icon(Icons.sort, size: 16),
|
||||||
() => Text(
|
label: Obx(
|
||||||
_videoReplyReplyController.mode.value == Mode.MAIN_LIST_HOT
|
() => Text(
|
||||||
? '按热度'
|
_videoReplyReplyController.mode.value ==
|
||||||
: '按时间',
|
Mode.MAIN_LIST_HOT
|
||||||
style: const TextStyle(fontSize: 13),
|
? '按热度'
|
||||||
|
: '按时间',
|
||||||
|
style: const TextStyle(fontSize: 13),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
)
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
void _onReply(ReplyInfo? item, int index) {
|
void _onReply(dynamic item, int index) {
|
||||||
dynamic oid = item?.oid.toInt();
|
dynamic oid = item?.oid.toInt();
|
||||||
dynamic root = item?.id.toInt();
|
dynamic root = GlobalData().grpcReply ? item?.id.toInt() : item?.rpid;
|
||||||
dynamic parent = item?.id.toInt();
|
dynamic key = oid + root;
|
||||||
dynamic key = oid + root + parent;
|
|
||||||
Navigator.of(context)
|
Navigator.of(context)
|
||||||
.push(
|
.push(
|
||||||
GetDialogRoute(
|
GetDialogRoute(
|
||||||
@@ -254,7 +268,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
return ReplyPage(
|
return ReplyPage(
|
||||||
oid: oid,
|
oid: oid,
|
||||||
root: root,
|
root: root,
|
||||||
parent: parent,
|
parent: root,
|
||||||
replyType: widget.replyType,
|
replyType: widget.replyType,
|
||||||
replyItem: item,
|
replyItem: item,
|
||||||
savedReply: _savedReplies[key],
|
savedReply: _savedReplies[key],
|
||||||
@@ -282,14 +296,26 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
.then((res) {
|
.then((res) {
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
_savedReplies[key] = null;
|
_savedReplies[key] = null;
|
||||||
ReplyInfo replyInfo = Utils.replyCast(res);
|
if (GlobalData().grpcReply) {
|
||||||
List list = (_videoReplyReplyController.loadingState.value as Success?)
|
ReplyInfo replyInfo = Utils.replyCast(res);
|
||||||
?.response ??
|
List list =
|
||||||
<ReplyInfo>[];
|
(_videoReplyReplyController.loadingState.value as Success?)
|
||||||
list.insert(index + 1, replyInfo);
|
?.response ??
|
||||||
_videoReplyReplyController.count.value += 1;
|
<ReplyInfo>[];
|
||||||
_videoReplyReplyController.loadingState.value =
|
list.insert(index + 1, replyInfo);
|
||||||
LoadingState.success(list);
|
_videoReplyReplyController.count.value += 1;
|
||||||
|
_videoReplyReplyController.loadingState.value =
|
||||||
|
LoadingState.success(list);
|
||||||
|
} else {
|
||||||
|
List list =
|
||||||
|
(_videoReplyReplyController.loadingState.value as Success?)
|
||||||
|
?.response ??
|
||||||
|
<ReplyItemModel>[];
|
||||||
|
list.insert(index + 1, ReplyItemModel.fromJson(res, ''));
|
||||||
|
_videoReplyReplyController.count.value += 1;
|
||||||
|
_videoReplyReplyController.loadingState.value =
|
||||||
|
LoadingState.success(list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -361,36 +387,56 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _replyItem(replyItem, index) {
|
Widget _replyItem(replyItem, index) {
|
||||||
return ReplyItemGrpc(
|
return GlobalData().grpcReply
|
||||||
replyItem: replyItem,
|
? ReplyItemGrpc(
|
||||||
replyLevel: widget.isDialogue ? '3' : '2',
|
replyItem: replyItem,
|
||||||
showReplyRow: false,
|
replyLevel: widget.isDialogue ? '3' : '2',
|
||||||
replyType: widget.replyType,
|
showReplyRow: false,
|
||||||
onReply: () {
|
|
||||||
_onReply(replyItem, index);
|
|
||||||
},
|
|
||||||
onDelete: (rpid, frpid) {
|
|
||||||
List list =
|
|
||||||
(_videoReplyReplyController.loadingState.value as Success).response;
|
|
||||||
list = list.where((item) => item.id != rpid).toList();
|
|
||||||
_videoReplyReplyController.count.value -= 1;
|
|
||||||
_videoReplyReplyController.loadingState.value =
|
|
||||||
LoadingState.success(list);
|
|
||||||
},
|
|
||||||
upMid: _videoReplyReplyController.upMid,
|
|
||||||
showDialogue: () {
|
|
||||||
_key.currentState?.showBottomSheet(
|
|
||||||
(context) => VideoReplyReplyPanel(
|
|
||||||
oid: replyItem.oid.toInt(),
|
|
||||||
rpid: replyItem.root.toInt(),
|
|
||||||
dialog: replyItem.dialog.toInt(),
|
|
||||||
replyType: widget.replyType,
|
replyType: widget.replyType,
|
||||||
source: 'videoDetail',
|
onReply: () {
|
||||||
isDialogue: true,
|
_onReply(replyItem, index);
|
||||||
),
|
},
|
||||||
);
|
onDelete: (rpid, frpid) {
|
||||||
},
|
List list =
|
||||||
);
|
(_videoReplyReplyController.loadingState.value as Success)
|
||||||
|
.response;
|
||||||
|
list = list.where((item) => item.id != rpid).toList();
|
||||||
|
_videoReplyReplyController.count.value -= 1;
|
||||||
|
_videoReplyReplyController.loadingState.value =
|
||||||
|
LoadingState.success(list);
|
||||||
|
},
|
||||||
|
upMid: _videoReplyReplyController.upMid,
|
||||||
|
showDialogue: () {
|
||||||
|
_key.currentState?.showBottomSheet(
|
||||||
|
(context) => VideoReplyReplyPanel(
|
||||||
|
oid: replyItem.oid.toInt(),
|
||||||
|
rpid: replyItem.root.toInt(),
|
||||||
|
dialog: replyItem.dialog.toInt(),
|
||||||
|
replyType: widget.replyType,
|
||||||
|
source: 'videoDetail',
|
||||||
|
isDialogue: true,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: ReplyItem(
|
||||||
|
replyItem: replyItem,
|
||||||
|
replyLevel: '2',
|
||||||
|
showReplyRow: false,
|
||||||
|
replyType: widget.replyType,
|
||||||
|
onReply: () {
|
||||||
|
_onReply(replyItem, index);
|
||||||
|
},
|
||||||
|
onDelete: (rpid, frpid) {
|
||||||
|
List list =
|
||||||
|
(_videoReplyReplyController.loadingState.value as Success)
|
||||||
|
.response;
|
||||||
|
list.removeWhere((item) => item.rpid == rpid);
|
||||||
|
_videoReplyReplyController.count.value -= 1;
|
||||||
|
_videoReplyReplyController.loadingState.value =
|
||||||
|
LoadingState.success(list);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
int _itemCount(LoadingState loadingState) {
|
int _itemCount(LoadingState loadingState) {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import 'package:PiliPalaX/pages/video/detail/introduction/widgets/intro_detail.d
|
|||||||
import 'package:PiliPalaX/pages/video/detail/reply_reply/view.dart';
|
import 'package:PiliPalaX/pages/video/detail/reply_reply/view.dart';
|
||||||
import 'package:PiliPalaX/pages/video/detail/widgets/ai_detail.dart';
|
import 'package:PiliPalaX/pages/video/detail/widgets/ai_detail.dart';
|
||||||
import 'package:PiliPalaX/utils/extension.dart';
|
import 'package:PiliPalaX/utils/extension.dart';
|
||||||
|
import 'package:PiliPalaX/utils/global_data.dart';
|
||||||
import 'package:PiliPalaX/utils/id_utils.dart';
|
import 'package:PiliPalaX/utils/id_utils.dart';
|
||||||
import 'package:auto_orientation/auto_orientation.dart';
|
import 'package:auto_orientation/auto_orientation.dart';
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
@@ -1314,16 +1315,17 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
// 展示二级回复
|
// 展示二级回复
|
||||||
void replyReply(replyItem, id, isTop) {
|
void replyReply(replyItem, id, isTop) {
|
||||||
EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () {
|
EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () {
|
||||||
|
int oid = replyItem.oid.toInt();
|
||||||
|
int rpid = GlobalData().grpcReply ? replyItem.id.toInt() : replyItem.rpid;
|
||||||
videoDetailController.childKey.currentState?.showBottomSheet(
|
videoDetailController.childKey.currentState?.showBottomSheet(
|
||||||
(context) => VideoReplyReplyPanel(
|
(context) => VideoReplyReplyPanel(
|
||||||
id: id,
|
id: id,
|
||||||
// rcount: replyItem.rcount,
|
oid: oid,
|
||||||
oid: replyItem.oid.toInt(),
|
rpid: rpid,
|
||||||
rpid: replyItem.id.toInt(),
|
|
||||||
firstFloor: replyItem,
|
firstFloor: replyItem,
|
||||||
replyType: ReplyType.video,
|
replyType: ReplyType.video,
|
||||||
source: 'videoDetail',
|
source: 'videoDetail',
|
||||||
isTop: isTop,
|
isTop: isTop ?? false,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ class GlobalData {
|
|||||||
|
|
||||||
int themeMode = 2;
|
int themeMode = 2;
|
||||||
|
|
||||||
|
bool grpcReply = true;
|
||||||
|
|
||||||
// 私有构造函数
|
// 私有构造函数
|
||||||
GlobalData._();
|
GlobalData._();
|
||||||
|
|
||||||
|
|||||||
@@ -99,6 +99,9 @@ class GStorage {
|
|||||||
static double get danmakuFontScaleFS =>
|
static double get danmakuFontScaleFS =>
|
||||||
setting.get(SettingBoxKey.danmakuFontScaleFS, defaultValue: 1.2);
|
setting.get(SettingBoxKey.danmakuFontScaleFS, defaultValue: 1.2);
|
||||||
|
|
||||||
|
static bool get grpcReply =>
|
||||||
|
setting.get(SettingBoxKey.grpcReply, defaultValue: true);
|
||||||
|
|
||||||
static MemberTabType get memberTab => MemberTabType
|
static MemberTabType get memberTab => MemberTabType
|
||||||
.values[setting.get(SettingBoxKey.memberTab, defaultValue: 0)];
|
.values[setting.get(SettingBoxKey.memberTab, defaultValue: 0)];
|
||||||
|
|
||||||
@@ -157,6 +160,7 @@ class GStorage {
|
|||||||
SettingBoxKey.themeMode,
|
SettingBoxKey.themeMode,
|
||||||
defaultValue: ThemeType.system.code,
|
defaultValue: ThemeType.system.code,
|
||||||
);
|
);
|
||||||
|
GlobalData().grpcReply = grpcReply;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<String> exportAllSettings() async {
|
static Future<String> exportAllSettings() async {
|
||||||
@@ -274,7 +278,8 @@ class SettingBoxKey {
|
|||||||
previewQuality = 'previewQuality',
|
previewQuality = 'previewQuality',
|
||||||
checkDynamic = 'checkDynamic',
|
checkDynamic = 'checkDynamic',
|
||||||
dynamicPeriod = 'dynamicPeriod',
|
dynamicPeriod = 'dynamicPeriod',
|
||||||
schemeVariant = 'schemeVariaznt',
|
schemeVariant = 'schemeVariant',
|
||||||
|
grpcReply = 'grpcReply',
|
||||||
|
|
||||||
// Sponsor Block
|
// Sponsor Block
|
||||||
enableSponsorBlock = 'enableSponsorBlock',
|
enableSponsorBlock = 'enableSponsorBlock',
|
||||||
|
|||||||
Reference in New Issue
Block a user