feat: show aiConclusion (#1698)

This commit is contained in:
My-Responsitories
2025-10-25 14:54:21 +08:00
committed by GitHub
parent ccb61415f5
commit 1a9d8e35ba
3 changed files with 191 additions and 114 deletions

View File

@@ -18,6 +18,118 @@ class AiConclusionPanel extends CommonSlidePage {
@override
State<AiConclusionPanel> createState() => _AiDetailState();
static Widget buildContent(
BuildContext context,
ThemeData theme,
AiConclusionResult res, {
Key? key,
bool tap = true,
}) {
return CustomScrollView(
key: key,
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
if (res.summary?.isNotEmpty == true) ...[
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 14),
child: selectableText(
res.summary!,
style: const TextStyle(
fontSize: 15,
height: 1.5,
),
),
),
),
if (res.outline?.isNotEmpty == true)
SliverToBoxAdapter(
child: Divider(
height: 20,
color: theme.dividerColor.withValues(alpha: 0.1),
thickness: 6,
),
),
],
if (res.outline?.isNotEmpty == true)
SliverPadding(
padding: EdgeInsets.only(
left: 14,
right: 14,
bottom: MediaQuery.viewPaddingOf(context).bottom + 100,
),
sliver: SliverList.builder(
itemCount: res.outline!.length,
itemBuilder: (context, index) {
final item = res.outline![index];
return SelectionArea(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (index != 0) const SizedBox(height: 10),
Text(
item.title!,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
height: 1.5,
),
),
const SizedBox(height: 6),
...?item.partOutline?.map(
(item) => Wrap(
children: [
Text.rich(
TextSpan(
style: TextStyle(
fontSize: 14,
color: theme.colorScheme.onSurface,
height: 1.5,
),
children: [
TextSpan(
text: DurationUtils.formatDuration(
item.timestamp,
),
style: tap
? TextStyle(
color: theme.colorScheme.primary,
)
: null,
recognizer: tap
? (TapGestureRecognizer()
..onTap = () {
try {
Get.find<VideoDetailController>(
tag: Get.arguments['heroTag'],
).plPlayerController.seekTo(
Duration(
seconds: item.timestamp!,
),
isSeek: false,
);
} catch (_) {}
})
: null,
),
const TextSpan(text: ' '),
TextSpan(text: item.content!),
],
),
),
],
),
),
],
),
);
},
),
),
],
);
}
}
class _AiDetailState extends State<AiConclusionPanel>
@@ -65,102 +177,11 @@ class _AiDetailState extends State<AiConclusionPanel>
@override
Widget buildList(ThemeData theme) {
final child = CustomScrollView(
final child = AiConclusionPanel.buildContent(
context,
theme,
widget.item,
key: _key,
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
if (widget.item.summary?.isNotEmpty == true) ...[
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 14),
child: selectableText(
widget.item.summary!,
style: const TextStyle(
fontSize: 15,
height: 1.5,
),
),
),
),
if (widget.item.outline?.isNotEmpty == true)
SliverToBoxAdapter(
child: Divider(
height: 20,
color: theme.dividerColor.withValues(alpha: 0.1),
thickness: 6,
),
),
],
if (widget.item.outline?.isNotEmpty == true)
SliverPadding(
padding: EdgeInsets.only(
left: 14,
right: 14,
bottom: MediaQuery.viewPaddingOf(context).bottom + 100,
),
sliver: SliverList.builder(
itemCount: widget.item.outline!.length,
itemBuilder: (context, index) {
final item = widget.item.outline![index];
return SelectionArea(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (index != 0) const SizedBox(height: 10),
Text(
item.title!,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
height: 1.5,
),
),
const SizedBox(height: 6),
...?item.partOutline?.map(
(item) => Wrap(
children: [
Text.rich(
TextSpan(
style: TextStyle(
fontSize: 14,
color: theme.colorScheme.onSurface,
height: 1.5,
),
children: [
TextSpan(
text: DurationUtils.formatDuration(
item.timestamp,
),
style: TextStyle(
color: theme.colorScheme.primary,
),
recognizer: TapGestureRecognizer()
..onTap = () {
try {
Get.find<VideoDetailController>(
tag: Get.arguments['heroTag'],
).plPlayerController.seekTo(
Duration(seconds: item.timestamp!),
isSeek: false,
);
} catch (_) {}
},
),
const TextSpan(text: ' '),
TextSpan(text: item.content!),
],
),
),
],
),
),
],
),
);
},
),
),
],
);
if (_isNested) {
return ExtendedVisibilityDetector(