fix(login): opravit vracení na přihlašovací stránku při vracení zpět

Merge pull request #29 from hernikplays/bug-login
This commit is contained in:
Matyáš Caras 2022-09-26 17:06:00 +02:00 committed by GitHub
commit d2cbebff25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 24 deletions

View file

@ -231,18 +231,21 @@ class _LoginPageState extends State<LoginPage> {
var odsouhlasil = await storage.read(key: "oc_souhlas");
if (!mounted) return;
if (odsouhlasil == null || odsouhlasil != "ano") {
Navigator.pushReplacement(
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (c) => WelcomeScreen(
canteen: canteen, n: flutterLocalNotificationsPlugin)));
builder: (c) => WelcomeScreen(
canteen: canteen, n: flutterLocalNotificationsPlugin),
),
(route) => false);
} else {
Navigator.pushReplacement(
context,
MaterialPageRoute(
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) => JidelnicekPage(
canteen: canteen, n: flutterLocalNotificationsPlugin)),
);
canteen: canteen, n: flutterLocalNotificationsPlugin),
),
(route) => false);
}
} on PlatformException {
if (!mounted) return;
@ -381,20 +384,21 @@ class _LoginPageState extends State<LoginPage> {
await storage.read(key: "oc_souhlas");
if (!mounted) return;
if (odsouhlasil == null || odsouhlasil != "ano") {
Navigator.pushReplacement(
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (c) => WelcomeScreen(
canteen: canteen,
n: flutterLocalNotificationsPlugin)));
n: flutterLocalNotificationsPlugin)),
(route) => false);
} else {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => JidelnicekPage(
canteen: canteen,
n: flutterLocalNotificationsPlugin)),
);
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) => JidelnicekPage(
canteen: canteen,
n: flutterLocalNotificationsPlugin)),
(route) => false);
}
} on PlatformException {
if (!mounted) return;
@ -445,10 +449,11 @@ class _LoginPageState extends State<LoginPage> {
den: DateTime.parse(j["den"])));
}
if (!mounted) return;
Navigator.pushReplacement(
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: ((context) => OfflineJidelnicek(jidla: jidla))));
builder: ((context) => OfflineJidelnicek(jidla: jidla))),
(route) => false);
}
}
}

View file

@ -330,8 +330,10 @@ class _JidelnicekPageState extends State<JidelnicekPage> {
onPressed: () {
const storage = FlutterSecureStorage();
storage.deleteAll();
Navigator.pushReplacement(context,
MaterialPageRoute(builder: (c) => const LoginPage()));
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (c) => const LoginPage()),
(route) => false);
},
child: Text(Languages.of(context)!.yes)),
TextButton(

View file

@ -70,9 +70,11 @@ class _WelcomeScreenState extends State<WelcomeScreen> {
const storage = FlutterSecureStorage();
await storage.write(key: "oc_souhlas", value: "ano");
if (!mounted) return;
Navigator.of(context).pushReplacement(MaterialPageRoute(
builder: (c) =>
JidelnicekPage(canteen: widget.canteen, n: widget.n)));
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (c) =>
JidelnicekPage(canteen: widget.canteen, n: widget.n)),
(route) => false);
},
),
);