fix: 7处修复 - 溢出/黑屏/趋势图/欢迎卡片/抽屉

This commit is contained in:
MingNian
2026-06-03 16:14:20 +08:00
parent 7953cca15d
commit 711b583aaf
6 changed files with 372 additions and 146 deletions

View File

@@ -51,19 +51,33 @@ class HealthDrawer extends ConsumerWidget {
child: Text('健康概览', style: Theme.of(context).textTheme.labelMedium!.copyWith(fontWeight: FontWeight.w600)),
),
latestHealth.when(
data: (data) => Column(children: [
_HealthMetric(icon: Icons.favorite, label: '血压', value: _bpText(data['BloodPressure']), onTap: () => pushRoute(ref, 'trend', params: {'type': 'blood_pressure'})),
_HealthMetric(icon: Icons.monitor_heart, label: '心率', value: _metricText(data['HeartRate'], '次/分'), onTap: () => pushRoute(ref, 'trend', params: {'type': 'heart_rate'})),
_HealthMetric(icon: Icons.bloodtype, label: '血糖', value: _metricText(data['Glucose'], 'mmol/L'), onTap: () => pushRoute(ref, 'trend', params: {'type': 'glucose'})),
_HealthMetric(icon: Icons.air, label: '血氧', value: _metricText(data['SpO2'], '%'), onTap: () => pushRoute(ref, 'trend', params: {'type': 'spo2'})),
]),
data: (data) => Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Wrap(
spacing: 8,
runSpacing: 8,
children: [
_HealthMetricChip(icon: Icons.favorite, label: '血压', value: _bpText(data['BloodPressure']), onTap: () => pushRoute(ref, 'trend', params: {'type': 'blood_pressure'})),
_HealthMetricChip(icon: Icons.monitor_heart, label: '心率', value: _metricText(data['HeartRate'], ''), onTap: () => pushRoute(ref, 'trend', params: {'type': 'heart_rate'})),
_HealthMetricChip(icon: Icons.bloodtype, label: '血糖', value: _metricText(data['Glucose'], ''), onTap: () => pushRoute(ref, 'trend', params: {'type': 'glucose'})),
_HealthMetricChip(icon: Icons.air, label: '血氧', value: _metricText(data['SpO2'], '%'), onTap: () => pushRoute(ref, 'trend', params: {'type': 'spo2'})),
],
),
),
loading: () => const Padding(padding: EdgeInsets.all(16), child: Center(child: SizedBox(width: 20, height: 20, child: CircularProgressIndicator(strokeWidth: 2)))),
error: (_, _) => Column(children: [
_HealthMetric(icon: Icons.favorite, label: '血压', value: '--'),
_HealthMetric(icon: Icons.monitor_heart, label: '心率', value: '--'),
_HealthMetric(icon: Icons.bloodtype, label: '血糖', value: '--'),
_HealthMetric(icon: Icons.air, label: '血氧', value: '--'),
]),
error: (_, _) => Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Wrap(
spacing: 8,
runSpacing: 8,
children: [
const _HealthMetricChip(icon: Icons.favorite, label: '血压', value: '--'),
const _HealthMetricChip(icon: Icons.monitor_heart, label: '心率', value: '--'),
const _HealthMetricChip(icon: Icons.bloodtype, label: '血糖', value: '--'),
const _HealthMetricChip(icon: Icons.air, label: '血氧', value: '--'),
],
),
),
),
const Divider(),
@@ -136,15 +150,34 @@ class _DrawerItem extends StatelessWidget {
@override Widget build(BuildContext context) => ListTile(leading: Icon(icon, size: 20, color: const Color(0xFF666666)), title: Text(label, style: const TextStyle(fontSize: 16)), onTap: onTap, dense: true);
}
class _HealthMetric extends StatelessWidget {
final IconData icon; final String label; final String value; final VoidCallback? onTap;
const _HealthMetric({required this.icon, required this.label, required this.value, this.onTap});
@override Widget build(BuildContext context) => ListTile(
leading: Icon(icon, size: 18, color: const Color(0xFF635BFF)),
title: Text(label, style: const TextStyle(fontSize: 16, color: Color(0xFF1A1A1A))),
trailing: Text(value, style: TextStyle(fontSize: 16, color: value == '--' ? const Color(0xFF999999) : const Color(0xFF1A1A1A))),
dense: true,
class _HealthMetricChip extends StatelessWidget {
final IconData icon;
final String label;
final String value;
final VoidCallback? onTap;
const _HealthMetricChip({required this.icon, required this.label, required this.value, this.onTap});
@override
Widget build(BuildContext context) => GestureDetector(
onTap: onTap,
child: Container(
width: 80,
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: const Color(0xFFEDEBFF)),
),
child: Row(mainAxisSize: MainAxisSize.min, children: [
Icon(icon, size: 14, color: const Color(0xFF635BFF)),
const SizedBox(width: 4),
Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [
Text(label, style: TextStyle(fontSize: 10, color: Colors.grey[600])),
Text(value, style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w600, color: Color(0xFF1A1A1A))),
]),
]),
),
);
}
@@ -156,15 +189,15 @@ class _ConversationItem extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
return Container(
margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
decoration: BoxDecoration(
color: const Color(0xFFF8F7FF),
borderRadius: BorderRadius.circular(10),
),
child: ListTile(
leading: Container(
width: 36,
height: 36,
width: 32,
height: 32,
decoration: BoxDecoration(
color: const Color(0xFFEDEBFF),
borderRadius: BorderRadius.circular(8),
@@ -172,13 +205,12 @@ class _ConversationItem extends ConsumerWidget {
child: Icon(_getAgentIcon(item.agent), size: 16, color: const Color(0xFF635BFF)),
),
title: Text(item.title, maxLines: 1, overflow: TextOverflow.ellipsis, style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w500)),
subtitle: Text(item.lastMessage, maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 11, color: Colors.grey[500])),
subtitle: Text(item.lastMessage, maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 10, color: Colors.grey[500])),
trailing: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Text(_formatTime(item.updatedAt), style: const TextStyle(fontSize: 9, color: Color(0xFFCCCCCC))),
const SizedBox(height: 2),
PopupMenuButton<int>(
icon: const Icon(Icons.more_vert, size: 14, color: Color(0xFFCCCCCC)),
itemBuilder: (_) => [