Initial commit
This commit is contained in:
1
lib/feature/account/account.dart
Normal file
1
lib/feature/account/account.dart
Normal file
@@ -0,0 +1 @@
|
||||
export 'presentation/pages/account_page/account_page.dart';
|
||||
@@ -0,0 +1,42 @@
|
||||
import '../../../../../food_delivery_client.dart';
|
||||
|
||||
class AccountPage extends StatelessWidget {
|
||||
const AccountPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<LanguageBloc, LanguageState>(
|
||||
builder: (context, state) {
|
||||
return WLayout(
|
||||
child: Scaffold(
|
||||
body: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Text(context.loc.iCantSignIn),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
if (state.currentLocale == Locale("uz")) {
|
||||
context.read<LanguageBloc>().add(
|
||||
LanguageEvent.changed(Locale('ru')),
|
||||
);
|
||||
} else if (state.currentLocale == Locale("ru")) {
|
||||
context.read<LanguageBloc>().add(
|
||||
LanguageEvent.changed(Locale('en')),
|
||||
);
|
||||
} else {
|
||||
context.read<LanguageBloc>().add(
|
||||
LanguageEvent.changed(Locale('uz')),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text("changelang"),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
1
lib/feature/basket/basket.dart
Normal file
1
lib/feature/basket/basket.dart
Normal file
@@ -0,0 +1 @@
|
||||
export 'presentation/pages/basket_page/basket_page.dart';
|
||||
@@ -0,0 +1,12 @@
|
||||
import '../../../../../food_delivery_client.dart';
|
||||
|
||||
class BasketPage extends StatelessWidget {
|
||||
const BasketPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WLayout(
|
||||
child: Scaffold(body: Center(child: Text(context.loc.useYourTAxiAccount))),
|
||||
);
|
||||
}
|
||||
}
|
||||
1
lib/feature/browse/browse.dart
Normal file
1
lib/feature/browse/browse.dart
Normal file
@@ -0,0 +1 @@
|
||||
export 'presentation/pages/browse_page/browse_page.dart';
|
||||
@@ -0,0 +1,12 @@
|
||||
import '../../../../../food_delivery_client.dart';
|
||||
|
||||
class BrowsePage extends StatelessWidget {
|
||||
const BrowsePage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WLayout(
|
||||
child: Scaffold(body: Center(child: Text(context.loc.mobileNumber))),
|
||||
);
|
||||
}
|
||||
}
|
||||
2
lib/feature/common/common.dart
Normal file
2
lib/feature/common/common.dart
Normal file
@@ -0,0 +1,2 @@
|
||||
export 'presentation/widgets/widgets.dart';
|
||||
export 'presentation/blocs/language_bloc/language_bloc.dart';
|
||||
@@ -0,0 +1,36 @@
|
||||
|
||||
import '../../../../../food_delivery_client.dart';
|
||||
|
||||
part 'language_event.dart';
|
||||
|
||||
part 'language_state.dart';
|
||||
|
||||
part 'language_bloc.freezed.dart';
|
||||
@injectable
|
||||
class LanguageBloc extends Bloc<LanguageEvent, LanguageState> {
|
||||
final StorageService _storageService;
|
||||
|
||||
LanguageBloc(this._storageService) : super(const LanguageState()) {
|
||||
on<_Started>(_onStarted);
|
||||
|
||||
on<_Changeded>(_onChanged);
|
||||
}
|
||||
|
||||
Future<void> _onStarted(_Started event, Emitter<LanguageState> emit) async {
|
||||
final lang = _storageService.getString(key: AppLocaleKeys.language);
|
||||
|
||||
if (lang != null) {
|
||||
emit(state.copyWith(currentLocale: Locale(lang)));
|
||||
} else {
|
||||
emit(state.copyWith(currentLocale: Locale("en")));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onChanged(_Changeded event, Emitter<LanguageState> emit) async {
|
||||
_storageService.setString(
|
||||
key: AppLocaleKeys.language,
|
||||
value: event.locale.languageCode,
|
||||
);
|
||||
emit(state.copyWith(currentLocale: event.locale));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,535 @@
|
||||
// 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 'language_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$LanguageEvent {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LanguageEvent);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LanguageEvent()';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class $LanguageEventCopyWith<$Res> {
|
||||
$LanguageEventCopyWith(LanguageEvent _, $Res Function(LanguageEvent) __);
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LanguageEvent].
|
||||
extension LanguageEventPatterns on LanguageEvent {
|
||||
/// 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( _Started value)? started,TResult Function( _Changeded value)? changed,required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _Started() when started != null:
|
||||
return started(_that);case _Changeded() when changed != null:
|
||||
return changed(_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( _Started value) started,required TResult Function( _Changeded value) changed,}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _Started():
|
||||
return started(_that);case _Changeded():
|
||||
return changed(_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( _Started value)? started,TResult? Function( _Changeded value)? changed,}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _Started() when started != null:
|
||||
return started(_that);case _Changeded() when changed != null:
|
||||
return changed(_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()? started,TResult Function( Locale locale)? changed,required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _Started() when started != null:
|
||||
return started();case _Changeded() when changed != null:
|
||||
return changed(_that.locale);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() started,required TResult Function( Locale locale) changed,}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _Started():
|
||||
return started();case _Changeded():
|
||||
return changed(_that.locale);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()? started,TResult? Function( Locale locale)? changed,}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _Started() when started != null:
|
||||
return started();case _Changeded() when changed != null:
|
||||
return changed(_that.locale);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _Started implements LanguageEvent {
|
||||
const _Started();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Started);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LanguageEvent.started()';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _Changeded implements LanguageEvent {
|
||||
const _Changeded(this.locale);
|
||||
|
||||
|
||||
final Locale locale;
|
||||
|
||||
/// Create a copy of LanguageEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$ChangededCopyWith<_Changeded> get copyWith => __$ChangededCopyWithImpl<_Changeded>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Changeded&&(identical(other.locale, locale) || other.locale == locale));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,locale);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LanguageEvent.changed(locale: $locale)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$ChangededCopyWith<$Res> implements $LanguageEventCopyWith<$Res> {
|
||||
factory _$ChangededCopyWith(_Changeded value, $Res Function(_Changeded) _then) = __$ChangededCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
Locale locale
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$ChangededCopyWithImpl<$Res>
|
||||
implements _$ChangededCopyWith<$Res> {
|
||||
__$ChangededCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _Changeded _self;
|
||||
final $Res Function(_Changeded) _then;
|
||||
|
||||
/// Create a copy of LanguageEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') $Res call({Object? locale = null,}) {
|
||||
return _then(_Changeded(
|
||||
null == locale ? _self.locale : locale // ignore: cast_nullable_to_non_nullable
|
||||
as Locale,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$LanguageState {
|
||||
|
||||
Locale get currentLocale;
|
||||
/// Create a copy of LanguageState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$LanguageStateCopyWith<LanguageState> get copyWith => _$LanguageStateCopyWithImpl<LanguageState>(this as LanguageState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LanguageState&&(identical(other.currentLocale, currentLocale) || other.currentLocale == currentLocale));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,currentLocale);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LanguageState(currentLocale: $currentLocale)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $LanguageStateCopyWith<$Res> {
|
||||
factory $LanguageStateCopyWith(LanguageState value, $Res Function(LanguageState) _then) = _$LanguageStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
Locale currentLocale
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$LanguageStateCopyWithImpl<$Res>
|
||||
implements $LanguageStateCopyWith<$Res> {
|
||||
_$LanguageStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final LanguageState _self;
|
||||
final $Res Function(LanguageState) _then;
|
||||
|
||||
/// Create a copy of LanguageState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? currentLocale = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
currentLocale: null == currentLocale ? _self.currentLocale : currentLocale // ignore: cast_nullable_to_non_nullable
|
||||
as Locale,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LanguageState].
|
||||
extension LanguageStatePatterns on LanguageState {
|
||||
/// 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( _LanguageState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LanguageState() 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( _LanguageState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LanguageState():
|
||||
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( _LanguageState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LanguageState() 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( Locale currentLocale)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LanguageState() when $default != null:
|
||||
return $default(_that.currentLocale);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( Locale currentLocale) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LanguageState():
|
||||
return $default(_that.currentLocale);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( Locale currentLocale)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LanguageState() when $default != null:
|
||||
return $default(_that.currentLocale);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _LanguageState implements LanguageState {
|
||||
const _LanguageState({this.currentLocale = const Locale('en')});
|
||||
|
||||
|
||||
@override@JsonKey() final Locale currentLocale;
|
||||
|
||||
/// Create a copy of LanguageState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$LanguageStateCopyWith<_LanguageState> get copyWith => __$LanguageStateCopyWithImpl<_LanguageState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LanguageState&&(identical(other.currentLocale, currentLocale) || other.currentLocale == currentLocale));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,currentLocale);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LanguageState(currentLocale: $currentLocale)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$LanguageStateCopyWith<$Res> implements $LanguageStateCopyWith<$Res> {
|
||||
factory _$LanguageStateCopyWith(_LanguageState value, $Res Function(_LanguageState) _then) = __$LanguageStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
Locale currentLocale
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$LanguageStateCopyWithImpl<$Res>
|
||||
implements _$LanguageStateCopyWith<$Res> {
|
||||
__$LanguageStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _LanguageState _self;
|
||||
final $Res Function(_LanguageState) _then;
|
||||
|
||||
/// Create a copy of LanguageState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? currentLocale = null,}) {
|
||||
return _then(_LanguageState(
|
||||
currentLocale: null == currentLocale ? _self.currentLocale : currentLocale // ignore: cast_nullable_to_non_nullable
|
||||
as Locale,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,8 @@
|
||||
part of 'language_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class LanguageEvent with _$LanguageEvent {
|
||||
const factory LanguageEvent.started() = _Started;
|
||||
|
||||
const factory LanguageEvent.changed(Locale locale) = _Changeded;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
part of 'language_bloc.dart';
|
||||
|
||||
@freezed
|
||||
abstract class LanguageState with _$LanguageState {
|
||||
const factory LanguageState({@Default(Locale('en')) Locale currentLocale}) =
|
||||
_LanguageState;
|
||||
}
|
||||
25
lib/feature/common/presentation/widgets/w_divider.dart
Normal file
25
lib/feature/common/presentation/widgets/w_divider.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
import '../../../../food_delivery_client.dart';
|
||||
|
||||
class WDivider extends StatelessWidget {
|
||||
const WDivider({
|
||||
super.key,
|
||||
this.height = 10,
|
||||
this.endIndent = 0,
|
||||
this.indent = 0,
|
||||
});
|
||||
|
||||
final double height;
|
||||
final double endIndent;
|
||||
final double indent;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Divider(
|
||||
color: AppColors.cF6F6F6,
|
||||
height: height,
|
||||
thickness: height,
|
||||
endIndent: 0,
|
||||
indent: 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
144
lib/feature/common/presentation/widgets/w_food_item.dart
Normal file
144
lib/feature/common/presentation/widgets/w_food_item.dart
Normal file
@@ -0,0 +1,144 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter_bounceable/flutter_bounceable.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
import '../../../../food_delivery_client.dart';
|
||||
|
||||
class WFoodItem extends StatelessWidget {
|
||||
const WFoodItem({
|
||||
super.key,
|
||||
this.imageHeight,
|
||||
this.textStyle1,
|
||||
this.textStyle2,
|
||||
this.enableTag = false,
|
||||
});
|
||||
|
||||
final double? imageHeight;
|
||||
final TextStyle? textStyle1;
|
||||
final TextStyle? textStyle2;
|
||||
final bool enableTag;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Bounceable(
|
||||
onTap: () {},
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// CachedNetworkImage(
|
||||
// imageUrl: AppLocaleKeys.imageUrl,
|
||||
// width: 200,
|
||||
// height: 155,
|
||||
// fit: BoxFit.cover,
|
||||
// placeholder: (context, url) => CircularProgressIndicator(),
|
||||
// errorWidget: (context, url, error) => Icon(Icons.error),
|
||||
//
|
||||
// ),
|
||||
SizedBox(
|
||||
height: imageHeight ?? 155,
|
||||
width: context.w,
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: AppLocaleKeys.imageUrl,
|
||||
width: 200,
|
||||
height: 155,
|
||||
fit: BoxFit.cover,
|
||||
placeholder: (context, url) =>
|
||||
Center(child: CircularProgressIndicator.adaptive()),
|
||||
errorWidget: (context, url, error) => Icon(Icons.error),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 10,
|
||||
right: 8,
|
||||
left: 0,
|
||||
child: Row(
|
||||
children: [
|
||||
if (enableTag)
|
||||
DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.c34A853,
|
||||
borderRadius: AppUtils.kBorderRadiusTop20Bottom20,
|
||||
),
|
||||
child: Text(
|
||||
"5 orders until \$8 reward",
|
||||
style: AppTextStyles.size14Medium.copyWith(
|
||||
color: AppColors.cFFFFFF,
|
||||
),
|
||||
).paddingOnly(top: 2, bottom: 2, left: 20, right: 40),
|
||||
),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
onPressed: () {},
|
||||
icon: SvgPicture.asset(AppIcons.icDislike),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
8.verticalSpace,
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"Adenine Kitchen",
|
||||
style: textStyle1 ?? AppTextStyles.size16Medium,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 24,
|
||||
width: 24,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.cEEEEEE,
|
||||
borderRadius: AppUtils.kBorderRadius28,
|
||||
),
|
||||
child: Center(
|
||||
child: Text("4.4", style: AppTextStyles.size12Regular),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// RichText(
|
||||
// text: TextSpan(
|
||||
// text: "\$0.29 Delivery Fee",
|
||||
// children: [TextSpan(text: "10-25 min")],
|
||||
// style: AppTextStyles.size14Regular.copyWith(
|
||||
// color: AppColors.c6B6B6B,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
"\$0.29 Delivery Fee",
|
||||
style:
|
||||
textStyle2 ??
|
||||
AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.c6B6B6B,
|
||||
),
|
||||
),
|
||||
5.horizontalSpace,
|
||||
Icon(Icons.circle, size: 5, color: AppColors.c6B6B6B),
|
||||
5.horizontalSpace,
|
||||
Text(
|
||||
"10-25 min",
|
||||
style:
|
||||
textStyle2 ??
|
||||
AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.c6B6B6B,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
).paddingSymmetric(horizontal: 15),
|
||||
);
|
||||
}
|
||||
}
|
||||
24
lib/feature/common/presentation/widgets/w_layout.dart
Normal file
24
lib/feature/common/presentation/widgets/w_layout.dart
Normal file
@@ -0,0 +1,24 @@
|
||||
import '../../../../food_delivery_client.dart';
|
||||
|
||||
class WLayout extends StatelessWidget {
|
||||
const WLayout({
|
||||
super.key,
|
||||
this.bgColor = AppColors.cFFFFFF,
|
||||
this.bottom = true,
|
||||
this.top = true,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
final Color bgColor;
|
||||
final bool bottom;
|
||||
final bool top;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: bgColor,
|
||||
child: SafeArea(top: top, bottom: bottom, child: child),
|
||||
);
|
||||
}
|
||||
}
|
||||
21
lib/feature/common/presentation/widgets/w_see_all_raw.dart
Normal file
21
lib/feature/common/presentation/widgets/w_see_all_raw.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
import '../../../../food_delivery_client.dart';
|
||||
|
||||
class WSeeAllRaw extends StatelessWidget {
|
||||
const WSeeAllRaw({super.key, required this.title, required this.onPressed});
|
||||
|
||||
final String title;
|
||||
final VoidCallback onPressed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(child: Text(title, style: AppTextStyles.size24Bold)),
|
||||
TextButton(
|
||||
onPressed: onPressed,
|
||||
child: Text("see all", style: AppTextStyles.size16Medium),
|
||||
),
|
||||
],
|
||||
).paddingOnly(left: 15, right: 8);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import '../../../../food_delivery_client.dart';
|
||||
|
||||
class WStoriesListItem extends StatelessWidget {
|
||||
const WStoriesListItem({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 200,
|
||||
width: 155,
|
||||
child: ClipRRect(
|
||||
borderRadius: AppUtils.kBorderRadius10,
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: AppLocaleKeys.imageUrl,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
||||
|
||||
|
||||
],
|
||||
)
|
||||
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
5
lib/feature/common/presentation/widgets/widgets.dart
Normal file
5
lib/feature/common/presentation/widgets/widgets.dart
Normal file
@@ -0,0 +1,5 @@
|
||||
export 'w_layout.dart';
|
||||
export 'w_food_item.dart';
|
||||
export 'w_divider.dart';
|
||||
export 'w_see_all_raw.dart';
|
||||
export 'w_stories_list_item.dart';
|
||||
11
lib/feature/home/home.dart
Normal file
11
lib/feature/home/home.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
export 'presentation/pages/home_page/home_page.dart';
|
||||
export 'presentation/blocs/home_bloc/home_bloc.dart';
|
||||
export 'presentation/pages/home_page/widgets/w_home_headers.dart';
|
||||
export 'presentation/widgets/w_category_item.dart';
|
||||
export "presentation/pages/home_page/widgets/w_categories_header_item.dart";
|
||||
export 'presentation/pages/home_page/widgets/w_delivery_header.dart';
|
||||
export 'presentation/pages/home_page/widgets/w_discount_part.dart';
|
||||
export 'presentation/pages/home_page/widgets/w_offers_carouseL_slider.dart';
|
||||
export 'presentation/pages/home_page/widgets/w_popular_near_you.dart';
|
||||
export 'presentation/pages/home_page/widgets/w_todays_offers.dart';
|
||||
export 'package:food_delivery_client/feature/home/presentation/pages/home_page/widgets/pick_it_for_free.dart';
|
||||
17
lib/feature/home/presentation/blocs/home_bloc/home_bloc.dart
Normal file
17
lib/feature/home/presentation/blocs/home_bloc/home_bloc.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
import 'package:food_delivery_client/food_delivery_client.dart';
|
||||
|
||||
part 'home_event.dart';
|
||||
|
||||
part 'home_state.dart';
|
||||
|
||||
part 'home_bloc.freezed.dart';
|
||||
@injectable
|
||||
class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
||||
HomeBloc() : super(const HomeState()) {
|
||||
on<_Changed>(_onChanged);
|
||||
}
|
||||
|
||||
void _onChanged(_Changed event, Emitter<HomeState> emit) {
|
||||
emit(state.copyWith(currentIndex: event.index));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,535 @@
|
||||
// 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 'home_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$HomeEvent {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is HomeEvent);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'HomeEvent()';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class $HomeEventCopyWith<$Res> {
|
||||
$HomeEventCopyWith(HomeEvent _, $Res Function(HomeEvent) __);
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [HomeEvent].
|
||||
extension HomeEventPatterns on HomeEvent {
|
||||
/// 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( _Started value)? started,TResult Function( _Changed value)? changed,required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _Started() when started != null:
|
||||
return started(_that);case _Changed() when changed != null:
|
||||
return changed(_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( _Started value) started,required TResult Function( _Changed value) changed,}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _Started():
|
||||
return started(_that);case _Changed():
|
||||
return changed(_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( _Started value)? started,TResult? Function( _Changed value)? changed,}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _Started() when started != null:
|
||||
return started(_that);case _Changed() when changed != null:
|
||||
return changed(_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()? started,TResult Function( int index)? changed,required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _Started() when started != null:
|
||||
return started();case _Changed() when changed != null:
|
||||
return changed(_that.index);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() started,required TResult Function( int index) changed,}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _Started():
|
||||
return started();case _Changed():
|
||||
return changed(_that.index);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()? started,TResult? Function( int index)? changed,}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _Started() when started != null:
|
||||
return started();case _Changed() when changed != null:
|
||||
return changed(_that.index);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _Started implements HomeEvent {
|
||||
const _Started();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Started);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'HomeEvent.started()';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _Changed implements HomeEvent {
|
||||
const _Changed(this.index);
|
||||
|
||||
|
||||
final int index;
|
||||
|
||||
/// Create a copy of HomeEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$ChangedCopyWith<_Changed> get copyWith => __$ChangedCopyWithImpl<_Changed>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Changed&&(identical(other.index, index) || other.index == index));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,index);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'HomeEvent.changed(index: $index)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$ChangedCopyWith<$Res> implements $HomeEventCopyWith<$Res> {
|
||||
factory _$ChangedCopyWith(_Changed value, $Res Function(_Changed) _then) = __$ChangedCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
int index
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$ChangedCopyWithImpl<$Res>
|
||||
implements _$ChangedCopyWith<$Res> {
|
||||
__$ChangedCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _Changed _self;
|
||||
final $Res Function(_Changed) _then;
|
||||
|
||||
/// Create a copy of HomeEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') $Res call({Object? index = null,}) {
|
||||
return _then(_Changed(
|
||||
null == index ? _self.index : index // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$HomeState {
|
||||
|
||||
int get currentIndex;
|
||||
/// Create a copy of HomeState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$HomeStateCopyWith<HomeState> get copyWith => _$HomeStateCopyWithImpl<HomeState>(this as HomeState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is HomeState&&(identical(other.currentIndex, currentIndex) || other.currentIndex == currentIndex));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,currentIndex);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'HomeState(currentIndex: $currentIndex)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $HomeStateCopyWith<$Res> {
|
||||
factory $HomeStateCopyWith(HomeState value, $Res Function(HomeState) _then) = _$HomeStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
int currentIndex
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$HomeStateCopyWithImpl<$Res>
|
||||
implements $HomeStateCopyWith<$Res> {
|
||||
_$HomeStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final HomeState _self;
|
||||
final $Res Function(HomeState) _then;
|
||||
|
||||
/// Create a copy of HomeState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? currentIndex = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
currentIndex: null == currentIndex ? _self.currentIndex : currentIndex // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [HomeState].
|
||||
extension HomeStatePatterns on HomeState {
|
||||
/// 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( _HomeState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _HomeState() 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( _HomeState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _HomeState():
|
||||
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( _HomeState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _HomeState() 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( int currentIndex)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _HomeState() when $default != null:
|
||||
return $default(_that.currentIndex);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( int currentIndex) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _HomeState():
|
||||
return $default(_that.currentIndex);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( int currentIndex)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _HomeState() when $default != null:
|
||||
return $default(_that.currentIndex);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _HomeState implements HomeState {
|
||||
const _HomeState({this.currentIndex = 0});
|
||||
|
||||
|
||||
@override@JsonKey() final int currentIndex;
|
||||
|
||||
/// Create a copy of HomeState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$HomeStateCopyWith<_HomeState> get copyWith => __$HomeStateCopyWithImpl<_HomeState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _HomeState&&(identical(other.currentIndex, currentIndex) || other.currentIndex == currentIndex));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,currentIndex);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'HomeState(currentIndex: $currentIndex)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$HomeStateCopyWith<$Res> implements $HomeStateCopyWith<$Res> {
|
||||
factory _$HomeStateCopyWith(_HomeState value, $Res Function(_HomeState) _then) = __$HomeStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
int currentIndex
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$HomeStateCopyWithImpl<$Res>
|
||||
implements _$HomeStateCopyWith<$Res> {
|
||||
__$HomeStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _HomeState _self;
|
||||
final $Res Function(_HomeState) _then;
|
||||
|
||||
/// Create a copy of HomeState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? currentIndex = null,}) {
|
||||
return _then(_HomeState(
|
||||
currentIndex: null == currentIndex ? _self.currentIndex : currentIndex // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,8 @@
|
||||
part of 'home_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class HomeEvent with _$HomeEvent {
|
||||
const factory HomeEvent.started() = _Started;
|
||||
const factory HomeEvent.changed(int index) = _Changed;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
part of 'home_bloc.dart';
|
||||
|
||||
@freezed
|
||||
abstract class HomeState with _$HomeState {
|
||||
const factory HomeState({
|
||||
@Default(0) int currentIndex
|
||||
}) = _HomeState;
|
||||
}
|
||||
26
lib/feature/home/presentation/mixins/categories_mixin.dart
Normal file
26
lib/feature/home/presentation/mixins/categories_mixin.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
import 'package:food_delivery_client/core/core.dart';
|
||||
|
||||
mixin CategoriesMixin {
|
||||
List<String> images = [
|
||||
AppImages.imgConvenience,
|
||||
AppImages.imgAlcohol,
|
||||
AppImages.imgPetSupplies,
|
||||
AppImages.imgFlowers,
|
||||
AppImages.imgGrocery,
|
||||
AppImages.imgAmerican,
|
||||
AppImages.imgSpeciality,
|
||||
AppImages.imgTakeout,
|
||||
AppImages.imgAsian,
|
||||
AppImages.imgIceCream,
|
||||
AppImages.imgHalal,
|
||||
AppImages.imgRetails,
|
||||
AppImages.imgCarribean,
|
||||
AppImages.imgIndian,
|
||||
AppImages.imgFrench,
|
||||
AppImages.imgFastFoods,
|
||||
AppImages.imgBurger,
|
||||
AppImages.imgRide,
|
||||
AppImages.imgChinese,
|
||||
AppImages.imgDesert,
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
mixin HomePageMixins {
|
||||
static const headers = [];
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
import 'package:food_delivery_client/feature/home/presentation/mixins/categories_mixin.dart';
|
||||
|
||||
import '../../../../../food_delivery_client.dart';
|
||||
|
||||
class CategoriesPage extends StatelessWidget with CategoriesMixin {
|
||||
CategoriesPage({super.key});
|
||||
|
||||
show(BuildContext context) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
|
||||
builder: (context) => Wrap(children: [this]),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<String> _titles = [
|
||||
context.loc.convenience,
|
||||
context.loc.alcohol,
|
||||
context.loc.petSupplies,
|
||||
context.loc.flowers,
|
||||
context.loc.grocery,
|
||||
context.loc.american,
|
||||
context.loc.speciality,
|
||||
context.loc.takeout,
|
||||
context.loc.asian,
|
||||
context.loc.iceCream,
|
||||
context.loc.halal,
|
||||
context.loc.retails,
|
||||
context.loc.caribbean,
|
||||
context.loc.indian,
|
||||
context.loc.french,
|
||||
context.loc.fastFoods,
|
||||
context.loc.burger,
|
||||
context.loc.ride,
|
||||
context.loc.chinese,
|
||||
context.loc.dessert,
|
||||
];
|
||||
return Material(
|
||||
color: AppColors.cFFFFFF,
|
||||
borderRadius: AppUtils.kBorderRadius20,
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
24.verticalSpace,
|
||||
Text(context.loc.allCategories, style: AppTextStyles.size20Regular),
|
||||
30.verticalSpace,
|
||||
GridView.builder(
|
||||
itemCount: images.length,
|
||||
padding: EdgeInsets.zero,
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 4,
|
||||
crossAxisSpacing: 5,
|
||||
mainAxisSpacing: 10,
|
||||
childAspectRatio: 78 / 100,
|
||||
),
|
||||
itemBuilder: (context, index) => WCategoryItem(
|
||||
onTap: () {},
|
||||
imgUrl: images[index],
|
||||
text: _titles[index],
|
||||
),
|
||||
),
|
||||
40.verticalSpace,
|
||||
],
|
||||
).paddingSymmetric(horizontal: 15),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
34
lib/feature/home/presentation/pages/home_page/home_page.dart
Normal file
34
lib/feature/home/presentation/pages/home_page/home_page.dart
Normal file
@@ -0,0 +1,34 @@
|
||||
import '../../../../../food_delivery_client.dart';
|
||||
|
||||
class HomePage extends StatelessWidget {
|
||||
const HomePage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => sl<HomeBloc>(),
|
||||
child: BlocBuilder<HomeBloc, HomeState>(
|
||||
builder: (context, state) {
|
||||
return WLayout(
|
||||
child: Scaffold(
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
SliverToBoxAdapter(child: WHomeHeader()),
|
||||
SliverToBoxAdapter(child: Column(children: [
|
||||
WDeliveryHeader(),
|
||||
WDiscountPart(),
|
||||
WOffersCarouselSlider(),
|
||||
WDiscountPart(),
|
||||
WPopularNearYou(),
|
||||
WTodayOffers(),
|
||||
WPickItUpForFree()
|
||||
])),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
import '../../../../../../food_delivery_client.dart';
|
||||
|
||||
class WPickItUpForFree extends StatelessWidget {
|
||||
const WPickItUpForFree({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
mainAxisAlignment:MainAxisAlignment.start,
|
||||
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
12.verticalSpace,
|
||||
Column(
|
||||
mainAxisAlignment:MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('Pick it up for free', style: AppTextStyles.size24Bold),
|
||||
Text(
|
||||
"Skip the fees when you order pick-up",
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.c545454,
|
||||
),
|
||||
),
|
||||
7.verticalSpace,
|
||||
],
|
||||
).paddingSymmetric(horizontal: 15),
|
||||
Container(
|
||||
height: 210,
|
||||
width: context.w,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage(AppImages.imgPickUp),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
child: Align(
|
||||
alignment: AlignmentGeometry.topCenter,
|
||||
child: CarouselSlider.builder(
|
||||
options: CarouselOptions(
|
||||
height: 100.0,
|
||||
reverse: false,
|
||||
viewportFraction: 0.9,
|
||||
animateToClosest: true,
|
||||
autoPlay: true,
|
||||
autoPlayCurve: Curves.easeIn,
|
||||
initialPage: 0,
|
||||
padEnds: false,
|
||||
enableInfiniteScroll: true,
|
||||
scrollPhysics: const AlwaysScrollableScrollPhysics(),
|
||||
scrollDirection: Axis.horizontal,
|
||||
),
|
||||
itemCount: 5,
|
||||
itemBuilder: (context, index, realIndex) {
|
||||
return Builder(
|
||||
builder: (BuildContext context) {
|
||||
return PickItUpItem().paddingOnly(left: 15);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
10.verticalSpace,
|
||||
WFoodItem(),
|
||||
40.verticalSpace
|
||||
|
||||
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class PickItUpItem extends StatelessWidget {
|
||||
const PickItUpItem({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
color: AppColors.cTransparent,
|
||||
child: InkWell(
|
||||
onTap: () {},
|
||||
child: Ink(
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.cFFFFFF,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.c000000.newWithOpacity(.25),
|
||||
offset: const Offset(0, 1),
|
||||
blurRadius: 2,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
spacing: 6,
|
||||
children: [
|
||||
Image.network(
|
||||
AppLocaleKeys.imageUrl,
|
||||
height: 88,
|
||||
width: 96,
|
||||
fit: BoxFit.cover,
|
||||
).paddingAll(4),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text("Island Takeway", style: AppTextStyles.size17Bold),
|
||||
Text(
|
||||
"10-20 min",
|
||||
style: AppTextStyles.size14Medium.copyWith(
|
||||
color: AppColors.c6B6B6B,
|
||||
),
|
||||
),
|
||||
],
|
||||
).paddingOnly(top: 4, bottom: 4, right: 40),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import 'package:flutter_bounceable/flutter_bounceable.dart';
|
||||
|
||||
import '../../../../../../food_delivery_client.dart';
|
||||
|
||||
class WCategoriesHeaderItem extends StatelessWidget {
|
||||
const WCategoriesHeaderItem({
|
||||
super.key,
|
||||
required this.text,
|
||||
required this.imageUrl,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
final String text;
|
||||
final String imageUrl;
|
||||
final VoidCallback onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: AppUtils.kBorderRadius10,
|
||||
child: Ink(
|
||||
height: 88,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: AppUtils.kBorderRadius10,
|
||||
color: AppColors.cE6E6E6.newWithOpacity(.4),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Align(
|
||||
alignment: AlignmentGeometry.topRight,
|
||||
child: Image.asset(imageUrl).paddingOnly(top: 5, right: 5),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
text,
|
||||
style: AppTextStyles.size18Medium,
|
||||
).paddingOnly(left: 12, bottom: 6),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import 'package:food_delivery_client/feature/home/presentation/pages/categories_page/categories_page.dart';
|
||||
|
||||
import '../../../../../../food_delivery_client.dart';
|
||||
|
||||
class WDeliveryHeader extends StatelessWidget {
|
||||
const WDeliveryHeader({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<String> _titles = [
|
||||
context.loc.convenience,
|
||||
context.loc.alcohol,
|
||||
context.loc.petSupplies,
|
||||
context.loc.more,
|
||||
];
|
||||
return Column(
|
||||
children: [
|
||||
15.verticalSpace,
|
||||
Row(
|
||||
spacing: 12,
|
||||
children: [
|
||||
WCategoriesHeaderItem(
|
||||
onTap: () {},
|
||||
text: context.loc.american,
|
||||
imageUrl: AppImages.imgAmerican,
|
||||
),
|
||||
WCategoriesHeaderItem(
|
||||
onTap: () {},
|
||||
text: context.loc.grocery,
|
||||
imageUrl: AppImages.imgGrocery,
|
||||
),
|
||||
],
|
||||
),
|
||||
8.verticalSpace,
|
||||
GridView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: _titles.length,
|
||||
padding: EdgeInsets.zero,
|
||||
scrollDirection: Axis.vertical,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 4,
|
||||
crossAxisSpacing: 5,
|
||||
mainAxisSpacing: 10,
|
||||
childAspectRatio: 78 / 100,
|
||||
),
|
||||
itemBuilder: (context, index) => WCategoryItem(
|
||||
onTap: () {
|
||||
if (index == 3) {
|
||||
CategoriesPage().show(context);
|
||||
}
|
||||
},
|
||||
imgUrl: index != 3 ? _images[index] : null,
|
||||
text: _titles[index],
|
||||
child: index == 3
|
||||
? SizedBox(height: 55, width: 55, child: Icon(Icons.more_horiz))
|
||||
: null,
|
||||
),
|
||||
),
|
||||
8.verticalSpace,
|
||||
WDivider()
|
||||
],
|
||||
).paddingSymmetric(horizontal: 15);
|
||||
}
|
||||
}
|
||||
|
||||
List _images = [
|
||||
AppImages.imgConvenience,
|
||||
AppImages.imgAlcohol,
|
||||
AppImages.imgPetSupplies,
|
||||
];
|
||||
@@ -0,0 +1,25 @@
|
||||
import '../../../../../../food_delivery_client.dart';
|
||||
|
||||
class WDiscountPart extends StatelessWidget {
|
||||
const WDiscountPart({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ListView.separated(
|
||||
shrinkWrap: true,
|
||||
padding: EdgeInsets.symmetric(vertical: 12),
|
||||
scrollDirection: Axis.vertical,
|
||||
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemBuilder: (context, index) => WFoodItem(enableTag: true),
|
||||
separatorBuilder: (context, index) => 20.verticalSpace,
|
||||
itemCount: 3,
|
||||
),
|
||||
WDivider(),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
import '../../../../../../food_delivery_client.dart';
|
||||
|
||||
class WHomeHeader extends StatelessWidget {
|
||||
const WHomeHeader({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<HomeBloc, HomeState>(
|
||||
builder: (context, state) {
|
||||
return DecoratedBox(
|
||||
decoration: BoxDecoration(color: AppColors.cFFFFFF),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
15.verticalSpace,
|
||||
Stack(
|
||||
alignment: AlignmentGeometry.center,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () {},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SvgPicture.asset(AppIcons.icLocation, height: 20),
|
||||
8.horizontalSpace,
|
||||
Text("London Hall", style: AppTextStyles.size18Medium),
|
||||
5.horizontalSpace,
|
||||
SvgPicture.asset(AppIcons.icArrowBottom),
|
||||
],
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: AlignmentGeometry.topRight,
|
||||
child: IconButton(
|
||||
onPressed: () {},
|
||||
icon: SvgPicture.asset(
|
||||
AppIcons.icFilter,
|
||||
height: 36,
|
||||
width: 36,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
).paddingSymmetric(horizontal: 15),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
import '../../../../../../food_delivery_client.dart';
|
||||
|
||||
class WOffersCarouselSlider extends StatelessWidget {
|
||||
WOffersCarouselSlider({super.key});
|
||||
|
||||
List _colors = [
|
||||
AppColors.cD2D7F0,
|
||||
AppColors.c9EE2B8,
|
||||
AppColors.cE2CC9E,
|
||||
AppColors.cC99EE2,
|
||||
AppColors.cE29EC7,
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
16.verticalSpace,
|
||||
CarouselSlider.builder(
|
||||
options: CarouselOptions(
|
||||
height: 170.0,
|
||||
reverse: false,
|
||||
viewportFraction: 0.9,
|
||||
animateToClosest: true,
|
||||
autoPlay: true,
|
||||
autoPlayCurve: Curves.easeIn,
|
||||
initialPage: 0,
|
||||
padEnds: false,
|
||||
enableInfiniteScroll: true,
|
||||
scrollPhysics: const AlwaysScrollableScrollPhysics(),
|
||||
scrollDirection: Axis.horizontal,
|
||||
),
|
||||
itemBuilder: (context, index, realIndex) => Builder(
|
||||
builder: (BuildContext context) {
|
||||
return Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
margin: EdgeInsets.only(left: 15),
|
||||
decoration: BoxDecoration(
|
||||
color: _colors[index],
|
||||
borderRadius: AppUtils.kBorderRadius16,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Order from these restaurants and save",
|
||||
style: AppTextStyles.size17Bold,
|
||||
),
|
||||
const Spacer(),
|
||||
Material(
|
||||
color: AppColors.cTransparent,
|
||||
child: InkWell(
|
||||
onTap: () {},
|
||||
borderRadius: AppUtils.kBorderRadius30,
|
||||
child: Ink(
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.cFFFFFF,
|
||||
borderRadius: AppUtils.kBorderRadius30,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [Text('Browse offer')],
|
||||
).paddingSymmetric(horizontal: 8, vertical: 4),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
).paddingSymmetric(horizontal: 15, vertical: 15),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: AppUtils.kBorderRadiusTop15Bottom15,
|
||||
child: Image.network(
|
||||
AppLocaleKeys.imageUrl,
|
||||
height: 170,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
itemCount: _colors.length,
|
||||
),
|
||||
8.verticalSpace,
|
||||
WDivider(),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import '../../../../../../food_delivery_client.dart';
|
||||
|
||||
class WPopularNearYou extends StatelessWidget {
|
||||
const WPopularNearYou({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
10.verticalSpace,
|
||||
WSeeAllRaw(title: "Popular near you", onPressed: () {}),
|
||||
10.verticalSpace,
|
||||
CarouselSlider.builder(
|
||||
options: CarouselOptions(
|
||||
height: 180.0,
|
||||
reverse: false,
|
||||
viewportFraction: 0.9,
|
||||
animateToClosest: true,
|
||||
autoPlay: true,
|
||||
autoPlayCurve: Curves.easeIn,
|
||||
initialPage: 0,
|
||||
padEnds: false,
|
||||
enableInfiniteScroll: true,
|
||||
scrollPhysics: const AlwaysScrollableScrollPhysics(),
|
||||
scrollDirection: Axis.horizontal,
|
||||
),
|
||||
itemCount: 5,
|
||||
itemBuilder: (context, index, realIndex) {
|
||||
return Builder(
|
||||
builder: (BuildContext context) {
|
||||
return WFoodItem(
|
||||
imageHeight: 130,
|
||||
textStyle1: AppTextStyles.size14Medium,
|
||||
textStyle2: AppTextStyles.size12Regular,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
13.verticalSpace,
|
||||
WDivider(),
|
||||
10.verticalSpace,
|
||||
ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
|
||||
scrollDirection: Axis.vertical,
|
||||
itemBuilder: (context, index) => WFoodItem(),
|
||||
separatorBuilder: (context, index) => 25.verticalSpace,
|
||||
itemCount: 5,
|
||||
),
|
||||
25.verticalSpace,
|
||||
WDivider(),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import '../../../../../../food_delivery_client.dart';
|
||||
|
||||
class WTodayOffers extends StatelessWidget {
|
||||
const WTodayOffers({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
12.verticalSpace,
|
||||
WSeeAllRaw(
|
||||
title: "Today's offers",
|
||||
onPressed: () {},
|
||||
),
|
||||
10.verticalSpace,
|
||||
CarouselSlider.builder(
|
||||
options: CarouselOptions(
|
||||
height: 180.0,
|
||||
reverse: false,
|
||||
viewportFraction: 0.9,
|
||||
animateToClosest: true,
|
||||
autoPlay: true,
|
||||
autoPlayCurve: Curves.easeIn,
|
||||
initialPage: 0,
|
||||
padEnds: false,
|
||||
enableInfiniteScroll: true,
|
||||
scrollPhysics: const AlwaysScrollableScrollPhysics(),
|
||||
scrollDirection: Axis.horizontal,
|
||||
),
|
||||
itemCount: 5,
|
||||
itemBuilder: (context, index, realIndex) {
|
||||
return Builder(
|
||||
builder: (BuildContext context) {
|
||||
return WFoodItem(
|
||||
imageHeight: 130,
|
||||
enableTag: true,
|
||||
textStyle1: AppTextStyles.size14Medium,
|
||||
textStyle2: AppTextStyles.size12Regular,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
10.verticalSpace,
|
||||
WDivider(),
|
||||
10.verticalSpace,
|
||||
ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
|
||||
scrollDirection: Axis.vertical,
|
||||
itemBuilder: (context, index) => WFoodItem(),
|
||||
separatorBuilder: (context, index) => 25.verticalSpace,
|
||||
itemCount: 3,
|
||||
),
|
||||
25.verticalSpace,
|
||||
WDivider()
|
||||
|
||||
|
||||
|
||||
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
47
lib/feature/home/presentation/widgets/w_category_item.dart
Normal file
47
lib/feature/home/presentation/widgets/w_category_item.dart
Normal file
@@ -0,0 +1,47 @@
|
||||
import '../../../../food_delivery_client.dart';
|
||||
|
||||
class WCategoryItem extends StatelessWidget {
|
||||
const WCategoryItem({
|
||||
super.key,
|
||||
required this.onTap,
|
||||
this.text,
|
||||
this.imgUrl,
|
||||
this.child,
|
||||
});
|
||||
|
||||
final VoidCallback onTap;
|
||||
final String? text;
|
||||
final String? imgUrl;
|
||||
final Widget? child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: AppUtils.kBorderRadius10,
|
||||
child: Ink(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: AppUtils.kBorderRadius10,
|
||||
color: AppColors.cE6E6E6.newWithOpacity(.4),
|
||||
),
|
||||
child: SizedBox(
|
||||
height: 55,
|
||||
width: 55,
|
||||
child: child ?? Image.asset(imgUrl!, fit: BoxFit.cover),
|
||||
).paddingSymmetric(vertical: 8, horizontal: 12),
|
||||
),
|
||||
),
|
||||
3.verticalSpace,
|
||||
if (text != null)
|
||||
Text(
|
||||
text!,
|
||||
maxLines: 2,
|
||||
style: AppTextStyles.size14Medium,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
3
lib/feature/main/main.dart
Normal file
3
lib/feature/main/main.dart
Normal file
@@ -0,0 +1,3 @@
|
||||
export 'package:food_delivery_client/feature/main/presentation/pages/main_page/main_page.dart';
|
||||
export 'presentation/mixins/main_page_mixin.dart';
|
||||
export 'package:food_delivery_client/feature/main/presentation/blocs/main_bloc/main_bloc.dart';
|
||||
18
lib/feature/main/presentation/blocs/main_bloc/main_bloc.dart
Normal file
18
lib/feature/main/presentation/blocs/main_bloc/main_bloc.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:food_delivery_client/food_delivery_client.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'main_event.dart';
|
||||
|
||||
part 'main_state.dart';
|
||||
|
||||
part 'main_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class MainBloc extends Bloc<MainEvent, MainState> {
|
||||
MainBloc() : super(const MainState()) {
|
||||
on<_Loaded>((event, emit) {
|
||||
emit(state.copyWith(currentIndex: event.index));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,538 @@
|
||||
// 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 'main_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$MainEvent {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is MainEvent);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'MainEvent()';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class $MainEventCopyWith<$Res> {
|
||||
$MainEventCopyWith(MainEvent _, $Res Function(MainEvent) __);
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [MainEvent].
|
||||
extension MainEventPatterns on MainEvent {
|
||||
/// 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( _Started value)? started,TResult Function( _Loaded value)? loaded,required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _Started() when started != null:
|
||||
return started(_that);case _Loaded() when loaded != null:
|
||||
return loaded(_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( _Started value) started,required TResult Function( _Loaded value) loaded,}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _Started():
|
||||
return started(_that);case _Loaded():
|
||||
return loaded(_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( _Started value)? started,TResult? Function( _Loaded value)? loaded,}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _Started() when started != null:
|
||||
return started(_that);case _Loaded() when loaded != null:
|
||||
return loaded(_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()? started,TResult Function( int index)? loaded,required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _Started() when started != null:
|
||||
return started();case _Loaded() when loaded != null:
|
||||
return loaded(_that.index);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() started,required TResult Function( int index) loaded,}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _Started():
|
||||
return started();case _Loaded():
|
||||
return loaded(_that.index);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()? started,TResult? Function( int index)? loaded,}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _Started() when started != null:
|
||||
return started();case _Loaded() when loaded != null:
|
||||
return loaded(_that.index);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _Started implements MainEvent {
|
||||
const _Started();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Started);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'MainEvent.started()';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _Loaded implements MainEvent {
|
||||
const _Loaded(this.index);
|
||||
|
||||
|
||||
final int index;
|
||||
|
||||
/// Create a copy of MainEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$LoadedCopyWith<_Loaded> get copyWith => __$LoadedCopyWithImpl<_Loaded>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Loaded&&(identical(other.index, index) || other.index == index));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,index);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'MainEvent.loaded(index: $index)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$LoadedCopyWith<$Res> implements $MainEventCopyWith<$Res> {
|
||||
factory _$LoadedCopyWith(_Loaded value, $Res Function(_Loaded) _then) = __$LoadedCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
int index
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$LoadedCopyWithImpl<$Res>
|
||||
implements _$LoadedCopyWith<$Res> {
|
||||
__$LoadedCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _Loaded _self;
|
||||
final $Res Function(_Loaded) _then;
|
||||
|
||||
/// Create a copy of MainEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') $Res call({Object? index = null,}) {
|
||||
return _then(_Loaded(
|
||||
null == index ? _self.index : index // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$MainState {
|
||||
|
||||
RequestStatus get status; int get currentIndex;
|
||||
/// Create a copy of MainState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$MainStateCopyWith<MainState> get copyWith => _$MainStateCopyWithImpl<MainState>(this as MainState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is MainState&&(identical(other.status, status) || other.status == status)&&(identical(other.currentIndex, currentIndex) || other.currentIndex == currentIndex));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,status,currentIndex);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'MainState(status: $status, currentIndex: $currentIndex)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $MainStateCopyWith<$Res> {
|
||||
factory $MainStateCopyWith(MainState value, $Res Function(MainState) _then) = _$MainStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
RequestStatus status, int currentIndex
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$MainStateCopyWithImpl<$Res>
|
||||
implements $MainStateCopyWith<$Res> {
|
||||
_$MainStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final MainState _self;
|
||||
final $Res Function(MainState) _then;
|
||||
|
||||
/// Create a copy of MainState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? status = null,Object? currentIndex = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as RequestStatus,currentIndex: null == currentIndex ? _self.currentIndex : currentIndex // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [MainState].
|
||||
extension MainStatePatterns on MainState {
|
||||
/// 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( _MainState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _MainState() 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( _MainState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _MainState():
|
||||
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( _MainState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _MainState() 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, int currentIndex)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _MainState() when $default != null:
|
||||
return $default(_that.status,_that.currentIndex);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, int currentIndex) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _MainState():
|
||||
return $default(_that.status,_that.currentIndex);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, int currentIndex)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _MainState() when $default != null:
|
||||
return $default(_that.status,_that.currentIndex);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _MainState implements MainState {
|
||||
const _MainState({this.status = RequestStatus.initial, this.currentIndex = 0});
|
||||
|
||||
|
||||
@override@JsonKey() final RequestStatus status;
|
||||
@override@JsonKey() final int currentIndex;
|
||||
|
||||
/// Create a copy of MainState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$MainStateCopyWith<_MainState> get copyWith => __$MainStateCopyWithImpl<_MainState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _MainState&&(identical(other.status, status) || other.status == status)&&(identical(other.currentIndex, currentIndex) || other.currentIndex == currentIndex));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,status,currentIndex);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'MainState(status: $status, currentIndex: $currentIndex)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$MainStateCopyWith<$Res> implements $MainStateCopyWith<$Res> {
|
||||
factory _$MainStateCopyWith(_MainState value, $Res Function(_MainState) _then) = __$MainStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
RequestStatus status, int currentIndex
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$MainStateCopyWithImpl<$Res>
|
||||
implements _$MainStateCopyWith<$Res> {
|
||||
__$MainStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _MainState _self;
|
||||
final $Res Function(_MainState) _then;
|
||||
|
||||
/// Create a copy of MainState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? status = null,Object? currentIndex = null,}) {
|
||||
return _then(_MainState(
|
||||
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as RequestStatus,currentIndex: null == currentIndex ? _self.currentIndex : currentIndex // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,8 @@
|
||||
part of 'main_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class MainEvent with _$MainEvent {
|
||||
const factory MainEvent.started() = _Started;
|
||||
const factory MainEvent.loaded(int index) = _Loaded;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
part of 'main_bloc.dart';
|
||||
|
||||
@freezed
|
||||
abstract class MainState with _$MainState {
|
||||
const factory MainState({
|
||||
@Default(RequestStatus.initial) RequestStatus status,
|
||||
@Default(0) int currentIndex,
|
||||
|
||||
}) = _MainState;
|
||||
}
|
||||
28
lib/feature/main/presentation/mixins/main_page_mixin.dart
Normal file
28
lib/feature/main/presentation/mixins/main_page_mixin.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
import '../../../../food_delivery_client.dart';
|
||||
|
||||
mixin MainPageMixin {
|
||||
final List<Widget> pages = [
|
||||
HomePage(),
|
||||
BrowsePage(),
|
||||
BasketPage(),
|
||||
AccountPage(),
|
||||
];
|
||||
|
||||
final List<Widget> defaultIcons = [
|
||||
SvgPicture.asset(AppIcons.icHome),
|
||||
SvgPicture.asset(AppIcons.icBrowse),
|
||||
SvgPicture.asset(AppIcons.icBasket),
|
||||
SvgPicture.asset(AppIcons.icAccount),
|
||||
];
|
||||
|
||||
final List<Widget> activeIcons = [
|
||||
SvgPicture.asset(AppIcons.icHomeActive),
|
||||
SvgPicture.asset(AppIcons.icBrowseActive),
|
||||
SvgPicture.asset(AppIcons.icBasketActive),
|
||||
SvgPicture.asset(AppIcons.icAccountActive),
|
||||
];
|
||||
|
||||
final List<String> labels = ["Home", "Browse", "Baskets", 'Account'];
|
||||
}
|
||||
40
lib/feature/main/presentation/pages/main_page/main_page.dart
Normal file
40
lib/feature/main/presentation/pages/main_page/main_page.dart
Normal file
@@ -0,0 +1,40 @@
|
||||
import '../../../../../food_delivery_client.dart';
|
||||
|
||||
class MainPage extends StatelessWidget with MainPageMixin {
|
||||
MainPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => sl<MainBloc>(),
|
||||
child: BlocBuilder<MainBloc, MainState>(
|
||||
builder: (context, state) {
|
||||
return Scaffold(
|
||||
body: IndexedStack(
|
||||
index: state.currentIndex,
|
||||
sizing: StackFit.expand,
|
||||
alignment: AlignmentGeometry.center,
|
||||
children: pages,
|
||||
),
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
onTap: (value) {
|
||||
context.read<MainBloc>().add(MainEvent.loaded(value));
|
||||
},
|
||||
currentIndex: state.currentIndex,
|
||||
items: List.generate(
|
||||
defaultIcons.length,
|
||||
(index) => BottomNavigationBarItem(
|
||||
icon: defaultIcons[index].paddingOnly(bottom: 4.85),
|
||||
activeIcon: activeIcons[index].paddingOnly(bottom: 4.85),
|
||||
label: labels[index],
|
||||
tooltip: labels[index],
|
||||
backgroundColor: AppColors.cFFFFFF,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
0
lib/feature/on_boarding/on_boarding.dart
Normal file
0
lib/feature/on_boarding/on_boarding.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
import 'package:food_delivery_client/food_delivery_client.dart';
|
||||
|
||||
part 'splash_event.dart';
|
||||
|
||||
part 'splash_state.dart';
|
||||
|
||||
part 'splash_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class SplashBloc extends Bloc<SplashEvent, SplashState> {
|
||||
SplashBloc() : super(const SplashState()) {
|
||||
on<_Started>(_onStarted);
|
||||
}
|
||||
|
||||
Future<void> _onStarted(_Started event, Emitter<SplashState> emit) async {
|
||||
await Future.delayed(TimeDelayConst.duration3);
|
||||
emit(state.copyWith(status: RequestStatus.loaded));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,463 @@
|
||||
// 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 'splash_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$SplashEvent {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is SplashEvent);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SplashEvent()';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class $SplashEventCopyWith<$Res> {
|
||||
$SplashEventCopyWith(SplashEvent _, $Res Function(SplashEvent) __);
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [SplashEvent].
|
||||
extension SplashEventPatterns on SplashEvent {
|
||||
/// 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( _Started value)? started,required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _Started() when started != null:
|
||||
return started(_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( _Started value) started,}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _Started():
|
||||
return started(_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( _Started value)? started,}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _Started() when started != null:
|
||||
return started(_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()? started,required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _Started() when started != null:
|
||||
return started();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() started,}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _Started():
|
||||
return started();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()? started,}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _Started() when started != null:
|
||||
return started();case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _Started implements SplashEvent {
|
||||
const _Started();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Started);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SplashEvent.started()';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$SplashState {
|
||||
|
||||
RequestStatus get status;
|
||||
/// Create a copy of SplashState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$SplashStateCopyWith<SplashState> get copyWith => _$SplashStateCopyWithImpl<SplashState>(this as SplashState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is SplashState&&(identical(other.status, status) || other.status == status));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,status);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SplashState(status: $status)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $SplashStateCopyWith<$Res> {
|
||||
factory $SplashStateCopyWith(SplashState value, $Res Function(SplashState) _then) = _$SplashStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
RequestStatus status
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$SplashStateCopyWithImpl<$Res>
|
||||
implements $SplashStateCopyWith<$Res> {
|
||||
_$SplashStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final SplashState _self;
|
||||
final $Res Function(SplashState) _then;
|
||||
|
||||
/// Create a copy of SplashState
|
||||
/// 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 [SplashState].
|
||||
extension SplashStatePatterns on SplashState {
|
||||
/// 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( _SplashState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _SplashState() 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( _SplashState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _SplashState():
|
||||
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( _SplashState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _SplashState() 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 _SplashState() 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 _SplashState():
|
||||
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 _SplashState() when $default != null:
|
||||
return $default(_that.status);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _SplashState implements SplashState {
|
||||
const _SplashState({this.status = RequestStatus.initial});
|
||||
|
||||
|
||||
@override@JsonKey() final RequestStatus status;
|
||||
|
||||
/// Create a copy of SplashState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$SplashStateCopyWith<_SplashState> get copyWith => __$SplashStateCopyWithImpl<_SplashState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SplashState&&(identical(other.status, status) || other.status == status));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,status);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SplashState(status: $status)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$SplashStateCopyWith<$Res> implements $SplashStateCopyWith<$Res> {
|
||||
factory _$SplashStateCopyWith(_SplashState value, $Res Function(_SplashState) _then) = __$SplashStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
RequestStatus status
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$SplashStateCopyWithImpl<$Res>
|
||||
implements _$SplashStateCopyWith<$Res> {
|
||||
__$SplashStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _SplashState _self;
|
||||
final $Res Function(_SplashState) _then;
|
||||
|
||||
/// Create a copy of SplashState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? status = null,}) {
|
||||
return _then(_SplashState(
|
||||
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as RequestStatus,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,6 @@
|
||||
part of 'splash_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class SplashEvent with _$SplashEvent {
|
||||
const factory SplashEvent.started() = _Started;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
part of 'splash_bloc.dart';
|
||||
|
||||
@freezed
|
||||
abstract class SplashState with _$SplashState {
|
||||
const factory SplashState({
|
||||
@Default(RequestStatus.initial) RequestStatus status,
|
||||
}) = _SplashState;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
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';
|
||||
|
||||
class SplashPage extends StatelessWidget {
|
||||
const SplashPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => sl<SplashBloc>()..add(SplashEvent.started()),
|
||||
child: BlocListener<SplashBloc, SplashState>(
|
||||
listener: (context, state) {
|
||||
if (state.status.isLoaded()) {
|
||||
context.go(Routes.main);
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
backgroundColor: AppColors.c142328,
|
||||
body: Align(
|
||||
alignment: AlignmentGeometry.center,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset(AppIcons.icUber),
|
||||
SvgPicture.asset(AppIcons.icEat),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user