opt: nav icon color

ref orz12/main
This commit is contained in:
bggRGjQaUbCoE
2025-02-22 20:37:47 +08:00
parent 9ebc054c8c
commit 6a615c408b

View File

@@ -184,146 +184,155 @@ class _MainAppState extends State<MainApp>
} }
} }
}, },
child: Scaffold( child: AnnotatedRegion<SystemUiOverlayStyle>(
resizeToAvoidBottomInset: false, value: SystemUiOverlayStyle(
extendBody: true, systemNavigationBarColor: Colors.transparent,
body: Row( systemNavigationBarIconBrightness:
mainAxisAlignment: MainAxisAlignment.center, Theme.of(context).brightness == Brightness.light
children: [ ? Brightness.dark
if (useSideBar || context.orientation == Orientation.landscape) : Brightness.light, // 设置虚拟按键图标颜色
Obx( ),
() => _mainController.navigationBars.length > 1 child: Scaffold(
? NavigationRail( resizeToAvoidBottomInset: false,
groupAlignment: 0.5, extendBody: true,
selectedIndex: _mainController.selectedIndex.value, body: Row(
onDestinationSelected: setIndex, mainAxisAlignment: MainAxisAlignment.center,
labelType: NavigationRailLabelType.selected, children: [
leading: userAndSearchVertical, if (useSideBar || context.orientation == Orientation.landscape)
destinations: _mainController.navigationBars Obx(
.map( () => _mainController.navigationBars.length > 1
(e) => NavigationRailDestination( ? NavigationRail(
icon: _buildIcon( groupAlignment: 0.5,
id: e['id'], selectedIndex: _mainController.selectedIndex.value,
count: e['count'], onDestinationSelected: setIndex,
icon: e['icon'], labelType: NavigationRailLabelType.selected,
leading: userAndSearchVertical,
destinations: _mainController.navigationBars
.map(
(e) => NavigationRailDestination(
icon: _buildIcon(
id: e['id'],
count: e['count'],
icon: e['icon'],
),
selectedIcon: _buildIcon(
id: e['id'],
count: e['count'],
icon: e['selectIcon'],
),
label: Text(e['label']),
), ),
selectedIcon: _buildIcon( )
id: e['id'], .toList(),
count: e['count'], )
icon: e['selectIcon'], : Container(
), padding: EdgeInsets.only(
label: Text(e['label']), top: MediaQuery.paddingOf(context).top + 10,
), ),
) width: 56,
.toList(), child: userAndSearchVertical,
)
: Container(
padding: EdgeInsets.only(
top: MediaQuery.paddingOf(context).top + 10,
), ),
width: 56, ),
child: userAndSearchVertical, VerticalDivider(
width: 1,
indent: MediaQuery.of(context).padding.top,
endIndent: MediaQuery.of(context).padding.bottom,
color: Theme.of(context).colorScheme.outline.withOpacity(0.06),
),
Expanded(
child: _mainController.mainTabBarView
? CustomTabBarView(
scrollDirection:
context.orientation == Orientation.portrait
? Axis.horizontal
: Axis.vertical,
physics: const NeverScrollableScrollPhysics(),
controller: _mainController.controller,
children: _mainController.pages,
)
: PageView(
physics: const NeverScrollableScrollPhysics(),
controller: _mainController.controller,
children: _mainController.pages,
), ),
), ),
VerticalDivider( ],
width: 1, ),
indent: MediaQuery.of(context).padding.top, bottomNavigationBar: useSideBar ||
endIndent: MediaQuery.of(context).padding.bottom, context.orientation == Orientation.landscape
color: Theme.of(context).colorScheme.outline.withOpacity(0.06), ? null
), : StreamBuilder(
Expanded( stream: _mainController.hideTabBar
child: _mainController.mainTabBarView ? _mainController.bottomBarStream.stream
? CustomTabBarView( : StreamController<bool>.broadcast().stream,
scrollDirection: initialData: true,
context.orientation == Orientation.portrait builder: (context, AsyncSnapshot snapshot) {
? Axis.horizontal return AnimatedSlide(
: Axis.vertical, curve: Curves.easeInOutCubicEmphasized,
physics: const NeverScrollableScrollPhysics(), duration: const Duration(milliseconds: 500),
controller: _mainController.controller, offset: Offset(0, snapshot.data ? 0 : 1),
children: _mainController.pages, child: enableMYBar
) ? Obx(
: PageView( () => _mainController.navigationBars.length > 1
physics: const NeverScrollableScrollPhysics(), ? NavigationBar(
controller: _mainController.controller, onDestinationSelected: setIndex,
children: _mainController.pages, selectedIndex:
), _mainController.selectedIndex.value,
), destinations:
], _mainController.navigationBars.map(
), (e) {
bottomNavigationBar: return NavigationDestination(
useSideBar || context.orientation == Orientation.landscape icon: _buildIcon(
? null id: e['id'],
: StreamBuilder( count: e['count'],
stream: _mainController.hideTabBar icon: e['icon'],
? _mainController.bottomBarStream.stream ),
: StreamController<bool>.broadcast().stream, selectedIcon: _buildIcon(
initialData: true, id: e['id'],
builder: (context, AsyncSnapshot snapshot) { count: e['count'],
return AnimatedSlide( icon: e['selectIcon'],
curve: Curves.easeInOutCubicEmphasized, ),
duration: const Duration(milliseconds: 500), label: e['label'],
offset: Offset(0, snapshot.data ? 0 : 1), );
child: enableMYBar },
? Obx( ).toList(),
() => _mainController.navigationBars.length > 1 )
? NavigationBar( : const SizedBox.shrink(),
onDestinationSelected: setIndex, )
selectedIndex: : Obx(
_mainController.selectedIndex.value, () => _mainController.navigationBars.length > 1
destinations: ? BottomNavigationBar(
_mainController.navigationBars.map( currentIndex:
(e) { _mainController.selectedIndex.value,
return NavigationDestination( onTap: setIndex,
iconSize: 16,
selectedFontSize: 12,
unselectedFontSize: 12,
type: BottomNavigationBarType.fixed,
items: _mainController.navigationBars
.map(
(e) => BottomNavigationBarItem(
icon: _buildIcon( icon: _buildIcon(
id: e['id'], id: e['id'],
count: e['count'], count: e['count'],
icon: e['icon'], icon: e['icon'],
), ),
selectedIcon: _buildIcon( activeIcon: _buildIcon(
id: e['id'], id: e['id'],
count: e['count'], count: e['count'],
icon: e['selectIcon'], icon: e['selectIcon'],
), ),
label: e['label'], label: e['label'],
); ),
}, )
).toList(), .toList(),
) )
: const SizedBox.shrink(), : const SizedBox.shrink(),
) ),
: Obx( );
() => _mainController.navigationBars.length > 1 },
? BottomNavigationBar( ),
currentIndex: ),
_mainController.selectedIndex.value,
onTap: setIndex,
iconSize: 16,
selectedFontSize: 12,
unselectedFontSize: 12,
type: BottomNavigationBarType.fixed,
items: _mainController.navigationBars
.map(
(e) => BottomNavigationBarItem(
icon: _buildIcon(
id: e['id'],
count: e['count'],
icon: e['icon'],
),
activeIcon: _buildIcon(
id: e['id'],
count: e['count'],
icon: e['selectIcon'],
),
label: e['label'],
),
)
.toList(),
)
: const SizedBox.shrink(),
),
);
},
),
), ),
); );
} }