opt: navigationBar展示

This commit is contained in:
guozhigq
2024-04-11 23:26:06 +08:00
parent 48e81ac85c
commit f3eb870b1a
2 changed files with 66 additions and 66 deletions

View File

@ -127,81 +127,81 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
}, },
children: _mainController.pages, children: _mainController.pages,
), ),
bottomNavigationBar: StreamBuilder( bottomNavigationBar: _mainController.navigationBars.length > 1
stream: _mainController.hideTabBar ? StreamBuilder(
? _mainController.bottomBarStream.stream stream: _mainController.hideTabBar
: StreamController<bool>.broadcast().stream, ? _mainController.bottomBarStream.stream
initialData: true, : StreamController<bool>.broadcast().stream,
builder: (context, AsyncSnapshot snapshot) { initialData: true,
return AnimatedSlide( builder: (context, AsyncSnapshot snapshot) {
curve: Curves.easeInOutCubicEmphasized, return AnimatedSlide(
duration: const Duration(milliseconds: 500), curve: Curves.easeInOutCubicEmphasized,
offset: Offset(0, snapshot.data ? 0 : 1), duration: const Duration(milliseconds: 500),
child: Obx( offset: Offset(0, snapshot.data ? 0 : 1),
() => enableMYBar child: enableMYBar
? NavigationBar( ? NavigationBar(
onDestinationSelected: (value) => setIndex(value), onDestinationSelected: (value) => setIndex(value),
selectedIndex: _mainController.selectedIndex, selectedIndex: _mainController.selectedIndex,
destinations: <Widget>[ destinations: <Widget>[
..._mainController.navigationBars.map((e) { ..._mainController.navigationBars.map((e) {
return NavigationDestination( return NavigationDestination(
icon: Obx( icon: Obx(
() => Badge( () => Badge(
label: label: _mainController
_mainController.dynamicBadgeType.value == .dynamicBadgeType.value ==
DynamicBadgeMode.number DynamicBadgeMode.number
? Text(e['count'].toString()) ? Text(e['count'].toString())
: null, : null,
padding: padding:
const EdgeInsets.fromLTRB(6, 0, 6, 0), const EdgeInsets.fromLTRB(6, 0, 6, 0),
isLabelVisible: isLabelVisible: _mainController
_mainController.dynamicBadgeType.value != .dynamicBadgeType.value !=
DynamicBadgeMode.hidden && DynamicBadgeMode.hidden &&
e['count'] > 0, e['count'] > 0,
child: e['icon'], child: e['icon'],
), ),
), ),
selectedIcon: e['selectIcon'], selectedIcon: e['selectIcon'],
label: e['label'], label: e['label'],
); );
}).toList(), }).toList(),
], ],
) )
: BottomNavigationBar( : BottomNavigationBar(
currentIndex: _mainController.selectedIndex, currentIndex: _mainController.selectedIndex,
onTap: (value) => setIndex(value), onTap: (value) => setIndex(value),
iconSize: 16, iconSize: 16,
selectedFontSize: 12, selectedFontSize: 12,
unselectedFontSize: 12, unselectedFontSize: 12,
items: [ items: [
..._mainController.navigationBars.map((e) { ..._mainController.navigationBars.map((e) {
return BottomNavigationBarItem( return BottomNavigationBarItem(
icon: Obx( icon: Obx(
() => Badge( () => Badge(
label: label: _mainController
_mainController.dynamicBadgeType.value == .dynamicBadgeType.value ==
DynamicBadgeMode.number DynamicBadgeMode.number
? Text(e['count'].toString()) ? Text(e['count'].toString())
: null, : null,
padding: padding:
const EdgeInsets.fromLTRB(6, 0, 6, 0), const EdgeInsets.fromLTRB(6, 0, 6, 0),
isLabelVisible: isLabelVisible: _mainController
_mainController.dynamicBadgeType.value != .dynamicBadgeType.value !=
DynamicBadgeMode.hidden && DynamicBadgeMode.hidden &&
e['count'] > 0, e['count'] > 0,
child: e['icon'], child: e['icon'],
), ),
), ),
activeIcon: e['selectIcon'], activeIcon: e['selectIcon'],
label: e['label'], label: e['label'],
); );
}).toList(), }).toList(),
], ],
), ),
), );
); },
}, )
), : null,
), ),
); );
} }

View File

@ -287,7 +287,7 @@ class _StyleSettingState extends State<StyleSetting> {
ListTile( ListTile(
dense: false, dense: false,
onTap: () => Get.toNamed('/navbarSetting'), onTap: () => Get.toNamed('/navbarSetting'),
title: Text('navbar设置', style: titleStyle), title: Text('底部导航栏设置', style: titleStyle),
), ),
if (Platform.isAndroid) if (Platform.isAndroid)
ListTile( ListTile(