forked from firka/student-legacy
fix this
This commit is contained in:
parent
89adf5a26f
commit
d426d4866a
@ -3,17 +3,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
class KretenLoginScreen extends StatefulWidget {
|
||||
const KretenLoginScreen({super.key, required this.onLogin});
|
||||
class KretenLoginWidget extends StatefulWidget {
|
||||
const KretenLoginWidget({super.key, required this.onLogin});
|
||||
|
||||
// final String selectedSchool;
|
||||
final void Function(String code) onLogin;
|
||||
|
||||
@override
|
||||
State<KretenLoginScreen> createState() => _KretenLoginScreenState();
|
||||
State<KretenLoginWidget> createState() => _KretenLoginWidgetState();
|
||||
}
|
||||
|
||||
class _KretenLoginScreenState extends State<KretenLoginScreen> {
|
||||
class _KretenLoginWidgetState extends State<KretenLoginWidget> {
|
||||
late final WebViewController controller;
|
||||
var loadingPercentage = 0;
|
||||
var currentUrl = '';
|
||||
@ -24,71 +24,35 @@ class _KretenLoginScreenState extends State<KretenLoginScreen> {
|
||||
controller = WebViewController()
|
||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||
..setNavigationDelegate(NavigationDelegate(
|
||||
onNavigationRequest: (n) async {
|
||||
if (n.url.startsWith('https://mobil.e-kreta.hu')) {
|
||||
setState(() {
|
||||
loadingPercentage = 0;
|
||||
currentUrl = n.url;
|
||||
});
|
||||
|
||||
// final String instituteCode = widget.selectedSchool;
|
||||
// if (!n.url.startsWith(
|
||||
// 'https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect?code=')) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
List<String> requiredThings = n.url
|
||||
.replaceAll(
|
||||
'https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect?code=',
|
||||
'')
|
||||
.replaceAll(
|
||||
'&scope=openid%20email%20offline_access%20kreta-ellenorzo-webapi.public%20kreta-eugyintezes-webapi.public%20kreta-fileservice-webapi.public%20kreta-mobile-global-webapi.public%20kreta-dkt-webapi.public%20kreta-ier-webapi.public&state=refilc_student_mobile&session_state=',
|
||||
':')
|
||||
.split(':');
|
||||
|
||||
String code = requiredThings[0];
|
||||
// String sessionState = requiredThings[1];
|
||||
|
||||
widget.onLogin(code);
|
||||
// Future.delayed(const Duration(milliseconds: 500), () {
|
||||
// Navigator.of(context).pop();
|
||||
// });
|
||||
// Navigator.of(context).pop();
|
||||
|
||||
return NavigationDecision.prevent;
|
||||
} else {
|
||||
return NavigationDecision.navigate;
|
||||
}
|
||||
},
|
||||
onPageStarted: (url) async {
|
||||
// setState(() {
|
||||
// loadingPercentage = 0;
|
||||
// currentUrl = url;
|
||||
setState(() {
|
||||
loadingPercentage = 0;
|
||||
currentUrl = url;
|
||||
});
|
||||
|
||||
// final String instituteCode = widget.selectedSchool;
|
||||
if (!url.startsWith(
|
||||
'https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect?code=')) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> requiredThings = url
|
||||
.replaceAll(
|
||||
'https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect?code=',
|
||||
'')
|
||||
.replaceAll(
|
||||
'&scope=openid%20email%20offline_access%20kreta-ellenorzo-webapi.public%20kreta-eugyintezes-webapi.public%20kreta-fileservice-webapi.public%20kreta-mobile-global-webapi.public%20kreta-dkt-webapi.public%20kreta-ier-webapi.public&state=refilc_student_mobile&session_state=',
|
||||
':')
|
||||
.split(':');
|
||||
|
||||
String code = requiredThings[0];
|
||||
// String sessionState = requiredThings[1];
|
||||
|
||||
widget.onLogin(code);
|
||||
// Future.delayed(const Duration(milliseconds: 500), () {
|
||||
// Navigator.of(context).pop();
|
||||
// });
|
||||
|
||||
// // final String instituteCode = widget.selectedSchool;
|
||||
// if (!url.startsWith(
|
||||
// 'https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect?code=')) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// List<String> requiredThings = url
|
||||
// .replaceAll(
|
||||
// 'https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect?code=',
|
||||
// '')
|
||||
// .replaceAll(
|
||||
// '&scope=openid%20email%20offline_access%20kreta-ellenorzo-webapi.public%20kreta-eugyintezes-webapi.public%20kreta-fileservice-webapi.public%20kreta-mobile-global-webapi.public%20kreta-dkt-webapi.public%20kreta-ier-webapi.public&state=refilc_student_mobile&session_state=',
|
||||
// ':')
|
||||
// .split(':');
|
||||
|
||||
// String code = requiredThings[0];
|
||||
// // String sessionState = requiredThings[1];
|
||||
|
||||
// widget.onLogin(code);
|
||||
// // Future.delayed(const Duration(milliseconds: 500), () {
|
||||
// // Navigator.of(context).pop();
|
||||
// // });
|
||||
// // Navigator.of(context).pop();
|
||||
// Navigator.of(context).pop();
|
||||
},
|
||||
onProgress: (progress) {
|
||||
setState(() {
|
||||
@ -107,6 +71,7 @@ class _KretenLoginScreenState extends State<KretenLoginScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
// Future<void> loadLoginUrl() async {
|
||||
// String nonceStr = await Provider.of<KretaClient>(context, listen: false)
|
||||
// .getAPI(KretaAPI.nonce, json: false);
|
||||
|
||||
@ -115,22 +80,30 @@ class _KretenLoginScreenState extends State<KretenLoginScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: const BackButton(),
|
||||
title: const Text('e-KRÉTA Bejelentkezés'),
|
||||
),
|
||||
body: Stack(
|
||||
children: [
|
||||
WebViewWidget(
|
||||
return Stack(
|
||||
children: [
|
||||
// WebView that will only be visible when the loading is 100%
|
||||
Visibility(
|
||||
visible: loadingPercentage == 100,
|
||||
maintainState: true, // Keep the WebView running in the background
|
||||
child: WebViewWidget(
|
||||
controller: controller,
|
||||
),
|
||||
if (loadingPercentage < 100)
|
||||
LinearProgressIndicator(
|
||||
value: loadingPercentage / 100.0,
|
||||
),
|
||||
// Show the CircularProgressIndicator while loading is not 100%
|
||||
if (loadingPercentage < 100)
|
||||
Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
CircularProgressIndicator(
|
||||
value: loadingPercentage /
|
||||
100.0, // Shows progress as a percentage
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user