feat: 侧边栏适配异形屏、分区子侧栏内边距优化

This commit is contained in:
orz12
2024-06-12 20:18:27 +08:00
parent 2035ae90f3
commit 6ac24ef52c
3 changed files with 48 additions and 35 deletions

View File

@@ -39,10 +39,9 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
_mainController.pageController =
PageController(initialPage: _mainController.selectedIndex);
enableMYBar = setting.get(SettingBoxKey.enableMYBar, defaultValue: true);
useSideBar =
setting.get(SettingBoxKey.useSideBar, defaultValue: false);
enableGradientBg = setting.get(SettingBoxKey.enableGradientBg,
defaultValue: true);
useSideBar = setting.get(SettingBoxKey.useSideBar, defaultValue: false);
enableGradientBg =
setting.get(SettingBoxKey.enableGradientBg, defaultValue: true);
}
void setIndex(int value) async {
@@ -152,7 +151,7 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
children: [
if (useSideBar) ...[
SizedBox(
width: 55,
width: 55 + MediaQuery.of(context).padding.left,
child: NavigationRail(
groupAlignment: 0.0,
minWidth: 40.0,
@@ -170,8 +169,11 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
DynamicBadgeMode.number
? Text(e['count'].toString())
: null,
padding:
const EdgeInsets.fromLTRB(2, 0, 2, 0),
padding: EdgeInsets.fromLTRB(
2 + MediaQuery.of(context).padding.left,
0,
2,
0),
isLabelVisible:
_mainController.dynamicBadgeType !=
DynamicBadgeMode.hidden &&

View File

@@ -88,33 +88,44 @@ class _RankPageState extends State<RankPage>
child: ConstrainedBox(
constraints: BoxConstraints(minHeight: constraint.maxHeight),
child: IntrinsicHeight(
child: NavigationRail(
backgroundColor: Colors.transparent,
minWidth: 50.0,
// elevation: 0,
selectedIndex: _selectedTabIndex,
onDestinationSelected: (int index) {
feedBack();
if (_selectedTabIndex == index) {
_rankController.tabsCtrList[index]().animateToTop();
} else {
setState(() {
_rankController.tabController.index = index;
_selectedTabIndex = index;
});
}
},
labelType: NavigationRailLabelType.none,
destinations: [
for (var tab in _rankController.tabs)
NavigationRailDestination(
icon: Text(tab['label']),
// selectedIcon: Text(tab['label']),
label: const SizedBox.shrink(),
),
],
trailing: const SizedBox(height: 100),
))));
child: MediaQuery.removePadding(
context: context,
removeLeft: true,
removeRight: true,
removeTop: true,
child: NavigationRail(
groupAlignment: -1.0,
backgroundColor: Colors.transparent,
minWidth: 40.0,
useIndicator: false,
// elevation: 0,
selectedIndex: _selectedTabIndex,
onDestinationSelected: (int index) {
feedBack();
if (_selectedTabIndex == index) {
_rankController.tabsCtrList[index]()
.animateToTop();
} else {
setState(() {
_rankController.tabController.index = index;
_selectedTabIndex = index;
});
}
},
labelType: NavigationRailLabelType.none,
destinations: [
for (var tab in _rankController.tabs)
NavigationRailDestination(
icon: Padding(
padding: const EdgeInsets.symmetric(
vertical: 4),
child: Text(tab['label'])),
// selectedIcon: Text(tab['label']),
label: const SizedBox.shrink(),
),
],
trailing: const SizedBox(height: 100),
)))));
}),
Expanded(
child: TabBarView(

View File

@@ -85,7 +85,7 @@ class _ZonePageState extends State<ZonePage>
SliverPadding(
// 单列布局 EdgeInsets.zero
padding:
const EdgeInsets.fromLTRB(StyleString.safeSpace, StyleString.safeSpace, 0, 0),
const EdgeInsets.fromLTRB(StyleString.cardSpace, StyleString.safeSpace, 0, 0),
sliver: FutureBuilder(
future: _futureBuilderFuture,
builder: (context, snapshot) {