mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
Merge remote-tracking branch 'upstream/main'
This commit is contained in:
@@ -241,10 +241,11 @@ class VideoHttp {
|
|||||||
// 获取投币状态
|
// 获取投币状态
|
||||||
static Future hasCoinVideo({required String bvid}) async {
|
static Future hasCoinVideo({required String bvid}) async {
|
||||||
var res = await Request().get(Api.hasCoinVideo, data: {'bvid': bvid});
|
var res = await Request().get(Api.hasCoinVideo, data: {'bvid': bvid});
|
||||||
|
print('res: $res');
|
||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
return {'status': true, 'data': res.data['data']};
|
return {'status': true, 'data': res.data['data']};
|
||||||
} else {
|
} else {
|
||||||
return {'status': true, 'data': []};
|
return {'status': false, 'data': []};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,7 +379,7 @@ class VideoHttp {
|
|||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
return {'status': true, 'data': res.data['data']};
|
return {'status': true, 'data': res.data['data']};
|
||||||
} else {
|
} else {
|
||||||
return {'status': true, 'data': []};
|
return {'status': false, 'data': []};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -394,7 +395,7 @@ class VideoHttp {
|
|||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
return {'status': true, 'data': res.data['data']};
|
return {'status': true, 'data': res.data['data']};
|
||||||
} else {
|
} else {
|
||||||
return {'status': true, 'data': []};
|
return {'status': false, 'data': []};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,10 +473,7 @@ class VideoHttp {
|
|||||||
'data': AiConclusionModel.fromJson(res.data['data']),
|
'data': AiConclusionModel.fromJson(res.data['data']),
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {'status': false, 'data': []};
|
||||||
'status': false,
|
|
||||||
'data': []
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
9
lib/models/common/dynamic_badge_mode.dart
Normal file
9
lib/models/common/dynamic_badge_mode.dart
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
enum DynamicBadgeMode { hidden, point, number }
|
||||||
|
|
||||||
|
extension DynamicBadgeModeDesc on DynamicBadgeMode {
|
||||||
|
String get description => ['隐藏', '红点', '数字'][index];
|
||||||
|
}
|
||||||
|
|
||||||
|
extension DynamicBadgeModeCode on DynamicBadgeMode {
|
||||||
|
int get code => [0, 1, 2][index];
|
||||||
|
}
|
||||||
@@ -17,8 +17,9 @@ class LatestDataModel {
|
|||||||
url = json['url'];
|
url = json['url'];
|
||||||
tagName = json['tag_name'];
|
tagName = json['tag_name'];
|
||||||
createdAt = json['created_at'];
|
createdAt = json['created_at'];
|
||||||
assets =
|
assets = json['assets'] != null
|
||||||
json['assets'].map<AssetItem>((e) => AssetItem.fromJson(e)).toList();
|
? json['assets'].map<AssetItem>((e) => AssetItem.fromJson(e)).toList()
|
||||||
|
: [];
|
||||||
body = json['body'];
|
body = json['body'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import 'package:pilipala/pages/home/view.dart';
|
|||||||
import 'package:pilipala/pages/media/index.dart';
|
import 'package:pilipala/pages/media/index.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
import 'package:pilipala/utils/utils.dart';
|
import 'package:pilipala/utils/utils.dart';
|
||||||
|
import '../../models/common/dynamic_badge_mode.dart';
|
||||||
|
|
||||||
class MainController extends GetxController {
|
class MainController extends GetxController {
|
||||||
List<Widget> pages = <Widget>[
|
List<Widget> pages = <Widget>[
|
||||||
@@ -65,6 +66,7 @@ class MainController extends GetxController {
|
|||||||
int selectedIndex = 0;
|
int selectedIndex = 0;
|
||||||
Box userInfoCache = GStrorage.userInfo;
|
Box userInfoCache = GStrorage.userInfo;
|
||||||
RxBool userLogin = false.obs;
|
RxBool userLogin = false.obs;
|
||||||
|
late Rx<DynamicBadgeMode> dynamicBadgeType = DynamicBadgeMode.number.obs;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@@ -75,8 +77,13 @@ class MainController extends GetxController {
|
|||||||
hideTabBar = setting.get(SettingBoxKey.hideTabBar, defaultValue: true);
|
hideTabBar = setting.get(SettingBoxKey.hideTabBar, defaultValue: true);
|
||||||
var userInfo = userInfoCache.get('userInfoCache');
|
var userInfo = userInfoCache.get('userInfoCache');
|
||||||
userLogin.value = userInfo != null;
|
userLogin.value = userInfo != null;
|
||||||
|
dynamicBadgeType.value = DynamicBadgeMode.values[setting.get(
|
||||||
|
SettingBoxKey.dynamicBadgeMode,
|
||||||
|
defaultValue: DynamicBadgeMode.number.code)];
|
||||||
|
if (dynamicBadgeType.value != DynamicBadgeMode.hidden) {
|
||||||
getUnreadDynamic();
|
getUnreadDynamic();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void onBackPressed(BuildContext context) {
|
void onBackPressed(BuildContext context) {
|
||||||
if (_lastPressedAt == null ||
|
if (_lastPressedAt == null ||
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'dart:async';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
|
import 'package:pilipala/models/common/dynamic_badge_mode.dart';
|
||||||
import 'package:pilipala/pages/dynamics/index.dart';
|
import 'package:pilipala/pages/dynamics/index.dart';
|
||||||
import 'package:pilipala/pages/home/index.dart';
|
import 'package:pilipala/pages/home/index.dart';
|
||||||
import 'package:pilipala/pages/media/index.dart';
|
import 'package:pilipala/pages/media/index.dart';
|
||||||
@@ -127,17 +128,22 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|||||||
destinations: <Widget>[
|
destinations: <Widget>[
|
||||||
..._mainController.navigationBars.map((e) {
|
..._mainController.navigationBars.map((e) {
|
||||||
return NavigationDestination(
|
return NavigationDestination(
|
||||||
icon: Badge(
|
icon: Obx(
|
||||||
backgroundColor:
|
() => Badge(
|
||||||
Theme.of(context).colorScheme.primary,
|
label:
|
||||||
textColor: Theme.of(context)
|
_mainController.dynamicBadgeType.value ==
|
||||||
.colorScheme
|
DynamicBadgeMode.number
|
||||||
.onInverseSurface,
|
? Text(e['count'].toString())
|
||||||
label: Text(e['count'].toString()),
|
: null,
|
||||||
padding: const EdgeInsets.fromLTRB(6, 0, 6, 0),
|
padding:
|
||||||
isLabelVisible: e['count'] > 0,
|
const EdgeInsets.fromLTRB(6, 0, 6, 0),
|
||||||
|
isLabelVisible:
|
||||||
|
_mainController.dynamicBadgeType.value !=
|
||||||
|
DynamicBadgeMode.hidden &&
|
||||||
|
e['count'] > 0,
|
||||||
child: e['icon'],
|
child: e['icon'],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
selectedIcon: e['selectIcon'],
|
selectedIcon: e['selectIcon'],
|
||||||
label: e['label'],
|
label: e['label'],
|
||||||
);
|
);
|
||||||
@@ -153,17 +159,22 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|||||||
items: [
|
items: [
|
||||||
..._mainController.navigationBars.map((e) {
|
..._mainController.navigationBars.map((e) {
|
||||||
return BottomNavigationBarItem(
|
return BottomNavigationBarItem(
|
||||||
icon: Badge(
|
icon: Obx(
|
||||||
backgroundColor:
|
() => Badge(
|
||||||
Theme.of(context).colorScheme.primary,
|
label:
|
||||||
textColor: Theme.of(context)
|
_mainController.dynamicBadgeType.value ==
|
||||||
.colorScheme
|
DynamicBadgeMode.number
|
||||||
.onInverseSurface,
|
? Text(e['count'].toString())
|
||||||
label: Text(e['count'].toString()),
|
: null,
|
||||||
padding: const EdgeInsets.fromLTRB(6, 0, 6, 0),
|
padding:
|
||||||
isLabelVisible: e['count'] > 0,
|
const EdgeInsets.fromLTRB(6, 0, 6, 0),
|
||||||
|
isLabelVisible:
|
||||||
|
_mainController.dynamicBadgeType.value !=
|
||||||
|
DynamicBadgeMode.hidden &&
|
||||||
|
e['count'] > 0,
|
||||||
child: e['icon'],
|
child: e['icon'],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
activeIcon: e['selectIcon'],
|
activeIcon: e['selectIcon'],
|
||||||
label: e['label'],
|
label: e['label'],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import 'package:pilipala/models/common/theme_type.dart';
|
|||||||
import 'package:pilipala/utils/feed_back.dart';
|
import 'package:pilipala/utils/feed_back.dart';
|
||||||
import 'package:pilipala/utils/login.dart';
|
import 'package:pilipala/utils/login.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
|
import '../../models/common/dynamic_badge_mode.dart';
|
||||||
|
import '../main/index.dart';
|
||||||
|
import 'widgets/select_dialog.dart';
|
||||||
|
|
||||||
class SettingController extends GetxController {
|
class SettingController extends GetxController {
|
||||||
Box userInfoCache = GStrorage.userInfo;
|
Box userInfoCache = GStrorage.userInfo;
|
||||||
@@ -19,6 +22,7 @@ class SettingController extends GetxController {
|
|||||||
RxInt picQuality = 10.obs;
|
RxInt picQuality = 10.obs;
|
||||||
Rx<ThemeType> themeType = ThemeType.system.obs;
|
Rx<ThemeType> themeType = ThemeType.system.obs;
|
||||||
var userInfo;
|
var userInfo;
|
||||||
|
Rx<DynamicBadgeMode> dynamicBadgeType = DynamicBadgeMode.number.obs;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@@ -33,6 +37,9 @@ class SettingController extends GetxController {
|
|||||||
setting.get(SettingBoxKey.defaultPicQa, defaultValue: 10);
|
setting.get(SettingBoxKey.defaultPicQa, defaultValue: 10);
|
||||||
themeType.value = ThemeType.values[setting.get(SettingBoxKey.themeMode,
|
themeType.value = ThemeType.values[setting.get(SettingBoxKey.themeMode,
|
||||||
defaultValue: ThemeType.system.code)];
|
defaultValue: ThemeType.system.code)];
|
||||||
|
dynamicBadgeType.value = DynamicBadgeMode.values[setting.get(
|
||||||
|
SettingBoxKey.dynamicBadgeMode,
|
||||||
|
defaultValue: DynamicBadgeMode.number.code)];
|
||||||
}
|
}
|
||||||
|
|
||||||
loginOut() async {
|
loginOut() async {
|
||||||
@@ -76,4 +83,31 @@ class SettingController extends GetxController {
|
|||||||
feedBackEnable.value = !feedBackEnable.value;
|
feedBackEnable.value = !feedBackEnable.value;
|
||||||
setting.put(SettingBoxKey.feedBackEnable, feedBackEnable.value);
|
setting.put(SettingBoxKey.feedBackEnable, feedBackEnable.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置动态未读标记
|
||||||
|
setDynamicBadgeMode(BuildContext context) async {
|
||||||
|
DynamicBadgeMode? result = await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return SelectDialog<DynamicBadgeMode>(
|
||||||
|
title: '动态未读标记',
|
||||||
|
value: dynamicBadgeType.value,
|
||||||
|
values: DynamicBadgeMode.values.map((e) {
|
||||||
|
return {'title': e.description, 'value': e};
|
||||||
|
}).toList(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (result != null) {
|
||||||
|
dynamicBadgeType.value = result;
|
||||||
|
setting.put(SettingBoxKey.dynamicBadgeMode, result.code);
|
||||||
|
MainController mainController = Get.put(MainController());
|
||||||
|
mainController.dynamicBadgeType.value =
|
||||||
|
DynamicBadgeMode.values[result.code];
|
||||||
|
if (mainController.dynamicBadgeType.value != DynamicBadgeMode.hidden) {
|
||||||
|
mainController.getUnreadDynamic();
|
||||||
|
}
|
||||||
|
SmartDialog.showToast('设置成功');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import 'package:pilipala/pages/setting/widgets/select_dialog.dart';
|
|||||||
import 'package:pilipala/pages/setting/widgets/slide_dialog.dart';
|
import 'package:pilipala/pages/setting/widgets/slide_dialog.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
|
|
||||||
|
import '../../models/common/dynamic_badge_mode.dart';
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
import 'widgets/switch_item.dart';
|
import 'widgets/switch_item.dart';
|
||||||
|
|
||||||
@@ -244,6 +245,14 @@ class _StyleSettingState extends State<StyleSetting> {
|
|||||||
'当前模式:${settingController.themeType.value.description}',
|
'当前模式:${settingController.themeType.value.description}',
|
||||||
style: subTitleStyle)),
|
style: subTitleStyle)),
|
||||||
),
|
),
|
||||||
|
ListTile(
|
||||||
|
dense: false,
|
||||||
|
onTap: () => settingController.setDynamicBadgeMode(context),
|
||||||
|
title: Text('动态未读标记', style: titleStyle),
|
||||||
|
subtitle: Obx(() => Text(
|
||||||
|
'当前标记样式:${settingController.dynamicBadgeType.value.description}',
|
||||||
|
style: subTitleStyle)),
|
||||||
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
dense: false,
|
dense: false,
|
||||||
onTap: () => Get.toNamed('/colorSetting'),
|
onTap: () => Get.toNamed('/colorSetting'),
|
||||||
|
|||||||
@@ -148,8 +148,10 @@ class VideoIntroController extends GetxController {
|
|||||||
// 获取投币状态
|
// 获取投币状态
|
||||||
Future queryHasCoinVideo() async {
|
Future queryHasCoinVideo() async {
|
||||||
var result = await VideoHttp.hasCoinVideo(bvid: bvid);
|
var result = await VideoHttp.hasCoinVideo(bvid: bvid);
|
||||||
|
if (result['status']) {
|
||||||
hasCoin.value = result["data"]['multiply'] == 0 ? false : true;
|
hasCoin.value = result["data"]['multiply'] == 0 ? false : true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 获取收藏状态
|
// 获取收藏状态
|
||||||
Future queryHasFavVideo() async {
|
Future queryHasFavVideo() async {
|
||||||
@@ -208,6 +210,10 @@ class VideoIntroController extends GetxController {
|
|||||||
|
|
||||||
// (取消)点赞
|
// (取消)点赞
|
||||||
Future actionLikeVideo() async {
|
Future actionLikeVideo() async {
|
||||||
|
if (userInfo == null) {
|
||||||
|
SmartDialog.showToast('账号未登录');
|
||||||
|
return;
|
||||||
|
}
|
||||||
var result = await VideoHttp.likeVideo(bvid: bvid, type: !hasLike.value);
|
var result = await VideoHttp.likeVideo(bvid: bvid, type: !hasLike.value);
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
// hasLike.value = result["data"] == 1 ? true : false;
|
// hasLike.value = result["data"] == 1 ? true : false;
|
||||||
|
|||||||
@@ -147,8 +147,8 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler {
|
|||||||
processingState: AudioProcessingState.idle,
|
processingState: AudioProcessingState.idle,
|
||||||
playing: false,
|
playing: false,
|
||||||
));
|
));
|
||||||
_item.removeLast();
|
|
||||||
if (_item.isNotEmpty) {
|
if (_item.isNotEmpty) {
|
||||||
|
_item.removeLast();
|
||||||
setMediaItem(_item.last);
|
setMediaItem(_item.last);
|
||||||
}
|
}
|
||||||
if (_item.isEmpty) {
|
if (_item.isEmpty) {
|
||||||
|
|||||||
@@ -139,7 +139,8 @@ class SettingBoxKey {
|
|||||||
enableMYBar = 'enableMYBar',
|
enableMYBar = 'enableMYBar',
|
||||||
hideSearchBar = 'hideSearchBar', // 收起顶栏
|
hideSearchBar = 'hideSearchBar', // 收起顶栏
|
||||||
hideTabBar = 'hideTabBar', // 收起底栏
|
hideTabBar = 'hideTabBar', // 收起底栏
|
||||||
tabbarSort = 'tabbarSort'; // 首页tabbar
|
tabbarSort = 'tabbarSort', // 首页tabbar
|
||||||
|
dynamicBadgeMode = 'dynamicBadgeMode';
|
||||||
}
|
}
|
||||||
|
|
||||||
class LocalCacheKey {
|
class LocalCacheKey {
|
||||||
|
|||||||
@@ -301,6 +301,7 @@ class Utils {
|
|||||||
// [arm64-v8a]
|
// [arm64-v8a]
|
||||||
String abi = androidInfo.supportedAbis.first;
|
String abi = androidInfo.supportedAbis.first;
|
||||||
late String downloadUrl;
|
late String downloadUrl;
|
||||||
|
if (data.assets.isNotEmpty) {
|
||||||
for (var i in data.assets) {
|
for (var i in data.assets) {
|
||||||
if (i.downloadUrl.contains(abi)) {
|
if (i.downloadUrl.contains(abi)) {
|
||||||
downloadUrl = i.downloadUrl;
|
downloadUrl = i.downloadUrl;
|
||||||
@@ -313,6 +314,7 @@ class Utils {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 时间戳转时间
|
// 时间戳转时间
|
||||||
static tampToSeektime(number) {
|
static tampToSeektime(number) {
|
||||||
|
|||||||
@@ -500,10 +500,11 @@ packages:
|
|||||||
floating:
|
floating:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: floating
|
path: "."
|
||||||
sha256: d9d563089e34fbd714ffdcdd2df447ec41b40c9226dacae6b4f78847aef8b991
|
ref: main
|
||||||
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
resolved-ref: d2d8421c4d80f6113f832404109853684721e11a
|
||||||
source: hosted
|
url: "https://github.com/guozhigq/floating.git"
|
||||||
|
source: git
|
||||||
version: "2.0.1"
|
version: "2.0.1"
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
|
|||||||
@@ -124,7 +124,10 @@ dependencies:
|
|||||||
# 代理
|
# 代理
|
||||||
system_proxy: ^0.1.0
|
system_proxy: ^0.1.0
|
||||||
# pip
|
# pip
|
||||||
floating: ^2.0.1
|
floating:
|
||||||
|
git:
|
||||||
|
url: https://github.com/guozhigq/floating.git
|
||||||
|
ref: main
|
||||||
# html解析
|
# html解析
|
||||||
html: ^0.15.4
|
html: ^0.15.4
|
||||||
# html渲染
|
# html渲染
|
||||||
|
|||||||
Reference in New Issue
Block a user