174 lines
4.8 KiB
Dart
174 lines
4.8 KiB
Dart
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';
|
|
|
|
class SpaceHome extends StatefulWidget {
|
|
const SpaceHome({super.key});
|
|
|
|
@override
|
|
State<SpaceHome> createState() => _SpaceHomeState();
|
|
}
|
|
|
|
class _SpaceHomeState extends State<SpaceHome> {
|
|
//TODO: in languageProvider
|
|
var tempTexts = [
|
|
"Bewerte jetzt deine DHBW-Kantine...",
|
|
"Rate your DHBW canteen now...",
|
|
"Évaluez votre cantine DHBW maintenant..."
|
|
];
|
|
|
|
//TODO: END-TODO
|
|
|
|
late Timer _timer;
|
|
late String text = "";
|
|
var index = 1;
|
|
|
|
var indexMap = {0: "fr", 1: "de", 2: "en"};
|
|
|
|
@override
|
|
void initState() {
|
|
text = tempTexts[0];
|
|
super.initState();
|
|
_timer = Timer.periodic(
|
|
const Duration(seconds: 5),
|
|
(timer) {
|
|
setState(() {
|
|
text = tempTexts[index];
|
|
index = (index + 1 >= tempTexts.length ? 0 : index + 1);
|
|
});
|
|
},
|
|
);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_timer.cancel();
|
|
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<LanguageProvider>(context, listen: false)
|
|
.languageData[indexMap[index]]["pageHome"]["noTimePopupTitle"],
|
|
style: TextStyle(fontSize: 25),
|
|
),
|
|
content: Text(
|
|
Provider.of<LanguageProvider>(context, listen: false)
|
|
.languageData[indexMap[index]]["pageHome"]
|
|
["noTimePopupContent"],
|
|
style: TextStyle(fontSize: 20),
|
|
),
|
|
actions: [
|
|
FilledButton(
|
|
child: Text(
|
|
Provider.of<LanguageProvider>(context, listen: false)
|
|
.languageData[indexMap[index]]["pageHome"]
|
|
["noTimePopupButton"],
|
|
style: TextStyle(fontSize: 17),
|
|
),
|
|
onPressed: () {
|
|
if (disableRateTimeDebug) {
|
|
Provider.of<SpaceProvider>(context, listen: false)
|
|
.setSelectedSpace(1);
|
|
}
|
|
Navigator.of(context).pop();
|
|
},
|
|
)
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: GestureDetector(
|
|
onTap: () {
|
|
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<SpaceProvider>(context, listen: false)
|
|
.setSelectedSpace(1);
|
|
}
|
|
},
|
|
child: Stack(
|
|
children: [
|
|
Center(
|
|
child: Container(
|
|
width: 1600,
|
|
height: 750,
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage("assets/backgrounds/Essen.jpg"),
|
|
fit: BoxFit.cover, // Deckt den gesamten Bildschirm ab
|
|
colorFilter: ColorFilter.mode(
|
|
Colors.white.withOpacity(0.2),
|
|
BlendMode.dstATop,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
text,
|
|
style: TextStyle(
|
|
fontSize: 70,
|
|
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),
|
|
),
|
|
SizedBox(
|
|
height: 50,
|
|
),
|
|
Text(
|
|
"11:30 - 14:30",
|
|
style: TextStyle(fontSize: 40),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|