mod: ai总结样式
This commit is contained in:
@ -242,6 +242,12 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
showBottomSheet(
|
showBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
enableDrag: true,
|
enableDrag: true,
|
||||||
|
shape: const RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.only(
|
||||||
|
topLeft: Radius.circular(25),
|
||||||
|
topRight: Radius.circular(25),
|
||||||
|
),
|
||||||
|
),
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return AiDetail(modelResult: videoIntroController.modelResult);
|
return AiDetail(modelResult: videoIntroController.modelResult);
|
||||||
},
|
},
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:hive/hive.dart';
|
|
||||||
import 'package:pilipala/models/video/ai.dart';
|
import 'package:pilipala/models/video/ai.dart';
|
||||||
import 'package:pilipala/pages/video/detail/index.dart';
|
import 'package:pilipala/pages/video/detail/index.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/global_data_cache.dart';
|
||||||
import 'package:pilipala/utils/utils.dart';
|
import 'package:pilipala/utils/utils.dart';
|
||||||
|
|
||||||
Box localCache = GStrorage.localCache;
|
|
||||||
late double sheetHeight;
|
|
||||||
|
|
||||||
class AiDetail extends StatelessWidget {
|
class AiDetail extends StatelessWidget {
|
||||||
final ModelResult? modelResult;
|
final ModelResult? modelResult;
|
||||||
|
|
||||||
@ -21,124 +16,21 @@ class AiDetail extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
sheetHeight = localCache.get('sheetHeight');
|
|
||||||
return Container(
|
return Container(
|
||||||
color: Theme.of(context).colorScheme.surface,
|
padding: const EdgeInsets.only(left: 16, right: 16),
|
||||||
padding: const EdgeInsets.only(left: 14, right: 14),
|
height: GlobalDataCache().sheetHeight,
|
||||||
height: sheetHeight,
|
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
InkWell(
|
_buildHeader(context),
|
||||||
onTap: () => Get.back(),
|
|
||||||
child: Container(
|
|
||||||
height: 35,
|
|
||||||
padding: const EdgeInsets.only(bottom: 2),
|
|
||||||
child: Center(
|
|
||||||
child: Container(
|
|
||||||
width: 32,
|
|
||||||
height: 3,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(3)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
if (modelResult!.resultType != 0 &&
|
if (modelResult!.summary != '') ...[
|
||||||
modelResult!.summary != '') ...[
|
_buildSummaryText(modelResult!.summary!),
|
||||||
SelectableText(
|
|
||||||
modelResult!.summary!,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 15,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
height: 1.5,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
],
|
],
|
||||||
ListView.builder(
|
_buildOutlineList(context),
|
||||||
shrinkWrap: true,
|
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
|
||||||
itemCount: modelResult!.outline!.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final outline = modelResult!.outline![index];
|
|
||||||
return Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
SelectableText(
|
|
||||||
outline.title!,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
height: 1.5,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 6),
|
|
||||||
ListView.builder(
|
|
||||||
shrinkWrap: true,
|
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
|
||||||
itemCount: outline.partOutline!.length,
|
|
||||||
itemBuilder: (context, i) {
|
|
||||||
final part = outline.partOutline![i];
|
|
||||||
return Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
try {
|
|
||||||
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(
|
|
||||||
fontSize: 13,
|
|
||||||
color: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.onSurface,
|
|
||||||
height: 1.5,
|
|
||||||
),
|
|
||||||
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),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -148,77 +40,113 @@ class AiDetail extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
InlineSpan buildContent(BuildContext context, content) {
|
Widget _buildHeader(BuildContext context) {
|
||||||
List descV2 = content.descV2;
|
return Center(
|
||||||
// type
|
child: Container(
|
||||||
// 1 普通文本
|
decoration: BoxDecoration(
|
||||||
// 2 @用户
|
color: Theme.of(context).hintColor,
|
||||||
List<TextSpan> spanChilds = List.generate(descV2.length, (index) {
|
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||||
final currentDesc = descV2[index];
|
),
|
||||||
switch (currentDesc.type) {
|
height: 4,
|
||||||
case 1:
|
width: 40,
|
||||||
List<InlineSpan> spanChildren = [];
|
margin: const EdgeInsets.symmetric(vertical: 16),
|
||||||
RegExp urlRegExp = RegExp(r'https?://\S+\b');
|
),
|
||||||
Iterable<Match> matches = urlRegExp.allMatches(currentDesc.rawText);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
int previousEndIndex = 0;
|
Widget _buildSummaryText(String summary) {
|
||||||
for (Match match in matches) {
|
return SelectableText(
|
||||||
if (match.start > previousEndIndex) {
|
summary,
|
||||||
spanChildren.add(TextSpan(
|
textAlign: TextAlign.justify,
|
||||||
text: currentDesc.rawText
|
style: const TextStyle(
|
||||||
.substring(previousEndIndex, match.start)));
|
fontSize: 16,
|
||||||
}
|
fontWeight: FontWeight.bold,
|
||||||
spanChildren.add(
|
height: 1.6,
|
||||||
TextSpan(
|
),
|
||||||
text: match.group(0),
|
);
|
||||||
style: TextStyle(
|
}
|
||||||
color: Theme.of(context).colorScheme.primary), // 设置颜色为蓝色
|
|
||||||
recognizer: TapGestureRecognizer()
|
|
||||||
..onTap = () {
|
|
||||||
// 处理点击事件
|
|
||||||
try {
|
|
||||||
Get.toNamed(
|
|
||||||
'/webview',
|
|
||||||
parameters: {
|
|
||||||
'url': match.group(0)!,
|
|
||||||
'type': 'url',
|
|
||||||
'pageTitle': match.group(0)!,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} catch (err) {
|
|
||||||
SmartDialog.showToast(err.toString());
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
previousEndIndex = match.end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (previousEndIndex < currentDesc.rawText.length) {
|
Widget _buildOutlineList(BuildContext context) {
|
||||||
spanChildren.add(TextSpan(
|
return ListView.builder(
|
||||||
text: currentDesc.rawText.substring(previousEndIndex)));
|
shrinkWrap: true,
|
||||||
}
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
itemCount: modelResult!.outline!.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final outline = modelResult!.outline![index];
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
_buildOutlineTitle(outline.title!),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_buildPartOutlineList(context, outline.partOutline!),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
TextSpan result = TextSpan(children: spanChildren);
|
Widget _buildOutlineTitle(String title) {
|
||||||
return result;
|
return SelectableText(
|
||||||
case 2:
|
title,
|
||||||
final colorSchemePrimary = Theme.of(context).colorScheme.primary;
|
textAlign: TextAlign.justify,
|
||||||
final heroTag = Utils.makeHeroTag(currentDesc.bizId);
|
style: const TextStyle(
|
||||||
return TextSpan(
|
fontSize: 16,
|
||||||
text: '@${currentDesc.rawText}',
|
fontWeight: FontWeight.bold,
|
||||||
style: TextStyle(color: colorSchemePrimary),
|
height: 1.5,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildPartOutlineList(
|
||||||
|
BuildContext context, List<PartOutline> partOutline) {
|
||||||
|
return ListView.builder(
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
itemCount: partOutline.length,
|
||||||
|
itemBuilder: (context, i) {
|
||||||
|
final part = partOutline[i];
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
_buildPartText(context, part),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onPartTap(BuildContext context, int timestamp) {
|
||||||
|
try {
|
||||||
|
final controller = Get.find<VideoDetailController>(
|
||||||
|
tag: Get.arguments['heroTag'],
|
||||||
|
);
|
||||||
|
controller.plPlayerController.seekTo(
|
||||||
|
Duration(seconds: timestamp),
|
||||||
|
);
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildPartText(BuildContext context, PartOutline part) {
|
||||||
|
return SelectableText.rich(
|
||||||
|
TextSpan(
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
TextSpan(
|
||||||
|
text: Utils.tampToSeektime(part.timestamp!),
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
recognizer: TapGestureRecognizer()
|
recognizer: TapGestureRecognizer()
|
||||||
..onTap = () {
|
..onTap = () => _onPartTap(context, part.timestamp!),
|
||||||
Get.toNamed(
|
),
|
||||||
'/member?mid=${currentDesc.bizId}',
|
const TextSpan(text: ' '),
|
||||||
arguments: {'face': '', 'heroTag': heroTag},
|
TextSpan(text: part.content!),
|
||||||
);
|
],
|
||||||
},
|
),
|
||||||
);
|
);
|
||||||
default:
|
|
||||||
return const TextSpan();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return TextSpan(children: spanChilds);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ class GlobalDataCache {
|
|||||||
late FullScreenGestureMode fullScreenGestureMode;
|
late FullScreenGestureMode fullScreenGestureMode;
|
||||||
late bool enablePlayerControlAnimation;
|
late bool enablePlayerControlAnimation;
|
||||||
late List<String> actionTypeSort;
|
late List<String> actionTypeSort;
|
||||||
|
late double sheetHeight;
|
||||||
String? wWebid;
|
String? wWebid;
|
||||||
|
|
||||||
/// 播放器相关
|
/// 播放器相关
|
||||||
@ -103,5 +104,6 @@ class GlobalDataCache {
|
|||||||
speedsList.addAll(playSpeedSystem);
|
speedsList.addAll(playSpeedSystem);
|
||||||
|
|
||||||
userInfo = userInfoCache.get('userInfoCache');
|
userInfo = userInfoCache.get('userInfoCache');
|
||||||
|
sheetHeight = localCache.get('sheetHeight');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -351,6 +351,9 @@ class Utils {
|
|||||||
|
|
||||||
// 时间戳转时间
|
// 时间戳转时间
|
||||||
static tampToSeektime(number) {
|
static tampToSeektime(number) {
|
||||||
|
if (number is String && int.tryParse(number) == null) {
|
||||||
|
return number;
|
||||||
|
}
|
||||||
int hours = number ~/ 60;
|
int hours = number ~/ 60;
|
||||||
int minutes = number % 60;
|
int minutes = number % 60;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user