forked from eatvio/eatvio_app
feat(order info): added order info screen
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:eatvio_app/core/app_router.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/core/utils/toasts.dart';
|
||||
@@ -11,10 +13,10 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
|
||||
AuthCubit({
|
||||
required this.authRepository,
|
||||
}) : super(AuthState());
|
||||
}) : super(const AuthState());
|
||||
|
||||
Future<bool> getTokenByCredentials(String email, String password) async {
|
||||
emit(AuthState.loading());
|
||||
emit(const AuthState.loading());
|
||||
try {
|
||||
final token = (await authRepository.getTokenByCredentials(
|
||||
email,
|
||||
@@ -31,7 +33,7 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
AppRouter.navigatorKey.currentContext?.go('/my-profile-screen');
|
||||
return true;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
log(e.toString());
|
||||
showErrorToast('Неверный адрес электронной почты или пароль');
|
||||
emit(AuthState.error(errorMessage: '$e'));
|
||||
return false;
|
||||
|
||||
@@ -12,8 +12,7 @@ part of 'auth_state.dart';
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
||||
);
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
/// @nodoc
|
||||
mixin _$AuthState {
|
||||
@@ -23,14 +22,16 @@ mixin _$AuthState {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(String token) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(String token)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
@@ -38,21 +39,24 @@ mixin _$AuthState {
|
||||
TResult Function(String token)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_AuthState value) $default, {
|
||||
required TResult Function(AuthStateLoading value) loading,
|
||||
required TResult Function(AuthStateLoaded value) loaded,
|
||||
required TResult Function(AuthStateError value) error,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_AuthState value)? $default, {
|
||||
TResult? Function(AuthStateLoading value)? loading,
|
||||
TResult? Function(AuthStateLoaded value)? loaded,
|
||||
TResult? Function(AuthStateError value)? error,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_AuthState value)? $default, {
|
||||
@@ -60,7 +64,8 @@ mixin _$AuthState {
|
||||
TResult Function(AuthStateLoaded value)? loaded,
|
||||
TResult Function(AuthStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -86,9 +91,8 @@ class _$AuthStateCopyWithImpl<$Res, $Val extends AuthState>
|
||||
/// @nodoc
|
||||
abstract class _$$AuthStateImplCopyWith<$Res> {
|
||||
factory _$$AuthStateImplCopyWith(
|
||||
_$AuthStateImpl value,
|
||||
$Res Function(_$AuthStateImpl) then,
|
||||
) = __$$AuthStateImplCopyWithImpl<$Res>;
|
||||
_$AuthStateImpl value, $Res Function(_$AuthStateImpl) then) =
|
||||
__$$AuthStateImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -96,9 +100,8 @@ class __$$AuthStateImplCopyWithImpl<$Res>
|
||||
extends _$AuthStateCopyWithImpl<$Res, _$AuthStateImpl>
|
||||
implements _$$AuthStateImplCopyWith<$Res> {
|
||||
__$$AuthStateImplCopyWithImpl(
|
||||
_$AuthStateImpl _value,
|
||||
$Res Function(_$AuthStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
_$AuthStateImpl _value, $Res Function(_$AuthStateImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of AuthState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -204,20 +207,18 @@ abstract class _AuthState implements AuthState {
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$AuthStateLoadingImplCopyWith<$Res> {
|
||||
factory _$$AuthStateLoadingImplCopyWith(
|
||||
_$AuthStateLoadingImpl value,
|
||||
$Res Function(_$AuthStateLoadingImpl) then,
|
||||
) = __$$AuthStateLoadingImplCopyWithImpl<$Res>;
|
||||
factory _$$AuthStateLoadingImplCopyWith(_$AuthStateLoadingImpl value,
|
||||
$Res Function(_$AuthStateLoadingImpl) then) =
|
||||
__$$AuthStateLoadingImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$AuthStateLoadingImplCopyWithImpl<$Res>
|
||||
extends _$AuthStateCopyWithImpl<$Res, _$AuthStateLoadingImpl>
|
||||
implements _$$AuthStateLoadingImplCopyWith<$Res> {
|
||||
__$$AuthStateLoadingImplCopyWithImpl(
|
||||
_$AuthStateLoadingImpl _value,
|
||||
$Res Function(_$AuthStateLoadingImpl) _then,
|
||||
) : super(_value, _then);
|
||||
__$$AuthStateLoadingImplCopyWithImpl(_$AuthStateLoadingImpl _value,
|
||||
$Res Function(_$AuthStateLoadingImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of AuthState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -323,10 +324,9 @@ abstract class AuthStateLoading implements AuthState {
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$AuthStateLoadedImplCopyWith<$Res> {
|
||||
factory _$$AuthStateLoadedImplCopyWith(
|
||||
_$AuthStateLoadedImpl value,
|
||||
$Res Function(_$AuthStateLoadedImpl) then,
|
||||
) = __$$AuthStateLoadedImplCopyWithImpl<$Res>;
|
||||
factory _$$AuthStateLoadedImplCopyWith(_$AuthStateLoadedImpl value,
|
||||
$Res Function(_$AuthStateLoadedImpl) then) =
|
||||
__$$AuthStateLoadedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({String token});
|
||||
}
|
||||
@@ -336,24 +336,22 @@ class __$$AuthStateLoadedImplCopyWithImpl<$Res>
|
||||
extends _$AuthStateCopyWithImpl<$Res, _$AuthStateLoadedImpl>
|
||||
implements _$$AuthStateLoadedImplCopyWith<$Res> {
|
||||
__$$AuthStateLoadedImplCopyWithImpl(
|
||||
_$AuthStateLoadedImpl _value,
|
||||
$Res Function(_$AuthStateLoadedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
_$AuthStateLoadedImpl _value, $Res Function(_$AuthStateLoadedImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of AuthState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? token = null}) {
|
||||
return _then(
|
||||
_$AuthStateLoadedImpl(
|
||||
token:
|
||||
null == token
|
||||
? _value.token
|
||||
: token // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
),
|
||||
);
|
||||
$Res call({
|
||||
Object? token = null,
|
||||
}) {
|
||||
return _then(_$AuthStateLoadedImpl(
|
||||
token: null == token
|
||||
? _value.token
|
||||
: token // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,9 +386,7 @@ class _$AuthStateLoadedImpl implements AuthStateLoaded {
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$AuthStateLoadedImplCopyWith<_$AuthStateLoadedImpl> get copyWith =>
|
||||
__$$AuthStateLoadedImplCopyWithImpl<_$AuthStateLoadedImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
@@ -482,10 +478,9 @@ abstract class AuthStateLoaded implements AuthState {
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$AuthStateErrorImplCopyWith<$Res> {
|
||||
factory _$$AuthStateErrorImplCopyWith(
|
||||
_$AuthStateErrorImpl value,
|
||||
$Res Function(_$AuthStateErrorImpl) then,
|
||||
) = __$$AuthStateErrorImplCopyWithImpl<$Res>;
|
||||
factory _$$AuthStateErrorImplCopyWith(_$AuthStateErrorImpl value,
|
||||
$Res Function(_$AuthStateErrorImpl) then) =
|
||||
__$$AuthStateErrorImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({String errorMessage});
|
||||
}
|
||||
@@ -495,24 +490,22 @@ class __$$AuthStateErrorImplCopyWithImpl<$Res>
|
||||
extends _$AuthStateCopyWithImpl<$Res, _$AuthStateErrorImpl>
|
||||
implements _$$AuthStateErrorImplCopyWith<$Res> {
|
||||
__$$AuthStateErrorImplCopyWithImpl(
|
||||
_$AuthStateErrorImpl _value,
|
||||
$Res Function(_$AuthStateErrorImpl) _then,
|
||||
) : super(_value, _then);
|
||||
_$AuthStateErrorImpl _value, $Res Function(_$AuthStateErrorImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of AuthState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? errorMessage = null}) {
|
||||
return _then(
|
||||
_$AuthStateErrorImpl(
|
||||
errorMessage:
|
||||
null == errorMessage
|
||||
? _value.errorMessage
|
||||
: errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
),
|
||||
);
|
||||
$Res call({
|
||||
Object? errorMessage = null,
|
||||
}) {
|
||||
return _then(_$AuthStateErrorImpl(
|
||||
errorMessage: null == errorMessage
|
||||
? _value.errorMessage
|
||||
: errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -548,9 +541,7 @@ class _$AuthStateErrorImpl implements AuthStateError {
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$AuthStateErrorImplCopyWith<_$AuthStateErrorImpl> get copyWith =>
|
||||
__$$AuthStateErrorImplCopyWithImpl<_$AuthStateErrorImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:easy_debounce/easy_debounce.dart';
|
||||
import 'package:eatvio_app/core/const.dart';
|
||||
import 'package:eatvio_app/core/locator_service.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
@@ -22,7 +23,7 @@ import 'package:url_launcher/url_launcher.dart';
|
||||
import '../bloc/auth_state.dart';
|
||||
|
||||
class AuthScreen extends StatefulWidget {
|
||||
const AuthScreen();
|
||||
const AuthScreen({super.key});
|
||||
|
||||
@override
|
||||
State<AuthScreen> createState() => _AuthScreenState();
|
||||
@@ -36,7 +37,7 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||
final authCubit = sl<AuthCubit>();
|
||||
late StreamSubscription<bool> keyboardSubscription;
|
||||
bool isFocused = false;
|
||||
|
||||
int tapsCount = 0;
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -60,15 +61,27 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
toolbarHeight: isFocused ? 64 : MediaQuery.of(context).size.width - 64,
|
||||
title: SvgPicture.asset(
|
||||
ImageConstant.imgLogoEatvio,
|
||||
height: isFocused ? 64 : MediaQuery.of(context).size.width - 64,
|
||||
fit: BoxFit.contain,
|
||||
title: GestureDetector(
|
||||
onTap: () {
|
||||
tapsCount++;
|
||||
if (tapsCount == 6) {
|
||||
tapsCount = 0;
|
||||
// showModalBottomSheet(context: context, builder: (context) => );
|
||||
}
|
||||
EasyDebounce.debounce('change env', Durations.medium4, () {
|
||||
tapsCount = 0;
|
||||
});
|
||||
},
|
||||
child: SvgPicture.asset(
|
||||
ImageConstant.imgLogoEatvio,
|
||||
height: isFocused ? 64 : MediaQuery.of(context).size.width - 64,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -104,7 +117,7 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text('Нет аккаунта? '),
|
||||
const Text('Нет аккаунта? '),
|
||||
GestureDetector(
|
||||
onTap: () => GoRouter.of(context).goNamed('webViewRegistrationScreen'),
|
||||
child: Text(
|
||||
@@ -118,18 +131,18 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||
),
|
||||
],
|
||||
),
|
||||
Spacer(),
|
||||
const Spacer(),
|
||||
Center(
|
||||
child: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
text: 'Нажимая "Войти", Вы соглашаетесь \n',
|
||||
style: TextStyle(
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.black,
|
||||
),
|
||||
children: [
|
||||
TextSpan(text: 'c '),
|
||||
const TextSpan(text: 'c '),
|
||||
TextSpan(
|
||||
text: ' Публичной офертой',
|
||||
style: TextStyle(
|
||||
@@ -138,14 +151,14 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||
decorationColor: appTheme.blueA400,
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()..onTap = () async => await launchUrl(Uri.parse(baseUrl + '/oferta_bs.pdf')),
|
||||
recognizer: TapGestureRecognizer()..onTap = () async => await launchUrl(Uri.parse('$baseUrl/oferta_bs.pdf')),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Container(
|
||||
SizedBox(
|
||||
height: 48,
|
||||
width: MediaQuery.of(context).size.width - 32,
|
||||
child: FloatingActionButton.extended(
|
||||
@@ -165,12 +178,14 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||
passwordController.text,
|
||||
);
|
||||
if (isAuthenticated) {
|
||||
context.read<ProfileAvatarCubit>().getMyProfile();
|
||||
context.read<ChatsCubit>().getChatRoomsWithLoading();
|
||||
if (context.mounted) {
|
||||
context.read<ProfileAvatarCubit>().getMyProfile();
|
||||
context.read<ChatsCubit>().getChatRoomsWithLoading();
|
||||
}
|
||||
}
|
||||
},
|
||||
label: state is AuthStateLoading
|
||||
? CupertinoActivityIndicator()
|
||||
? const CupertinoActivityIndicator()
|
||||
: Text(
|
||||
'Войти',
|
||||
style: theme.textTheme.titleSmall!.copyWith(color: Colors.white),
|
||||
|
||||
Reference in New Issue
Block a user