Merge branch 'refilc:dev' into dev

This commit is contained in:
Geryy 2024-05-03 21:13:02 +02:00 committed by GitHub
commit c4e7ebc020
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,10 +1,9 @@
// import 'dart:async'; // import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/widgets.dart';
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/common/widgets/absence/absence_display.dart';
@ -17,7 +16,6 @@ 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:flutter_svg/flutter_svg.dart';
import 'package:flutter_portal/flutter_portal.dart';
class LoginScreen extends StatefulWidget { class LoginScreen extends StatefulWidget {
const LoginScreen({super.key, this.back = false}); const LoginScreen({super.key, this.back = false});
@ -85,9 +83,9 @@ 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;
return Portal( return Scaffold(
child: Scaffold(
body: Container( body: Container(
decoration: const BoxDecoration(color: Color(0xFFDAE4F7)), decoration: const BoxDecoration(color: Color(0xFFDAE4F7)),
child: SingleChildScrollView( child: SingleChildScrollView(
@ -121,8 +119,7 @@ class LoginScreenState extends State<LoginScreen> {
Material( Material(
type: MaterialType.transparency, type: MaterialType.transparency,
child: showBack child: showBack
? BackButton( ? BackButton(color: AppColors.of(context).text)
color: AppColors.of(context).text)
: const SizedBox(height: 48.0), : const SizedBox(height: 48.0),
), ),
], ],
@ -130,172 +127,208 @@ class LoginScreenState extends State<LoginScreen> {
Stack( Stack(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
children: [ children: [
// Column(
// mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// const SizedBox(height: 21),
// CarouselSlider(
// options: CarouselOptions(
// height: MediaQuery.of(context).size.height,
// viewportFraction: 1,
// autoPlay: true,
// autoPlayInterval: const Duration(seconds: 6),
// pauseAutoPlayOnTouch: true),
// items: [1, 2, 3, 4].map((i) {
// return Builder(
// builder: (BuildContext context) {
// return Column(
// crossAxisAlignment:
// CrossAxisAlignment.start,
// mainAxisAlignment:
// MainAxisAlignment.start,
// children: [
// Padding(
// padding:
// const EdgeInsets.only(left: 24),
// child: Column(
// crossAxisAlignment:
// CrossAxisAlignment.start,
// mainAxisAlignment:
// MainAxisAlignment.start,
// children: [
// Text(
// "welcome_title_$i".i18n,
// style: const TextStyle(
// color: Color(0xFF050B15),
// fontSize: 19,
// fontFamily: 'Montserrat',
// fontWeight:
// FontWeight.w700,
// height: 1.3),
// ),
// const SizedBox(
// height: 14.375), //meth
// Padding(
// padding:
// const EdgeInsets.only(
// right: 20),
// child: Text(
// "welcome_text_$i".i18n,
// style: const TextStyle(
// color:
// Color(0xFF050B15),
// fontFamily: 'FigTree',
// fontWeight:
// FontWeight.w500,
// fontSize: 17,
// height: 1.3),
// ),
// ),
// ],
// )),
// const SizedBox(height: 15.625),
// Padding(
// padding: const EdgeInsets.only(
// left: 16, right: 16),
// child: Image.asset(
// 'assets/images/showcase$i.png'))
// ],
// );
// },
// );
// }).toList(),
// ),
// ],
// ),
// Container(
// height: 250,
// width: double.infinity,
// decoration: const BoxDecoration(
// gradient: LinearGradient(
// colors: [Color(0x00DAE4F7), Color(0xFFDAE4F7)],
// stops: [0, 0.1],
// begin: Alignment.topCenter,
// end: Alignment.bottomCenter,
// ),
// ),
// child: Padding(
// padding: const EdgeInsets.only(top: 3),
// child: Column(
// children: [
// SizedBox(
// height: 48,
// width: double.infinity,
// child: Padding(
// padding: const EdgeInsets.symmetric(
// horizontal: 16),
// child: FilledButton(
// style: ButtonStyle(
// shape: MaterialStateProperty.all<
// RoundedRectangleBorder>(
// const RoundedRectangleBorder(
// borderRadius: BorderRadius.all(
// Radius.circular(12)),
// ))),
// onPressed: () {},
// child: Text(
// "login".i18n,
// style: const TextStyle(
// fontFamily: 'Montserrat',
// fontSize: 20,
// fontWeight: FontWeight.w700),
// )),
// ),
// ),
// const SizedBox(height: 8),
// ],
// ),
// ),
// )
//
//
// TODO: OLD LOGIN FROM HERE
Column( Column(
//login buttons and ui starts here //login buttons and ui starts here
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
const SizedBox(height: 21),
CarouselSlider(
options: CarouselOptions(
height: MediaQuery.of(context).size.height,
viewportFraction: 1,
autoPlay: true,
autoPlayInterval: const Duration(seconds: 6),
pauseAutoPlayOnTouch: true),
items: [1, 2, 3, 4].map((i) {
return Builder(
builder: (BuildContext context) {
return Column(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding:
const EdgeInsets.only(left: 24),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Text(
"welcome_title_$i".i18n,
style: const TextStyle(
color: Color(0xFF050B15),
fontSize: 19,
fontFamily: 'Montserrat',
fontWeight: FontWeight.w700,
height: 1.3),
),
const SizedBox(
height: 14.375), //meth
Padding( Padding(
padding: const EdgeInsets.only( padding: const EdgeInsets.only(
left: 22.0, right: 20),
right: 22.0, child: Text(
top: 0.0, "welcome_text_$i".i18n,
style: const TextStyle(
color: Color(0xFF050B15),
fontFamily: 'FigTree',
fontWeight:
FontWeight.w500,
fontSize: 17,
height: 1.3),
), ),
),
],
)),
const SizedBox(height: 15.625),
Padding(
padding: const EdgeInsets.only(
left: 16, right: 16),
child: Image.asset(
'assets/images/showcase$i.png'))
],
);
},
);
}).toList(),
),
],
),
Container(
height: 300,
width: double.infinity,
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [Color(0x00DAE4F7), Color(0xFFDAE4F7)],
stops: [0, 0.12],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
child: Padding(
padding: EdgeInsets.only(top: 50, bottom: MediaQuery.of(context).viewInsets.bottom),
child: Column(
children: [
SizedBox(
height: 48,
width: double.infinity,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16),
child: FilledButton(
style: ButtonStyle(
shape: MaterialStateProperty.all<
RoundedRectangleBorder>(
const RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(12)),
))),
onPressed: () {
showModalBottomSheet(
backgroundColor: Colors.transparent,
context: context,
builder: (BuildContext context) {
return Container(
height: MediaQuery.of(context)
.size
.height *
0.5 + 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.only(
top: 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,
),
),
Container(
width: double.infinity,
child: AutofillGroup( child: AutofillGroup(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment:
CrossAxisAlignment
.end,
children: [ children: [
// username // username
Padding( Padding(
padding: padding:
const EdgeInsets.only(bottom: 6.0), const EdgeInsets
.only(
bottom:
6.0),
child: Row( child: Row(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.spaceBetween, MainAxisAlignment
.spaceBetween,
children: [ children: [
Expanded( Expanded(
child: Text( child: Text(
"username".i18n, "username"
maxLines: 1, .i18n,
style: TextStyle( maxLines:
1,
style:
TextStyle(
color: AppColors.of(context) color: AppColors.of(context)
.loginPrimary, .loginPrimary,
fontWeight: FontWeight.w500, fontWeight:
fontSize: 12.0, FontWeight.w500,
fontSize:
12.0,
), ),
), ),
), ),
Expanded( Expanded(
child: Text( child: Text(
"usernameHint".i18n, "usernameHint"
maxLines: 1, .i18n,
textAlign: TextAlign.right, maxLines:
style: TextStyle( 1,
textAlign:
TextAlign
.right,
style:
TextStyle(
color: AppColors.of(context) color: AppColors.of(context)
.loginSecondary, .loginSecondary,
fontWeight: FontWeight.w500, fontWeight:
fontSize: 12.0, FontWeight.w500,
fontSize:
12.0,
), ),
), ),
), ),
@ -304,43 +337,65 @@ class LoginScreenState extends State<LoginScreen> {
), ),
Padding( Padding(
padding: padding:
const EdgeInsets.only(bottom: 12.0), const EdgeInsets
.only(
bottom:
12.0),
child: LoginInput( child: LoginInput(
style: LoginInputStyle.username, style:
controller: usernameController, LoginInputStyle
.username,
controller:
usernameController,
), ),
), ),
// password // password
Padding( Padding(
padding: padding:
const EdgeInsets.only(bottom: 6.0), const EdgeInsets
.only(
bottom:
6.0),
child: Row( child: Row(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.spaceBetween, MainAxisAlignment
.spaceBetween,
children: [ children: [
Expanded( Expanded(
child: Text( child: Text(
"password".i18n, "password"
maxLines: 1, .i18n,
style: TextStyle( maxLines:
1,
style:
TextStyle(
color: AppColors.of(context) color: AppColors.of(context)
.loginPrimary, .loginPrimary,
fontWeight: FontWeight.w500, fontWeight:
fontSize: 12.0, FontWeight.w500,
fontSize:
12.0,
), ),
), ),
), ),
Expanded( Expanded(
child: Text( child: Text(
"passwordHint".i18n, "passwordHint"
maxLines: 1, .i18n,
textAlign: TextAlign.right, maxLines:
style: TextStyle( 1,
textAlign:
TextAlign
.right,
style:
TextStyle(
color: AppColors.of(context) color: AppColors.of(context)
.loginSecondary, .loginSecondary,
fontWeight: FontWeight.w500, fontWeight:
fontSize: 12.0, FontWeight.w500,
fontSize:
12.0,
), ),
), ),
), ),
@ -349,65 +404,122 @@ class LoginScreenState extends State<LoginScreen> {
), ),
Padding( Padding(
padding: padding:
const EdgeInsets.only(bottom: 12.0), const EdgeInsets
.only(
bottom:
12.0),
child: LoginInput( child: LoginInput(
style: LoginInputStyle.password, style:
controller: passwordController, LoginInputStyle
.password,
controller:
passwordController,
), ),
), ),
// school // school
Padding( Padding(
padding: padding:
const EdgeInsets.only(bottom: 6.0), const EdgeInsets
.only(
bottom:
6.0),
child: Text( child: Text(
"school".i18n, "school".i18n,
maxLines: 1, maxLines: 1,
style: TextStyle( style:
color: AppColors.of(context) TextStyle(
color: AppColors.of(
context)
.loginPrimary, .loginPrimary,
fontWeight: FontWeight.w500, fontWeight:
fontSize: 12.0, FontWeight
.w500,
fontSize:
12.0,
), ),
), ),
), ),
SchoolInput( SchoolInput(
scroll: _scrollController, scroll:
controller: schoolController, _scrollController,
controller:
schoolController,
), ),
], ],
), ),
), ),
), ),
const Padding(
padding: EdgeInsets.only(
left: 22.0,
right: 22.0,
top: 0.0,
),
),
Padding( Padding(
padding: const EdgeInsets.only( padding:
const EdgeInsets.only(
top: 35.0, top: 35.0,
left: 22.0, left: 22.0,
right: 22.0, right: 22.0,
), ),
child: Visibility( child: Visibility(
visible: _loginState != LoginState.inProgress, visible: _loginState !=
replacement: const Padding( LoginState
padding: EdgeInsets.symmetric(vertical: 6.0), .inProgress,
child: CircularProgressIndicator( replacement:
valueColor: AlwaysStoppedAnimation<Color>( const Padding(
Colors.white), padding: EdgeInsets
.symmetric(
vertical:
6.0),
child:
CircularProgressIndicator(
valueColor:
AlwaysStoppedAnimation<
Color>(
Colors
.white),
), ),
), ),
child: LoginButton( child: LoginButton(
child: Text("login".i18n, child: Text(
"login".i18n,
maxLines: 1, maxLines: 1,
style: const TextStyle( style:
fontWeight: FontWeight.bold, const TextStyle(
fontWeight:
FontWeight
.bold,
fontSize: 20.0, fontSize: 20.0,
)), )),
onPressed: () => _loginAPI(context: context), onPressed: () =>
_loginAPI(
context:
context),
), ),
), ),
), ),
]),
);
},
);
},
child: Text(
"login".i18n,
style: const TextStyle(
fontFamily: 'Montserrat',
fontSize: 20,
fontWeight: FontWeight.w700),
)),
),
),
const SizedBox(height: 8),
], ],
), ),
// TODO: OLD LOGIN FROM HERE ),
),
], ],
), ),
@ -449,7 +561,6 @@ class LoginScreenState extends State<LoginScreen> {
), ),
), ),
), ),
),
); );
} }