Ajout fonctionnalité écran arriere

This commit is contained in:
2026-05-20 21:50:54 +02:00
parent 0074c28dcd
commit d0045a7d61
4 changed files with 135 additions and 0 deletions
@@ -10,6 +10,126 @@ class TrackerScreen extends StatefulWidget {
State<TrackerScreen> createState() => _TrackerScreenState();
}
class CompactMoodView extends StatelessWidget {
const CompactMoodView({super.key});
@override
Widget build(BuildContext context) {
final provider = Provider.of<EmotionProvider>(context);
final lastEntry = provider.entries.isNotEmpty ? provider.entries.first : null;
final emotions = [
{'label': 'Très bien', 'emoji': '😊', 'color': const Color(0xFF4CAF50)},
{'label': 'Bien', 'emoji': '🙂', 'color': const Color(0xFF8BC34A)},
{'label': 'Neutre', 'emoji': '😐', 'color': const Color(0xFFFFC107)},
{'label': 'Pas top', 'emoji': '🙁', 'color': const Color(0xFFFF9800)},
{'label': 'Stressé', 'emoji': '😫', 'color': const Color(0xFFF44336)},
];
return Container(
padding: const EdgeInsets.all(16),
color: const Color(0xFF000022),
child: Column(
children: [
const Text(
'CESIZen',
style: TextStyle(
color: Color(0xFF000080),
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
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,
),
),
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),
],
),
),
);
},
),
),
],
),
),
],
),
);
}
}
class _TrackerScreenState extends State<TrackerScreen> {
@override
void initState() {
+15
View File
@@ -90,6 +90,21 @@ class _HomeScreenState extends State<HomeScreen> {
@override
Widget build(BuildContext context) {
final authProvider = Provider.of<AuthProvider>(context);
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);
if (isXiaomiBackScreen) {
return const Scaffold(
body: SafeArea(
child: CompactMoodView(),
),
);
}
if (authProvider.isLoading && authProvider.user == null) {
return const Scaffold(