220 lines
6.4 KiB
Dart
220 lines
6.4 KiB
Dart
/// 时间: 2026-04-02
|
|
/// 功能: 关怀模式底部导航栏
|
|
/// 介绍: 关怀模式下显示的简化底部导航栏,只包含诗词和答题两个入口
|
|
/// 最新变化: 2026-04-02 初始创建
|
|
|
|
import 'dart:ui';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import '../../config/app_config.dart';
|
|
import '../../services/get/theme_controller.dart';
|
|
|
|
class CareModeNavigation extends StatelessWidget {
|
|
final int currentIndex;
|
|
final Function(int) onTap;
|
|
|
|
const CareModeNavigation({
|
|
super.key,
|
|
required this.currentIndex,
|
|
required this.onTap,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final themeController = Get.find<ThemeController>();
|
|
|
|
return Obx(() {
|
|
final isDark = themeController.isDarkMode;
|
|
final enableBlur = themeController.enableBlurEffect;
|
|
final primaryColor = themeController.currentThemeColor;
|
|
|
|
return _buildGlassBar(context, isDark, enableBlur, primaryColor);
|
|
});
|
|
}
|
|
|
|
Widget _buildGlassBar(
|
|
BuildContext context,
|
|
bool isDark,
|
|
bool enableBlur,
|
|
Color primaryColor,
|
|
) {
|
|
return SafeArea(
|
|
top: false,
|
|
child: Container(
|
|
padding: EdgeInsets.only(
|
|
left: AppConfig.liquidGlassHorizontalMargin,
|
|
right: AppConfig.liquidGlassHorizontalMargin,
|
|
bottom: AppConfig.liquidGlassBottomMargin,
|
|
top: 8,
|
|
),
|
|
child: Container(
|
|
height: AppConfig.liquidGlassHeight,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(
|
|
AppConfig.liquidGlassCornerRadius,
|
|
),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: isDark
|
|
? Colors.black.withValues(alpha: 0.6)
|
|
: Colors.black.withValues(alpha: 0.15),
|
|
blurRadius: 35,
|
|
spreadRadius: -10,
|
|
offset: const Offset(0, 12),
|
|
),
|
|
],
|
|
),
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.circular(
|
|
AppConfig.liquidGlassCornerRadius,
|
|
),
|
|
child: enableBlur
|
|
? BackdropFilter(
|
|
filter: ImageFilter.blur(
|
|
sigmaX: AppConfig.liquidGlassBlur,
|
|
sigmaY: AppConfig.liquidGlassBlur,
|
|
),
|
|
child: _buildGlassContent(isDark, primaryColor),
|
|
)
|
|
: _buildGlassContent(isDark, primaryColor),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildGlassContent(bool isDark, Color primaryColor) {
|
|
return Stack(
|
|
children: [
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
color: isDark
|
|
? Colors.black.withValues(alpha: 0.4)
|
|
: Colors.white.withValues(alpha: 0.9),
|
|
borderRadius: BorderRadius.circular(
|
|
AppConfig.liquidGlassCornerRadius,
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(
|
|
AppConfig.liquidGlassCornerRadius,
|
|
),
|
|
border: Border.all(
|
|
color: isDark
|
|
? Colors.white.withValues(alpha: 0.2)
|
|
: Colors.black.withValues(alpha: 0.1),
|
|
width: 0.6,
|
|
),
|
|
),
|
|
),
|
|
_buildNavItems(primaryColor),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildNavItems(Color primaryColor) {
|
|
final items = [
|
|
_NavItem(Icons.menu_book_rounded, '📖', '诗词', 0),
|
|
_NavItem(Icons.psychology_rounded, '🎯', '答题', 1),
|
|
];
|
|
|
|
return Row(
|
|
children: List.generate(items.length, (index) {
|
|
return Expanded(
|
|
child: _buildNavItem(
|
|
items[index],
|
|
index == currentIndex,
|
|
primaryColor,
|
|
),
|
|
);
|
|
}),
|
|
);
|
|
}
|
|
|
|
Widget _buildNavItem(_NavItem item, bool isSelected, Color primaryColor) {
|
|
final themeController = Get.find<ThemeController>();
|
|
|
|
return Obx(() {
|
|
final isDark = themeController.isDarkMode;
|
|
final enableAnimation = themeController.enableAnimation;
|
|
|
|
return Material(
|
|
color: Colors.transparent,
|
|
child: InkWell(
|
|
onTap: () => onTap(item.index),
|
|
splashColor: Colors.transparent,
|
|
highlightColor: Colors.transparent,
|
|
borderRadius: BorderRadius.circular(
|
|
AppConfig.liquidGlassCornerRadius,
|
|
),
|
|
child: AnimatedContainer(
|
|
duration: enableAnimation
|
|
? const Duration(milliseconds: 250)
|
|
: Duration.zero,
|
|
curve: Curves.easeOutCubic,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
enableAnimation
|
|
? AnimatedScale(
|
|
scale: isSelected ? 1.1 : 1.0,
|
|
duration: const Duration(milliseconds: 200),
|
|
curve: Curves.easeOutCubic,
|
|
child: _buildIcon(
|
|
item,
|
|
isSelected,
|
|
isDark,
|
|
primaryColor,
|
|
),
|
|
)
|
|
: _buildIcon(item, isSelected, isDark, primaryColor),
|
|
const SizedBox(height: 3),
|
|
AnimatedDefaultTextStyle(
|
|
duration: enableAnimation
|
|
? const Duration(milliseconds: 200)
|
|
: Duration.zero,
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
fontWeight: isSelected ? FontWeight.w600 : FontWeight.w400,
|
|
color: isSelected
|
|
? primaryColor
|
|
: (isDark ? Colors.grey[400] : Colors.grey[600]),
|
|
letterSpacing: 0.15,
|
|
),
|
|
child: Text(item.label),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
});
|
|
}
|
|
|
|
Widget _buildIcon(
|
|
_NavItem item,
|
|
bool isSelected,
|
|
bool isDark,
|
|
Color primaryColor,
|
|
) {
|
|
return Icon(
|
|
item.icon,
|
|
size: 24,
|
|
color: isSelected
|
|
? primaryColor
|
|
: (isDark ? Colors.grey[400] : Colors.grey[600]),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _NavItem {
|
|
final IconData icon;
|
|
final String emoji;
|
|
final String label;
|
|
final int index;
|
|
|
|
_NavItem(this.icon, this.emoji, this.label, this.index);
|
|
}
|