generated from dellevin/template
适配深色模式
This commit is contained in:
@@ -8,34 +8,33 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 获取底部安全区域高度
|
||||
final bottomPadding = MediaQuery.of(context).padding.bottom;
|
||||
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
return Consumer<AppProvider>(
|
||||
builder: (context, provider, child) {
|
||||
return Container(
|
||||
// 高度:导航栏本身高度 + 底部安全距离 + 上下边距
|
||||
height: 64 + bottomPadding + 16,
|
||||
color: Colors.transparent,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Dock栏主体 - 悬浮效果
|
||||
Container(
|
||||
height: 56,
|
||||
margin: const EdgeInsets.symmetric(horizontal: 40),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: colors.surface,
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.08),
|
||||
color: Colors.black.withOpacity(isDark ? 0.3 : 0.08),
|
||||
blurRadius: 20,
|
||||
offset: const Offset(0, 4),
|
||||
spreadRadius: 0,
|
||||
),
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.04),
|
||||
color: Colors.black.withOpacity(isDark ? 0.15 : 0.04),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 2),
|
||||
spreadRadius: -2,
|
||||
@@ -45,19 +44,16 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
// 主页按钮
|
||||
_buildNavItem(
|
||||
colors: colors,
|
||||
icon: Icons.home_outlined,
|
||||
activeIcon: Icons.home,
|
||||
isActive: provider.bottomNavIndex == 0,
|
||||
onTap: () => provider.setBottomNavIndex(0),
|
||||
),
|
||||
|
||||
// 中间新增按钮
|
||||
_buildAddButton(context, provider),
|
||||
|
||||
// 我的按钮
|
||||
_buildNavItem(
|
||||
colors: colors,
|
||||
icon: Icons.person_outline,
|
||||
activeIcon: Icons.person,
|
||||
isActive: provider.bottomNavIndex == 2,
|
||||
@@ -66,7 +62,6 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
// 底部安全距离占位
|
||||
SizedBox(height: bottomPadding + 8),
|
||||
],
|
||||
),
|
||||
@@ -74,9 +69,9 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建导航项
|
||||
|
||||
Widget _buildNavItem({
|
||||
required ColorScheme colors,
|
||||
required IconData icon,
|
||||
required IconData activeIcon,
|
||||
required bool isActive,
|
||||
@@ -92,16 +87,16 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
child: Center(
|
||||
child: Icon(
|
||||
isActive ? activeIcon : icon,
|
||||
color: isActive ? const Color(0xFF1A1A1A) : const Color(0xFF999999),
|
||||
color: isActive ? colors.primary : colors.onSurface.withValues(alpha: 0.4),
|
||||
size: 26,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建中间新增按钮
|
||||
|
||||
Widget _buildAddButton(BuildContext context, AppProvider provider) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return GestureDetector(
|
||||
onTap: () => _showAddDialog(context, provider),
|
||||
onLongPress: () => _showQuickAddDialog(context, provider),
|
||||
@@ -109,25 +104,23 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
width: 44,
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF1A1A1A),
|
||||
color: colors.primary,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: Colors.white,
|
||||
color: colors.onPrimary,
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 长按快速添加 - 根据当前界面直接跳转到对应添加界面
|
||||
void _showQuickAddDialog(BuildContext context, AppProvider provider) {
|
||||
// 根据当前主标签页决定跳转到哪个添加界面
|
||||
final currentTab = provider.mainTabIndex;
|
||||
|
||||
|
||||
switch (currentTab) {
|
||||
case 0: // 观影标签页
|
||||
case 0:
|
||||
final statusMap = {
|
||||
0: 'watched',
|
||||
1: 'watching',
|
||||
@@ -140,7 +133,7 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
arguments: {'initialStatus': currentStatus},
|
||||
);
|
||||
break;
|
||||
case 1: // 阅读标签页
|
||||
case 1:
|
||||
final statusMap = {
|
||||
0: 'read',
|
||||
1: 'reading',
|
||||
@@ -153,7 +146,7 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
arguments: {'initialStatus': currentStatus},
|
||||
);
|
||||
break;
|
||||
case 2: // 笔记标签页
|
||||
case 2:
|
||||
Navigator.pushNamed(context, '/note-form');
|
||||
break;
|
||||
default:
|
||||
@@ -161,34 +154,33 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// 显示新增对话框
|
||||
void _showAddDialog(BuildContext context, AppProvider provider) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
backgroundColor: Colors.white,
|
||||
backgroundColor: colors.surface,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
|
||||
),
|
||||
builder: (BuildContext context) {
|
||||
final bottomColors = Theme.of(context).colorScheme;
|
||||
return SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// 顶部指示条
|
||||
Container(
|
||||
width: 40,
|
||||
height: 4,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFE0E0E0),
|
||||
color: bottomColors.onSurface.withValues(alpha: 0.15),
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
// 标题
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 24),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
@@ -196,15 +188,15 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF1A1A1A),
|
||||
color: bottomColors.onSurface,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// 选项列表
|
||||
_buildAddOption(
|
||||
colors: bottomColors,
|
||||
icon: Icons.movie_outlined,
|
||||
title: '添加观影',
|
||||
subtitle: '记录你看过的电影',
|
||||
@@ -224,6 +216,7 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
_buildAddOption(
|
||||
colors: bottomColors,
|
||||
icon: Icons.menu_book_outlined,
|
||||
title: '添加阅读',
|
||||
subtitle: '记录你读过的书',
|
||||
@@ -243,6 +236,7 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
_buildAddOption(
|
||||
colors: bottomColors,
|
||||
icon: Icons.note_outlined,
|
||||
title: '添加笔记',
|
||||
subtitle: '记录你的想法和笔记',
|
||||
@@ -259,8 +253,8 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建新增选项
|
||||
Widget _buildAddOption({
|
||||
required ColorScheme colors,
|
||||
required IconData icon,
|
||||
required String title,
|
||||
required String subtitle,
|
||||
@@ -276,13 +270,13 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
width: 44,
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFF5F5F5),
|
||||
color: colors.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
size: 22,
|
||||
color: const Color(0xFF666666),
|
||||
color: colors.onSurface.withValues(alpha: 0.6),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
@@ -292,26 +286,26 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF1A1A1A),
|
||||
color: colors.onSurface,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
subtitle,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF999999),
|
||||
color: colors.onSurface.withValues(alpha: 0.4),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icon(
|
||||
Icons.chevron_right,
|
||||
color: Color(0xFFCCCCCC),
|
||||
color: colors.onSurface.withValues(alpha: 0.25),
|
||||
size: 20,
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user