mobile_skt/lib/widgets/bottom_nav_bar.dart

66 lines
2.3 KiB
Dart
Raw Normal View History

2024-03-19 11:09:07 +08:00
import 'package:animated_bottom_navigation_bar/animated_bottom_navigation_bar.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sk_base_mobile/app_theme.dart';
import 'package:sk_base_mobile/screens/landing/landing_controller.dart';
import 'package:sk_base_mobile/util/screen_adaper_util.dart';
import 'package:auto_size_text/auto_size_text.dart';
class BottomNavBar extends StatelessWidget {
BottomNavBar({super.key});
final controller = Get.put(LandingController());
final autoSizeGroup = AutoSizeGroup();
@override
Widget build(BuildContext context) {
return Obx(
() => AnimatedBottomNavigationBar.builder(
itemCount: controller.pages.length,
2024-03-31 17:13:29 +08:00
elevation: ScreenAdaper.height(20),
height: ScreenAdaper.height(100),
2024-03-19 11:09:07 +08:00
activeIndex: controller.currentIndex.value,
gapLocation: GapLocation.center,
2024-03-31 17:13:29 +08:00
notchMargin: ScreenAdaper.height(10),
notchSmoothness: NotchSmoothness.smoothEdge,
leftCornerRadius: ScreenAdaper.sp(40),
rightCornerRadius: ScreenAdaper.sp(40),
2024-03-19 11:09:07 +08:00
onTap: (index) {
controller.currentIndex.value = index;
},
tabBuilder: (int index, bool isActive) {
final color = isActive
? AppTheme.activeNavigationBarColor
: AppTheme.notActiveNavigationBarColor;
return Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
2024-03-26 16:02:49 +08:00
controller.bottomNavItems![index].icon,
2024-03-28 17:18:46 +08:00
size: ScreenAdaper.height(40),
2024-03-19 11:09:07 +08:00
color: color,
),
AutoSizeText(
2024-03-26 16:02:49 +08:00
controller.bottomNavItems![index].label ?? '',
2024-03-19 11:09:07 +08:00
maxLines: 1,
2024-03-28 17:18:46 +08:00
style:
TextStyle(color: color, fontSize: ScreenAdaper.height(20)),
2024-03-19 11:09:07 +08:00
group: autoSizeGroup,
),
],
);
},
),
);
}
}
// BottomNavigationBar(
2024-03-28 17:18:46 +08:00
// iconsize: ScreenAdaper.height(40),
2024-03-19 11:09:07 +08:00
// type: BottomNavigationBarType.fixed,
// items: bottomNavItems,
// showSelectedLabels: true,
// showUnselectedLabels: true,
// currentIndex: _selectedLanding,
// onTap: (landing) {
// _onItemTapped(landing);
// },
// )