mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-31 08:08:19 +08:00
feat: scroll spring in history & fav (#645)
This commit is contained in:
committed by
GitHub
parent
a7eebcc209
commit
d3cbc95235
@@ -30,11 +30,7 @@ class CustomTabBarViewScrollPhysics extends ScrollPhysics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
SpringDescription get spring => SpringDescription(
|
SpringDescription get spring => CustomSpringDescription();
|
||||||
mass: GStorage.springDescription[0],
|
|
||||||
stiffness: GStorage.springDescription[1],
|
|
||||||
damping: GStorage.springDescription[2],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomTabBarViewClampingScrollPhysics extends ClampingScrollPhysics {
|
class CustomTabBarViewClampingScrollPhysics extends ClampingScrollPhysics {
|
||||||
@@ -46,11 +42,7 @@ class CustomTabBarViewClampingScrollPhysics extends ClampingScrollPhysics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
SpringDescription get spring => SpringDescription(
|
SpringDescription get spring => CustomSpringDescription();
|
||||||
mass: GStorage.springDescription[0],
|
|
||||||
stiffness: GStorage.springDescription[1],
|
|
||||||
damping: GStorage.springDescription[2],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class PositionRetainedScrollPhysics extends AlwaysScrollableScrollPhysics {
|
class PositionRetainedScrollPhysics extends AlwaysScrollableScrollPhysics {
|
||||||
@@ -86,3 +78,20 @@ class PositionRetainedScrollPhysics extends AlwaysScrollableScrollPhysics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CustomSpringDescription implements SpringDescription {
|
||||||
|
@override
|
||||||
|
final mass = GStorage.springDescription[0];
|
||||||
|
|
||||||
|
@override
|
||||||
|
final stiffness = GStorage.springDescription[1];
|
||||||
|
|
||||||
|
@override
|
||||||
|
final damping = GStorage.springDescription[2];
|
||||||
|
|
||||||
|
CustomSpringDescription._();
|
||||||
|
|
||||||
|
static final _instance = CustomSpringDescription._();
|
||||||
|
|
||||||
|
factory CustomSpringDescription() => _instance;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:PiliPlus/common/widgets/scroll_physics.dart';
|
||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
import 'package:PiliPlus/pages/fav/article/view.dart';
|
import 'package:PiliPlus/pages/fav/article/view.dart';
|
||||||
import 'package:PiliPlus/pages/fav/note/view.dart';
|
import 'package:PiliPlus/pages/fav/note/view.dart';
|
||||||
@@ -10,7 +11,15 @@ import 'package:get/get.dart';
|
|||||||
enum _FavType { video, bangumi, cinema, article, note }
|
enum _FavType { video, bangumi, cinema, article, note }
|
||||||
|
|
||||||
extension _FavTypeExt on _FavType {
|
extension _FavTypeExt on _FavType {
|
||||||
String get title => ['视频', '追番', '追剧', '专栏', '笔记'][index];
|
String get title => const ['视频', '追番', '追剧', '专栏', '笔记'][index];
|
||||||
|
|
||||||
|
Widget get page => switch (this) {
|
||||||
|
_FavType.video => const FavVideoPage(),
|
||||||
|
_FavType.bangumi => const FavPgcPage(type: 1),
|
||||||
|
_FavType.cinema => const FavPgcPage(type: 2),
|
||||||
|
_FavType.article => const FavArticlePage(),
|
||||||
|
_FavType.note => const FavNotePage(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
class FavPage extends StatefulWidget {
|
class FavPage extends StatefulWidget {
|
||||||
@@ -83,26 +92,12 @@ class _FavPageState extends State<FavPage> with SingleTickerProviderStateMixin {
|
|||||||
],
|
],
|
||||||
bottom: TabBar(
|
bottom: TabBar(
|
||||||
controller: _tabController,
|
controller: _tabController,
|
||||||
tabs: _FavType.values
|
tabs: _FavType.values.map((item) => Tab(text: item.title)).toList(),
|
||||||
.map(
|
|
||||||
(item) => Tab(text: item.title),
|
|
||||||
)
|
|
||||||
.toList(),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: TabBarView(
|
body: tabBarView(
|
||||||
controller: _tabController,
|
controller: _tabController,
|
||||||
children: _FavType.values
|
children: _FavType.values.map((item) => item.page).toList(),
|
||||||
.map(
|
|
||||||
(item) => switch (item) {
|
|
||||||
_FavType.video => const FavVideoPage(),
|
|
||||||
_FavType.bangumi => const FavPgcPage(type: 1),
|
|
||||||
_FavType.cinema => const FavPgcPage(type: 2),
|
|
||||||
_FavType.article => const FavArticlePage(),
|
|
||||||
_FavType.note => const FavNotePage(),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.toList(),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:PiliPlus/common/widgets/http_error.dart';
|
import 'package:PiliPlus/common/widgets/http_error.dart';
|
||||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||||
|
import 'package:PiliPlus/common/widgets/scroll_physics.dart';
|
||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
import 'package:PiliPlus/pages/fav_search/view.dart' show SearchType;
|
import 'package:PiliPlus/pages/fav_search/view.dart' show SearchType;
|
||||||
import 'package:PiliPlus/pages/history/base_controller.dart';
|
import 'package:PiliPlus/pages/history/base_controller.dart';
|
||||||
@@ -227,7 +228,7 @@ class _HistoryPageState extends State<HistoryPage>
|
|||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
physics: enableMultiSelect
|
physics: enableMultiSelect
|
||||||
? const NeverScrollableScrollPhysics()
|
? const NeverScrollableScrollPhysics()
|
||||||
: null,
|
: const CustomTabBarViewScrollPhysics(),
|
||||||
controller: _historyController.tabController,
|
controller: _historyController.tabController,
|
||||||
children: [
|
children: [
|
||||||
_buildPage,
|
_buildPage,
|
||||||
|
|||||||
@@ -2583,7 +2583,7 @@ SettingsModel _getVideoFilterSelectModel({
|
|||||||
value = result!;
|
value = result!;
|
||||||
await GStorage.setting.put(key, result);
|
await GStorage.setting.put(key, result);
|
||||||
setState();
|
setState();
|
||||||
RecommendFilter.update();
|
if (isFilter) RecommendFilter.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user