feat: video tags
This commit is contained in:
@ -609,4 +609,7 @@ class Api {
|
|||||||
|
|
||||||
/// @我的
|
/// @我的
|
||||||
static const String messageAtAPi = '/x/msgfeed/at?';
|
static const String messageAtAPi = '/x/msgfeed/at?';
|
||||||
|
|
||||||
|
/// 视频标签
|
||||||
|
static const String videoTag = '/x/tag/archive/tags';
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import 'dart:convert';
|
|||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
|
import 'package:pilipala/models/video/tags.dart';
|
||||||
import '../common/constants.dart';
|
import '../common/constants.dart';
|
||||||
import '../models/common/reply_type.dart';
|
import '../models/common/reply_type.dart';
|
||||||
import '../models/home/rcmd/result.dart';
|
import '../models/home/rcmd/result.dart';
|
||||||
@ -559,4 +560,19 @@ class VideoHttp {
|
|||||||
final List body = res.data['body'];
|
final List body = res.data['body'];
|
||||||
return {'content': content, 'body': body};
|
return {'content': content, 'body': body};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取视频标签
|
||||||
|
static Future getVideoTag({required String bvid}) async {
|
||||||
|
var res = await Request().get(Api.videoTag, data: {'bvid': bvid});
|
||||||
|
if (res.data['code'] == 0) {
|
||||||
|
return {
|
||||||
|
'status': true,
|
||||||
|
'data': res.data['data'].map<VideoTagItem>((e) {
|
||||||
|
return VideoTagItem.fromJson(e);
|
||||||
|
}).toList()
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {'status': false, 'data': [], 'msg': res.data['message']};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
17
lib/models/video/tags.dart
Normal file
17
lib/models/video/tags.dart
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
class VideoTagItem {
|
||||||
|
String? tagName;
|
||||||
|
int? tagId;
|
||||||
|
int? tagType;
|
||||||
|
|
||||||
|
VideoTagItem({
|
||||||
|
this.tagName,
|
||||||
|
this.tagId,
|
||||||
|
this.tagType,
|
||||||
|
});
|
||||||
|
|
||||||
|
VideoTagItem.fromJson(Map<String, dynamic> json) {
|
||||||
|
tagName = json['tag_name'];
|
||||||
|
tagId = json['tag_id'];
|
||||||
|
tagType = json['type'];
|
||||||
|
}
|
||||||
|
}
|
@ -10,6 +10,7 @@ import 'package:pilipala/http/user.dart';
|
|||||||
import 'package:pilipala/http/video.dart';
|
import 'package:pilipala/http/video.dart';
|
||||||
import 'package:pilipala/models/user/fav_folder.dart';
|
import 'package:pilipala/models/user/fav_folder.dart';
|
||||||
import 'package:pilipala/models/video/ai.dart';
|
import 'package:pilipala/models/video/ai.dart';
|
||||||
|
import 'package:pilipala/models/video/tags.dart';
|
||||||
import 'package:pilipala/models/video_detail_res.dart';
|
import 'package:pilipala/models/video_detail_res.dart';
|
||||||
import 'package:pilipala/pages/video/detail/controller.dart';
|
import 'package:pilipala/pages/video/detail/controller.dart';
|
||||||
import 'package:pilipala/pages/video/detail/reply/index.dart';
|
import 'package:pilipala/pages/video/detail/reply/index.dart';
|
||||||
@ -52,6 +53,7 @@ class VideoIntroController extends GetxController {
|
|||||||
|
|
||||||
RxInt lastPlayCid = 0.obs;
|
RxInt lastPlayCid = 0.obs;
|
||||||
var userInfo;
|
var userInfo;
|
||||||
|
RxList<VideoTagItem> videoTags = <VideoTagItem>[].obs;
|
||||||
|
|
||||||
// 同时观看
|
// 同时观看
|
||||||
bool isShowOnlineTotal = false;
|
bool isShowOnlineTotal = false;
|
||||||
@ -81,6 +83,7 @@ class VideoIntroController extends GetxController {
|
|||||||
}
|
}
|
||||||
enableRelatedVideo =
|
enableRelatedVideo =
|
||||||
setting.get(SettingBoxKey.enableRelatedVideo, defaultValue: true);
|
setting.get(SettingBoxKey.enableRelatedVideo, defaultValue: true);
|
||||||
|
queryVideoTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取视频简介&分p
|
// 获取视频简介&分p
|
||||||
@ -678,4 +681,12 @@ class VideoIntroController extends GetxController {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取视频标签
|
||||||
|
void queryVideoTag() async {
|
||||||
|
var result = await VideoHttp.getVideoTag(bvid: bvid);
|
||||||
|
if (result['status']) {
|
||||||
|
videoTags.value = result['data'];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -387,7 +387,10 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
ExpandablePanel(
|
ExpandablePanel(
|
||||||
controller: _expandableCtr,
|
controller: _expandableCtr,
|
||||||
collapsed: const SizedBox(height: 0),
|
collapsed: const SizedBox(height: 0),
|
||||||
expanded: IntroDetail(videoDetail: widget.videoDetail!),
|
expanded: IntroDetail(
|
||||||
|
videoDetail: widget.videoDetail!,
|
||||||
|
videoTags: videoIntroController.videoTags,
|
||||||
|
),
|
||||||
theme: const ExpandableThemeData(
|
theme: const ExpandableThemeData(
|
||||||
animationDuration: Duration(milliseconds: 300),
|
animationDuration: Duration(milliseconds: 300),
|
||||||
scrollAnimationDuration: Duration(milliseconds: 300),
|
scrollAnimationDuration: Duration(milliseconds: 300),
|
||||||
|
@ -4,6 +4,7 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:pilipala/http/constants.dart';
|
import 'package:pilipala/http/constants.dart';
|
||||||
|
import 'package:pilipala/models/video/tags.dart';
|
||||||
import 'package:pilipala/utils/feed_back.dart';
|
import 'package:pilipala/utils/feed_back.dart';
|
||||||
import 'package:pilipala/utils/utils.dart';
|
import 'package:pilipala/utils/utils.dart';
|
||||||
|
|
||||||
@ -11,13 +12,15 @@ class IntroDetail extends StatelessWidget {
|
|||||||
const IntroDetail({
|
const IntroDetail({
|
||||||
super.key,
|
super.key,
|
||||||
this.videoDetail,
|
this.videoDetail,
|
||||||
|
this.videoTags,
|
||||||
});
|
});
|
||||||
|
|
||||||
final dynamic videoDetail;
|
final dynamic videoDetail;
|
||||||
|
final RxList<VideoTagItem>? videoTags;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
TextStyle textStyle = TextStyle(
|
TextStyle textStyle = TextStyle(
|
||||||
fontSize: 14,
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
);
|
);
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
@ -59,19 +62,26 @@ class IntroDetail extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
if (videoDetail!.descV2.isNotEmpty) ...[
|
||||||
SelectableRegion(
|
const SizedBox(height: 4),
|
||||||
focusNode: FocusNode(),
|
SelectableRegion(
|
||||||
selectionControls: MaterialTextSelectionControls(),
|
focusNode: FocusNode(),
|
||||||
child: Text.rich(
|
selectionControls: MaterialTextSelectionControls(),
|
||||||
style: const TextStyle(height: 1.4),
|
child: Text.rich(
|
||||||
TextSpan(
|
style: TextStyle(
|
||||||
children: [
|
height: 1.4, color: Theme.of(context).colorScheme.outline),
|
||||||
buildContent(context, videoDetail!),
|
TextSpan(
|
||||||
],
|
children: [
|
||||||
|
buildContent(context, videoDetail!),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Obx(() => null != videoTags && videoTags!.isNotEmpty
|
||||||
|
? _buildTags(context, videoTags)
|
||||||
|
: const SizedBox.shrink()),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -152,4 +162,42 @@ class IntroDetail extends StatelessWidget {
|
|||||||
});
|
});
|
||||||
return TextSpan(children: spanChilds);
|
return TextSpan(children: spanChilds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildTags(BuildContext context, List<VideoTagItem>? videoTags) {
|
||||||
|
final ColorScheme colorScheme = Theme.of(context).colorScheme;
|
||||||
|
return Wrap(
|
||||||
|
spacing: 6,
|
||||||
|
runSpacing: 6,
|
||||||
|
direction: Axis.horizontal,
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
children: videoTags!.map((tag) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: () {
|
||||||
|
Get.toNamed(
|
||||||
|
'/tag',
|
||||||
|
arguments: {
|
||||||
|
'tagId': tag.tagId,
|
||||||
|
'tagName': tag.tagName,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: colorScheme.surfaceVariant.withOpacity(0.5),
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
|
||||||
|
child: Text(
|
||||||
|
tag.tagName!,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user