From df56c82c690e2d910c2435bc0e0cee6682798b48 Mon Sep 17 00:00:00 2001 From: Jonas Braus Date: Tue, 26 Nov 2024 16:13:10 +0100 Subject: [PATCH] nix bewerten vor 11:30 nach 14:30 --- lib/providers/languageProvider.dart | 12 +++- lib/spaces/spaceHome.dart | 85 +++++++++++++++++++++++++++-- 2 files changed, 90 insertions(+), 7 deletions(-) diff --git a/lib/providers/languageProvider.dart b/lib/providers/languageProvider.dart index 61cfbca..0e61252 100644 --- a/lib/providers/languageProvider.dart +++ b/lib/providers/languageProvider.dart @@ -24,7 +24,9 @@ class LanguageProvider extends ChangeNotifier { }, "pageHome": { - + "noTimePopupTitle": "Du kannst gerade nicht bewerten!", + "noTimePopupContent": "Du kannst nur zu den Essenszeiten zwischen 11:30 und 14:30 bewerten!", + "noTimePopupButton": "OK" }, "pageService": { @@ -71,7 +73,9 @@ class LanguageProvider extends ChangeNotifier { "question2": "Quality", }, "pageHome": { - + "noTimePopupTitle": "You cannot rate right now!", + "noTimePopupContent": "You can only rate during meal times between 11:30 AM and 2:30 PM!", + "noTimePopupButton": "OK" }, "pageService": { "question1": "Question1", @@ -114,7 +118,9 @@ class LanguageProvider extends ChangeNotifier { "question2": "Qualité", }, "pageHome": { - + "noTimePopupTitle": "Vous ne pouvez pas évaluer pour le moment !", + "noTimePopupContent": "Vous ne pouvez évaluer que pendant les heures de repas entre 11h30 et 14h30 !", + "noTimePopupButton": "D'ACCORD" }, "pageService": { "question1": "Question1", diff --git a/lib/spaces/spaceHome.dart b/lib/spaces/spaceHome.dart index 76ce890..02723df 100644 --- a/lib/spaces/spaceHome.dart +++ b/lib/spaces/spaceHome.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:mensaapp/providers/languageProvider.dart'; import 'package:mensaapp/providers/spaceProvider.dart'; import 'package:provider/provider.dart'; @@ -25,6 +26,8 @@ class _SpaceHomeState extends State { late String text = ""; var index = 1; + var indexMap = {0: "fr", 1: "de", 2: "en"}; + @override void initState() { text = tempTexts[0]; @@ -46,12 +49,73 @@ class _SpaceHomeState extends State { super.dispose(); } + // only for test + var disableRateTimeDebug = false; + + // end only for test + void _showNotRateTimeDialog(BuildContext context) { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20), + ), + title: Text( + Provider.of(context, listen: false) + .languageData[indexMap[index]]["pageHome"]["noTimePopupTitle"], + style: TextStyle(fontSize: 25), + ), + content: Text( + Provider.of(context, listen: false) + .languageData[indexMap[index]]["pageHome"] + ["noTimePopupContent"], + style: TextStyle(fontSize: 20), + ), + actions: [ + FilledButton( + child: Text( + Provider.of(context, listen: false) + .languageData[indexMap[index]]["pageHome"] + ["noTimePopupButton"], + style: TextStyle(fontSize: 17), + ), + onPressed: () { + if (disableRateTimeDebug) { + Provider.of(context, listen: false) + .setSelectedSpace(1); + } + Navigator.of(context).pop(); + }, + ) + ], + ); + }, + ); + } + @override Widget build(BuildContext context) { return Scaffold( body: GestureDetector( onTap: () { - Provider.of(context, listen: false).setSelectedSpace(1); + var now = DateTime.now(); + + if (!(now + .difference( + DateTime(now.year, now.month, now.day, 11, 30)) + .inMinutes > + 0 && + now + .difference( + DateTime(now.year, now.month, now.day, 14, 30)) + .inMinutes < + 0)) { + _showNotRateTimeDialog(context); + } else { + Provider.of(context, listen: false) + .setSelectedSpace(1); + } }, child: Stack( children: [ @@ -83,11 +147,24 @@ class _SpaceHomeState extends State { fontWeight: FontWeight.bold, color: Theme.of(context).colorScheme.primary), ), - const SizedBox(height: 40,), - Icon(Icons.touch_app, size: 150, color: Colors.black.withOpacity(0.5),) + const SizedBox( + height: 40, + ), + Icon( + Icons.touch_app, + size: 150, + color: Colors.black.withOpacity(0.5), + ), + SizedBox( + height: 50, + ), + Text( + "11:30 - 14:30", + style: TextStyle(fontSize: 40), + ), ], ), - ) + ), ], ), ),