From 6515d8348d637b1f8af9d479e7944c3910c8ae9d Mon Sep 17 00:00:00 2001 From: Sam DEPARDIEU Date: Wed, 20 May 2026 22:17:01 +0200 Subject: [PATCH] =?UTF-8?q?Correction=20fonctionnalit=C3=A9=20rear=20displ?= =?UTF-8?q?ay?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tracker/screens/tracker_screen.dart | 196 +++++++++++------- mobile/lib/main.dart | 11 +- 2 files changed, 125 insertions(+), 82 deletions(-) diff --git a/mobile/lib/features/tracker/screens/tracker_screen.dart b/mobile/lib/features/tracker/screens/tracker_screen.dart index 72853a7..1bae517 100644 --- a/mobile/lib/features/tracker/screens/tracker_screen.dart +++ b/mobile/lib/features/tracker/screens/tracker_screen.dart @@ -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> emotions) { + try { + final match = emotions.firstWhere( + (e) => e['label'] == label, + ); + return match['emoji'] as String; + } catch (_) { + return '😐'; + } + } } class _TrackerScreenState extends State { diff --git a/mobile/lib/main.dart b/mobile/lib/main.dart index 9851757..26ba56d 100644 --- a/mobile/lib/main.dart +++ b/mobile/lib/main.dart @@ -93,10 +93,13 @@ class _HomeScreenState extends State { final mediaQuery = MediaQuery.of(context); final size = mediaQuery.size; - // Détection de l'écran arrière du Xiaomi 17 Pro Max (976x596) - // On vérifie les dimensions avec une petite marge de tolérance ou en mode paysage/portrait - final bool isXiaomiBackScreen = (size.width.toInt() == 976 && size.height.toInt() == 596) || - (size.width.toInt() == 596 && size.height.toInt() == 976); + // Détection de l'écran arrière du Xiaomi 17 Pro Max + // On utilise les dimensions logiques observées (381x624) + final bool isXiaomiBackScreen = + // 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) { return const Scaffold(