Merge branch 'main' into fix

This commit is contained in:
guozhigq
2024-04-19 23:28:00 +08:00
2 changed files with 224 additions and 252 deletions

View File

@ -16,6 +16,7 @@ import 'package:pilipala/pages/video/detail/reply_reply/index.dart';
import 'package:pilipala/utils/feed_back.dart'; import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/id_utils.dart'; import 'package:pilipala/utils/id_utils.dart';
import '../../../models/video/reply/item.dart';
import '../widgets/dynamic_panel.dart'; import '../widgets/dynamic_panel.dart';
class DynamicDetailPage extends StatefulWidget { class DynamicDetailPage extends StatefulWidget {
@ -210,9 +211,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
onRefresh: () async { onRefresh: () async {
await _dynamicDetailController.queryReplyList(); await _dynamicDetailController.queryReplyList();
}, },
child: Stack( child: CustomScrollView(
children: [
CustomScrollView(
controller: scrollController, controller: scrollController,
slivers: [ slivers: [
if (action != 'comment') if (action != 'comment')
@ -230,9 +229,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
border: Border( border: Border(
top: BorderSide( top: BorderSide(
width: 0.6, width: 0.6,
color: Theme.of(context) color: Theme.of(context).dividerColor.withOpacity(0.05),
.dividerColor
.withOpacity(0.05),
), ),
), ),
), ),
@ -264,8 +261,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
_dynamicDetailController.queryBySort(), _dynamicDetailController.queryBySort(),
icon: const Icon(Icons.sort, size: 16), icon: const Icon(Icons.sort, size: 16),
label: Obx(() => Text( label: Obx(() => Text(
_dynamicDetailController _dynamicDetailController.sortTypeLabel.value,
.sortTypeLabel.value,
style: const TextStyle(fontSize: 13), style: const TextStyle(fontSize: 13),
)), )),
), ),
@ -282,22 +278,22 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
if (snapshot.connectionState == ConnectionState.done) { if (snapshot.connectionState == ConnectionState.done) {
Map data = snapshot.data as Map; Map data = snapshot.data as Map;
if (snapshot.data['status']) { if (snapshot.data['status']) {
RxList<ReplyItemModel> replyList =
_dynamicDetailController.replyList;
// 请求成功 // 请求成功
return Obx( return Obx(
() => _dynamicDetailController.replyList.isEmpty && () => replyList.isEmpty &&
_dynamicDetailController.isLoadingMore _dynamicDetailController.isLoadingMore
? SliverList( ? SliverList(
delegate: SliverChildBuilderDelegate( delegate:
(context, index) { SliverChildBuilderDelegate((context, index) {
return const VideoReplySkeleton(); return const VideoReplySkeleton();
}, childCount: 8), }, childCount: 8),
) )
: SliverList( : SliverList(
delegate: SliverChildBuilderDelegate( delegate: SliverChildBuilderDelegate(
(context, index) { (context, index) {
if (index == if (index == replyList.length) {
_dynamicDetailController
.replyList.length) {
return Container( return Container(
padding: EdgeInsets.only( padding: EdgeInsets.only(
bottom: MediaQuery.of(context) bottom: MediaQuery.of(context)
@ -324,25 +320,21 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
); );
} else { } else {
return ReplyItem( return ReplyItem(
replyItem: _dynamicDetailController replyItem: replyList[index],
.replyList[index],
showReplyRow: true, showReplyRow: true,
replyLevel: '1', replyLevel: '1',
replyReply: (replyItem) => replyReply: (replyItem) =>
replyReply(replyItem), replyReply(replyItem),
replyType: replyType: ReplyType.values[replyType],
ReplyType.values[replyType],
addReply: (replyItem) { addReply: (replyItem) {
_dynamicDetailController replyList[index]
.replyList[index].replies! .replies!
.add(replyItem); .add(replyItem);
}, },
); );
} }
}, },
childCount: _dynamicDetailController childCount: replyList.length + 1,
.replyList.length +
1,
), ),
), ),
); );
@ -365,17 +357,17 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
) )
], ],
), ),
Positioned( ),
bottom: MediaQuery.of(context).padding.bottom + 14, floatingActionButton: SlideTransition(
right: 14,
child: SlideTransition(
position: Tween<Offset>( position: Tween<Offset>(
begin: const Offset(0, 2), begin: const Offset(0, 2),
end: const Offset(0, 0), end: const Offset(0, 0),
).animate(CurvedAnimation( ).animate(
CurvedAnimation(
parent: fabAnimationCtr, parent: fabAnimationCtr,
curve: Curves.easeInOut, curve: Curves.easeInOut,
)), ),
),
child: FloatingActionButton( child: FloatingActionButton(
heroTag: null, heroTag: null,
onPressed: () { onPressed: () {
@ -397,8 +389,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
// 完成评论,数据添加 // 完成评论,数据添加
if (value != null && value['data'] != null) if (value != null && value['data'] != null)
{ {
_dynamicDetailController.replyList _dynamicDetailController.replyList.add(value['data']),
.add(value['data']),
_dynamicDetailController.acount.value++ _dynamicDetailController.acount.value++
} }
}, },
@ -408,10 +399,6 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
child: const Icon(Icons.reply), child: const Icon(Icons.reply),
), ),
), ),
),
],
),
),
); );
} }
} }

View File

@ -49,7 +49,7 @@ class AiDetail extends StatelessWidget {
child: SingleChildScrollView( child: SingleChildScrollView(
child: Column( child: Column(
children: [ children: [
Text( SelectableText(
modelResult!.summary!, modelResult!.summary!,
style: const TextStyle( style: const TextStyle(
fontSize: 15, fontSize: 15,
@ -60,13 +60,15 @@ class AiDetail extends StatelessWidget {
const SizedBox(height: 20), const SizedBox(height: 20),
ListView.builder( ListView.builder(
shrinkWrap: true, shrinkWrap: true,
itemCount: modelResult!.outline!.length,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
itemCount: modelResult!.outline!.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final outline = modelResult!.outline![index];
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( SelectableText(
modelResult!.outline![index].title!, outline.title!,
style: const TextStyle( style: const TextStyle(
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -77,16 +79,31 @@ class AiDetail extends StatelessWidget {
ListView.builder( ListView.builder(
shrinkWrap: true, shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
itemCount: modelResult! itemCount: outline.partOutline!.length,
.outline![index].partOutline!.length,
itemBuilder: (context, i) { itemBuilder: (context, i) {
final part = outline.partOutline![i];
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Wrap( GestureDetector(
children: [ onTap: () {
RichText( try {
text: TextSpan( final controller =
Get.find<VideoDetailController>(
tag: Get.arguments['heroTag'],
);
controller.plPlayerController.seekTo(
Duration(
seconds: Utils.duration(
Utils.tampToSeektime(
part.timestamp!),
).toInt(),
),
);
} catch (_) {}
},
child: SelectableText.rich(
TextSpan(
style: TextStyle( style: TextStyle(
fontSize: 13, fontSize: 13,
color: Theme.of(context) color: Theme.of(context)
@ -97,56 +114,24 @@ class AiDetail extends StatelessWidget {
children: [ children: [
TextSpan( TextSpan(
text: Utils.tampToSeektime( text: Utils.tampToSeektime(
modelResult! part.timestamp!),
.outline![index]
.partOutline![i]
.timestamp!),
style: TextStyle( style: TextStyle(
color: Theme.of(context) color: Theme.of(context)
.colorScheme .colorScheme
.primary, .primary,
), ),
recognizer: TapGestureRecognizer()
..onTap = () {
// 跳转到指定位置
try {
Get.find<VideoDetailController>(
tag: Get.arguments[
'heroTag'])
.plPlayerController
.seekTo(
Duration(
seconds:
Utils.duration(
Utils.tampToSeektime(modelResult!
.outline![
index]
.partOutline![
i]
.timestamp!)
.toString(),
),
),
);
} catch (_) {}
},
), ),
const TextSpan(text: ' '), const TextSpan(text: ' '),
TextSpan( TextSpan(text: part.content!),
text: modelResult!
.outline![index]
.partOutline![i]
.content!),
], ],
), ),
), ),
],
), ),
const SizedBox(height: 20),
], ],
); );
}, },
), ),
const SizedBox(height: 20),
], ],
); );
}, },