mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: show video note list
Closes #376 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -142,7 +142,7 @@ class SearchDynamic extends StatelessWidget {
|
||||
name,
|
||||
style: TextStyle(
|
||||
color: vip != null
|
||||
? (vip?['status'] ?? vip?['vipStatus']) > 0 &&
|
||||
? (vip?['status'] ?? vip?['vipStatus'] ?? 0) > 0 &&
|
||||
(vip?['type'] ?? vip?['vipType']) == 2
|
||||
? context.vipColor
|
||||
: null
|
||||
|
||||
@@ -20,6 +20,7 @@ import 'package:PiliPlus/models/video/play/subtitle.dart';
|
||||
import 'package:PiliPlus/models/video_detail_res.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/note/note_list_page.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/view_v.dart' show ViewPointsPage;
|
||||
@@ -1343,9 +1344,9 @@ class VideoDetailController extends GetxController
|
||||
childKey.currentState?.showBottomSheet(
|
||||
enableDrag: false,
|
||||
backgroundColor: Colors.transparent,
|
||||
(context) => ViewPointsPage(
|
||||
child: _postPanel(),
|
||||
),
|
||||
(context) => GStorage.collapsibleVideoPage
|
||||
? ViewPointsPage(child: _postPanel())
|
||||
: _postPanel(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2175,4 +2176,18 @@ class VideoDetailController extends GetxController
|
||||
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),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,12 +406,11 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
'status'] ??
|
||||
-1) >
|
||||
0 &&
|
||||
(videoIntroController
|
||||
.userStat
|
||||
.value['card']?['vip']
|
||||
?[
|
||||
'type'] ??
|
||||
-1) ==
|
||||
videoIntroController
|
||||
.userStat
|
||||
.value['card']
|
||||
?[
|
||||
'vip']?['type'] ==
|
||||
2
|
||||
? context.vipColor
|
||||
: null,
|
||||
|
||||
215
lib/pages/video/detail/note/note_list_page.dart
Normal file
215
lib/pages/video/detail/note/note_list_page.dart
Normal 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,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
44
lib/pages/video/detail/note/note_list_page_ctr.dart
Normal file
44
lib/pages/video/detail/note/note_list_page_ctr.dart
Normal 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,
|
||||
);
|
||||
}
|
||||
@@ -266,9 +266,11 @@ class ReplyItem extends StatelessWidget {
|
||||
Text(
|
||||
'${replyItem.member?.uname}',
|
||||
style: TextStyle(
|
||||
color: (replyItem.member?.vip?['vipType'] == 2)
|
||||
? context.vipColor
|
||||
: Theme.of(context).colorScheme.outline,
|
||||
color:
|
||||
(replyItem.member?.vip?['vipStatus'] ?? 0) > 0 &&
|
||||
replyItem.member?.vip?['vipType'] == 2
|
||||
? context.vipColor
|
||||
: Theme.of(context).colorScheme.outline,
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1104,6 +1104,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 'note':
|
||||
videoDetailController.showNoteList();
|
||||
break;
|
||||
}
|
||||
},
|
||||
itemBuilder: (BuildContext context) =>
|
||||
@@ -1112,6 +1115,11 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
value: 'later',
|
||||
child: Text('稍后再看'),
|
||||
),
|
||||
if (videoDetailController.epId == null)
|
||||
const PopupMenuItem<String>(
|
||||
value: 'note',
|
||||
child: Text('查看笔记'),
|
||||
),
|
||||
const PopupMenuItem<String>(
|
||||
value: 'report',
|
||||
child: Text('举报'),
|
||||
|
||||
@@ -1397,6 +1397,9 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 'note':
|
||||
videoDetailController.showNoteList();
|
||||
break;
|
||||
}
|
||||
},
|
||||
itemBuilder: (BuildContext context) =>
|
||||
@@ -1405,6 +1408,11 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
value: 'later',
|
||||
child: Text('稍后再看'),
|
||||
),
|
||||
if (videoDetailController.epId == null)
|
||||
const PopupMenuItem<String>(
|
||||
value: 'note',
|
||||
child: Text('查看笔记'),
|
||||
),
|
||||
const PopupMenuItem<String>(
|
||||
value: 'report',
|
||||
child: Text('举报'),
|
||||
@@ -2404,9 +2412,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
videoDetailController.childKey.currentState?.showBottomSheet(
|
||||
backgroundColor: Colors.transparent,
|
||||
(context) => GStorage.collapsibleVideoPage
|
||||
? ViewPointsPage(
|
||||
child: listSheetContent(),
|
||||
)
|
||||
? ViewPointsPage(child: listSheetContent())
|
||||
: listSheetContent(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -157,6 +157,16 @@ class _HeaderControlState extends State<HeaderControl> {
|
||||
leading: const Icon(Icons.watch_later_outlined, size: 20),
|
||||
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(
|
||||
dense: true,
|
||||
onTap: () => {Get.back(), scheduleExit()},
|
||||
|
||||
Reference in New Issue
Block a user