today_actions_card.dart
3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../controllers/today_controller.dart';
/// Figma: 每日行动 — 睡眠/健身/步数卡片,横向可滑动
class TodayActionsCard extends GetView<TodayController> {
const TodayActionsCard({super.key});
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 标题
const Padding(
padding: EdgeInsets.only(bottom: 12),
child: Text(
'每日行动',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
color: Color(0xFF0F0F11),
),
),
),
// 横向滑动卡片列表
SizedBox(
height: 110,
child: ListView.separated(
scrollDirection: Axis.horizontal,
itemCount: controller.dailyActions.length,
separatorBuilder: (_, __) => const SizedBox(width: 12),
itemBuilder: (_, i) {
final item = controller.dailyActions[i];
return _ActionCard(item: item);
},
),
),
],
);
}
}
class _ActionCard extends StatelessWidget {
final DailyActionItem item;
const _ActionCard({required this.item});
static const _brandColor = Color(0xFF845EEE);
static const _h1 = Color(0xFF0F0F11);
static const _h2 = Color(0xFF666666);
@override
Widget build(BuildContext context) {
return Container(
width: 140,
padding: const EdgeInsets.all(14),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 标题行
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
item.label,
style: const TextStyle(
fontSize: 13,
color: _brandColor,
fontWeight: FontWeight.w500,
),
),
const Icon(Icons.chevron_right, size: 16, color: _h2),
],
),
const Spacer(),
// 数值
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
item.value,
style: const TextStyle(
fontSize: 26,
fontWeight: FontWeight.w700,
color: _h1,
height: 1,
),
),
const SizedBox(width: 3),
Padding(
padding: const EdgeInsets.only(bottom: 2),
child: Text(
item.unit,
style: const TextStyle(
fontSize: 12,
color: _h2,
),
),
),
if (item.subValue != null) ...[
const SizedBox(width: 2),
Text(
item.subValue!,
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,
color: _h1,
height: 1,
),
),
const SizedBox(width: 3),
Padding(
padding: const EdgeInsets.only(bottom: 2),
child: Text(
item.subUnit ?? '',
style: const TextStyle(
fontSize: 12,
color: _h2,
),
),
),
],
],
),
],
),
);
}
}