From bf183a379e95e8f6baeb369cff4a54bb81431e07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maty=C3=A1=C5=A1=20Caras?= Date: Mon, 25 Apr 2022 20:35:57 +0200 Subject: [PATCH] =?UTF-8?q?UI=20Vylep=C5=A1en=C3=AD=20(#3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.dart | 254 ++++++++++++++++++++------------------- lib/okna/burza.dart | 2 +- lib/okna/jidelnicek.dart | 2 +- 3 files changed, 132 insertions(+), 126 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 680ed5c..7699afc 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -121,130 +121,136 @@ class _LoginPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - title: const Text("Přihlášení"), - ), - body: Center( - child: SizedBox( - width: MediaQuery.of(context).size.width - 50, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text( - 'OpenCanteen', - textAlign: TextAlign.center, - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 40), - ), - const Text( - 'Přihlášení', - textAlign: TextAlign.center, - ), - TextField( - controller: userControl, - autofillHints: const [AutofillHints.username], - decoration: - const InputDecoration(labelText: 'Uživatelské jméno'), - ), - TextField( - autofillHints: const [AutofillHints.password], - decoration: const InputDecoration(labelText: 'Heslo'), - controller: passControl, - obscureText: true, - ), - TextField( - autofillHints: const [AutofillHints.url], - decoration: const InputDecoration(labelText: 'iCanteen URL'), - keyboardType: TextInputType.url, - controller: canteenControl, - ), - Row(mainAxisAlignment: MainAxisAlignment.center, children: [ - Switch( - value: rememberMe, - onChanged: (value) { - setState(() { - rememberMe = value; - }); - }), - const Text("Zapamatovat si mě") - ]), - TextButton( - onPressed: () async { - if (canteenControl.text.contains("http://")) { - // kontrolujeme šifrované spojení - var d = await showDialog( - context: context, - builder: (c) => AlertDialog( - title: const Text("Varování!"), - content: const SingleChildScrollView( - child: Text( - "Snažíte se přihlásit přes nešifrované spojení HTTP, jste si jisti, že tak chcete učinit?")), - actions: [ - TextButton( - onPressed: () => Navigator.pop(c, true), - child: const Text("Ano")), - TextButton( - onPressed: () => Navigator.pop(c, false), - child: const Text("Ne, změnit")) - ], - )); - if (!d!) return; - } - - // souhlas - const storage = FlutterSecureStorage(); - var odsouhlasil = await storage.read(key: "oc_souhlas"); - if (odsouhlasil == null || odsouhlasil != "ano") { - var d = await showDialog( - context: context, - builder: (c) => AlertDialog( - title: const Text("Pozor"), - content: const SingleChildScrollView( - child: Text( - "Toto není oficiální aplikace k ovládání iCanteen. Autor neručí za ztráty nebo nefunkčnost v souvislosti s používáním této aplikace. Tato zpráva se znovu neukáže.")), - actions: [ - TextButton( - onPressed: () => Navigator.pop(c, true), - child: const Text("Souhlasím")), - TextButton( - onPressed: () => Navigator.pop(c, false), - child: const Text("Nesouhlasím")) - ], - )); - if (!d!) return; - await storage.write(key: "oc_souhlas", value: "ano"); - } - - var canteen = Canteen(canteenControl.text); - var l = - await canteen.login(userControl.text, passControl.text); - if (!l) { - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text( - "Přihlášení se nezdařilo, zkontrolujte údaje"), - ), - ); - return; - } - if (rememberMe) { - LoginManager.setDetails(userControl.text, - passControl.text, canteenControl.text); - } - Navigator.pushReplacement( - context, - MaterialPageRoute( - builder: (context) => JidelnicekPage( - user: userControl.text, - canteen: canteen, - )), - ); - }, - child: const Text("Přihlásit se")), - ], - ), + appBar: AppBar( + title: const Text("Přihlášení"), ), - ), - ); + body: Center( + child: SingleChildScrollView( + child: SizedBox( + width: MediaQuery.of(context).size.width - 50, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + 'OpenCanteen', + textAlign: TextAlign.center, + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 40), + ), + const Text( + 'Přihlášení', + textAlign: TextAlign.center, + ), + TextField( + controller: userControl, + autofillHints: const [AutofillHints.username], + decoration: + const InputDecoration(labelText: 'Uživatelské jméno'), + ), + TextField( + autofillHints: const [AutofillHints.password], + decoration: const InputDecoration(labelText: 'Heslo'), + controller: passControl, + obscureText: true, + ), + TextField( + autofillHints: const [AutofillHints.url], + decoration: + const InputDecoration(labelText: 'iCanteen URL'), + keyboardType: TextInputType.url, + controller: canteenControl, + ), + Row(mainAxisAlignment: MainAxisAlignment.center, children: [ + Switch( + value: rememberMe, + onChanged: (value) { + setState(() { + rememberMe = value; + }); + }), + const Text("Zapamatovat si mě") + ]), + TextButton( + onPressed: () async { + if (canteenControl.text.contains("http://")) { + // kontrolujeme šifrované spojení + var d = await showDialog( + context: context, + builder: (c) => AlertDialog( + title: const Text("Varování!"), + content: const SingleChildScrollView( + child: Text( + "Snažíte se přihlásit přes nešifrované spojení HTTP, jste si jisti, že tak chcete učinit?")), + actions: [ + TextButton( + onPressed: () => + Navigator.pop(c, true), + child: const Text("Ano")), + TextButton( + onPressed: () => + Navigator.pop(c, false), + child: const Text("Ne, změnit")) + ], + )); + if (!d!) return; + } + + // souhlas + const storage = FlutterSecureStorage(); + var odsouhlasil = await storage.read(key: "oc_souhlas"); + if (odsouhlasil == null || odsouhlasil != "ano") { + var d = await showDialog( + context: context, + builder: (c) => AlertDialog( + title: const Text("Pozor"), + content: const SingleChildScrollView( + child: Text( + "Toto není oficiální aplikace k ovládání iCanteen. Autor neručí za ztráty nebo nefunkčnost v souvislosti s používáním této aplikace. Tato zpráva se znovu neukáže.")), + actions: [ + TextButton( + onPressed: () => + Navigator.pop(c, true), + child: const Text("Souhlasím")), + TextButton( + onPressed: () => + Navigator.pop(c, false), + child: const Text("Nesouhlasím")) + ], + )); + if (!d!) return; + await storage.write(key: "oc_souhlas", value: "ano"); + } + + var canteen = Canteen(canteenControl.text); + var l = await canteen.login( + userControl.text, passControl.text); + if (!l) { + ScaffoldMessenger.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text( + "Přihlášení se nezdařilo, zkontrolujte údaje"), + ), + ); + return; + } + if (rememberMe) { + LoginManager.setDetails(userControl.text, + passControl.text, canteenControl.text); + } + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) => JidelnicekPage( + user: userControl.text, + canteen: canteen, + )), + ); + }, + child: const Text("Přihlásit se")), + ], + ), + ), + ), + )); } } diff --git a/lib/okna/burza.dart b/lib/okna/burza.dart index 8294074..f5787c6 100644 --- a/lib/okna/burza.dart +++ b/lib/okna/burza.dart @@ -126,7 +126,7 @@ class _BurzaPageState extends State { SingleChildScrollView( physics: const AlwaysScrollableScrollPhysics(), child: SizedBox( - height: MediaQuery.of(context).size.height - 120, + height: MediaQuery.of(context).size.height / 1.3, child: Column(children: obsah), ), ) diff --git a/lib/okna/jidelnicek.dart b/lib/okna/jidelnicek.dart index f5c052a..7b70ba1 100644 --- a/lib/okna/jidelnicek.dart +++ b/lib/okna/jidelnicek.dart @@ -283,7 +283,7 @@ class _JidelnicekPageState extends State { .onPrimary .withOpacity(0), child: Column(children: obsah), - height: MediaQuery.of(context).size.height - 160, + height: MediaQuery.of(context).size.height / 1.3, ), onHorizontalDragEnd: (details) { if (details.primaryVelocity?.compareTo(0) == -1) {