diff --git a/filcnaplo/pubspec.yaml b/filcnaplo/pubspec.yaml index 65a7f9d..69bef6c 100644 --- a/filcnaplo/pubspec.yaml +++ b/filcnaplo/pubspec.yaml @@ -3,7 +3,7 @@ description: "Nem hivatalos e-napló alkalmazás az e-Kréta rendszerhez" homepage: https://refilc.hu publish_to: "none" -version: 4.2.2+222 +version: 4.2.3+223 environment: sdk: ">=2.17.0 <3.0.0" diff --git a/filcnaplo_desktop_ui/lib/screens/login/login_screen.dart b/filcnaplo_desktop_ui/lib/screens/login/login_screen.dart index a206d61..da312a6 100644 --- a/filcnaplo_desktop_ui/lib/screens/login/login_screen.dart +++ b/filcnaplo_desktop_ui/lib/screens/login/login_screen.dart @@ -5,7 +5,6 @@ import 'package:elegant_notification/elegant_notification.dart'; import 'package:elegant_notification/resources/arrays.dart'; import 'package:filcnaplo/api/client.dart'; import 'package:filcnaplo/api/login.dart'; -import 'package:filcnaplo/theme/colors/colors.dart'; import 'package:filcnaplo_mobile_ui/screens/login/login_button.dart'; import 'package:filcnaplo_mobile_ui/screens/login/login_input.dart'; import 'package:filcnaplo_mobile_ui/screens/login/school_input/school_input.dart'; @@ -14,6 +13,17 @@ import 'package:flutter/services.dart'; import 'package:flutter_acrylic/flutter_acrylic.dart'; import 'login_screen.i18n.dart'; +const LinearGradient _backgroundGradient = LinearGradient( + colors: [ + Color.fromARGB(255, 0, 0, 0), + Color.fromARGB(255, 23, 77, 185), + Color.fromARGB(255, 7, 42, 112), + ], + begin: Alignment(-0.8, -2), + end: Alignment(0.8, 1.0), + stops: [-1.0, 0.0, 1.0], +); + class LoginScreen extends StatefulWidget { const LoginScreen({Key? key, this.back = false}) : super(key: key); @@ -70,210 +80,236 @@ class _LoginScreenState extends State { } }); - if (Platform.isMacOS) Window.getTitlebarHeight().then((value) => setState(() => topInset = value)); + if (Platform.isMacOS) { + Window.getTitlebarHeight() + .then((value) => setState(() => topInset = value)); + } } @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: AppColors.of(context).filc, - body: SafeArea( - child: Stack( - children: [ - Row( - children: [ - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - // App logo - Padding( - padding: const EdgeInsets.only(bottom: 24.0), - child: ClipRect( - child: Padding( - padding: const EdgeInsets.only(left: 12.0, right: 12.0, bottom: 32.0), - child: SizedBox( - width: 82.0, - height: 82.0, - // Png shadow *hack* - child: Stack( - children: [ - Padding( - padding: const EdgeInsets.only(top: 8.0), - child: Opacity(child: Image.asset("assets/icons/ic_splash.png", color: Colors.black), opacity: 0.3), - ), - BackdropFilter( - filter: ImageFilter.blur(sigmaX: 6.0, sigmaY: 6.0), - child: Image.asset("assets/icons/ic_splash.png"), - ) - ], - ), - ), - ), - ), - ), - - // Inputs - SizedBox( - width: 400.0, - child: AutofillGroup( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // Username - Padding( - padding: const EdgeInsets.only(bottom: 6.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: Text( - "username".i18n, - maxLines: 1, - style: const TextStyle( - color: Colors.white, - fontWeight: FontWeight.w600, - fontSize: 14.0, - ), - ), - ), - Expanded( - child: Text( - "usernameHint".i18n, - maxLines: 1, - textAlign: TextAlign.right, - style: const TextStyle( - color: Colors.white54, - fontWeight: FontWeight.w500, - fontSize: 12.0, - ), - ), - ), - ], - ), - ), - Padding( - padding: const EdgeInsets.only(bottom: 12.0), - child: LoginInput( - style: LoginInputStyle.username, - controller: usernameController, - ), - ), - - // Password - Padding( - padding: const EdgeInsets.only(bottom: 6.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: Text( - "password".i18n, - maxLines: 1, - style: const TextStyle( - color: Colors.white, - fontWeight: FontWeight.w600, - fontSize: 14.0, - ), - ), - ), - Expanded( - child: Text( - "passwordHint".i18n, - maxLines: 1, - textAlign: TextAlign.right, - style: const TextStyle( - color: Colors.white54, - fontWeight: FontWeight.w500, - fontSize: 12.0, - ), - ), - ), - ], - ), - ), - Padding( - padding: const EdgeInsets.only(bottom: 12.0), - child: LoginInput( - style: LoginInputStyle.password, - controller: passwordController, - ), - ), - - // School - Padding( - padding: const EdgeInsets.only(bottom: 6.0), - child: Text( - "school".i18n, - maxLines: 1, - style: const TextStyle( - color: Colors.white, - fontWeight: FontWeight.w600, - fontSize: 14.0, - ), - ), - ), - SchoolInput( - scroll: _scrollController, - controller: schoolController, - ), - ], - ), - ), - ), - - // Log in button - SizedBox( - width: 400.0, - child: Padding( - padding: const EdgeInsets.only(top: 42.0), - child: Visibility( - child: LoginButton( - child: Text("login".i18n, - maxLines: 1, - style: const TextStyle( - fontWeight: FontWeight.w600, - fontSize: 15.0, - )), - onPressed: () => _loginAPI(context: context), - ), - visible: _loginState != LoginState.inProgress, - replacement: const Padding( - padding: EdgeInsets.symmetric(vertical: 6.0), - child: Center( - child: CircularProgressIndicator( - valueColor: AlwaysStoppedAnimation(Colors.white), - ), - ), - ), - ), - ), - ), - if (_loginState == LoginState.missingFields || _loginState == LoginState.invalidGrant || _loginState == LoginState.failed) + body: Container( + decoration: BoxDecoration( + gradient: _backgroundGradient, + ), + child: SafeArea( + child: Stack( + children: [ + Row( + children: [ + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // App logo Padding( - padding: const EdgeInsets.only(top: 8.0), - child: Text( - ["missing_fields", "invalid_grant", "error"][_loginState.index].i18n, - style: const TextStyle(color: Colors.red, fontWeight: FontWeight.w500), + padding: const EdgeInsets.only(bottom: 24.0), + child: ClipRect( + child: Padding( + padding: const EdgeInsets.only( + left: 12.0, right: 12.0, bottom: 32.0), + child: SizedBox( + width: 100.0, + height: 100.0, + // Png shadow *hack* + child: Stack( + children: [ + Padding( + padding: const EdgeInsets.only(top: 8.0), + child: Opacity( + child: Image.asset( + "assets/icons/ic_splash.png", + color: Colors.black), + opacity: 0.3), + ), + BackdropFilter( + filter: ImageFilter.blur( + sigmaX: 6.0, sigmaY: 6.0), + child: Image.asset( + "assets/icons/ic_splash.png"), + ) + ], + ), + ), + ), ), ), - ], + + // Inputs + SizedBox( + width: 400.0, + child: AutofillGroup( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Username + Padding( + padding: const EdgeInsets.only(bottom: 6.0), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Text( + "username".i18n, + maxLines: 1, + style: const TextStyle( + color: Colors.white, + fontWeight: FontWeight.w600, + fontSize: 14.0, + ), + ), + ), + Expanded( + child: Text( + "usernameHint".i18n, + maxLines: 1, + textAlign: TextAlign.right, + style: const TextStyle( + color: Colors.white54, + fontWeight: FontWeight.w500, + fontSize: 12.0, + ), + ), + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.only(bottom: 12.0), + child: LoginInput( + style: LoginInputStyle.username, + controller: usernameController, + ), + ), + + // Password + Padding( + padding: const EdgeInsets.only(bottom: 6.0), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Text( + "password".i18n, + maxLines: 1, + style: const TextStyle( + color: Colors.white, + fontWeight: FontWeight.w600, + fontSize: 14.0, + ), + ), + ), + Expanded( + child: Text( + "passwordHint".i18n, + maxLines: 1, + textAlign: TextAlign.right, + style: const TextStyle( + color: Colors.white54, + fontWeight: FontWeight.w500, + fontSize: 12.0, + ), + ), + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.only(bottom: 12.0), + child: LoginInput( + style: LoginInputStyle.password, + controller: passwordController, + ), + ), + + // School + Padding( + padding: const EdgeInsets.only(bottom: 6.0), + child: Text( + "school".i18n, + maxLines: 1, + style: const TextStyle( + color: Colors.white, + fontWeight: FontWeight.w600, + fontSize: 14.0, + ), + ), + ), + SchoolInput( + scroll: _scrollController, + controller: schoolController, + ), + ], + ), + ), + ), + + // Log in button + SizedBox( + width: 400.0, + child: Padding( + padding: const EdgeInsets.only(top: 42.0), + child: Visibility( + child: LoginButton( + child: Text("login".i18n, + maxLines: 1, + style: const TextStyle( + fontWeight: FontWeight.w600, + fontSize: 15.0, + )), + onPressed: () => _loginAPI(context: context), + ), + visible: _loginState != LoginState.inProgress, + replacement: const Padding( + padding: EdgeInsets.symmetric(vertical: 6.0), + child: Center( + child: CircularProgressIndicator( + valueColor: AlwaysStoppedAnimation( + Colors.white), + ), + ), + ), + ), + ), + ), + if (_loginState == LoginState.missingFields || + _loginState == LoginState.invalidGrant || + _loginState == LoginState.failed) + Padding( + padding: const EdgeInsets.only(top: 8.0), + child: Text( + [ + "missing_fields", + "invalid_grant", + "error" + ][_loginState.index] + .i18n, + style: const TextStyle( + color: Colors.red, + fontWeight: FontWeight.w500), + ), + ), + ], + ), ), - ), - ], - ), - if (showBack) - Container( - alignment: Alignment.topLeft, - padding: EdgeInsets.only(left: 16.0, top: topInset), - child: const ClipOval( - child: Material( - type: MaterialType.transparency, - child: BackButton(color: Colors.white), - ), - ), + ], ), - ], + if (showBack) + Container( + alignment: Alignment.topLeft, + padding: EdgeInsets.only(left: 16.0, top: topInset), + child: const ClipOval( + child: Material( + type: MaterialType.transparency, + child: BackButton(color: Colors.white), + ), + ), + ), + ], + ), ), ), ); @@ -283,7 +319,9 @@ class _LoginScreenState extends State { String username = usernameController.text; String password = passwordController.text; - if (username == "" || password == "" || schoolController.selectedSchool == null) { + if (username == "" || + password == "" || + schoolController.selectedSchool == null) { return setState(() => _loginState = LoginState.missingFields); } @@ -313,7 +351,8 @@ class _LoginScreenState extends State { ).show(context); }, onSuccess: () { - Navigator.of(context).pushNamedAndRemoveUntil("login_to_navigation", (_) => false); + Navigator.of(context) + .pushNamedAndRemoveUntil("login_to_navigation", (_) => false); }).then((res) => setState(() => _loginState = res)); } }