mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: spring
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -423,8 +423,7 @@ class _ListSheetContentState extends State<ListSheetContent>
|
||||
child: _isList
|
||||
? Material(
|
||||
color: Colors.transparent,
|
||||
child: TabBarView(
|
||||
physics: customTabBarViewScrollPhysics,
|
||||
child: tabBarView(
|
||||
controller: _ctr,
|
||||
children: List.generate(
|
||||
widget.season.sections.length,
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Widget tabBarView({
|
||||
required List<Widget> children,
|
||||
TabController? controller,
|
||||
}) =>
|
||||
TabBarView(
|
||||
physics: customTabBarViewScrollPhysics,
|
||||
controller: controller,
|
||||
children: children,
|
||||
);
|
||||
|
||||
class CustomTabBarViewScrollPhysics extends ScrollPhysics {
|
||||
CustomTabBarViewScrollPhysics({super.parent});
|
||||
@@ -9,12 +19,14 @@ class CustomTabBarViewScrollPhysics extends ScrollPhysics {
|
||||
return CustomTabBarViewScrollPhysics(parent: buildParent(ancestor)!);
|
||||
}
|
||||
|
||||
final springDescription = GStorage.springDescription;
|
||||
|
||||
@override
|
||||
SpringDescription spring = SpringDescription(
|
||||
mass: GStorage.springDescription[0],
|
||||
stiffness: GStorage.springDescription[1],
|
||||
damping: GStorage.springDescription[2]
|
||||
);
|
||||
SpringDescription get spring => SpringDescription(
|
||||
mass: springDescription[0],
|
||||
stiffness: springDescription[1],
|
||||
damping: springDescription[2],
|
||||
);
|
||||
}
|
||||
|
||||
final customTabBarViewScrollPhysics = CustomTabBarViewScrollPhysics();
|
||||
final customTabBarViewScrollPhysics = CustomTabBarViewScrollPhysics();
|
||||
|
||||
@@ -162,8 +162,7 @@ class _BangumiPageState extends State<BangumiPage>
|
||||
.map((title) => Tab(text: title))
|
||||
.toList()),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
physics: customTabBarViewScrollPhysics,
|
||||
child: tabBarView(
|
||||
children: types
|
||||
.map((type) =>
|
||||
PgcIndexPage(indexType: type))
|
||||
|
||||
@@ -142,8 +142,7 @@ class _DanmakuBlockPageState extends State<DanmakuBlockPage> {
|
||||
'${ruleLabels[i]}(${_danmakuBlockController.ruleTypes[i]!.length})')),
|
||||
]),
|
||||
),
|
||||
body: TabBarView(
|
||||
physics: customTabBarViewScrollPhysics,
|
||||
body: tabBarView(
|
||||
controller: _danmakuBlockController.tabController,
|
||||
children: [
|
||||
for (var i = 0; i < ruleLabels.length; i++)
|
||||
|
||||
@@ -183,8 +183,7 @@ class _DynamicsPageState extends State<DynamicsPage>
|
||||
body: Row(children: [
|
||||
if (upPanelPosition == UpPanelPosition.leftFixed) upPanelPart(),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
physics: customTabBarViewScrollPhysics,
|
||||
child: tabBarView(
|
||||
controller: _dynamicsController.tabController,
|
||||
children: _dynamicsController.tabsPageList,
|
||||
)),
|
||||
|
||||
@@ -36,8 +36,7 @@ class _EmotePanelState extends State<EmotePanel>
|
||||
? Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
physics: customTabBarViewScrollPhysics,
|
||||
child: tabBarView(
|
||||
controller: _emotePanelController.tabController,
|
||||
children: (loadingState.response as List<Packages>).map(
|
||||
(e) {
|
||||
|
||||
@@ -83,8 +83,7 @@ class _FollowPageState extends State<FollowPage> {
|
||||
]
|
||||
]),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
physics: customTabBarViewScrollPhysics,
|
||||
child: tabBarView(
|
||||
controller: _followController.tabController,
|
||||
children: [
|
||||
for (var i = 0;
|
||||
|
||||
@@ -73,8 +73,7 @@ class _HomePageState extends State<HomePage>
|
||||
] else
|
||||
const SizedBox(height: 6),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
physics: customTabBarViewScrollPhysics,
|
||||
child: tabBarView(
|
||||
controller: _homeController.tabController,
|
||||
children: _homeController.tabsPageList,
|
||||
),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/spring_physics.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
@@ -538,8 +539,7 @@ class _LoginPageState extends State<LoginPage> {
|
||||
}
|
||||
return true;
|
||||
},
|
||||
child: TabBarView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
child: tabBarView(
|
||||
controller: _loginPageCtr.tabController,
|
||||
children: [
|
||||
tabViewOuter(loginByPassword()),
|
||||
|
||||
@@ -151,8 +151,7 @@ class _MemberPageNewState extends State<MemberPageNew>
|
||||
Widget get _buildBody => SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: TabBarView(
|
||||
physics: customTabBarViewScrollPhysics,
|
||||
child: tabBarView(
|
||||
controller: _userController.tabController,
|
||||
children: _userController.tab2!.map((item) {
|
||||
return switch (item.param!) {
|
||||
|
||||
@@ -69,8 +69,7 @@ class _MemberSearchPageState extends State<MemberSearchPage> {
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
physics: customTabBarViewScrollPhysics,
|
||||
child: tabBarView(
|
||||
controller: _memberSearchCtr.tabController,
|
||||
children: [
|
||||
SearchArchive(ctr: _memberSearchCtr),
|
||||
|
||||
@@ -119,8 +119,7 @@ class _SearchResultPageState extends State<SearchResultPage>
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
physics: customTabBarViewScrollPhysics,
|
||||
child: tabBarView(
|
||||
controller: _tabController,
|
||||
children: SearchType.values
|
||||
.map(
|
||||
|
||||
@@ -542,7 +542,8 @@ List<SettingsModel> get styleSettings => [
|
||||
leading: const Icon(Icons.chrome_reader_mode_outlined),
|
||||
onTap: (setState) {
|
||||
final numberRegExp = RegExp(r'[\d\.]+');
|
||||
List springDescription = GStorage.springDescription.map((i) => i.toString()).toList();
|
||||
List springDescription =
|
||||
GStorage.springDescription.map((i) => i.toString()).toList();
|
||||
showDialog(
|
||||
context: Get.context!,
|
||||
builder: (context) {
|
||||
@@ -550,32 +551,28 @@ List<SettingsModel> get styleSettings => [
|
||||
title: const Text('弹簧参数'),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextFormField(
|
||||
autofocus: true,
|
||||
initialValue: springDescription[0],
|
||||
keyboardType: TextInputType.numberWithOptions(),
|
||||
onChanged: (value) { springDescription[0] = value; },
|
||||
inputFormatters: [FilteringTextInputFormatter.allow(numberRegExp)],
|
||||
decoration: InputDecoration(labelText: 'mass'),
|
||||
children: List.generate(
|
||||
3,
|
||||
(index) => TextFormField(
|
||||
autofocus: index == 0,
|
||||
initialValue: springDescription[index],
|
||||
keyboardType:
|
||||
TextInputType.numberWithOptions(decimal: true),
|
||||
onChanged: (value) {
|
||||
springDescription[index] = value;
|
||||
},
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(numberRegExp)
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
labelText: const [
|
||||
'mass',
|
||||
'stiffness',
|
||||
'damping'
|
||||
][index],
|
||||
),
|
||||
),
|
||||
TextFormField(
|
||||
autofocus: true,
|
||||
initialValue: springDescription[1],
|
||||
keyboardType: TextInputType.numberWithOptions(),
|
||||
onChanged: (value) { springDescription[1] = value; },
|
||||
inputFormatters: [FilteringTextInputFormatter.allow(numberRegExp)],
|
||||
decoration: InputDecoration(labelText: 'stiffness'),
|
||||
),
|
||||
TextFormField(
|
||||
autofocus: true,
|
||||
initialValue: springDescription[2],
|
||||
keyboardType: TextInputType.numberWithOptions(),
|
||||
onChanged: (value) { springDescription[2] = value; },
|
||||
inputFormatters: [FilteringTextInputFormatter.allow(numberRegExp)],
|
||||
decoration: InputDecoration(labelText: 'damping'),
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
@@ -590,9 +587,15 @@ List<SettingsModel> get styleSettings => [
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Get.back();
|
||||
late final spring = GStorage.springDescription;
|
||||
await GStorage.setting.put(
|
||||
SettingBoxKey.springDescription,
|
||||
List<double>.generate(3, (i) => double.tryParse(springDescription[i]) ?? GStorage.springDescription[i]),
|
||||
List<double>.generate(
|
||||
3,
|
||||
(i) =>
|
||||
double.tryParse(springDescription[i]) ??
|
||||
spring[i],
|
||||
),
|
||||
);
|
||||
SmartDialog.showToast('设置成功,重启生效');
|
||||
setState();
|
||||
|
||||
@@ -621,8 +621,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
showReply: videoDetailController.showReply,
|
||||
),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
physics: customTabBarViewScrollPhysics,
|
||||
child: tabBarView(
|
||||
controller: videoDetailController.tabCtr,
|
||||
children: [
|
||||
videoIntro(),
|
||||
@@ -672,8 +671,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
children: [
|
||||
buildTabbar(showReply: videoDetailController.showReply),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
physics: customTabBarViewScrollPhysics,
|
||||
child: tabBarView(
|
||||
controller: videoDetailController.tabCtr,
|
||||
children: [
|
||||
videoIntro(),
|
||||
@@ -772,8 +770,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
showReply: videoDetailController.showReply,
|
||||
),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
physics: customTabBarViewScrollPhysics,
|
||||
child: tabBarView(
|
||||
controller: videoDetailController.tabCtr,
|
||||
children: [
|
||||
if (videoDetailController.showReply)
|
||||
@@ -882,8 +879,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
showReply: videoDetailController.showReply,
|
||||
),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
physics: customTabBarViewScrollPhysics,
|
||||
child: tabBarView(
|
||||
controller: videoDetailController.tabCtr,
|
||||
children: [
|
||||
if (videoDetailController.videoType ==
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
import 'package:PiliPlus/common/widgets/pair.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart'
|
||||
show kDragContainerExtentPercentage, displacement;
|
||||
@@ -415,11 +416,18 @@ class GStorage {
|
||||
};
|
||||
}
|
||||
|
||||
static final _defaultSpring = const ClampingScrollPhysics().spring;
|
||||
|
||||
static final List springDescription = setting
|
||||
.get(SettingBoxKey.springDescription,
|
||||
defaultValue: [_defaultSpring.mass, _defaultSpring.stiffness, _defaultSpring.damping]);
|
||||
// static final SpringDescription _kDefaultSpring = SpringDescription.withDampingRatio(
|
||||
// mass: 0.5,
|
||||
// stiffness: 100.0,
|
||||
// ratio: 1.1,
|
||||
// );
|
||||
// damping = ratio * 2.0 * math.sqrt(mass * stiffness)
|
||||
static List<double> get springDescription => List<double>.from(
|
||||
setting.get(
|
||||
SettingBoxKey.springDescription, // [mass, stiffness, damping]
|
||||
defaultValue: [0.5, 100.0, 2.2 * sqrt(50)],
|
||||
),
|
||||
);
|
||||
|
||||
// static Brightness get brightness {
|
||||
// return switch (_themeMode) {
|
||||
|
||||
Reference in New Issue
Block a user