feat: refine AI navigation and accessibility recovery

This commit is contained in:
2026-08-26 22:58:26 +08:00
parent c6f98b5445
commit 9ccbdfead4
15 changed files with 521 additions and 203 deletions
+96 -32
View File
@@ -3,9 +3,12 @@ import 'dart:async';
import 'package:miaoji_zhang/shared/services/shanghai_time.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:miaoji_zhang/shared/api/api_client.dart';
import 'package:miaoji_zhang/shared/api/business_api.dart';
import 'package:miaoji_zhang/shared/api/config_api.dart';
import 'package:miaoji_zhang/shared/services/current_ledger_store.dart';
import 'package:miaoji_zhang/shared/services/session_store.dart';
import 'package:miaoji_zhang/shared/theme/app_theme.dart';
import 'package:miaoji_zhang/shared/widgets/app_controls.dart';
import 'package:miaoji_zhang/shared/widgets/async_error_view.dart';
@@ -161,8 +164,7 @@ class _StatsPageState extends State<StatsPage> {
else ...[
_categoryCard(stats),
SizedBox(height: 10),
if (stats.analysis case final analysis?)
_analysisCard(analysis),
_reportCard(stats.analysis),
SizedBox(height: 10),
_trendCard(stats),
if (stats.byCategory.isNotEmpty) ...[
@@ -318,41 +320,103 @@ class _StatsPageState extends State<StatsPage> {
);
}
Widget _analysisCard(String text) {
return Container(
padding: const EdgeInsets.all(14),
decoration: BoxDecoration(
color: context.jz.aiBackground,
Widget _reportCard(String? analysis) {
final aiEnabled = SessionStore.instance.aiEnabled;
final accent = aiEnabled ? AppTheme.ai : AppTheme.primary;
final background = aiEnabled
? context.jz.aiBackground
: context.jz.primaryBackground;
final copy = analysis?.trim().isNotEmpty == true
? analysis!.trim()
: '查看本周期的收支变化、分类排行和消费高峰。';
final route = Uri(
path: '/report',
queryParameters: {'period': _period, 'date': _anchor.toIso8601String()},
).toString();
return Semantics(
button: true,
label: aiEnabled ? '查看 AI 报告' : '查看周期报告',
child: Material(
color: background,
borderRadius: BorderRadius.circular(14),
border: Border.all(color: AppTheme.ai.withValues(alpha: 0.12)),
),
child: Row(
children: [
Container(
width: 30,
height: 30,
child: InkWell(
onTap: () => context.push(route),
borderRadius: BorderRadius.circular(14),
child: Container(
padding: const EdgeInsets.all(14),
decoration: BoxDecoration(
color: context.jz.card,
borderRadius: BorderRadius.circular(10),
borderRadius: BorderRadius.circular(14),
border: Border.all(color: accent.withValues(alpha: 0.12)),
),
child: Icon(
Icons.auto_awesome_rounded,
size: 16,
color: AppTheme.ai,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 32,
height: 32,
decoration: BoxDecoration(
color: context.jz.card,
borderRadius: BorderRadius.circular(10),
),
child: Icon(
aiEnabled
? Icons.auto_awesome_rounded
: Icons.assessment_outlined,
size: 17,
color: accent,
),
),
SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
aiEnabled
? '${PublicConfigApi.companionName}的 AI 报告'
: '周期报告',
style: TextStyle(
fontSize: 12.5,
fontWeight: FontWeight.w700,
color: accent,
),
),
SizedBox(height: 5),
Text(
copy,
style: TextStyle(
fontSize: 12,
color: context.jz.text2,
height: 1.5,
),
),
SizedBox(height: 8),
Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'查看完整报告',
style: TextStyle(
fontSize: 11.5,
fontWeight: FontWeight.w700,
color: accent,
),
),
SizedBox(width: 2),
Icon(
Icons.chevron_right_rounded,
size: 17,
color: accent,
),
],
),
],
),
),
],
),
),
SizedBox(width: 10),
Expanded(
child: Text(
text,
style: TextStyle(
fontSize: 12,
color: context.jz.text2,
height: 1.5,
),
),
),
],
),
),
);
}