Vylepšení

This commit is contained in:
Matyáš Caras 2022-04-09 17:54:08 +02:00
parent 453b06e242
commit d106e78cb3
6 changed files with 111 additions and 86 deletions

7
CHANGELOG.md Normal file
View file

@ -0,0 +1,7 @@
# 0.1.1
- Přidán RefreshIndicator na obrazovku s jídelníčkem
- Přidáno odsazení od okrajů u jídelníčku
- Domovská obrazovka nyní zobrazuje zprávu, pokud na dnešní den není žádné jídlo v jídelníčku
- Upgrade knihovny
# 0.1.0
- První verze

View file

@ -49,7 +49,7 @@ class _BurzaPageState extends State<BurzaPage> {
Text("${b.pocet}x"), Text("${b.pocet}x"),
TextButton( TextButton(
onPressed: () { onPressed: () {
widget.canteen.objednatZBurzy(b).then((_) { widget.canteen.objednatZBurzy(b).then((a) {
nactiBurzu(); nactiBurzu();
}); });
}, },

View file

@ -28,6 +28,14 @@ class _HomePageState extends State<HomePage> {
setState(() { setState(() {
kredit = kr.kredit; kredit = kr.kredit;
dnes = jd; dnes = jd;
if (jd.jidla.isEmpty) {
obsah = [
const Text(
"Žádné jídlo pro dnešní den",
style: TextStyle(fontSize: 20),
)
];
}
for (var j in jd.jidla) { for (var j in jd.jidla) {
if (j.objednano) jidloDnes = j; if (j.objednano) jidloDnes = j;
obsah.add( obsah.add(
@ -99,30 +107,33 @@ class _HomePageState extends State<HomePage> {
physics: const AlwaysScrollableScrollPhysics(), physics: const AlwaysScrollableScrollPhysics(),
child: Center( child: Center(
child: SizedBox( child: SizedBox(
child: Column( child: SizedBox(
children: [ height: MediaQuery.of(context).size.height / 1.5,
const SizedBox( child: Column(
height: 5, children: [
), const SizedBox(
Text( height: 5,
"${widget.user} - $kredit", ),
style: const TextStyle(fontSize: 13), Text(
), "${widget.user} - $kredit",
const SizedBox( style: const TextStyle(fontSize: 13),
height: 10, ),
), const SizedBox(
Text( height: 10,
"Dnes je ${DateTime.now().day}. ${DateTime.now().month}.", ),
style: const TextStyle( Text(
fontSize: 20, fontWeight: FontWeight.bold), "Dnes je ${DateTime.now().day}. ${DateTime.now().month}.",
), style: const TextStyle(
Padding( fontSize: 20, fontWeight: FontWeight.bold),
padding: const EdgeInsets.only(top: 20), ),
child: Column(children: obsah), Padding(
), padding: const EdgeInsets.only(top: 20),
], child: Column(children: obsah),
),
],
),
width: MediaQuery.of(context).size.width - 50,
), ),
width: MediaQuery.of(context).size.width - 50,
), ),
), ),
), ),

View file

@ -182,66 +182,73 @@ class _JidelnicekPageState extends State<JidelnicekPage> {
appBar: AppBar( appBar: AppBar(
title: const Text('Jídelníček'), title: const Text('Jídelníček'),
), ),
body: Center( body: RefreshIndicator(
child: Column( child: Center(
children: [ child: SizedBox(
const SizedBox(height: 10), child: Column(
Text("Kredit: $kredit"), children: [
Row(mainAxisAlignment: MainAxisAlignment.center, children: [ const SizedBox(height: 10),
IconButton( Text("Kredit: $kredit"),
onPressed: () { Row(mainAxisAlignment: MainAxisAlignment.center, children: [
setState(() { IconButton(
den = den.subtract(const Duration(days: 1)); onPressed: () {
nactiJidlo(); setState(() {
}); den = den.subtract(const Duration(days: 1));
}, nactiJidlo();
icon: const Icon(Icons.arrow_left)), });
TextButton( },
onPressed: () async { icon: const Icon(Icons.arrow_left)),
var datePicked = await showDatePicker( TextButton(
context: context, onPressed: () async {
initialDate: den, var datePicked = await showDatePicker(
currentDate: den, context: context,
firstDate: DateTime(2019, 1, 1), initialDate: den,
lastDate: DateTime(den.year + 1, 12, 31), currentDate: den,
locale: const Locale("cs")); firstDate: DateTime(2019, 1, 1),
if (datePicked == null) return; lastDate: DateTime(den.year + 1, 12, 31),
setState(() { locale: const Locale("cs"));
den = datePicked; if (datePicked == null) return;
nactiJidlo(); setState(() {
}); den = datePicked;
}, nactiJidlo();
child: Text( });
"${den.day}. ${den.month}. ${den.year} - $denTydne")), },
IconButton( child: Text(
onPressed: () { "${den.day}. ${den.month}. ${den.year} - $denTydne")),
setState(() { IconButton(
den = den.add(const Duration(days: 1)); onPressed: () {
nactiJidlo(); setState(() {
}); den = den.add(const Duration(days: 1));
}, nactiJidlo();
icon: const Icon(Icons.arrow_right)), });
]), },
SingleChildScrollView( icon: const Icon(Icons.arrow_right)),
child: GestureDetector( ]),
child: Column(children: obsah), SingleChildScrollView(
onHorizontalDragEnd: (details) { physics: const AlwaysScrollableScrollPhysics(),
if (details.primaryVelocity?.compareTo(0) == -1) { child: GestureDetector(
setState(() { child: Column(children: obsah),
den = den.subtract(const Duration(days: 1)); onHorizontalDragEnd: (details) {
nactiJidlo(); if (details.primaryVelocity?.compareTo(0) == -1) {
}); setState(() {
} else { den = den.subtract(const Duration(days: 1));
setState(() { nactiJidlo();
den = den.add(const Duration(days: 1)); });
nactiJidlo(); } else {
}); setState(() {
} den = den.add(const Duration(days: 1));
}, nactiJidlo();
), });
) }
], },
),
)
],
),
width: MediaQuery.of(context).size.width - 50,
),
), ),
onRefresh: nactiJidlo,
), ),
); );
} }

View file

@ -28,7 +28,7 @@ packages:
name: canteenlib name: canteenlib
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.1.0-alpha.13" version: "0.1.0-alpha.14"
characters: characters:
dependency: transitive dependency: transitive
description: description:

View file

@ -6,7 +6,7 @@ publish_to: 'none'
# The following defines the version and build number for your application. # The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43 # A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +. # followed by an optional build number separated by a +.
version: 0.1.0+1 version: 0.1.1+2
environment: environment:
sdk: ">=2.16.1 <3.0.0" sdk: ">=2.16.1 <3.0.0"
@ -16,7 +16,7 @@ dependencies:
sdk: flutter sdk: flutter
flutter_localizations: flutter_localizations:
sdk: flutter sdk: flutter
canteenlib: ^0.1.0-alpha.13 canteenlib: ^0.1.0-alpha.14
cupertino_icons: ^1.0.2 cupertino_icons: ^1.0.2
connectivity_plus: ^2.2.1 connectivity_plus: ^2.2.1
flutter_secure_storage: ^5.0.2 flutter_secure_storage: ^5.0.2