Práce na #4 + pár vylepšení

This commit is contained in:
Matyáš Caras 2022-04-26 18:20:42 +02:00
parent de7f9a7caa
commit 0c96776a0e
13 changed files with 151 additions and 7 deletions

4
.fossa.yml Normal file
View File

@ -0,0 +1,4 @@
version: 3
targets:
only:
- type: pub

View File

@ -1,3 +1,4 @@
# 0.2.0
# 0.1.1
- Přidán RefreshIndicator na obrazovku s jídelníčkem
- Přidáno odsazení od okrajů u jídelníčku

View File

@ -1,5 +1,7 @@
## Zásady používání a ochrany soukromí aplikace OpenCanteen
Platí od 5. 4. 2022
Platí od 26. 4. 2022
[Předchozí verze](https://github.com/hernikplays/opencanteen/blob/0.1.1/PRIVACY.md)
### Používání
- Tato aplikace není vyvíjena nebo podporována firmou Z-WARE s.r.o. a není oficiální klient pro systém iCanteen
- Uživatel aplikace sám zodpovídá za svůj účet a údaje
@ -11,7 +13,7 @@ Platí od 5. 4. 2022
- Aplikace odesílá data pouze na URL instance systému iCanteen, kterou uživatel aplikace sám zadá
- V případě, že tato instance není zabezpečena protokolem HTTPS, neručí vývojář aplikace za vzniklá nebezpečí
- Aplikace neobsahuje reklamy
- Aplikace dlouhodobě ukládá údaje uživatele (přihlašovací jméno, heslo, URL k instanci) pouze v případě, že uživatel při přihlašování povolí možnost `Zapamatovat si mě`. V tom případě jsou data zašifrována a uložena na zařízení uživatele
- Aplikace dlouhodobě ukládá do zařízení údaje uživatele (přihlašovací jméno, heslo, URL k instanci, jídelníček na aktuální den pro offline zobrazení) pouze v případě, že uživatel při přihlašování povolí možnost `Zapamatovat si mě`. V tom případě jsou data zašifrována a uložena na zařízení uživatele
- V opačném případě jsou údaje uložené v mezipaměti jen na dobu nezbytně nutnou a následně smazány operačním systémem
### Kontakt

View File

@ -17,4 +17,9 @@ class LoginManager {
await storage.write(key: "oc_pass", value: pass);
await storage.write(key: "oc_url", value: url);
}
static Future<bool> zapamatovat() async {
const storage = FlutterSecureStorage();
return await storage.containsKey(key: "oc_pass");
}
}

View File

@ -219,7 +219,11 @@ class _LoginPageState extends State<LoginPage> {
if (!d!) return;
await storage.write(key: "oc_souhlas", value: "ano");
}
if (!canteenControl.text.startsWith("https://") &&
!canteenControl.text.startsWith("http://")) {
canteenControl.text =
"https://" + canteenControl.text;
}
var canteen = Canteen(canteenControl.text);
var l = await canteen.login(
userControl.text, passControl.text);

View File

@ -20,7 +20,10 @@ class _AboutPageState extends State<AboutPage> {
child: Column(mainAxisSize: MainAxisSize.min, children: [
const Text("OpenCanteen", style: TextStyle(fontSize: 30)),
const Text("© 2022 Matyáš Caras a přispěvatelé"),
const Text("Vydáno pod licencí GNU GPLv3"),
InkWell(
onTap: () => launch(
"https://github.com/hernikplays/opencanteen/blob/main/LICENSE"),
child: const Text("Vydáno pod licencí GNU GPLv3")),
const SizedBox(height: 15),
const Text("Použité knihovny:", style: TextStyle(fontSize: 19)),
const SizedBox(height: 10),
@ -47,7 +50,12 @@ class _AboutPageState extends State<AboutPage> {
cudlik(
"canteenlib",
"Copyright (c) 2022 Matyáš Caras and contributors, licence MIT",
"https://github.com/hernikplays/canteenlib/blob/main/LICENSE")
"https://github.com/hernikplays/canteenlib/blob/main/LICENSE"),
const SizedBox(height: 10),
cudlik(
"path_provider",
"Copyright 2013 The Flutter Authors. All rights reserved., licence BSD-3-Clause",
"https://github.com/flutter/plugins/blob/main/packages/path_provider/path_provider/LICENSE")
]),
),
);

View File

@ -1,9 +1,14 @@
import 'dart:convert';
import 'dart:io';
import 'package:canteenlib/canteenlib.dart';
import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:opencanteen/util.dart';
import 'package:path_provider/path_provider.dart';
import 'package:url_launcher/url_launcher.dart';
import '../loginmanager.dart';
import '../main.dart';
import 'about.dart';
@ -47,7 +52,7 @@ class _JidelnicekPageState extends State<JidelnicekPage> {
}
widget.canteen.ziskejUzivatele().then((kr) {
kredit = kr.kredit;
widget.canteen.jidelnicekDen(den: den).then((jd) {
widget.canteen.jidelnicekDen(den: den).then((jd) async {
setState(() {
obsah = [];
if (jd.jidla.isEmpty) {
@ -205,9 +210,39 @@ class _JidelnicekPageState extends State<JidelnicekPage> {
}
}
/// uložení jídelníčku pro dnešek offline
void ulozitDnesekOffline() async {
if (await LoginManager.zapamatovat()) {
Directory appDocDir = await getApplicationDocumentsDirectory();
for (var f in appDocDir.listSync()) {
// Vymažeme obsah
if (f.path.contains("jidelnicek")) {
f.deleteSync();
}
}
// Uložíme nová data
var j = await widget.canteen.jidelnicekDen();
var soubor = File(appDocDir.path +
"/jidelnicek_${den.year}-${den.month}-${den.day}.json");
soubor.createSync();
var jidla = [];
for (var jidlo in j.jidla) {
jidla.add({
"nazev": jidlo.nazev,
"varianta": jidlo.varianta,
"objednano": jidlo.objednano,
"cena": jidlo.cena,
"naBurze": jidlo.naBurze
});
}
await soubor.writeAsString(json.encode(jidla));
}
}
@override
void initState() {
super.initState();
ulozitDnesekOffline();
nactiJidlo();
}

View File

@ -120,6 +120,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.2"
flutter:
dependency: "direct main"
description: flutter
@ -261,6 +268,55 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
path_provider:
dependency: "direct main"
description:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.9"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.12"
path_provider_ios:
dependency: transitive
description:
name: path_provider_ios
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.5"
path_provider_macos:
dependency: transitive
description:
name: path_provider_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
petitparser:
dependency: transitive
description:
@ -268,6 +324,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "4.4.0"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
plugin_platform_interface:
dependency: transitive
description:
@ -275,6 +338,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.4"
sky_engine:
dependency: transitive
description: flutter
@ -371,6 +441,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.2"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0+1"
xml:
dependency: transitive
description:

View File

@ -6,7 +6,7 @@ publish_to: 'none'
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
version: 0.1.1+2
version: 0.2.0+3
environment:
sdk: ">=2.16.1 <3.0.0"
@ -20,6 +20,7 @@ dependencies:
connectivity_plus: ^2.2.1
flutter_secure_storage: ^5.0.2
url_launcher: ^6.0.20
path_provider: ^2.0.9
dev_dependencies:
flutter_lints: ^1.0.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB