Merge branch 'main' into feature-minePage
This commit is contained in:
@ -146,20 +146,26 @@ class DynamicsController extends GetxController {
|
||||
/// 专栏文章查看
|
||||
case 'DYNAMIC_TYPE_ARTICLE':
|
||||
String title = item.modules.moduleDynamic.major.opus.title;
|
||||
String url = item.modules.moduleDynamic.major.opus.jumpUrl;
|
||||
if (url.contains('opus') || url.contains('read')) {
|
||||
String jumpUrl = item.modules.moduleDynamic.major.opus.jumpUrl;
|
||||
String url =
|
||||
jumpUrl.startsWith('//') ? jumpUrl.split('//').last : jumpUrl;
|
||||
if (jumpUrl.contains('opus') || jumpUrl.contains('read')) {
|
||||
RegExp digitRegExp = RegExp(r'\d+');
|
||||
Iterable<Match> matches = digitRegExp.allMatches(url);
|
||||
Iterable<Match> matches = digitRegExp.allMatches(jumpUrl);
|
||||
String number = matches.first.group(0)!;
|
||||
if (url.contains('read')) {
|
||||
number = 'cv$number';
|
||||
if (jumpUrl.contains('read')) {
|
||||
Get.toNamed('/read', parameters: {
|
||||
'title': title,
|
||||
'id': number,
|
||||
'articleType': url.split('/')[1]
|
||||
});
|
||||
} else {
|
||||
Get.toNamed('/opus', parameters: {
|
||||
'title': title,
|
||||
'id': number,
|
||||
'articleType': 'opus'
|
||||
});
|
||||
}
|
||||
Get.toNamed('/htmlRender', parameters: {
|
||||
'url': url.startsWith('//') ? url.split('//').last : url,
|
||||
'title': title,
|
||||
'id': number,
|
||||
'dynamicType': url.split('//').last.split('/')[1]
|
||||
});
|
||||
} else {
|
||||
Get.toNamed(
|
||||
'/webview',
|
||||
|
||||
@ -32,7 +32,8 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
late DynamicDetailController _dynamicDetailController;
|
||||
late AnimationController fabAnimationCtr;
|
||||
Future? _futureBuilderFuture;
|
||||
late StreamController<bool> titleStreamC; // appBar title
|
||||
late StreamController<bool> titleStreamC =
|
||||
StreamController<bool>.broadcast(); // appBar title
|
||||
late ScrollController scrollController;
|
||||
bool _visibleTitle = false;
|
||||
String? action;
|
||||
@ -48,7 +49,6 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
super.initState();
|
||||
// floor 1原创 2转发
|
||||
init();
|
||||
titleStreamC = StreamController<bool>();
|
||||
if (action == 'comment') {
|
||||
_visibleTitle = true;
|
||||
titleStreamC.add(true);
|
||||
|
||||
@ -6,17 +6,17 @@ import 'package:pilipala/http/video.dart';
|
||||
import 'package:pilipala/models/user/fav_detail.dart';
|
||||
import 'package:pilipala/models/user/fav_folder.dart';
|
||||
import 'package:pilipala/pages/fav/index.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
|
||||
class FavDetailController extends GetxController {
|
||||
FavFolderItemData? item;
|
||||
Rx<FavDetailData> favDetailData = FavDetailData().obs;
|
||||
|
||||
int? mediaId;
|
||||
late String heroTag;
|
||||
int currentPage = 1;
|
||||
bool isLoadingMore = false;
|
||||
RxMap favInfo = {}.obs;
|
||||
RxList favList = [].obs;
|
||||
RxList<FavDetailItemData> favList = <FavDetailItemData>[].obs;
|
||||
RxString loadingText = '加载中...'.obs;
|
||||
RxInt mediaCount = 0.obs;
|
||||
late String isOwner;
|
||||
@ -128,4 +128,22 @@ class FavDetailController extends GetxController {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future toViewPlayAll() async {
|
||||
final FavDetailItemData firstItem = favList.first;
|
||||
final String heroTag = Utils.makeHeroTag(firstItem.bvid);
|
||||
Get.toNamed(
|
||||
'/video?bvid=${firstItem.bvid}&cid=${firstItem.cid}',
|
||||
arguments: {
|
||||
'videoItem': firstItem,
|
||||
'heroTag': heroTag,
|
||||
'sourceType': 'fav',
|
||||
'mediaId': favInfo['id'],
|
||||
'oid': firstItem.id,
|
||||
'favTitle': favInfo['title'],
|
||||
'favInfo': favInfo,
|
||||
'count': favInfo['media_count'],
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,8 @@ class _FavDetailPageState extends State<FavDetailPage> {
|
||||
late final ScrollController _controller = ScrollController();
|
||||
final FavDetailController _favDetailController =
|
||||
Get.put(FavDetailController());
|
||||
late StreamController<bool> titleStreamC; // a
|
||||
late StreamController<bool> titleStreamC =
|
||||
StreamController<bool>.broadcast(); // a
|
||||
Future? _futureBuilderFuture;
|
||||
late String mediaId;
|
||||
|
||||
@ -31,7 +32,6 @@ class _FavDetailPageState extends State<FavDetailPage> {
|
||||
super.initState();
|
||||
mediaId = Get.parameters['mediaId']!;
|
||||
_futureBuilderFuture = _favDetailController.queryUserFavFolderDetail();
|
||||
titleStreamC = StreamController<bool>();
|
||||
_controller.addListener(
|
||||
() {
|
||||
if (_controller.offset > 160) {
|
||||
@ -260,6 +260,15 @@ class _FavDetailPageState extends State<FavDetailPage> {
|
||||
)
|
||||
],
|
||||
),
|
||||
floatingActionButton: Obx(
|
||||
() => _favDetailController.mediaCount > 0
|
||||
? FloatingActionButton.extended(
|
||||
onPressed: _favDetailController.toViewPlayAll,
|
||||
label: const Text('播放全部'),
|
||||
icon: const Icon(Icons.playlist_play),
|
||||
)
|
||||
: const SizedBox(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ class FollowSearchController extends GetxController {
|
||||
return {'status': true, 'data': <FollowItemModel>[].obs};
|
||||
}
|
||||
if (type == 'init') {
|
||||
ps = 1;
|
||||
pn = 1;
|
||||
}
|
||||
var res = await MemberHttp.getfollowSearch(
|
||||
mid: mid,
|
||||
|
||||
@ -43,14 +43,17 @@ class HistoryItem extends StatelessWidget {
|
||||
}
|
||||
if (videoItem.history.business.contains('article')) {
|
||||
int cid = videoItem.history.cid ??
|
||||
// videoItem.history.oid ??
|
||||
videoItem.history.oid ??
|
||||
await SearchHttp.ab2c(aid: aid, bvid: bvid);
|
||||
if (cid == -1) {
|
||||
return SmartDialog.showToast('无法获取文章内容');
|
||||
}
|
||||
Get.toNamed(
|
||||
'/webview',
|
||||
'/read',
|
||||
parameters: {
|
||||
'url': 'https://www.bilibili.com/read/cv$cid',
|
||||
'type': 'note',
|
||||
'pageTitle': videoItem.title
|
||||
'title': videoItem.title,
|
||||
'id': cid.toString(),
|
||||
'articleType': 'read',
|
||||
},
|
||||
);
|
||||
} else if (videoItem.history.business == 'live') {
|
||||
|
||||
@ -6,6 +6,7 @@ import 'package:pilipala/http/user.dart';
|
||||
import 'package:pilipala/models/model_hot_video_item.dart';
|
||||
import 'package:pilipala/models/user/info.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
|
||||
class LaterController extends GetxController {
|
||||
final ScrollController scrollController = ScrollController();
|
||||
@ -48,7 +49,7 @@ class LaterController extends GetxController {
|
||||
aid != null ? '即将移除该视频,确定是否移除' : '即将删除所有已观看视频,此操作不可恢复。确定是否删除?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => SmartDialog.dismiss(),
|
||||
onPressed: SmartDialog.dismiss,
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.outline),
|
||||
@ -87,7 +88,7 @@ class LaterController extends GetxController {
|
||||
content: const Text('确定要清空你的稍后再看列表吗?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => SmartDialog.dismiss(),
|
||||
onPressed: SmartDialog.dismiss,
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.outline),
|
||||
@ -109,4 +110,19 @@ class LaterController extends GetxController {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// 稍后再看播放全部
|
||||
Future toViewPlayAll() async {
|
||||
final HotVideoItemModel firstItem = laterList.first;
|
||||
final String heroTag = Utils.makeHeroTag(firstItem.bvid);
|
||||
Get.toNamed(
|
||||
'/video?bvid=${firstItem.bvid}&cid=${firstItem.cid}',
|
||||
arguments: {
|
||||
'videoItem': firstItem,
|
||||
'heroTag': heroTag,
|
||||
'sourceType': 'watchLater',
|
||||
'count': laterList.length,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,6 +128,15 @@ class _LaterPageState extends State<LaterPage> {
|
||||
)
|
||||
],
|
||||
),
|
||||
floatingActionButton: Obx(
|
||||
() => _laterController.laterList.isNotEmpty
|
||||
? FloatingActionButton.extended(
|
||||
onPressed: _laterController.toViewPlayAll,
|
||||
label: const Text('播放全部'),
|
||||
icon: const Icon(Icons.playlist_play),
|
||||
)
|
||||
: const SizedBox(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/http/live.dart';
|
||||
import 'package:pilipala/models/live/follow.dart';
|
||||
import 'package:pilipala/models/live/item.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
|
||||
@ -11,6 +12,8 @@ class LiveController extends GetxController {
|
||||
int _currentPage = 1;
|
||||
RxInt crossAxisCount = 2.obs;
|
||||
RxList<LiveItemModel> liveList = <LiveItemModel>[].obs;
|
||||
RxList<LiveFollowingItemModel> liveFollowingList =
|
||||
<LiveFollowingItemModel>[].obs;
|
||||
bool flag = false;
|
||||
OverlayEntry? popupDialog;
|
||||
Box setting = GStrorage.setting;
|
||||
@ -44,6 +47,7 @@ class LiveController extends GetxController {
|
||||
// 下拉刷新
|
||||
Future onRefresh() async {
|
||||
queryLiveList('init');
|
||||
fetchLiveFollowing();
|
||||
}
|
||||
|
||||
// 上拉加载
|
||||
@ -61,4 +65,17 @@ class LiveController extends GetxController {
|
||||
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
Future fetchLiveFollowing() async {
|
||||
var res = await LiveHttp.liveFollowing(pn: 1, ps: 20);
|
||||
if (res['status']) {
|
||||
liveFollowingList.value =
|
||||
(res['data'].list as List<LiveFollowingItemModel>)
|
||||
.where((LiveFollowingItemModel item) =>
|
||||
item.liveStatus == 1 && item.recordLiveTime == 0) // 根据条件过滤
|
||||
.toList();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,8 @@ import 'package:get/get.dart';
|
||||
import 'package:pilipala/common/constants.dart';
|
||||
import 'package:pilipala/common/skeleton/video_card_v.dart';
|
||||
import 'package:pilipala/common/widgets/http_error.dart';
|
||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
import 'package:pilipala/models/live/follow.dart';
|
||||
import 'package:pilipala/utils/main_stream.dart';
|
||||
|
||||
import 'controller.dart';
|
||||
@ -22,6 +24,7 @@ class _LivePageState extends State<LivePage>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
final LiveController _liveController = Get.put(LiveController());
|
||||
late Future _futureBuilderFuture;
|
||||
late Future _futureBuilderFuture2;
|
||||
late ScrollController scrollController;
|
||||
|
||||
@override
|
||||
@ -31,6 +34,7 @@ class _LivePageState extends State<LivePage>
|
||||
void initState() {
|
||||
super.initState();
|
||||
_futureBuilderFuture = _liveController.queryLiveList('init');
|
||||
_futureBuilderFuture2 = _liveController.fetchLiveFollowing();
|
||||
scrollController = _liveController.scrollController;
|
||||
scrollController.addListener(
|
||||
() {
|
||||
@ -69,6 +73,7 @@ class _LivePageState extends State<LivePage>
|
||||
child: CustomScrollView(
|
||||
controller: _liveController.scrollController,
|
||||
slivers: [
|
||||
buildFollowingList(),
|
||||
SliverPadding(
|
||||
// 单列布局 EdgeInsets.zero
|
||||
padding:
|
||||
@ -147,4 +152,148 @@ class _LivePageState extends State<LivePage>
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 关注的up直播
|
||||
Widget buildFollowingList() {
|
||||
return SliverPadding(
|
||||
padding: const EdgeInsets.only(top: 16),
|
||||
sliver: SliverToBoxAdapter(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Obx(
|
||||
() => Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
const TextSpan(
|
||||
text: ' 我的关注 ',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: ' ${_liveController.liveFollowingList.length}',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: '人正在直播',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
FutureBuilder(
|
||||
future: _futureBuilderFuture2,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
if (snapshot.data == null) {
|
||||
return const SizedBox();
|
||||
}
|
||||
Map? data = snapshot.data;
|
||||
if (data?['status']) {
|
||||
RxList list = _liveController.liveFollowingList;
|
||||
// ignore: invalid_use_of_protected_member
|
||||
return Obx(() => LiveFollowingListView(list: list.value));
|
||||
} else {
|
||||
return SizedBox(
|
||||
height: 80,
|
||||
child: Center(
|
||||
child: Text(
|
||||
data?['msg'] ?? '',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return const SizedBox();
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class LiveFollowingListView extends StatelessWidget {
|
||||
final List list;
|
||||
|
||||
const LiveFollowingListView({super.key, required this.list});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 100,
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemBuilder: (context, index) {
|
||||
final LiveFollowingItemModel item = list[index];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(3, 12, 3, 0),
|
||||
child: Column(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Get.toNamed(
|
||||
'/liveRoom?roomid=${item.roomId}',
|
||||
arguments: {
|
||||
'liveItem': item,
|
||||
'heroTag': item.roomId.toString()
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
width: 54,
|
||||
height: 54,
|
||||
padding: const EdgeInsets.all(2),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(27),
|
||||
border: Border.all(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
width: 1.5,
|
||||
),
|
||||
),
|
||||
child: NetworkImgLayer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
type: 'avatar',
|
||||
src: list[index].face,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
SizedBox(
|
||||
width: 62,
|
||||
child: Text(
|
||||
list[index].uname,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: list.length,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,6 +48,7 @@ class LiveRoomController extends GetxController {
|
||||
// 直播间弹幕开关 默认打开
|
||||
RxBool danmakuSwitch = true.obs;
|
||||
late String buvid;
|
||||
RxBool isPortrait = false.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@ -58,11 +59,12 @@ class LiveRoomController extends GetxController {
|
||||
if (Get.arguments != null) {
|
||||
liveItem = Get.arguments['liveItem'];
|
||||
heroTag = Get.arguments['heroTag'] ?? '';
|
||||
if (liveItem != null && liveItem.pic != null && liveItem.pic != '') {
|
||||
cover = liveItem.pic;
|
||||
}
|
||||
if (liveItem != null && liveItem.cover != null && liveItem.cover != '') {
|
||||
cover = liveItem.cover;
|
||||
if (liveItem != null) {
|
||||
cover = (liveItem.pic != null && liveItem.pic != '')
|
||||
? liveItem.pic
|
||||
: (liveItem.cover != null && liveItem.cover != '')
|
||||
? liveItem.cover
|
||||
: null;
|
||||
}
|
||||
Request.getBuvid().then((value) => buvid = value);
|
||||
}
|
||||
@ -100,6 +102,7 @@ class LiveRoomController extends GetxController {
|
||||
Future queryLiveInfo() async {
|
||||
var res = await LiveHttp.liveRoomInfo(roomId: roomId, qn: currentQn);
|
||||
if (res['status']) {
|
||||
isPortrait.value = res['data'].isPortrait;
|
||||
List<CodecItem> codec =
|
||||
res['data'].playurlInfo.playurl.stream.first.format.first.codec;
|
||||
CodecItem item = codec.first;
|
||||
|
||||
@ -115,6 +115,9 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
plPlayerController = _liveRoomController.plPlayerController;
|
||||
return PLVideoPlayer(
|
||||
controller: plPlayerController,
|
||||
alignment: _liveRoomController.isPortrait.value
|
||||
? Alignment.topCenter
|
||||
: Alignment.center,
|
||||
bottomControl: BottomControl(
|
||||
controller: plPlayerController,
|
||||
liveRoomCtr: _liveRoomController,
|
||||
@ -178,64 +181,18 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AppBar(
|
||||
centerTitle: false,
|
||||
titleSpacing: 0,
|
||||
backgroundColor: Colors.transparent,
|
||||
foregroundColor: Colors.white,
|
||||
toolbarHeight:
|
||||
MediaQuery.of(context).orientation == Orientation.portrait
|
||||
? 56
|
||||
: 0,
|
||||
title: FutureBuilder(
|
||||
future: _futureBuilder,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.data == null) {
|
||||
return const SizedBox();
|
||||
}
|
||||
Map data = snapshot.data as Map;
|
||||
if (data['status']) {
|
||||
return Obx(
|
||||
() => Row(
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
width: 34,
|
||||
height: 34,
|
||||
type: 'avatar',
|
||||
src: _liveRoomController
|
||||
.roomInfoH5.value.anchorInfo!.baseInfo!.face,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
_liveRoomController.roomInfoH5.value
|
||||
.anchorInfo!.baseInfo!.uname!,
|
||||
style: const TextStyle(fontSize: 14),
|
||||
),
|
||||
const SizedBox(height: 1),
|
||||
if (_liveRoomController
|
||||
.roomInfoH5.value.watchedShow !=
|
||||
null)
|
||||
Text(
|
||||
_liveRoomController.roomInfoH5.value
|
||||
.watchedShow!['text_large'] ??
|
||||
'',
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return const SizedBox();
|
||||
}
|
||||
},
|
||||
Obx(
|
||||
() => SizedBox(
|
||||
height: MediaQuery.of(context).padding.top +
|
||||
(_liveRoomController.isPortrait.value ||
|
||||
MediaQuery.of(context).orientation ==
|
||||
Orientation.landscape
|
||||
? 0
|
||||
: kToolbarHeight),
|
||||
),
|
||||
),
|
||||
PopScope(
|
||||
@ -249,66 +206,141 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
verticalScreen();
|
||||
}
|
||||
},
|
||||
child: SizedBox(
|
||||
width: Get.size.width,
|
||||
height: MediaQuery.of(context).orientation ==
|
||||
Orientation.landscape
|
||||
? Get.size.height
|
||||
: Get.size.width * 9 / 16,
|
||||
child: videoPlayerPanel,
|
||||
child: Obx(
|
||||
() => Container(
|
||||
width: Get.size.width,
|
||||
height: MediaQuery.of(context).orientation ==
|
||||
Orientation.landscape
|
||||
? Get.size.height
|
||||
: !_liveRoomController.isPortrait.value
|
||||
? Get.size.width * 9 / 16
|
||||
: Get.size.height -
|
||||
MediaQuery.of(context).padding.top,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(6)),
|
||||
),
|
||||
child: videoPlayerPanel,
|
||||
),
|
||||
),
|
||||
),
|
||||
// 显示消息的列表
|
||||
buildMessageListUI(
|
||||
],
|
||||
),
|
||||
// 定位 快速滑动到底部
|
||||
Positioned(
|
||||
right: 20,
|
||||
bottom: MediaQuery.of(context).padding.bottom + 80,
|
||||
child: SlideTransition(
|
||||
position: Tween<Offset>(
|
||||
begin: const Offset(0, 4),
|
||||
end: const Offset(0, 0),
|
||||
).animate(CurvedAnimation(
|
||||
parent: fabAnimationCtr,
|
||||
curve: Curves.easeInOut,
|
||||
)),
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
_scrollToBottom();
|
||||
},
|
||||
icon: const Icon(Icons.keyboard_arrow_down), // 图标
|
||||
label: const Text('新消息'), // 文字
|
||||
style: ElevatedButton.styleFrom(
|
||||
// primary: Colors.blue, // 按钮背景颜色
|
||||
// onPrimary: Colors.white, // 按钮文字颜色
|
||||
padding: const EdgeInsets.fromLTRB(14, 12, 20, 12), // 按钮内边距
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// 顶栏
|
||||
Positioned(
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: AppBar(
|
||||
centerTitle: false,
|
||||
titleSpacing: 0,
|
||||
backgroundColor: Colors.transparent,
|
||||
foregroundColor: Colors.white,
|
||||
toolbarHeight:
|
||||
MediaQuery.of(context).orientation == Orientation.portrait
|
||||
? 56
|
||||
: 0,
|
||||
title: FutureBuilder(
|
||||
future: _futureBuilder,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.data == null) {
|
||||
return const SizedBox();
|
||||
}
|
||||
Map data = snapshot.data as Map;
|
||||
if (data['status']) {
|
||||
return Obx(
|
||||
() => Row(
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
width: 34,
|
||||
height: 34,
|
||||
type: 'avatar',
|
||||
src: _liveRoomController
|
||||
.roomInfoH5.value.anchorInfo!.baseInfo!.face,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
_liveRoomController.roomInfoH5.value.anchorInfo!
|
||||
.baseInfo!.uname!,
|
||||
style: const TextStyle(fontSize: 14),
|
||||
),
|
||||
const SizedBox(height: 1),
|
||||
if (_liveRoomController
|
||||
.roomInfoH5.value.watchedShow !=
|
||||
null)
|
||||
Text(
|
||||
_liveRoomController.roomInfoH5.value
|
||||
.watchedShow!['text_large'] ??
|
||||
'',
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return const SizedBox();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
// 消息列表
|
||||
Obx(
|
||||
() => Positioned(
|
||||
top: MediaQuery.of(context).padding.top +
|
||||
kToolbarHeight +
|
||||
(_liveRoomController.isPortrait.value
|
||||
? Get.size.width
|
||||
: Get.size.width * 9 / 16),
|
||||
bottom: 90 + MediaQuery.of(context).padding.bottom,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: buildMessageListUI(
|
||||
context,
|
||||
_liveRoomController,
|
||||
_scrollController,
|
||||
),
|
||||
// Container(
|
||||
// padding: const EdgeInsets.only(
|
||||
// left: 14, right: 14, top: 4, bottom: 4),
|
||||
// margin: const EdgeInsets.only(
|
||||
// bottom: 6,
|
||||
// left: 14,
|
||||
// ),
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.grey.withOpacity(0.1),
|
||||
// borderRadius: const BorderRadius.all(Radius.circular(20)),
|
||||
// ),
|
||||
// child: Obx(
|
||||
// () => AnimatedSwitcher(
|
||||
// duration: const Duration(milliseconds: 300),
|
||||
// transitionBuilder:
|
||||
// (Widget child, Animation<double> animation) {
|
||||
// return FadeTransition(opacity: animation, child: child);
|
||||
// },
|
||||
// child: Text.rich(
|
||||
// key:
|
||||
// ValueKey(_liveRoomController.joinRoomTip['userName']),
|
||||
// TextSpan(
|
||||
// style: const TextStyle(color: Colors.white),
|
||||
// children: [
|
||||
// TextSpan(
|
||||
// text:
|
||||
// '${_liveRoomController.joinRoomTip['userName']} ',
|
||||
// style: TextStyle(
|
||||
// color: Colors.white.withOpacity(0.6),
|
||||
// ),
|
||||
// ),
|
||||
// TextSpan(
|
||||
// text:
|
||||
// '${_liveRoomController.joinRoomTip['message']}',
|
||||
// style: const TextStyle(color: Colors.white),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
const SizedBox(height: 10),
|
||||
// 弹幕输入框
|
||||
Container(
|
||||
),
|
||||
),
|
||||
// 消息输入框
|
||||
Visibility(
|
||||
visible: MediaQuery.of(context).orientation == Orientation.portrait,
|
||||
child: Positioned(
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(
|
||||
left: 14,
|
||||
right: 14,
|
||||
@ -384,32 +416,6 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// 定位 快速滑动到底部
|
||||
Positioned(
|
||||
right: 20,
|
||||
bottom: MediaQuery.of(context).padding.bottom + 80,
|
||||
child: SlideTransition(
|
||||
position: Tween<Offset>(
|
||||
begin: const Offset(0, 4),
|
||||
end: const Offset(0, 0),
|
||||
).animate(CurvedAnimation(
|
||||
parent: fabAnimationCtr,
|
||||
curve: Curves.easeInOut,
|
||||
)),
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
_scrollToBottom();
|
||||
},
|
||||
icon: const Icon(Icons.keyboard_arrow_down), // 图标
|
||||
label: const Text('新消息'), // 文字
|
||||
style: ElevatedButton.styleFrom(
|
||||
// primary: Colors.blue, // 按钮背景颜色
|
||||
// onPrimary: Colors.white, // 按钮文字颜色
|
||||
padding: const EdgeInsets.fromLTRB(14, 12, 20, 12), // 按钮内边距
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -467,7 +473,9 @@ Widget buildMessageListUI(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.withOpacity(0.1),
|
||||
color: liveRoomController.isPortrait.value
|
||||
? Colors.black.withOpacity(0.3)
|
||||
: Colors.grey.withOpacity(0.1),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
||||
),
|
||||
margin: EdgeInsets.only(
|
||||
|
||||
@ -240,4 +240,6 @@ class MemberController extends GetxController {
|
||||
}
|
||||
|
||||
void pushfavPage() => Get.toNamed('/fav?mid=$mid');
|
||||
// 跳转图文专栏
|
||||
void pushArticlePage() => Get.toNamed('/memberArticle?mid=$mid');
|
||||
}
|
||||
|
||||
@ -29,7 +29,8 @@ class _MemberPageState extends State<MemberPage>
|
||||
late Future _memberCoinsFuture;
|
||||
late Future _memberLikeFuture;
|
||||
final ScrollController _extendNestCtr = ScrollController();
|
||||
final StreamController<bool> appbarStream = StreamController<bool>();
|
||||
final StreamController<bool> appbarStream =
|
||||
StreamController<bool>.broadcast();
|
||||
late int mid;
|
||||
|
||||
@override
|
||||
@ -170,32 +171,44 @@ class _MemberPageState extends State<MemberPage>
|
||||
),
|
||||
|
||||
/// 视频
|
||||
Obx(() => ListTile(
|
||||
onTap: _memberController.pushArchivesPage,
|
||||
title: Text(
|
||||
'${_memberController.isOwner.value ? '我' : 'Ta'}的投稿'),
|
||||
trailing: const Icon(Icons.arrow_forward_outlined,
|
||||
size: 19),
|
||||
)),
|
||||
Obx(
|
||||
() => ListTile(
|
||||
onTap: _memberController.pushArchivesPage,
|
||||
title: Text(
|
||||
'${_memberController.isOwner.value ? '我' : 'Ta'}的投稿'),
|
||||
trailing:
|
||||
const Icon(Icons.arrow_forward_outlined, size: 19),
|
||||
),
|
||||
),
|
||||
|
||||
/// 他的收藏夹
|
||||
Obx(() => ListTile(
|
||||
onTap: _memberController.pushfavPage,
|
||||
title: Text(
|
||||
'${_memberController.isOwner.value ? '我' : 'Ta'}的收藏'),
|
||||
trailing: const Icon(Icons.arrow_forward_outlined,
|
||||
size: 19),
|
||||
)),
|
||||
Obx(
|
||||
() => ListTile(
|
||||
onTap: _memberController.pushfavPage,
|
||||
title: Text(
|
||||
'${_memberController.isOwner.value ? '我' : 'Ta'}的收藏'),
|
||||
trailing:
|
||||
const Icon(Icons.arrow_forward_outlined, size: 19),
|
||||
),
|
||||
),
|
||||
|
||||
/// 专栏
|
||||
Obx(() => ListTile(
|
||||
Obx(
|
||||
() => ListTile(
|
||||
onTap: _memberController.pushArticlePage,
|
||||
title: Text(
|
||||
'${_memberController.isOwner.value ? '我' : 'Ta'}的专栏'))),
|
||||
'${_memberController.isOwner.value ? '我' : 'Ta'}的专栏'),
|
||||
trailing:
|
||||
const Icon(Icons.arrow_forward_outlined, size: 19),
|
||||
),
|
||||
),
|
||||
|
||||
/// 合集
|
||||
Obx(() => ListTile(
|
||||
title: Text(
|
||||
'${_memberController.isOwner.value ? '我' : 'Ta'}的合集'))),
|
||||
Obx(
|
||||
() => ListTile(
|
||||
title: Text(
|
||||
'${_memberController.isOwner.value ? '我' : 'Ta'}的合集')),
|
||||
),
|
||||
MediaQuery.removePadding(
|
||||
removeTop: true,
|
||||
removeBottom: true,
|
||||
@ -406,7 +419,7 @@ class _MemberPageState extends State<MemberPage>
|
||||
? '个人认证:'
|
||||
: '企业认证:',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
children: [
|
||||
TextSpan(
|
||||
|
||||
@ -27,10 +27,13 @@ class MemberArchiveController extends GetxController {
|
||||
|
||||
// 获取用户投稿
|
||||
Future getMemberArchive(type) async {
|
||||
if (isLoading.value) {
|
||||
return;
|
||||
}
|
||||
isLoading.value = true;
|
||||
if (type == 'init') {
|
||||
pn = 1;
|
||||
archivesList.clear();
|
||||
isLoading.value = true;
|
||||
}
|
||||
var res = await MemberHttp.memberArchive(
|
||||
mid: mid,
|
||||
|
||||
68
lib/pages/member_article/controller.dart
Normal file
68
lib/pages/member_article/controller.dart
Normal file
@ -0,0 +1,68 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/http/member.dart';
|
||||
import 'package:pilipala/models/member/article.dart';
|
||||
|
||||
class MemberArticleController extends GetxController {
|
||||
final ScrollController scrollController = ScrollController();
|
||||
late int mid;
|
||||
int pn = 1;
|
||||
String? offset;
|
||||
bool hasMore = true;
|
||||
String? wWebid;
|
||||
RxBool isLoading = false.obs;
|
||||
RxList<MemberArticleItemModel> articleList = <MemberArticleItemModel>[].obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
mid = int.parse(Get.parameters['mid']!);
|
||||
}
|
||||
|
||||
// 获取wWebid
|
||||
Future getWWebid() async {
|
||||
var res = await MemberHttp.getWWebid(mid: mid);
|
||||
if (res['status']) {
|
||||
wWebid = res['data'];
|
||||
} else {
|
||||
wWebid = '-1';
|
||||
SmartDialog.showToast(res['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
Future getMemberArticle(type) async {
|
||||
if (isLoading.value) {
|
||||
return;
|
||||
}
|
||||
isLoading.value = true;
|
||||
if (wWebid == null) {
|
||||
await getWWebid();
|
||||
}
|
||||
if (type == 'init') {
|
||||
pn = 1;
|
||||
articleList.clear();
|
||||
}
|
||||
var res = await MemberHttp.getMemberArticle(
|
||||
mid: mid,
|
||||
pn: pn,
|
||||
offset: offset,
|
||||
wWebid: wWebid!,
|
||||
);
|
||||
if (res['status']) {
|
||||
offset = res['data'].offset;
|
||||
hasMore = res['data'].hasMore!;
|
||||
if (type == 'init') {
|
||||
articleList.value = res['data'].items;
|
||||
}
|
||||
if (type == 'onLoad') {
|
||||
articleList.addAll(res['data'].items);
|
||||
}
|
||||
pn += 1;
|
||||
} else {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
}
|
||||
isLoading.value = false;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
4
lib/pages/member_article/index.dart
Normal file
4
lib/pages/member_article/index.dart
Normal file
@ -0,0 +1,4 @@
|
||||
library member_article;
|
||||
|
||||
export './controller.dart';
|
||||
export './view.dart';
|
||||
176
lib/pages/member_article/view.dart
Normal file
176
lib/pages/member_article/view.dart
Normal file
@ -0,0 +1,176 @@
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/common/skeleton/skeleton.dart';
|
||||
import 'package:pilipala/common/widgets/http_error.dart';
|
||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
import 'package:pilipala/common/widgets/no_data.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
|
||||
import 'controller.dart';
|
||||
|
||||
class MemberArticlePage extends StatefulWidget {
|
||||
const MemberArticlePage({super.key});
|
||||
|
||||
@override
|
||||
State<MemberArticlePage> createState() => _MemberArticlePageState();
|
||||
}
|
||||
|
||||
class _MemberArticlePageState extends State<MemberArticlePage> {
|
||||
late MemberArticleController _memberArticleController;
|
||||
late Future _futureBuilderFuture;
|
||||
late ScrollController scrollController;
|
||||
late int mid;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
mid = int.parse(Get.parameters['mid']!);
|
||||
final String heroTag = Utils.makeHeroTag(mid);
|
||||
_memberArticleController = Get.put(MemberArticleController(), tag: heroTag);
|
||||
_futureBuilderFuture = _memberArticleController.getMemberArticle('init');
|
||||
scrollController = _memberArticleController.scrollController;
|
||||
|
||||
scrollController.addListener(_scrollListener);
|
||||
}
|
||||
|
||||
void _scrollListener() {
|
||||
if (scrollController.position.pixels >=
|
||||
scrollController.position.maxScrollExtent - 200) {
|
||||
EasyThrottle.throttle(
|
||||
'member_archives', const Duration(milliseconds: 500), () {
|
||||
_memberArticleController.getMemberArticle('onLoad');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: 0,
|
||||
centerTitle: false,
|
||||
title: const Text('Ta的图文', style: TextStyle(fontSize: 16)),
|
||||
),
|
||||
body: FutureBuilder(
|
||||
future: _futureBuilderFuture,
|
||||
builder: (BuildContext context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
if (snapshot.data != null) {
|
||||
return _buildContent(snapshot.data as Map);
|
||||
} else {
|
||||
return _buildError(snapshot.data['msg']);
|
||||
}
|
||||
} else {
|
||||
return ListView.builder(
|
||||
itemCount: 10,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return _buildSkeleton();
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildContent(Map data) {
|
||||
RxList list = _memberArticleController.articleList;
|
||||
if (data['status']) {
|
||||
return Obx(
|
||||
() => list.isNotEmpty
|
||||
? ListView.separated(
|
||||
controller: scrollController,
|
||||
itemCount: list.length,
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return Divider(
|
||||
height: 10,
|
||||
color: Theme.of(context).dividerColor.withOpacity(0.15),
|
||||
);
|
||||
},
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return _buildListItem(list[index]);
|
||||
},
|
||||
)
|
||||
: const CustomScrollView(
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
NoData(),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return _buildError(data['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildListItem(dynamic item) {
|
||||
return ListTile(
|
||||
onTap: () {
|
||||
Get.toNamed('/opus', parameters: {
|
||||
'title': item.content,
|
||||
'id': item.opusId,
|
||||
'articleType': 'opus',
|
||||
});
|
||||
},
|
||||
leading: NetworkImgLayer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
type: 'emote',
|
||||
src: item.cover['url'],
|
||||
),
|
||||
title: Text(
|
||||
item.content,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
subtitle: Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: Text(
|
||||
'${item.stat["like"]}人点赞',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildError(String errMsg) {
|
||||
return CustomScrollView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
SliverToBoxAdapter(
|
||||
child: HttpError(
|
||||
errMsg: errMsg,
|
||||
fn: () {},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSkeleton() {
|
||||
return Skeleton(
|
||||
child: ListTile(
|
||||
leading: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
),
|
||||
title: Container(
|
||||
height: 16,
|
||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
||||
),
|
||||
subtitle: Container(
|
||||
height: 11,
|
||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -21,7 +21,7 @@ class MemberSeasonsController extends GetxController {
|
||||
mid = int.parse(Get.parameters['mid']!);
|
||||
category = Get.parameters['category']!;
|
||||
if (category == '0') {
|
||||
seasonId = int.parse(Get.parameters['seriesId']!);
|
||||
seasonId = int.parse(Get.parameters['seasonId']!);
|
||||
}
|
||||
if (category == '1') {
|
||||
seriesId = int.parse(Get.parameters['seriesId']!);
|
||||
|
||||
@ -203,9 +203,9 @@ class LikeItem extends StatelessWidget {
|
||||
Text.rich(TextSpan(children: [
|
||||
TextSpan(text: nickNameList.join('、')),
|
||||
const TextSpan(text: ' '),
|
||||
if (item.users!.length > 1)
|
||||
if (item.counts! > 1)
|
||||
TextSpan(
|
||||
text: '等总计${item.users!.length}人',
|
||||
text: '等总计${item.counts}人',
|
||||
style: TextStyle(color: outline),
|
||||
),
|
||||
TextSpan(
|
||||
|
||||
100
lib/pages/opus/controller.dart
Normal file
100
lib/pages/opus/controller.dart
Normal file
@ -0,0 +1,100 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/http/read.dart';
|
||||
import 'package:pilipala/models/read/opus.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:pilipala/plugin/pl_gallery/hero_dialog_route.dart';
|
||||
import 'package:pilipala/plugin/pl_gallery/interactiveviewer_gallery.dart';
|
||||
|
||||
class OpusController extends GetxController {
|
||||
late String url;
|
||||
RxString title = ''.obs;
|
||||
late String id;
|
||||
late String articleType;
|
||||
Rx<OpusDataModel> opusData = OpusDataModel().obs;
|
||||
final ScrollController scrollController = ScrollController();
|
||||
late StreamController<bool> appbarStream = StreamController<bool>.broadcast();
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
title.value = Get.parameters['title'] ?? '';
|
||||
id = Get.parameters['id']!;
|
||||
articleType = Get.parameters['articleType']!;
|
||||
if (articleType == 'opus') {
|
||||
url = 'https://www.bilibili.com/opus/$id';
|
||||
}
|
||||
scrollController.addListener(_scrollListener);
|
||||
}
|
||||
|
||||
Future fetchOpusData() async {
|
||||
var res = await ReadHttp.parseArticleOpus(id: id);
|
||||
if (res['status']) {
|
||||
List<String> keys = res.keys.toList();
|
||||
if (keys.contains('isCv') && res['isCv']) {
|
||||
Get.offNamed('/read', parameters: {
|
||||
'id': res['cvId'],
|
||||
'title': title.value,
|
||||
'articleType': 'cv',
|
||||
});
|
||||
} else {
|
||||
opusData.value = res['data'];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void _scrollListener() {
|
||||
final double offset = scrollController.position.pixels;
|
||||
if (offset > 100) {
|
||||
appbarStream.add(true);
|
||||
} else {
|
||||
appbarStream.add(false);
|
||||
}
|
||||
}
|
||||
|
||||
void onPreviewImg(picList, initIndex, context) {
|
||||
Navigator.of(context).push(
|
||||
HeroDialogRoute<void>(
|
||||
builder: (BuildContext context) => InteractiveviewerGallery(
|
||||
sources: picList,
|
||||
initIndex: initIndex,
|
||||
itemBuilder: (
|
||||
BuildContext context,
|
||||
int index,
|
||||
bool isFocus,
|
||||
bool enablePageView,
|
||||
) {
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
if (enablePageView) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
child: Center(
|
||||
child: Hero(
|
||||
tag: picList[index],
|
||||
child: CachedNetworkImage(
|
||||
fadeInDuration: const Duration(milliseconds: 0),
|
||||
imageUrl: picList[index],
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
onPageChanged: (int pageIndex) {},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
scrollController.removeListener(_scrollListener);
|
||||
appbarStream.close();
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
4
lib/pages/opus/index.dart
Normal file
4
lib/pages/opus/index.dart
Normal file
@ -0,0 +1,4 @@
|
||||
library opus;
|
||||
|
||||
export 'controller.dart';
|
||||
export 'view.dart';
|
||||
62
lib/pages/opus/text_helper.dart
Normal file
62
lib/pages/opus/text_helper.dart
Normal file
@ -0,0 +1,62 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pilipala/models/read/opus.dart';
|
||||
|
||||
class TextHelper {
|
||||
static Alignment getAlignment(int? align) {
|
||||
switch (align) {
|
||||
case 1:
|
||||
return Alignment.center;
|
||||
case 0:
|
||||
return Alignment.centerLeft;
|
||||
case 2:
|
||||
return Alignment.centerRight;
|
||||
default:
|
||||
return Alignment.centerLeft;
|
||||
}
|
||||
}
|
||||
|
||||
static TextSpan buildTextSpan(
|
||||
ModuleParagraphTextNode node, int? align, BuildContext context) {
|
||||
// 获取node的所有key
|
||||
if (node.nodeType != null) {
|
||||
return TextSpan(
|
||||
text: node.word?.words ?? '',
|
||||
style: TextStyle(
|
||||
fontSize:
|
||||
node.word?.fontSize != null ? node.word!.fontSize! * 0.95 : 14,
|
||||
fontWeight: node.word?.style?.bold != null
|
||||
? FontWeight.bold
|
||||
: FontWeight.normal,
|
||||
height: align == 1 ? 2 : 1.5,
|
||||
color: node.word?.color != null
|
||||
? Color(int.parse(node.word!.color!.substring(1, 7), radix: 16) +
|
||||
0xFF000000)
|
||||
: Theme.of(context).colorScheme.onBackground,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
switch (node.type) {
|
||||
case 'TEXT_NODE_TYPE_WORD':
|
||||
return TextSpan(
|
||||
text: node.word?.words ?? '',
|
||||
style: TextStyle(
|
||||
fontSize: node.word?.fontSize != null
|
||||
? node.word!.fontSize! * 0.95
|
||||
: 14,
|
||||
fontWeight: node.word?.style?.bold != null
|
||||
? FontWeight.bold
|
||||
: FontWeight.normal,
|
||||
height: align == 1 ? 2 : 1.5,
|
||||
color: node.word?.color != null
|
||||
? Color(
|
||||
int.parse(node.word!.color!.substring(1, 7), radix: 16) +
|
||||
0xFF000000)
|
||||
: Theme.of(context).colorScheme.onBackground,
|
||||
),
|
||||
);
|
||||
default:
|
||||
return const TextSpan(text: '');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
286
lib/pages/opus/view.dart
Normal file
286
lib/pages/opus/view.dart
Normal file
@ -0,0 +1,286 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
import 'package:pilipala/models/read/opus.dart';
|
||||
import 'controller.dart';
|
||||
import 'text_helper.dart';
|
||||
|
||||
class OpusPage extends StatefulWidget {
|
||||
const OpusPage({super.key});
|
||||
|
||||
@override
|
||||
State<OpusPage> createState() => _OpusPageState();
|
||||
}
|
||||
|
||||
class _OpusPageState extends State<OpusPage> {
|
||||
final OpusController controller = Get.put(OpusController());
|
||||
late Future _futureBuilderFuture;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_futureBuilderFuture = controller.fetchOpusData();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: _buildAppBar(),
|
||||
body: SingleChildScrollView(
|
||||
controller: controller.scrollController,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildTitle(),
|
||||
_buildFutureContent(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
AppBar _buildAppBar() {
|
||||
return AppBar(
|
||||
title: StreamBuilder(
|
||||
stream: controller.appbarStream.stream.distinct(),
|
||||
initialData: false,
|
||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||
return AnimatedOpacity(
|
||||
opacity: snapshot.data ? 1 : 0,
|
||||
curve: Curves.easeOut,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
child: Obx(
|
||||
() => Text(
|
||||
controller.title.value,
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.more_vert_rounded),
|
||||
onPressed: () {},
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTitle() {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 4),
|
||||
child: Obx(
|
||||
() => Text(
|
||||
controller.title.value,
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
letterSpacing: 1,
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFutureContent() {
|
||||
return FutureBuilder(
|
||||
future: _futureBuilderFuture,
|
||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
if (snapshot.data == null) {
|
||||
return const SizedBox();
|
||||
}
|
||||
if (snapshot.data['status']) {
|
||||
return _buildContent(controller.opusData.value);
|
||||
} else {
|
||||
return _buildError(snapshot.data['message']);
|
||||
}
|
||||
} else {
|
||||
return _buildLoading();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildContent(OpusDataModel opusData) {
|
||||
if (opusData.detail == null) {
|
||||
return const SizedBox();
|
||||
}
|
||||
final modules = opusData.detail!.modules!;
|
||||
late ModuleContent moduleContent;
|
||||
// 获取所有的图片链接
|
||||
final List<String> picList = [];
|
||||
final int moduleIndex =
|
||||
modules.indexWhere((module) => module.moduleContent != null);
|
||||
if (moduleIndex != -1) {
|
||||
moduleContent = modules[moduleIndex].moduleContent!;
|
||||
for (var paragraph in moduleContent.paragraphs!) {
|
||||
if (paragraph.paraType == 2) {
|
||||
for (var pic in paragraph.pic!.pics!) {
|
||||
picList.add(pic.url!);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print('No moduleContent found');
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
16, 0, 16, MediaQuery.of(context).padding.bottom + 40),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 30),
|
||||
child: _buildStatsWidget(opusData),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 20),
|
||||
child: _buildAuthorWidget(opusData),
|
||||
),
|
||||
...moduleContent.paragraphs!.map(
|
||||
(ModuleParagraph paragraph) {
|
||||
return Column(
|
||||
children: [
|
||||
if (paragraph.paraType == 1) ...[
|
||||
Container(
|
||||
alignment: TextHelper.getAlignment(paragraph.align),
|
||||
margin: const EdgeInsets.only(bottom: 10),
|
||||
child: Text.rich(
|
||||
TextSpan(
|
||||
children: paragraph.text?.nodes?.map((node) {
|
||||
return TextHelper.buildTextSpan(
|
||||
node, paragraph.align, context);
|
||||
}).toList() ??
|
||||
[],
|
||||
),
|
||||
),
|
||||
)
|
||||
] else if (paragraph.paraType == 2) ...[
|
||||
...paragraph.pic?.pics?.map(
|
||||
(Pic pic) => Center(
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(top: 10, bottom: 10),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
controller.onPreviewImg(
|
||||
picList,
|
||||
picList.indexOf(pic.url!),
|
||||
context,
|
||||
);
|
||||
},
|
||||
child: NetworkImgLayer(
|
||||
src: pic.url,
|
||||
width: (Get.size.width - 32) * pic.scale!,
|
||||
height: (Get.size.width - 32) *
|
||||
pic.scale! /
|
||||
pic.aspectRatio!,
|
||||
type: 'emote',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
) ??
|
||||
[],
|
||||
] else
|
||||
const SizedBox(),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAuthorWidget(OpusDataModel opusData) {
|
||||
final modules = opusData.detail!.modules!;
|
||||
late ModuleAuthor moduleAuthor;
|
||||
final int moduleIndex =
|
||||
modules.indexWhere((module) => module.moduleAuthor != null);
|
||||
if (moduleIndex != -1) {
|
||||
moduleAuthor = modules[moduleIndex].moduleAuthor!;
|
||||
} else {
|
||||
return const SizedBox();
|
||||
}
|
||||
return Row(
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
width: 48,
|
||||
height: 48,
|
||||
type: 'avatar',
|
||||
src: moduleAuthor.face,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
moduleAuthor.name!,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
StyledText(moduleAuthor.pubTime!),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatsWidget(OpusDataModel opusData) {
|
||||
final modules = opusData.detail!.modules!;
|
||||
final ModuleStat moduleStat = modules.last.moduleStat!;
|
||||
return Row(
|
||||
children: [
|
||||
StyledText('${moduleStat.comment!.count}评论'),
|
||||
const SizedBox(width: 10),
|
||||
StyledText('${moduleStat.like!.count}赞'),
|
||||
const SizedBox(width: 10),
|
||||
StyledText('${moduleStat.favorite!.count}转发'),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildError(String message) {
|
||||
return SizedBox(
|
||||
height: 100,
|
||||
child: Center(
|
||||
child: Text(message),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLoading() {
|
||||
return const SizedBox(
|
||||
height: 100,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class StyledText extends StatelessWidget {
|
||||
final String text;
|
||||
|
||||
const StyledText(this.text, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
94
lib/pages/read/controller.dart
Normal file
94
lib/pages/read/controller.dart
Normal file
@ -0,0 +1,94 @@
|
||||
import 'dart:async';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/http/read.dart';
|
||||
import 'package:pilipala/models/read/read.dart';
|
||||
import 'package:pilipala/plugin/pl_gallery/hero_dialog_route.dart';
|
||||
import 'package:pilipala/plugin/pl_gallery/interactiveviewer_gallery.dart';
|
||||
|
||||
class ReadPageController extends GetxController {
|
||||
late String url;
|
||||
RxString title = ''.obs;
|
||||
late String id;
|
||||
late String articleType;
|
||||
Rx<ReadDataModel> cvData = ReadDataModel().obs;
|
||||
final ScrollController scrollController = ScrollController();
|
||||
late StreamController<bool> appbarStream = StreamController<bool>.broadcast();
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
title.value = Get.parameters['title'] ?? '';
|
||||
id = Get.parameters['id']!;
|
||||
articleType = Get.parameters['articleType']!;
|
||||
scrollController.addListener(_scrollListener);
|
||||
fetchViewInfo();
|
||||
}
|
||||
|
||||
Future fetchCvData() async {
|
||||
var res = await ReadHttp.parseArticleCv(id: id);
|
||||
if (res['status']) {
|
||||
cvData.value = res['data'];
|
||||
title.value = cvData.value.readInfo!.title!;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void _scrollListener() {
|
||||
final double offset = scrollController.position.pixels;
|
||||
if (offset > 100) {
|
||||
appbarStream.add(true);
|
||||
} else {
|
||||
appbarStream.add(false);
|
||||
}
|
||||
}
|
||||
|
||||
void onPreviewImg(picList, initIndex, context) {
|
||||
Navigator.of(context).push(
|
||||
HeroDialogRoute<void>(
|
||||
builder: (BuildContext context) => InteractiveviewerGallery(
|
||||
sources: picList,
|
||||
initIndex: initIndex,
|
||||
itemBuilder: (
|
||||
BuildContext context,
|
||||
int index,
|
||||
bool isFocus,
|
||||
bool enablePageView,
|
||||
) {
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
if (enablePageView) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
child: Center(
|
||||
child: Hero(
|
||||
tag: picList[index],
|
||||
child: CachedNetworkImage(
|
||||
fadeInDuration: const Duration(milliseconds: 0),
|
||||
imageUrl: picList[index],
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
onPageChanged: (int pageIndex) {},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void fetchViewInfo() {
|
||||
ReadHttp.getViewInfo(id: id);
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
scrollController.removeListener(_scrollListener);
|
||||
appbarStream.close();
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
4
lib/pages/read/index.dart
Normal file
4
lib/pages/read/index.dart
Normal file
@ -0,0 +1,4 @@
|
||||
library read;
|
||||
|
||||
export 'controller.dart';
|
||||
export 'view.dart';
|
||||
342
lib/pages/read/view.dart
Normal file
342
lib/pages/read/view.dart
Normal file
@ -0,0 +1,342 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/common/widgets/html_render.dart';
|
||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
import 'package:pilipala/models/read/opus.dart';
|
||||
import 'package:pilipala/models/read/read.dart';
|
||||
import 'package:pilipala/pages/opus/text_helper.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
import 'controller.dart';
|
||||
|
||||
class ReadPage extends StatefulWidget {
|
||||
const ReadPage({super.key});
|
||||
|
||||
@override
|
||||
State<ReadPage> createState() => _ReadPageState();
|
||||
}
|
||||
|
||||
class _ReadPageState extends State<ReadPage> {
|
||||
final ReadPageController controller = Get.put(ReadPageController());
|
||||
late Future _futureBuilderFuture;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_futureBuilderFuture = controller.fetchCvData();
|
||||
}
|
||||
|
||||
List<String> extractDataSrc(String input) {
|
||||
final regex = RegExp(r'data-src="([^"]*)"');
|
||||
final matches = regex.allMatches(input);
|
||||
return matches.map((match) {
|
||||
final dataSrc = match.group(1)!;
|
||||
return dataSrc.startsWith('//') ? 'https:$dataSrc' : dataSrc;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: _buildAppBar(),
|
||||
body: SingleChildScrollView(
|
||||
controller: controller.scrollController,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildTitle(),
|
||||
_buildFutureContent(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
AppBar _buildAppBar() {
|
||||
return AppBar(
|
||||
title: StreamBuilder(
|
||||
stream: controller.appbarStream.stream.distinct(),
|
||||
initialData: false,
|
||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||
return AnimatedOpacity(
|
||||
opacity: snapshot.data ? 1 : 0,
|
||||
curve: Curves.easeOut,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
child: Obx(
|
||||
() => Text(
|
||||
controller.title.value,
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.more_vert_rounded),
|
||||
onPressed: () {},
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTitle() {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 4),
|
||||
child: Obx(
|
||||
() => Text(
|
||||
controller.title.value,
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
letterSpacing: 1,
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFutureContent() {
|
||||
return FutureBuilder(
|
||||
future: _futureBuilderFuture,
|
||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
if (snapshot.data == null) {
|
||||
return const SizedBox();
|
||||
}
|
||||
if (snapshot.data['status']) {
|
||||
return _buildContent(snapshot.data['data']);
|
||||
} else {
|
||||
return _buildError(snapshot.data['message']);
|
||||
}
|
||||
} else {
|
||||
return _buildLoading();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildContent(ReadDataModel cvData) {
|
||||
final List<String> picList = _extractPicList(cvData);
|
||||
final List<String> imgList = extractDataSrc(cvData.readInfo!.content!);
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
16, 0, 16, MediaQuery.of(context).padding.bottom + 40),
|
||||
child: cvData.readInfo!.opus == null
|
||||
? _buildNonOpusContent(cvData, imgList)
|
||||
: _buildOpusContent(cvData, picList),
|
||||
);
|
||||
}
|
||||
|
||||
List<String> _extractPicList(ReadDataModel cvData) {
|
||||
final List<String> picList = [];
|
||||
if (cvData.readInfo!.opus != null) {
|
||||
final List<ModuleParagraph> paragraphs =
|
||||
cvData.readInfo!.opus!.content!.paragraphs!;
|
||||
for (var paragraph in paragraphs) {
|
||||
if (paragraph.paraType == 2) {
|
||||
for (var pic in paragraph.pic!.pics!) {
|
||||
picList.add(pic.url!);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return picList;
|
||||
}
|
||||
|
||||
Widget _buildNonOpusContent(ReadDataModel cvData, List<String> imgList) {
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 30),
|
||||
child: _buildStatsWidget(cvData),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 20),
|
||||
child: _buildAuthorWidget(cvData),
|
||||
),
|
||||
HtmlRender(
|
||||
htmlContent: cvData.readInfo!.content!,
|
||||
imgList: imgList,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildOpusContent(ReadDataModel cvData, List<String> picList) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 30),
|
||||
child: _buildStatsWidget(cvData),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 20),
|
||||
child: _buildAuthorWidget(cvData),
|
||||
),
|
||||
...cvData.readInfo!.opus!.content!.paragraphs!.map(
|
||||
(ModuleParagraph paragraph) {
|
||||
return Column(
|
||||
children: [
|
||||
if (paragraph.paraType == 1)
|
||||
_buildTextParagraph(paragraph)
|
||||
else if (paragraph.paraType == 2)
|
||||
..._buildPics(paragraph, picList)
|
||||
else
|
||||
const SizedBox(),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTextParagraph(ModuleParagraph paragraph) {
|
||||
return Container(
|
||||
alignment: TextHelper.getAlignment(paragraph.align),
|
||||
margin: const EdgeInsets.only(bottom: 10),
|
||||
child: Text.rich(
|
||||
TextSpan(
|
||||
children: paragraph.text?.nodes?.map((node) {
|
||||
return TextHelper.buildTextSpan(node, paragraph.align, context);
|
||||
}).toList() ??
|
||||
[],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildError(String message) {
|
||||
return SizedBox(
|
||||
height: 100,
|
||||
child: Center(
|
||||
child: Text(message),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLoading() {
|
||||
return const SizedBox(
|
||||
height: 100,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatsWidget(ReadDataModel cvData) {
|
||||
return Row(
|
||||
children: [
|
||||
StyledText(Utils.CustomStamp_str(
|
||||
timestamp: cvData.readInfo!.publishTime!,
|
||||
date: 'YY-MM-DD hh:mm',
|
||||
toInt: false,
|
||||
)),
|
||||
const SizedBox(width: 10),
|
||||
StyledText('${Utils.numFormat(cvData.readInfo!.stats!['view'])}浏览'),
|
||||
const StyledText(' · '),
|
||||
StyledText('${cvData.readInfo!.stats!['like']}点赞'),
|
||||
// const StyledText(' · '),
|
||||
// StyledText('${cvData.readInfo!.stats!['reply']}评论'),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAuthorWidget(ReadDataModel cvData) {
|
||||
final Author author = cvData.readInfo!.author!;
|
||||
return Row(
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
width: 48,
|
||||
height: 48,
|
||||
type: 'avatar',
|
||||
src: author.face,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
author.name!,
|
||||
style: TextStyle(
|
||||
color: author.vip!.nicknameColor != null
|
||||
? Color(author.vip!.nicknameColor!)
|
||||
: null,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Image.asset(
|
||||
'assets/images/lv/lv${author.level}.png',
|
||||
height: 11,
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
StyledText('粉丝: ${Utils.numFormat(author.fans)}'),
|
||||
const SizedBox(width: 10),
|
||||
StyledText(
|
||||
'文章: ${Utils.numFormat(cvData.readInfo!.totalArtNum)}'),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _buildPics(ModuleParagraph paragraph, List<String> picList) {
|
||||
return paragraph.pic?.pics
|
||||
?.map(
|
||||
(Pic pic) => Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 10, bottom: 10),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
controller.onPreviewImg(
|
||||
picList,
|
||||
picList.indexOf(pic.url!),
|
||||
context,
|
||||
);
|
||||
},
|
||||
child: NetworkImgLayer(
|
||||
src: pic.url,
|
||||
width: (Get.size.width - 32) * pic.scale!,
|
||||
height:
|
||||
(Get.size.width - 32) * pic.scale! / pic.aspectRatio!,
|
||||
type: 'emote',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList() ??
|
||||
[];
|
||||
}
|
||||
}
|
||||
|
||||
class StyledText extends StatelessWidget {
|
||||
final String text;
|
||||
|
||||
const StyledText(this.text, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -14,11 +14,10 @@ Widget searchArticlePanel(BuildContext context, ctr, list) {
|
||||
itemBuilder: (context, index) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
Get.toNamed('/htmlRender', parameters: {
|
||||
'url': 'www.bilibili.com/read/cv${list[index].id}',
|
||||
Get.toNamed('/read', parameters: {
|
||||
'title': list[index].subTitle,
|
||||
'id': 'cv${list[index].id}',
|
||||
'dynamicType': 'read'
|
||||
'id': list[index].id.toString(),
|
||||
'articleType': 'read'
|
||||
});
|
||||
},
|
||||
child: Padding(
|
||||
|
||||
@ -261,90 +261,97 @@ class VideoPanelController extends GetxController {
|
||||
onShowFilterSheet(searchPanelCtr) {
|
||||
showModalBottomSheet(
|
||||
context: Get.context!,
|
||||
isScrollControlled: true,
|
||||
builder: (context) {
|
||||
return StatefulBuilder(
|
||||
builder: (context, StateSetter setState) {
|
||||
return Container(
|
||||
color: Theme.of(Get.context!).colorScheme.surface,
|
||||
padding: const EdgeInsets.only(top: 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 12, bottom: MediaQuery.of(context).padding.bottom + 20),
|
||||
child: Wrap(
|
||||
children: [
|
||||
const ListTile(
|
||||
title: Text('内容时长'),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 14,
|
||||
right: 14,
|
||||
bottom: 14,
|
||||
),
|
||||
child: Wrap(
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
direction: Axis.horizontal,
|
||||
textDirection: TextDirection.ltr,
|
||||
children: [
|
||||
for (var i in timeFiltersList)
|
||||
Obx(
|
||||
() => SearchText(
|
||||
searchText: i['label'],
|
||||
searchTextIdx: i['value'],
|
||||
isSelect:
|
||||
currentTimeFilterval.value == i['value'],
|
||||
onSelect: (value) async {
|
||||
currentTimeFilterval.value = i['value'];
|
||||
setState(() {});
|
||||
SmartDialog.showToast("「${i['label']}」的筛选结果");
|
||||
SearchPanelController ctr =
|
||||
Get.find<SearchPanelController>(
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const ListTile(
|
||||
title: Text('内容时长'),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 14,
|
||||
right: 14,
|
||||
bottom: 14,
|
||||
),
|
||||
child: Wrap(
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
direction: Axis.horizontal,
|
||||
textDirection: TextDirection.ltr,
|
||||
children: [
|
||||
for (var i in timeFiltersList)
|
||||
Obx(
|
||||
() => SearchText(
|
||||
searchText: i['label'],
|
||||
searchTextIdx: i['value'],
|
||||
isSelect:
|
||||
currentTimeFilterval.value == i['value'],
|
||||
onSelect: (value) async {
|
||||
currentTimeFilterval.value = i['value'];
|
||||
setState(() {});
|
||||
SmartDialog.showToast(
|
||||
"「${i['label']}」的筛选结果");
|
||||
SearchPanelController ctr = Get.find<
|
||||
SearchPanelController>(
|
||||
tag: 'video${searchPanelCtr.keyword!}');
|
||||
ctr.duration.value = i['value'];
|
||||
Get.back();
|
||||
SmartDialog.showLoading(msg: '获取中');
|
||||
await ctr.onRefresh();
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
onLongSelect: (value) => {},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
const ListTile(
|
||||
title: Text('内容分区'),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 14, right: 14),
|
||||
child: Wrap(
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
direction: Axis.horizontal,
|
||||
textDirection: TextDirection.ltr,
|
||||
children: [
|
||||
for (var i in partFiltersList)
|
||||
SearchText(
|
||||
searchText: i['label'],
|
||||
searchTextIdx: i['value'],
|
||||
isSelect: currentPartFilterval.value == i['value'],
|
||||
onSelect: (value) async {
|
||||
currentPartFilterval.value = i['value'];
|
||||
setState(() {});
|
||||
SmartDialog.showToast("「${i['label']}」的筛选结果");
|
||||
SearchPanelController ctr =
|
||||
Get.find<SearchPanelController>(
|
||||
ctr.duration.value = i['value'];
|
||||
Get.back();
|
||||
SmartDialog.showLoading(msg: '获取中');
|
||||
await ctr.onRefresh();
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
onLongSelect: (value) => {},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
const ListTile(
|
||||
title: Text('内容分区'),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 14, right: 14),
|
||||
child: Wrap(
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
direction: Axis.horizontal,
|
||||
textDirection: TextDirection.ltr,
|
||||
children: [
|
||||
for (var i in partFiltersList)
|
||||
SearchText(
|
||||
searchText: i['label'],
|
||||
searchTextIdx: i['value'],
|
||||
isSelect:
|
||||
currentPartFilterval.value == i['value'],
|
||||
onSelect: (value) async {
|
||||
currentPartFilterval.value = i['value'];
|
||||
setState(() {});
|
||||
SmartDialog.showToast("「${i['label']}」的筛选结果");
|
||||
SearchPanelController ctr = Get.find<
|
||||
SearchPanelController>(
|
||||
tag: 'video${searchPanelCtr.keyword!}');
|
||||
ctr.tids.value = i['value'];
|
||||
Get.back();
|
||||
SmartDialog.showLoading(msg: '获取中');
|
||||
await ctr.onRefresh();
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
onLongSelect: (value) => {},
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
ctr.tids.value = i['value'];
|
||||
Get.back();
|
||||
SmartDialog.showLoading(msg: '获取中');
|
||||
await ctr.onRefresh();
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
onLongSelect: (value) => {},
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@ -24,14 +24,14 @@ class _SubDetailPageState extends State<SubDetailPage> {
|
||||
late final ScrollController _controller = ScrollController();
|
||||
final SubDetailController _subDetailController =
|
||||
Get.put(SubDetailController());
|
||||
late StreamController<bool> titleStreamC; // a
|
||||
late StreamController<bool> titleStreamC =
|
||||
StreamController<bool>.broadcast(); // a
|
||||
late Future _futureBuilderFuture;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_futureBuilderFuture = _subDetailController.queryUserSeasonList();
|
||||
titleStreamC = StreamController<bool>();
|
||||
_controller.addListener(
|
||||
() {
|
||||
if (_controller.offset > 160) {
|
||||
|
||||
@ -7,9 +7,11 @@ import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:ns_danmaku/ns_danmaku.dart';
|
||||
import 'package:pilipala/http/constants.dart';
|
||||
import 'package:pilipala/http/user.dart';
|
||||
import 'package:pilipala/http/video.dart';
|
||||
import 'package:pilipala/models/common/reply_type.dart';
|
||||
import 'package:pilipala/models/common/search_type.dart';
|
||||
import 'package:pilipala/models/video/later.dart';
|
||||
import 'package:pilipala/models/video/play/quality.dart';
|
||||
import 'package:pilipala/models/video/play/url.dart';
|
||||
import 'package:pilipala/models/video/reply/item.dart';
|
||||
@ -24,7 +26,10 @@ import '../../../models/video/subTitile/content.dart';
|
||||
import '../../../http/danmaku.dart';
|
||||
import '../../../plugin/pl_player/models/bottom_control_type.dart';
|
||||
import '../../../utils/id_utils.dart';
|
||||
import 'introduction/controller.dart';
|
||||
import 'reply/controller.dart';
|
||||
import 'widgets/header_control.dart';
|
||||
import 'widgets/watch_later_list.dart';
|
||||
|
||||
class VideoDetailController extends GetxController
|
||||
with GetSingleTickerProviderStateMixin {
|
||||
@ -37,9 +42,10 @@ class VideoDetailController extends GetxController
|
||||
Map videoItem = {};
|
||||
// 视频类型 默认投稿视频
|
||||
SearchType videoType = Get.arguments['videoType'] ?? SearchType.video;
|
||||
// 页面来源 稍后再看 收藏夹
|
||||
RxString sourceType = 'normal'.obs;
|
||||
|
||||
/// tabs相关配置
|
||||
int tabInitialIndex = 0;
|
||||
late TabController tabCtr;
|
||||
RxList<String> tabs = <String>['简介', '评论'].obs;
|
||||
|
||||
@ -110,6 +116,9 @@ class VideoDetailController extends GetxController
|
||||
RxDouble sheetHeight = 0.0.obs;
|
||||
RxString archiveSourceType = 'dash'.obs;
|
||||
ScrollController? replyScrillController;
|
||||
List<MediaVideoItemModel> mediaList = <MediaVideoItemModel>[];
|
||||
RxBool isWatchLaterVisible = false.obs;
|
||||
RxString watchLaterTitle = ''.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@ -119,9 +128,7 @@ class VideoDetailController extends GetxController
|
||||
if (argMap.containsKey('videoItem')) {
|
||||
var args = argMap['videoItem'];
|
||||
updateCover(args.pic);
|
||||
}
|
||||
|
||||
if (argMap.containsKey('pic')) {
|
||||
} else if (argMap.containsKey('pic')) {
|
||||
updateCover(argMap['pic']);
|
||||
}
|
||||
|
||||
@ -160,6 +167,21 @@ class VideoDetailController extends GetxController
|
||||
bvid: bvid,
|
||||
videoType: videoType,
|
||||
);
|
||||
|
||||
sourceType.value = argMap['sourceType'] ?? 'normal';
|
||||
isWatchLaterVisible.value =
|
||||
sourceType.value == 'watchLater' || sourceType.value == 'fav';
|
||||
if (sourceType.value == 'watchLater') {
|
||||
watchLaterTitle.value = '稍后再看';
|
||||
fetchMediaList();
|
||||
}
|
||||
if (sourceType.value == 'fav') {
|
||||
watchLaterTitle.value = argMap['favTitle'];
|
||||
queryFavVideoList();
|
||||
}
|
||||
tabCtr.addListener(() {
|
||||
onTabChanged();
|
||||
});
|
||||
}
|
||||
|
||||
showReplyReplyPanel(oid, fRpid, firstFloor, currentReply, loadMore) {
|
||||
@ -561,4 +583,101 @@ class VideoDetailController extends GetxController
|
||||
duration: const Duration(milliseconds: 300), curve: Curves.ease);
|
||||
}
|
||||
}
|
||||
|
||||
void toggeleWatchLaterVisible(bool val) {
|
||||
if (sourceType.value == 'watchLater' || sourceType.value == 'fav') {
|
||||
isWatchLaterVisible.value = !isWatchLaterVisible.value;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取稍后再看列表
|
||||
Future fetchMediaList() async {
|
||||
final Map argMap = Get.arguments;
|
||||
var count = argMap['count'];
|
||||
var res = await UserHttp.getMediaList(
|
||||
type: 2,
|
||||
bizId: userInfo.mid,
|
||||
ps: count,
|
||||
);
|
||||
if (res['status']) {
|
||||
mediaList = res['data'].reversed.toList();
|
||||
} else {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
// 稍后再看面板展开
|
||||
showMediaListPanel() {
|
||||
replyReplyBottomSheetCtr =
|
||||
scaffoldKey.currentState?.showBottomSheet((BuildContext context) {
|
||||
return MediaListPanel(
|
||||
sheetHeight: sheetHeight.value,
|
||||
mediaList: mediaList,
|
||||
changeMediaList: changeMediaList,
|
||||
panelTitle: watchLaterTitle.value,
|
||||
bvid: bvid,
|
||||
mediaId: Get.arguments['mediaId'],
|
||||
hasMore: mediaList.length != Get.arguments['count'],
|
||||
);
|
||||
});
|
||||
replyReplyBottomSheetCtr?.closed.then((value) {
|
||||
isWatchLaterVisible.value = true;
|
||||
});
|
||||
}
|
||||
|
||||
// 切换稍后再看
|
||||
Future changeMediaList(bvidVal, cidVal, aidVal, coverVal) async {
|
||||
final VideoIntroController videoIntroCtr =
|
||||
Get.find<VideoIntroController>(tag: heroTag);
|
||||
bvid = bvidVal;
|
||||
oid.value = aidVal ?? IdUtils.bv2av(bvid);
|
||||
cid.value = cidVal;
|
||||
danmakuCid.value = cidVal;
|
||||
cover.value = coverVal;
|
||||
queryVideoUrl();
|
||||
clearSubtitleContent();
|
||||
await getSubtitle();
|
||||
setSubtitleContent();
|
||||
// 重新请求评论
|
||||
try {
|
||||
/// 未渲染回复组件时可能异常
|
||||
final VideoReplyController videoReplyCtr =
|
||||
Get.find<VideoReplyController>(tag: heroTag);
|
||||
videoReplyCtr.aid = aidVal;
|
||||
videoReplyCtr.queryReplyList(type: 'init');
|
||||
} catch (_) {}
|
||||
videoIntroCtr.lastPlayCid.value = cidVal;
|
||||
videoIntroCtr.bvid = bvidVal;
|
||||
replyReplyBottomSheetCtr!.close();
|
||||
await videoIntroCtr.queryVideoIntro();
|
||||
}
|
||||
|
||||
// 获取收藏夹视频列表
|
||||
Future queryFavVideoList() async {
|
||||
final Map argMap = Get.arguments;
|
||||
var mediaId = argMap['mediaId'];
|
||||
var oid = argMap['oid'];
|
||||
var res = await UserHttp.parseFavVideo(
|
||||
mediaId: mediaId,
|
||||
oid: oid,
|
||||
bvid: bvid,
|
||||
);
|
||||
if (res['status']) {
|
||||
mediaList = res['data'];
|
||||
}
|
||||
}
|
||||
|
||||
// 监听tabBarView切换
|
||||
void onTabChanged() {
|
||||
isWatchLaterVisible.value = tabCtr.index == 0;
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
super.onClose();
|
||||
plPlayerController.dispose();
|
||||
tabCtr.removeListener(() {
|
||||
onTabChanged();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ class VideoIntroController extends GetxController {
|
||||
// 视频详情 请求返回
|
||||
Rx<VideoDetailData> videoDetail = VideoDetailData().obs;
|
||||
// up主粉丝数
|
||||
Map userStat = {'follower': '-'};
|
||||
RxInt follower = 0.obs;
|
||||
// 是否点赞
|
||||
RxBool hasLike = false.obs;
|
||||
// 是否投币
|
||||
@ -115,7 +115,7 @@ class VideoIntroController extends GetxController {
|
||||
Future queryUserStat() async {
|
||||
var result = await UserHttp.userStat(mid: videoDetail.value.owner!.mid!);
|
||||
if (result['status']) {
|
||||
userStat = result['data'];
|
||||
follower.value = result['data']['follower'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -144,7 +144,6 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
final Box<dynamic> setting = GStrorage.setting;
|
||||
late double sheetHeight;
|
||||
late final dynamic owner;
|
||||
late final dynamic follower;
|
||||
late int mid;
|
||||
late String memberHeroTag;
|
||||
late bool enableAi;
|
||||
@ -177,7 +176,6 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
sheetHeight = localCache.get('sheetHeight');
|
||||
|
||||
owner = widget.videoDetail!.owner;
|
||||
follower = Utils.numFormat(videoIntroController.userStat['follower']);
|
||||
enableAi = setting.get(SettingBoxKey.enableAi, defaultValue: true);
|
||||
_expandableCtr = ExpandableController(initialExpanded: false);
|
||||
|
||||
@ -470,13 +468,16 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
fadeOutDuration: Duration.zero,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Text(owner.name, style: const TextStyle(fontSize: 13)),
|
||||
Text(widget.videoDetail!.owner!.name!,
|
||||
style: const TextStyle(fontSize: 13)),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
follower,
|
||||
style: TextStyle(
|
||||
fontSize: t.textTheme.labelSmall!.fontSize,
|
||||
color: outline,
|
||||
Obx(
|
||||
() => Text(
|
||||
Utils.numFormat(videoIntroController.follower.value),
|
||||
style: TextStyle(
|
||||
fontSize: t.textTheme.labelSmall!.fontSize,
|
||||
color: outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
|
||||
@ -68,6 +68,10 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
late final AppLifecycleListener _lifecycleListener;
|
||||
late double statusHeight;
|
||||
|
||||
// 稍后再看控制器
|
||||
// late AnimationController _laterCtr;
|
||||
// late Animation<Offset> _laterOffsetAni;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -104,6 +108,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
}
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
lifecycleListener();
|
||||
// watchLaterControllerInit();
|
||||
}
|
||||
|
||||
// 获取视频资源,初始化播放器
|
||||
@ -211,6 +216,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
vdCtr.bottomList.removeAt(3);
|
||||
}
|
||||
}
|
||||
vdCtr.toggeleWatchLaterVisible(!isFullScreen);
|
||||
});
|
||||
}
|
||||
|
||||
@ -236,6 +242,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
appbarStream.close();
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
_lifecycleListener.dispose();
|
||||
// _laterCtr.dispose();
|
||||
// _laterOffsetAni.removeListener(() {});
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@ -482,6 +490,21 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
);
|
||||
}
|
||||
|
||||
/// 稍后再看控制器初始化
|
||||
// void watchLaterControllerInit() {
|
||||
// _laterCtr = AnimationController(
|
||||
// duration: const Duration(milliseconds: 300),
|
||||
// vsync: this,
|
||||
// );
|
||||
// _laterOffsetAni = Tween<Offset>(
|
||||
// begin: const Offset(0.0, 1.0),
|
||||
// end: Offset.zero,
|
||||
// ).animate(CurvedAnimation(
|
||||
// parent: _laterCtr,
|
||||
// curve: Curves.easeInOut,
|
||||
// ));
|
||||
// }
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final sizeContext = MediaQuery.sizeOf(context);
|
||||
@ -595,6 +618,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
child: AppBar(
|
||||
backgroundColor: Colors.black,
|
||||
elevation: 0,
|
||||
scrolledUnderElevation: 0,
|
||||
),
|
||||
),
|
||||
body: ExtendedNestedScrollView(
|
||||
@ -757,6 +781,62 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
null,
|
||||
);
|
||||
}),
|
||||
),
|
||||
|
||||
/// 稍后再看列表
|
||||
Obx(
|
||||
() => Visibility(
|
||||
visible: vdCtr.sourceType.value == 'watchLater' ||
|
||||
vdCtr.sourceType.value == 'fav',
|
||||
child: AnimatedPositioned(
|
||||
duration: const Duration(milliseconds: 400),
|
||||
curve: Curves.easeInOut,
|
||||
left: 12,
|
||||
bottom: vdCtr.isWatchLaterVisible.value
|
||||
? MediaQuery.of(context).padding.bottom + 12
|
||||
: -100,
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
vdCtr.toggeleWatchLaterVisible(
|
||||
!vdCtr.isWatchLaterVisible.value);
|
||||
vdCtr.showMediaListPanel();
|
||||
},
|
||||
borderRadius: const BorderRadius.all(Radius.circular(14)),
|
||||
child: Container(
|
||||
width: Get.width - 24,
|
||||
height: 54,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.secondaryContainer
|
||||
.withOpacity(0.95),
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(14)),
|
||||
),
|
||||
child: Row(children: [
|
||||
const Icon(Icons.playlist_play, size: 24),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
vdCtr.watchLaterTitle.value,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.onSecondaryContainer,
|
||||
fontWeight: FontWeight.bold,
|
||||
letterSpacing: 0.2,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
const Icon(Icons.keyboard_arrow_up_rounded, size: 26),
|
||||
]),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
|
||||
229
lib/pages/video/detail/widgets/watch_later_list.dart
Normal file
229
lib/pages/video/detail/widgets/watch_later_list.dart
Normal file
@ -0,0 +1,229 @@
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/common/constants.dart';
|
||||
import 'package:pilipala/common/widgets/badge.dart';
|
||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
import 'package:pilipala/common/widgets/stat/danmu.dart';
|
||||
import 'package:pilipala/common/widgets/stat/view.dart';
|
||||
import 'package:pilipala/http/search.dart';
|
||||
import 'package:pilipala/http/user.dart';
|
||||
import 'package:pilipala/models/video/later.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
|
||||
class MediaListPanel extends StatefulWidget {
|
||||
const MediaListPanel({
|
||||
this.sheetHeight,
|
||||
required this.mediaList,
|
||||
this.changeMediaList,
|
||||
this.panelTitle,
|
||||
this.bvid,
|
||||
this.mediaId,
|
||||
this.hasMore = false,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final double? sheetHeight;
|
||||
final List<MediaVideoItemModel> mediaList;
|
||||
final Function? changeMediaList;
|
||||
final String? panelTitle;
|
||||
final String? bvid;
|
||||
final int? mediaId;
|
||||
final bool hasMore;
|
||||
|
||||
@override
|
||||
State<MediaListPanel> createState() => _MediaListPanelState();
|
||||
}
|
||||
|
||||
class _MediaListPanelState extends State<MediaListPanel> {
|
||||
RxList<MediaVideoItemModel> mediaList = <MediaVideoItemModel>[].obs;
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
mediaList.value = widget.mediaList;
|
||||
_scrollController.addListener(() {
|
||||
if (_scrollController.position.pixels >=
|
||||
_scrollController.position.maxScrollExtent - 200) {
|
||||
if (widget.hasMore) {
|
||||
EasyThrottle.throttle(
|
||||
'queryFollowDynamic', const Duration(seconds: 1), () {
|
||||
loadMore();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void loadMore() async {
|
||||
var res = await UserHttp.getMediaList(
|
||||
type: 3,
|
||||
bizId: widget.mediaId!,
|
||||
ps: 20,
|
||||
oid: mediaList.last.id,
|
||||
);
|
||||
if (res['status']) {
|
||||
if (res['data'].isNotEmpty) {
|
||||
mediaList.addAll(res['data']);
|
||||
}
|
||||
} else {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: widget.sheetHeight,
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: Column(
|
||||
children: [
|
||||
AppBar(
|
||||
toolbarHeight: 45,
|
||||
automaticallyImplyLeading: false,
|
||||
centerTitle: false,
|
||||
title: Text(
|
||||
widget.panelTitle ?? '稍后再看',
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close, size: 20),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: Material(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: Obx(
|
||||
() => ListView.builder(
|
||||
controller: _scrollController,
|
||||
itemCount: mediaList.length,
|
||||
itemBuilder: ((context, index) {
|
||||
var item = mediaList[index];
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
String bvid = item.bvId!;
|
||||
int? aid = item.id;
|
||||
String cover = item.cover ?? '';
|
||||
final int cid =
|
||||
await SearchHttp.ab2c(aid: aid, bvid: bvid);
|
||||
widget.changeMediaList?.call(bvid, cid, aid, cover);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10, vertical: 8),
|
||||
child: LayoutBuilder(
|
||||
builder: (BuildContext context,
|
||||
BoxConstraints boxConstraints) {
|
||||
const double width = 120;
|
||||
return Container(
|
||||
constraints: const BoxConstraints(minHeight: 88),
|
||||
height: width / StyleString.aspectRatio,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
AspectRatio(
|
||||
aspectRatio: StyleString.aspectRatio,
|
||||
child: LayoutBuilder(
|
||||
builder: (BuildContext context,
|
||||
BoxConstraints boxConstraints) {
|
||||
final double maxWidth =
|
||||
boxConstraints.maxWidth;
|
||||
final double maxHeight =
|
||||
boxConstraints.maxHeight;
|
||||
return Stack(
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
src: item.cover ?? '',
|
||||
width: maxWidth,
|
||||
height: maxHeight,
|
||||
),
|
||||
PBadge(
|
||||
text: Utils.timeFormat(
|
||||
item.duration!),
|
||||
right: 6.0,
|
||||
bottom: 6.0,
|
||||
type: 'gray',
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(
|
||||
10, 0, 6, 0),
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.title as String,
|
||||
textAlign: TextAlign.start,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
color: item.bvId == widget.bvid
|
||||
? Theme.of(context)
|
||||
.colorScheme
|
||||
.primary
|
||||
: null,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
item.upper?.name as String,
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.labelMedium!
|
||||
.fontSize,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Row(
|
||||
children: [
|
||||
StatView(
|
||||
view: item.cntInfo!['play']
|
||||
as int),
|
||||
const SizedBox(width: 8),
|
||||
StatDanMu(
|
||||
danmu:
|
||||
item.cntInfo!['danmaku']
|
||||
as int),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user