99 lines
3.0 KiB
Dart
99 lines
3.0 KiB
Dart
import 'dart:ui';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:lucide_icons/lucide_icons.dart';
|
|
|
|
class GlassBottomNav extends StatelessWidget {
|
|
final int currentIndex;
|
|
final Function(int) onTap;
|
|
|
|
const GlassBottomNav({
|
|
super.key,
|
|
required this.currentIndex,
|
|
required this.onTap,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ClipRect(
|
|
child: BackdropFilter(
|
|
filter: ImageFilter.blur(sigmaX: 20, sigmaY: 20),
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.black.withOpacity(0.2), // bg-black/20
|
|
border: Border(top: BorderSide(color: Colors.white.withOpacity(0.1))),
|
|
),
|
|
padding: EdgeInsets.only(
|
|
bottom: MediaQuery.of(context).padding.bottom + 12,
|
|
top: 12,
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: [
|
|
_buildNavItem(0, LucideIcons.compass, '发现'),
|
|
_buildNavItem(1, LucideIcons.playCircle, '剧本'),
|
|
_buildNavItem(2, LucideIcons.radio, '操控'),
|
|
_buildNavItem(3, LucideIcons.user, '我的'),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildNavItem(int index, IconData icon, String label) {
|
|
bool isActive = currentIndex == index;
|
|
return GestureDetector(
|
|
onTap: () => onTap(index),
|
|
behavior: HitTestBehavior.opaque,
|
|
child: SizedBox(
|
|
width: 60,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
if (isActive)
|
|
Container(
|
|
width: 40,
|
|
height: 40,
|
|
decoration: BoxDecoration(
|
|
color: Colors.white.withOpacity(0.1),
|
|
shape: BoxShape.circle,
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.white.withOpacity(0.1),
|
|
blurRadius: 10,
|
|
spreadRadius: 5,
|
|
)
|
|
]
|
|
),
|
|
),
|
|
AnimatedScale(
|
|
scale: isActive ? 1.1 : 1.0,
|
|
duration: const Duration(milliseconds: 300),
|
|
child: Icon(
|
|
icon,
|
|
size: 26,
|
|
color: isActive ? Colors.white : Colors.white.withOpacity(0.5),
|
|
shadows: isActive ? [const BoxShadow(color: Colors.white, blurRadius: 10)] : null,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
label,
|
|
style: TextStyle(
|
|
fontSize: 10,
|
|
color: isActive ? Colors.white : Colors.white.withOpacity(0.4),
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|