Correction fonctionnalité rear display

This commit is contained in:
2026-05-20 22:17:01 +02:00
parent d0045a7d61
commit 6515d8348d
2 changed files with 125 additions and 82 deletions
@@ -39,16 +39,22 @@ class CompactMoodView extends StatelessWidget {
), ),
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
if (lastEntry != null &&
DateFormat('yyyy-MM-dd').format(lastEntry.createdAt) ==
DateFormat('yyyy-MM-dd').format(DateTime.now()))
Expanded( Expanded(
child: Center( child: Row(
child: InkWell( crossAxisAlignment: CrossAxisAlignment.start,
onTap: () { children: [
// Logic to allow re-entry if needed, or just display // Section Dernière Humeur
}, Expanded(
child: Container( 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), padding: const EdgeInsets.all(20),
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color(0xFF000080).withOpacity(0.3), color: const Color(0xFF000080).withOpacity(0.3),
@@ -57,32 +63,41 @@ class CompactMoodView extends StatelessWidget {
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
const Text( Text(
'Humeur enregistrée', _getEmojiForEmotion(lastEntry.emotion, emotions),
style: TextStyle(color: Colors.white70, fontSize: 12), style: const TextStyle(fontSize: 40),
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
Text( Text(
lastEntry.emotion, lastEntry.emotion,
style: const TextStyle( style: const TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 24, fontSize: 20,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
const SizedBox(height: 10), const SizedBox(height: 5),
const Text( Text(
'Tapoter pour changer', DateFormat('dd/MM HH:mm').format(lastEntry.createdAt),
style: TextStyle(color: Colors.white54, fontSize: 10), style: const TextStyle(color: Colors.white54, fontSize: 12),
),
],
),
)
else
const Center(
child: Text(
'Aucune donnée',
style: TextStyle(color: Colors.white38),
),
), ),
], ],
), ),
), ),
), const VerticalDivider(color: Colors.white24, width: 32),
), // Section Choix de l'humeur
)
else
Expanded( Expanded(
flex: 1,
child: Column( child: Column(
children: [ children: [
const Text( const Text(
@@ -91,32 +106,43 @@ class CompactMoodView extends StatelessWidget {
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
Expanded( Expanded(
child: ListView.builder( child: GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 2.5,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
),
itemCount: emotions.length, itemCount: emotions.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final mood = emotions[index]; final mood = emotions[index];
return Padding( return ElevatedButton(
padding: const EdgeInsets.symmetric(vertical: 4),
child: ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(horizontal: 8),
backgroundColor: (mood['color'] as Color).withOpacity(0.2), backgroundColor: (mood['color'] as Color).withOpacity(0.2),
foregroundColor: Colors.white, foregroundColor: Colors.white,
elevation: 0, elevation: 0,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15), borderRadius: BorderRadius.circular(12),
), ),
), ),
onPressed: () { onPressed: () {
provider.addEmotion(mood['label'] as String, ""); provider.addEmotion(mood['label'] as String, "");
}, },
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text(mood['emoji'] as String, style: const TextStyle(fontSize: 20)), Text(mood['emoji'] as String, style: const TextStyle(fontSize: 18)),
const SizedBox(width: 15), const SizedBox(width: 8),
Text(mood['label'] as String), Flexible(
], child: Text(
mood['label'] as String,
style: const TextStyle(fontSize: 12),
overflow: TextOverflow.ellipsis,
), ),
), ),
],
),
); );
}, },
), ),
@@ -126,8 +152,22 @@ class CompactMoodView extends StatelessWidget {
), ),
], ],
), ),
),
],
),
); );
} }
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> { class _TrackerScreenState extends State<TrackerScreen> {
+7 -4
View File
@@ -93,10 +93,13 @@ class _HomeScreenState extends State<HomeScreen> {
final mediaQuery = MediaQuery.of(context); final mediaQuery = MediaQuery.of(context);
final size = mediaQuery.size; final size = mediaQuery.size;
// Détection de l'écran arrière du Xiaomi 17 Pro Max (976x596) // Détection de l'écran arrière du Xiaomi 17 Pro Max
// On vérifie les dimensions avec une petite marge de tolérance ou en mode paysage/portrait // On utilise les dimensions logiques observées (381x624)
final bool isXiaomiBackScreen = (size.width.toInt() == 976 && size.height.toInt() == 596) || final bool isXiaomiBackScreen =
(size.width.toInt() == 596 && size.height.toInt() == 976); // Mode Paysage (624x381)
((size.width >= 620 && size.width <= 630) && (size.height >= 375 && size.height <= 385)) ||
// Mode Portrait (381x624)
((size.width >= 375 && size.width <= 385) && (size.height >= 620 && size.height <= 630));
if (isXiaomiBackScreen) { if (isXiaomiBackScreen) {
return const Scaffold( return const Scaffold(