mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: custom main pageview
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -23,7 +23,7 @@ class MainController extends GetxController {
|
|||||||
final StreamController<bool> bottomBarStream =
|
final StreamController<bool> bottomBarStream =
|
||||||
StreamController<bool>.broadcast();
|
StreamController<bool>.broadcast();
|
||||||
late bool hideTabBar;
|
late bool hideTabBar;
|
||||||
late TabController controller;
|
late dynamic controller;
|
||||||
RxInt selectedIndex = 0.obs;
|
RxInt selectedIndex = 0.obs;
|
||||||
RxBool isLogin = false.obs;
|
RxBool isLogin = false.obs;
|
||||||
|
|
||||||
@@ -39,6 +39,8 @@ class MainController extends GetxController {
|
|||||||
late final RxString msgUnReadCount = ''.obs;
|
late final RxString msgUnReadCount = ''.obs;
|
||||||
late int lastCheckUnreadAt = 0;
|
late int lastCheckUnreadAt = 0;
|
||||||
|
|
||||||
|
late final mainTabBarView = GStorage.mainTabBarView;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
|
|||||||
@@ -42,11 +42,13 @@ class _MainAppState extends State<MainApp>
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_lastSelectTime = DateTime.now().millisecondsSinceEpoch;
|
_lastSelectTime = DateTime.now().millisecondsSinceEpoch;
|
||||||
_mainController.controller = TabController(
|
_mainController.controller = _mainController.mainTabBarView
|
||||||
|
? TabController(
|
||||||
vsync: this,
|
vsync: this,
|
||||||
initialIndex: _mainController.selectedIndex.value,
|
initialIndex: _mainController.selectedIndex.value,
|
||||||
length: _mainController.navigationBars.length,
|
length: _mainController.navigationBars.length,
|
||||||
);
|
)
|
||||||
|
: PageController(initialPage: _mainController.selectedIndex.value);
|
||||||
enableMYBar =
|
enableMYBar =
|
||||||
GStorage.setting.get(SettingBoxKey.enableMYBar, defaultValue: true);
|
GStorage.setting.get(SettingBoxKey.enableMYBar, defaultValue: true);
|
||||||
useSideBar =
|
useSideBar =
|
||||||
@@ -114,7 +116,11 @@ class _MainAppState extends State<MainApp>
|
|||||||
|
|
||||||
if (value != _mainController.selectedIndex.value) {
|
if (value != _mainController.selectedIndex.value) {
|
||||||
_mainController.selectedIndex.value = value;
|
_mainController.selectedIndex.value = value;
|
||||||
|
if (_mainController.mainTabBarView) {
|
||||||
_mainController.controller.animateTo(value);
|
_mainController.controller.animateTo(value);
|
||||||
|
} else {
|
||||||
|
_mainController.controller.jumpToPage(value);
|
||||||
|
}
|
||||||
dynamic currentPage = _mainController.pages[value];
|
dynamic currentPage = _mainController.pages[value];
|
||||||
if (currentPage is HomePage) {
|
if (currentPage is HomePage) {
|
||||||
_checkDefaultSearch();
|
_checkDefaultSearch();
|
||||||
@@ -217,13 +223,20 @@ class _MainAppState extends State<MainApp>
|
|||||||
color: Theme.of(context).colorScheme.outline.withOpacity(0.06),
|
color: Theme.of(context).colorScheme.outline.withOpacity(0.06),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: CustomTabBarView(
|
child: _mainController.mainTabBarView
|
||||||
scrollDirection: context.orientation == Orientation.portrait
|
? CustomTabBarView(
|
||||||
|
scrollDirection:
|
||||||
|
context.orientation == Orientation.portrait
|
||||||
? Axis.horizontal
|
? Axis.horizontal
|
||||||
: Axis.vertical,
|
: Axis.vertical,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
controller: _mainController.controller,
|
controller: _mainController.controller,
|
||||||
children: _mainController.pages,
|
children: _mainController.pages,
|
||||||
|
)
|
||||||
|
: PageView(
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
controller: _mainController.controller,
|
||||||
|
children: _mainController.pages,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1895,6 +1895,14 @@ List<SettingsModel> get extraSettings => [
|
|||||||
setKey: SettingBoxKey.preInitPlayer,
|
setKey: SettingBoxKey.preInitPlayer,
|
||||||
defaultVal: false,
|
defaultVal: false,
|
||||||
),
|
),
|
||||||
|
SettingsModel(
|
||||||
|
settingsType: SettingsType.sw1tch,
|
||||||
|
title: '首页切换页面动画',
|
||||||
|
leading: Icon(Icons.home_outlined),
|
||||||
|
setKey: SettingBoxKey.mainTabBarView,
|
||||||
|
defaultVal: false,
|
||||||
|
needReboot: true,
|
||||||
|
),
|
||||||
SettingsModel(
|
SettingsModel(
|
||||||
settingsType: SettingsType.sw1tch,
|
settingsType: SettingsType.sw1tch,
|
||||||
enableFeedback: true,
|
enableFeedback: true,
|
||||||
|
|||||||
@@ -345,6 +345,9 @@ class GStorage {
|
|||||||
static bool get preInitPlayer =>
|
static bool get preInitPlayer =>
|
||||||
GStorage.setting.get(SettingBoxKey.preInitPlayer, defaultValue: false);
|
GStorage.setting.get(SettingBoxKey.preInitPlayer, defaultValue: false);
|
||||||
|
|
||||||
|
static bool get mainTabBarView =>
|
||||||
|
GStorage.setting.get(SettingBoxKey.mainTabBarView, defaultValue: false);
|
||||||
|
|
||||||
static List<double> get dynamicDetailRatio => List<double>.from(setting
|
static List<double> get dynamicDetailRatio => List<double>.from(setting
|
||||||
.get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0]));
|
.get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0]));
|
||||||
|
|
||||||
@@ -569,6 +572,7 @@ class SettingBoxKey {
|
|||||||
audioNormalization = 'audioNormalization',
|
audioNormalization = 'audioNormalization',
|
||||||
superResolutionType = 'superResolutionType',
|
superResolutionType = 'superResolutionType',
|
||||||
preInitPlayer = 'preInitPlayer',
|
preInitPlayer = 'preInitPlayer',
|
||||||
|
mainTabBarView = 'mainTabBarView',
|
||||||
|
|
||||||
// Sponsor Block
|
// Sponsor Block
|
||||||
enableSponsorBlock = 'enableSponsorBlock',
|
enableSponsorBlock = 'enableSponsorBlock',
|
||||||
|
|||||||
Reference in New Issue
Block a user