Merge branch 'design'
This commit is contained in:
@ -106,7 +106,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
}
|
||||
|
||||
// 查看二级评论
|
||||
void replyReply(replyItem) {
|
||||
void replyReply(replyItem, currentReply) {
|
||||
int oid = replyItem.oid;
|
||||
int rpid = replyItem.rpid!;
|
||||
Get.to(
|
||||
@ -324,8 +324,8 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
replyItem: replyList[index],
|
||||
showReplyRow: true,
|
||||
replyLevel: '1',
|
||||
replyReply: (replyItem) =>
|
||||
replyReply(replyItem),
|
||||
replyReply: (replyItem, currentReply) =>
|
||||
replyReply(replyItem, currentReply),
|
||||
replyType: ReplyType.values[replyType],
|
||||
addReply: (replyItem) {
|
||||
replyList[index]
|
||||
|
@ -162,7 +162,7 @@ class VideoDetailController extends GetxController
|
||||
);
|
||||
}
|
||||
|
||||
showReplyReplyPanel(oid, fRpid, firstFloor) {
|
||||
showReplyReplyPanel(oid, fRpid, firstFloor, currentReply, loadMore) {
|
||||
replyReplyBottomSheetCtr =
|
||||
scaffoldKey.currentState?.showBottomSheet((BuildContext context) {
|
||||
return VideoReplyReplyPanel(
|
||||
@ -175,6 +175,8 @@ class VideoDetailController extends GetxController
|
||||
replyType: ReplyType.video,
|
||||
source: 'videoDetail',
|
||||
sheetHeight: sheetHeight.value,
|
||||
currentReply: currentReply,
|
||||
loadMore: loadMore,
|
||||
);
|
||||
});
|
||||
replyReplyBottomSheetCtr?.closed.then((value) {
|
||||
|
@ -112,7 +112,7 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
}
|
||||
|
||||
// 展示二级回复
|
||||
void replyReply(replyItem) {
|
||||
void replyReply(replyItem, currentReply, loadMore) {
|
||||
final VideoDetailController videoDetailCtr =
|
||||
Get.find<VideoDetailController>(tag: heroTag);
|
||||
if (replyItem != null) {
|
||||
@ -120,7 +120,7 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
videoDetailCtr.fRpid = replyItem.rpid!;
|
||||
videoDetailCtr.firstFloor = replyItem;
|
||||
videoDetailCtr.showReplyReplyPanel(
|
||||
replyItem.oid, replyItem.rpid!, replyItem);
|
||||
replyItem.oid, replyItem.rpid!, replyItem, currentReply, loadMore);
|
||||
}
|
||||
}
|
||||
|
||||
@ -232,8 +232,10 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
.replyList[index],
|
||||
showReplyRow: true,
|
||||
replyLevel: replyLevel,
|
||||
replyReply: (replyItem) =>
|
||||
replyReply(replyItem),
|
||||
replyReply: (replyItem, currentReply,
|
||||
loadMore) =>
|
||||
replyReply(replyItem, currentReply,
|
||||
loadMore),
|
||||
replyType: ReplyType.video,
|
||||
);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ class ReplyItem extends StatelessWidget {
|
||||
onTap: () {
|
||||
feedBack();
|
||||
if (replyReply != null) {
|
||||
replyReply!(replyItem);
|
||||
replyReply!(replyItem, null, replyItem!.replies!.isNotEmpty);
|
||||
}
|
||||
},
|
||||
onLongPress: () {
|
||||
@ -362,9 +362,13 @@ class ReplyItemRow extends StatelessWidget {
|
||||
for (int i = 0; i < replies!.length; i++) ...[
|
||||
InkWell(
|
||||
// 一楼点击评论展开评论详情
|
||||
// onTap: () {
|
||||
// replyReply?.call(replyItem);
|
||||
// },
|
||||
onTap: () {
|
||||
replyReply?.call(
|
||||
replyItem,
|
||||
replies![i],
|
||||
replyItem!.replies!.isNotEmpty,
|
||||
);
|
||||
},
|
||||
onLongPress: () {
|
||||
feedBack();
|
||||
showModalBottomSheet(
|
||||
@ -535,9 +539,12 @@ InlineSpan buildContent(
|
||||
spanChilds.add(
|
||||
TextSpan(
|
||||
text: str,
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () =>
|
||||
replyReply?.call(replyItem.root == 0 ? replyItem : fReplyItem),
|
||||
// recognizer: TapGestureRecognizer()
|
||||
// ..onTap = () => replyReply?.call(
|
||||
// replyItem.root == 0 ? replyItem : fReplyItem,
|
||||
// replyItem,
|
||||
// fReplyItem!.replies!.isNotEmpty,
|
||||
// ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ class VideoReplyReplyController extends GetxController {
|
||||
currentPage = 0;
|
||||
}
|
||||
|
||||
Future queryReplyList({type = 'init'}) async {
|
||||
Future queryReplyList({type = 'init', currentReply}) async {
|
||||
if (type == 'init') {
|
||||
currentPage = 0;
|
||||
}
|
||||
@ -63,6 +63,17 @@ class VideoReplyReplyController extends GetxController {
|
||||
// res['data'].replies.addAll(replyList);
|
||||
}
|
||||
}
|
||||
if (replyList.isNotEmpty && currentReply != null) {
|
||||
int indexToRemove =
|
||||
replyList.indexWhere((item) => currentReply.rpid == item.rpid);
|
||||
// 如果找到了指定ID的项,则移除
|
||||
if (indexToRemove != -1) {
|
||||
replyList.removeAt(indexToRemove);
|
||||
}
|
||||
if (currentPage == 1 && type == 'init') {
|
||||
replyList.insert(0, currentReply);
|
||||
}
|
||||
}
|
||||
isLoadingMore = false;
|
||||
return res;
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ class VideoReplyReplyPanel extends StatefulWidget {
|
||||
this.source,
|
||||
this.replyType,
|
||||
this.sheetHeight,
|
||||
this.currentReply,
|
||||
this.loadMore,
|
||||
super.key,
|
||||
});
|
||||
final int? oid;
|
||||
@ -29,6 +31,8 @@ class VideoReplyReplyPanel extends StatefulWidget {
|
||||
final String? source;
|
||||
final ReplyType? replyType;
|
||||
final double? sheetHeight;
|
||||
final dynamic currentReply;
|
||||
final bool? loadMore;
|
||||
|
||||
@override
|
||||
State<VideoReplyReplyPanel> createState() => _VideoReplyReplyPanelState();
|
||||
@ -63,7 +67,9 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
},
|
||||
);
|
||||
|
||||
_futureBuilderFuture = _videoReplyReplyController.queryReplyList();
|
||||
_futureBuilderFuture = _videoReplyReplyController.queryReplyList(
|
||||
currentReply: widget.currentReply,
|
||||
);
|
||||
}
|
||||
|
||||
void replyReply(replyItem) {}
|
||||
@ -107,7 +113,9 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
onRefresh: () async {
|
||||
setState(() {});
|
||||
_videoReplyReplyController.currentPage = 0;
|
||||
return await _videoReplyReplyController.queryReplyList();
|
||||
return await _videoReplyReplyController.queryReplyList(
|
||||
currentReply: widget.currentReply,
|
||||
);
|
||||
},
|
||||
child: CustomScrollView(
|
||||
controller: _videoReplyReplyController.scrollController,
|
||||
@ -134,84 +142,102 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
),
|
||||
),
|
||||
],
|
||||
FutureBuilder(
|
||||
future: _futureBuilderFuture,
|
||||
builder: (BuildContext context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
Map? data = snapshot.data;
|
||||
if (data != null && data['status']) {
|
||||
// 请求成功
|
||||
return Obx(
|
||||
() => SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
if (index ==
|
||||
_videoReplyReplyController
|
||||
.replyList.length) {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(context)
|
||||
.padding
|
||||
.bottom),
|
||||
height: MediaQuery.of(context)
|
||||
.padding
|
||||
.bottom +
|
||||
100,
|
||||
child: Center(
|
||||
child: Obx(
|
||||
() => Text(
|
||||
widget.loadMore != null && widget.loadMore!
|
||||
? FutureBuilder(
|
||||
future: _futureBuilderFuture,
|
||||
builder: (BuildContext context, snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
ConnectionState.done) {
|
||||
Map? data = snapshot.data;
|
||||
if (data != null && data['status']) {
|
||||
// 请求成功
|
||||
return Obx(
|
||||
() => SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
if (index ==
|
||||
_videoReplyReplyController
|
||||
.noMore.value,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline,
|
||||
.replyList.length) {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(context)
|
||||
.padding
|
||||
.bottom),
|
||||
height: MediaQuery.of(context)
|
||||
.padding
|
||||
.bottom +
|
||||
100,
|
||||
child: Center(
|
||||
child: Obx(
|
||||
() => Text(
|
||||
_videoReplyReplyController
|
||||
.noMore.value,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return ReplyItem(
|
||||
replyItem: _videoReplyReplyController
|
||||
.replyList[index],
|
||||
replyLevel: '2',
|
||||
showReplyRow: false,
|
||||
addReply: (replyItem) {
|
||||
_videoReplyReplyController.replyList
|
||||
.add(replyItem);
|
||||
);
|
||||
} else {
|
||||
return ReplyItem(
|
||||
replyItem:
|
||||
_videoReplyReplyController
|
||||
.replyList[index],
|
||||
replyLevel: '2',
|
||||
showReplyRow: false,
|
||||
addReply: (replyItem) {
|
||||
_videoReplyReplyController
|
||||
.replyList
|
||||
.add(replyItem);
|
||||
},
|
||||
replyType: widget.replyType,
|
||||
replyReply: (replyItem) =>
|
||||
replyReply(replyItem),
|
||||
);
|
||||
}
|
||||
},
|
||||
replyType: widget.replyType,
|
||||
replyReply: (replyItem) =>
|
||||
replyReply(replyItem),
|
||||
);
|
||||
}
|
||||
},
|
||||
childCount: _videoReplyReplyController
|
||||
.replyList.length +
|
||||
1,
|
||||
childCount: _videoReplyReplyController
|
||||
.replyList.length +
|
||||
1,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
// 请求错误
|
||||
return HttpError(
|
||||
errMsg: data?['msg'] ?? '请求错误',
|
||||
fn: () => setState(() {}),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// 骨架屏
|
||||
return SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
return const VideoReplySkeleton();
|
||||
}, childCount: 8),
|
||||
);
|
||||
}
|
||||
},
|
||||
)
|
||||
: SliverToBoxAdapter(
|
||||
child: SizedBox(
|
||||
height: 200,
|
||||
child: Center(
|
||||
child: Text(
|
||||
'还没有评论',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
// 请求错误
|
||||
return HttpError(
|
||||
errMsg: data?['msg'] ?? '请求错误',
|
||||
fn: () => setState(() {}),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// 骨架屏
|
||||
return SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
return const VideoReplySkeleton();
|
||||
}, childCount: 8),
|
||||
);
|
||||
}
|
||||
},
|
||||
)
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
Reference in New Issue
Block a user