| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- import 'dart:ui';
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import '../../../../config/translations/strings_enum.dart';
- import '../../../../config/theme/light_theme_colors.dart';
- import '../../../../config/theme/dark_theme_colors.dart';
- import '../../../data/sp/ix_sp.dart';
- class IXBottomNavigationBar extends StatelessWidget {
- final int currentIndex;
- final int lastIndex;
- final Function(int) onTap;
- const IXBottomNavigationBar({
- super.key,
- required this.currentIndex,
- required this.lastIndex,
- required this.onTap,
- });
- @override
- Widget build(BuildContext context) {
- return ClipRRect(
- child: BackdropFilter(
- filter: ImageFilter.blur(sigmaX: 4, sigmaY: 10),
- child: SafeArea(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: [
- _buildNavItem(
- icon: Icons.gamepad,
- label: Strings.bottomBarGames.tr,
- index: 0,
- onTap: () => onTap(0),
- ),
- _buildNavItem(
- icon: Icons.bolt,
- label: Strings.bottomBarBoost.tr,
- index: 1,
- onTap: () => onTap(1),
- ),
- _buildNavItem(
- icon: Icons.person,
- label: Strings.bottomBarMe.tr,
- index: 2,
- onTap: () => onTap(2),
- ),
- ],
- ),
- ),
- ),
- );
- }
- Widget _buildNavItem({
- required IconData icon,
- required String label,
- required int index,
- required VoidCallback onTap,
- }) {
- final isSelected = currentIndex == index;
- final bool isLightTheme = IXSP.getThemeIsLight();
- // 根据主题获取颜色
- final selectedColor = isLightTheme
- ? LightThemeColors.bottomBarSelectedColor
- : DarkThemeColors.bottomBarSelectedColor;
- final unselectedColor = isLightTheme
- ? LightThemeColors.bottomBarUnselectedColor
- : DarkThemeColors.bottomBarUnselectedColor;
- return GestureDetector(
- onTap: onTap,
- behavior: HitTestBehavior.opaque,
- child: Stack(
- children: [
- Container(
- width: 100,
- height: 52,
- margin: const EdgeInsets.only(top: 12),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- AnimatedSwitcher(
- duration: const Duration(milliseconds: 300),
- transitionBuilder: (child, animation) {
- return FadeTransition(opacity: animation, child: child);
- },
- child: Icon(
- icon,
- key: ValueKey("bottom_bar_icon_$isSelected"),
- size: 24,
- color: isSelected ? selectedColor : unselectedColor,
- ),
- ),
- AnimatedDefaultTextStyle(
- duration: const Duration(milliseconds: 300),
- curve: Curves.easeInOut,
- style: TextStyle(
- fontSize: 12,
- height: 1.4,
- color: isSelected ? selectedColor : unselectedColor,
- fontWeight: FontWeight.w500,
- ),
- child: Text(label),
- ),
- ],
- ),
- ),
- ],
- ),
- );
- }
- }
|