forked from firka/student-legacy
change kretenlogin to widget
This commit is contained in:
parent
eda093a9b5
commit
2d5c270641
@ -3,17 +3,17 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:webview_flutter/webview_flutter.dart';
|
import 'package:webview_flutter/webview_flutter.dart';
|
||||||
|
|
||||||
class KretenLoginScreen extends StatefulWidget {
|
class KretenLoginWidget extends StatefulWidget {
|
||||||
const KretenLoginScreen({super.key, required this.onLogin});
|
const KretenLoginWidget({super.key, required this.onLogin});
|
||||||
|
|
||||||
// final String selectedSchool;
|
// final String selectedSchool;
|
||||||
final void Function(String code) onLogin;
|
final void Function(String code) onLogin;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<KretenLoginScreen> createState() => _KretenLoginScreenState();
|
State<KretenLoginWidget> createState() => _KretenLoginWidgetState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _KretenLoginScreenState extends State<KretenLoginScreen> {
|
class _KretenLoginWidgetState extends State<KretenLoginWidget> {
|
||||||
late final WebViewController controller;
|
late final WebViewController controller;
|
||||||
var loadingPercentage = 0;
|
var loadingPercentage = 0;
|
||||||
var currentUrl = '';
|
var currentUrl = '';
|
||||||
@ -24,20 +24,19 @@ class _KretenLoginScreenState extends State<KretenLoginScreen> {
|
|||||||
controller = WebViewController()
|
controller = WebViewController()
|
||||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||||
..setNavigationDelegate(NavigationDelegate(
|
..setNavigationDelegate(NavigationDelegate(
|
||||||
onNavigationRequest: (n) async {
|
onPageStarted: (url) async {
|
||||||
if (n.url.startsWith('https://mobil.e-kreta.hu')) {
|
|
||||||
setState(() {
|
setState(() {
|
||||||
loadingPercentage = 0;
|
loadingPercentage = 0;
|
||||||
currentUrl = n.url;
|
currentUrl = url;
|
||||||
});
|
});
|
||||||
|
|
||||||
// final String instituteCode = widget.selectedSchool;
|
// final String instituteCode = widget.selectedSchool;
|
||||||
// if (!n.url.startsWith(
|
if (!url.startsWith(
|
||||||
// 'https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect?code=')) {
|
'https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect?code=')) {
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
List<String> requiredThings = n.url
|
List<String> requiredThings = url
|
||||||
.replaceAll(
|
.replaceAll(
|
||||||
'https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect?code=',
|
'https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect?code=',
|
||||||
'')
|
'')
|
||||||
@ -54,41 +53,6 @@ class _KretenLoginScreenState extends State<KretenLoginScreen> {
|
|||||||
// Navigator.of(context).pop();
|
// Navigator.of(context).pop();
|
||||||
// });
|
// });
|
||||||
// Navigator.of(context).pop();
|
// Navigator.of(context).pop();
|
||||||
|
|
||||||
return NavigationDecision.prevent;
|
|
||||||
} else {
|
|
||||||
return NavigationDecision.navigate;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onPageStarted: (url) async {
|
|
||||||
// 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();
|
|
||||||
// // });
|
|
||||||
// // Navigator.of(context).pop();
|
|
||||||
},
|
},
|
||||||
onProgress: (progress) {
|
onProgress: (progress) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -116,12 +80,7 @@ class _KretenLoginScreenState extends State<KretenLoginScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Stack(
|
||||||
appBar: AppBar(
|
|
||||||
leading: const BackButton(),
|
|
||||||
title: const Text('e-KRÉTA Bejelentkezés'),
|
|
||||||
),
|
|
||||||
body: Stack(
|
|
||||||
children: [
|
children: [
|
||||||
WebViewWidget(
|
WebViewWidget(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
@ -131,7 +90,6 @@ class _KretenLoginScreenState extends State<KretenLoginScreen> {
|
|||||||
value: loadingPercentage / 100.0,
|
value: loadingPercentage / 100.0,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,19 @@
|
|||||||
import 'package:refilc/api/client.dart';
|
import 'package:refilc/api/client.dart';
|
||||||
import 'package:refilc/api/login.dart';
|
import 'package:refilc/api/login.dart';
|
||||||
import 'package:refilc/theme/colors/colors.dart';
|
import 'package:refilc/theme/colors/colors.dart';
|
||||||
|
import 'package:refilc_mobile_ui/common/bottom_sheet_menu/rounded_bottom_sheet.dart';
|
||||||
import 'package:refilc_mobile_ui/common/custom_snack_bar.dart';
|
import 'package:refilc_mobile_ui/common/custom_snack_bar.dart';
|
||||||
import 'package:refilc_mobile_ui/common/system_chrome.dart';
|
import 'package:refilc_mobile_ui/common/system_chrome.dart';
|
||||||
|
import 'package:refilc_mobile_ui/common/widgets/absence/absence_display.dart';
|
||||||
|
import 'package:refilc_mobile_ui/screens/login/login_button.dart';
|
||||||
|
import 'package:refilc_mobile_ui/screens/login/login_input.dart';
|
||||||
import 'package:refilc_mobile_ui/screens/login/school_input/school_input.dart';
|
import 'package:refilc_mobile_ui/screens/login/school_input/school_input.dart';
|
||||||
import 'package:refilc_mobile_ui/screens/settings/privacy_view.dart';
|
import 'package:refilc_mobile_ui/screens/settings/privacy_view.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'login_screen.i18n.dart';
|
import 'login_screen.i18n.dart';
|
||||||
import 'package:carousel_slider/carousel_slider.dart';
|
import 'package:carousel_slider/carousel_slider.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:refilc_mobile_ui/screens/login/kreten_login.dart'; //new library for new web login
|
import 'package:refilc_mobile_ui/screens/login/kreten_login.dart'; //new library for new web login
|
||||||
|
|
||||||
class LoginScreen extends StatefulWidget {
|
class LoginScreen extends StatefulWidget {
|
||||||
@ -27,8 +32,8 @@ class LoginScreenState extends State<LoginScreen> {
|
|||||||
final passwordController = TextEditingController();
|
final passwordController = TextEditingController();
|
||||||
final schoolController = SchoolInputController();
|
final schoolController = SchoolInputController();
|
||||||
final _scrollController = ScrollController();
|
final _scrollController = ScrollController();
|
||||||
// new controllers
|
|
||||||
final codeController = TextEditingController();
|
final codeController = TextEditingController();
|
||||||
|
|
||||||
LoginState _loginState = LoginState.normal;
|
LoginState _loginState = LoginState.normal;
|
||||||
bool showBack = false;
|
bool showBack = false;
|
||||||
|
|
||||||
@ -54,7 +59,7 @@ class LoginScreenState extends State<LoginScreen> {
|
|||||||
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
|
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
|
||||||
statusBarColor: Colors.transparent,
|
statusBarColor: Colors.transparent,
|
||||||
statusBarIconBrightness: Brightness.light,
|
statusBarIconBrightness: Brightness.light,
|
||||||
systemNavigationBarColor: Color(0xFFDAE4F7),
|
systemNavigationBarColor: Colors.white,
|
||||||
systemNavigationBarIconBrightness: Brightness.dark,
|
systemNavigationBarIconBrightness: Brightness.dark,
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -80,7 +85,7 @@ class LoginScreenState extends State<LoginScreen> {
|
|||||||
precacheImage(const AssetImage('assets/images/showcase2.png'), context);
|
precacheImage(const AssetImage('assets/images/showcase2.png'), context);
|
||||||
precacheImage(const AssetImage('assets/images/showcase3.png'), context);
|
precacheImage(const AssetImage('assets/images/showcase3.png'), context);
|
||||||
precacheImage(const AssetImage('assets/images/showcase4.png'), context);
|
precacheImage(const AssetImage('assets/images/showcase4.png'), context);
|
||||||
// bool selected = false;
|
bool selected = false;
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Container(
|
body: Container(
|
||||||
@ -97,17 +102,9 @@ class LoginScreenState extends State<LoginScreen> {
|
|||||||
children: [
|
children: [
|
||||||
// app icon
|
// app icon
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 24, top: 0),
|
padding: const EdgeInsets.only(left: 24, top: 20),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
if (showBack)
|
|
||||||
Material(
|
|
||||||
type: MaterialType.transparency,
|
|
||||||
child: showBack
|
|
||||||
? const BackButton(color: Colors.black)
|
|
||||||
: const SizedBox(height: 48.0),
|
|
||||||
),
|
|
||||||
if (showBack) const SizedBox(width: 8),
|
|
||||||
Image.asset(
|
Image.asset(
|
||||||
'assets/icons/ic_rounded.png',
|
'assets/icons/ic_rounded.png',
|
||||||
width: 30.0,
|
width: 30.0,
|
||||||
@ -121,6 +118,12 @@ class LoginScreenState extends State<LoginScreen> {
|
|||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
fontFamily: 'Montserrat'),
|
fontFamily: 'Montserrat'),
|
||||||
),
|
),
|
||||||
|
Material(
|
||||||
|
type: MaterialType.transparency,
|
||||||
|
child: showBack
|
||||||
|
? BackButton(color: AppColors.of(context).text)
|
||||||
|
: const SizedBox(height: 48.0),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
Stack(
|
Stack(
|
||||||
@ -131,7 +134,7 @@ class LoginScreenState extends State<LoginScreen> {
|
|||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 21),
|
||||||
CarouselSlider(
|
CarouselSlider(
|
||||||
options: CarouselOptions(
|
options: CarouselOptions(
|
||||||
height: MediaQuery.of(context).size.height,
|
height: MediaQuery.of(context).size.height,
|
||||||
@ -198,115 +201,145 @@ class LoginScreenState extends State<LoginScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
height: 330,
|
height: 300,
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
colors: [Color(0x00DAE4F7), Color(0xFFDAE4F7)],
|
colors: [Color(0x00DAE4F7), Color(0xFFDAE4F7)],
|
||||||
stops: [0, 0.24],
|
stops: [0, 0.12],
|
||||||
begin: Alignment.topCenter,
|
begin: Alignment.topCenter,
|
||||||
end: Alignment.bottomCenter,
|
end: Alignment.bottomCenter,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
top: 90,
|
top: 50,
|
||||||
bottom: MediaQuery.of(context).viewInsets.bottom),
|
bottom: MediaQuery.of(context).viewInsets.bottom),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 52,
|
height: 48,
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 16),
|
horizontal: 16),
|
||||||
child: GestureDetector(
|
child: FilledButton(
|
||||||
onTap: () {
|
style: ButtonStyle(
|
||||||
final NavigatorState navigator =
|
shape: WidgetStateProperty.all<
|
||||||
Navigator.of(context);
|
RoundedRectangleBorder>(
|
||||||
navigator
|
const RoundedRectangleBorder(
|
||||||
.push(
|
borderRadius: BorderRadius.all(
|
||||||
MaterialPageRoute(
|
Radius.circular(12)),
|
||||||
builder: (context) =>
|
))),
|
||||||
KretenLoginScreen(
|
onPressed: () {
|
||||||
onLogin: (String code) {
|
showModalBottomSheet(
|
||||||
codeController.text = code;
|
backgroundColor: Colors.transparent,
|
||||||
navigator.pop();
|
context: context,
|
||||||
|
isScrollControlled:
|
||||||
|
true, // This ensures the modal accommodates input fields properly
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
height: MediaQuery.of(context)
|
||||||
|
.size
|
||||||
|
.height *
|
||||||
|
0.8 +
|
||||||
|
MediaQuery.of(context)
|
||||||
|
.viewInsets
|
||||||
|
.bottom,
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: Color(0xFFDAE4F7),
|
||||||
|
borderRadius: BorderRadius.only(
|
||||||
|
topRight:
|
||||||
|
Radius.circular(24.0),
|
||||||
|
topLeft:
|
||||||
|
Radius.circular(24.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.center,
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets
|
||||||
|
.symmetric(
|
||||||
|
vertical: 18),
|
||||||
|
child: Container(
|
||||||
|
decoration:
|
||||||
|
const BoxDecoration(
|
||||||
|
color:
|
||||||
|
Color(0xFFB9C8E5),
|
||||||
|
borderRadius:
|
||||||
|
BorderRadius.only(
|
||||||
|
topRight:
|
||||||
|
Radius.circular(
|
||||||
|
2.0),
|
||||||
|
topLeft:
|
||||||
|
Radius.circular(
|
||||||
|
2.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
width: 40,
|
||||||
|
height: 4,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.only(
|
||||||
|
right: 14,
|
||||||
|
left: 14,
|
||||||
|
bottom: 24),
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius:
|
||||||
|
BorderRadius
|
||||||
|
.circular(16),
|
||||||
|
child: Container(
|
||||||
|
decoration:
|
||||||
|
BoxDecoration(
|
||||||
|
borderRadius:
|
||||||
|
BorderRadius
|
||||||
|
.circular(
|
||||||
|
16),
|
||||||
|
),
|
||||||
|
child:
|
||||||
|
KretenLoginWidget(
|
||||||
|
onLogin:
|
||||||
|
(String code) {
|
||||||
|
codeController
|
||||||
|
.text = code;
|
||||||
|
Navigator.of(
|
||||||
|
context)
|
||||||
|
.pop();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.then((value) {
|
],
|
||||||
if (codeController.text != "") {
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
).then((value) {
|
||||||
|
// After closing the modal bottom sheet, check if the code is set
|
||||||
|
if (codeController.text.isNotEmpty) {
|
||||||
|
// Call your API after retrieving the code
|
||||||
_NewLoginAPI(context: context);
|
_NewLoginAPI(context: context);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Text(
|
||||||
width:
|
"login_w_kreta_acc".i18n,
|
||||||
MediaQuery.of(context).size.width *
|
|
||||||
0.75,
|
|
||||||
height: 60.0,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
// image: const DecorationImage(
|
|
||||||
// image:
|
|
||||||
// AssetImage('assets/images/btn_kreten_login.png'),
|
|
||||||
// fit: BoxFit.scaleDown,
|
|
||||||
// ),
|
|
||||||
borderRadius:
|
|
||||||
BorderRadius.circular(12.0),
|
|
||||||
color: const Color(0xFF0097C1),
|
|
||||||
),
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
top: 5.0,
|
|
||||||
left: 5.0,
|
|
||||||
right: 5.0,
|
|
||||||
bottom: 5.0),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Image.asset(
|
|
||||||
'assets/images/btn_kreten_login.png',
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
width: 10.0,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
width: 1.0,
|
|
||||||
height: 30.0,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
width: 10.0,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'login_w_kreta_acc'.i18n,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: Colors.white,
|
fontFamily: 'Montserrat',
|
||||||
fontWeight: FontWeight.bold,
|
fontSize: 16,
|
||||||
fontSize: 14.0,
|
fontWeight: FontWeight.w700),
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 8),
|
||||||
const SizedBox(height: 17),
|
|
||||||
// privacy policy
|
|
||||||
GestureDetector(
|
|
||||||
onTap: () => PrivacyView.show(context),
|
|
||||||
child: Text(
|
|
||||||
'privacy'.i18n,
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.black,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
fontSize: 14.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -334,6 +367,18 @@ class LoginScreenState extends State<LoginScreen> {
|
|||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
// privacy policy
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () => PrivacyView.show(context),
|
||||||
|
child: Text(
|
||||||
|
'privacy'.i18n,
|
||||||
|
style: TextStyle(
|
||||||
|
color: AppColors.of(context).loginSecondary,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
fontSize: 14.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -390,13 +435,6 @@ class LoginScreenState extends State<LoginScreen> {
|
|||||||
// }),
|
// }),
|
||||||
// );
|
// );
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// setState(() => _loginState = LoginState.inProgress);
|
|
||||||
// _callAPI();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// new login api
|
|
||||||
// ignore: non_constant_identifier_names
|
|
||||||
void _NewLoginAPI({required BuildContext context}) {
|
void _NewLoginAPI({required BuildContext context}) {
|
||||||
String code = codeController.text;
|
String code = codeController.text;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user