Uvítací obrazovka (Finally closes #3)

This commit is contained in:
Matyáš Caras 2022-05-18 19:38:11 +02:00
parent 4818aaba7f
commit 4107b96ed7
14 changed files with 208 additions and 56 deletions

View file

@ -1,3 +1,6 @@
# 1.1.0
- Přidat uvítací obrazovku při prvním spuštění
- Mírné vyčištění kódu
# 1.0.0
- Ukládání dnešního jídelníčku offline
- Stránka s možnostmi nastavení aplikace

BIN
assets/burza.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
assets/doburzy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

BIN
assets/objednavam.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

View file

@ -85,6 +85,26 @@ abstract class Languages {
String get balance;
// Uvítací obrazovka
String get welcome;
String get appDesc;
String get aboutOrder;
String get howOrder;
String get aboutToExch;
String get howToExch;
String get aboutFromExch;
String get howFromExch;
String get next;
// Burza
String get exchange;

View file

@ -92,7 +92,7 @@ class LanguageCz extends Languages {
@override
String get notOfficial =>
"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.";
"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. Pokračováním souhlasíte.";
@override
String get offline => "JSTE OFFLINE";
@ -165,4 +165,35 @@ class LanguageCz extends Languages {
@override
String get yes => "Ano";
@override
String get aboutFromExch => "Žádné jídlo? Žádný problém!";
@override
String get aboutOrder => "Klepnutím objednáte";
@override
String get aboutToExch => "Nemáte chuť?";
@override
String get appDesc =>
"OpenCanteen je neoficiální aplikace pro přístup do obědového systému iCanteen";
@override
String get howFromExch =>
"Z vysunovacího menu přejděte do burzy a objednejte si z dostupných jídel";
@override
String get howOrder =>
"Jednoduše klepněte na jídlo s modrým políčkem a máte objednáno";
@override
String get howToExch =>
"Stačí dlouze podržet jméno objednaného jídla a můžete ho přesunout na nebo z burzy";
@override
String get welcome => "Vítejte v OpenCanteen";
@override
String get next => "Další";
}

View file

@ -92,7 +92,7 @@ class LanguageEn extends Languages {
@override
String get notOfficial =>
"This is not an official app for accessing iCanteen. The author is not responsible for non-functionality or losses while using this app. This message will not appear again.";
"This is not an official app for accessing iCanteen. The author is not responsible for non-functionality or losses while using this app. By continuing you agree.";
@override
String get offline => "YOU ARE OFFLINE";
@ -166,4 +166,34 @@ class LanguageEn extends Languages {
@override
String get yes => "Yes";
@override
String get appDesc => "OpenCanteen is a mobile app for accessing iCanteen.";
@override
String get welcome => "Welcome to OpenCanteen";
@override
String get aboutOrder => "Order with a tap";
@override
String get howOrder =>
"Simply tap on a meal with a blue checkbox next to it and it's done!";
@override
String get aboutToExch => "Don't want your food?";
@override
String get howToExch =>
"If you cannot cancel your order, simply long-tap on the ordered food and put it into the exchange.";
@override
String get aboutFromExch => "No food? No problem!";
@override
String get howFromExch =>
"Simply check the exchange from the sidebar and order when a meal is available.";
@override
String get next => "Next";
}

View file

@ -9,6 +9,7 @@ import 'package:opencanteen/loginmanager.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:canteenlib/canteenlib.dart';
import 'package:opencanteen/okna/offline_jidelnicek.dart';
import 'package:opencanteen/okna/welcome.dart';
import 'package:opencanteen/util.dart';
import 'package:path_provider/path_provider.dart';
@ -123,7 +124,6 @@ class _LoginPageState extends State<LoginPage> {
context,
MaterialPageRoute(
builder: (context) => JidelnicekPage(
user: r["user"]!,
canteen: canteen,
)),
);
@ -220,34 +220,6 @@ class _LoginPageState extends State<LoginPage> {
));
if (!d!) return;
}
// souhlas
const storage = FlutterSecureStorage();
var odsouhlasil = await storage.read(key: "oc_souhlas");
if (odsouhlasil == null || odsouhlasil != "ano") {
var d = await showDialog<bool>(
context: context,
builder: (c) => AlertDialog(
title: Text(Languages.of(context)!.warning),
content: SingleChildScrollView(
child: Text(Languages.of(context)!
.notOfficial)),
actions: [
TextButton(
onPressed: () =>
Navigator.pop(c, true),
child: Text(
Languages.of(context)!.agree)),
TextButton(
onPressed: () =>
Navigator.pop(c, false),
child: Text(
Languages.of(context)!.disagree))
],
));
if (!d!) return;
await storage.write(key: "oc_souhlas", value: "ano");
}
if (!canteenControl.text.startsWith("https://") &&
!canteenControl.text.startsWith("http://")) {
canteenControl.text =
@ -271,14 +243,25 @@ class _LoginPageState extends State<LoginPage> {
LoginManager.setDetails(userControl.text,
passControl.text, canteenControl.text);
}
// souhlas
const storage = FlutterSecureStorage();
var odsouhlasil =
await storage.read(key: "oc_souhlas");
if (odsouhlasil == null || odsouhlasil != "ano") {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (c) =>
WelcomeScreen(canteen: canteen)));
} else {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => JidelnicekPage(
user: userControl.text,
canteen: canteen,
)),
);
}
} on Exception catch (_) {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(

View file

@ -6,10 +6,8 @@ import '../lang/lang.dart';
import '../main.dart';
class BurzaPage extends StatefulWidget {
const BurzaPage({Key? key, required this.canteen, required this.user})
: super(key: key);
const BurzaPage({Key? key, required this.canteen}) : super(key: key);
final Canteen canteen;
final String user;
@override
State<BurzaPage> createState() => _BurzaPageState();
}
@ -114,7 +112,7 @@ class _BurzaPageState extends State<BurzaPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
drawer: drawerGenerator(context, widget.canteen, widget.user, 3),
drawer: drawerGenerator(context, widget.canteen, 3),
appBar: AppBar(
title: Text(Languages.of(context)!.exchange),
),

View file

@ -15,10 +15,8 @@ import '../main.dart';
import 'about.dart';
class JidelnicekPage extends StatefulWidget {
const JidelnicekPage({Key? key, required this.canteen, required this.user})
: super(key: key);
const JidelnicekPage({Key? key, required this.canteen}) : super(key: key);
final Canteen canteen;
final String user;
@override
State<JidelnicekPage> createState() => _JidelnicekPageState();
}
@ -262,7 +260,7 @@ class _JidelnicekPageState extends State<JidelnicekPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
drawer: drawerGenerator(context, widget.canteen, widget.user, 1),
drawer: drawerGenerator(context, widget.canteen, 1),
appBar: AppBar(
title: Text(Languages.of(context)!.menu),
actions: [

75
lib/okna/welcome.dart Normal file
View file

@ -0,0 +1,75 @@
import 'package:canteenlib/canteenlib.dart';
import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:introduction_screen/introduction_screen.dart';
import 'package:opencanteen/lang/lang.dart';
import 'package:opencanteen/okna/jidelnicek.dart';
class WelcomeScreen extends StatefulWidget {
const WelcomeScreen({Key? key, required this.canteen}) : super(key: key);
final Canteen canteen;
@override
State<WelcomeScreen> createState() => _WelcomeScreenState();
}
class _WelcomeScreenState extends State<WelcomeScreen> {
@override
Widget build(BuildContext context) {
var listPagesViewModel = [
PageViewModel(
title: Languages.of(context)!.welcome,
body: Languages.of(context)!.appDesc,
image: const Center(
child: Icon(Icons.waving_hand_outlined, size: 175),
),
),
PageViewModel(
title: Languages.of(context)!.aboutOrder,
body: Languages.of(context)!.howOrder,
image: Center(
child: Image.asset('assets/objednavam.png',
width: MediaQuery.of(context).size.width * 0.85),
),
),
PageViewModel(
title: Languages.of(context)!.aboutToExch,
body: Languages.of(context)!.howToExch,
image: Center(
child: Image.asset('assets/doburzy.png',
width: MediaQuery.of(context).size.width * 0.85),
),
),
PageViewModel(
title: Languages.of(context)!.aboutFromExch,
body: Languages.of(context)!.howFromExch,
image: Center(
child: Image.asset('assets/burza.png',
width: MediaQuery.of(context).size.width * 0.85),
),
),
PageViewModel(
title: Languages.of(context)!.warning,
body: Languages.of(context)!.notOfficial,
image: const Center(
child: Icon(Icons.warning_amber_outlined, size: 175),
),
),
];
return Scaffold(
body: IntroductionScreen(
pages: listPagesViewModel,
next: Text(Languages.of(context)!.next),
done: Text(Languages.of(context)!.ok,
style: const TextStyle(fontWeight: FontWeight.w600)),
onDone: () async {
const storage = FlutterSecureStorage();
await storage.write(key: "oc_souhlas", value: "ano");
Navigator.of(context).pushReplacement(MaterialPageRoute(
builder: (c) => JidelnicekPage(canteen: widget.canteen)));
},
),
);
}
}

View file

@ -5,8 +5,7 @@ import 'package:opencanteen/okna/burza.dart';
import 'lang/lang.dart';
import 'okna/jidelnicek.dart';
Drawer drawerGenerator(
BuildContext context, Canteen canteen, String user, int p) {
Drawer drawerGenerator(BuildContext context, Canteen canteen, int p) {
Drawer drawer = const Drawer();
switch (p) {
case 1:
@ -29,7 +28,7 @@ Drawer drawerGenerator(
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => BurzaPage(canteen: canteen, user: user),
builder: (context) => BurzaPage(canteen: canteen),
),
),
),
@ -51,8 +50,7 @@ Drawer drawerGenerator(
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (c) =>
JidelnicekPage(canteen: canteen, user: user))),
builder: (c) => JidelnicekPage(canteen: canteen))),
),
ListTile(
leading: const Icon(Icons.store),

View file

@ -113,6 +113,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.7.2"
dots_indicator:
dependency: transitive
description:
name: dots_indicator
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
ffi:
dependency: transitive
description:
@ -226,6 +233,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.17.0"
introduction_screen:
dependency: "direct main"
description:
name: introduction_screen
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.2"
js:
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: 1.0.0+3
version: 1.1.0+4
environment:
sdk: ">=2.16.1 <3.0.0"
@ -22,6 +22,7 @@ dependencies:
url_launcher: ^6.0.20
path_provider: ^2.0.9
shared_preferences: ^2.0.13
introduction_screen: ^3.0.1
dev_dependencies:
flutter_lints: ^1.0.0
@ -36,9 +37,10 @@ flutter:
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
assets:
- assets/burza.png
- assets/doburzy.png
- assets/objednavam.png
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.