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,95 +39,135 @@ class CompactMoodView extends StatelessWidget {
), ),
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
if (lastEntry != null && Expanded(
DateFormat('yyyy-MM-dd').format(lastEntry.createdAt) == child: Row(
DateFormat('yyyy-MM-dd').format(DateTime.now())) crossAxisAlignment: CrossAxisAlignment.start,
Expanded( children: [
child: Center( // Section Dernière Humeur
child: InkWell( Expanded(
onTap: () { flex: 1,
// Logic to allow re-entry if needed, or just display child: Column(
}, children: [
child: Container( const Text(
padding: const EdgeInsets.all(20), 'Dernière humeur',
decoration: BoxDecoration( style: TextStyle(color: Colors.white70, fontSize: 14),
color: const Color(0xFF000080).withOpacity(0.3), ),
borderRadius: BorderRadius.circular(20), const SizedBox(height: 20),
), if (lastEntry != null)
child: Column( Container(
mainAxisSize: MainAxisSize.min, padding: const EdgeInsets.all(20),
children: [ decoration: BoxDecoration(
const Text( color: const Color(0xFF000080).withOpacity(0.3),
'Humeur enregistrée', borderRadius: BorderRadius.circular(20),
style: TextStyle(color: Colors.white70, fontSize: 12), ),
), child: Column(
const SizedBox(height: 10), mainAxisSize: MainAxisSize.min,
Text( children: [
lastEntry.emotion, Text(
style: const TextStyle( _getEmojiForEmotion(lastEntry.emotion, emotions),
color: Colors.white, style: const TextStyle(fontSize: 40),
fontSize: 24, ),
fontWeight: FontWeight.bold, 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),
),
],
),
), ),
), ),
), 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(
'Comment allez-vous ?', 'Comment allez-vous ?',
style: TextStyle(color: Colors.white70, fontSize: 14), style: TextStyle(color: Colors.white70, fontSize: 14),
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
Expanded( Expanded(
child: ListView.builder( child: GridView.builder(
itemCount: emotions.length, gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
itemBuilder: (context, index) { crossAxisCount: 2,
final mood = emotions[index]; childAspectRatio: 2.5,
return Padding( crossAxisSpacing: 10,
padding: const EdgeInsets.symmetric(vertical: 4), mainAxisSpacing: 10,
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),
],
),
), ),
); 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> { 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(