mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
Squashed commit of the following:
commit 8285fab60440587dc68d1662b177466d8a533720
Author: orz12 <ms_lyq@hotmail.com>
Date: Tue Apr 23 00:16:41 2024 +0800
feat: 自适应导航栏依赖
commit 3af4be16fe5c7c2e97b2b457071f5fe28425905d
Merge: 209e1215 ce459701
Author: X64D <152763398+X64D@users.noreply.github.com>
Date: Mon Apr 22 15:01:23 2024 +0000
Merge branch 'orz12:main' into main
commit 209e121530ed6701c3c729e8d8a5d4b5fc92747b
Author: X64D <152763398+X64D@users.noreply.github.com>
Date: Mon Apr 8 23:18:43 2024 +0000
feat: 横屏适配 #53 #57
commit 1671f29e9c1d22324ad7d5ededd9e09c84363be4
Author: X64D <152763398+X64D@users.noreply.github.com>
Date: Mon Apr 8 23:11:16 2024 +0000
feat: 横屏适配 #53 #57
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:PiliPalaX/models/common/dynamic_badge_mode.dart';
|
||||
@@ -30,6 +31,7 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
||||
int? _lastSelectTime; //上次点击时间
|
||||
Box setting = GStrorage.setting;
|
||||
late bool enableMYBar;
|
||||
late bool horizontalScreen;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -38,6 +40,7 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
||||
_mainController.pageController =
|
||||
PageController(initialPage: _mainController.selectedIndex);
|
||||
enableMYBar = setting.get(SettingBoxKey.enableMYBar, defaultValue: true);
|
||||
horizontalScreen = setting.get(SettingBoxKey.horizontalScreen, defaultValue: false);
|
||||
}
|
||||
|
||||
void setIndex(int value) async {
|
||||
@@ -109,7 +112,43 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
||||
onPopInvoked: (bool didPop) async {
|
||||
_mainController.onBackPressed(context);
|
||||
},
|
||||
child: Scaffold(
|
||||
child: horizontalScreen
|
||||
? AdaptiveScaffold(
|
||||
body: (_) => PageView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
controller: _mainController.pageController,
|
||||
onPageChanged: (index) {
|
||||
_mainController.selectedIndex = index;
|
||||
setState(() {});
|
||||
},
|
||||
children: _mainController.pages,
|
||||
),
|
||||
destinations: _mainController.navigationBars.map((e) => NavigationDestination(
|
||||
icon: Badge(
|
||||
label: _mainController.dynamicBadgeType ==
|
||||
DynamicBadgeMode.number
|
||||
? Text(e['count'].toString())
|
||||
: null,
|
||||
padding: const EdgeInsets.fromLTRB(6, 0, 6, 0),
|
||||
isLabelVisible:
|
||||
_mainController.dynamicBadgeType !=
|
||||
DynamicBadgeMode.hidden &&
|
||||
e['count'] > 0,
|
||||
child: e['icon'],
|
||||
backgroundColor:
|
||||
Theme.of(context).colorScheme.primary,
|
||||
textColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.onInverseSurface,
|
||||
),
|
||||
selectedIcon: e['selectIcon'],
|
||||
label: e['label'],
|
||||
)).toList(),
|
||||
onSelectedIndexChange: (value) => setIndex(value),
|
||||
selectedIndex: _mainController.selectedIndex,
|
||||
useDrawer: false
|
||||
)
|
||||
: Scaffold(
|
||||
extendBody: true,
|
||||
body: PageView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
|
||||
Reference in New Issue
Block a user