fix: resolve navigation-cache regressions and todo UX

This commit is contained in:
qzl
2026-03-20 16:45:08 +08:00
parent 3f1858d733
commit 55f3805ee9
15 changed files with 160 additions and 105 deletions
@@ -268,11 +268,8 @@ class _TodoQuadrantsScreenState extends State<TodoQuadrantsScreen> {
Future<void> _completeTodo(TodoResponse todo) async {
try {
await _todoRepository.completeTodo(todo.id);
if (mounted) {
Toast.show(context, '已完成', type: ToastType.success);
}
try {
await _loadTodos();
await _loadTodos(showPageLoader: false);
} catch (_) {
// ignore reload error
}
@@ -283,14 +280,17 @@ class _TodoQuadrantsScreenState extends State<TodoQuadrantsScreen> {
}
}
void _navigateToDetail(TodoResponse todo) {
context.push(AppRoutes.todoDetail(todo.id));
Future<void> _navigateToDetail(TodoResponse todo) async {
final changed = await context.push<bool>(AppRoutes.todoDetail(todo.id));
if (changed == true) {
await _loadTodos(showPageLoader: false);
}
}
Future<void> _addTodo() async {
final created = await context.push<bool>(AppRoutes.todoCreate);
if (created == true) {
await _loadTodos();
await _loadTodos(showPageLoader: false);
}
}
@@ -326,25 +326,6 @@ class _TodoQuadrantsScreenState extends State<TodoQuadrantsScreen> {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
AppPressable(
borderRadius: BorderRadius.circular(AppRadius.full),
onTap: _loadTodos,
child: Container(
width: 36,
height: 36,
decoration: BoxDecoration(
color: AppColors.messageBtnWrap,
borderRadius: BorderRadius.circular(AppRadius.full),
border: Border.all(color: AppColors.messageBtnBorder),
),
child: const Icon(
LucideIcons.refreshCcw,
size: 18,
color: AppColors.slate600,
),
),
),
const SizedBox(width: AppSpacing.sm),
AppPressable(
borderRadius: BorderRadius.circular(AppRadius.full),
onTap: _addTodo,
@@ -448,6 +429,7 @@ class _TodoQuadrantsScreenState extends State<TodoQuadrantsScreen> {
horizontal: AppSpacing.sm,
),
child: _TodoItemWidget(
key: ValueKey(item.id),
item: item,
onComplete: () => _completeTodo(item),
onTap: () => _navigateToDetail(item),
@@ -603,6 +585,7 @@ class _TodoItemWidget extends StatefulWidget {
final VoidCallback onTap;
const _TodoItemWidget({
super.key,
required this.item,
required this.onComplete,
required this.onTap,