Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions assets/images/login_background.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
248 changes: 181 additions & 67 deletions lib/screens/auth/views/login_screen.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:shop/common/app_logger.dart';
import 'package:shop/constants.dart';
import 'package:shop/repository/auth_repository.dart';
Expand Down Expand Up @@ -104,79 +105,192 @@ class _LoginScreenState extends State<LoginScreen> {

@override
Widget build(BuildContext context) {
final Size size = MediaQuery.of(context).size;
final theme = Theme.of(context);
const Color brandPrimary = cellphoneZRed;
final Color inputFillColor =
theme.inputDecorationTheme.fillColor ?? lightGreyColor;

final InputDecorationThemeData pillInputTheme =
theme.inputDecorationTheme.copyWith(
filled: true,
fillColor: inputFillColor,
contentPadding: const EdgeInsets.symmetric(horizontal: 20, vertical: 18),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(32),
borderSide: BorderSide.none,
),
hintStyle: theme.textTheme.bodyMedium?.copyWith(
color:
theme.textTheme.bodyMedium?.color?.withOpacity(0.6) ?? blackColor40,
fontWeight: FontWeight.w500,
),
);

return Scaffold(
body: SingleChildScrollView(
child: Column(
children: [
Image.asset(
"assets/images/login_dark.png",
body: Stack(
children: [
Positioned.fill(
child: SvgPicture.asset(
'assets/images/login_background.svg',
fit: BoxFit.cover,
),
Padding(
padding: const EdgeInsets.all(defaultPadding),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Welcome back!",
style: Theme.of(context).textTheme.headlineSmall,
),
const SizedBox(height: defaultPadding / 2),
const Text(
"Log in with your data that you intered during your registration.",
),
const SizedBox(height: defaultPadding),
LogInForm(
formKey: _formKey,
onEmailSaved: (email) => _email = email,
onPasswordSaved: (password) => _password = password,
),
Align(
child: TextButton(
child: const Text("Forgot password"),
onPressed: () {
Navigator.pushNamed(
context, passwordRecoveryScreenRoute);
},
),
SafeArea(
child: Align(
alignment: Alignment.center,
child: SingleChildScrollView(
padding: const EdgeInsets.symmetric(
horizontal: defaultPadding * 1.4,
vertical: defaultPadding * 1.2,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const SizedBox(height: defaultPadding * 1.5),
_buildLoginCard(
context: context,
decorationTheme: pillInputTheme,
buttonColor: brandPrimary,
),
],
),
),
),
),
],
),
);
}

Widget _buildLoginCard({
required BuildContext context,
required InputDecorationThemeData decorationTheme,
required Color buttonColor,
}) {
final theme = Theme.of(context);

return Container(
width: double.infinity,
padding: const EdgeInsets.all(defaultPadding * 1.5),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(36),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Cellphone",
style: (theme.textTheme.headlineLarge ??
theme.textTheme.headlineSmall ??
const TextStyle())
.copyWith(
fontWeight: FontWeight.w800,
color: buttonColor,
letterSpacing: -0.5,
),
),
const SizedBox(width: 8),
SvgPicture.asset(
'assets/logo/CellphoneZ.svg',
height: 48,
width: 48,
),
],
),
const SizedBox(height: defaultPadding * 1.5),
Theme(
data: theme.copyWith(
inputDecorationTheme: decorationTheme,
textSelectionTheme: TextSelectionThemeData(
cursorColor: buttonColor,
selectionColor: buttonColor.withOpacity(0.2),
selectionHandleColor: buttonColor,
),
),
child: LogInForm(
formKey: _formKey,
onEmailSaved: (email) => _email = email,
onPasswordSaved: (password) => _password = password,
),
),
Align(
alignment: Alignment.centerRight,
child: TextButton(
onPressed: () {
Navigator.pushNamed(context, passwordRecoveryScreenRoute);
},
style: TextButton.styleFrom(
foregroundColor: buttonColor,
),
child: const Text("Forgot password?"),
),
),
const SizedBox(height: defaultPadding),
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: _isLoading ? null : _handleLogin,
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 18),
backgroundColor: buttonColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(32),
),
elevation: 8,
shadowColor: buttonColor.withOpacity(0.4),
),
child: _isLoading
? const SizedBox(
height: 22,
width: 22,
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
),
)
: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Text(
"Login",
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
SizedBox(width: 8),
Icon(Icons.arrow_forward_rounded),
],
),
),
SizedBox(
height:
size.height > 700 ? size.height * 0.1 : defaultPadding,
),
ElevatedButton(
onPressed: _isLoading ? null : _handleLogin,
child: _isLoading
? const SizedBox(
height: 20,
width: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor:
AlwaysStoppedAnimation<Color>(Colors.white),
),
)
: const Text("Log in"),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text("Don't have an account?"),
TextButton(
onPressed: () {
Navigator.pushNamed(context, signUpScreenRoute);
},
child: const Text("Sign up"),
)
],
),
],
),
),
const SizedBox(height: defaultPadding / 2),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Don't have an account?",
style: theme.textTheme.bodyMedium?.copyWith(
color: theme.textTheme.bodyMedium?.color?.withOpacity(0.6) ??
blackColor60,
),
),
TextButton(
onPressed: () {
Navigator.pushNamed(context, signUpScreenRoute);
},
style: TextButton.styleFrom(
foregroundColor: buttonColor,
),
child: const Text("Sign up"),
),
)
],
),
],
),
],
),
);
}
Expand Down
Loading
Loading