Merge branch 'main' into fix

This commit is contained in:
guozhigq
2024-12-01 20:12:21 +08:00
61 changed files with 1622 additions and 1022 deletions

BIN
assets/images/video/dlna.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

BIN
assets/images/video/pip.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/constants.dart';
@ -98,7 +99,8 @@ class _PagesBottomSheetState extends State<PagesBottomSheet>
with TickerProviderStateMixin {
final ScrollController _listScrollController = ScrollController();
late ListObserverController _listObserverController;
final ScrollController _scrollController = ScrollController();
late GridObserverController _gridObserverController;
final ScrollController _gridScrollController = ScrollController();
late int currentIndex;
TabController? tabController;
List<ListObserverController>? _listObserverControllerList;
@ -163,6 +165,9 @@ class _PagesBottomSheetState extends State<PagesBottomSheet>
);
},
);
} else {
_gridObserverController =
GridObserverController(controller: _gridScrollController);
}
}
@ -185,18 +190,12 @@ class _PagesBottomSheetState extends State<PagesBottomSheet>
);
}
}
} else {
_gridObserverController.initialIndexModel = ObserverIndexPositionModel(
index: currentIndex,
isFixedHeight: false,
);
}
WidgetsBinding.instance.addPostFrameCallback((_) {
if (widget.dataType != VideoEpidoesType.videoEpisode) {
double itemHeight = (widget.isFullScreen
? 400
: Get.size.width - 3 * StyleString.safeSpace) /
5.2;
double offset = ((currentIndex - 1) / 2).ceil() * itemHeight;
_scrollController.jumpTo(offset);
}
});
}
// 获取订阅状态
@ -236,7 +235,9 @@ class _PagesBottomSheetState extends State<PagesBottomSheet>
void dispose() {
try {
_listObserverController.controller?.dispose();
_gridObserverController.controller?.dispose();
_listScrollController.dispose();
_gridScrollController.dispose();
for (var element in _listObserverControllerList!) {
element.controller?.dispose();
}
@ -303,24 +304,27 @@ class _PagesBottomSheetState extends State<PagesBottomSheet>
: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 12.0), // 设置左右间距为12
child: GridView.count(
controller: _scrollController,
crossAxisCount: 2,
crossAxisSpacing: StyleString.safeSpace,
childAspectRatio: 2.6,
children: List.generate(
widget.episodes.length,
(index) {
bool isCurrentIndex = currentIndex == index;
return EpisodeGridItem(
episode: widget.episodes[index],
index: index,
isCurrentIndex: isCurrentIndex,
dataType: widget.dataType,
changeFucCall: widget.changeFucCall,
isFullScreen: widget.isFullScreen,
);
},
child: GridViewObserver(
controller: _gridObserverController,
child: GridView.count(
controller: _gridScrollController,
crossAxisCount: 2,
crossAxisSpacing: StyleString.safeSpace,
childAspectRatio: 2.6,
children: List.generate(
widget.episodes.length,
(index) {
bool isCurrentIndex = currentIndex == index;
return EpisodeGridItem(
episode: widget.episodes[index],
index: index,
isCurrentIndex: isCurrentIndex,
dataType: widget.dataType,
changeFucCall: widget.changeFucCall,
isFullScreen: widget.isFullScreen,
);
},
),
),
),
),

View File

@ -0,0 +1,126 @@
import 'package:flutter/material.dart';
import '../constants.dart';
import 'skeleton.dart';
class VideoIntroSkeleton extends StatelessWidget {
const VideoIntroSkeleton({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
Color bgColor = Theme.of(context).colorScheme.onInverseSurface;
return Skeleton(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: StyleString.safeSpace),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 18),
Container(
width: double.infinity,
height: 20,
margin: const EdgeInsets.only(bottom: 6),
color: bgColor,
),
Container(
width: 220,
height: 20,
margin: const EdgeInsets.only(bottom: 12),
color: bgColor,
),
Row(
children: [
Container(
width: 45,
height: 14,
color: bgColor,
),
const SizedBox(width: 8),
Container(
width: 45,
height: 14,
color: bgColor,
),
const SizedBox(width: 8),
Container(
width: 45,
height: 14,
color: bgColor,
),
const Spacer(),
Container(
width: 35,
height: 14,
color: bgColor,
),
const SizedBox(width: 4),
],
),
const SizedBox(height: 30),
LayoutBuilder(builder: (context, constraints) {
// 并列5个正方形
double width = (constraints.maxWidth - 30) / 5;
return Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: List.generate(5, (index) {
return Container(
width: width - 24,
height: width - 24,
decoration: BoxDecoration(
color: bgColor,
borderRadius: BorderRadius.circular(16),
),
);
}),
);
}),
const SizedBox(height: 20),
Container(
width: double.infinity,
height: 30,
margin: const EdgeInsets.symmetric(horizontal: 6),
decoration: BoxDecoration(
color: bgColor,
borderRadius: BorderRadius.circular(8),
),
),
const SizedBox(height: 20),
Row(
children: [
ClipOval(
child: Container(
width: 44,
height: 44,
color: bgColor,
),
),
const SizedBox(width: 12),
Container(
width: 50,
height: 14,
color: bgColor,
),
const SizedBox(width: 8),
Container(
width: 35,
height: 14,
color: bgColor,
),
const Spacer(),
Container(
width: 55,
height: 30,
decoration: BoxDecoration(
color: bgColor,
borderRadius: BorderRadius.circular(16),
),
),
const SizedBox(width: 2)
],
),
const SizedBox(height: 10),
],
),
),
);
}
}

View File

@ -0,0 +1,25 @@
import 'package:flutter/material.dart';
class DragHandle extends StatelessWidget {
const DragHandle({super.key});
@override
Widget build(BuildContext context) {
return InkWell(
onTap: Navigator.of(context).pop,
child: SizedBox(
height: 36,
child: Center(
child: Container(
width: 32,
height: 4,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.outline,
borderRadius: BorderRadius.circular(4),
),
),
),
),
);
}
}

View File

@ -48,7 +48,7 @@ class NetworkImgLayer extends StatelessWidget {
Widget build(BuildContext context) {
int defaultImgQuality = 10;
try {
defaultImgQuality = GlobalDataCache().imgQuality;
defaultImgQuality = GlobalDataCache.imgQuality;
} catch (_) {}
if (src == '' || src == null) {

View File

@ -12,6 +12,7 @@ import '../../http/video.dart';
import '../../utils/utils.dart';
import '../constants.dart';
import 'badge.dart';
import 'drag_handle.dart';
import 'network_img_layer.dart';
import 'stat/danmu.dart';
import 'stat/view.dart';
@ -373,27 +374,12 @@ class MorePanel extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
return Padding(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
InkWell(
onTap: () => Get.back(),
child: Container(
height: 35,
padding: const EdgeInsets.only(bottom: 2),
child: Center(
child: Container(
width: 32,
height: 3,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.outline,
borderRadius: const BorderRadius.all(Radius.circular(3))),
),
),
),
),
const DragHandle(),
ListTile(
onTap: () async => await menuActionHandler('block'),
minLeadingWidth: 0,

View File

@ -5,6 +5,7 @@ import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/image_save.dart';
import 'package:pilipala/utils/route_push.dart';
import '../../models/model_rec_video_item.dart';
import 'drag_handle.dart';
import 'stat/danmu.dart';
import 'stat/view.dart';
import '../../http/dynamics.dart';
@ -368,27 +369,12 @@ class MorePanel extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
return Padding(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
InkWell(
onTap: () => Get.back(),
child: Container(
height: 35,
padding: const EdgeInsets.only(bottom: 2),
child: Center(
child: Container(
width: 32,
height: 3,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.outline,
borderRadius: const BorderRadius.all(Radius.circular(3))),
),
),
),
),
const DragHandle(),
ListTile(
onTap: () async => await menuActionHandler('block'),
minLeadingWidth: 0,

View File

@ -622,4 +622,8 @@ class Api {
/// 视频标签
static const String videoTag = '/x/tag/archive/tags';
/// 修复标题和海报
// /api/view?id=${aid} /all/video/av${aid} /video/av${aid}/
static const String fixTitleAndPic = '${HttpString.biliplusBaseUrl}/api/view';
}

View File

@ -1,8 +1,15 @@
import 'package:pilipala/models/common/invalid_video.dart';
import 'dart:convert';
import 'dart:math';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:pilipala/models/sponsor_block/segment.dart';
import 'index.dart';
class CommonHttp {
static final RegExp spmPrefixExp =
RegExp(r'<meta name="spm_prefix" content="([^"]+?)">');
static Future unReadDynamic() async {
var res = await Request().get(Api.getUnreadDynamic,
data: {'alltype_offset': 0, 'video_offset': '', 'article_offset': 0});
@ -43,4 +50,68 @@ class CommonHttp {
};
}
}
static Future fixVideoPicAndTitle({required int aid}) async {
var res = await Request().getWithoutCookie(Api.fixTitleAndPic, data: {
'id': aid,
});
if (res != null) {
if (res.data['code'] == -404) {
return {
'status': false,
'data': null,
'msg': '没有相关信息',
};
} else {
return {
'status': true,
'data': InvalidVideoModel.fromJson(res.data),
};
}
} else {
return {
'status': false,
'data': null,
'msg': '没有相关信息',
};
}
}
static Future buvidActivate() async {
try {
// 获取 HTML 数据
var html = await Request().get(Api.dynamicSpmPrefix);
// 提取 spmPrefix
String spmPrefix = spmPrefixExp.firstMatch(html.data)?.group(1) ?? '';
// 生成随机 PNG 结束部分
Random rand = Random();
String randPngEnd = base64.encode(
List<int>.generate(32, (_) => rand.nextInt(256))
..addAll(List<int>.filled(4, 0))
..addAll([73, 69, 78, 68])
..addAll(List<int>.generate(4, (_) => rand.nextInt(256))),
);
// 构建 JSON 数据
String jsonData = json.encode({
'3064': 1,
'39c8': '$spmPrefix.fp.risk',
'3c43': {
'adca': 'Linux',
'bfe9': randPngEnd.substring(randPngEnd.length - 50),
},
});
// 发送 POST 请求
await Request().post(
Api.activateBuvidApi,
data: {'payload': jsonData},
options: Options(contentType: 'application/json'),
);
} catch (err) {
debugPrint('buvidActivate error: $err');
}
}
}

View File

@ -8,6 +8,8 @@ class HttpString {
static const String messageBaseUrl = 'https://message.bilibili.com';
static const String bangumiBaseUrl = 'https://bili.meark.me';
static const String sponsorBlockBaseUrl = 'https://www.bsbsb.top';
static const String biliplusBaseUrl = 'https://www.biliplus.com';
static const List<int> validateStatusCodes = [
302,
304,

View File

@ -1,9 +1,7 @@
// ignore_for_file: avoid_print
import 'dart:async';
import 'dart:convert';
import 'dart:developer';
import 'dart:io';
import 'dart:math' show Random;
import 'package:cookie_jar/cookie_jar.dart';
import 'package:dio/dio.dart';
import 'package:dio/io.dart';
@ -13,7 +11,6 @@ import 'package:pilipala/models/user/info.dart';
import 'package:pilipala/utils/id_utils.dart';
import '../utils/storage.dart';
import '../utils/utils.dart';
import 'api.dart';
import 'constants.dart';
import 'interceptor.dart';
@ -27,8 +24,6 @@ class Request {
late bool enableSystemProxy;
late String systemProxyHost;
late String systemProxyPort;
static final RegExp spmPrefixExp =
RegExp(r'<meta name="spm_prefix" content="([^"]+?)">');
static String? buvid;
/// 设置cookie
@ -62,11 +57,6 @@ class Request {
baseUrlType = 'bangumi';
}
setBaseUrl(type: baseUrlType);
try {
await buvidActivate();
} catch (e) {
log("setCookie, ${e.toString()}");
}
final String cookieString = cookie
.map((Cookie cookie) => '${cookie.name}=${cookie.value}')
@ -78,7 +68,7 @@ class Request {
// 从cookie中获取 csrf token
static Future<String> getCsrf() async {
List<Cookie> cookies = await cookieManager.cookieJar
.loadForRequest(Uri.parse(HttpString.apiBaseUrl));
.loadForRequest(Uri.parse(HttpString.baseUrl));
String token = '';
if (cookies.where((e) => e.name == 'bili_jct').isNotEmpty) {
token = cookies.firstWhere((e) => e.name == 'bili_jct').value;
@ -92,9 +82,12 @@ class Request {
}
final List<Cookie> cookies = await cookieManager.cookieJar
.loadForRequest(Uri.parse(HttpString.baseUrl));
buvid = cookies.firstWhere((cookie) => cookie.name == 'buvid3').value;
if (buvid == null) {
.loadForRequest(Uri.parse(HttpString.apiBaseUrl));
buvid = cookies
.firstWhere((cookie) => cookie.name == 'buvid3',
orElse: () => Cookie('buvid3', ''))
.value;
if (buvid == null || buvid!.isEmpty) {
try {
var result = await Request().get(
"${HttpString.apiBaseUrl}/x/frontend/finger/spi",
@ -122,30 +115,6 @@ class Request {
dio.options.headers['referer'] = 'https://www.bilibili.com/';
}
static Future buvidActivate() async {
var html = await Request().get(Api.dynamicSpmPrefix);
String spmPrefix = spmPrefixExp.firstMatch(html.data)!.group(1)!;
Random rand = Random();
String rand_png_end = base64.encode(
List<int>.generate(32, (_) => rand.nextInt(256)) +
List<int>.filled(4, 0) +
[73, 69, 78, 68] +
List<int>.generate(4, (_) => rand.nextInt(256)));
String jsonData = json.encode({
'3064': 1,
'39c8': '${spmPrefix}.fp.risk',
'3c43': {
'adca': 'Linux',
'bfe9': rand_png_end.substring(rand_png_end.length - 50),
},
});
await Request().post(Api.activateBuvidApi,
data: {'payload': jsonData},
options: Options(contentType: 'application/json'));
}
/*
* config it and create
*/

View File

@ -26,7 +26,7 @@ class MemberHttp {
}) async {
String? wWebid;
if ((await getWWebid(mid: mid))['status']) {
wWebid = GlobalDataCache().wWebid;
wWebid = GlobalDataCache.wWebid;
}
Map params = await WbiSign().makSign({
@ -574,7 +574,7 @@ class MemberHttp {
}
static Future getWWebid({required int mid}) async {
String? wWebid = GlobalDataCache().wWebid;
String? wWebid = GlobalDataCache.wWebid;
if (wWebid != null) {
return {'status': true, 'data': wWebid};
}
@ -588,7 +588,7 @@ class MemberHttp {
final content = match.group(1);
String decodedString = Uri.decodeComponent(content!);
Map<String, dynamic> map = jsonDecode(decodedString);
GlobalDataCache().wWebid = map['access_id'];
GlobalDataCache.wWebid = map['access_id'];
return {'status': true, 'data': map['access_id']};
} else {
return {'status': false, 'data': '请检查登录状态'};
@ -605,7 +605,7 @@ class MemberHttp {
}) async {
String? wWebid;
if ((await getWWebid(mid: mid))['status']) {
wWebid = GlobalDataCache().wWebid;
wWebid = GlobalDataCache.wWebid;
}
Map params = await WbiSign().makSign({
'host_mid': mid,

View File

@ -10,6 +10,7 @@ import 'package:flutter/material.dart';
import 'package:dynamic_color/dynamic_color.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/common/widgets/custom_toast.dart';
import 'package:pilipala/http/common.dart';
import 'package:pilipala/http/init.dart';
import 'package:pilipala/models/common/color_type.dart';
import 'package:pilipala/models/common/theme_type.dart';
@ -65,7 +66,8 @@ void main() async {
}
PiliSchame.init();
await GlobalDataCache().initialize();
await GlobalDataCache.initialize();
CommonHttp.buvidActivate();
}
class MyApp extends StatelessWidget {

View File

@ -0,0 +1,18 @@
enum CommentRangeType {
video,
bangumi,
// dynamic,
}
extension ActionTypeExtension on CommentRangeType {
String get value => [
'video',
'bangumi',
// 'dynamic',
][index];
String get label => [
'视频',
'番剧',
// '动态',
][index];
}

View File

@ -0,0 +1,73 @@
class InvalidVideoModel {
final int? id;
final int? ver;
final int? aid;
final String? lastupdate;
final int? lastupdatets;
final String? title;
final String? description;
final String? pic;
final int? tid;
final String? typename;
final int? created;
final String? createdAt;
final String? author;
final int? mid;
final String? play;
final String? coins;
final String? review;
final String? videoReview;
final String? favorites;
final String? tag;
final List<String>? tagList;
InvalidVideoModel({
this.id,
this.ver,
this.aid,
this.lastupdate,
this.lastupdatets,
this.title,
this.description,
this.pic,
this.tid,
this.typename,
this.created,
this.createdAt,
this.author,
this.mid,
this.play,
this.coins,
this.review,
this.videoReview,
this.favorites,
this.tag,
this.tagList,
});
factory InvalidVideoModel.fromJson(Map<String, dynamic> json) {
return InvalidVideoModel(
id: json['id'],
ver: json['ver'],
aid: json['aid'],
lastupdate: json['lastupdate'],
lastupdatets: json['lastupdatets'],
title: json['title'],
description: json['description'],
pic: json['pic'],
tid: json['tid'],
typename: json['typename'],
created: json['created'],
createdAt: json['created_at'],
author: json['author'],
mid: json['mid'],
play: json['play'],
coins: json['coins'],
review: json['review'],
videoReview: json['video_review'],
favorites: json['favorites'],
tag: json['tag'],
tagList: json['tag'].toString().split(',').toList(),
);
}
}

View File

@ -5,6 +5,7 @@ import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/common/constants.dart';
import 'package:pilipala/common/widgets/badge.dart';
import 'package:pilipala/common/widgets/drag_handle.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';
@ -445,27 +446,12 @@ class BangumiStatusWidget extends StatelessWidget {
}
Widget morePanel(BuildContext context, BangumiIntroController ctr) {
return Container(
return Padding(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
InkWell(
onTap: () => Get.back(),
child: Container(
height: 35,
padding: const EdgeInsets.only(bottom: 2),
child: Center(
child: Container(
width: 32,
height: 3,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.outline,
borderRadius: const BorderRadius.all(Radius.circular(3))),
),
),
),
),
const DragHandle(),
...ctr.followStatusList
.map(
(e) => ListTile(

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/common/widgets/drag_handle.dart';
import 'package:pilipala/common/widgets/stat/danmu.dart';
import 'package:pilipala/common/widgets/stat/view.dart';
import 'package:pilipala/utils/storage.dart';
@ -23,94 +24,81 @@ class IntroDetail extends StatelessWidget {
color: Theme.of(context).colorScheme.onSurface,
);
return Container(
color: Theme.of(context).colorScheme.surface,
padding: const EdgeInsets.only(left: 14, right: 14),
padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
height: sheetHeight,
child: Column(
children: [
Container(
height: 35,
padding: const EdgeInsets.only(bottom: 2),
child: Center(
child: Container(
width: 32,
height: 3,
decoration: BoxDecoration(
color: Theme.of(context)
.colorScheme
.onSecondaryContainer
.withOpacity(0.5),
borderRadius: const BorderRadius.all(Radius.circular(3))),
),
),
),
const DragHandle(),
Expanded(
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
bangumiDetail!.title,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
child: Padding(
padding: const EdgeInsets.only(left: 16, right: 16),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
bangumiDetail!.title,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
),
const SizedBox(height: 4),
Row(
children: [
StatView(
view: bangumiDetail!.stat!['views'],
size: 'medium',
),
const SizedBox(width: 6),
StatDanMu(
danmu: bangumiDetail!.stat!['danmakus'],
size: 'medium',
),
],
),
const SizedBox(height: 4),
Row(
children: [
Text(
bangumiDetail!.areas!.first['name'],
style: smallTitle,
),
const SizedBox(width: 6),
Text(
bangumiDetail!.publish!['pub_time_show'],
style: smallTitle,
),
const SizedBox(width: 6),
Text(
bangumiDetail!.newEp!['desc'],
style: smallTitle,
),
],
),
const SizedBox(height: 20),
Text(
'简介:',
style: Theme.of(context).textTheme.titleMedium,
),
const SizedBox(height: 4),
Text(
'${bangumiDetail!.evaluate!}',
style: smallTitle.copyWith(fontSize: 13),
),
const SizedBox(height: 20),
Text(
'声优:',
style: Theme.of(context).textTheme.titleMedium,
),
const SizedBox(height: 4),
Text(
bangumiDetail.actors,
style: smallTitle.copyWith(fontSize: 13),
),
SizedBox(height: MediaQuery.of(context).padding.bottom + 20)
],
const SizedBox(height: 4),
Row(
children: [
StatView(
view: bangumiDetail!.stat!['views'],
size: 'medium',
),
const SizedBox(width: 6),
StatDanMu(
danmu: bangumiDetail!.stat!['danmakus'],
size: 'medium',
),
],
),
const SizedBox(height: 4),
Row(
children: [
Text(
bangumiDetail!.areas!.first['name'],
style: smallTitle,
),
const SizedBox(width: 6),
Text(
bangumiDetail!.publish!['pub_time_show'],
style: smallTitle,
),
const SizedBox(width: 6),
Text(
bangumiDetail!.newEp!['desc'],
style: smallTitle,
),
],
),
const SizedBox(height: 20),
Text(
'简介:',
style: Theme.of(context).textTheme.titleMedium,
),
const SizedBox(height: 4),
Text(
'${bangumiDetail!.evaluate!}',
style: smallTitle.copyWith(fontSize: 13),
),
const SizedBox(height: 20),
Text(
'声优:',
style: Theme.of(context).textTheme.titleMedium,
),
const SizedBox(height: 4),
Text(
bangumiDetail.actors,
style: smallTitle.copyWith(fontSize: 13),
),
SizedBox(height: MediaQuery.of(context).padding.bottom + 20)
],
),
),
),
)

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/widgets/drag_handle.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/http/user.dart';
import 'package:pilipala/utils/feed_back.dart';
@ -108,28 +109,12 @@ class MorePanel extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
return Padding(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
// clipBehavior: Clip.hardEdge,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
InkWell(
onTap: () => Get.back(),
child: Container(
height: 35,
padding: const EdgeInsets.only(bottom: 2),
child: Center(
child: Container(
width: 32,
height: 3,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.outline,
borderRadius: const BorderRadius.all(Radius.circular(3))),
),
),
),
),
const DragHandle(),
ListTile(
onTap: () async {
try {

View File

@ -34,6 +34,7 @@ class _UpPanelState extends State<UpPanel> {
List<LiveUserItem> liveList = [];
static const itemPadding = EdgeInsets.symmetric(horizontal: 5, vertical: 0);
late MyInfo userInfo;
RxBool showLiveUser = false.obs;
void listFormat() {
userInfo = widget.upData.myInfo!;
@ -131,21 +132,70 @@ class _UpPanelState extends State<UpPanel> {
children: [
const SizedBox(width: 10),
if (liveList.isNotEmpty) ...[
for (int i = 0; i < liveList.length; i++) ...[
upItemBuild(liveList[i], i)
],
VerticalDivider(
indent: 20,
endIndent: 40,
width: 26,
color: Theme.of(context)
.colorScheme
.primary
.withOpacity(0.5),
Obx(
() => AnimatedSwitcher(
duration: const Duration(milliseconds: 300),
transitionBuilder: (Widget child,
Animation<double> animation) {
return FadeTransition(
opacity: animation, child: child);
},
child: showLiveUser.value
? Row(
key: ValueKey<bool>(showLiveUser.value),
children: [
for (int i = 0;
i < liveList.length;
i++)
UpItemWidget(
data: liveList[i],
index: i,
currentMid: currentMid,
onClickUp: onClickUp,
onClickUpAni: onClickUpAni,
itemPadding: itemPadding,
contentWidth: contentWidth,
)
],
)
: SizedBox.shrink(
key: ValueKey<bool>(showLiveUser.value),
),
),
),
Obx(
() => IconButton(
onPressed: () {
showLiveUser.value = !showLiveUser.value;
},
icon: AnimatedSwitcher(
duration: const Duration(milliseconds: 300),
transitionBuilder: (Widget child,
Animation<double> animation) {
return ScaleTransition(
scale: animation, child: child);
},
child: Icon(
!showLiveUser.value
? Icons.arrow_forward_ios_rounded
: Icons.arrow_back_ios_rounded,
key: ValueKey<bool>(showLiveUser.value),
size: 18,
),
),
),
),
],
for (int i = 0; i < upList.length; i++) ...[
upItemBuild(upList[i], i)
UpItemWidget(
data: upList[i],
index: i,
currentMid: currentMid,
onClickUp: onClickUp,
onClickUpAni: onClickUpAni,
itemPadding: itemPadding,
contentWidth: contentWidth,
)
],
const SizedBox(width: 10),
],
@ -165,18 +215,103 @@ class _UpPanelState extends State<UpPanel> {
)),
);
}
}
Widget upItemBuild(data, i) {
class _SliverHeaderDelegate extends SliverPersistentHeaderDelegate {
_SliverHeaderDelegate({required this.height, required this.child});
final double height;
final Widget child;
@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
return child;
}
@override
double get maxExtent => height;
@override
double get minExtent => height;
@override
bool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate) =>
true;
}
class UpPanelSkeleton extends StatelessWidget {
const UpPanelSkeleton({super.key});
@override
Widget build(BuildContext context) {
return ListView.builder(
scrollDirection: Axis.horizontal,
physics: const NeverScrollableScrollPhysics(),
itemCount: 10,
itemBuilder: ((context, index) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 0),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 50,
height: 50,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.onInverseSurface,
borderRadius: BorderRadius.circular(50),
),
),
Container(
margin: const EdgeInsets.only(top: 6),
width: 45,
height: 12,
color: Theme.of(context).colorScheme.onInverseSurface,
),
],
),
);
}),
);
}
}
class UpItemWidget extends StatelessWidget {
final dynamic data;
final int index;
final RxInt currentMid;
final Function(dynamic, int) onClickUp;
final Function(dynamic, int) onClickUpAni;
// final Function() feedBack;
final EdgeInsets itemPadding;
final double contentWidth;
const UpItemWidget({
Key? key,
required this.data,
required this.index,
required this.currentMid,
required this.onClickUp,
required this.onClickUpAni,
// required this.feedBack,
required this.itemPadding,
required this.contentWidth,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
feedBack();
if (data.type == 'up') {
EasyThrottle.throttle('follow', const Duration(milliseconds: 300),
() {
if (GlobalDataCache().enableDynamicSwitch) {
onClickUp(data, i);
if (GlobalDataCache.enableDynamicSwitch) {
onClickUp(data, index);
} else {
onClickUpAni(data, i);
onClickUpAni(data, index);
}
});
} else if (data.type == 'live') {
@ -251,13 +386,12 @@ class _UpPanelState extends State<UpPanel> {
softWrap: false,
textAlign: TextAlign.center,
style: TextStyle(
color: currentMid.value == data.mid
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.outline,
fontSize: Theme.of(context)
.textTheme
.labelMedium!
.fontSize),
color: currentMid.value == data.mid
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.outline,
fontSize:
Theme.of(context).textTheme.labelMedium!.fontSize,
),
),
),
),
@ -269,64 +403,3 @@ class _UpPanelState extends State<UpPanel> {
);
}
}
class _SliverHeaderDelegate extends SliverPersistentHeaderDelegate {
_SliverHeaderDelegate({required this.height, required this.child});
final double height;
final Widget child;
@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
return child;
}
@override
double get maxExtent => height;
@override
double get minExtent => height;
@override
bool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate) =>
true;
}
class UpPanelSkeleton extends StatelessWidget {
const UpPanelSkeleton({super.key});
@override
Widget build(BuildContext context) {
return ListView.builder(
scrollDirection: Axis.horizontal,
physics: const NeverScrollableScrollPhysics(),
itemCount: 10,
itemBuilder: ((context, index) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 0),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 50,
height: 50,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.onInverseSurface,
borderRadius: BorderRadius.circular(50),
),
),
Container(
margin: const EdgeInsets.only(top: 6),
width: 45,
height: 12,
color: Theme.of(context).colorScheme.onInverseSurface,
),
],
),
);
}),
);
}
}

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:pilipala/http/common.dart';
import 'package:pilipala/http/user.dart';
import 'package:pilipala/http/video.dart';
import 'package:pilipala/models/user/fav_detail.dart';
@ -8,6 +9,8 @@ import 'package:pilipala/models/user/fav_folder.dart';
import 'package:pilipala/pages/fav/index.dart';
import 'package:pilipala/utils/utils.dart';
import 'widget/invalid_video_card.dart';
class FavDetailController extends GetxController {
FavFolderItemData? item;
RxString title = ''.obs;
@ -131,8 +134,9 @@ class FavDetailController extends GetxController {
'privacy': [22, 0].contains(item!.attr) ? 0 : 1,
},
);
title.value = res['title'];
print(title);
if (res != null) {
title.value = res['title'];
}
}
Future toViewPlayAll() async {
@ -152,4 +156,22 @@ class FavDetailController extends GetxController {
},
);
}
// 查看无效视频信息
Future toViewInvalidVideo(FavDetailItemData item) async {
SmartDialog.showLoading(msg: '加载中...');
var res = await CommonHttp.fixVideoPicAndTitle(aid: item.id!);
SmartDialog.dismiss();
if (res['status']) {
showModalBottomSheet(
context: Get.context!,
isScrollControlled: true,
builder: (context) {
return InvalidVideoCard(videoInfo: res['data']);
},
);
} else {
SmartDialog.showToast(res['msg']);
}
}
}

View File

@ -226,6 +226,8 @@ class _FavDetailPageState extends State<FavDetailPage> {
isOwner: _favDetailController.isOwner,
callFn: () => _favDetailController
.onCancelFav(favList[index].id),
viewInvalidVideoCb: () => _favDetailController
.toViewInvalidVideo(favList[index]),
);
}, childCount: favList.length),
),

View File

@ -19,6 +19,7 @@ class FavVideoCardH extends StatelessWidget {
final Function? callFn;
final int? searchType;
final String isOwner;
final Function? viewInvalidVideoCb;
const FavVideoCardH({
Key? key,
@ -26,6 +27,7 @@ class FavVideoCardH extends StatelessWidget {
this.callFn,
this.searchType,
required this.isOwner,
this.viewInvalidVideoCb,
}) : super(key: key);
@override
@ -36,6 +38,10 @@ class FavVideoCardH extends StatelessWidget {
return InkWell(
onTap: () async {
// int? seasonId;
if (videoItem.title == '已失效视频') {
viewInvalidVideoCb?.call();
return;
}
String? epId;
if (videoItem.ogv != null &&
(videoItem.ogv['type_name'] == '番剧' ||
@ -65,11 +71,17 @@ class FavVideoCardH extends StatelessWidget {
epId != null ? SearchType.media_bangumi : SearchType.video,
});
},
onLongPress: () => imageSaveDialog(
context,
videoItem,
SmartDialog.dismiss,
),
onLongPress: () {
if (videoItem.title == '已失效视频') {
SmartDialog.showToast('视频已失效');
return;
}
imageSaveDialog(
context,
videoItem,
SmartDialog.dismiss,
);
},
child: Column(
children: [
Padding(

View File

@ -0,0 +1,97 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/models/common/invalid_video.dart';
class InvalidVideoCard extends StatelessWidget {
const InvalidVideoCard({required this.videoInfo, Key? key}) : super(key: key);
final InvalidVideoModel videoInfo;
@override
Widget build(BuildContext context) {
const TextStyle textStyle = TextStyle(fontSize: 14.0);
return Padding(
padding: EdgeInsets.fromLTRB(
12,
14,
12,
MediaQuery.of(context).padding.bottom + 20,
),
child: LayoutBuilder(
builder: (context, constraints) {
double maxWidth = constraints.maxWidth;
double maxHeight = maxWidth * 9 / 16;
return SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
NetworkImgLayer(
width: maxWidth,
height: maxHeight,
src: videoInfo.pic,
radius: 20,
),
const SizedBox(height: 10),
SelectableText(
videoInfo.title!,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 2),
SelectableText(videoInfo.author!, style: textStyle),
const SizedBox(height: 2),
SelectableText('创建时间:${videoInfo.createdAt}', style: textStyle),
SelectableText('更新时间:${videoInfo.lastupdate}',
style: textStyle),
SelectableText('分类:${videoInfo.typename}', style: textStyle),
SelectableText(
'投币:${videoInfo.coins} 收藏:${videoInfo.favorites}',
style: textStyle),
if (videoInfo.tagList != null &&
videoInfo.tagList!.isNotEmpty) ...[
const SizedBox(height: 6),
_buildTags(context, videoInfo.tagList),
],
],
),
);
},
),
);
}
Widget _buildTags(BuildContext context, List<String>? videoTags) {
final ColorScheme colorScheme = Theme.of(context).colorScheme;
return Wrap(
spacing: 6,
runSpacing: 6,
direction: Axis.horizontal,
textDirection: TextDirection.ltr,
children: videoTags!.map((tag) {
return InkWell(
onTap: () {
Get.toNamed('/searchResult', parameters: {'keyword': tag});
},
borderRadius: BorderRadius.circular(6),
child: Container(
decoration: BoxDecoration(
color: colorScheme.surfaceVariant.withOpacity(0.5),
borderRadius: BorderRadius.circular(6),
),
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 10),
child: Text(
tag,
style: TextStyle(
fontSize: 12,
color: colorScheme.onSurfaceVariant,
),
),
),
);
}).toList(),
);
}
}

View File

@ -53,6 +53,7 @@ class FavEditController extends GetxController {
intro: intro,
mediaId: mediaId!,
cover: cover,
privacy: privacy.value,
);
if (res['status']) {
SmartDialog.showToast('编辑成功');
@ -74,4 +75,14 @@ class FavEditController extends GetxController {
SmartDialog.showToast(res['msg']);
}
}
void togglePrivacy() {
if (privacy.value == 0) {
privacy.value = 1;
SmartDialog.showToast('设置为私密后,只有自己可见');
} else {
privacy.value = 0;
SmartDialog.showToast('设置为公开后,所有人可见');
}
}
}

View File

@ -21,31 +21,22 @@ class _FavEditPageState extends State<FavEditPage> {
appBar: AppBar(
title: Obx(
() => _favEditController.type.value == 'add'
? Text(
'新建收藏夹',
style: Theme.of(context).textTheme.titleMedium,
)
: Text(
'编辑收藏夹',
style: Theme.of(context).textTheme.titleMedium,
),
? const Text('新建收藏夹')
: const Text('编辑收藏夹'),
),
actions: [
Obx(
() => _favEditController.privacy.value == 0
? IconButton(
onPressed: () {
_favEditController.privacy.value = 1;
},
icon: const Icon(Icons.lock_open_outlined))
: IconButton(
onPressed: () {
_favEditController.privacy.value = 0;
},
icon: Icon(
Icons.lock_outlined,
color: Theme.of(context).colorScheme.error,
)),
() => IconButton(
onPressed: _favEditController.togglePrivacy,
icon: Icon(
_favEditController.privacy.value == 0
? Icons.lock_open_outlined
: Icons.lock_outlined,
color: _favEditController.privacy.value == 0
? null
: Theme.of(context).colorScheme.error,
),
),
),
TextButton(
onPressed: _favEditController.onSubmit, child: const Text('保存')),

View File

@ -69,7 +69,7 @@ class LiveRoomController extends GetxController {
Request.getBuvid().then((value) => buvid = value);
}
// CDN优化
enableCDN = setting.get(SettingBoxKey.enableCDN, defaultValue: true);
enableCDN = setting.get(SettingBoxKey.enableCDN, defaultValue: false);
final userInfo = userInfoCache.get('userInfoCache');
if (userInfo != null && userInfo.mid != null) {
userId = userInfo.mid;

View File

@ -312,25 +312,28 @@ class _LiveRoomPageState extends State<LiveRoomPage>
),
),
// 消息列表
Obx(
() => Align(
alignment: Alignment.bottomCenter,
child: Container(
margin: EdgeInsets.only(
bottom: 90 + padding.bottom,
),
height: Get.size.height -
(padding.top +
kToolbarHeight +
(_liveRoomController.isPortrait.value
? Get.size.width
: Get.size.width * 9 / 16) +
100 +
padding.bottom),
child: buildMessageListUI(
context,
_liveRoomController,
_scrollController,
Visibility(
visible: !isLandscape,
child: Obx(
() => Align(
alignment: Alignment.bottomCenter,
child: Container(
margin: EdgeInsets.only(
bottom: 90 + padding.bottom,
),
height: Get.size.height -
(padding.top +
kToolbarHeight +
(_liveRoomController.isPortrait.value
? Get.size.width
: Get.size.width * 9 / 16) +
100 +
padding.bottom),
child: buildMessageListUI(
context,
_liveRoomController,
_scrollController,
),
),
),
),

View File

@ -125,7 +125,7 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
double sheetHeight = MediaQuery.sizeOf(context).height -
MediaQuery.of(context).padding.top -
MediaQuery.sizeOf(context).width * 9 / 16;
GlobalDataCache().sheetHeight = sheetHeight;
GlobalDataCache.sheetHeight = sheetHeight;
localCache.put('sheetHeight', sheetHeight);
localCache.put('statusBarHeight', statusBarHeight);

View File

@ -28,9 +28,8 @@ class MemberArchiveController extends GetxController {
super.onInit();
mid = int.parse(Get.parameters['mid']!);
currentOrder.value = orderList.first;
ownerMid = GlobalDataCache().userInfo != null
? GlobalDataCache().userInfo!.mid!
: -1;
ownerMid =
GlobalDataCache.userInfo != null ? GlobalDataCache.userInfo!.mid! : -1;
isOwner.value = mid == -1 || mid == ownerMid;
}

View File

@ -20,9 +20,8 @@ class MemberArticleController extends GetxController {
void onInit() {
super.onInit();
mid = int.parse(Get.parameters['mid']!);
ownerMid = GlobalDataCache().userInfo != null
? GlobalDataCache().userInfo!.mid!
: -1;
ownerMid =
GlobalDataCache.userInfo != null ? GlobalDataCache.userInfo!.mid! : -1;
isOwner.value = mid == -1 || mid == ownerMid;
}

View File

@ -18,9 +18,8 @@ class MemberDynamicsController extends GetxController {
void onInit() {
super.onInit();
mid = int.parse(Get.parameters['mid']!);
ownerMid = GlobalDataCache().userInfo != null
? GlobalDataCache().userInfo!.mid!
: -1;
ownerMid =
GlobalDataCache.userInfo != null ? GlobalDataCache.userInfo!.mid! : -1;
isOwner.value = mid == -1 || mid == ownerMid;
}

View File

@ -59,7 +59,7 @@ class MemberSeasonsController extends GetxController {
mid: mid,
seriesId: seriesId!,
pn: pn,
currentMid: GlobalDataCache().userInfo?.mid ?? -1,
currentMid: GlobalDataCache.userInfo?.mid ?? -1,
);
if (res['status']) {
seasonsList.addAll(res['data'].seriesList);

View File

@ -43,10 +43,10 @@ class SSearchController extends GetxController {
hintText = hint;
}
}
historyCacheList = GlobalDataCache().historyCacheList;
historyCacheList = GlobalDataCache.historyCacheList;
historyList.value = historyCacheList;
enableHotKey = setting.get(SettingBoxKey.enableHotKey, defaultValue: true);
enableSearchSuggest = GlobalDataCache().enableSearchSuggest;
enableSearchSuggest = GlobalDataCache.enableSearchSuggest;
}
void onChange(value) {
@ -128,7 +128,7 @@ class SSearchController extends GetxController {
historyCacheList = [];
historyList.refresh();
localCache.put('cacheList', []);
GlobalDataCache().historyCacheList = [];
GlobalDataCache.historyCacheList = [];
SmartDialog.showToast('搜索历史已清空');
}
@ -139,7 +139,7 @@ class SSearchController extends GetxController {
historyList.value = historyCacheList;
historyList.refresh();
localCache.put('cacheList', historyCacheList);
GlobalDataCache().historyCacheList = historyCacheList;
GlobalDataCache.historyCacheList = historyCacheList;
searchFocusNode.unfocus();
}
}

View File

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/models/common/comment_range_type.dart';
import 'package:pilipala/models/common/dynamics_type.dart';
import 'package:pilipala/models/common/reply_sort_type.dart';
import 'package:pilipala/pages/setting/widgets/select_dialog.dart';
@ -27,6 +28,8 @@ class _ExtraSettingState extends State<ExtraSetting> {
late String defaultSystemProxyHost;
late String defaultSystemProxyPort;
bool userLogin = false;
// 记录每个选项是否被选中的状态
late List<String> enableComment;
@override
void initState() {
@ -47,6 +50,8 @@ class _ExtraSettingState extends State<ExtraSetting> {
localCache.get(LocalCacheKey.systemProxyHost, defaultValue: '');
defaultSystemProxyPort =
localCache.get(LocalCacheKey.systemProxyPort, defaultValue: '');
enableComment = setting
.get(SettingBoxKey.enableComment, defaultValue: ['video', 'bangumi']);
}
// 设置代理
@ -146,7 +151,7 @@ class _ExtraSettingState extends State<ExtraSetting> {
setKey: SettingBoxKey.enableSearchSuggest,
defaultVal: true,
callFn: (val) {
GlobalDataCache().enableSearchSuggest = val;
GlobalDataCache.enableSearchSuggest = val;
},
),
SetSwitchItem(
@ -181,7 +186,7 @@ class _ExtraSettingState extends State<ExtraSetting> {
setKey: SettingBoxKey.enableAutoExpand,
defaultVal: false,
callFn: (val) {
GlobalDataCache().enableAutoExpand = val;
GlobalDataCache.enableAutoExpand = val;
},
),
const SetSwitchItem(
@ -190,9 +195,103 @@ class _ExtraSettingState extends State<ExtraSetting> {
setKey: SettingBoxKey.enableRelatedVideo,
defaultVal: true,
),
SetSwitchItem(
title: '视频投屏开关',
subTitle: '打开后将在播放器右上角显示投屏入口',
setKey: SettingBoxKey.enableDlna,
defaultVal: false,
callFn: (bool val) {
GlobalDataCache.enableDlna = val;
},
),
SetSwitchItem(
title: 'Sponsor Block',
subTitle: '自动跳过视频中赞助片段',
setKey: SettingBoxKey.enableSponsorBlock,
defaultVal: false,
callFn: (bool val) {
GlobalDataCache.enableSponsorBlock = val;
},
),
ListTile(
dense: false,
title: Text('评论展示', style: titleStyle),
onTap: () async {
List<String> tempEnableComment = List.from(enableComment);
int? result = await showDialog(
context: context,
builder: (context) {
// 带多选框的list
return StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return AlertDialog(
title: const Text('评论展示'),
contentPadding: const EdgeInsets.fromLTRB(0, 24, 0, 24),
content: SizedBox(
width: double.maxFinite,
child: ListView.builder(
itemCount: CommentRangeType.values.length,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (BuildContext context, int index) {
return CheckboxListTile(
contentPadding: const EdgeInsets.symmetric(
horizontal: 24, vertical: 0),
title: Text(
'${CommentRangeType.values[index].label}评论'),
value: tempEnableComment.contains(
CommentRangeType.values[index].value),
onChanged: (bool? value) {
setState(() {
if (value == true) {
tempEnableComment.add(
CommentRangeType.values[index].value);
} else {
tempEnableComment.remove(
CommentRangeType.values[index].value);
}
});
},
);
},
),
),
actions: [
TextButton(
onPressed: Navigator.of(context).pop,
child: Text(
'取消',
style: TextStyle(
color: Theme.of(context).colorScheme.outline),
),
),
TextButton(
onPressed: () async {
enableComment = tempEnableComment;
setting.put(
SettingBoxKey.enableComment, enableComment);
GlobalDataCache.enableComment = enableComment;
SmartDialog.showToast('操作成功');
Navigator.of(context).pop();
},
child: const Text('确认'),
)
],
);
},
);
},
);
if (result != null) {
defaultReplySort = result;
setting.put(SettingBoxKey.replySortType, result);
setState(() {});
}
},
),
ListTile(
dense: false,
title: Text('评论排序', style: titleStyle),
subtitle: Text(
'当前优先展示「${ReplySortType.values[defaultReplySort].titles}',
style: subTitleStyle,
@ -202,7 +301,7 @@ class _ExtraSettingState extends State<ExtraSetting> {
context: context,
builder: (context) {
return SelectDialog<int>(
title: '评论展示',
title: '评论排序',
value: defaultReplySort,
values: ReplySortType.values.map((e) {
return {'title': e.titles, 'value': e.index};

View File

@ -38,7 +38,7 @@ class _ActionMenuSetPageState extends State<ActionMenuSetPage> {
.map<String>((i) => (i['value'] as ActionType).value)
.toList();
setting.put(SettingBoxKey.actionTypeSort, sortedTabbar);
GlobalDataCache().actionTypeSort = sortedTabbar;
GlobalDataCache.actionTypeSort = sortedTabbar;
SmartDialog.showToast('操作成功');
}

View File

@ -58,11 +58,11 @@ class _PlayGesturePageState extends State<PlayGesturePage> {
},
);
if (result != null) {
GlobalDataCache().fullScreenGestureMode = FullScreenGestureMode
GlobalDataCache.fullScreenGestureMode = FullScreenGestureMode
.values
.firstWhere((element) => element.values == result);
fullScreenGestureMode =
GlobalDataCache().fullScreenGestureMode.index;
GlobalDataCache.fullScreenGestureMode.index;
setting.put(
SettingBoxKey.fullScreenGestureMode, fullScreenGestureMode);
SmartDialog.showToast('设置成功');

View File

@ -31,6 +31,7 @@ class _PlaySettingState extends State<PlaySetting> {
late int defaultFullScreenMode;
late int defaultBtmProgressBehavior;
late String defaultAoOutput;
late String hardwareDecodeFormat;
@override
void initState() {
@ -49,6 +50,8 @@ class _PlaySettingState extends State<PlaySetting> {
defaultValue: BtmProgresBehavior.values.first.code);
defaultAoOutput =
setting.get(SettingBoxKey.defaultAoOutput, defaultValue: '0');
hardwareDecodeFormat = setting.get(SettingBoxKey.hardwareDecodeFormat,
defaultValue: Platform.isAndroid ? 'auto-safe' : 'auto');
}
@override
@ -92,7 +95,7 @@ class _PlaySettingState extends State<PlaySetting> {
title: 'CDN优化',
subTitle: '使用优质CDN线路',
setKey: SettingBoxKey.enableCDN,
defaultVal: true,
defaultVal: false,
),
const SetSwitchItem(
title: '自动播放',
@ -155,7 +158,7 @@ class _PlaySettingState extends State<PlaySetting> {
setKey: SettingBoxKey.enablePlayerControlAnimation,
defaultVal: true,
callFn: (bool val) {
GlobalDataCache().enablePlayerControlAnimation = val;
GlobalDataCache.enablePlayerControlAnimation = val;
}),
SetSwitchItem(
title: '港澳台模式',
@ -294,6 +297,34 @@ class _PlaySettingState extends State<PlaySetting> {
}
},
),
ListTile(
dense: false,
title: Text('硬解方式', style: titleStyle),
subtitle: Text(
'当前硬解方式(--hwdec)$hardwareDecodeFormat',
style: subTitleStyle,
),
onTap: () async {
String? result = await showDialog(
context: context,
builder: (context) {
return SelectDialog<String>(
title: '硬解方式',
value: hardwareDecodeFormat,
values: ['no', 'auto-safe', 'auto', 'yes', 'auto-copy']
.map((e) {
return {'title': e, 'value': e};
}).toList());
},
);
if (result != null) {
setting.put(SettingBoxKey.hardwareDecodeFormat, result);
hardwareDecodeFormat = result;
GlobalDataCache.hardwareDecodeFormat = result;
setState(() {});
}
},
),
ListTile(
dense: false,
title: Text('默认全屏方式', style: titleStyle),

View File

@ -175,7 +175,7 @@ class _StyleSettingState extends State<StyleSetting> {
SettingBoxKey.defaultPicQa, picQuality);
Get.back();
settingController.picQuality.value = picQuality;
GlobalDataCache().imgQuality = picQuality;
GlobalDataCache.imgQuality = picQuality;
SmartDialog.showToast('设置成功');
},
child: const Text('确定'),

View File

@ -21,6 +21,7 @@ import 'package:pilipala/models/video/play/url.dart';
import 'package:pilipala/models/video/reply/item.dart';
import 'package:pilipala/pages/video/detail/reply_reply/index.dart';
import 'package:pilipala/plugin/pl_player/index.dart';
import 'package:pilipala/utils/global_data_cache.dart';
import 'package:pilipala/utils/storage.dart';
import 'package:pilipala/utils/utils.dart';
import 'package:pilipala/utils/video_utils.dart';
@ -115,6 +116,7 @@ class VideoDetailController extends GetxController
BottomControlType.time,
BottomControlType.space,
BottomControlType.fit,
BottomControlType.speed,
BottomControlType.fullscreen,
].obs;
RxDouble sheetHeight = 0.0.obs;
@ -140,8 +142,16 @@ class VideoDetailController extends GetxController
} else if (argMap.containsKey('pic')) {
updateCover(argMap['pic']);
}
tabCtr = TabController(length: 2, vsync: this);
tabs.value = <String>[
'简介',
if (videoType == SearchType.video &&
GlobalDataCache.enableComment.contains('video'))
'评论',
if (videoType == SearchType.media_bangumi &&
GlobalDataCache.enableComment.contains('bangumi'))
'评论'
];
tabCtr = TabController(length: tabs.length, vsync: this);
autoPlay.value =
setting.get(SettingBoxKey.autoPlayEnable, defaultValue: true);
enableHA.value = setting.get(SettingBoxKey.enableHA, defaultValue: false);
@ -159,7 +169,7 @@ class VideoDetailController extends GetxController
}
// CDN优化
enableCDN = setting.get(SettingBoxKey.enableCDN, defaultValue: true);
enableCDN = setting.get(SettingBoxKey.enableCDN, defaultValue: false);
// 预设的画质
cacheVideoQa = setting.get(SettingBoxKey.defaultVideoQa);
// 预设的解码格式
@ -198,7 +208,7 @@ class VideoDetailController extends GetxController
});
/// 仅投稿视频skip
if (videoType == SearchType.video) {
if (videoType == SearchType.video && GlobalDataCache.enableSponsorBlock) {
querySkipSegments();
}
}
@ -480,6 +490,15 @@ class VideoDetailController extends GetxController
getDanmaku(subtitles);
}
}
headerControl = HeaderControl(
controller: plPlayerController,
videoDetailCtr: this,
floating: floating,
bvid: bvid,
videoType: videoType,
showSubtitleBtn: result['status'] && result['data'].subtitles.isNotEmpty,
);
plPlayerController.setHeaderControl(headerControl);
}
// 获取弹幕

View File

@ -17,6 +17,7 @@ import 'package:pilipala/pages/video/detail/controller.dart';
import 'package:pilipala/pages/video/detail/reply/index.dart';
import 'package:pilipala/plugin/pl_player/models/play_repeat.dart';
import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/global_data_cache.dart';
import 'package:pilipala/utils/id_utils.dart';
import 'package:pilipala/utils/storage.dart';
import 'package:share_plus/share_plus.dart';
@ -87,19 +88,22 @@ class VideoIntroController extends GetxController {
}
// 获取视频简介&分p
Future queryVideoIntro({cover}) async {
Future queryVideoIntro({String? cover, String? type, int? cid}) async {
var result = await VideoHttp.videoIntro(bvid: bvid);
if (result['status']) {
videoDetail.value = result['data']!;
ugcSeason = result['data']!.ugcSeason;
pages.value = result['data']!.pages!;
lastPlayCid.value = videoDetail.value.cid!;
if (pages.isNotEmpty) {
lastPlayCid.value = pages.first.cid!;
if (type == null) {
lastPlayCid.value = cid ?? videoDetail.value.cid!;
}
final VideoDetailController videoDetailCtr =
Get.find<VideoDetailController>(tag: heroTag);
videoDetailCtr.tabs.value = ['简介', '评论 ${result['data']?.stat?.reply}'];
videoDetailCtr.tabs.value = [
'简介',
if (GlobalDataCache.enableComment.contains('video'))
'评论 ${result['data']?.stat?.reply}'
];
videoDetailCtr.cover.value = cover ?? result['data'].pic ?? '';
// 获取到粉丝数再返回
await queryUserStat();
@ -469,13 +473,16 @@ class VideoIntroController extends GetxController {
// 重新请求评论
try {
/// 未渲染回复组件时可能异常
final VideoReplyController videoReplyCtr =
Get.find<VideoReplyController>(tag: heroTag);
videoReplyCtr.aid = aid;
videoReplyCtr.queryReplyList(type: 'init');
if (GlobalDataCache.enableComment.contains('video')) {
final VideoReplyController videoReplyCtr =
Get.find<VideoReplyController>(tag: heroTag);
videoReplyCtr.aid = aid;
videoReplyCtr.queryReplyList(type: 'init');
}
} catch (_) {}
this.bvid = bvid;
await queryVideoIntro(cover: cover);
// 点击切换时优先取当前cid
await queryVideoIntro(cover: cover, cid: cid);
}
void startTimer() {

View File

@ -6,8 +6,8 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import 'package:hive/hive.dart';
import 'package:lottie/lottie.dart';
import 'package:pilipala/common/constants.dart';
import 'package:pilipala/common/skeleton/video_intro.dart';
import 'package:pilipala/common/widgets/http_error.dart';
import 'package:pilipala/pages/video/detail/index.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
@ -57,7 +57,7 @@ class _VideoIntroPanelState extends State<VideoIntroPanel>
heroTag = Get.arguments['heroTag'];
videoIntroController =
Get.put(VideoIntroController(bvid: widget.bvid), tag: heroTag);
_futureBuilderFuture = videoIntroController.queryVideoIntro();
_futureBuilderFuture = videoIntroController.queryVideoIntro(type: 'init');
videoIntroController.videoDetail.listen((value) {
videoDetail = value;
});
@ -76,10 +76,8 @@ class _VideoIntroPanelState extends State<VideoIntroPanel>
future: _futureBuilderFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.data == null) {
return const SliverToBoxAdapter(child: SizedBox());
}
if (snapshot.data['status']) {
Map? data = snapshot.data;
if (data != null && data['status']) {
// 请求成功
return Obx(
() => VideoInfo(
@ -91,25 +89,16 @@ class _VideoIntroPanelState extends State<VideoIntroPanel>
} else {
// 请求错误
return HttpError(
errMsg: snapshot.data['msg'],
btnText: snapshot.data['code'] == -404 ||
snapshot.data['code'] == 62002
errMsg: data?['msg'] ?? '请求异常',
btnText: (data?['code'] == -404 || data?['code'] == 62002)
? '返回上一页'
: null,
fn: () => Get.back(),
);
}
} else {
return SliverToBoxAdapter(
child: SizedBox(
height: 100,
child: Center(
child: Lottie.asset(
'assets/loading.json',
width: 200,
),
),
),
return const SliverToBoxAdapter(
child: VideoIntroSkeleton(),
);
}
},
@ -169,8 +158,8 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
owner = widget.videoDetail!.owner;
enableAi = setting.get(SettingBoxKey.enableAi, defaultValue: true);
_expandableCtr = ExpandableController(
initialExpanded: GlobalDataCache().enableAutoExpand);
_expandableCtr =
ExpandableController(initialExpanded: GlobalDataCache.enableAutoExpand);
}
// 收藏
@ -556,7 +545,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
}
Widget actionGrid(BuildContext context, videoIntroController) {
final actionTypeSort = GlobalDataCache().actionTypeSort;
final actionTypeSort = GlobalDataCache.actionTypeSort;
Map<String, Widget> menuListWidgets = {
'like': Obx(

View File

@ -27,7 +27,7 @@ class SeasonPanel extends StatefulWidget {
}
class _SeasonPanelState extends State<SeasonPanel> {
late List<EpisodeItem> episodes;
List<EpisodeItem>? episodes;
late int cid;
late RxInt currentIndex = (-1).obs;
final String heroTag = Get.arguments['heroTag'];
@ -75,7 +75,10 @@ class _SeasonPanelState extends State<SeasonPanel> {
// 获取currentIndex
void getCurrentIndex() {
currentIndex.value = episodes.indexWhere((EpisodeItem e) => e.cid == cid);
if (episodes != null) {
currentIndex.value =
episodes!.indexWhere((EpisodeItem e) => e.cid == cid);
}
final List<SectionItem> sections = widget.ugcSeason.sections!;
if (sections.length == 1 && sections.first.type == 1) {
final List<EpisodeItem> episodesList = sections.first.episodes!;
@ -83,6 +86,7 @@ class _SeasonPanelState extends State<SeasonPanel> {
for (int j = 0; j < episodesList[i].pages!.length; j++) {
if (episodesList[i].pages![j].cid == cid) {
currentIndex.value = i;
episodes = episodesList;
continue;
}
}
@ -137,7 +141,7 @@ class _SeasonPanelState extends State<SeasonPanel> {
widget.videoIntroCtr.bottomSheetController =
_bottomSheetController = EpisodeBottomSheet(
currentCid: cid,
episodes: episodes,
episodes: episodes!,
changeFucCall: changeFucCall,
sheetHeight: widget.sheetHeight,
dataType: VideoEpidoesType.videoEpisode,
@ -165,7 +169,7 @@ class _SeasonPanelState extends State<SeasonPanel> {
),
const SizedBox(width: 10),
Obx(() => Text(
'${currentIndex.value + 1}/${episodes.length}',
'${currentIndex.value + 1}/${episodes!.length}',
style: Theme.of(context).textTheme.labelMedium,
)),
const SizedBox(width: 6),

View File

@ -7,6 +7,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/common/widgets/badge.dart';
import 'package:pilipala/common/widgets/drag_handle.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/http/reply.dart';
import 'package:pilipala/models/common/reply_type.dart';
@ -52,7 +53,7 @@ class ReplyItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
final bool isOwner = int.parse(replyItem!.member!.mid!) ==
(GlobalDataCache().userInfo?.mid ?? -1);
(GlobalDataCache.userInfo?.mid ?? -1);
return Material(
child: InkWell(
// 点击整个评论区 评论详情/回复
@ -415,7 +416,7 @@ class ReplyItemRow extends StatelessWidget {
onLongPress: () {
feedBack();
final bool isOwner = int.parse(replyItem!.member!.mid!) ==
(GlobalDataCache().userInfo?.mid ?? -1);
(GlobalDataCache.userInfo?.mid ?? -1);
showModalBottomSheet(
context: context,
useRootNavigator: true,
@ -1117,27 +1118,12 @@ class MorePanel extends StatelessWidget {
ColorScheme colorScheme = Theme.of(context).colorScheme;
TextTheme textTheme = Theme.of(context).textTheme;
Color errorColor = colorScheme.error;
return Container(
return Padding(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
InkWell(
onTap: () => Get.back(),
child: Container(
height: 35,
padding: const EdgeInsets.only(bottom: 2),
child: Center(
child: Container(
width: 32,
height: 3,
decoration: BoxDecoration(
color: colorScheme.outline,
borderRadius: const BorderRadius.all(Radius.circular(3))),
),
),
),
),
const DragHandle(),
ListTile(
onTap: () async => await menuActionHandler('copyAll'),
minLeadingWidth: 0,

View File

@ -89,9 +89,12 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
return AppBar(
toolbarHeight: 45,
automaticallyImplyLeading: false,
title: Text(
'评论详情',
style: Theme.of(context).textTheme.titleSmall,
title: Padding(
padding: const EdgeInsets.only(left: 14),
child: Text(
'评论详情',
style: Theme.of(context).textTheme.titleSmall,
),
),
actions: [
IconButton(
@ -102,7 +105,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
Navigator.pop(context);
},
),
const SizedBox(width: 14),
const SizedBox(width: 12),
],
);
}

View File

@ -24,6 +24,7 @@ import 'package:pilipala/pages/video/detail/related/index.dart';
import 'package:pilipala/plugin/pl_player/index.dart';
import 'package:pilipala/plugin/pl_player/models/play_repeat.dart';
import 'package:pilipala/services/service_locator.dart';
import 'package:pilipala/utils/global_data_cache.dart';
import 'package:pilipala/utils/storage.dart';
import 'package:status_bar_control/status_bar_control.dart';
@ -679,8 +680,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
forceElevated: innerBoxIsScrolled,
expandedHeight: expandedHeight,
backgroundColor: Colors.black,
flexibleSpace: FlexibleSpaceBar(
background: PopScope(
flexibleSpace: SizedBox.expand(
child: PopScope(
canPop:
plPlayerController?.isFullScreen.value != true,
onPopInvoked: (bool didPop) {
@ -784,13 +785,20 @@ class _VideoDetailPageState extends State<VideoDetailPage>
);
},
),
Obx(
() => VideoReplyPanel(
bvid: vdCtr.bvid,
oid: vdCtr.oid.value,
onControllerCreated: vdCtr.onControllerCreated,
),
)
if ((vdCtr.videoType == SearchType.media_bangumi &&
GlobalDataCache.enableComment
.contains('bangumi')) ||
(vdCtr.videoType == SearchType.video &&
GlobalDataCache.enableComment
.contains('video'))) ...[
Obx(
() => VideoReplyPanel(
bvid: vdCtr.bvid,
oid: vdCtr.oid.value,
onControllerCreated: vdCtr.onControllerCreated,
),
)
],
],
),
),
@ -914,6 +922,21 @@ class _VideoDetailPageState extends State<VideoDetailPage>
icon: const Icon(FontAwesomeIcons.arrowLeft, size: 15),
fuc: () => Get.back(),
),
const SizedBox(width: 8),
ComBtn(
icon: const Icon(
FontAwesomeIcons.house,
size: 15,
color: Colors.white,
),
fuc: () async {
await vdCtr.plPlayerController.dispose(type: 'all');
if (mounted) {
Navigator.popUntil(
context, (Route<dynamic> route) => route.isFirst);
}
},
),
const Spacer(),
ComBtn(
icon: const Icon(Icons.history_outlined, size: 22),

View File

@ -1,6 +1,7 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/widgets/drag_handle.dart';
import 'package:pilipala/models/video/ai.dart';
import 'package:pilipala/pages/video/detail/index.dart';
import 'package:pilipala/utils/global_data_cache.dart';
@ -17,21 +18,24 @@ class AiDetail extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.only(left: 16, right: 16),
height: GlobalDataCache().sheetHeight,
padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
height: GlobalDataCache.sheetHeight,
child: Column(
children: [
_buildHeader(context),
const DragHandle(),
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
if (modelResult!.summary != '') ...[
_buildSummaryText(modelResult!.summary!),
const SizedBox(height: 20),
child: Padding(
padding: const EdgeInsets.only(left: 16, right: 16),
child: Column(
children: [
if (modelResult!.summary != '') ...[
_buildSummaryText(modelResult!.summary!),
const SizedBox(height: 20),
],
_buildOutlineList(context),
],
_buildOutlineList(context),
],
),
),
),
),
@ -40,20 +44,6 @@ class AiDetail extends StatelessWidget {
);
}
Widget _buildHeader(BuildContext context) {
return Center(
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).hintColor,
borderRadius: const BorderRadius.all(Radius.circular(10)),
),
height: 4,
width: 40,
margin: const EdgeInsets.symmetric(vertical: 16),
),
);
}
Widget _buildSummaryText(String summary) {
return SelectableText(
summary,

View File

@ -7,7 +7,9 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:marquee/marquee.dart';
import 'package:ns_danmaku/ns_danmaku.dart';
import 'package:pilipala/common/widgets/drag_handle.dart';
import 'package:pilipala/http/user.dart';
import 'package:pilipala/models/video/play/quality.dart';
import 'package:pilipala/models/video/play/url.dart';
@ -16,6 +18,7 @@ import 'package:pilipala/pages/video/detail/index.dart';
import 'package:pilipala/pages/video/detail/introduction/widgets/menu_row.dart';
import 'package:pilipala/plugin/pl_player/index.dart';
import 'package:pilipala/plugin/pl_player/models/play_repeat.dart';
import 'package:pilipala/utils/global_data_cache.dart';
import 'package:pilipala/utils/storage.dart';
import 'package:pilipala/services/shutdown_timer_service.dart';
import '../../../../http/danmaku.dart';
@ -30,7 +33,7 @@ class HeaderControl extends StatefulWidget implements PreferredSizeWidget {
this.floating,
this.bvid,
this.videoType,
this.showSubtitleBtn,
this.showSubtitleBtn = true,
super.key,
});
final PlPlayerController? controller;
@ -38,7 +41,7 @@ class HeaderControl extends StatefulWidget implements PreferredSizeWidget {
final Floating? floating;
final String? bvid;
final SearchType? videoType;
final bool? showSubtitleBtn;
final bool showSubtitleBtn;
@override
State<HeaderControl> createState() => _HeaderControlState();
@ -55,11 +58,12 @@ class _HeaderControlState extends State<HeaderControl> {
final Box<dynamic> localCache = GStorage.localCache;
final Box<dynamic> videoStorage = GStorage.video;
late List<double> speedsList;
double buttonSpace = 8;
double buttonSpace = 4;
RxBool isFullScreen = false.obs;
late String heroTag;
late VideoIntroController videoIntroController;
late VideoDetailData videoDetail;
DateTime initialTime = DateTime.now();
@override
void initState() {
@ -101,50 +105,11 @@ class _HeaderControlState extends State<HeaderControl> {
margin: const EdgeInsets.all(12),
child: Column(
children: <Widget>[
SizedBox(
height: 35,
child: Center(
child: Container(
width: 32,
height: 3,
decoration: BoxDecoration(
color: Theme.of(context)
.colorScheme
.onSecondaryContainer
.withOpacity(0.5),
borderRadius:
const BorderRadius.all(Radius.circular(3))),
),
),
),
const DragHandle(),
Expanded(
child: Material(
child: ListView(
children: [
// ListTile(
// onTap: () {},
// dense: true,
// enabled: false,
// leading:
// const Icon(Icons.network_cell_outlined, size: 20),
// title: Text('省流模式', style: titleStyle),
// subtitle: Text('低画质 减少视频缓存', style: subTitleStyle),
// trailing: Transform.scale(
// scale: 0.75,
// child: Switch(
// thumbIcon: MaterialStateProperty.resolveWith<Icon?>(
// (Set<MaterialState> states) {
// if (states.isNotEmpty &&
// states.first == MaterialState.selected) {
// return const Icon(Icons.done);
// }
// return null; // All other states will use the default thumbIcon.
// }),
// value: false,
// onChanged: (value) => {},
// ),
// ),
// ),
ListTile(
onTap: () async {
final res = await UserHttp.toViewLater(
@ -485,65 +450,6 @@ class _HeaderControlState extends State<HeaderControl> {
});
}
/// 选择倍速
void showSetSpeedSheet() {
final double currentSpeed = widget.controller!.playbackSpeed;
showDialog(
context: Get.context!,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('播放速度'),
content: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return Wrap(
spacing: 8,
runSpacing: 2,
children: [
for (final double i in speedsList) ...<Widget>[
if (i == currentSpeed) ...<Widget>[
FilledButton(
onPressed: () async {
// setState(() => currentSpeed = i),
await widget.controller!.setPlaybackSpeed(i);
Get.back();
},
child: Text(i.toString()),
),
] else ...[
FilledButton.tonal(
onPressed: () async {
// setState(() => currentSpeed = i),
await widget.controller!.setPlaybackSpeed(i);
Get.back();
},
child: Text(i.toString()),
),
]
]
],
);
}),
actions: <Widget>[
TextButton(
onPressed: () => Get.back(),
child: Text(
'取消',
style: TextStyle(color: Theme.of(context).colorScheme.outline),
),
),
TextButton(
onPressed: () async {
await widget.controller!.setDefaultSpeed();
Get.back();
},
child: const Text('默认速度'),
),
],
);
},
);
}
/// 选择画质
void showSetVideoQa() {
final List<FormatItem> videoFormat = videoInfo.supportFormats!;
@ -1143,6 +1049,16 @@ class _HeaderControlState extends State<HeaderControl> {
);
}
Stream<DateTime> _getTimeStream() {
return Stream.periodic(const Duration(seconds: 60), (count) {
return DateTime.now();
});
}
String _formatTime(DateTime dateTime) {
return '${dateTime.hour}:${dateTime.minute < 10 ? '0${dateTime.minute}' : dateTime.minute}';
}
@override
Widget build(BuildContext context) {
final _ = widget.controller!;
@ -1158,49 +1074,12 @@ class _HeaderControlState extends State<HeaderControl> {
primary: false,
automaticallyImplyLeading: false,
titleSpacing: 14,
title: Row(
title: Column(
children: [
ComBtn(
icon: const Icon(
FontAwesomeIcons.arrowLeft,
size: 15,
color: Colors.white,
),
fuc: () => <Set<void>>{
if (widget.controller!.isFullScreen.value)
<void>{widget.controller!.triggerFullScreen(status: false)}
else
<void>{
if (MediaQuery.of(context).orientation ==
Orientation.landscape)
{
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
])
},
Get.back()
}
},
),
SizedBox(width: buttonSpace),
if (isFullScreen.value &&
isLandscape &&
widget.videoType == SearchType.video) ...[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
if (isFullScreen.value && isLandscape) ...[
Row(
children: [
ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 200),
child: Obx(
() => Text(
videoIntroController.videoDetail.value.title ?? '',
style: const TextStyle(
color: Colors.white,
fontSize: 16,
),
),
),
),
const SizedBox(width: 40),
if (videoIntroController.isShowOnlineTotal)
Text(
'${videoIntroController.total.value}人正在看',
@ -1208,158 +1087,226 @@ class _HeaderControlState extends State<HeaderControl> {
color: Colors.white,
fontSize: 12,
),
)
),
const Spacer(),
Expanded(
child: Align(
alignment: Alignment.center,
child: StreamBuilder<DateTime>(
stream: _getTimeStream(),
builder: (context, snapshot) {
if (snapshot.hasData) {
String currentTime = _formatTime(snapshot.data!);
return Text(
currentTime,
style: const TextStyle(fontSize: 12),
);
} else if (snapshot.connectionState ==
ConnectionState.waiting) {
// 如果Stream还未发出数据先显示初始获取的时间
String currentTime = _formatTime(initialTime);
return Text(
currentTime,
style: const TextStyle(fontSize: 12),
);
} else {
return const SizedBox();
}
},
),
),
),
const Spacer(),
/// TODO 网络&电量
],
)
] else ...[
ComBtn(
icon: const Icon(
FontAwesomeIcons.house,
size: 15,
color: Colors.white,
),
fuc: () async {
// 销毁播放器实例
await widget.controller!.dispose(type: 'all');
if (mounted) {
Navigator.popUntil(
context, (Route<dynamic> route) => route.isFirst);
}
},
),
],
const Spacer(),
// ComBtn(
// icon: const Icon(
// FontAwesomeIcons.cropSimple,
// size: 15,
// color: Colors.white,
// ),
// fuc: () => _.screenshot(),
// ),
ComBtn(
icon: const Icon(
Icons.cast,
size: 19,
color: Colors.white,
),
fuc: () async {
showDialog<void>(
context: context,
builder: (BuildContext context) {
return LiveDlnaPage(
datasource: widget.videoDetailCtr!.videoUrl);
Row(
children: [
ComBtn(
icon: const Icon(
FontAwesomeIcons.arrowLeft,
size: 15,
color: Colors.white,
),
fuc: () => <Set<void>>{
if (widget.controller!.isFullScreen.value)
<void>{widget.controller!.triggerFullScreen(status: false)}
else
<void>{
if (MediaQuery.of(context).orientation ==
Orientation.landscape)
{
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
])
},
Get.back()
}
},
);
},
),
if (isFullScreen.value) ...[
SizedBox(
width: 56,
height: 34,
child: TextButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero),
),
onPressed: () => showShootDanmakuSheet(),
child: const Text(
'发弹幕',
style: textStyle,
),
),
),
SizedBox(
width: 34,
height: 34,
child: Obx(
() => IconButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero),
),
onPressed: () {
_.isOpenDanmu.value = !_.isOpenDanmu.value;
},
icon: Icon(
_.isOpenDanmu.value
? Icons.subtitles_outlined
: Icons.subtitles_off_outlined,
size: 19,
SizedBox(width: buttonSpace),
if (isFullScreen.value &&
isLandscape &&
widget.videoType == SearchType.video) ...[
Expanded(
child: LayoutBuilder(builder: (context, constraints) {
return SizedBox(
width: constraints.maxWidth,
height: 25,
child: Obx(
() => Marquee(
text: videoIntroController.videoDetail.value.title ??
'',
style: const TextStyle(fontSize: 16),
scrollAxis: Axis.horizontal,
crossAxisAlignment: CrossAxisAlignment.center,
blankSpace: constraints.maxWidth,
velocity: 100,
pauseAfterRound: const Duration(seconds: 1),
startPadding: 0,
accelerationDuration: const Duration(seconds: 1),
accelerationCurve: Curves.linear,
decelerationDuration: const Duration(seconds: 1),
decelerationCurve: Curves.easeOut,
),
),
);
}),
),
] else ...[
ComBtn(
icon: const Icon(
FontAwesomeIcons.house,
size: 15,
color: Colors.white,
),
fuc: () async {
// 销毁播放器实例
await widget.controller!.dispose(type: 'all');
if (context.mounted) {
Navigator.popUntil(
context, (Route<dynamic> route) => route.isFirst);
}
},
),
),
),
],
SizedBox(width: buttonSpace),
if (Platform.isAndroid) ...<Widget>[
SizedBox(
width: 34,
height: 34,
child: IconButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero),
),
onPressed: () async {
bool canUsePiP = false;
widget.controller!.hiddenControls(false);
try {
canUsePiP = await widget.floating!.isPipAvailable;
} on PlatformException catch (_) {
canUsePiP = false;
}
if (canUsePiP) {
final Rational aspectRatio = Rational(
widget.videoDetailCtr!.data.dash!.video!.first.width!,
widget.videoDetailCtr!.data.dash!.video!.first.height!,
],
const Spacer(),
if (GlobalDataCache.enableDlna) ...[
ComBtn(
icon: Image.asset('assets/images/video/dlna.png', width: 19),
fuc: () async {
showDialog<void>(
context: context,
builder: (BuildContext context) {
return LiveDlnaPage(
datasource: widget.videoDetailCtr!.videoUrl);
},
);
await widget.floating!.enable(aspectRatio: aspectRatio);
} else {}
},
},
),
SizedBox(width: buttonSpace),
],
/// 弹幕开关(全屏时)
if (isFullScreen.value) ...[
SizedBox(
width: 56,
height: 34,
child: TextButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero),
),
onPressed: () => showShootDanmakuSheet(),
child: const Text(
'发弹幕',
style: textStyle,
),
),
),
SizedBox(width: buttonSpace),
SizedBox(
width: 34,
height: 34,
child: Obx(
() => IconButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero),
),
onPressed: () {
_.isOpenDanmu.value = !_.isOpenDanmu.value;
},
icon: Icon(
_.isOpenDanmu.value
? Icons.subtitles_outlined
: Icons.subtitles_off_outlined,
size: 19,
color: Colors.white,
),
),
),
),
SizedBox(width: buttonSpace),
],
/// pip
if (Platform.isAndroid) ...<Widget>[
SizedBox(
width: 34,
height: 34,
child: IconButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero),
),
onPressed: () async {
bool canUsePiP = false;
widget.controller!.hiddenControls(false);
try {
canUsePiP = await widget.floating!.isPipAvailable;
} on PlatformException catch (_) {
canUsePiP = false;
}
if (canUsePiP) {
final Rational aspectRatio = Rational(
widget.videoDetailCtr!.data.dash!.video!.first.width!,
widget
.videoDetailCtr!.data.dash!.video!.first.height!,
);
await widget.floating!.enable(aspectRatio: aspectRatio);
} else {}
},
icon: Image.asset(
'assets/images/video/pip.png',
width: 19,
color: Colors.white,
),
),
),
SizedBox(width: buttonSpace),
],
/// 字幕
if (widget.showSubtitleBtn) ...[
ComBtn(
icon: Icon(
FontAwesomeIcons.closedCaptioning,
size: 16,
color: Colors.white.withOpacity(0.9),
),
fuc: () => showSubtitleDialog(),
),
SizedBox(width: buttonSpace),
],
ComBtn(
icon: const Icon(
Icons.picture_in_picture_outlined,
Icons.more_vert_outlined,
size: 19,
color: Colors.white,
),
fuc: () => showSettingSheet(),
),
),
SizedBox(width: buttonSpace),
],
/// 字幕
if (widget.showSubtitleBtn ?? true)
ComBtn(
icon: const Icon(
Icons.closed_caption_off,
size: 22,
color: Colors.white,
),
fuc: () => showSubtitleDialog(),
),
SizedBox(width: buttonSpace),
Obx(
() => SizedBox(
width: 45,
height: 34,
child: TextButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero),
),
onPressed: () => showSetSpeedSheet(),
child: Text(
'${_.playbackSpeed}X',
style: textStyle,
),
),
),
),
SizedBox(width: buttonSpace),
ComBtn(
icon: const Icon(
Icons.more_vert_outlined,
size: 18,
color: Colors.white,
),
fuc: () => showSettingSheet(),
],
),
],
),

View File

@ -101,25 +101,11 @@ class _WhisperDetailPageState extends State<WhisperDetailPage>
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
title: SizedBox(
width: double.infinity,
width: double.maxFinite,
height: 50,
child: Row(
children: [
SizedBox(
width: 34,
height: 34,
child: IconButton(
onPressed: () => Get.back(),
icon: Icon(
Icons.arrow_back_ios,
size: 18,
color: Theme.of(context).colorScheme.onPrimaryContainer,
),
),
),
const SizedBox(width: 10),
GestureDetector(
onTap: () {
feedBack();

View File

@ -7,8 +7,8 @@ import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:path_provider/path_provider.dart';
import 'package:pilipala/common/widgets/drag_handle.dart';
import 'package:pilipala/utils/download.dart';
import 'package:share_plus/share_plus.dart';
import 'package:status_bar_control/status_bar_control.dart';
@ -234,17 +234,17 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
@override
Widget build(BuildContext context) {
return InteractiveViewerBoundary(
controller: _transformationController,
boundaryWidth: MediaQuery.of(context).size.width,
onScaleChanged: _onScaleChanged,
onLeftBoundaryHit: _onLeftBoundaryHit,
onRightBoundaryHit: _onRightBoundaryHit,
onNoBoundaryHit: _onNoBoundaryHit,
maxScale: widget.maxScale,
minScale: widget.minScale,
child: Stack(children: [
CustomDismissible(
return Stack(children: [
InteractiveViewerBoundary(
controller: _transformationController,
boundaryWidth: MediaQuery.of(context).size.width,
onScaleChanged: _onScaleChanged,
onLeftBoundaryHit: _onLeftBoundaryHit,
onRightBoundaryHit: _onRightBoundaryHit,
onNoBoundaryHit: _onNoBoundaryHit,
maxScale: widget.maxScale,
minScale: widget.minScale,
child: CustomDismissible(
onDismissed: () {
Navigator.of(context).pop();
widget.onDismissed?.call(_pageController!.page!.floor());
@ -275,53 +275,50 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
},
),
),
Positioned(
bottom: 0,
left: 0,
right: 0,
child: Container(
padding: EdgeInsets.fromLTRB(
12, 8, 20, MediaQuery.of(context).padding.bottom + 8),
decoration: _enablePageView
? BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.transparent,
Colors.black.withOpacity(0.3)
],
),
)
: null,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
icon: const Icon(Icons.close, color: Colors.white),
onPressed: () {
Navigator.of(context).pop();
widget.onDismissed?.call(_pageController!.page!.floor());
},
),
widget.sources.length > 1
? Text(
"${currentIndex! + 1}/${widget.sources.length}",
style: const TextStyle(color: Colors.white),
)
: const SizedBox(),
PopupMenuButton(
itemBuilder: (context) {
return _buildPopupMenuList();
},
child: const Icon(Icons.more_horiz, color: Colors.white),
),
],
),
),
Positioned(
bottom: 0,
left: 0,
right: 0,
child: Container(
padding: EdgeInsets.fromLTRB(
12, 8, 20, MediaQuery.of(context).padding.bottom + 8),
decoration: _enablePageView
? BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Colors.transparent, Colors.black.withOpacity(0.3)],
),
)
: null,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
icon: const Icon(Icons.close, color: Colors.white),
onPressed: () {
Navigator.of(context).pop();
widget.onDismissed?.call(_pageController!.page!.floor());
},
),
widget.sources.length > 1
? Text(
"${currentIndex! + 1}/${widget.sources.length}",
style: const TextStyle(color: Colors.white),
)
: const SizedBox(),
PopupMenuButton(
itemBuilder: (context) {
return _buildPopupMenuList();
},
child: const Icon(Icons.more_horiz, color: Colors.white),
),
],
),
),
]),
);
),
]);
}
// 图片分享
@ -426,29 +423,13 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
useRootNavigator: true,
isScrollControlled: true,
builder: (context) {
return Container(
return Padding(
padding:
EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
InkWell(
onTap: () => Get.back(),
child: Container(
height: 35,
padding: const EdgeInsets.only(bottom: 2),
child: Center(
child: Container(
width: 32,
height: 3,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.outline,
borderRadius:
const BorderRadius.all(Radius.circular(3))),
),
),
),
),
const DragHandle(),
..._buildListTitles(),
],
),

View File

@ -6,6 +6,7 @@ import 'dart:typed_data';
import 'package:easy_debounce/easy_throttle.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_volume_controller/flutter_volume_controller.dart';
import 'package:get/get.dart';
import 'package:hive/hive.dart';
@ -113,12 +114,13 @@ class PlPlayerController {
// final Durations durations;
List<Map<String, dynamic>> videoFitType = [
{'attr': BoxFit.contain, 'desc': '包含'},
{'attr': BoxFit.cover, 'desc': '覆盖'},
{'attr': BoxFit.fill, 'desc': ''},
{'attr': BoxFit.fitHeight, 'desc': '度适应'},
{'attr': BoxFit.fitWidth, 'desc': '度适应'},
{'attr': BoxFit.scaleDown, 'desc': '小适应'},
{'attr': BoxFit.contain, 'desc': '自动'},
{'attr': BoxFit.cover, 'desc': '铺满'},
{'attr': BoxFit.fill, 'desc': ''},
{'attr': BoxFit.fitHeight, 'desc': ''},
{'attr': BoxFit.fitWidth, 'desc': ''},
{'attr': BoxFit.scaleDown, 'desc': ''},
{'attr': BoxFit.none, 'desc': '原始'},
];
PreferredSizeWidget? headerControl;
@ -278,19 +280,18 @@ class PlPlayerController {
// 添加一个私有构造函数
PlPlayerController._internal(this.videoType) {
final cache = GlobalDataCache();
isOpenDanmu.value = cache.isOpenDanmu;
blockTypes = cache.blockTypes;
showArea = cache.showArea;
opacityVal = cache.opacityVal;
fontSizeVal = cache.fontSizeVal;
danmakuDurationVal = cache.danmakuDurationVal;
strokeWidth = cache.strokeWidth;
playRepeat = cache.playRepeat;
_playbackSpeed.value = cache.playbackSpeed;
enableAutoLongPressSpeed = cache.enableAutoLongPressSpeed;
_longPressSpeed.value = cache.longPressSpeed;
speedsList = cache.speedsList;
isOpenDanmu.value = GlobalDataCache.isOpenDanmu;
blockTypes = GlobalDataCache.blockTypes;
showArea = GlobalDataCache.showArea;
opacityVal = GlobalDataCache.opacityVal;
fontSizeVal = GlobalDataCache.fontSizeVal;
danmakuDurationVal = GlobalDataCache.danmakuDurationVal;
strokeWidth = GlobalDataCache.strokeWidth;
playRepeat = GlobalDataCache.playRepeat;
_playbackSpeed.value = GlobalDataCache.playbackSpeed;
enableAutoLongPressSpeed = GlobalDataCache.enableAutoLongPressSpeed;
_longPressSpeed.value = GlobalDataCache.longPressSpeed;
speedsList = GlobalDataCache.speedsList;
// _playerEventSubs = onPlayerStatusChanged.listen((PlayerStatus status) {
// if (status == PlayerStatus.playing) {
// WakelockPlus.enable();
@ -471,6 +472,7 @@ class PlPlayerController {
configuration: VideoControllerConfiguration(
enableHardwareAcceleration: enableHA,
androidAttachSurfaceAfterVideoParameters: false,
hwdec: enableHA ? GlobalDataCache.hardwareDecodeFormat : null,
),
);
@ -828,47 +830,53 @@ class PlPlayerController {
}
/// Toggle Change the videofit accordingly
void toggleVideoFit() {
showDialog(
context: Get.context!,
builder: (context) {
return AlertDialog(
title: const Text('画面比例'),
content: StatefulBuilder(builder: (context, StateSetter setState) {
return Wrap(
alignment: WrapAlignment.start,
void toggleVideoFit(String toggleType) {
if (toggleType == 'press') {
final String videoFitDEsc = _videoFitDesc.value;
final int index = videoFitType.indexWhere(
(element) => element['desc'] == videoFitDEsc,
);
final int newIndex = index + 1 >= videoFitType.length ? 0 : index + 1;
_videoFit.value = videoFitType[newIndex]['attr'];
_videoFitDesc.value = videoFitType[newIndex]['desc'];
setVideoFit();
SmartDialog.showToast('画面比例:${videoFitType[newIndex]['desc']}');
} else {
void onPressed(item) {
_videoFit.value = item['attr'];
_videoFitDesc.value = item['desc'];
setVideoFit();
Navigator.of(Get.context!).pop();
}
showDialog(
context: Get.context!,
builder: (context) {
return AlertDialog(
title: const Text('画面比例'),
content: Wrap(
spacing: 8,
runSpacing: 2,
children: [
for (var i in videoFitType) ...[
if (_videoFit.value == i['attr']) ...[
FilledButton(
onPressed: () async {
_videoFit.value = i['attr'];
_videoFitDesc.value = i['desc'];
setVideoFit();
Get.back();
},
onPressed: () => onPressed(i),
child: Text(i['desc']),
),
] else ...[
FilledButton.tonal(
onPressed: () async {
_videoFit.value = i['attr'];
_videoFitDesc.value = i['desc'];
setVideoFit();
Get.back();
},
onPressed: () => onPressed(i),
child: Text(i['desc']),
),
]
]
],
);
}),
);
},
);
),
);
},
);
}
}
/// 缓存fit
@ -929,6 +937,11 @@ class PlPlayerController {
showControls.value = !val;
}
/// 设置/更新顶部控制栏
void setHeaderControl(PreferredSizeWidget? widget) {
headerControl = widget;
}
void toggleFullScreen(bool val) {
_isFullScreen.value = val;
}
@ -1047,13 +1060,12 @@ class PlPlayerController {
/// 缓存本次弹幕选项
cacheDanmakuOption() {
final cache = GlobalDataCache();
cache.blockTypes = blockTypes;
cache.showArea = showArea;
cache.opacityVal = opacityVal;
cache.fontSizeVal = fontSizeVal;
cache.danmakuDurationVal = danmakuDurationVal;
cache.strokeWidth = strokeWidth;
GlobalDataCache.blockTypes = blockTypes;
GlobalDataCache.showArea = showArea;
GlobalDataCache.opacityVal = opacityVal;
GlobalDataCache.fontSizeVal = fontSizeVal;
GlobalDataCache.danmakuDurationVal = danmakuDurationVal;
GlobalDataCache.strokeWidth = strokeWidth;
localCache.put(LocalCacheKey.danmakuBlockType, blockTypes);
localCache.put(LocalCacheKey.danmakuShowArea, showArea);

View File

@ -89,7 +89,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
late bool enableBackgroundPlay;
late double screenWidth;
final FullScreenGestureMode fullScreenGestureMode =
GlobalDataCache().fullScreenGestureMode;
GlobalDataCache.fullScreenGestureMode;
// 用于记录上一次全屏切换手势触发时间,避免误触
DateTime? lastFullScreenToggleTime;
@ -136,7 +136,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
screenWidth = Get.size.width;
animationController = AnimationController(
vsync: this,
duration: GlobalDataCache().enablePlayerControlAnimation
duration: GlobalDataCache.enablePlayerControlAnimation
? const Duration(milliseconds: 150)
: const Duration(milliseconds: 10),
);
@ -301,16 +301,22 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
/// 画面比例
BottomControlType.fit: SizedBox(
width: 45,
height: 30,
child: TextButton(
onPressed: () => _.toggleVideoFit(),
onPressed: () => _.toggleVideoFit('press'),
onLongPress: () => _.toggleVideoFit('longPress'),
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero),
),
child: Obx(
() => Text(
_.videoFitDEsc.value,
style: const TextStyle(color: Colors.white, fontSize: 13),
style: const TextStyle(
color: Colors.white,
fontSize: 12,
fontWeight: FontWeight.bold,
),
),
),
),
@ -320,29 +326,49 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
BottomControlType.speed: SizedBox(
width: 45,
height: 34,
child: TextButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero),
),
onPressed: () {},
child: Obx(
() => Text(
'${_.playbackSpeed.toString()}X',
style: textStyle,
child: PopupMenuButton<double>(
tooltip: '更改播放速度',
onSelected: (double value) {
_.setPlaybackSpeed(value);
},
initialValue: _.playbackSpeed,
color: Colors.black.withOpacity(0.8),
itemBuilder: (BuildContext context) {
return _.speedsList.map((double speed) {
return PopupMenuItem<double>(
height: 40,
padding: const EdgeInsets.only(left: 20),
value: speed,
child: Text(
'${speed}x',
style: textStyle.copyWith(fontWeight: FontWeight.bold),
),
);
}).toList();
},
child: Container(
width: 45,
height: 34,
alignment: Alignment.center,
margin: const EdgeInsets.only(right: 4),
child: Obx(
() => Text(
'${_.playbackSpeed.toString()}x',
style: textStyle.copyWith(fontWeight: FontWeight.bold),
),
),
),
),
),
/// 字幕
/// 全屏
BottomControlType.fullscreen: ComBtn(
icon: Obx(
() => Icon(
() => Image.asset(
_.isFullScreen.value
? FontAwesomeIcons.compress
: FontAwesomeIcons.expand,
size: 15,
? 'assets/images/video/fullscreen_exit.png'
: 'assets/images/video/fullscreen.png',
width: 19,
color: Colors.white,
),
),
@ -359,6 +385,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
BottomControlType.time,
BottomControlType.space,
BottomControlType.fit,
BottomControlType.speed,
BottomControlType.fullscreen,
];
for (var i = 0; i < userSpecifyItem.length; i++) {
@ -739,29 +766,37 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
// 头部、底部控制条
Obx(
() => Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (widget.headerControl != null || _.headerControl != null)
ClipRect(
if (widget.headerControl != null || _.headerControl != null) ...[
Flexible(
child: ClipRect(
child: AppBarAni(
controller: animationController,
visible: !_.controlsLock.value && _.showControls.value,
position: 'top',
child: widget.headerControl ?? _.headerControl!,
),
),
),
] else ...[
const SizedBox.shrink()
],
Flexible(
flex: _.videoType == 'live' ? 0 : 1,
child: ClipRect(
child: AppBarAni(
controller: animationController,
visible: !_.controlsLock.value && _.showControls.value,
position: 'top',
child: widget.headerControl ?? _.headerControl!,
position: 'bottom',
child: widget.bottomControl ??
BottomControl(
controller: widget.controller,
triggerFullScreen: _.triggerFullScreen,
buildBottomControl: buildBottomControl(),
),
),
),
const Spacer(),
ClipRect(
child: AppBarAni(
controller: animationController,
visible: !_.controlsLock.value && _.showControls.value,
position: 'bottom',
child: widget.bottomControl ??
BottomControl(
controller: widget.controller,
triggerFullScreen: _.triggerFullScreen,
buildBottomControl: buildBottomControl(),
),
),
),
],
),
@ -807,8 +842,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
total: Duration(seconds: max),
progressBarColor: colorTheme,
baseBarColor: Colors.white.withOpacity(0.2),
bufferedBarColor:
Theme.of(context).colorScheme.primary.withOpacity(0.4),
bufferedBarColor: Colors.white.withOpacity(0.6),
timeLabelLocation: TimeLabelLocation.none,
thumbColor: colorTheme,
barHeight: 3,

View File

@ -1,8 +1,6 @@
import 'package:audio_video_progress_bar/audio_video_progress_bar.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/plugin/pl_player/index.dart';
import 'package:pilipala/utils/feed_back.dart';
import 'progress_bar.dart';
class BottomControl extends StatelessWidget implements PreferredSizeWidget {
final PlPlayerController? controller;
@ -20,54 +18,18 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
@override
Widget build(BuildContext context) {
Color colorTheme = Theme.of(context).colorScheme.primary;
final _ = controller!;
return Container(
color: Colors.transparent,
height: 90,
padding: const EdgeInsets.only(left: 18, right: 18),
padding: const EdgeInsets.symmetric(horizontal: 18),
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Obx(
() {
final int value = _.sliderPositionSeconds.value;
final int max = _.durationSeconds.value;
final int buffer = _.bufferedSeconds.value;
if (value > max || max <= 0) {
return const SizedBox();
}
return Padding(
padding: const EdgeInsets.only(left: 7, right: 7, bottom: 6),
child: ProgressBar(
progress: Duration(seconds: value),
buffered: Duration(seconds: buffer),
total: Duration(seconds: max),
progressBarColor: colorTheme,
baseBarColor: Colors.white.withOpacity(0.2),
bufferedBarColor: colorTheme.withOpacity(0.4),
timeLabelLocation: TimeLabelLocation.none,
thumbColor: colorTheme,
barHeight: 3.5,
thumbRadius: 7,
onDragStart: (duration) {
feedBack();
_.onChangedSliderStart();
},
onDragUpdate: (duration) {
_.onUpdatedSliderProgress(duration.timeStamp);
},
onSeek: (duration) {
_.onChangedSliderEnd();
_.onChangedSlider(duration.inSeconds.toDouble());
_.seekTo(Duration(seconds: duration.inSeconds),
type: 'slider');
},
),
);
},
Padding(
padding: const EdgeInsets.fromLTRB(7, 0, 7, 6),
child: ProgressBarWidget(controller: controller!),
),
Row(children: [...buildBottomControl!]),
Row(children: buildBottomControl!),
const SizedBox(height: 10),
],
),

View File

@ -0,0 +1,52 @@
import 'package:audio_video_progress_bar/audio_video_progress_bar.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/plugin/pl_player/index.dart';
import 'package:pilipala/utils/feed_back.dart';
class ProgressBarWidget extends StatelessWidget {
final PlPlayerController controller;
const ProgressBarWidget({
required this.controller,
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Obx(() {
Color colorTheme = Theme.of(context).colorScheme.primary;
final _ = controller;
final int value = _.sliderPositionSeconds.value;
final int max = _.durationSeconds.value;
final int buffer = _.bufferedSeconds.value;
if (value > max || max <= 0) {
return const SizedBox();
}
return ProgressBar(
progress: Duration(seconds: value),
buffered: Duration(seconds: buffer),
total: Duration(seconds: max),
progressBarColor: colorTheme,
baseBarColor: Colors.white.withOpacity(0.2),
bufferedBarColor: Colors.white.withOpacity(0.6),
timeLabelLocation: TimeLabelLocation.none,
thumbColor: colorTheme,
barHeight: 3.5,
thumbRadius: 7,
onDragStart: (duration) {
feedBack();
_.onChangedSliderStart();
},
onDragUpdate: (duration) {
_.onUpdatedSliderProgress(duration.timeStamp);
},
onSeek: (duration) {
_.onChangedSliderEnd();
_.onChangedSlider(duration.inSeconds.toDouble());
_.seekTo(Duration(seconds: duration.inSeconds), type: 'slider');
},
);
});
}
}

View File

@ -1,3 +1,4 @@
import 'dart:io';
import 'package:hive/hive.dart';
import 'package:pilipala/models/user/info.dart';
import 'package:pilipala/plugin/pl_player/models/play_repeat.dart';
@ -5,54 +6,62 @@ import 'package:pilipala/plugin/pl_player/models/play_speed.dart';
import 'package:pilipala/utils/storage.dart';
import '../models/common/index.dart';
Box setting = GStorage.setting;
Box settingBox = GStorage.setting;
Box localCache = GStorage.localCache;
Box videoStorage = GStorage.video;
Box userInfoCache = GStorage.userInfo;
class GlobalDataCache {
late int imgQuality;
late FullScreenGestureMode fullScreenGestureMode;
late bool enablePlayerControlAnimation;
late List<String> actionTypeSort;
late double sheetHeight;
String? wWebid;
static late int imgQuality;
static late FullScreenGestureMode fullScreenGestureMode;
static late bool enablePlayerControlAnimation;
static late List<String> actionTypeSort;
static late double sheetHeight;
static String? wWebid;
/// 播放器相关
// 弹幕开关
late bool isOpenDanmu;
static late bool isOpenDanmu;
// 弹幕屏蔽类型
late List<dynamic> blockTypes;
static late List<dynamic> blockTypes;
// 弹幕展示区域
late double showArea;
static late double showArea;
// 弹幕透明度
late double opacityVal;
static late double opacityVal;
// 弹幕字体大小
late double fontSizeVal;
static late double fontSizeVal;
// 弹幕显示时间
late double danmakuDurationVal;
static late double danmakuDurationVal;
// 弹幕描边宽度
late double strokeWidth;
static late double strokeWidth;
// 播放器循环模式
late PlayRepeat playRepeat;
static late PlayRepeat playRepeat;
// 播放器默认播放速度
late double playbackSpeed;
static late double playbackSpeed;
// 播放器自动长按速度
late bool enableAutoLongPressSpeed;
static late bool enableAutoLongPressSpeed;
// 播放器长按速度
late double longPressSpeed;
static late double longPressSpeed;
// 播放器速度列表
late List<double> speedsList;
static late List<double> speedsList;
// 用户信息
UserInfoData? userInfo;
static UserInfoData? userInfo;
// 搜索历史
late List historyCacheList;
//
late bool enableSearchSuggest = true;
static late List historyCacheList;
// 搜索建议
static late bool enableSearchSuggest;
// 简介默认展开
late bool enableAutoExpand = false;
//
late bool enableDynamicSwitch = true;
static late bool enableAutoExpand;
// 动态切换
static late bool enableDynamicSwitch;
// 投屏开关
static bool enableDlna = false;
// 硬件解码格式
static late String hardwareDecodeFormat;
// sponsorBlock开关
static bool enableSponsorBlock = false;
// 视频评论开关
static List<String> enableComment = ['video', 'bangumi'];
// 私有构造函数
GlobalDataCache._();
@ -64,19 +73,19 @@ class GlobalDataCache {
factory GlobalDataCache() => _instance;
// 异步初始化方法
Future<void> initialize() async {
imgQuality = await setting.get(SettingBoxKey.defaultPicQa,
static Future<void> initialize() async {
imgQuality = await settingBox.get(SettingBoxKey.defaultPicQa,
defaultValue: 10); // 设置全局变量
fullScreenGestureMode = FullScreenGestureMode.values[setting.get(
fullScreenGestureMode = FullScreenGestureMode.values[settingBox.get(
SettingBoxKey.fullScreenGestureMode,
defaultValue: FullScreenGestureMode.fromBottomtoTop.index)];
enablePlayerControlAnimation = setting
enablePlayerControlAnimation = settingBox
.get(SettingBoxKey.enablePlayerControlAnimation, defaultValue: true);
actionTypeSort = await setting.get(SettingBoxKey.actionTypeSort,
actionTypeSort = await settingBox.get(SettingBoxKey.actionTypeSort,
defaultValue: ['like', 'coin', 'collect', 'watchLater', 'share']);
isOpenDanmu =
await setting.get(SettingBoxKey.enableShowDanmaku, defaultValue: false);
isOpenDanmu = await settingBox.get(SettingBoxKey.enableShowDanmaku,
defaultValue: false);
blockTypes =
await localCache.get(LocalCacheKey.danmakuBlockType, defaultValue: []);
showArea =
@ -97,7 +106,7 @@ class GlobalDataCache {
.firstWhere((e) => e.value == defaultPlayRepeat);
playbackSpeed =
await videoStorage.get(VideoBoxKey.playSpeedDefault, defaultValue: 1.0);
enableAutoLongPressSpeed = await setting
enableAutoLongPressSpeed = await settingBox
.get(SettingBoxKey.enableAutoLongPressSpeed, defaultValue: false);
if (!enableAutoLongPressSpeed) {
longPressSpeed = await videoStorage.get(VideoBoxKey.longPressSpeedDefault,
@ -115,10 +124,21 @@ class GlobalDataCache {
sheetHeight = localCache.get('sheetHeight', defaultValue: 0.0);
historyCacheList = localCache.get('cacheList', defaultValue: []);
enableSearchSuggest =
setting.get(SettingBoxKey.enableSearchSuggest, defaultValue: true);
settingBox.get(SettingBoxKey.enableSearchSuggest, defaultValue: true);
enableAutoExpand =
setting.get(SettingBoxKey.enableAutoExpand, defaultValue: false);
settingBox.get(SettingBoxKey.enableAutoExpand, defaultValue: false);
enableDynamicSwitch =
setting.get(SettingBoxKey.enableDynamicSwitch, defaultValue: true);
settingBox.get(SettingBoxKey.enableDynamicSwitch, defaultValue: true);
enableDlna = settingBox.get(SettingBoxKey.enableDlna, defaultValue: false);
hardwareDecodeFormat = settingBox.get(SettingBoxKey.hardwareDecodeFormat,
defaultValue: Platform.isAndroid ? 'auto-safe' : 'auto');
settingBox.get(SettingBoxKey.enableDynamicSwitch, defaultValue: true);
enableDlna = settingBox.get(SettingBoxKey.enableDlna, defaultValue: false);
enableSponsorBlock =
settingBox.get(SettingBoxKey.enableSponsorBlock, defaultValue: false);
settingBox.get(SettingBoxKey.enableDynamicSwitch, defaultValue: true);
enableDlna = settingBox.get(SettingBoxKey.enableDlna, defaultValue: false);
enableComment = settingBox
.get(SettingBoxKey.enableComment, defaultValue: ['video', 'bangumi']);
}
}

View File

@ -118,7 +118,7 @@ class LoginUtils {
Request.dio.options.headers['cookie'] = '';
userInfoCache.put('userInfoCache', null);
localCache.put(LocalCacheKey.accessKey, {'mid': -1, 'value': ''});
GlobalDataCache().userInfo = null;
GlobalDataCache.userInfo = null;
await refreshLoginStatus(false);
}
}

View File

@ -115,7 +115,11 @@ class SettingBoxKey {
enableAi = 'enableAi',
enableAutoExpand = 'enableAutoExpand',
defaultHomePage = 'defaultHomePage',
enableRelatedVideo = 'enableRelatedVideo';
enableRelatedVideo = 'enableRelatedVideo',
enableDlna = 'enableDlna',
hardwareDecodeFormat = 'hardwareDecodeFormat',
enableSponsorBlock = 'enableSponsorBlock',
enableComment = 'enableComment';
/// 外观
static const String themeMode = 'themeMode',

View File

@ -497,6 +497,14 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "6.2.1"
fading_edge_scrollview:
dependency: transitive
description:
name: fading_edge_scrollview
sha256: c25c2231652ce774cc31824d0112f11f653881f43d7f5302c05af11942052031
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.0"
fake_async:
dependency: transitive
description:
@ -990,6 +998,14 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "6.1.0"
marquee:
dependency: "direct main"
description:
name: marquee
sha256: "4b5243d2804373bdc25fc93d42c3b402d6ec1f4ee8d0bb72276edd04ae7addb8"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.2.3"
matcher:
dependency: transitive
description:

View File

@ -152,6 +152,8 @@ dependencies:
re_highlight: ^0.0.3
# 图片选择器
image_picker: ^1.1.2
# 跑马灯
marquee: ^2.2.3
dev_dependencies:
flutter_test: