v0.1.6版本

This commit is contained in:
DelLevin-Home
2026-03-12 23:33:41 +08:00
parent 235b42c620
commit e181ebf9c6
36 changed files with 5450 additions and 2053 deletions

View File

@@ -11,7 +11,7 @@ class CustomBottomNavBar extends StatelessWidget {
return Consumer<AppProvider>(
builder: (context, provider, child) {
return Container(
height: 48,
height: 64,
decoration: const BoxDecoration(
color: Colors.white,
border: Border(
@@ -58,12 +58,19 @@ class CustomBottomNavBar extends StatelessWidget {
onTap: onTap,
child: Container(
color: Colors.transparent,
padding: const EdgeInsets.symmetric(vertical: 12),
padding: const EdgeInsets.symmetric(vertical: 10),
child: Center(
child: Icon(
isActive ? activeIcon : icon,
color: isActive ? const Color(0xFF1A1A1A) : const Color(0xFF999999),
size: 24,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 8),
decoration: BoxDecoration(
color: isActive ? const Color(0xFF1A1A1A) : Colors.transparent,
borderRadius: BorderRadius.circular(8),
),
child: Icon(
isActive ? activeIcon : icon,
color: isActive ? Colors.white : const Color(0xFF999999),
size: 22,
),
),
),
),
@@ -73,14 +80,15 @@ class CustomBottomNavBar extends StatelessWidget {
/// 构建中间新增按钮
Widget _buildAddButton(BuildContext context, AppProvider provider) {
return InkWell(
return GestureDetector(
onTap: () => _showAddDialog(context, provider),
onLongPress: () => _showQuickAddDialog(context, provider),
child: Container(
width: 40,
height: 40,
width: 44,
height: 44,
decoration: BoxDecoration(
color: const Color(0xFF1A1A1A),
borderRadius: BorderRadius.circular(8),
borderRadius: BorderRadius.circular(12),
),
child: const Icon(
Icons.add,
@@ -91,68 +99,202 @@ class CustomBottomNavBar extends StatelessWidget {
);
}
/// 长按快速添加 - 根据当前界面直接跳转到对应添加界面
void _showQuickAddDialog(BuildContext context, AppProvider provider) {
// 根据当前主标签页决定跳转到哪个添加界面
final currentTab = provider.mainTabIndex;
switch (currentTab) {
case 0: // 观影标签页
final statusMap = {
0: 'watched',
1: 'watching',
2: 'want_to_watch',
};
final currentStatus = statusMap[provider.movieStatusIndex] ?? 'want_to_watch';
Navigator.pushNamed(
context,
'/movie-form',
arguments: {'initialStatus': currentStatus},
);
break;
case 1: // 阅读标签页
final statusMap = {
0: 'read',
1: 'reading',
2: 'want_to_read',
};
final currentStatus = statusMap[provider.bookStatusIndex] ?? 'want_to_read';
Navigator.pushNamed(
context,
'/book-form',
arguments: {'initialStatus': currentStatus},
);
break;
case 2: // 笔记标签页
Navigator.pushNamed(context, '/note-form');
break;
default:
_showAddDialog(context, provider);
}
}
/// 显示新增对话框
void _showAddDialog(BuildContext context, AppProvider provider) {
showModalBottomSheet(
context: context,
backgroundColor: Colors.white,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
),
builder: (BuildContext context) {
return SafeArea(
child: Wrap(
children: [
ListTile(
leading: const Icon(Icons.movie, color: Colors.green),
title: const Text('添加观影'),
subtitle: const Text('记录你看过的电影'),
onTap: () {
Navigator.pop(context);
// 根据当前影视标签页的选中状态设置默认值
final statusMap = {
0: 'watched',
1: 'watching',
2: 'want_to_watch',
};
final currentStatus = statusMap[provider.movieStatusIndex] ?? 'want_to_watch';
Navigator.pushNamed(
context,
'/movie-form',
arguments: {'initialStatus': currentStatus},
);
},
),
ListTile(
leading: const Icon(Icons.menu_book, color: Colors.orange),
title: const Text('添加阅读'),
subtitle: const Text('记录你读过的书'),
onTap: () {
Navigator.pop(context);
// 根据当前阅读标签页的选中状态设置默认值
final statusMap = {
0: 'read',
1: 'reading',
2: 'want_to_read',
};
final currentStatus = statusMap[provider.bookStatusIndex] ?? 'want_to_read';
Navigator.pushNamed(
context,
'/book-form',
arguments: {'initialStatus': currentStatus},
);
},
),
ListTile(
leading: const Icon(Icons.note, color: Colors.blue),
title: const Text('添加笔记'),
subtitle: const Text('记录你的想法和笔记'),
onTap: () {
Navigator.pop(context);
// 直接打开添加笔记表单
Navigator.pushNamed(context, '/note-form');
},
),
],
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),
borderRadius: BorderRadius.circular(2),
),
),
const SizedBox(height: 20),
// 标题
const Padding(
padding: EdgeInsets.symmetric(horizontal: 24),
child: Row(
children: [
Text(
'新增记录',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: Color(0xFF1A1A1A),
),
),
],
),
),
const SizedBox(height: 16),
// 选项列表
_buildAddOption(
icon: Icons.movie_outlined,
title: '添加观影',
subtitle: '记录你看过的电影',
onTap: () {
Navigator.pop(context);
final statusMap = {
0: 'watched',
1: 'watching',
2: 'want_to_watch',
};
final currentStatus = statusMap[provider.movieStatusIndex] ?? 'want_to_watch';
Navigator.pushNamed(
context,
'/movie-form',
arguments: {'initialStatus': currentStatus},
);
},
),
_buildAddOption(
icon: Icons.menu_book_outlined,
title: '添加阅读',
subtitle: '记录你读过的书',
onTap: () {
Navigator.pop(context);
final statusMap = {
0: 'read',
1: 'reading',
2: 'want_to_read',
};
final currentStatus = statusMap[provider.bookStatusIndex] ?? 'want_to_read';
Navigator.pushNamed(
context,
'/book-form',
arguments: {'initialStatus': currentStatus},
);
},
),
_buildAddOption(
icon: Icons.note_outlined,
title: '添加笔记',
subtitle: '记录你的想法和笔记',
onTap: () {
Navigator.pop(context);
Navigator.pushNamed(context, '/note-form');
},
),
],
),
),
);
},
);
}
/// 构建新增选项
Widget _buildAddOption({
required IconData icon,
required String title,
required String subtitle,
required VoidCallback onTap,
}) {
return InkWell(
onTap: onTap,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 14),
child: Row(
children: [
Container(
width: 44,
height: 44,
decoration: BoxDecoration(
color: const Color(0xFFF5F5F5),
borderRadius: BorderRadius.circular(10),
),
child: Icon(
icon,
size: 22,
color: const Color(0xFF666666),
),
),
const SizedBox(width: 16),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Color(0xFF1A1A1A),
),
),
const SizedBox(height: 2),
Text(
subtitle,
style: const TextStyle(
fontSize: 13,
color: Color(0xFF999999),
),
),
],
),
),
const Icon(
Icons.chevron_right,
color: Color(0xFFCCCCCC),
size: 20,
),
],
),
),
);
}
}

View File

@@ -32,15 +32,19 @@ class _NoteListItemContent extends StatelessWidget {
return InkWell(
onTap: () {
Navigator.pushNamed(context, '/note-detail', arguments: note);
Navigator.pushNamed(context, '/note-detail', arguments: note).then((_) async {
// 返回时刷新笔记列表
await context.read<AppProvider>().loadNotes();
});
},
onLongPress: () => _showDeleteDialog(context),
child: Container(
margin: const EdgeInsets.only(bottom: 8),
padding: const EdgeInsets.all(12),
margin: const EdgeInsets.only(bottom: 12),
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: const Color(0xFFE5E5E5)),
color: const Color(0xFFFAFAFA),
borderRadius: BorderRadius.circular(12),
border: Border.all(color: const Color(0xFFE8E8E8), width: 0.5),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -50,26 +54,27 @@ class _NoteListItemContent extends StatelessWidget {
children: [
// 格式标记
Container(
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 1),
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
decoration: BoxDecoration(
color: const Color(0xFFF5F5F5),
border: Border.all(color: const Color(0xFFE5E5E5)),
color: Colors.white,
borderRadius: BorderRadius.circular(4),
border: Border.all(color: const Color(0xFFE8E8E8), width: 0.5),
),
child: Text(
isPlainText ? 'TXT' : 'MD',
style: const TextStyle(
fontSize: 9,
fontWeight: FontWeight.w500,
fontSize: 10,
fontWeight: FontWeight.w600,
color: Color(0xFF999999),
),
),
),
const SizedBox(width: 8),
const SizedBox(width: 10),
// 时间 - 使用缓存的格式化结果
Text(
_formatDateCached(note.updatedAt),
style: const TextStyle(
fontSize: 11,
fontSize: 12,
color: Color(0xFF999999),
),
),
@@ -78,14 +83,14 @@ class _NoteListItemContent extends StatelessWidget {
if (note.images.isNotEmpty) ...[
const Icon(
Icons.image_outlined,
size: 11,
size: 14,
color: Color(0xFF999999),
),
const SizedBox(width: 2),
const SizedBox(width: 4),
Text(
'${note.images.length}',
style: const TextStyle(
fontSize: 11,
fontSize: 12,
color: Color(0xFF999999),
),
),
@@ -93,33 +98,35 @@ class _NoteListItemContent extends StatelessWidget {
],
),
const SizedBox(height: 8),
const SizedBox(height: 12),
// 内容摘要(去除首尾空格)
Text(
note.summary.trim(),
style: TextStyle(
fontSize: 14,
fontSize: 15,
color: const Color(0xFF1A1A1A),
height: isPlainText ? 1.6 : 1.5,
height: isPlainText ? 1.7 : 1.6,
),
maxLines: isPlainText ? 4 : 3,
overflow: TextOverflow.ellipsis,
),
// 图片预览区域(显示前2张图片)
// 图片预览区域(显示前4张图片)
if (note.images.isNotEmpty) ...[
const SizedBox(height: 10),
const SizedBox(height: 12),
SizedBox(
height: 60,
height: 70,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: note.images.length > 2 ? 2 : note.images.length,
physics: const NeverScrollableScrollPhysics(), // 禁用滚动,提高性能
itemCount: note.images.length > 4 ? 4 : note.images.length,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
return _NoteImage(
imagePath: note.images[index],
index: index,
totalCount: note.images.length,
showMore: index == 3 && note.images.length > 4,
);
},
),
@@ -128,21 +135,22 @@ class _NoteListItemContent extends StatelessWidget {
// 底部标签
if (note.tags.isNotEmpty) ...[
const SizedBox(height: 10),
const SizedBox(height: 12),
Wrap(
spacing: 6,
runSpacing: 6,
spacing: 8,
runSpacing: 8,
children: note.tags.take(3).map((tag) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
decoration: BoxDecoration(
color: const Color(0xFFF5F5F5),
border: Border.all(color: const Color(0xFFE5E5E5)),
color: Colors.white,
borderRadius: BorderRadius.circular(6),
border: Border.all(color: const Color(0xFFE8E8E8), width: 0.5),
),
child: Text(
tag,
style: const TextStyle(
fontSize: 11,
fontSize: 12,
color: Color(0xFF666666),
),
),
@@ -163,23 +171,50 @@ class _NoteListItemContent extends StatelessWidget {
builder: (context) => AlertDialog(
backgroundColor: Colors.white,
elevation: 0,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero),
title: const Text('确认删除'),
content: const Text('确定要删除这条笔记吗?'),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
title: const Text(
'确认删除',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
content: const Text(
'确定要删除这条笔记吗?删除后可在回收站恢复。',
style: TextStyle(
fontSize: 14,
color: Color(0xFF666666),
height: 1.5,
),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('取消', style: TextStyle(color: Color(0xFF666666))),
style: TextButton.styleFrom(
foregroundColor: const Color(0xFF666666),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
),
child: const Text('取消'),
),
TextButton(
ElevatedButton(
onPressed: () async {
await context.read<AppProvider>().removeNote(note.id);
Navigator.pop(context);
ToastUtil.show(context, '已删除');
},
child: const Text('删除', style: TextStyle(color: Colors.red)),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red,
foregroundColor: Colors.white,
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
),
child: const Text('删除'),
),
],
actionsPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
),
);
}
@@ -189,33 +224,52 @@ class _NoteListItemContent extends StatelessWidget {
class _NoteImage extends StatelessWidget {
final String imagePath;
final int index;
final int totalCount;
final bool showMore;
const _NoteImage({
required this.imagePath,
required this.index,
this.totalCount = 0,
this.showMore = false,
});
@override
Widget build(BuildContext context) {
return Container(
width: 60,
height: 60,
margin: EdgeInsets.only(right: index < 1 ? 8 : 0),
width: 70,
height: 70,
margin: EdgeInsets.only(right: index < 3 ? 10 : 0),
decoration: BoxDecoration(
border: Border.all(color: const Color(0xFFE5E5E5)),
),
child: Image.file(
File(imagePath),
fit: BoxFit.cover,
// 使用低内存缓存
cacheWidth: 120,
cacheHeight: 120,
errorBuilder: (_, __, ___) => const Icon(
Icons.broken_image,
size: 24,
color: Color(0xFFCCCCCC),
),
borderRadius: BorderRadius.circular(8),
border: Border.all(color: const Color(0xFFE8E8E8), width: 0.5),
),
clipBehavior: Clip.antiAlias,
child: showMore
? Container(
color: const Color(0xFFF5F5F5),
child: Center(
child: Text(
'+${totalCount - 4}',
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Color(0xFF666666),
),
),
),
)
: Image.file(
File(imagePath),
fit: BoxFit.cover,
cacheWidth: 140,
cacheHeight: 140,
errorBuilder: (_, __, ___) => const Icon(
Icons.broken_image,
size: 28,
color: Color(0xFFCCCCCC),
),
),
);
}
}