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),
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> {
+7 -4
View File
@@ -93,10 +93,13 @@ class _HomeScreenState extends State<HomeScreen> {
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(