mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: video tabbarview
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,32 +1,54 @@
|
|||||||
import 'package:PiliPlus/utils/storage.dart';
|
import 'package:PiliPlus/utils/storage.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
Widget videoTabBarView({
|
||||||
|
required List<Widget> children,
|
||||||
|
TabController? controller,
|
||||||
|
}) =>
|
||||||
|
TabBarView(
|
||||||
|
physics: const CustomTabBarViewClampingScrollPhysics(),
|
||||||
|
controller: controller,
|
||||||
|
children: children,
|
||||||
|
);
|
||||||
|
|
||||||
Widget tabBarView({
|
Widget tabBarView({
|
||||||
required List<Widget> children,
|
required List<Widget> children,
|
||||||
TabController? controller,
|
TabController? controller,
|
||||||
}) =>
|
}) =>
|
||||||
TabBarView(
|
TabBarView(
|
||||||
physics: customTabBarViewScrollPhysics,
|
physics: const CustomTabBarViewScrollPhysics(),
|
||||||
controller: controller,
|
controller: controller,
|
||||||
children: children,
|
children: children,
|
||||||
);
|
);
|
||||||
|
|
||||||
class CustomTabBarViewScrollPhysics extends ScrollPhysics {
|
class CustomTabBarViewScrollPhysics extends ScrollPhysics {
|
||||||
CustomTabBarViewScrollPhysics({super.parent});
|
const CustomTabBarViewScrollPhysics({super.parent});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
CustomTabBarViewScrollPhysics applyTo(ScrollPhysics? ancestor) {
|
CustomTabBarViewScrollPhysics applyTo(ScrollPhysics? ancestor) {
|
||||||
return CustomTabBarViewScrollPhysics(parent: buildParent(ancestor)!);
|
return CustomTabBarViewScrollPhysics(parent: buildParent(ancestor));
|
||||||
}
|
}
|
||||||
|
|
||||||
final springDescription = GStorage.springDescription;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
SpringDescription get spring => SpringDescription(
|
SpringDescription get spring => SpringDescription(
|
||||||
mass: springDescription[0],
|
mass: GStorage.springDescription[0],
|
||||||
stiffness: springDescription[1],
|
stiffness: GStorage.springDescription[1],
|
||||||
damping: springDescription[2],
|
damping: GStorage.springDescription[2],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final customTabBarViewScrollPhysics = CustomTabBarViewScrollPhysics();
|
class CustomTabBarViewClampingScrollPhysics extends ClampingScrollPhysics {
|
||||||
|
const CustomTabBarViewClampingScrollPhysics({super.parent});
|
||||||
|
|
||||||
|
@override
|
||||||
|
CustomTabBarViewClampingScrollPhysics applyTo(ScrollPhysics? ancestor) {
|
||||||
|
return CustomTabBarViewClampingScrollPhysics(parent: buildParent(ancestor));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
SpringDescription get spring => SpringDescription(
|
||||||
|
mass: GStorage.springDescription[0],
|
||||||
|
stiffness: GStorage.springDescription[1],
|
||||||
|
damping: GStorage.springDescription[2],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -587,14 +587,13 @@ List<SettingsModel> get styleSettings => [
|
|||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
Get.back();
|
Get.back();
|
||||||
late final spring = GStorage.springDescription;
|
|
||||||
await GStorage.setting.put(
|
await GStorage.setting.put(
|
||||||
SettingBoxKey.springDescription,
|
SettingBoxKey.springDescription,
|
||||||
List<double>.generate(
|
List<double>.generate(
|
||||||
3,
|
3,
|
||||||
(i) =>
|
(i) =>
|
||||||
double.tryParse(springDescription[i]) ??
|
double.tryParse(springDescription[i]) ??
|
||||||
spring[i],
|
GStorage.springDescription[i],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
SmartDialog.showToast('设置成功,重启生效');
|
SmartDialog.showToast('设置成功,重启生效');
|
||||||
|
|||||||
@@ -624,7 +624,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
showReply: videoDetailController.showReply,
|
showReply: videoDetailController.showReply,
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: tabBarView(
|
child: videoTabBarView(
|
||||||
controller: videoDetailController.tabCtr,
|
controller: videoDetailController.tabCtr,
|
||||||
children: [
|
children: [
|
||||||
videoIntro(),
|
videoIntro(),
|
||||||
@@ -674,7 +674,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
children: [
|
children: [
|
||||||
buildTabbar(showReply: videoDetailController.showReply),
|
buildTabbar(showReply: videoDetailController.showReply),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: tabBarView(
|
child: videoTabBarView(
|
||||||
controller: videoDetailController.tabCtr,
|
controller: videoDetailController.tabCtr,
|
||||||
children: [
|
children: [
|
||||||
videoIntro(),
|
videoIntro(),
|
||||||
@@ -773,7 +773,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
showReply: videoDetailController.showReply,
|
showReply: videoDetailController.showReply,
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: tabBarView(
|
child: videoTabBarView(
|
||||||
controller: videoDetailController.tabCtr,
|
controller: videoDetailController.tabCtr,
|
||||||
children: [
|
children: [
|
||||||
if (videoDetailController.showReply)
|
if (videoDetailController.showReply)
|
||||||
@@ -882,7 +882,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
showReply: videoDetailController.showReply,
|
showReply: videoDetailController.showReply,
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: tabBarView(
|
child: videoTabBarView(
|
||||||
controller: videoDetailController.tabCtr,
|
controller: videoDetailController.tabCtr,
|
||||||
children: [
|
children: [
|
||||||
if (videoDetailController.videoType ==
|
if (videoDetailController.videoType ==
|
||||||
|
|||||||
@@ -422,12 +422,12 @@ class GStorage {
|
|||||||
// ratio: 1.1,
|
// ratio: 1.1,
|
||||||
// );
|
// );
|
||||||
// damping = ratio * 2.0 * math.sqrt(mass * stiffness)
|
// damping = ratio * 2.0 * math.sqrt(mass * stiffness)
|
||||||
static List<double> get springDescription => List<double>.from(
|
static final List<double> springDescription = List<double>.from(
|
||||||
setting.get(
|
setting.get(
|
||||||
SettingBoxKey.springDescription, // [mass, stiffness, damping]
|
SettingBoxKey.springDescription, // [mass, stiffness, damping]
|
||||||
defaultValue: [0.5, 100.0, 2.2 * sqrt(50)],
|
defaultValue: [0.5, 100.0, 2.2 * sqrt(50)],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// static Brightness get brightness {
|
// static Brightness get brightness {
|
||||||
// return switch (_themeMode) {
|
// return switch (_themeMode) {
|
||||||
|
|||||||
Reference in New Issue
Block a user