mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-05 17:47:46 +08:00
refa: danmaku & feat: scroll fixed velocity (#1791)
This commit is contained in:
committed by
GitHub
parent
0a40d11133
commit
49b7ea14c3
28
lib/utils/extension/box_ext.dart
Normal file
28
lib/utils/extension/box_ext.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
extension BoxExt<E> on Box<E> {
|
||||
bool equal(dynamic key, E value) {
|
||||
return const DeepCollectionEquality().equals(value, get(key));
|
||||
}
|
||||
|
||||
Future<void>? putNE(dynamic key, E value) {
|
||||
if (!equal(key, value)) {
|
||||
return put(key, value);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<void>? putAllNE(Map<dynamic, E> entries) {
|
||||
final Map<dynamic, E> newEntries = {};
|
||||
entries.forEach((key, value) {
|
||||
if (!equal(key, value)) {
|
||||
newEntries[key] = value;
|
||||
}
|
||||
});
|
||||
if (newEntries.isNotEmpty) {
|
||||
return putAll(newEntries);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ extension IntExt on int? {
|
||||
|
||||
extension DoubleExt on double {
|
||||
double toPrecision(int fractionDigits) {
|
||||
final mod = pow(10, fractionDigits.toDouble()).toDouble();
|
||||
return ((this * mod).round().toDouble() / mod);
|
||||
final mod = pow(10, fractionDigits).toDouble();
|
||||
return (this * mod).roundToDouble() / mod;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -643,16 +643,16 @@ abstract final class PageUtils {
|
||||
}
|
||||
}
|
||||
|
||||
static void showVideoBottomSheet(
|
||||
static Future<void>? showVideoBottomSheet(
|
||||
BuildContext context, {
|
||||
required Widget child,
|
||||
required ValueGetter<bool> isFullScreen,
|
||||
double? padding,
|
||||
}) {
|
||||
if (!context.mounted) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
Get.key.currentState!.push(
|
||||
return Get.key.currentState!.push(
|
||||
PublishRoute(
|
||||
pageBuilder: (context, animation, secondaryAnimation) {
|
||||
if (context.isPortrait) {
|
||||
|
||||
@@ -191,6 +191,7 @@ abstract final class SettingBoxKey {
|
||||
danmakuDuration = 'danmakuDuration',
|
||||
danmakuStaticDuration = 'danmakuStaticDuration',
|
||||
danmakuMassiveMode = 'danmakuMassiveMode',
|
||||
danmakuFixedV = 'danmakuFixedV',
|
||||
danmakuLineHeight = 'danmakuLineHeight',
|
||||
strokeWidth = 'strokeWidth',
|
||||
fontWeight = 'fontWeight';
|
||||
|
||||
@@ -319,6 +319,9 @@ abstract final class Pref {
|
||||
static bool get danmakuMassiveMode =>
|
||||
_setting.get(SettingBoxKey.danmakuMassiveMode, defaultValue: false);
|
||||
|
||||
static bool get danmakuFixedV =>
|
||||
_setting.get(SettingBoxKey.danmakuFixedV, defaultValue: false);
|
||||
|
||||
static double get subtitleFontScale =>
|
||||
_setting.get(SettingBoxKey.subtitleFontScale, defaultValue: 1.0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user