LifeMate — Personal, Family & Learning Companion
feat: add learning confidence and difficulty check-ins
davoodmehraban89 committed
Oct 5, 2026 at 16:25 UTC
0bac88b6471cb351528cb0bfed179d5cb0d5e651
1 file changed
+63
apps/lifemate/lib/phase4_ui.dart
+63
@@ -67,6 +67,67 @@ class _Phase4HubState extends State<Phase4Hub> {
67
}
68
}
69
70
+ Future<void> learningCheckin(Map<String, dynamic> goal) async {
71
+ var confidence = 3;
72
+ var difficulty = 3;
73
+ final note = TextEditingController();
74
+ final saved = await showDialog<bool>(
75
+ context: context,
76
+ builder: (dialogContext) => StatefulBuilder(
77
+ builder: (context, setLocalState) => AlertDialog(
78
+ title: Text('ثبت پیشرفت · ${goal['title'] ?? ''}'),
79
+ content: Column(
80
+ mainAxisSize: MainAxisSize.min,
81
+ children: [
82
+ _ScaleRow(
83
+ label: 'اعتماد',
84
+ value: confidence,
85
+ onChanged: (v) => setLocalState(() => confidence = v),
86
+ ),
87
+ _ScaleRow(
88
+ label: 'سختی',
89
+ value: difficulty,
90
+ onChanged: (v) => setLocalState(() => difficulty = v),
91
+ ),
92
+ const SizedBox(height: 12),
93
+ TextField(
94
+ controller: note,
95
+ maxLines: 2,
96
+ decoration: const InputDecoration(
97
+ labelText: 'یادداشت کوتاه (اختیاری)',
98
+ ),
99
+ ),
100
+ ],
101
+ ),
102
+ actions: [
103
+ TextButton(
104
+ onPressed: () => Navigator.pop(dialogContext, false),
105
+ child: const Text('انصراف'),
106
+ ),
107
+ FilledButton(
108
+ onPressed: () async {
109
+ await widget.api.createLearningCheckin(
110
+ learningGoalId: goal['id']?.toString(),
111
+ confidence: confidence,
112
+ difficulty: difficulty,
113
+ note: note.text.trim().isEmpty ? null : note.text.trim(),
114
+ );
115
+ if (dialogContext.mounted) Navigator.pop(dialogContext, true);
116
+ },
117
+ child: const Text('ثبت'),
118
+ ),
119
+ ],
120
+ ),
121
+ ),
122
+ );
123
+ note.dispose();
124
+ if (saved == true && mounted) {
125
+ ScaffoldMessenger.of(context).showSnackBar(
126
+ const SnackBar(content: Text('پیشرفت یادگیری ثبت شد.')),
127
+ );
128
+ }
129
+ }
130
+
131
Future<void> wellbeingCheckin() async {
132
var mood = 3;
133
var energy = 3;
@@ -258,6 +319,8 @@ class _Phase4HubState extends State<Phase4Hub> {
319
leading: const Icon(Icons.flag_circle_outlined),
320
title: Text(goal['title']?.toString() ?? ''),
321
subtitle: Text(goal['target']?.toString() ?? ''),
322
+ trailing: const Icon(Icons.add_chart_outlined),
323
+ onTap: () => learningCheckin(goal),
324
),
325
),
326
)