feat:login page done
This commit is contained in:
@@ -13,6 +13,8 @@ import 'package:dio/dio.dart' as _i361;
|
||||
import 'package:get_it/get_it.dart' as _i174;
|
||||
import 'package:injectable/injectable.dart' as _i526;
|
||||
|
||||
import '../../feature/auth/presentation/blocs/login_bloc/login_bloc.dart'
|
||||
as _i1065;
|
||||
import '../../feature/basket/presentation/blocs/basket_bloc.dart' as _i728;
|
||||
import '../../feature/browse/presentation/blocs/browse_bloc/browse_bloc.dart'
|
||||
as _i991;
|
||||
@@ -40,6 +42,7 @@ extension GetItInjectableX on _i174.GetIt {
|
||||
final dioModule = _$DioModule();
|
||||
gh.factory<_i1007.HomeBloc>(() => _i1007.HomeBloc());
|
||||
gh.factory<_i728.BasketBloc>(() => _i728.BasketBloc());
|
||||
gh.factory<_i1065.LoginBloc>(() => _i1065.LoginBloc());
|
||||
gh.factory<_i991.BrowseBloc>(() => _i991.BrowseBloc());
|
||||
gh.factory<_i580.MainBloc>(() => _i580.MainBloc());
|
||||
gh.factory<_i311.SplashBloc>(() => _i311.SplashBloc());
|
||||
|
||||
31
lib/core/helpers/formatters.dart
Normal file
31
lib/core/helpers/formatters.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'package:mask_text_input_formatter/mask_text_input_formatter.dart';
|
||||
|
||||
abstract class Formatters {
|
||||
static final phoneFormatter = MaskTextInputFormatter(
|
||||
mask: '## ### ## ##',
|
||||
filter: {"#": RegExp(r'[0-9]')},
|
||||
type: MaskAutoCompletionType.lazy,
|
||||
);
|
||||
|
||||
static final cardFormatter = MaskTextInputFormatter(
|
||||
mask: '#### #### #### ####',
|
||||
filter: {"#": RegExp(r'[0-9]')},
|
||||
type: MaskAutoCompletionType.lazy,
|
||||
);
|
||||
static final cardNumberFormatter = MaskTextInputFormatter(
|
||||
mask: '#### #### #### ####',
|
||||
filter: {"#": RegExp(r'[0-9]')},
|
||||
type: MaskAutoCompletionType.lazy,
|
||||
);
|
||||
|
||||
static final cardExpirationDateFormatter = MaskTextInputFormatter(
|
||||
mask: '##/##',
|
||||
filter: {"#": RegExp(r'[0-9]')},
|
||||
type: MaskAutoCompletionType.lazy,
|
||||
);
|
||||
static final moneyFormatter = MaskTextInputFormatter(
|
||||
mask: '########',
|
||||
filter: {"#": RegExp(r'[0-9]')},
|
||||
type: MaskAutoCompletionType.lazy,
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:food_delivery_client/feature/auth/presentation/pages/login_page/login_page.dart';
|
||||
import 'package:food_delivery_client/feature/home/presentation/pages/restaurants_by_category_page/restaurants_by_category_page.dart';
|
||||
|
||||
import '../../food_delivery_client.dart';
|
||||
@@ -12,6 +13,11 @@ class AppRoutes {
|
||||
initialLocation: Routes.splash,
|
||||
routes: [
|
||||
GoRoute(path: Routes.splash, builder: (context, state) => SplashPage()),
|
||||
GoRoute(
|
||||
path: Routes.login,
|
||||
pageBuilder: (context, state) => CupertinoPage(child: LoginPage()),
|
||||
),
|
||||
|
||||
GoRoute(
|
||||
path: Routes.main,
|
||||
pageBuilder: (context, state) => CupertinoPage(child: MainPage()),
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
@@ -24,5 +24,6 @@ abstract class AppColors {
|
||||
static const Color c05A357 = Color(0xFF05A357);
|
||||
static const Color cE8E8E8 = Color(0xFFE8E8E8);
|
||||
static const Color c660000 = Color(0x66000000);
|
||||
static const Color c6A6E7F = Color(0xFF6A6E7F);
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,18 @@ import '../../food_delivery_client.dart';
|
||||
abstract class AppTheme {
|
||||
static ThemeData get lightTheme => ThemeData.light().copyWith(
|
||||
brightness: Brightness.light,
|
||||
|
||||
// colorScheme: ColorScheme(
|
||||
// brightness: Brightness.light,
|
||||
// primary: AppColors.cFFFFFF,
|
||||
// onPrimary:AppColors.cFFFFFF,
|
||||
// secondary: AppColors.cFFFFFF,
|
||||
// onSecondary: AppColors.cFFFFFF,
|
||||
// error:AppColors.cRed,
|
||||
// onError: AppColors.cRed,
|
||||
// surface: AppColors.cFFFFFF,
|
||||
// onSurface: AppColors.cFFFFFF,
|
||||
// ),
|
||||
appBarTheme: AppBarTheme(
|
||||
elevation: 0,
|
||||
backgroundColor: AppColors.cFFFFFF,
|
||||
@@ -10,14 +22,28 @@ abstract class AppTheme {
|
||||
surfaceTintColor: AppColors.cTransparent,
|
||||
),
|
||||
scaffoldBackgroundColor: AppColors.cFFFFFF,
|
||||
|
||||
progressIndicatorTheme: ProgressIndicatorThemeData(
|
||||
color: AppColors.cFFFFFF,
|
||||
circularTrackColor: AppColors.cFFFFFF,
|
||||
linearTrackColor: AppColors.cFFFFFF,
|
||||
borderRadius: BorderRadiusGeometry.circular(30),
|
||||
),
|
||||
|
||||
pageTransitionsTheme: PageTransitionsTheme(
|
||||
builders: {
|
||||
TargetPlatform.android: CupertinoPageTransitionsBuilder(),
|
||||
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
|
||||
},
|
||||
),
|
||||
bottomNavigationBarTheme: BottomNavigationBarThemeData(
|
||||
elevation:0,
|
||||
elevation: 0,
|
||||
showSelectedLabels: true,
|
||||
showUnselectedLabels: true,
|
||||
backgroundColor: AppColors.cFFFFFF,
|
||||
type: BottomNavigationBarType.fixed,
|
||||
unselectedItemColor: AppColors.cB5B5B5,
|
||||
selectedItemColor:AppColors.c000000,
|
||||
selectedItemColor: AppColors.c000000,
|
||||
selectedLabelStyle: AppTextStyles.size10Regular.copyWith(
|
||||
color: Colors.red,
|
||||
),
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:food_delivery_client/food_delivery_client.dart';
|
||||
|
||||
part 'login_event.dart';
|
||||
|
||||
part 'login_state.dart';
|
||||
|
||||
part 'login_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class LoginBloc extends Bloc<LoginEvent, LoginState> {
|
||||
LoginBloc() : super(const LoginState()) {
|
||||
on<_Login>(_onLogin);
|
||||
}
|
||||
|
||||
Future<void> _onLogin(_Login event, Emitter<LoginState> emit) async {
|
||||
emit(state.copyWith(status: RequestStatus.loading));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
part of 'login_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class LoginEvent with _$LoginEvent {
|
||||
const factory LoginEvent.checked() = _Checked;
|
||||
|
||||
const factory LoginEvent.login() = _Login;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
part of 'login_bloc.dart';
|
||||
|
||||
@freezed
|
||||
abstract class LoginState with _$LoginState {
|
||||
const factory LoginState({
|
||||
@Default(RequestStatus.initial) RequestStatus status,
|
||||
}) = _LoginState;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import 'package:food_delivery_client/feature/auth/presentation/blocs/login_bloc/login_bloc.dart';
|
||||
import 'package:food_delivery_client/feature/auth/presentation/pages/login_page/widgets/login_body.dart';
|
||||
|
||||
import '../../../../../food_delivery_client.dart';
|
||||
|
||||
class LoginPage extends StatelessWidget {
|
||||
const LoginPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => sl<LoginBloc>(),
|
||||
child: WLayout(
|
||||
child: Scaffold(
|
||||
body: WLoginBody(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:food_delivery_client/core/helpers/formatters.dart';
|
||||
|
||||
import '../../../../../../food_delivery_client.dart';
|
||||
import '../../../blocs/login_bloc/login_bloc.dart';
|
||||
|
||||
class WLoginBody extends StatefulWidget {
|
||||
const WLoginBody({super.key});
|
||||
|
||||
@override
|
||||
State<WLoginBody> createState() => _WLoginBodyState();
|
||||
}
|
||||
|
||||
class _WLoginBodyState extends State<WLoginBody> {
|
||||
late final TextEditingController _phoneController;
|
||||
late final TextEditingController _passwordController;
|
||||
final GlobalKey _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_phoneController = TextEditingController();
|
||||
_passwordController = TextEditingController();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_phoneController.dispose();
|
||||
_passwordController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<LoginBloc, LoginState>(
|
||||
builder: (context, state) {
|
||||
return Form(
|
||||
key: _formKey,
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
45.verticalSpace,
|
||||
Align(
|
||||
alignment: AlignmentGeometry.center,
|
||||
child: Text("Let's go", style: AppTextStyles.size24Bold),
|
||||
),
|
||||
20.verticalSpace,
|
||||
Text(
|
||||
'Phone number',
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.c6A6E7F,
|
||||
),
|
||||
),
|
||||
5.verticalSpace,
|
||||
AppTextFormField(
|
||||
height: 50,
|
||||
hintText: "Enter phone number",
|
||||
prefixIcon: Text(
|
||||
"+ 998",
|
||||
style: AppTextStyles.size16Regular.copyWith(fontSize: 16),
|
||||
),
|
||||
borderRadius: AppUtils.kBorderRadius8,
|
||||
controller: _phoneController,
|
||||
keyBoardType: TextInputType.number,
|
||||
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
Formatters.phoneFormatter,
|
||||
LengthLimitingTextInputFormatter(12),
|
||||
],
|
||||
),
|
||||
20.verticalSpace,
|
||||
Text(
|
||||
'Password',
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.c6A6E7F,
|
||||
),
|
||||
),
|
||||
5.verticalSpace,
|
||||
AppTextFormField(
|
||||
height: 50,
|
||||
hintText: "Enter password",
|
||||
keyBoardType: TextInputType.text,
|
||||
borderRadius: AppUtils.kBorderRadius8,
|
||||
controller: _passwordController,
|
||||
),
|
||||
Align(
|
||||
alignment: AlignmentGeometry.centerRight,
|
||||
child: TextButton(
|
||||
onPressed: () {},
|
||||
child: Text('Forgot password'),
|
||||
),
|
||||
),
|
||||
|
||||
const Spacer(),
|
||||
AppButton(
|
||||
name: "Continue",
|
||||
isLoading: state.status.isLoading(),
|
||||
onPressed: () {},
|
||||
borderRadius: 15,
|
||||
backgroundColor: AppColors.c34A853,
|
||||
),
|
||||
20.verticalSpace,
|
||||
],
|
||||
).paddingSymmetric(horizontal: 16),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
|
||||
import '../../../../food_delivery_client.dart';
|
||||
|
||||
|
||||
class AppButton extends StatelessWidget {
|
||||
const AppButton({
|
||||
super.key,
|
||||
required this.name,
|
||||
required this.onPressed,
|
||||
this.onPressed,
|
||||
this.margin,
|
||||
this.backgroundColor,
|
||||
this.borderRadius,
|
||||
@@ -16,10 +14,11 @@ class AppButton extends StatelessWidget {
|
||||
this.action,
|
||||
this.trailing,
|
||||
this.mainAxisAlignment,
|
||||
this.isLoading = false,
|
||||
});
|
||||
|
||||
final String name;
|
||||
final VoidCallback onPressed;
|
||||
final VoidCallback? onPressed;
|
||||
final EdgeInsets? margin;
|
||||
final Color? backgroundColor;
|
||||
final Color? textColor;
|
||||
@@ -28,6 +27,7 @@ class AppButton extends StatelessWidget {
|
||||
final double? height;
|
||||
final Widget? action;
|
||||
final Widget? trailing;
|
||||
final bool isLoading;
|
||||
final MainAxisAlignment? mainAxisAlignment;
|
||||
|
||||
@override
|
||||
@@ -45,16 +45,28 @@ class AppButton extends StatelessWidget {
|
||||
color: backgroundColor ?? AppColors.c000000,
|
||||
borderRadius: BorderRadius.circular(borderRadius ?? 0),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: mainAxisAlignment ?? MainAxisAlignment.center,
|
||||
children: [
|
||||
action ?? AppUtils.kSizedBox,
|
||||
Text(name, style: AppTextStyles.size16Bold.copyWith(
|
||||
color: AppColors.cFFFFFF
|
||||
)),
|
||||
trailing ?? AppUtils.kSizedBox,
|
||||
],
|
||||
),
|
||||
child: isLoading
|
||||
? Center(
|
||||
child: CircularProgressIndicator.adaptive(
|
||||
padding: EdgeInsets.all(2),
|
||||
valueColor: AlwaysStoppedAnimation(AppColors.cFFFFFF),
|
||||
backgroundColor: AppColors.cFFFFFF,
|
||||
),
|
||||
)
|
||||
: Row(
|
||||
mainAxisAlignment:
|
||||
mainAxisAlignment ?? MainAxisAlignment.center,
|
||||
children: [
|
||||
action ?? AppUtils.kSizedBox,
|
||||
Text(
|
||||
name,
|
||||
style: AppTextStyles.size16Bold.copyWith(
|
||||
color: AppColors.cFFFFFF,
|
||||
),
|
||||
),
|
||||
trailing ?? AppUtils.kSizedBox,
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,10 @@ class AppTextFormField extends StatelessWidget {
|
||||
this.obscureText = false,
|
||||
required this.controller,
|
||||
this.prefixIcon,
|
||||
this.prefixSvgPath, this.focusNode,
|
||||
this.prefixSvgPath,
|
||||
this.focusNode,
|
||||
this.borderRadius,
|
||||
this.height,
|
||||
});
|
||||
|
||||
final int? maxLines;
|
||||
@@ -37,57 +40,57 @@ class AppTextFormField extends StatelessWidget {
|
||||
late final Widget? prefixIcon;
|
||||
final String? prefixSvgPath;
|
||||
final FocusNode? focusNode;
|
||||
final BorderRadius? borderRadius;
|
||||
final double? height;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextFormField(
|
||||
enabled: true,
|
||||
autofocus: true,
|
||||
maxLines: maxLines ?? 1,
|
||||
minLines: minLines ?? 1,
|
||||
onChanged: onChanged,
|
||||
focusNode: focusNode,
|
||||
inputFormatters: inputFormatters,
|
||||
keyboardType: keyBoardType,
|
||||
style: textStyle ?? AppTextStyles.size16Regular,
|
||||
onTap: onTap,
|
||||
textAlign: textAlign ?? TextAlign.start,
|
||||
controller: controller,
|
||||
validator: validator,
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
decoration: InputDecoration(
|
||||
return SizedBox(
|
||||
height: height ?? 44,
|
||||
child: TextFormField(
|
||||
enabled: true,
|
||||
filled: true,
|
||||
fillColor: fillColor ?? AppColors.cEEEEEE,
|
||||
hintText: hintText,
|
||||
hintStyle: hintTextStyle,
|
||||
prefixIconConstraints: BoxConstraints(
|
||||
minHeight: 0,
|
||||
maxHeight: 24,
|
||||
maxWidth: 34,
|
||||
minWidth: 0,
|
||||
),
|
||||
prefixIcon: prefixIcon?.paddingOnly(left: 10).paddingAll(3),
|
||||
contentPadding: EdgeInsets.symmetric(vertical: 12, horizontal: 12),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: AppUtils.kBorderRadius40,
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderRadius: AppUtils.kBorderRadius40,
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: AppUtils.kBorderRadius40,
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: AppUtils.kBorderRadius40,
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
disabledBorder: OutlineInputBorder(
|
||||
borderRadius: AppUtils.kBorderRadius40,
|
||||
borderSide: BorderSide.none,
|
||||
autofocus: true,
|
||||
maxLines: maxLines ?? 1,
|
||||
minLines: minLines ?? 1,
|
||||
onChanged: onChanged,
|
||||
focusNode: focusNode,
|
||||
inputFormatters: inputFormatters,
|
||||
keyboardType: keyBoardType,
|
||||
style: textStyle ?? AppTextStyles.size16Regular,
|
||||
onTap: onTap,
|
||||
textAlign: textAlign ?? TextAlign.start,
|
||||
controller: controller,
|
||||
validator: validator,
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
decoration: InputDecoration(
|
||||
enabled: true,
|
||||
filled: true,
|
||||
fillColor: fillColor ?? AppColors.cEEEEEE,
|
||||
hintText: hintText,
|
||||
hintStyle: hintTextStyle,
|
||||
prefixIconConstraints: BoxConstraints(minHeight: 24, minWidth: 0),
|
||||
prefixIcon: prefixIcon?.paddingOnly(left: 10).paddingAll(3),
|
||||
contentPadding: EdgeInsets.symmetric(vertical: 12, horizontal: 12),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: borderRadius ?? AppUtils.kBorderRadius40,
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderRadius: borderRadius ?? AppUtils.kBorderRadius40,
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: borderRadius ?? AppUtils.kBorderRadius40,
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: borderRadius ?? AppUtils.kBorderRadius40,
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
disabledBorder: OutlineInputBorder(
|
||||
borderRadius: borderRadius ?? AppUtils.kBorderRadius40,
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:food_delivery_client/feature/on_boarding/presentation/blocs/splash_bloc/splash_bloc.dart';
|
||||
|
||||
import '../../../../../food_delivery_client.dart';
|
||||
@@ -13,7 +12,7 @@ class SplashPage extends StatelessWidget {
|
||||
child: BlocListener<SplashBloc, SplashState>(
|
||||
listener: (context, state) {
|
||||
if (state.status.isLoaded()) {
|
||||
context.go(Routes.main);
|
||||
context.go(Routes.login);
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
|
||||
Reference in New Issue
Block a user