Compare commits
2 Commits
4c652c2b47
...
b23808c731
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b23808c731 | ||
|
|
cdec9980af |
@@ -13,6 +13,8 @@ import 'package:dio/dio.dart' as _i361;
|
|||||||
import 'package:get_it/get_it.dart' as _i174;
|
import 'package:get_it/get_it.dart' as _i174;
|
||||||
import 'package:injectable/injectable.dart' as _i526;
|
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/basket/presentation/blocs/basket_bloc.dart' as _i728;
|
||||||
import '../../feature/browse/presentation/blocs/browse_bloc/browse_bloc.dart'
|
import '../../feature/browse/presentation/blocs/browse_bloc/browse_bloc.dart'
|
||||||
as _i991;
|
as _i991;
|
||||||
@@ -40,6 +42,7 @@ extension GetItInjectableX on _i174.GetIt {
|
|||||||
final dioModule = _$DioModule();
|
final dioModule = _$DioModule();
|
||||||
gh.factory<_i1007.HomeBloc>(() => _i1007.HomeBloc());
|
gh.factory<_i1007.HomeBloc>(() => _i1007.HomeBloc());
|
||||||
gh.factory<_i728.BasketBloc>(() => _i728.BasketBloc());
|
gh.factory<_i728.BasketBloc>(() => _i728.BasketBloc());
|
||||||
|
gh.factory<_i1065.LoginBloc>(() => _i1065.LoginBloc());
|
||||||
gh.factory<_i991.BrowseBloc>(() => _i991.BrowseBloc());
|
gh.factory<_i991.BrowseBloc>(() => _i991.BrowseBloc());
|
||||||
gh.factory<_i580.MainBloc>(() => _i580.MainBloc());
|
gh.factory<_i580.MainBloc>(() => _i580.MainBloc());
|
||||||
gh.factory<_i311.SplashBloc>(() => _i311.SplashBloc());
|
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: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 'package:food_delivery_client/feature/home/presentation/pages/restaurants_by_category_page/restaurants_by_category_page.dart';
|
||||||
|
|
||||||
import '../../food_delivery_client.dart';
|
import '../../food_delivery_client.dart';
|
||||||
@@ -12,6 +13,11 @@ class AppRoutes {
|
|||||||
initialLocation: Routes.splash,
|
initialLocation: Routes.splash,
|
||||||
routes: [
|
routes: [
|
||||||
GoRoute(path: Routes.splash, builder: (context, state) => SplashPage()),
|
GoRoute(path: Routes.splash, builder: (context, state) => SplashPage()),
|
||||||
|
GoRoute(
|
||||||
|
path: Routes.login,
|
||||||
|
pageBuilder: (context, state) => CupertinoPage(child: LoginPage()),
|
||||||
|
),
|
||||||
|
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: Routes.main,
|
path: Routes.main,
|
||||||
pageBuilder: (context, state) => CupertinoPage(child: MainPage()),
|
pageBuilder: (context, state) => CupertinoPage(child: MainPage()),
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'dart:developer';
|
|
||||||
|
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
|||||||
@@ -24,5 +24,6 @@ abstract class AppColors {
|
|||||||
static const Color c05A357 = Color(0xFF05A357);
|
static const Color c05A357 = Color(0xFF05A357);
|
||||||
static const Color cE8E8E8 = Color(0xFFE8E8E8);
|
static const Color cE8E8E8 = Color(0xFFE8E8E8);
|
||||||
static const Color c660000 = Color(0x66000000);
|
static const Color c660000 = Color(0x66000000);
|
||||||
|
static const Color c6A6E7F = Color(0xFF6A6E7F);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,18 @@ import '../../food_delivery_client.dart';
|
|||||||
abstract class AppTheme {
|
abstract class AppTheme {
|
||||||
static ThemeData get lightTheme => ThemeData.light().copyWith(
|
static ThemeData get lightTheme => ThemeData.light().copyWith(
|
||||||
brightness: Brightness.light,
|
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(
|
appBarTheme: AppBarTheme(
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
backgroundColor: AppColors.cFFFFFF,
|
backgroundColor: AppColors.cFFFFFF,
|
||||||
@@ -10,6 +22,20 @@ abstract class AppTheme {
|
|||||||
surfaceTintColor: AppColors.cTransparent,
|
surfaceTintColor: AppColors.cTransparent,
|
||||||
),
|
),
|
||||||
scaffoldBackgroundColor: AppColors.cFFFFFF,
|
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(
|
bottomNavigationBarTheme: BottomNavigationBarThemeData(
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
showSelectedLabels: true,
|
showSelectedLabels: true,
|
||||||
|
|||||||
@@ -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,501 @@
|
|||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
// coverage:ignore-file
|
||||||
|
// ignore_for_file: type=lint
|
||||||
|
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||||
|
|
||||||
|
part of 'login_bloc.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// FreezedGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
// dart format off
|
||||||
|
T _$identity<T>(T value) => value;
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$LoginEvent {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is LoginEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => runtimeType.hashCode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'LoginEvent()';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class $LoginEventCopyWith<$Res> {
|
||||||
|
$LoginEventCopyWith(LoginEvent _, $Res Function(LoginEvent) __);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Adds pattern-matching-related methods to [LoginEvent].
|
||||||
|
extension LoginEventPatterns on LoginEvent {
|
||||||
|
/// A variant of `map` that fallback to returning `orElse`.
|
||||||
|
///
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case final Subclass value:
|
||||||
|
/// return ...;
|
||||||
|
/// case _:
|
||||||
|
/// return orElse();
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult maybeMap<TResult extends Object?>({TResult Function( _Checked value)? checked,TResult Function( _Login value)? login,required TResult orElse(),}){
|
||||||
|
final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _Checked() when checked != null:
|
||||||
|
return checked(_that);case _Login() when login != null:
|
||||||
|
return login(_that);case _:
|
||||||
|
return orElse();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// A `switch`-like method, using callbacks.
|
||||||
|
///
|
||||||
|
/// Callbacks receives the raw object, upcasted.
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case final Subclass value:
|
||||||
|
/// return ...;
|
||||||
|
/// case final Subclass2 value:
|
||||||
|
/// return ...;
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult map<TResult extends Object?>({required TResult Function( _Checked value) checked,required TResult Function( _Login value) login,}){
|
||||||
|
final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _Checked():
|
||||||
|
return checked(_that);case _Login():
|
||||||
|
return login(_that);case _:
|
||||||
|
throw StateError('Unexpected subclass');
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// A variant of `map` that fallback to returning `null`.
|
||||||
|
///
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case final Subclass value:
|
||||||
|
/// return ...;
|
||||||
|
/// case _:
|
||||||
|
/// return null;
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( _Checked value)? checked,TResult? Function( _Login value)? login,}){
|
||||||
|
final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _Checked() when checked != null:
|
||||||
|
return checked(_that);case _Login() when login != null:
|
||||||
|
return login(_that);case _:
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// A variant of `when` that fallback to an `orElse` callback.
|
||||||
|
///
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case Subclass(:final field):
|
||||||
|
/// return ...;
|
||||||
|
/// case _:
|
||||||
|
/// return orElse();
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function()? checked,TResult Function()? login,required TResult orElse(),}) {final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _Checked() when checked != null:
|
||||||
|
return checked();case _Login() when login != null:
|
||||||
|
return login();case _:
|
||||||
|
return orElse();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// A `switch`-like method, using callbacks.
|
||||||
|
///
|
||||||
|
/// As opposed to `map`, this offers destructuring.
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case Subclass(:final field):
|
||||||
|
/// return ...;
|
||||||
|
/// case Subclass2(:final field2):
|
||||||
|
/// return ...;
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function() checked,required TResult Function() login,}) {final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _Checked():
|
||||||
|
return checked();case _Login():
|
||||||
|
return login();case _:
|
||||||
|
throw StateError('Unexpected subclass');
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// A variant of `when` that fallback to returning `null`
|
||||||
|
///
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case Subclass(:final field):
|
||||||
|
/// return ...;
|
||||||
|
/// case _:
|
||||||
|
/// return null;
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>({TResult? Function()? checked,TResult? Function()? login,}) {final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _Checked() when checked != null:
|
||||||
|
return checked();case _Login() when login != null:
|
||||||
|
return login();case _:
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
|
||||||
|
class _Checked implements LoginEvent {
|
||||||
|
const _Checked();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => runtimeType.hashCode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'LoginEvent.checked()';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
|
||||||
|
class _Login implements LoginEvent {
|
||||||
|
const _Login();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Login);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => runtimeType.hashCode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'LoginEvent.login()';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$LoginState {
|
||||||
|
|
||||||
|
RequestStatus get status;
|
||||||
|
/// Create a copy of LoginState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
$LoginStateCopyWith<LoginState> get copyWith => _$LoginStateCopyWithImpl<LoginState>(this as LoginState, _$identity);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is LoginState&&(identical(other.status, status) || other.status == status));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(runtimeType,status);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'LoginState(status: $status)';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract mixin class $LoginStateCopyWith<$Res> {
|
||||||
|
factory $LoginStateCopyWith(LoginState value, $Res Function(LoginState) _then) = _$LoginStateCopyWithImpl;
|
||||||
|
@useResult
|
||||||
|
$Res call({
|
||||||
|
RequestStatus status
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
/// @nodoc
|
||||||
|
class _$LoginStateCopyWithImpl<$Res>
|
||||||
|
implements $LoginStateCopyWith<$Res> {
|
||||||
|
_$LoginStateCopyWithImpl(this._self, this._then);
|
||||||
|
|
||||||
|
final LoginState _self;
|
||||||
|
final $Res Function(LoginState) _then;
|
||||||
|
|
||||||
|
/// Create a copy of LoginState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@pragma('vm:prefer-inline') @override $Res call({Object? status = null,}) {
|
||||||
|
return _then(_self.copyWith(
|
||||||
|
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||||
|
as RequestStatus,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Adds pattern-matching-related methods to [LoginState].
|
||||||
|
extension LoginStatePatterns on LoginState {
|
||||||
|
/// A variant of `map` that fallback to returning `orElse`.
|
||||||
|
///
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case final Subclass value:
|
||||||
|
/// return ...;
|
||||||
|
/// case _:
|
||||||
|
/// return orElse();
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _LoginState value)? $default,{required TResult orElse(),}){
|
||||||
|
final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _LoginState() when $default != null:
|
||||||
|
return $default(_that);case _:
|
||||||
|
return orElse();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// A `switch`-like method, using callbacks.
|
||||||
|
///
|
||||||
|
/// Callbacks receives the raw object, upcasted.
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case final Subclass value:
|
||||||
|
/// return ...;
|
||||||
|
/// case final Subclass2 value:
|
||||||
|
/// return ...;
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _LoginState value) $default,){
|
||||||
|
final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _LoginState():
|
||||||
|
return $default(_that);case _:
|
||||||
|
throw StateError('Unexpected subclass');
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// A variant of `map` that fallback to returning `null`.
|
||||||
|
///
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case final Subclass value:
|
||||||
|
/// return ...;
|
||||||
|
/// case _:
|
||||||
|
/// return null;
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _LoginState value)? $default,){
|
||||||
|
final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _LoginState() when $default != null:
|
||||||
|
return $default(_that);case _:
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// A variant of `when` that fallback to an `orElse` callback.
|
||||||
|
///
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case Subclass(:final field):
|
||||||
|
/// return ...;
|
||||||
|
/// case _:
|
||||||
|
/// return orElse();
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( RequestStatus status)? $default,{required TResult orElse(),}) {final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _LoginState() when $default != null:
|
||||||
|
return $default(_that.status);case _:
|
||||||
|
return orElse();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// A `switch`-like method, using callbacks.
|
||||||
|
///
|
||||||
|
/// As opposed to `map`, this offers destructuring.
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case Subclass(:final field):
|
||||||
|
/// return ...;
|
||||||
|
/// case Subclass2(:final field2):
|
||||||
|
/// return ...;
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( RequestStatus status) $default,) {final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _LoginState():
|
||||||
|
return $default(_that.status);case _:
|
||||||
|
throw StateError('Unexpected subclass');
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// A variant of `when` that fallback to returning `null`
|
||||||
|
///
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case Subclass(:final field):
|
||||||
|
/// return ...;
|
||||||
|
/// case _:
|
||||||
|
/// return null;
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( RequestStatus status)? $default,) {final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _LoginState() when $default != null:
|
||||||
|
return $default(_that.status);case _:
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
|
||||||
|
class _LoginState implements LoginState {
|
||||||
|
const _LoginState({this.status = RequestStatus.initial});
|
||||||
|
|
||||||
|
|
||||||
|
@override@JsonKey() final RequestStatus status;
|
||||||
|
|
||||||
|
/// Create a copy of LoginState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$LoginStateCopyWith<_LoginState> get copyWith => __$LoginStateCopyWithImpl<_LoginState>(this, _$identity);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LoginState&&(identical(other.status, status) || other.status == status));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(runtimeType,status);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'LoginState(status: $status)';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract mixin class _$LoginStateCopyWith<$Res> implements $LoginStateCopyWith<$Res> {
|
||||||
|
factory _$LoginStateCopyWith(_LoginState value, $Res Function(_LoginState) _then) = __$LoginStateCopyWithImpl;
|
||||||
|
@override @useResult
|
||||||
|
$Res call({
|
||||||
|
RequestStatus status
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
/// @nodoc
|
||||||
|
class __$LoginStateCopyWithImpl<$Res>
|
||||||
|
implements _$LoginStateCopyWith<$Res> {
|
||||||
|
__$LoginStateCopyWithImpl(this._self, this._then);
|
||||||
|
|
||||||
|
final _LoginState _self;
|
||||||
|
final $Res Function(_LoginState) _then;
|
||||||
|
|
||||||
|
/// Create a copy of LoginState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@override @pragma('vm:prefer-inline') $Res call({Object? status = null,}) {
|
||||||
|
return _then(_LoginState(
|
||||||
|
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||||
|
as RequestStatus,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// dart format on
|
||||||
@@ -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';
|
import '../../../../food_delivery_client.dart';
|
||||||
|
|
||||||
|
|
||||||
class AppButton extends StatelessWidget {
|
class AppButton extends StatelessWidget {
|
||||||
const AppButton({
|
const AppButton({
|
||||||
super.key,
|
super.key,
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.onPressed,
|
this.onPressed,
|
||||||
this.margin,
|
this.margin,
|
||||||
this.backgroundColor,
|
this.backgroundColor,
|
||||||
this.borderRadius,
|
this.borderRadius,
|
||||||
@@ -16,10 +14,11 @@ class AppButton extends StatelessWidget {
|
|||||||
this.action,
|
this.action,
|
||||||
this.trailing,
|
this.trailing,
|
||||||
this.mainAxisAlignment,
|
this.mainAxisAlignment,
|
||||||
|
this.isLoading = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String name;
|
final String name;
|
||||||
final VoidCallback onPressed;
|
final VoidCallback? onPressed;
|
||||||
final EdgeInsets? margin;
|
final EdgeInsets? margin;
|
||||||
final Color? backgroundColor;
|
final Color? backgroundColor;
|
||||||
final Color? textColor;
|
final Color? textColor;
|
||||||
@@ -28,6 +27,7 @@ class AppButton extends StatelessWidget {
|
|||||||
final double? height;
|
final double? height;
|
||||||
final Widget? action;
|
final Widget? action;
|
||||||
final Widget? trailing;
|
final Widget? trailing;
|
||||||
|
final bool isLoading;
|
||||||
final MainAxisAlignment? mainAxisAlignment;
|
final MainAxisAlignment? mainAxisAlignment;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -45,13 +45,25 @@ class AppButton extends StatelessWidget {
|
|||||||
color: backgroundColor ?? AppColors.c000000,
|
color: backgroundColor ?? AppColors.c000000,
|
||||||
borderRadius: BorderRadius.circular(borderRadius ?? 0),
|
borderRadius: BorderRadius.circular(borderRadius ?? 0),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: isLoading
|
||||||
mainAxisAlignment: mainAxisAlignment ?? MainAxisAlignment.center,
|
? Center(
|
||||||
|
child: CircularProgressIndicator.adaptive(
|
||||||
|
padding: EdgeInsets.all(2),
|
||||||
|
valueColor: AlwaysStoppedAnimation(AppColors.cFFFFFF),
|
||||||
|
backgroundColor: AppColors.cFFFFFF,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Row(
|
||||||
|
mainAxisAlignment:
|
||||||
|
mainAxisAlignment ?? MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
action ?? AppUtils.kSizedBox,
|
action ?? AppUtils.kSizedBox,
|
||||||
Text(name, style: AppTextStyles.size16Bold.copyWith(
|
Text(
|
||||||
color: AppColors.cFFFFFF
|
name,
|
||||||
)),
|
style: AppTextStyles.size16Bold.copyWith(
|
||||||
|
color: AppColors.cFFFFFF,
|
||||||
|
),
|
||||||
|
),
|
||||||
trailing ?? AppUtils.kSizedBox,
|
trailing ?? AppUtils.kSizedBox,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -17,7 +17,10 @@ class AppTextFormField extends StatelessWidget {
|
|||||||
this.obscureText = false,
|
this.obscureText = false,
|
||||||
required this.controller,
|
required this.controller,
|
||||||
this.prefixIcon,
|
this.prefixIcon,
|
||||||
this.prefixSvgPath, this.focusNode,
|
this.prefixSvgPath,
|
||||||
|
this.focusNode,
|
||||||
|
this.borderRadius,
|
||||||
|
this.height,
|
||||||
});
|
});
|
||||||
|
|
||||||
final int? maxLines;
|
final int? maxLines;
|
||||||
@@ -37,10 +40,14 @@ class AppTextFormField extends StatelessWidget {
|
|||||||
late final Widget? prefixIcon;
|
late final Widget? prefixIcon;
|
||||||
final String? prefixSvgPath;
|
final String? prefixSvgPath;
|
||||||
final FocusNode? focusNode;
|
final FocusNode? focusNode;
|
||||||
|
final BorderRadius? borderRadius;
|
||||||
|
final double? height;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return TextFormField(
|
return SizedBox(
|
||||||
|
height: height ?? 44,
|
||||||
|
child: TextFormField(
|
||||||
enabled: true,
|
enabled: true,
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
maxLines: maxLines ?? 1,
|
maxLines: maxLines ?? 1,
|
||||||
@@ -61,35 +68,31 @@ class AppTextFormField extends StatelessWidget {
|
|||||||
fillColor: fillColor ?? AppColors.cEEEEEE,
|
fillColor: fillColor ?? AppColors.cEEEEEE,
|
||||||
hintText: hintText,
|
hintText: hintText,
|
||||||
hintStyle: hintTextStyle,
|
hintStyle: hintTextStyle,
|
||||||
prefixIconConstraints: BoxConstraints(
|
prefixIconConstraints: BoxConstraints(minHeight: 24, minWidth: 0),
|
||||||
minHeight: 0,
|
|
||||||
maxHeight: 24,
|
|
||||||
maxWidth: 34,
|
|
||||||
minWidth: 0,
|
|
||||||
),
|
|
||||||
prefixIcon: prefixIcon?.paddingOnly(left: 10).paddingAll(3),
|
prefixIcon: prefixIcon?.paddingOnly(left: 10).paddingAll(3),
|
||||||
contentPadding: EdgeInsets.symmetric(vertical: 12, horizontal: 12),
|
contentPadding: EdgeInsets.symmetric(vertical: 12, horizontal: 12),
|
||||||
border: OutlineInputBorder(
|
border: OutlineInputBorder(
|
||||||
borderRadius: AppUtils.kBorderRadius40,
|
borderRadius: borderRadius ?? AppUtils.kBorderRadius40,
|
||||||
borderSide: BorderSide.none,
|
borderSide: BorderSide.none,
|
||||||
),
|
),
|
||||||
errorBorder: OutlineInputBorder(
|
errorBorder: OutlineInputBorder(
|
||||||
borderRadius: AppUtils.kBorderRadius40,
|
borderRadius: borderRadius ?? AppUtils.kBorderRadius40,
|
||||||
borderSide: BorderSide.none,
|
borderSide: BorderSide.none,
|
||||||
),
|
),
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: OutlineInputBorder(
|
||||||
borderRadius: AppUtils.kBorderRadius40,
|
borderRadius: borderRadius ?? AppUtils.kBorderRadius40,
|
||||||
borderSide: BorderSide.none,
|
borderSide: BorderSide.none,
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: OutlineInputBorder(
|
||||||
borderRadius: AppUtils.kBorderRadius40,
|
borderRadius: borderRadius ?? AppUtils.kBorderRadius40,
|
||||||
borderSide: BorderSide.none,
|
borderSide: BorderSide.none,
|
||||||
),
|
),
|
||||||
disabledBorder: OutlineInputBorder(
|
disabledBorder: OutlineInputBorder(
|
||||||
borderRadius: AppUtils.kBorderRadius40,
|
borderRadius: borderRadius ?? AppUtils.kBorderRadius40,
|
||||||
borderSide: BorderSide.none,
|
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 'package:food_delivery_client/feature/on_boarding/presentation/blocs/splash_bloc/splash_bloc.dart';
|
||||||
|
|
||||||
import '../../../../../food_delivery_client.dart';
|
import '../../../../../food_delivery_client.dart';
|
||||||
@@ -13,7 +12,7 @@ class SplashPage extends StatelessWidget {
|
|||||||
child: BlocListener<SplashBloc, SplashState>(
|
child: BlocListener<SplashBloc, SplashState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state.status.isLoaded()) {
|
if (state.status.isLoaded()) {
|
||||||
context.go(Routes.main);
|
context.go(Routes.login);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
|
|||||||
@@ -477,6 +477,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.0"
|
version: "1.3.0"
|
||||||
|
mask_text_input_formatter:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: mask_text_input_formatter
|
||||||
|
sha256: "978c58ec721c25621ceb468e633f4eef64b64d45424ac4540e0565d4f7c800cd"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.9.0"
|
||||||
matcher:
|
matcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ dependencies:
|
|||||||
carousel_slider: ^5.1.1
|
carousel_slider: ^5.1.1
|
||||||
equatable: ^2.0.7
|
equatable: ^2.0.7
|
||||||
dartz: ^0.10.1
|
dartz: ^0.10.1
|
||||||
|
mask_text_input_formatter: ^2.9.0
|
||||||
|
|
||||||
|
|
||||||
#DI
|
#DI
|
||||||
get_it: ^8.2.0
|
get_it: ^8.2.0
|
||||||
|
|||||||
Reference in New Issue
Block a user