feat(order info): added order info screen

This commit is contained in:
Username1548
2025-04-04 20:21:31 +07:00
parent 9715f4cac9
commit 748484cf8f
387 changed files with 16171 additions and 18199 deletions

View File

@@ -10,7 +10,7 @@ import 'package:eatvio_app/features/profile/repositories/profile_repository.dart
import 'package:flutter_bloc/flutter_bloc.dart';
class AboutDietCubit extends Cubit<AboutDietState> {
AboutDietCubit({required this.dietsRepository, required this.profileRepository}) : super(AboutDietState.initial());
AboutDietCubit({required this.dietsRepository, required this.profileRepository}) : super(const AboutDietState.initial());
final DietRepository dietsRepository;
final ProfileRepository profileRepository;
bool isCurrentDietStarted = false;
@@ -32,7 +32,7 @@ class AboutDietCubit extends Cubit<AboutDietState> {
Future<void> initDietPage(int id) async {
try {
emit(AboutDietState.loading());
emit(const AboutDietState.loading());
final diet = await dietsRepository.getDiet(id);
final chosenDiets = await profileRepository.getChosenDiets();
final lastChosenDiet = chosenDiets.firstOrNull;
@@ -81,7 +81,7 @@ class AboutDietCubit extends Cubit<AboutDietState> {
EasyDebounce.debounce(
'like_diet',
Duration(seconds: 1),
const Duration(seconds: 1),
() async {
try {
await dietsRepository.likeDiet(id);
@@ -112,7 +112,7 @@ class AboutDietCubit extends Cubit<AboutDietState> {
EasyDebounce.debounce(
'add_or_remove_diet_to_favorites',
Duration(seconds: 1),
const Duration(seconds: 1),
() async {
try {
await dietsRepository.addToFavorite(id);
@@ -143,7 +143,7 @@ class AboutDietCubit extends Cubit<AboutDietState> {
EasyDebounce.debounce(
'add_or_remove_diet_to_favorites',
Duration(seconds: 1),
const Duration(seconds: 1),
() async {
try {
await dietsRepository.removeFromFavorite(id);

View File

@@ -12,8 +12,7 @@ part of 'about_diet_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 _$AboutDietState {
@@ -23,9 +22,10 @@ mixin _$AboutDietState {
required TResult Function() initial,
required TResult Function() loading,
required TResult Function(Diet diet, bool isStarted, bool hasStartedDiet)
loaded,
loaded,
required TResult Function(String message) error,
}) => throw _privateConstructorUsedError;
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
TResult? Function()? $default, {
@@ -33,7 +33,8 @@ mixin _$AboutDietState {
TResult? Function()? loading,
TResult? Function(Diet diet, bool isStarted, bool hasStartedDiet)? loaded,
TResult? Function(String message)? error,
}) => throw _privateConstructorUsedError;
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
TResult Function()? $default, {
@@ -42,7 +43,8 @@ mixin _$AboutDietState {
TResult Function(Diet diet, bool isStarted, bool hasStartedDiet)? loaded,
TResult Function(String message)? error,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>(
TResult Function(_AboutDietState value) $default, {
@@ -50,7 +52,8 @@ mixin _$AboutDietState {
required TResult Function(DietStateLoading value) loading,
required TResult Function(DietStateLoaded value) loaded,
required TResult Function(DietStateError value) error,
}) => throw _privateConstructorUsedError;
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>(
TResult? Function(_AboutDietState value)? $default, {
@@ -58,7 +61,8 @@ mixin _$AboutDietState {
TResult? Function(DietStateLoading value)? loading,
TResult? Function(DietStateLoaded value)? loaded,
TResult? Function(DietStateError value)? error,
}) => throw _privateConstructorUsedError;
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>(
TResult Function(_AboutDietState value)? $default, {
@@ -67,15 +71,15 @@ mixin _$AboutDietState {
TResult Function(DietStateLoaded value)? loaded,
TResult Function(DietStateError value)? error,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}) =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $AboutDietStateCopyWith<$Res> {
factory $AboutDietStateCopyWith(
AboutDietState value,
$Res Function(AboutDietState) then,
) = _$AboutDietStateCopyWithImpl<$Res, AboutDietState>;
AboutDietState value, $Res Function(AboutDietState) then) =
_$AboutDietStateCopyWithImpl<$Res, AboutDietState>;
}
/// @nodoc
@@ -94,10 +98,9 @@ class _$AboutDietStateCopyWithImpl<$Res, $Val extends AboutDietState>
/// @nodoc
abstract class _$$AboutDietStateImplCopyWith<$Res> {
factory _$$AboutDietStateImplCopyWith(
_$AboutDietStateImpl value,
$Res Function(_$AboutDietStateImpl) then,
) = __$$AboutDietStateImplCopyWithImpl<$Res>;
factory _$$AboutDietStateImplCopyWith(_$AboutDietStateImpl value,
$Res Function(_$AboutDietStateImpl) then) =
__$$AboutDietStateImplCopyWithImpl<$Res>;
}
/// @nodoc
@@ -105,9 +108,8 @@ class __$$AboutDietStateImplCopyWithImpl<$Res>
extends _$AboutDietStateCopyWithImpl<$Res, _$AboutDietStateImpl>
implements _$$AboutDietStateImplCopyWith<$Res> {
__$$AboutDietStateImplCopyWithImpl(
_$AboutDietStateImpl _value,
$Res Function(_$AboutDietStateImpl) _then,
) : super(_value, _then);
_$AboutDietStateImpl _value, $Res Function(_$AboutDietStateImpl) _then)
: super(_value, _then);
/// Create a copy of AboutDietState
/// with the given fields replaced by the non-null parameter values.
@@ -139,7 +141,7 @@ class _$AboutDietStateImpl implements _AboutDietState {
required TResult Function() initial,
required TResult Function() loading,
required TResult Function(Diet diet, bool isStarted, bool hasStartedDiet)
loaded,
loaded,
required TResult Function(String message) error,
}) {
return $default();
@@ -220,20 +222,18 @@ abstract class _AboutDietState implements AboutDietState {
/// @nodoc
abstract class _$$DietStateInitialImplCopyWith<$Res> {
factory _$$DietStateInitialImplCopyWith(
_$DietStateInitialImpl value,
$Res Function(_$DietStateInitialImpl) then,
) = __$$DietStateInitialImplCopyWithImpl<$Res>;
factory _$$DietStateInitialImplCopyWith(_$DietStateInitialImpl value,
$Res Function(_$DietStateInitialImpl) then) =
__$$DietStateInitialImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$DietStateInitialImplCopyWithImpl<$Res>
extends _$AboutDietStateCopyWithImpl<$Res, _$DietStateInitialImpl>
implements _$$DietStateInitialImplCopyWith<$Res> {
__$$DietStateInitialImplCopyWithImpl(
_$DietStateInitialImpl _value,
$Res Function(_$DietStateInitialImpl) _then,
) : super(_value, _then);
__$$DietStateInitialImplCopyWithImpl(_$DietStateInitialImpl _value,
$Res Function(_$DietStateInitialImpl) _then)
: super(_value, _then);
/// Create a copy of AboutDietState
/// with the given fields replaced by the non-null parameter values.
@@ -265,7 +265,7 @@ class _$DietStateInitialImpl implements DietStateInitial {
required TResult Function() initial,
required TResult Function() loading,
required TResult Function(Diet diet, bool isStarted, bool hasStartedDiet)
loaded,
loaded,
required TResult Function(String message) error,
}) {
return initial();
@@ -346,20 +346,18 @@ abstract class DietStateInitial implements AboutDietState {
/// @nodoc
abstract class _$$DietStateLoadingImplCopyWith<$Res> {
factory _$$DietStateLoadingImplCopyWith(
_$DietStateLoadingImpl value,
$Res Function(_$DietStateLoadingImpl) then,
) = __$$DietStateLoadingImplCopyWithImpl<$Res>;
factory _$$DietStateLoadingImplCopyWith(_$DietStateLoadingImpl value,
$Res Function(_$DietStateLoadingImpl) then) =
__$$DietStateLoadingImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$DietStateLoadingImplCopyWithImpl<$Res>
extends _$AboutDietStateCopyWithImpl<$Res, _$DietStateLoadingImpl>
implements _$$DietStateLoadingImplCopyWith<$Res> {
__$$DietStateLoadingImplCopyWithImpl(
_$DietStateLoadingImpl _value,
$Res Function(_$DietStateLoadingImpl) _then,
) : super(_value, _then);
__$$DietStateLoadingImplCopyWithImpl(_$DietStateLoadingImpl _value,
$Res Function(_$DietStateLoadingImpl) _then)
: super(_value, _then);
/// Create a copy of AboutDietState
/// with the given fields replaced by the non-null parameter values.
@@ -391,7 +389,7 @@ class _$DietStateLoadingImpl implements DietStateLoading {
required TResult Function() initial,
required TResult Function() loading,
required TResult Function(Diet diet, bool isStarted, bool hasStartedDiet)
loaded,
loaded,
required TResult Function(String message) error,
}) {
return loading();
@@ -472,10 +470,9 @@ abstract class DietStateLoading implements AboutDietState {
/// @nodoc
abstract class _$$DietStateLoadedImplCopyWith<$Res> {
factory _$$DietStateLoadedImplCopyWith(
_$DietStateLoadedImpl value,
$Res Function(_$DietStateLoadedImpl) then,
) = __$$DietStateLoadedImplCopyWithImpl<$Res>;
factory _$$DietStateLoadedImplCopyWith(_$DietStateLoadedImpl value,
$Res Function(_$DietStateLoadedImpl) then) =
__$$DietStateLoadedImplCopyWithImpl<$Res>;
@useResult
$Res call({Diet diet, bool isStarted, bool hasStartedDiet});
@@ -487,9 +484,8 @@ class __$$DietStateLoadedImplCopyWithImpl<$Res>
extends _$AboutDietStateCopyWithImpl<$Res, _$DietStateLoadedImpl>
implements _$$DietStateLoadedImplCopyWith<$Res> {
__$$DietStateLoadedImplCopyWithImpl(
_$DietStateLoadedImpl _value,
$Res Function(_$DietStateLoadedImpl) _then,
) : super(_value, _then);
_$DietStateLoadedImpl _value, $Res Function(_$DietStateLoadedImpl) _then)
: super(_value, _then);
/// Create a copy of AboutDietState
/// with the given fields replaced by the non-null parameter values.
@@ -500,25 +496,20 @@ class __$$DietStateLoadedImplCopyWithImpl<$Res>
Object? isStarted = null,
Object? hasStartedDiet = null,
}) {
return _then(
_$DietStateLoadedImpl(
diet:
null == diet
? _value.diet
: diet // ignore: cast_nullable_to_non_nullable
as Diet,
isStarted:
null == isStarted
? _value.isStarted
: isStarted // ignore: cast_nullable_to_non_nullable
as bool,
hasStartedDiet:
null == hasStartedDiet
? _value.hasStartedDiet
: hasStartedDiet // ignore: cast_nullable_to_non_nullable
as bool,
),
);
return _then(_$DietStateLoadedImpl(
diet: null == diet
? _value.diet
: diet // ignore: cast_nullable_to_non_nullable
as Diet,
isStarted: null == isStarted
? _value.isStarted
: isStarted // ignore: cast_nullable_to_non_nullable
as bool,
hasStartedDiet: null == hasStartedDiet
? _value.hasStartedDiet
: hasStartedDiet // ignore: cast_nullable_to_non_nullable
as bool,
));
}
/// Create a copy of AboutDietState
@@ -535,11 +526,10 @@ class __$$DietStateLoadedImplCopyWithImpl<$Res>
/// @nodoc
class _$DietStateLoadedImpl implements DietStateLoaded {
const _$DietStateLoadedImpl({
required this.diet,
this.isStarted = false,
this.hasStartedDiet = false,
});
const _$DietStateLoadedImpl(
{required this.diet,
this.isStarted = false,
this.hasStartedDiet = false});
@override
final Diet diet;
@@ -577,9 +567,7 @@ class _$DietStateLoadedImpl implements DietStateLoaded {
@pragma('vm:prefer-inline')
_$$DietStateLoadedImplCopyWith<_$DietStateLoadedImpl> get copyWith =>
__$$DietStateLoadedImplCopyWithImpl<_$DietStateLoadedImpl>(
this,
_$identity,
);
this, _$identity);
@override
@optionalTypeArgs
@@ -588,7 +576,7 @@ class _$DietStateLoadedImpl implements DietStateLoaded {
required TResult Function() initial,
required TResult Function() loading,
required TResult Function(Diet diet, bool isStarted, bool hasStartedDiet)
loaded,
loaded,
required TResult Function(String message) error,
}) {
return loaded(diet, isStarted, hasStartedDiet);
@@ -664,11 +652,10 @@ class _$DietStateLoadedImpl implements DietStateLoaded {
}
abstract class DietStateLoaded implements AboutDietState {
const factory DietStateLoaded({
required final Diet diet,
final bool isStarted,
final bool hasStartedDiet,
}) = _$DietStateLoadedImpl;
const factory DietStateLoaded(
{required final Diet diet,
final bool isStarted,
final bool hasStartedDiet}) = _$DietStateLoadedImpl;
Diet get diet;
bool get isStarted;
@@ -683,10 +670,9 @@ abstract class DietStateLoaded implements AboutDietState {
/// @nodoc
abstract class _$$DietStateErrorImplCopyWith<$Res> {
factory _$$DietStateErrorImplCopyWith(
_$DietStateErrorImpl value,
$Res Function(_$DietStateErrorImpl) then,
) = __$$DietStateErrorImplCopyWithImpl<$Res>;
factory _$$DietStateErrorImplCopyWith(_$DietStateErrorImpl value,
$Res Function(_$DietStateErrorImpl) then) =
__$$DietStateErrorImplCopyWithImpl<$Res>;
@useResult
$Res call({String message});
}
@@ -696,24 +682,22 @@ class __$$DietStateErrorImplCopyWithImpl<$Res>
extends _$AboutDietStateCopyWithImpl<$Res, _$DietStateErrorImpl>
implements _$$DietStateErrorImplCopyWith<$Res> {
__$$DietStateErrorImplCopyWithImpl(
_$DietStateErrorImpl _value,
$Res Function(_$DietStateErrorImpl) _then,
) : super(_value, _then);
_$DietStateErrorImpl _value, $Res Function(_$DietStateErrorImpl) _then)
: super(_value, _then);
/// Create a copy of AboutDietState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? message = null}) {
return _then(
_$DietStateErrorImpl(
message:
null == message
? _value.message
: message // ignore: cast_nullable_to_non_nullable
as String,
),
);
$Res call({
Object? message = null,
}) {
return _then(_$DietStateErrorImpl(
message: null == message
? _value.message
: message // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
@@ -748,9 +732,7 @@ class _$DietStateErrorImpl implements DietStateError {
@pragma('vm:prefer-inline')
_$$DietStateErrorImplCopyWith<_$DietStateErrorImpl> get copyWith =>
__$$DietStateErrorImplCopyWithImpl<_$DietStateErrorImpl>(
this,
_$identity,
);
this, _$identity);
@override
@optionalTypeArgs
@@ -759,7 +741,7 @@ class _$DietStateErrorImpl implements DietStateError {
required TResult Function() initial,
required TResult Function() loading,
required TResult Function(Diet diet, bool isStarted, bool hasStartedDiet)
loaded,
loaded,
required TResult Function(String message) error,
}) {
return error(message);

View File

@@ -98,7 +98,7 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
return BlocBuilder<AboutDietCubit, AboutDietState>(
builder: (context, dietState) {
if (dietState is DietStateLoaded) {
Future.delayed(Duration(milliseconds: 500), () {
Future.delayed(const Duration(milliseconds: 500), () {
if (widget.navigateToComments && !_jumped) {
_scrollToBottom();
}
@@ -107,7 +107,7 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
backgroundColor: appTheme.gray100,
resizeToAvoidBottomInset: true,
bottomSheet: Container(
padding: EdgeInsets.symmetric(vertical: 12) + (Platform.isIOS ? const EdgeInsets.only(bottom: 16) : EdgeInsets.zero),
padding: const EdgeInsets.symmetric(vertical: 12) + (Platform.isIOS ? const EdgeInsets.only(bottom: 16) : EdgeInsets.zero),
decoration: BoxDecoration(
color: Colors.white,
border: Border(
@@ -169,7 +169,7 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
),
),
),
SizedBox(width: 8),
const SizedBox(width: 8),
BookmarkButton(
isFavorite: dietState.diet.isFavorite,
onTap: () {
@@ -188,7 +188,7 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
),
],
),
SizedBox(height: 8),
const SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
@@ -209,17 +209,17 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
),
height: 32,
width: 32,
child: Icon(
child: const Icon(
Icons.close_rounded,
size: 18,
color: Colors.white,
),
),
),
if (replyId != null) SizedBox(width: 8),
if (replyId != null) const SizedBox(width: 8),
Expanded(
child: ConstrainedBox(
constraints: BoxConstraints(minHeight: 52),
constraints: const BoxConstraints(minHeight: 52),
child: TextFormField(
textCapitalization: TextCapitalization.sentences,
onChanged: (_) {
@@ -229,7 +229,7 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
maxLines: 5,
minLines: 1,
keyboardType: TextInputType.multiline,
style: TextStyle(
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.black,
@@ -237,9 +237,9 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
),
decoration: InputDecoration(
isDense: false, // убираем true, чтобы padding учитывался корректно
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 16), // вертикальный паддинг увеличен
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16), // вертикальный паддинг увеличен
hintText: 'Комментарий',
hintStyle: TextStyle(
hintStyle: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
height: 1.2,
@@ -248,21 +248,21 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
filled: true,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(color: Color(0xFFD1D1D6), width: 1),
borderSide: const BorderSide(color: Color(0xFFD1D1D6), width: 1),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(color: Color(0xFFD1D1D6), width: 1),
borderSide: const BorderSide(color: Color(0xFFD1D1D6), width: 1),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(color: Color(0xFFD1D1D6), width: 1),
borderSide: const BorderSide(color: Color(0xFFD1D1D6), width: 1),
),
),
),
),
),
SizedBox(width: 8),
const SizedBox(width: 8),
GestureDetector(
onTap: () {
if (textEditingController.text.length > 2) {
@@ -277,7 +277,7 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
textEditingController.clear();
replyId = null;
});
Future.delayed(Duration(milliseconds: 500), () {
Future.delayed(const Duration(milliseconds: 500), () {
dietsCubit.getDiet(widget.diet.id, index: widget.index);
});
FocusManager.instance.primaryFocus?.unfocus();
@@ -321,7 +321,7 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
complainedContentType: ComplainedContent.diet,
id: widget.diet.id,
),
anchor: Aligned(
anchor: const Aligned(
shiftToWithinBound: AxisFlag(x: true, y: true),
follower: Alignment.topRight,
target: Alignment.bottomRight,
@@ -343,11 +343,11 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
),
body: SingleChildScrollView(
controller: scrollController,
padding: EdgeInsets.only(bottom: 160),
padding: const EdgeInsets.only(bottom: 160),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 8),
const SizedBox(height: 8),
MainBackgroundBouble(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -355,7 +355,7 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
Stack(
children: [
CachedNetworkImage(
imageUrl: baseUrl + '/storage/' + widget.diet.image,
imageUrl: '$baseUrl/storage/${widget.diet.image}',
height: 300,
width: MediaQuery.sizeOf(context).width,
fit: BoxFit.fill,
@@ -368,22 +368,23 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
InfoBouble(
backgroundColor: appTheme.whiteA700,
children: [
SvgPicture.asset('assets/icons/eye.svg', width: 18, height: 12),
SizedBox(width: 8),
const SizedBox(width: 8),
Text(
dietState.diet.totalViews.toString(),
style: TextStyles.textXSSemibold.copyWith(color: appTheme.black),
),
],
backgroundColor: appTheme.whiteA700,
),
SizedBox(width: 12),
const SizedBox(width: 12),
GestureDetector(
onTap: () {
dietsCubit.likeDiet(widget.diet.id, widget.index);
},
child: InfoBouble(
backgroundColor: appTheme.whiteA700,
children: [
SvgPicture.asset(
'assets/icons/heart.svg',
@@ -391,33 +392,32 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
height: 12,
colorFilter: dietState.diet.wasLikedByMe ? ColorFilter.mode(appTheme.blueA400, BlendMode.srcIn) : null,
),
SizedBox(width: 8),
const SizedBox(width: 8),
Text(
dietState.diet.totalLikes.toString(),
style: TextStyles.textXSSemibold.copyWith(color: appTheme.black),
),
],
backgroundColor: appTheme.whiteA700,
),
),
SizedBox(width: 12),
const SizedBox(width: 12),
InfoBouble(
backgroundColor: appTheme.whiteA700,
children: [
SvgPicture.asset('assets/icons/comment2.svg', width: 13, height: 12),
SizedBox(width: 8),
const SizedBox(width: 8),
Text(
dietState.diet.totalComments.toString(),
style: TextStyles.textXSSemibold.copyWith(color: appTheme.black),
),
],
backgroundColor: appTheme.whiteA700,
),
],
),
),
],
),
SizedBox(height: 16),
const SizedBox(height: 16),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
@@ -425,7 +425,7 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
),
),
SizedBox(height: 12),
const SizedBox(height: 12),
InfoRow(
diet: widget.diet,
type: ProductType.diet,
@@ -433,7 +433,7 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
ExpandableText(
text: widget.diet.details,
),
SizedBox(height: 20),
const SizedBox(height: 20),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: AuthorCard(
@@ -441,17 +441,17 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
title: s.diet_author,
),
),
SizedBox(height: 16),
const SizedBox(height: 16),
],
),
),
SizedBox(height: 16),
const SizedBox(height: 16),
MainBackgroundBouble(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: Center(
child: Text(
s.diet_plan + '(${widget.diet.duration.toString()} ' + getDayForm(widget.diet.duration, s) + ')',
'${s.diet_plan}(${widget.diet.duration.toString()} ${getDayForm(widget.diet.duration, s)})',
style: TextStyles.headingXLSemibold.copyWith(
color: appTheme.black,
),
@@ -459,9 +459,9 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
),
),
),
SizedBox(height: 8),
const SizedBox(height: 8),
ListView.builder(
physics: NeverScrollableScrollPhysics(),
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index) {
return _dayOfPlan(widget.diet.dailySchedule[index + 1] ?? {}, index, s);
@@ -469,20 +469,20 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
itemCount: widget.diet.dailySchedule.length,
),
MainBackgroundBouble(
padding: EdgeInsets.symmetric(vertical: 16),
padding: const EdgeInsets.symmetric(vertical: 16),
child: Column(
children: [
Container(
padding: EdgeInsets.symmetric(horizontal: 16),
padding: const EdgeInsets.symmetric(horizontal: 16),
alignment: Alignment.centerLeft,
child: Text(
dietState.diet.totalComments.toString() + ' ' + getCommentForm(dietState.diet.totalComments, s),
'${dietState.diet.totalComments} ${getCommentForm(dietState.diet.totalComments, s)}',
style: TextStyles.textMMedium.copyWith(
color: appTheme.gray500,
),
),
),
SizedBox(height: 16),
const SizedBox(height: 16),
if (state is CommentsStateLoading) const Loader(),
if (state is CommentsStateLoaded)
CommentsWidget(
@@ -519,7 +519,7 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
complainedContentType: ComplainedContent.diet,
id: widget.diet.id,
),
anchor: Aligned(
anchor: const Aligned(
shiftToWithinBound: AxisFlag(x: true, y: true),
follower: Alignment.topRight,
target: Alignment.bottomRight,
@@ -563,7 +563,7 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
complainedContentType: ComplainedContent.diet,
id: widget.diet.id,
),
anchor: Aligned(
anchor: const Aligned(
shiftToWithinBound: AxisFlag(x: true, y: true),
follower: Alignment.topRight,
target: Alignment.bottomRight,
@@ -594,7 +594,7 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
}
_dayOfPlan(Map<int, Map<int, DailySchedule>> day, int dayNumber, S s) {
_choiceChipWidget(int index) {
choiceChipWidget(int index) {
return ChoiceChip(
selectedColor: appTheme.blueA400,
pressElevation: 0,
@@ -621,7 +621,7 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
return Padding(
padding: const EdgeInsets.only(bottom: 8),
child: MainBackgroundBouble(
padding: EdgeInsets.only(
padding: const EdgeInsets.only(
top: 16,
),
child: Column(
@@ -632,13 +632,13 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
s.day + ' ' + (dayNumber + 1).toString(),
'${s.day} ${dayNumber + 1}',
style: TextStyles.headingXLSemibold.copyWith(
color: appTheme.black,
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
const Padding(
padding: EdgeInsets.symmetric(vertical: 12),
child: CustomDivider(),
),
Text(
@@ -650,21 +650,21 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_choiceChipWidget(0),
_choiceChipWidget(1),
_choiceChipWidget(2),
_choiceChipWidget(3),
_choiceChipWidget(4),
choiceChipWidget(0),
choiceChipWidget(1),
choiceChipWidget(2),
choiceChipWidget(3),
choiceChipWidget(4),
],
),
SizedBox(height: 8),
const SizedBox(height: 8),
ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) => _daily(day[widget.selectedIndexes[dayNumber] + 1]?[index + 1], s),
itemCount: day[widget.selectedIndexes[dayNumber] + 1]?.length ?? 0,
),
SizedBox(height: 8),
const SizedBox(height: 8),
],
),
),
@@ -695,9 +695,9 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
),
),
),
Spacer(),
const Spacer(),
Text(
daily.quantity.toString() + ' ' + getLocalizedMeasurementUnits(s, daily.portion),
'${daily.quantity} ${getLocalizedMeasurementUnits(s, daily.portion)}',
style: TextStyles.textMSemibold.copyWith(
color: appTheme.black,
),

View File

@@ -7,14 +7,16 @@ import 'package:flutter_svg/svg.dart';
import 'package:go_router/go_router.dart';
class AuthorCard extends StatelessWidget {
const AuthorCard({super.key, required this.author, required this.title});
const AuthorCard({super.key, required this.author, required this.title, this.backgroundColor, this.titleStyle});
final Author author;
final String title;
final Color? backgroundColor;
final TextStyle? titleStyle;
@override
Widget build(BuildContext context) {
Widget build(BuildContext context) {
return Container(
width: MediaQuery.sizeOf(context).width,
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: appTheme.cardBackground),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: backgroundColor ?? appTheme.cardBackground),
child: Stack(
children: [
Padding(
@@ -42,7 +44,7 @@ class AuthorCard extends StatelessWidget {
),
title: Text(
title,
style: TextStyles.textSSemibold.copyWith(
style: titleStyle ?? TextStyles.textSSemibold.copyWith(
color: appTheme.gray,
),
),
@@ -55,7 +57,7 @@ class AuthorCard extends StatelessWidget {
color: appTheme.black,
),
),
SizedBox(width: 10),
const SizedBox(width: 10),
if (author.authorPlaceInRating != null)
InfoBouble(
radius: 12,

View File

@@ -34,13 +34,13 @@ class _CalendarWidgetState extends State<CalendarWidget> {
final dateFormatter = DateFormat('MMMM', 'ru_RU');
return Center(
child: Text(
'${dateFormatter.format(day).capitalize()}',
dateFormatter.format(day).capitalize(),
style: TextStyle(color: appTheme.black, fontSize: 16, fontWeight: FontWeight.w400),
),
);
},
),
headerStyle: HeaderStyle(
headerStyle: const HeaderStyle(
titleCentered: true,
formatButtonVisible: false,
leftChevronVisible: false,

View File

@@ -18,9 +18,9 @@ class CancelDietBottomSheet extends StatelessWidget {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(height: 4),
BottomSheetHandlerBar(),
SizedBox(height: 12),
const SizedBox(height: 4),
const BottomSheetHandlerBar(),
const SizedBox(height: 12),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 25.0),
child: Text(
@@ -32,12 +32,13 @@ class CancelDietBottomSheet extends StatelessWidget {
),
),
Padding(
padding: EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 28),
padding: const EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 28),
child: CustomOutlinedButton(
onPressed: () async {
if (title != null) {
final result = await aboutDietCubit.cancelDiet();
if (result) {
if (!context.mounted) return;
Navigator.pop(context);
showSuccessToast('предыдущая диета отменена');
showModalBottomSheet(
@@ -48,16 +49,19 @@ class CancelDietBottomSheet extends StatelessWidget {
);
} else {
showErrorToast('Не удалось отменить диету');
if (!context.mounted) return;
Navigator.pop(context);
}
} else {
final result = await aboutDietCubit.cancelDiet();
if (result) {
showSuccessToast('Диета отменена');
if (!context.mounted) return;
Navigator.pop(context);
aboutDietCubit.clearStartedDietsState();
} else {
showErrorToast('Не удалось отменить диету');
if (!context.mounted) return;
Navigator.pop(context);
}
}
@@ -69,7 +73,7 @@ class CancelDietBottomSheet extends StatelessWidget {
),
buttonStyle: ButtonStyle(
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
side: WidgetStatePropertyAll(BorderSide.none),
side: const WidgetStatePropertyAll(BorderSide.none),
),
),
),

View File

@@ -10,10 +10,10 @@ class ExpandableText extends StatefulWidget {
final String text;
final int maxLines;
ExpandableText({required this.text, this.maxLines = 3});
const ExpandableText({super.key, required this.text, this.maxLines = 3});
@override
_ExpandableTextState createState() => _ExpandableTextState();
State<ExpandableText> createState() => _ExpandableTextState();
}
class _ExpandableTextState extends State<ExpandableText> {

View File

@@ -10,7 +10,7 @@ class InfoBouble extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
padding: padding ?? EdgeInsets.symmetric(horizontal: 12, vertical: 8.5),
padding: padding ?? const EdgeInsets.symmetric(horizontal: 12, vertical: 8.5),
decoration: BoxDecoration(
color: backgroundColor ?? appTheme.gray50,
borderRadius: BorderRadius.circular(radius),

View File

@@ -25,6 +25,7 @@ class MoreOptions extends StatelessWidget {
final s = S.of(context);
return MainBackgroundBouble(
enableShadow: true,
width: 272,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 14),
child: Column(
@@ -45,13 +46,13 @@ class MoreOptions extends StatelessWidget {
color: appTheme.black,
),
),
Spacer(),
const Spacer(),
SvgPicture.asset('assets/icons/copy2.svg', width: 16, height: 20),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 12.0),
const Padding(
padding: EdgeInsets.symmetric(vertical: 12.0),
child: CustomDivider(),
),
GestureDetector(
@@ -74,13 +75,13 @@ class MoreOptions extends StatelessWidget {
color: appTheme.black,
),
),
Spacer(),
const Spacer(),
SvgPicture.asset('assets/icons/share2.svg', width: 16, height: 20),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 12.0),
const Padding(
padding: EdgeInsets.symmetric(vertical: 12.0),
child: CustomDivider(),
),
GestureDetector(
@@ -107,7 +108,7 @@ class MoreOptions extends StatelessWidget {
color: appTheme.black,
),
),
Spacer(),
const Spacer(),
SvgPicture.asset('assets/icons/complain.svg', width: 16, height: 20),
],
),
@@ -115,7 +116,6 @@ class MoreOptions extends StatelessWidget {
],
),
),
width: 272,
);
}
}

View File

@@ -25,16 +25,16 @@ class _StartDietBottomSheetState extends State<StartDietBottomSheet> {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(height: 4),
BottomSheetHandlerBar(),
SizedBox(height: 12),
const SizedBox(height: 4),
const BottomSheetHandlerBar(),
const SizedBox(height: 12),
Text(
s.startDiet,
style: TextStyles.headingXLSemibold.copyWith(
color: appTheme.black,
),
),
SizedBox(height: 12),
const SizedBox(height: 12),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 25.0),
child: Text(
@@ -45,25 +45,27 @@ class _StartDietBottomSheetState extends State<StartDietBottomSheet> {
),
),
),
SizedBox(height: 12),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
const SizedBox(height: 12),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0),
child: CustomDivider(),
),
CalendarWidget(
startDate: startDate,
),
Padding(
padding: EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 28),
padding: const EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 28),
child: CustomOutlinedButton(
onPressed: () async {
final result = await widget.aboutDietCubit.startDiet(startDate[0]);
if (result) {
showSuccessToast('Диета успешно начата');
showSuccessToast('Диета успешно начата');
if (!context.mounted) return;
Navigator.pop(context);
widget.aboutDietCubit.emitCurrentStartedDietsState();
} else {
showErrorToast('Не удалось начать диету');
showErrorToast('Не удалось начать диету');
if (!context.mounted) return;
Navigator.pop(context);
}
},
@@ -74,7 +76,7 @@ class _StartDietBottomSheetState extends State<StartDietBottomSheet> {
),
buttonStyle: ButtonStyle(
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
side: WidgetStatePropertyAll(BorderSide.none),
side: const WidgetStatePropertyAll(BorderSide.none),
),
),
),

View File

@@ -144,7 +144,7 @@ class _TypeBadgesState extends State<TypeBadges> {
onClose: closeOverlay,
child: PortalTarget(
visible: overlaysVisibilityState[index],
anchor: Aligned(
anchor: const Aligned(
shiftToWithinBound: AxisFlag(x: true, y: true),
follower: Alignment.topRight,
target: Alignment.bottomRight,
@@ -202,13 +202,13 @@ class _InfoOverlayEntry extends StatelessWidget {
final String title;
final String description;
final assetPath;
final String assetPath;
final void Function() onClose;
@override
Widget build(BuildContext context) {
return MainBackgroundBouble(
padding: EdgeInsets.all(8),
padding: const EdgeInsets.all(8),
width: 343,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -220,7 +220,7 @@ class _InfoOverlayEntry extends StatelessWidget {
width: 20,
height: 20,
),
SizedBox(width: 8),
const SizedBox(width: 8),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -233,7 +233,7 @@ class _InfoOverlayEntry extends StatelessWidget {
color: appTheme.black,
),
),
SizedBox(height: 4),
const SizedBox(height: 4),
Text(
description,
softWrap: true,
@@ -261,11 +261,10 @@ class _InfoOverlayEntry extends StatelessWidget {
class _Barrier extends StatelessWidget {
const _Barrier({
Key? key,
required this.onClose,
required this.visible,
required this.child,
}) : super(key: key);
});
final Widget child;
final VoidCallback onClose;