feat: show video note list

Closes #376

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-03-04 11:42:41 +08:00
parent c990cf1660
commit 5986add7dd
13 changed files with 363 additions and 16 deletions

View File

@@ -11,6 +11,7 @@ Widget errorWidget({errMsg, callback}) => HttpError(
); );
Widget scrollErrorWidget({errMsg, callback}) => CustomScrollView( Widget scrollErrorWidget({errMsg, callback}) => CustomScrollView(
controller: ScrollController(),
slivers: [ slivers: [
HttpError( HttpError(
errMsg: errMsg, errMsg: errMsg,

View File

@@ -719,4 +719,6 @@ class Api {
static const String pgcIndexCondition = '/pgc/season/index/condition'; static const String pgcIndexCondition = '/pgc/season/index/condition';
static const String pgcIndexResult = '/pgc/season/index/result'; static const String pgcIndexResult = '/pgc/season/index/result';
static const String noteList = '/x/note/publish/list/archive';
} }

View File

@@ -1134,4 +1134,27 @@ class VideoHttp {
return LoadingState.error(res.data['message']); return LoadingState.error(res.data['message']);
} }
} }
static Future<LoadingState> getVideoNoteList({
dynamic oid,
dynamic uperMid,
required int page,
}) async {
var res = await Request().get(
Api.noteList,
queryParameters: {
'csrf': await Request.getCsrf(),
'oid': oid,
'oid_type': 0,
'pn': page,
'ps': 10,
if (uperMid != null) 'uper_mid': uperMid,
},
);
if (res.data['code'] == 0) {
return LoadingState.success(res.data['data']);
} else {
return LoadingState.error(res.data['message']);
}
}
} }

View File

@@ -142,7 +142,7 @@ class SearchDynamic extends StatelessWidget {
name, name,
style: TextStyle( style: TextStyle(
color: vip != null color: vip != null
? (vip?['status'] ?? vip?['vipStatus']) > 0 && ? (vip?['status'] ?? vip?['vipStatus'] ?? 0) > 0 &&
(vip?['type'] ?? vip?['vipType']) == 2 (vip?['type'] ?? vip?['vipType']) == 2
? context.vipColor ? context.vipColor
: null : null

View File

@@ -20,6 +20,7 @@ import 'package:PiliPlus/models/video/play/subtitle.dart';
import 'package:PiliPlus/models/video_detail_res.dart'; import 'package:PiliPlus/models/video_detail_res.dart';
import 'package:PiliPlus/pages/search/widgets/search_text.dart'; import 'package:PiliPlus/pages/search/widgets/search_text.dart';
import 'package:PiliPlus/pages/video/detail/introduction/controller.dart'; import 'package:PiliPlus/pages/video/detail/introduction/controller.dart';
import 'package:PiliPlus/pages/video/detail/note/note_list_page.dart';
import 'package:PiliPlus/pages/video/detail/related/controller.dart'; import 'package:PiliPlus/pages/video/detail/related/controller.dart';
import 'package:PiliPlus/pages/video/detail/reply/controller.dart'; import 'package:PiliPlus/pages/video/detail/reply/controller.dart';
import 'package:PiliPlus/pages/video/detail/view_v.dart' show ViewPointsPage; import 'package:PiliPlus/pages/video/detail/view_v.dart' show ViewPointsPage;
@@ -1343,9 +1344,9 @@ class VideoDetailController extends GetxController
childKey.currentState?.showBottomSheet( childKey.currentState?.showBottomSheet(
enableDrag: false, enableDrag: false,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
(context) => ViewPointsPage( (context) => GStorage.collapsibleVideoPage
child: _postPanel(), ? ViewPointsPage(child: _postPanel())
), : _postPanel(),
); );
} }
} }
@@ -2175,4 +2176,18 @@ class VideoDetailController extends GetxController
debugPrint('_getDmTrend: $e'); debugPrint('_getDmTrend: $e');
} }
} }
void showNoteList() async {
if (plPlayerController.isFullScreen.value) {
Utils.showFSSheet(
child: NoteListPage(oid: oid.value),
isFullScreen: plPlayerController.isFullScreen.value,
);
} else {
childKey.currentState?.showBottomSheet(
backgroundColor: Colors.transparent,
(context) => NoteListPage(oid: oid.value),
);
}
}
} }

View File

@@ -406,12 +406,11 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
'status'] ?? 'status'] ??
-1) > -1) >
0 && 0 &&
(videoIntroController videoIntroController
.userStat .userStat
.value['card']?['vip'] .value['card']
?[ ?[
'type'] ?? 'vip']?['type'] ==
-1) ==
2 2
? context.vipColor ? context.vipColor
: null, : null,

View File

@@ -0,0 +1,215 @@
import 'package:PiliPlus/common/skeleton/video_reply.dart';
import 'package:PiliPlus/common/widgets/icon_button.dart';
import 'package:PiliPlus/common/widgets/loading_widget.dart';
import 'package:PiliPlus/common/widgets/network_img_layer.dart';
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/pages/video/detail/note/note_list_page_ctr.dart';
import 'package:PiliPlus/utils/app_scheme.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class NoteListPage extends StatefulWidget {
const NoteListPage({super.key, this.oid, this.upperMid});
final dynamic oid;
final dynamic upperMid;
@override
State<NoteListPage> createState() => _NoteListPageState();
}
class _NoteListPageState extends State<NoteListPage> {
late final _controller = Get.put(
NoteListPageCtr(oid: widget.oid, upperMid: widget.upperMid),
);
@override
void dispose() {
Get.delete<NoteListPageCtr>();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
titleSpacing: 16,
toolbarHeight: 45,
title: Obx(
() => Text(
'笔记${_controller.count.value == -1 ? '' : '(${_controller.count.value})'}'),
),
bottom: PreferredSize(
preferredSize: Size.fromHeight(1),
child: Divider(
height: 1,
color: Theme.of(context).colorScheme.outline.withOpacity(0.1),
),
),
actions: [
iconButton(
context: context,
tooltip: '关闭',
icon: Icons.clear,
onPressed: Get.back,
size: 32,
),
const SizedBox(width: 16),
],
),
body: Obx(() => _buildBody(_controller.loadingState.value)),
);
}
Widget _buildBody(LoadingState loadingState) {
return switch (loadingState) {
Loading() => CustomScrollView(
physics: const NeverScrollableScrollPhysics(),
slivers: [
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return const VideoReplySkeleton();
},
childCount: 8,
),
)
],
),
Success() => (loadingState.response as List?)?.isNotEmpty == true
? RefreshIndicator(
onRefresh: () async {
await _controller.onRefresh();
},
child: CustomScrollView(
controller: ScrollController(),
slivers: [
SliverList.separated(
itemBuilder: (context, index) {
if (index == loadingState.response.length - 1) {
_controller.onLoadMore();
}
return _itemWidget(context, loadingState.response[index]);
},
itemCount: loadingState.response.length,
separatorBuilder: (context, index) => Divider(
height: 1,
color: Theme.of(context)
.colorScheme
.outline
.withOpacity(0.1),
),
),
SliverToBoxAdapter(
child: SizedBox(
height: MediaQuery.paddingOf(context).bottom + 80,
),
),
],
),
)
: scrollErrorWidget(
callback: _controller.onReload,
),
Error() => scrollErrorWidget(
errMsg: loadingState.errMsg,
callback: _controller.onReload,
),
LoadingState() => throw UnimplementedError(),
};
}
}
Widget _itemWidget(BuildContext context, dynamic item) {
return InkWell(
onTap: () {
if (item['web_url'] != null && item['web_url'] != '') {
PiliScheme.routePushFromUrl(item['web_url']);
}
},
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
GestureDetector(
onTap: () {
Get.toNamed('/member?mid=${item['author']['mid']}');
},
child: NetworkImgLayer(
height: 34,
width: 34,
src: item['author']['face'],
type: 'avatar',
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
GestureDetector(
onTap: () {
Get.toNamed('/member?mid=${item['author']['mid']}');
},
child: Row(
children: [
Text(
item['author']['name'],
style: TextStyle(
color: (item['author']?['vip_info']?['status'] ?? 0) >
0 &&
item['author']?['vip_info']?['type'] == 2
? context.vipColor
: Theme.of(context).colorScheme.outline,
fontSize: 13,
),
),
const SizedBox(width: 6),
Image.asset(
'assets/images/lv/lv${item['author']['level']}.png',
height: 11,
),
],
),
),
const SizedBox(height: 4),
Text(
item['pubtime'],
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
fontSize: 12,
),
),
if (item['summary'] != null) ...[
const SizedBox(height: 5),
Text(
item['summary'],
style: TextStyle(
height: 1.75,
fontSize:
Theme.of(context).textTheme.bodyMedium!.fontSize,
),
),
if (item['web_url'] != null && item['web_url'] != '')
Text(
'查看全部',
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
height: 1.75,
fontSize:
Theme.of(context).textTheme.bodyMedium!.fontSize,
),
),
],
],
),
),
],
),
),
);
}

View File

@@ -0,0 +1,44 @@
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/http/video.dart';
import 'package:PiliPlus/pages/common/common_controller.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:get/get.dart';
class NoteListPageCtr extends CommonController {
NoteListPageCtr({this.oid, this.upperMid});
final dynamic oid;
final dynamic upperMid;
RxInt count = (-1).obs;
@override
void onInit() {
super.onInit();
queryData();
}
@override
bool customHandleResponse(Success response) {
dynamic data = response.response;
count.value = data['page']?['total'] ?? -1;
if ((data['list'] as List?).isNullOrEmpty) {
isEnd = true;
}
if (currentPage != 1 && loadingState.value is Success) {
data['list'] ??= [];
data['list'].insertAll(0, (loadingState.value as Success).response);
}
if (isEnd.not && count.value != -1 && data['list'].length >= count.value) {
isEnd = true;
}
loadingState.value = LoadingState.success(data['list']);
return true;
}
@override
Future<LoadingState> customGetData() => VideoHttp.getVideoNoteList(
oid: oid,
uperMid: upperMid,
page: currentPage,
);
}

View File

@@ -266,9 +266,11 @@ class ReplyItem extends StatelessWidget {
Text( Text(
'${replyItem.member?.uname}', '${replyItem.member?.uname}',
style: TextStyle( style: TextStyle(
color: (replyItem.member?.vip?['vipType'] == 2) color:
? context.vipColor (replyItem.member?.vip?['vipStatus'] ?? 0) > 0 &&
: Theme.of(context).colorScheme.outline, replyItem.member?.vip?['vipType'] == 2
? context.vipColor
: Theme.of(context).colorScheme.outline,
fontSize: 13, fontSize: 13,
), ),
), ),

View File

@@ -1104,6 +1104,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
}); });
} }
break; break;
case 'note':
videoDetailController.showNoteList();
break;
} }
}, },
itemBuilder: (BuildContext context) => itemBuilder: (BuildContext context) =>
@@ -1112,6 +1115,11 @@ class _VideoDetailPageState extends State<VideoDetailPage>
value: 'later', value: 'later',
child: Text('稍后再看'), child: Text('稍后再看'),
), ),
if (videoDetailController.epId == null)
const PopupMenuItem<String>(
value: 'note',
child: Text('查看笔记'),
),
const PopupMenuItem<String>( const PopupMenuItem<String>(
value: 'report', value: 'report',
child: Text('举报'), child: Text('举报'),

View File

@@ -1397,6 +1397,9 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
}); });
} }
break; break;
case 'note':
videoDetailController.showNoteList();
break;
} }
}, },
itemBuilder: (BuildContext context) => itemBuilder: (BuildContext context) =>
@@ -1405,6 +1408,11 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
value: 'later', value: 'later',
child: Text('稍后再看'), child: Text('稍后再看'),
), ),
if (videoDetailController.epId == null)
const PopupMenuItem<String>(
value: 'note',
child: Text('查看笔记'),
),
const PopupMenuItem<String>( const PopupMenuItem<String>(
value: 'report', value: 'report',
child: Text('举报'), child: Text('举报'),
@@ -2404,9 +2412,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
videoDetailController.childKey.currentState?.showBottomSheet( videoDetailController.childKey.currentState?.showBottomSheet(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
(context) => GStorage.collapsibleVideoPage (context) => GStorage.collapsibleVideoPage
? ViewPointsPage( ? ViewPointsPage(child: listSheetContent())
child: listSheetContent(),
)
: listSheetContent(), : listSheetContent(),
); );
} }

View File

@@ -157,6 +157,16 @@ class _HeaderControlState extends State<HeaderControl> {
leading: const Icon(Icons.watch_later_outlined, size: 20), leading: const Icon(Icons.watch_later_outlined, size: 20),
title: const Text('添加至「稍后再看」', style: titleStyle), title: const Text('添加至「稍后再看」', style: titleStyle),
), ),
if (widget.videoDetailCtr.epId == null)
ListTile(
dense: true,
onTap: () {
Get.back();
widget.videoDetailCtr.showNoteList();
},
leading: const Icon(Icons.note_alt_outlined, size: 20),
title: const Text('查看笔记', style: titleStyle),
),
ListTile( ListTile(
dense: true, dense: true,
onTap: () => {Get.back(), scheduleExit()}, onTap: () => {Get.back(), scheduleExit()},

View File

@@ -430,7 +430,29 @@ class PiliScheme {
final String? area = pathSegments.first == 'mobile' final String? area = pathSegments.first == 'mobile'
? pathSegments.getOrNull(1) ? pathSegments.getOrNull(1)
: pathSegments.first; : pathSegments.first;
debugPrint('area: $area');
switch (area) { switch (area) {
case 'h5':
if (path.startsWith('/h5/note')) {
String? id = RegExp(r'cvid=(\d+)', caseSensitive: false)
.firstMatch(uri.query)
?.group(1);
if (id != null) {
Utils.toDupNamed(
'/htmlRender',
parameters: {
'url': 'https://www.bilibili.com/read/cv$id',
'title': '',
'id': 'cv$id',
'dynamicType': 'read'
},
off: off,
);
return true;
}
}
launchURL();
return false;
case 'opus' || 'dynamic': case 'opus' || 'dynamic':
bool hasMatch = await _onPushDynDetail(path, off); bool hasMatch = await _onPushDynDetail(path, off);
if (hasMatch.not) { if (hasMatch.not) {