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,208 +211,194 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
onRefresh: () async { onRefresh: () async {
await _dynamicDetailController.queryReplyList(); await _dynamicDetailController.queryReplyList();
}, },
child: Stack( child: CustomScrollView(
children: [ controller: scrollController,
CustomScrollView( slivers: [
controller: scrollController, if (action != 'comment')
slivers: [ SliverToBoxAdapter(
if (action != 'comment') child: DynamicPanel(
SliverToBoxAdapter( item: _dynamicDetailController.item,
child: DynamicPanel( source: 'detail',
item: _dynamicDetailController.item, ),
source: 'detail', ),
SliverPersistentHeader(
delegate: _MySliverPersistentHeaderDelegate(
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
border: Border(
top: BorderSide(
width: 0.6,
color: Theme.of(context).dividerColor.withOpacity(0.05),
),
), ),
), ),
SliverPersistentHeader( height: 45,
delegate: _MySliverPersistentHeaderDelegate( padding: const EdgeInsets.only(left: 12, right: 6),
child: Container( child: Row(
decoration: BoxDecoration( children: [
color: Theme.of(context).colorScheme.surface, Obx(
border: Border( () => AnimatedSwitcher(
top: BorderSide( duration: const Duration(milliseconds: 400),
width: 0.6, transitionBuilder:
color: Theme.of(context) (Widget child, Animation<double> animation) {
.dividerColor return ScaleTransition(
.withOpacity(0.05), scale: animation, child: child);
},
child: Text(
'${_dynamicDetailController.acount.value}',
key: ValueKey<int>(
_dynamicDetailController.acount.value),
), ),
), ),
), ),
height: 45, const Text('条回复'),
padding: const EdgeInsets.only(left: 12, right: 6), const Spacer(),
child: Row( SizedBox(
children: [ height: 35,
Obx( child: TextButton.icon(
() => AnimatedSwitcher( onPressed: () =>
duration: const Duration(milliseconds: 400), _dynamicDetailController.queryBySort(),
transitionBuilder: icon: const Icon(Icons.sort, size: 16),
(Widget child, Animation<double> animation) { label: Obx(() => Text(
return ScaleTransition( _dynamicDetailController.sortTypeLabel.value,
scale: animation, child: child); style: const TextStyle(fontSize: 13),
}, )),
child: Text( ),
'${_dynamicDetailController.acount.value}', )
key: ValueKey<int>( ],
_dynamicDetailController.acount.value),
),
),
),
const Text('条回复'),
const Spacer(),
SizedBox(
height: 35,
child: TextButton.icon(
onPressed: () =>
_dynamicDetailController.queryBySort(),
icon: const Icon(Icons.sort, size: 16),
label: Obx(() => Text(
_dynamicDetailController
.sortTypeLabel.value,
style: const TextStyle(fontSize: 13),
)),
),
)
],
),
),
), ),
pinned: true,
),
FutureBuilder(
future: _futureBuilderFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
Map data = snapshot.data as Map;
if (snapshot.data['status']) {
// 请求成功
return Obx(
() => _dynamicDetailController.replyList.isEmpty &&
_dynamicDetailController.isLoadingMore
? SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return const VideoReplySkeleton();
}, childCount: 8),
)
: SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index ==
_dynamicDetailController
.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(
_dynamicDetailController
.noMore.value,
style: TextStyle(
fontSize: 12,
color: Theme.of(context)
.colorScheme
.outline,
),
),
),
),
);
} else {
return ReplyItem(
replyItem: _dynamicDetailController
.replyList[index],
showReplyRow: true,
replyLevel: '1',
replyReply: (replyItem) =>
replyReply(replyItem),
replyType:
ReplyType.values[replyType],
addReply: (replyItem) {
_dynamicDetailController
.replyList[index].replies!
.add(replyItem);
},
);
}
},
childCount: _dynamicDetailController
.replyList.length +
1,
),
),
);
} else {
// 请求错误
return HttpError(
errMsg: data['msg'],
fn: () => setState(() {}),
);
}
} else {
// 骨架屏
return SliverList(
delegate: SliverChildBuilderDelegate((context, index) {
return const VideoReplySkeleton();
}, childCount: 8),
);
}
},
)
],
),
Positioned(
bottom: MediaQuery.of(context).padding.bottom + 14,
right: 14,
child: SlideTransition(
position: Tween<Offset>(
begin: const Offset(0, 2),
end: const Offset(0, 0),
).animate(CurvedAnimation(
parent: fabAnimationCtr,
curve: Curves.easeInOut,
)),
child: FloatingActionButton(
heroTag: null,
onPressed: () {
feedBack();
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (BuildContext context) {
return VideoReplyNewDialog(
oid: _dynamicDetailController.oid ??
IdUtils.bv2av(Get.parameters['bvid']!),
root: 0,
parent: 0,
replyType: ReplyType.values[replyType],
);
},
).then(
(value) => {
// 完成评论,数据添加
if (value != null && value['data'] != null)
{
_dynamicDetailController.replyList
.add(value['data']),
_dynamicDetailController.acount.value++
}
},
);
},
tooltip: '评论动态',
child: const Icon(Icons.reply),
), ),
), ),
pinned: true,
), ),
FutureBuilder(
future: _futureBuilderFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
Map data = snapshot.data as Map;
if (snapshot.data['status']) {
RxList<ReplyItemModel> replyList =
_dynamicDetailController.replyList;
// 请求成功
return Obx(
() => replyList.isEmpty &&
_dynamicDetailController.isLoadingMore
? SliverList(
delegate:
SliverChildBuilderDelegate((context, index) {
return const VideoReplySkeleton();
}, childCount: 8),
)
: SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index == 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(
_dynamicDetailController
.noMore.value,
style: TextStyle(
fontSize: 12,
color: Theme.of(context)
.colorScheme
.outline,
),
),
),
),
);
} else {
return ReplyItem(
replyItem: replyList[index],
showReplyRow: true,
replyLevel: '1',
replyReply: (replyItem) =>
replyReply(replyItem),
replyType: ReplyType.values[replyType],
addReply: (replyItem) {
replyList[index]
.replies!
.add(replyItem);
},
);
}
},
childCount: replyList.length + 1,
),
),
);
} else {
// 请求错误
return HttpError(
errMsg: data['msg'],
fn: () => setState(() {}),
);
}
} else {
// 骨架屏
return SliverList(
delegate: SliverChildBuilderDelegate((context, index) {
return const VideoReplySkeleton();
}, childCount: 8),
);
}
},
)
], ],
), ),
), ),
floatingActionButton: SlideTransition(
position: Tween<Offset>(
begin: const Offset(0, 2),
end: const Offset(0, 0),
).animate(
CurvedAnimation(
parent: fabAnimationCtr,
curve: Curves.easeInOut,
),
),
child: FloatingActionButton(
heroTag: null,
onPressed: () {
feedBack();
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (BuildContext context) {
return VideoReplyNewDialog(
oid: _dynamicDetailController.oid ??
IdUtils.bv2av(Get.parameters['bvid']!),
root: 0,
parent: 0,
replyType: ReplyType.values[replyType],
);
},
).then(
(value) => {
// 完成评论,数据添加
if (value != null && value['data'] != null)
{
_dynamicDetailController.replyList.add(value['data']),
_dynamicDetailController.acount.value++
}
},
);
},
tooltip: '评论动态',
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,76 +79,59 @@ 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 =
style: TextStyle( Get.find<VideoDetailController>(
fontSize: 13, tag: Get.arguments['heroTag'],
color: Theme.of(context) );
.colorScheme controller.plPlayerController.seekTo(
.onBackground, Duration(
height: 1.5, seconds: Utils.duration(
Utils.tampToSeektime(
part.timestamp!),
).toInt(),
), ),
children: [ );
TextSpan( } catch (_) {}
text: Utils.tampToSeektime( },
modelResult! child: SelectableText.rich(
.outline![index] TextSpan(
.partOutline![i] style: TextStyle(
.timestamp!), fontSize: 13,
style: TextStyle( color: Theme.of(context)
color: Theme.of(context) .colorScheme
.colorScheme .onBackground,
.primary, height: 1.5,
),
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: ' '),
TextSpan(
text: modelResult!
.outline![index]
.partOutline![i]
.content!),
],
), ),
children: [
TextSpan(
text: Utils.tampToSeektime(
part.timestamp!),
style: TextStyle(
color: Theme.of(context)
.colorScheme
.primary,
),
),
const TextSpan(text: ' '),
TextSpan(text: part.content!),
],
), ),
], ),
), ),
const SizedBox(height: 20),
], ],
); );
}, },
), ),
const SizedBox(height: 20),
], ],
); );
}, },