Merge branch 'main' into feature-invalidInfo
This commit is contained in:
126
lib/common/skeleton/video_intro.dart
Normal file
126
lib/common/skeleton/video_intro.dart
Normal 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),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -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) {
|
||||
|
||||
@ -1,9 +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});
|
||||
@ -70,4 +76,42 @@ class CommonHttp {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,18 +1,16 @@
|
||||
// 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';
|
||||
import 'package:dio_cookie_manager/dio_cookie_manager.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
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';
|
||||
|
||||
@ -26,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
|
||||
@ -43,7 +39,7 @@ class Request {
|
||||
dio.interceptors.add(cookieManager);
|
||||
final List<Cookie> cookie = await cookieManager.cookieJar
|
||||
.loadForRequest(Uri.parse(HttpString.baseUrl));
|
||||
final userInfo = userInfoCache.get('userInfoCache');
|
||||
final UserInfoData? userInfo = userInfoCache.get('userInfoCache');
|
||||
if (userInfo != null && userInfo.mid != null) {
|
||||
final List<Cookie> cookie2 = await cookieManager.cookieJar
|
||||
.loadForRequest(Uri.parse(HttpString.tUrl));
|
||||
@ -61,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}')
|
||||
@ -121,30 +112,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
|
||||
*/
|
||||
|
||||
@ -4,6 +4,7 @@ import 'package:hive/hive.dart';
|
||||
import 'package:html/parser.dart';
|
||||
import 'package:pilipala/models/member/article.dart';
|
||||
import 'package:pilipala/models/member/like.dart';
|
||||
import 'package:pilipala/models/user/info.dart';
|
||||
import 'package:pilipala/utils/global_data_cache.dart';
|
||||
import '../common/constants.dart';
|
||||
import '../models/dynamics/result.dart';
|
||||
@ -25,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({
|
||||
@ -472,9 +473,9 @@ class MemberHttp {
|
||||
String accessKey = res.data['data']['access_token'];
|
||||
Box localCache = GStorage.localCache;
|
||||
Box userInfoCache = GStorage.userInfo;
|
||||
var userInfo = userInfoCache.get('userInfoCache');
|
||||
final UserInfoData? userInfo = userInfoCache.get('userInfoCache');
|
||||
localCache.put(
|
||||
LocalCacheKey.accessKey, {'mid': userInfo.mid, 'value': accessKey});
|
||||
LocalCacheKey.accessKey, {'mid': userInfo!.mid, 'value': accessKey});
|
||||
return {'status': true, 'data': [], 'msg': '操作成功'};
|
||||
} else {
|
||||
return {
|
||||
@ -573,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};
|
||||
}
|
||||
@ -587,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': '请检查登录状态'};
|
||||
@ -604,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,
|
||||
|
||||
@ -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 {
|
||||
@ -224,12 +226,8 @@ class BuildMainApp extends StatelessWidget {
|
||||
|
||||
AppBarTheme appBarTheme(ColorScheme colorScheme) {
|
||||
return AppBarTheme(
|
||||
backgroundColor: currentThemeValue == ThemeType.dark
|
||||
? darkColorScheme.surface
|
||||
: lightColorScheme.surface,
|
||||
foregroundColor: currentThemeValue == ThemeType.dark
|
||||
? darkColorScheme.onSurface
|
||||
: lightColorScheme.onSurface,
|
||||
backgroundColor: colorScheme.surface,
|
||||
foregroundColor: colorScheme.onSurface,
|
||||
elevation: 0,
|
||||
titleSpacing: 0,
|
||||
scrolledUnderElevation: 0,
|
||||
|
||||
18
lib/models/common/comment_range_type.dart
Normal file
18
lib/models/common/comment_range_type.dart
Normal 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];
|
||||
}
|
||||
@ -3,6 +3,7 @@ import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/http/bangumi.dart';
|
||||
import 'package:pilipala/models/bangumi/list.dart';
|
||||
import 'package:pilipala/models/user/info.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
|
||||
class BangumiController extends GetxController {
|
||||
@ -15,14 +16,14 @@ class BangumiController extends GetxController {
|
||||
Box userInfoCache = GStorage.userInfo;
|
||||
RxBool userLogin = false.obs;
|
||||
late int mid;
|
||||
var userInfo;
|
||||
UserInfoData? userInfo;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
userInfo = userInfoCache.get('userInfoCache');
|
||||
if (userInfo != null) {
|
||||
mid = userInfo.mid;
|
||||
mid = userInfo!.mid!;
|
||||
}
|
||||
userLogin.value = userInfo != null;
|
||||
}
|
||||
@ -55,7 +56,7 @@ class BangumiController extends GetxController {
|
||||
if (userInfo == null) {
|
||||
return;
|
||||
}
|
||||
var result = await BangumiHttp.getRecentBangumi(mid: userInfo.mid);
|
||||
var result = await BangumiHttp.getRecentBangumi(mid: userInfo!.mid!);
|
||||
if (result['status']) {
|
||||
bangumiFollowList.value = result['data'].list;
|
||||
total.value = result['data'].total;
|
||||
|
||||
@ -8,6 +8,7 @@ import 'package:pilipala/http/search.dart';
|
||||
import 'package:pilipala/http/video.dart';
|
||||
import 'package:pilipala/models/bangumi/info.dart';
|
||||
import 'package:pilipala/models/user/fav_folder.dart';
|
||||
import 'package:pilipala/models/user/info.dart';
|
||||
import 'package:pilipala/pages/video/detail/index.dart';
|
||||
import 'package:pilipala/pages/video/detail/reply/index.dart';
|
||||
import 'package:pilipala/plugin/pl_player/models/play_repeat.dart';
|
||||
@ -57,7 +58,7 @@ class BangumiIntroController extends GetxController {
|
||||
RxBool isFollowed = false.obs;
|
||||
RxInt followStatus = 1.obs;
|
||||
int _tempThemeValue = -1;
|
||||
var userInfo;
|
||||
UserInfoData? userInfo;
|
||||
PersistentBottomSheetController? bottomSheetController;
|
||||
List<Map<String, dynamic>> followStatusList = [
|
||||
{'title': '标记为 「想看」', 'status': 1},
|
||||
@ -259,7 +260,7 @@ class BangumiIntroController extends GetxController {
|
||||
|
||||
Future queryVideoInFolder() async {
|
||||
var result = await VideoHttp.videoInFolder(
|
||||
mid: userInfo.mid, rid: IdUtils.bv2av(bvid));
|
||||
mid: userInfo!.mid!, rid: IdUtils.bv2av(bvid));
|
||||
if (result['status']) {
|
||||
favFolderData.value = result['data'];
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
||||
|
||||
// 收藏
|
||||
showFavBottomSheet() async {
|
||||
if (bangumiIntroController.userInfo.mid == null) {
|
||||
if (bangumiIntroController.userInfo?.mid == null) {
|
||||
SmartDialog.showToast('账号未登录');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/models/bangumi/info.dart';
|
||||
import 'package:pilipala/models/user/info.dart';
|
||||
import 'package:pilipala/pages/video/detail/index.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
import '../../../common/pages_bottom_sheet.dart';
|
||||
@ -37,7 +38,7 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
||||
late RxInt currentIndex = (-1).obs;
|
||||
final ScrollController listViewScrollCtr = ScrollController();
|
||||
Box userInfoCache = GStorage.userInfo;
|
||||
dynamic userInfo;
|
||||
UserInfoData? userInfo;
|
||||
// 默认未开通
|
||||
int vipStatus = 0;
|
||||
late int cid;
|
||||
@ -63,7 +64,7 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
||||
/// 获取大会员状态
|
||||
userInfo = userInfoCache.get('userInfoCache');
|
||||
if (userInfo != null) {
|
||||
vipStatus = userInfo.vipStatus;
|
||||
vipStatus = userInfo!.vipStatus!;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ import 'package:pilipala/models/common/dynamics_type.dart';
|
||||
import 'package:pilipala/models/dynamics/result.dart';
|
||||
import 'package:pilipala/models/dynamics/up.dart';
|
||||
import 'package:pilipala/models/live/item.dart';
|
||||
import 'package:pilipala/models/user/info.dart';
|
||||
import 'package:pilipala/utils/feed_back.dart';
|
||||
import 'package:pilipala/utils/id_utils.dart';
|
||||
import 'package:pilipala/utils/route_push.dart';
|
||||
@ -52,7 +53,7 @@ class DynamicsController extends GetxController {
|
||||
RxInt initialValue = 0.obs;
|
||||
Box userInfoCache = GStorage.userInfo;
|
||||
RxBool userLogin = false.obs;
|
||||
var userInfo;
|
||||
UserInfoData? userInfo;
|
||||
RxBool isLoadingDynamic = false.obs;
|
||||
Box setting = GStorage.setting;
|
||||
|
||||
@ -246,7 +247,7 @@ class DynamicsController extends GetxController {
|
||||
}
|
||||
upData.value.upList!.insertAll(0, [
|
||||
UpItem(face: '', uname: '全部动态', mid: -1),
|
||||
UpItem(face: userInfo.face, uname: '我', mid: userInfo.mid),
|
||||
UpItem(face: userInfo!.face, uname: '我', mid: userInfo!.mid),
|
||||
]);
|
||||
}
|
||||
return res;
|
||||
|
||||
@ -90,7 +90,7 @@ class _ActionPanelState extends State<ActionPanel>
|
||||
SmartDialog.showToast('请先登录');
|
||||
return;
|
||||
}
|
||||
int mid = userInfo.mid;
|
||||
int mid = userInfo.mid!;
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
enableDrag: true,
|
||||
|
||||
@ -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)
|
||||
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,
|
||||
)
|
||||
],
|
||||
VerticalDivider(
|
||||
indent: 20,
|
||||
endIndent: 40,
|
||||
width: 26,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.primary
|
||||
.withOpacity(0.5),
|
||||
)
|
||||
: 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') {
|
||||
@ -254,10 +389,9 @@ class _UpPanelState extends State<UpPanel> {
|
||||
color: currentMid.value == data.mid
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Theme.of(context).colorScheme.outline,
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.labelMedium!
|
||||
.fontSize),
|
||||
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,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/http/fan.dart';
|
||||
import 'package:pilipala/models/fans/result.dart';
|
||||
import 'package:pilipala/models/user/info.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
|
||||
class FansController extends GetxController {
|
||||
@ -13,7 +14,7 @@ class FansController extends GetxController {
|
||||
RxList<FansItemModel> fansList = <FansItemModel>[].obs;
|
||||
late int mid;
|
||||
late String name;
|
||||
var userInfo;
|
||||
UserInfoData? userInfo;
|
||||
RxString loadingText = '加载中...'.obs;
|
||||
RxBool isOwner = false.obs;
|
||||
|
||||
@ -23,9 +24,9 @@ class FansController extends GetxController {
|
||||
userInfo = userInfoCache.get('userInfoCache');
|
||||
mid = Get.parameters['mid'] != null
|
||||
? int.parse(Get.parameters['mid']!)
|
||||
: userInfo.mid;
|
||||
isOwner.value = mid == userInfo.mid;
|
||||
name = Get.parameters['name'] ?? userInfo.uname;
|
||||
: userInfo!.mid!;
|
||||
isOwner.value = mid == userInfo?.mid;
|
||||
name = Get.parameters['name'] ?? userInfo?.uname ?? '';
|
||||
}
|
||||
|
||||
Future queryFans(type) async {
|
||||
|
||||
@ -6,6 +6,7 @@ import 'package:pilipala/http/follow.dart';
|
||||
import 'package:pilipala/http/member.dart';
|
||||
import 'package:pilipala/models/follow/result.dart';
|
||||
import 'package:pilipala/models/member/tags.dart';
|
||||
import 'package:pilipala/models/user/info.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
|
||||
/// 查看自己的关注时,可以查看分类
|
||||
@ -18,7 +19,7 @@ class FollowController extends GetxController with GetTickerProviderStateMixin {
|
||||
RxList<FollowItemModel> followList = <FollowItemModel>[].obs;
|
||||
late int mid;
|
||||
late String name;
|
||||
var userInfo;
|
||||
UserInfoData? userInfo;
|
||||
RxString loadingText = '加载中...'.obs;
|
||||
RxBool isOwner = false.obs;
|
||||
late List<MemberTagItemModel> followTags;
|
||||
@ -30,9 +31,9 @@ class FollowController extends GetxController with GetTickerProviderStateMixin {
|
||||
userInfo = userInfoCache.get('userInfoCache');
|
||||
mid = Get.parameters['mid'] != null
|
||||
? int.parse(Get.parameters['mid']!)
|
||||
: userInfo.mid;
|
||||
isOwner.value = mid == userInfo.mid;
|
||||
name = Get.parameters['name'] ?? userInfo.uname;
|
||||
: userInfo!.mid!;
|
||||
isOwner.value = mid == userInfo?.mid;
|
||||
name = Get.parameters['name'] ?? userInfo?.uname ?? '';
|
||||
}
|
||||
|
||||
Future queryFollowings(type) async {
|
||||
@ -68,7 +69,7 @@ class FollowController extends GetxController with GetTickerProviderStateMixin {
|
||||
|
||||
// 当查看当前用户的关注时,请求关注分组
|
||||
Future followUpTags() async {
|
||||
if (userInfo != null && mid == userInfo.mid) {
|
||||
if (userInfo != null && mid == userInfo!.mid) {
|
||||
var res = await MemberHttp.followUpTags();
|
||||
if (res['status']) {
|
||||
followTags = res['data'];
|
||||
|
||||
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/models/common/tab_type.dart';
|
||||
import 'package:pilipala/models/user/info.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
import '../../http/index.dart';
|
||||
|
||||
@ -18,7 +19,7 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
|
||||
Box settingStorage = GStorage.setting;
|
||||
RxBool userLogin = false.obs;
|
||||
RxString userFace = ''.obs;
|
||||
var userInfo;
|
||||
UserInfoData? userInfo;
|
||||
Box setting = GStorage.setting;
|
||||
late final StreamController<bool> searchBarStream =
|
||||
StreamController<bool>.broadcast();
|
||||
@ -33,7 +34,7 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
|
||||
super.onInit();
|
||||
userInfo = userInfoCache.get('userInfoCache');
|
||||
userLogin.value = userInfo != null;
|
||||
userFace.value = userInfo != null ? userInfo.face : '';
|
||||
userFace.value = userInfo != null ? userInfo!.face! : '';
|
||||
hideSearchBar =
|
||||
setting.get(SettingBoxKey.hideSearchBar, defaultValue: false);
|
||||
if (setting.get(SettingBoxKey.enableSearchWord, defaultValue: true)) {
|
||||
@ -62,7 +63,7 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
|
||||
userInfo = await userInfoCache.get('userInfoCache');
|
||||
userLogin.value = val ?? false;
|
||||
if (val) return;
|
||||
userFace.value = userInfo != null ? userInfo.face : '';
|
||||
userFace.value = userInfo != null ? userInfo!.face! : '';
|
||||
}
|
||||
|
||||
void setTabConfig() async {
|
||||
|
||||
@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
import 'package:pilipala/models/user/info.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
|
||||
Box userInfoCache = GStorage.userInfo;
|
||||
@ -12,7 +13,7 @@ class HomeAppBar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var userInfo = userInfoCache.get('userInfoCache');
|
||||
final UserInfoData? userInfo = userInfoCache.get('userInfoCache');
|
||||
return SliverAppBar(
|
||||
// forceElevated: true,
|
||||
scrolledUnderElevation: 0,
|
||||
|
||||
@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
import 'package:pilipala/http/common.dart';
|
||||
import 'package:pilipala/models/user/info.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
import '../../models/common/dynamic_badge_mode.dart';
|
||||
@ -26,7 +27,7 @@ class MainController extends GetxController {
|
||||
late PageController pageController;
|
||||
int selectedIndex = 0;
|
||||
Box userInfoCache = GStorage.userInfo;
|
||||
dynamic userInfo;
|
||||
UserInfoData? userInfo;
|
||||
RxBool userLogin = false.obs;
|
||||
late Rx<DynamicBadgeMode> dynamicBadgeType = DynamicBadgeMode.number.obs;
|
||||
late bool enableGradientBg;
|
||||
@ -85,7 +86,7 @@ class MainController extends GetxController {
|
||||
}
|
||||
if (mineItemIndex != -1 && userInfo != null) {
|
||||
Widget avatar = NetworkImgLayer(
|
||||
width: 28, height: 28, src: userInfo.face, type: 'avatar');
|
||||
width: 28, height: 28, src: userInfo!.face, type: 'avatar');
|
||||
navigationBars[mineItemIndex]['icon'] = avatar;
|
||||
navigationBars[mineItemIndex]['selectIcon'] = avatar;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ import 'package:pilipala/models/member/archive.dart';
|
||||
import 'package:pilipala/models/member/coin.dart';
|
||||
import 'package:pilipala/models/member/info.dart';
|
||||
import 'package:pilipala/models/member/like.dart';
|
||||
import 'package:pilipala/models/user/info.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
@ -22,7 +23,7 @@ class MemberController extends GetxController {
|
||||
late int ownerMid;
|
||||
// 投稿列表
|
||||
RxList<VListItemModel>? archiveList = <VListItemModel>[].obs;
|
||||
dynamic userInfo;
|
||||
UserInfoData? userInfo;
|
||||
RxInt attribute = (-1).obs;
|
||||
RxString attributeText = '关注'.obs;
|
||||
RxList<MemberCoinsDataModel> recentCoinsList = <MemberCoinsDataModel>[].obs;
|
||||
@ -34,7 +35,7 @@ class MemberController extends GetxController {
|
||||
super.onInit();
|
||||
mid = int.tryParse(Get.parameters['mid']!) ?? -2;
|
||||
userInfo = userInfoCache.get('userInfoCache');
|
||||
ownerMid = userInfo != null ? userInfo.mid : -1;
|
||||
ownerMid = userInfo != null ? userInfo!.mid! : -1;
|
||||
isOwner.value = mid == ownerMid;
|
||||
face.value = Get.arguments['face'] ?? '';
|
||||
heroTag = Get.arguments['heroTag'] ?? '';
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/http/member.dart';
|
||||
import 'package:pilipala/models/member/seasons.dart';
|
||||
import 'package:pilipala/utils/global_data_cache.dart';
|
||||
|
||||
class MemberSeasonsController extends GetxController {
|
||||
final ScrollController scrollController = ScrollController();
|
||||
@ -58,7 +59,7 @@ class MemberSeasonsController extends GetxController {
|
||||
mid: mid,
|
||||
seriesId: seriesId!,
|
||||
pn: pn,
|
||||
currentMid: 17340771,
|
||||
currentMid: GlobalDataCache.userInfo?.mid ?? -1,
|
||||
);
|
||||
if (res['status']) {
|
||||
seasonsList.addAll(res['data'].seriesList);
|
||||
|
||||
@ -2,6 +2,8 @@ import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/common/constants.dart';
|
||||
import 'package:pilipala/common/skeleton/video_card_h.dart';
|
||||
import 'package:pilipala/common/widgets/http_error.dart';
|
||||
import 'controller.dart';
|
||||
import 'widgets/item.dart';
|
||||
|
||||
@ -54,9 +56,9 @@ class _MemberSeasonsPageState extends State<MemberSeasonsPage> {
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
if (snapshot.data != null) {
|
||||
Map data = snapshot.data as Map;
|
||||
Map? data = snapshot.data;
|
||||
List list = _memberSeasonsController.seasonsList;
|
||||
if (data['status']) {
|
||||
if (data?['status']) {
|
||||
return Obx(
|
||||
() => list.isNotEmpty
|
||||
? LayoutBuilder(
|
||||
@ -82,16 +84,44 @@ class _MemberSeasonsPageState extends State<MemberSeasonsPage> {
|
||||
);
|
||||
},
|
||||
)
|
||||
: const SizedBox(),
|
||||
: const HttpError(
|
||||
errMsg: '没有数据',
|
||||
isInSliver: false,
|
||||
isShowBtn: false,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return const SizedBox();
|
||||
return HttpError(
|
||||
errMsg: snapshot.data['msg'],
|
||||
isInSliver: false,
|
||||
fn: () {
|
||||
setState(() {
|
||||
_futureBuilderFuture =
|
||||
_memberSeasonsController.onRefresh();
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return const SizedBox();
|
||||
return HttpError(
|
||||
errMsg: snapshot.data['msg'] ?? '请求异常',
|
||||
isInSliver: false,
|
||||
fn: () {
|
||||
setState(() {
|
||||
_futureBuilderFuture =
|
||||
_memberSeasonsController.onRefresh();
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return const SizedBox();
|
||||
return ListView.builder(
|
||||
itemCount: 10,
|
||||
shrinkWrap: true,
|
||||
itemBuilder: (context, index) {
|
||||
return const VideoCardHSkeleton();
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
@ -3,6 +3,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/http/user.dart';
|
||||
import 'package:pilipala/models/user/info.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
|
||||
class MineEditController extends GetxController {
|
||||
@ -13,7 +14,7 @@ class MineEditController extends GetxController {
|
||||
final TextEditingController signCtr = TextEditingController();
|
||||
final TextEditingController birthdayCtr = TextEditingController();
|
||||
String? sex;
|
||||
dynamic userInfo;
|
||||
UserInfoData? userInfo;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,8 +2,8 @@ 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/http/init.dart';
|
||||
import 'package:pilipala/models/common/theme_type.dart';
|
||||
import 'package:pilipala/models/user/info.dart';
|
||||
import 'package:pilipala/utils/feed_back.dart';
|
||||
import 'package:pilipala/utils/login.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
@ -22,7 +22,7 @@ class SettingController extends GetxController {
|
||||
RxDouble toastOpacity = (1.0).obs;
|
||||
RxInt picQuality = 10.obs;
|
||||
Rx<ThemeType> themeType = ThemeType.system.obs;
|
||||
var userInfo;
|
||||
UserInfoData? userInfo;
|
||||
Rx<DynamicBadgeMode> dynamicBadgeType = DynamicBadgeMode.number.obs;
|
||||
RxInt defaultHomePage = 0.obs;
|
||||
|
||||
|
||||
@ -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};
|
||||
|
||||
@ -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('操作成功');
|
||||
}
|
||||
|
||||
|
||||
@ -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('设置成功');
|
||||
|
||||
@ -155,7 +155,7 @@ class _PlaySettingState extends State<PlaySetting> {
|
||||
setKey: SettingBoxKey.enablePlayerControlAnimation,
|
||||
defaultVal: true,
|
||||
callFn: (bool val) {
|
||||
GlobalDataCache().enablePlayerControlAnimation = val;
|
||||
GlobalDataCache.enablePlayerControlAnimation = val;
|
||||
}),
|
||||
SetSwitchItem(
|
||||
title: '港澳台模式',
|
||||
|
||||
@ -3,6 +3,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/http/member.dart';
|
||||
import 'package:pilipala/models/user/info.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
|
||||
class PrivacySetting extends StatefulWidget {
|
||||
@ -15,7 +16,7 @@ class PrivacySetting extends StatefulWidget {
|
||||
class _PrivacySettingState extends State<PrivacySetting> {
|
||||
bool userLogin = false;
|
||||
Box userInfoCache = GStorage.userInfo;
|
||||
var userInfo;
|
||||
UserInfoData? userInfo;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
||||
@ -3,6 +3,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/http/member.dart';
|
||||
import 'package:pilipala/models/common/rcmd_type.dart';
|
||||
import 'package:pilipala/models/user/info.dart';
|
||||
import 'package:pilipala/pages/setting/widgets/select_dialog.dart';
|
||||
import 'package:pilipala/utils/recommend_filter.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
@ -21,7 +22,7 @@ class _RecommendSettingState extends State<RecommendSetting> {
|
||||
static Box localCache = GStorage.localCache;
|
||||
late dynamic defaultRcmdType;
|
||||
Box userInfoCache = GStorage.userInfo;
|
||||
late dynamic userInfo;
|
||||
UserInfoData? userInfo;
|
||||
bool userLogin = false;
|
||||
late dynamic accessKeyInfo;
|
||||
// late int filterUnfollowedRatio;
|
||||
|
||||
@ -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('确定'),
|
||||
|
||||
@ -14,12 +14,14 @@ import 'package:pilipala/models/common/reply_type.dart';
|
||||
import 'package:pilipala/models/common/search_type.dart';
|
||||
import 'package:pilipala/models/sponsor_block/segment.dart';
|
||||
import 'package:pilipala/models/sponsor_block/segment_type.dart';
|
||||
import 'package:pilipala/models/user/info.dart';
|
||||
import 'package:pilipala/models/video/later.dart';
|
||||
import 'package:pilipala/models/video/play/quality.dart';
|
||||
import 'package:pilipala/models/video/play/url.dart';
|
||||
import 'package:pilipala/models/video/reply/item.dart';
|
||||
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';
|
||||
@ -94,7 +96,7 @@ class VideoDetailController extends GetxController
|
||||
double? brightness;
|
||||
// 默认记录历史记录
|
||||
bool enableHeart = true;
|
||||
var userInfo;
|
||||
UserInfoData? userInfo;
|
||||
late bool isFirstTime = true;
|
||||
Floating? floating;
|
||||
late PreferredSizeWidget headerControl;
|
||||
@ -125,6 +127,8 @@ class VideoDetailController extends GetxController
|
||||
RxInt watchLaterCount = 0.obs;
|
||||
List<SegmentDataModel> skipSegments = <SegmentDataModel>[];
|
||||
int? lastPosition;
|
||||
// 默认屏幕方向
|
||||
RxString videoDirection = 'horizontal'.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@ -137,8 +141,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);
|
||||
@ -195,7 +207,7 @@ class VideoDetailController extends GetxController
|
||||
});
|
||||
|
||||
/// 仅投稿视频skip
|
||||
if (videoType == SearchType.video) {
|
||||
if (videoType == SearchType.video && GlobalDataCache.enableSponsorBlock) {
|
||||
querySkipSegments();
|
||||
}
|
||||
}
|
||||
@ -283,6 +295,10 @@ class VideoDetailController extends GetxController
|
||||
} else {
|
||||
ScreenBrightness().resetScreenBrightness();
|
||||
}
|
||||
videoDirection.value = (firstVideo.width != null &&
|
||||
firstVideo.height != null)
|
||||
? (firstVideo.width! > firstVideo.height! ? 'horizontal' : 'vertical')
|
||||
: 'horizontal';
|
||||
await plPlayerController.setDataSource(
|
||||
DataSource(
|
||||
videoSource: video ?? videoUrl,
|
||||
@ -299,11 +315,7 @@ class VideoDetailController extends GetxController
|
||||
seekTo: seekToTime ?? defaultST,
|
||||
duration: duration ?? Duration(milliseconds: data.timeLength ?? 0),
|
||||
// 宽>高 水平 否则 垂直
|
||||
direction: firstVideo.width != null && firstVideo.height != null
|
||||
? ((firstVideo.width! - firstVideo.height!) > 0
|
||||
? 'horizontal'
|
||||
: 'vertical')
|
||||
: null,
|
||||
direction: videoDirection.value,
|
||||
bvid: bvid,
|
||||
cid: cid.value,
|
||||
enableHeart: enableHeart,
|
||||
@ -477,6 +489,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);
|
||||
}
|
||||
|
||||
// 获取弹幕
|
||||
@ -615,7 +636,7 @@ class VideoDetailController extends GetxController
|
||||
var count = argMap['count'];
|
||||
var res = await UserHttp.getMediaList(
|
||||
type: 2,
|
||||
bizId: userInfo.mid,
|
||||
bizId: userInfo!.mid!,
|
||||
ps: count,
|
||||
);
|
||||
if (res['status']) {
|
||||
|
||||
@ -9,6 +9,7 @@ import 'package:pilipala/http/constants.dart';
|
||||
import 'package:pilipala/http/user.dart';
|
||||
import 'package:pilipala/http/video.dart';
|
||||
import 'package:pilipala/models/user/fav_folder.dart';
|
||||
import 'package:pilipala/models/user/info.dart';
|
||||
import 'package:pilipala/models/video/ai.dart';
|
||||
import 'package:pilipala/models/video/tags.dart';
|
||||
import 'package:pilipala/models/video_detail_res.dart';
|
||||
@ -16,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';
|
||||
@ -49,10 +51,8 @@ class VideoIntroController extends GetxController {
|
||||
List delMediaIdsNew = [];
|
||||
// 关注状态 默认未关注
|
||||
RxMap followStatus = {}.obs;
|
||||
int _tempThemeValue = -1;
|
||||
|
||||
RxInt lastPlayCid = 0.obs;
|
||||
var userInfo;
|
||||
UserInfoData? userInfo;
|
||||
RxList<VideoTagItem> videoTags = <VideoTagItem>[].obs;
|
||||
|
||||
// 同时观看
|
||||
@ -100,7 +100,11 @@ class VideoIntroController extends GetxController {
|
||||
}
|
||||
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();
|
||||
@ -301,7 +305,7 @@ class VideoIntroController extends GetxController {
|
||||
|
||||
Future queryVideoInFolder() async {
|
||||
var result = await VideoHttp.videoInFolder(
|
||||
mid: userInfo.mid, rid: IdUtils.bv2av(bvid));
|
||||
mid: userInfo!.mid!, rid: IdUtils.bv2av(bvid));
|
||||
if (result['status']) {
|
||||
favFolderData.value = result['data'];
|
||||
}
|
||||
@ -470,10 +474,12 @@ class VideoIntroController extends GetxController {
|
||||
// 重新请求评论
|
||||
try {
|
||||
/// 未渲染回复组件时可能异常
|
||||
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);
|
||||
|
||||
@ -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';
|
||||
@ -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(
|
||||
|
||||
@ -52,7 +52,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 +415,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,
|
||||
|
||||
@ -89,10 +89,13 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
return AppBar(
|
||||
toolbarHeight: 45,
|
||||
automaticallyImplyLeading: false,
|
||||
title: Text(
|
||||
title: Padding(
|
||||
padding: const EdgeInsets.only(left: 14),
|
||||
child: Text(
|
||||
'评论详情',
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close, size: 20),
|
||||
@ -102,7 +105,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
const SizedBox(width: 12),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -123,14 +124,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
// 流
|
||||
appbarStreamListen() {
|
||||
appbarStream = StreamController<double>.broadcast();
|
||||
_extendNestCtr.addListener(
|
||||
() {
|
||||
final double offset = _extendNestCtr.position.pixels;
|
||||
vdCtr.sheetHeight.value =
|
||||
Get.size.height - videoHeight - statusBarHeight + offset;
|
||||
appbarStream.add(offset);
|
||||
},
|
||||
);
|
||||
_extendNestCtr.addListener(_extendNestCtrListener);
|
||||
}
|
||||
|
||||
// 播放器状态监听
|
||||
@ -225,6 +219,20 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
statusHeight = await StatusBarControl.getHeight;
|
||||
}
|
||||
|
||||
// _extendNestCtr监听
|
||||
void _extendNestCtrListener() {
|
||||
final double offset = _extendNestCtr.position.pixels;
|
||||
if (vdCtr.videoDirection.value == 'horizontal') {
|
||||
vdCtr.sheetHeight.value =
|
||||
Get.size.height - videoHeight - statusBarHeight + offset;
|
||||
appbarStream.add(offset);
|
||||
} else {
|
||||
if (offset > (Get.size.width * 22 / 16 - videoHeight)) {
|
||||
appbarStream.add(offset - (Get.size.width * 22 / 16 - videoHeight));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
shutdownTimerService.handleWaitingFinished();
|
||||
@ -243,6 +251,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
appbarStream.close();
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
_lifecycleListener.dispose();
|
||||
_extendNestCtr.removeListener(_extendNestCtrListener);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@ -494,11 +503,18 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
Widget build(BuildContext context) {
|
||||
final sizeContext = MediaQuery.sizeOf(context);
|
||||
final _context = MediaQuery.of(context);
|
||||
late double defaultVideoHeight = sizeContext.width * 9 / 16;
|
||||
late final double verticalHeight = sizeContext.width * 22 / 16;
|
||||
late double defaultVideoHeight = vdCtr.videoDirection.value == 'vertical'
|
||||
? verticalHeight
|
||||
: sizeContext.width * 9 / 16;
|
||||
late RxDouble videoHeight = defaultVideoHeight.obs;
|
||||
final double pinnedHeaderHeight =
|
||||
statusBarHeight + kToolbarHeight + videoHeight.value;
|
||||
// ignore: no_leading_underscores_for_local_identifiers
|
||||
vdCtr.videoDirection.listen((p0) {
|
||||
if (p0 == 'vertical') {
|
||||
videoHeight.value = defaultVideoHeight = verticalHeight;
|
||||
}
|
||||
});
|
||||
|
||||
// 竖屏
|
||||
final bool isPortrait = _context.orientation == Orientation.portrait;
|
||||
@ -541,10 +557,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
showEposideCb: () => vdCtr.videoType == SearchType.video
|
||||
? videoIntroController.showEposideHandler()
|
||||
: bangumiIntroController.showEposideHandler(),
|
||||
fullScreenCb: (bool status) {
|
||||
videoHeight.value =
|
||||
status ? Get.size.height : defaultVideoHeight;
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
@ -594,6 +606,28 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildAppBar(BuildContext context, AsyncSnapshot<num> snapshot) {
|
||||
final double distance =
|
||||
statusBarHeight + MediaQuery.of(context).padding.top;
|
||||
return AppBar(
|
||||
backgroundColor: Colors.black,
|
||||
systemOverlayStyle: Platform.isAndroid
|
||||
? SystemUiOverlayStyle(
|
||||
statusBarIconBrightness:
|
||||
Theme.of(context).brightness == Brightness.dark
|
||||
? Brightness.light
|
||||
: (snapshot.data! > distance
|
||||
? Brightness.dark
|
||||
: Brightness.light),
|
||||
)
|
||||
: Theme.of(context).brightness == Brightness.dark
|
||||
? SystemUiOverlayStyle.light
|
||||
: (snapshot.data! > distance
|
||||
? SystemUiOverlayStyle.dark
|
||||
: SystemUiOverlayStyle.light),
|
||||
);
|
||||
}
|
||||
|
||||
Widget childWhenDisabled = SafeArea(
|
||||
top: MediaQuery.of(context).orientation == Orientation.portrait &&
|
||||
plPlayerController?.isFullScreen.value == true,
|
||||
@ -611,11 +645,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
child: StreamBuilder(
|
||||
stream: appbarStream.stream.distinct(),
|
||||
initialData: 0,
|
||||
builder: ((context, snapshot) {
|
||||
return AppBar(
|
||||
backgroundColor: Colors.black,
|
||||
);
|
||||
}),
|
||||
builder: buildAppBar,
|
||||
),
|
||||
),
|
||||
body: ExtendedNestedScrollView(
|
||||
@ -750,6 +780,12 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
);
|
||||
},
|
||||
),
|
||||
if ((vdCtr.videoType == SearchType.media_bangumi &&
|
||||
GlobalDataCache.enableComment
|
||||
.contains('bangumi')) ||
|
||||
(vdCtr.videoType == SearchType.video &&
|
||||
GlobalDataCache.enableComment
|
||||
.contains('video'))) ...[
|
||||
Obx(
|
||||
() => VideoReplyPanel(
|
||||
bvid: vdCtr.bvid,
|
||||
@ -758,6 +794,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -773,7 +810,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
builder: ((context, snapshot) {
|
||||
return ScrollAppBar(
|
||||
snapshot.data!.toDouble(),
|
||||
() => continuePlay(),
|
||||
continuePlay,
|
||||
playerStatus.value,
|
||||
null,
|
||||
);
|
||||
@ -880,6 +917,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),
|
||||
|
||||
@ -18,7 +18,7 @@ class AiDetail extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.only(left: 16, right: 16),
|
||||
height: GlobalDataCache().sheetHeight,
|
||||
height: GlobalDataCache.sheetHeight,
|
||||
child: Column(
|
||||
children: [
|
||||
_buildHeader(context),
|
||||
|
||||
@ -34,21 +34,16 @@ class ScrollAppBar extends StatelessWidget {
|
||||
child: AppBar(
|
||||
primary: false,
|
||||
centerTitle: true,
|
||||
title: TextButton(
|
||||
title: TextButton.icon(
|
||||
onPressed: () => callback(),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(Icons.play_arrow_rounded),
|
||||
Text(
|
||||
label: Text(
|
||||
playerStatus == PlayerStatus.paused
|
||||
? '继续播放'
|
||||
: playerStatus == PlayerStatus.completed
|
||||
? '重新播放'
|
||||
: '播放中',
|
||||
)
|
||||
],
|
||||
),
|
||||
icon: const Icon(Icons.play_arrow_rounded),
|
||||
),
|
||||
// actions: [
|
||||
// IconButton(
|
||||
|
||||
@ -16,6 +16,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 +31,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 +39,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();
|
||||
@ -1237,6 +1238,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
||||
// ),
|
||||
// fuc: () => _.screenshot(),
|
||||
// ),
|
||||
if (GlobalDataCache.enableDlna) ...[
|
||||
ComBtn(
|
||||
icon: const Icon(
|
||||
Icons.cast,
|
||||
@ -1253,6 +1255,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
if (isFullScreen.value) ...[
|
||||
SizedBox(
|
||||
width: 56,
|
||||
@ -1326,7 +1329,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
||||
],
|
||||
|
||||
/// 字幕
|
||||
if (widget.showSubtitleBtn ?? true)
|
||||
if (widget.showSubtitleBtn)
|
||||
ComBtn(
|
||||
icon: const Icon(
|
||||
Icons.closed_caption_off,
|
||||
|
||||
@ -6,6 +6,7 @@ import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/http/msg.dart';
|
||||
import 'package:pilipala/models/msg/session.dart';
|
||||
import 'package:pilipala/models/user/info.dart';
|
||||
import 'package:pilipala/pages/whisper/index.dart';
|
||||
import '../../utils/feed_back.dart';
|
||||
import '../../utils/storage.dart';
|
||||
@ -80,7 +81,7 @@ class WhisperDetailController extends GetxController {
|
||||
Future sendMsg() async {
|
||||
feedBack();
|
||||
String message = replyContentController.text;
|
||||
final userInfo = userInfoCache.get('userInfoCache');
|
||||
final UserInfoData? userInfo = userInfoCache.get('userInfoCache');
|
||||
if (userInfo == null) {
|
||||
SmartDialog.showToast('请先登录');
|
||||
return;
|
||||
@ -90,7 +91,7 @@ class WhisperDetailController extends GetxController {
|
||||
return;
|
||||
}
|
||||
var result = await MsgHttp.sendMsg(
|
||||
senderUid: userInfo.mid,
|
||||
senderUid: userInfo.mid!,
|
||||
receiverId: int.parse(mid),
|
||||
content: {'content': message},
|
||||
msgType: 1,
|
||||
|
||||
@ -2,14 +2,12 @@ import 'dart:async';
|
||||
import 'dart:math';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
import 'package:pilipala/models/video/reply/emote.dart';
|
||||
import 'package:pilipala/pages/emote/index.dart';
|
||||
import 'package:pilipala/pages/video/detail/reply_new/toolbar_icon_button.dart';
|
||||
import 'package:pilipala/pages/whisper_detail/controller.dart';
|
||||
import 'package:pilipala/utils/feed_back.dart';
|
||||
import '../../utils/storage.dart';
|
||||
import 'widget/chat_item.dart';
|
||||
|
||||
class WhisperDetailPage extends StatefulWidget {
|
||||
@ -30,7 +28,6 @@ class _WhisperDetailPageState extends State<WhisperDetailPage>
|
||||
late double emoteHeight = 230.0;
|
||||
double keyboardHeight = 0.0; // 键盘高度
|
||||
RxString toolbarType = ''.obs;
|
||||
Box userInfoCache = GStorage.userInfo;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
||||
@ -278,19 +278,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();
|
||||
@ -929,6 +928,11 @@ class PlPlayerController {
|
||||
showControls.value = !val;
|
||||
}
|
||||
|
||||
/// 设置/更新顶部控制栏
|
||||
void setHeaderControl(PreferredSizeWidget? widget) {
|
||||
headerControl = widget;
|
||||
}
|
||||
|
||||
void toggleFullScreen(bool val) {
|
||||
_isFullScreen.value = val;
|
||||
}
|
||||
@ -1047,13 +1051,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);
|
||||
|
||||
@ -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),
|
||||
);
|
||||
|
||||
@ -5,54 +5,60 @@ 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;
|
||||
// sponsorBlock开关
|
||||
static bool enableSponsorBlock = false;
|
||||
// 视频评论开关
|
||||
static List<String> enableComment = ['video', 'bangumi'];
|
||||
|
||||
// 私有构造函数
|
||||
GlobalDataCache._();
|
||||
@ -64,19 +70,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 +103,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 +121,17 @@ 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);
|
||||
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']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,7 +115,10 @@ class SettingBoxKey {
|
||||
enableAi = 'enableAi',
|
||||
enableAutoExpand = 'enableAutoExpand',
|
||||
defaultHomePage = 'defaultHomePage',
|
||||
enableRelatedVideo = 'enableRelatedVideo';
|
||||
enableRelatedVideo = 'enableRelatedVideo',
|
||||
enableDlna = 'enableDlna',
|
||||
enableSponsorBlock = 'enableSponsorBlock',
|
||||
enableComment = 'enableComment';
|
||||
|
||||
/// 外观
|
||||
static const String themeMode = 'themeMode',
|
||||
|
||||
Reference in New Issue
Block a user