mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: custom spring (#304)
This commit is contained in:
committed by
GitHub
parent
6506afa732
commit
b2c520bd91
@@ -14,6 +14,7 @@ import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
|||||||
|
|
||||||
import '../../utils/storage.dart';
|
import '../../utils/storage.dart';
|
||||||
import '../../utils/utils.dart';
|
import '../../utils/utils.dart';
|
||||||
|
import 'package:PiliPlus/common/widgets/spring_physics.dart';
|
||||||
|
|
||||||
class ListSheetContent extends StatefulWidget {
|
class ListSheetContent extends StatefulWidget {
|
||||||
const ListSheetContent({
|
const ListSheetContent({
|
||||||
@@ -423,6 +424,7 @@ class _ListSheetContentState extends State<ListSheetContent>
|
|||||||
? Material(
|
? Material(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
|
physics: customTabBarViewScrollPhysics,
|
||||||
controller: _ctr,
|
controller: _ctr,
|
||||||
children: List.generate(
|
children: List.generate(
|
||||||
widget.season.sections.length,
|
widget.season.sections.length,
|
||||||
|
|||||||
20
lib/common/widgets/spring_physics.dart
Normal file
20
lib/common/widgets/spring_physics.dart
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:PiliPlus/utils/storage.dart';
|
||||||
|
|
||||||
|
class CustomTabBarViewScrollPhysics extends ScrollPhysics {
|
||||||
|
CustomTabBarViewScrollPhysics({super.parent});
|
||||||
|
|
||||||
|
@override
|
||||||
|
CustomTabBarViewScrollPhysics applyTo(ScrollPhysics? ancestor) {
|
||||||
|
return CustomTabBarViewScrollPhysics(parent: buildParent(ancestor)!);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
SpringDescription spring = SpringDescription(
|
||||||
|
mass: GStorage.springDescription[0],
|
||||||
|
stiffness: GStorage.springDescription[1],
|
||||||
|
damping: GStorage.springDescription[2]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
final customTabBarViewScrollPhysics = CustomTabBarViewScrollPhysics();
|
||||||
@@ -16,6 +16,7 @@ import 'package:PiliPlus/pages/main/index.dart';
|
|||||||
import '../../utils/grid.dart';
|
import '../../utils/grid.dart';
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
import 'widgets/bangumi_card_v.dart';
|
import 'widgets/bangumi_card_v.dart';
|
||||||
|
import 'package:PiliPlus/common/widgets/spring_physics.dart';
|
||||||
|
|
||||||
class BangumiPage extends StatefulWidget {
|
class BangumiPage extends StatefulWidget {
|
||||||
const BangumiPage({
|
const BangumiPage({
|
||||||
@@ -162,6 +163,7 @@ class _BangumiPageState extends State<BangumiPage>
|
|||||||
.toList()),
|
.toList()),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
|
physics: customTabBarViewScrollPhysics,
|
||||||
children: types
|
children: types
|
||||||
.map((type) =>
|
.map((type) =>
|
||||||
PgcIndexPage(indexType: type))
|
PgcIndexPage(indexType: type))
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import 'package:PiliPlus/utils/storage.dart';
|
|||||||
import '../../http/danmaku_block.dart';
|
import '../../http/danmaku_block.dart';
|
||||||
import '../../models/user/danmaku_block.dart';
|
import '../../models/user/danmaku_block.dart';
|
||||||
import '../../plugin/pl_player/controller.dart';
|
import '../../plugin/pl_player/controller.dart';
|
||||||
|
import 'package:PiliPlus/common/widgets/spring_physics.dart';
|
||||||
|
|
||||||
class DanmakuBlockPage extends StatefulWidget {
|
class DanmakuBlockPage extends StatefulWidget {
|
||||||
const DanmakuBlockPage({super.key});
|
const DanmakuBlockPage({super.key});
|
||||||
@@ -142,6 +143,7 @@ class _DanmakuBlockPageState extends State<DanmakuBlockPage> {
|
|||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
body: TabBarView(
|
body: TabBarView(
|
||||||
|
physics: customTabBarViewScrollPhysics,
|
||||||
controller: _danmakuBlockController.tabController,
|
controller: _danmakuBlockController.tabController,
|
||||||
children: [
|
children: [
|
||||||
for (var i = 0; i < ruleLabels.length; i++)
|
for (var i = 0; i < ruleLabels.length; i++)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import 'package:material_design_icons_flutter/material_design_icons_flutter.dart
|
|||||||
|
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
import 'widgets/up_panel.dart';
|
import 'widgets/up_panel.dart';
|
||||||
|
import 'package:PiliPlus/common/widgets/spring_physics.dart';
|
||||||
|
|
||||||
enum ReplyOption { allow, close, choose }
|
enum ReplyOption { allow, close, choose }
|
||||||
|
|
||||||
@@ -183,7 +184,7 @@ class _DynamicsPageState extends State<DynamicsPage>
|
|||||||
if (upPanelPosition == UpPanelPosition.leftFixed) upPanelPart(),
|
if (upPanelPosition == UpPanelPosition.leftFixed) upPanelPart(),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: customTabBarViewScrollPhysics,
|
||||||
controller: _dynamicsController.tabController,
|
controller: _dynamicsController.tabController,
|
||||||
children: _dynamicsController.tabsPageList,
|
children: _dynamicsController.tabsPageList,
|
||||||
)),
|
)),
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import '../../common/widgets/network_img_layer.dart';
|
import '../../common/widgets/network_img_layer.dart';
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
|
import 'package:PiliPlus/common/widgets/spring_physics.dart';
|
||||||
|
|
||||||
class EmotePanel extends StatefulWidget {
|
class EmotePanel extends StatefulWidget {
|
||||||
final Function onChoose;
|
final Function onChoose;
|
||||||
@@ -36,6 +37,7 @@ class _EmotePanelState extends State<EmotePanel>
|
|||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
|
physics: customTabBarViewScrollPhysics,
|
||||||
controller: _emotePanelController.tabController,
|
controller: _emotePanelController.tabController,
|
||||||
children: (loadingState.response as List<Packages>).map(
|
children: (loadingState.response as List<Packages>).map(
|
||||||
(e) {
|
(e) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:get/get.dart';
|
|||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
import 'widgets/follow_list.dart';
|
import 'widgets/follow_list.dart';
|
||||||
import 'widgets/owner_follow_list.dart';
|
import 'widgets/owner_follow_list.dart';
|
||||||
|
import 'package:PiliPlus/common/widgets/spring_physics.dart';
|
||||||
|
|
||||||
class FollowPage extends StatefulWidget {
|
class FollowPage extends StatefulWidget {
|
||||||
const FollowPage({super.key});
|
const FollowPage({super.key});
|
||||||
@@ -83,6 +84,7 @@ class _FollowPageState extends State<FollowPage> {
|
|||||||
]),
|
]),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
|
physics: customTabBarViewScrollPhysics,
|
||||||
controller: _followController.tabController,
|
controller: _followController.tabController,
|
||||||
children: [
|
children: [
|
||||||
for (var i = 0;
|
for (var i = 0;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import 'package:PiliPlus/common/widgets/network_img_layer.dart';
|
|||||||
import 'package:PiliPlus/utils/feed_back.dart';
|
import 'package:PiliPlus/utils/feed_back.dart';
|
||||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||||
import './controller.dart';
|
import './controller.dart';
|
||||||
|
import 'package:PiliPlus/common/widgets/spring_physics.dart';
|
||||||
|
|
||||||
class HomePage extends StatefulWidget {
|
class HomePage extends StatefulWidget {
|
||||||
const HomePage({super.key});
|
const HomePage({super.key});
|
||||||
@@ -73,6 +74,7 @@ class _HomePageState extends State<HomePage>
|
|||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
|
physics: customTabBarViewScrollPhysics,
|
||||||
controller: _homeController.tabController,
|
controller: _homeController.tabController,
|
||||||
children: _homeController.tabsPageList,
|
children: _homeController.tabsPageList,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import 'package:PiliPlus/utils/utils.dart';
|
|||||||
import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart';
|
import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:PiliPlus/common/widgets/spring_physics.dart';
|
||||||
|
|
||||||
class MemberPageNew extends StatefulWidget {
|
class MemberPageNew extends StatefulWidget {
|
||||||
const MemberPageNew({super.key});
|
const MemberPageNew({super.key});
|
||||||
@@ -151,6 +152,7 @@ class _MemberPageNewState extends State<MemberPageNew>
|
|||||||
top: false,
|
top: false,
|
||||||
bottom: false,
|
bottom: false,
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
|
physics: customTabBarViewScrollPhysics,
|
||||||
controller: _userController.tabController,
|
controller: _userController.tabController,
|
||||||
children: _userController.tab2!.map((item) {
|
children: _userController.tab2!.map((item) {
|
||||||
return switch (item.param!) {
|
return switch (item.param!) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:PiliPlus/pages/member_search/search_dynamic.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
|
import 'package:PiliPlus/common/widgets/spring_physics.dart';
|
||||||
|
|
||||||
class MemberSearchPage extends StatefulWidget {
|
class MemberSearchPage extends StatefulWidget {
|
||||||
const MemberSearchPage({super.key});
|
const MemberSearchPage({super.key});
|
||||||
@@ -69,6 +70,7 @@ class _MemberSearchPageState extends State<MemberSearchPage> {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
|
physics: customTabBarViewScrollPhysics,
|
||||||
controller: _memberSearchCtr.tabController,
|
controller: _memberSearchCtr.tabController,
|
||||||
children: [
|
children: [
|
||||||
SearchArchive(ctr: _memberSearchCtr),
|
SearchArchive(ctr: _memberSearchCtr),
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:get/get.dart';
|
|||||||
import 'package:PiliPlus/models/common/search_type.dart';
|
import 'package:PiliPlus/models/common/search_type.dart';
|
||||||
import 'package:PiliPlus/pages/search_panel/index.dart';
|
import 'package:PiliPlus/pages/search_panel/index.dart';
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
|
import 'package:PiliPlus/common/widgets/spring_physics.dart';
|
||||||
|
|
||||||
class SearchResultPage extends StatefulWidget {
|
class SearchResultPage extends StatefulWidget {
|
||||||
const SearchResultPage({super.key});
|
const SearchResultPage({super.key});
|
||||||
@@ -119,6 +120,7 @@ class _SearchResultPageState extends State<SearchResultPage>
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
|
physics: customTabBarViewScrollPhysics,
|
||||||
controller: _tabController,
|
controller: _tabController,
|
||||||
children: SearchType.values
|
children: SearchType.values
|
||||||
.map(
|
.map(
|
||||||
|
|||||||
@@ -536,6 +536,75 @@ List<SettingsModel> get styleSettings => [
|
|||||||
getSubtitle: () =>
|
getSubtitle: () =>
|
||||||
'当前启动页:${defaultNavigationBars.firstWhere((e) => e['id'] == GStorage.defaultHomePage)['label']}',
|
'当前启动页:${defaultNavigationBars.firstWhere((e) => e['id'] == GStorage.defaultHomePage)['label']}',
|
||||||
),
|
),
|
||||||
|
SettingsModel(
|
||||||
|
settingsType: SettingsType.normal,
|
||||||
|
title: '滑动动画弹簧参数',
|
||||||
|
leading: const Icon(Icons.chrome_reader_mode_outlined),
|
||||||
|
onTap: (setState) {
|
||||||
|
final numberRegExp = RegExp(r'[\d\.]+');
|
||||||
|
List springDescription = GStorage.springDescription.map((i) => i.toString()).toList();
|
||||||
|
showDialog(
|
||||||
|
context: Get.context!,
|
||||||
|
builder: (context) {
|
||||||
|
return AlertDialog(
|
||||||
|
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'),
|
||||||
|
),
|
||||||
|
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(
|
||||||
|
onPressed: Get.back,
|
||||||
|
child: Text(
|
||||||
|
'取消',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.outline,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () async {
|
||||||
|
Get.back();
|
||||||
|
await GStorage.setting.put(
|
||||||
|
SettingBoxKey.springDescription,
|
||||||
|
List<double>.generate(3, (i) => double.tryParse(springDescription[i]) ?? GStorage.springDescription[i]),
|
||||||
|
);
|
||||||
|
SmartDialog.showToast('设置成功,重启生效');
|
||||||
|
setState();
|
||||||
|
},
|
||||||
|
child: const Text('确定'),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
SettingsModel(
|
SettingsModel(
|
||||||
settingsType: SettingsType.normal,
|
settingsType: SettingsType.normal,
|
||||||
onTap: (setState) async {
|
onTap: (setState) async {
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ import 'package:screen_brightness/screen_brightness.dart';
|
|||||||
|
|
||||||
import '../../../services/shutdown_timer_service.dart';
|
import '../../../services/shutdown_timer_service.dart';
|
||||||
import 'widgets/header_control.dart';
|
import 'widgets/header_control.dart';
|
||||||
|
import 'package:PiliPlus/common/widgets/spring_physics.dart';
|
||||||
|
|
||||||
class VideoDetailPage extends StatefulWidget {
|
class VideoDetailPage extends StatefulWidget {
|
||||||
const VideoDetailPage({super.key});
|
const VideoDetailPage({super.key});
|
||||||
@@ -621,7 +622,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
physics: const ClampingScrollPhysics(),
|
physics: customTabBarViewScrollPhysics,
|
||||||
controller: videoDetailController.tabCtr,
|
controller: videoDetailController.tabCtr,
|
||||||
children: [
|
children: [
|
||||||
videoIntro(),
|
videoIntro(),
|
||||||
@@ -672,7 +673,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
buildTabbar(showReply: videoDetailController.showReply),
|
buildTabbar(showReply: videoDetailController.showReply),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
physics: const ClampingScrollPhysics(),
|
physics: customTabBarViewScrollPhysics,
|
||||||
controller: videoDetailController.tabCtr,
|
controller: videoDetailController.tabCtr,
|
||||||
children: [
|
children: [
|
||||||
videoIntro(),
|
videoIntro(),
|
||||||
@@ -772,6 +773,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
|
physics: customTabBarViewScrollPhysics,
|
||||||
controller: videoDetailController.tabCtr,
|
controller: videoDetailController.tabCtr,
|
||||||
children: [
|
children: [
|
||||||
if (videoDetailController.showReply)
|
if (videoDetailController.showReply)
|
||||||
@@ -881,7 +883,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
physics: const ClampingScrollPhysics(),
|
physics: customTabBarViewScrollPhysics,
|
||||||
controller: videoDetailController.tabCtr,
|
controller: videoDetailController.tabCtr,
|
||||||
children: [
|
children: [
|
||||||
if (videoDetailController.videoType ==
|
if (videoDetailController.videoType ==
|
||||||
|
|||||||
@@ -415,6 +415,12 @@ class GStorage {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static final _defaultSpring = const ClampingScrollPhysics().spring;
|
||||||
|
|
||||||
|
static final List springDescription = setting
|
||||||
|
.get(SettingBoxKey.springDescription,
|
||||||
|
defaultValue: [_defaultSpring.mass, _defaultSpring.stiffness, _defaultSpring.damping]);
|
||||||
|
|
||||||
// static Brightness get brightness {
|
// static Brightness get brightness {
|
||||||
// return switch (_themeMode) {
|
// return switch (_themeMode) {
|
||||||
// 0 => Brightness.light,
|
// 0 => Brightness.light,
|
||||||
@@ -625,6 +631,7 @@ class SettingBoxKey {
|
|||||||
antiGoodsDyn = 'antiGoodsDyn',
|
antiGoodsDyn = 'antiGoodsDyn',
|
||||||
antiGoodsReply = 'antiGoodsReply',
|
antiGoodsReply = 'antiGoodsReply',
|
||||||
expandDynLivePanel = 'expandDynLivePanel',
|
expandDynLivePanel = 'expandDynLivePanel',
|
||||||
|
springDescription = 'springDescription',
|
||||||
|
|
||||||
// Sponsor Block
|
// Sponsor Block
|
||||||
enableSponsorBlock = 'enableSponsorBlock',
|
enableSponsorBlock = 'enableSponsorBlock',
|
||||||
|
|||||||
Reference in New Issue
Block a user