Correction fonctionnalité rear display
This commit is contained in:
@@ -39,95 +39,135 @@ class CompactMoodView extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
if (lastEntry != null &&
|
||||
DateFormat('yyyy-MM-dd').format(lastEntry.createdAt) ==
|
||||
DateFormat('yyyy-MM-dd').format(DateTime.now()))
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
// Logic to allow re-entry if needed, or just display
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF000080).withOpacity(0.3),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Text(
|
||||
'Humeur enregistrée',
|
||||
style: TextStyle(color: Colors.white70, fontSize: 12),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
lastEntry.emotion,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
Expanded(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Section Dernière Humeur
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Column(
|
||||
children: [
|
||||
const Text(
|
||||
'Dernière humeur',
|
||||
style: TextStyle(color: Colors.white70, fontSize: 14),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
if (lastEntry != null)
|
||||
Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF000080).withOpacity(0.3),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
_getEmojiForEmotion(lastEntry.emotion, emotions),
|
||||
style: const TextStyle(fontSize: 40),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
lastEntry.emotion,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Text(
|
||||
DateFormat('dd/MM HH:mm').format(lastEntry.createdAt),
|
||||
style: const TextStyle(color: Colors.white54, fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
else
|
||||
const Center(
|
||||
child: Text(
|
||||
'Aucune donnée',
|
||||
style: TextStyle(color: Colors.white38),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const Text(
|
||||
'Tapoter pour changer',
|
||||
style: TextStyle(color: Colors.white54, fontSize: 10),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
const Text(
|
||||
'Comment allez-vous ?',
|
||||
style: TextStyle(color: Colors.white70, fontSize: 14),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: emotions.length,
|
||||
itemBuilder: (context, index) {
|
||||
final mood = emotions[index];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: (mood['color'] as Color).withOpacity(0.2),
|
||||
foregroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
provider.addEmotion(mood['label'] as String, "");
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Text(mood['emoji'] as String, style: const TextStyle(fontSize: 20)),
|
||||
const SizedBox(width: 15),
|
||||
Text(mood['label'] as String),
|
||||
],
|
||||
),
|
||||
const VerticalDivider(color: Colors.white24, width: 32),
|
||||
// Section Choix de l'humeur
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Column(
|
||||
children: [
|
||||
const Text(
|
||||
'Comment allez-vous ?',
|
||||
style: TextStyle(color: Colors.white70, fontSize: 14),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Expanded(
|
||||
child: GridView.builder(
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
childAspectRatio: 2.5,
|
||||
crossAxisSpacing: 10,
|
||||
mainAxisSpacing: 10,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
itemCount: emotions.length,
|
||||
itemBuilder: (context, index) {
|
||||
final mood = emotions[index];
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
backgroundColor: (mood['color'] as Color).withOpacity(0.2),
|
||||
foregroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
provider.addEmotion(mood['label'] as String, "");
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(mood['emoji'] as String, style: const TextStyle(fontSize: 18)),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(
|
||||
child: Text(
|
||||
mood['label'] as String,
|
||||
style: const TextStyle(fontSize: 12),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _getEmojiForEmotion(String label, List<Map<String, dynamic>> emotions) {
|
||||
try {
|
||||
final match = emotions.firstWhere(
|
||||
(e) => e['label'] == label,
|
||||
);
|
||||
return match['emoji'] as String;
|
||||
} catch (_) {
|
||||
return '😐';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _TrackerScreenState extends State<TrackerScreen> {
|
||||
|
||||
Reference in New Issue
Block a user