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

@@ -39,7 +39,7 @@ class CreateDietScreen extends StatelessWidget {
}
class CreateDietScreenContent extends StatefulWidget {
CreateDietScreenContent({super.key, this.diet});
const CreateDietScreenContent({super.key, this.diet});
final Diet? diet;
@override
@@ -66,18 +66,20 @@ class _CreateDietScreenContentState extends State<CreateDietScreenContent> {
return BlocBuilder<CreateDietCubit, CreateDietState>(
builder: (context, state) {
if (state.published) {
Future.delayed(Duration(milliseconds: 500), () {
Future.delayed(const Duration(milliseconds: 500), () {
if (!context.mounted) return;
context.pop();
showBottomSheetWithBlur(
userRootNavigator: true,
context: context,
child: SuccessPublishedDietBottomSheet(
title: '${state.dietData.name ?? 'Диета'}',
title: state.dietData.name ?? 'Диета',
),
);
});
} else if (state.drafted) {
Future.delayed(Duration(milliseconds: 500), () {
Future.delayed(const Duration(milliseconds: 500), () {
if (!context.mounted) return;
context.pop();
showBottomSheetWithBlur(
context: context,
@@ -103,13 +105,13 @@ class _CreateDietScreenContentState extends State<CreateDietScreenContent> {
body: SingleChildScrollView(
child: Column(
children: [
SizedBox(height: 8),
const SizedBox(height: 8),
MainBackgroundBouble(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 16),
const SizedBox(height: 16),
CustomTextFormField(
hintText: s.enter_diet_name,
controller: nameController,
@@ -119,12 +121,12 @@ class _CreateDietScreenContentState extends State<CreateDietScreenContent> {
},
),
if (state.dietNameError != null) ...[
SizedBox(
const SizedBox(
height: 4,
),
CustomErrorWidget(error: state.dietNameError ?? ''),
],
SizedBox(height: 12),
const SizedBox(height: 12),
SizedBox(
height: 132,
child: CustomTextFormField(
@@ -141,30 +143,30 @@ class _CreateDietScreenContentState extends State<CreateDietScreenContent> {
),
),
if (state.dietDescriptionError != null) ...[
SizedBox(
const SizedBox(
height: 4,
),
CustomErrorWidget(error: state.dietDescriptionError ?? ''),
],
SizedBox(height: 12),
DietDurationDropDownWidget(),
SizedBox(height: 12),
StatusDropDownWidget(),
SizedBox(height: 16),
DietTypeChoiceWidget(),
SizedBox(height: 16),
DietImagePickerWidget(),
SizedBox(height: 16),
const SizedBox(height: 12),
const DietDurationDropDownWidget(),
const SizedBox(height: 12),
const StatusDropDownWidget(),
const SizedBox(height: 16),
const DietTypeChoiceWidget(),
const SizedBox(height: 16),
const DietImagePickerWidget(),
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 + ' (${state.dietData.duration ?? 0} ' + getDayForm(state.dietData.duration ?? 0, s) + ')',
'${s.diet_plan} (${state.dietData.duration ?? 0} ${getDayForm(state.dietData.duration ?? 0, s)})',
style: TextStyles.headingXLSemibold.copyWith(
color: appTheme.black,
),
@@ -172,16 +174,16 @@ class _CreateDietScreenContentState extends State<CreateDietScreenContent> {
),
),
),
SizedBox(height: 8),
const SizedBox(height: 8),
ListView.separated(
padding: const EdgeInsets.all(0),
itemBuilder: (context, index) => DayWidget(index: index),
itemCount: state.dietData.dailySchedule?.length ?? 0,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
separatorBuilder: (context, index) => SizedBox(height: 8),
physics: const NeverScrollableScrollPhysics(),
separatorBuilder: (context, index) => const SizedBox(height: 8),
),
SizedBox(height: 12),
const SizedBox(height: 12),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Column(
@@ -192,19 +194,20 @@ class _CreateDietScreenContentState extends State<CreateDietScreenContent> {
: () async {
final diet = await context.read<CreateDietCubit>().getDietForPreview();
if (diet == null) return;
if (!context.mounted) return;
GoRouter.of(context).pushNamed(DietPreviewScreen.name, extra: diet);
},
text: s.preview,
height: 52,
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.gray),
buttonStyle: ButtonStyle(
side: WidgetStatePropertyAll(BorderSide.none),
side: const WidgetStatePropertyAll(BorderSide.none),
backgroundColor: WidgetStatePropertyAll(appTheme.dottedBorder),
),
),
SizedBox(height: 12),
const SizedBox(height: 12),
if (state.isDietPublishing)
Loader()
const Loader()
else
CustomOutlinedButton(
onPressed: () async {
@@ -213,11 +216,13 @@ class _CreateDietScreenContentState extends State<CreateDietScreenContent> {
widget.diet!.id,
);
if (result == 'error') {
if (!context.mounted) return;
showErrorDialog(context, title: '${s.could_not_update_diet} ${state.dietData.name}');
}
} else {
final result = await context.read<CreateDietCubit>().createDiet();
if (result == 'error') {
if (!context.mounted) return;
showErrorDialog(context, title: '${s.could_not_publish_diet} ${state.dietData.name}');
}
}
@@ -226,14 +231,14 @@ class _CreateDietScreenContentState extends State<CreateDietScreenContent> {
height: 52,
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.whiteA700),
buttonStyle: ButtonStyle(
side: WidgetStatePropertyAll(BorderSide.none),
side: const WidgetStatePropertyAll(BorderSide.none),
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
),
),
],
),
),
SizedBox(height: 20),
const SizedBox(height: 20),
],
),
),

View File

@@ -53,7 +53,7 @@ class CreateDietCubit extends Cubit<CreateDietState> {
name: diet.name,
duration: diet.duration,
type: type,
imageUrl: baseUrl + '/storage/' + diet.image,
imageUrl: '$baseUrl/storage/${diet.image}',
),
);
emit(state.copyWith(dietStateIndex: dietStateIndex, durationIndex: durationValues.indexOf(diet.duration)));

View File

@@ -12,8 +12,7 @@ part of 'create_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 _$CreateDietState {
@@ -45,28 +44,26 @@ mixin _$CreateDietState {
/// @nodoc
abstract class $CreateDietStateCopyWith<$Res> {
factory $CreateDietStateCopyWith(
CreateDietState value,
$Res Function(CreateDietState) then,
) = _$CreateDietStateCopyWithImpl<$Res, CreateDietState>;
CreateDietState value, $Res Function(CreateDietState) then) =
_$CreateDietStateCopyWithImpl<$Res, CreateDietState>;
@useResult
$Res call({
bool isLoading,
bool isDietPublishing,
String? errorMessage,
CreateDietModel dietData,
List<List<DailySchedule>>? copiedDay,
String? dietNameError,
String? dietDescriptionError,
String? dietDurationError,
String? dietStateError,
String? dietImageError,
List<String> dailyScheduleErrors,
int? durationIndex,
int? dietStateIndex,
bool published,
bool drafted,
bool isDietBeingEdited,
});
$Res call(
{bool isLoading,
bool isDietPublishing,
String? errorMessage,
CreateDietModel dietData,
List<List<DailySchedule>>? copiedDay,
String? dietNameError,
String? dietDescriptionError,
String? dietDurationError,
String? dietStateError,
String? dietImageError,
List<String> dailyScheduleErrors,
int? durationIndex,
int? dietStateIndex,
bool published,
bool drafted,
bool isDietBeingEdited});
$CreateDietModelCopyWith<$Res> get dietData;
}
@@ -103,91 +100,72 @@ class _$CreateDietStateCopyWithImpl<$Res, $Val extends CreateDietState>
Object? drafted = null,
Object? isDietBeingEdited = null,
}) {
return _then(
_value.copyWith(
isLoading:
null == isLoading
? _value.isLoading
: isLoading // ignore: cast_nullable_to_non_nullable
as bool,
isDietPublishing:
null == isDietPublishing
? _value.isDietPublishing
: isDietPublishing // ignore: cast_nullable_to_non_nullable
as bool,
errorMessage:
freezed == errorMessage
? _value.errorMessage
: errorMessage // ignore: cast_nullable_to_non_nullable
as String?,
dietData:
null == dietData
? _value.dietData
: dietData // ignore: cast_nullable_to_non_nullable
as CreateDietModel,
copiedDay:
freezed == copiedDay
? _value.copiedDay
: copiedDay // ignore: cast_nullable_to_non_nullable
as List<List<DailySchedule>>?,
dietNameError:
freezed == dietNameError
? _value.dietNameError
: dietNameError // ignore: cast_nullable_to_non_nullable
as String?,
dietDescriptionError:
freezed == dietDescriptionError
? _value.dietDescriptionError
: dietDescriptionError // ignore: cast_nullable_to_non_nullable
as String?,
dietDurationError:
freezed == dietDurationError
? _value.dietDurationError
: dietDurationError // ignore: cast_nullable_to_non_nullable
as String?,
dietStateError:
freezed == dietStateError
? _value.dietStateError
: dietStateError // ignore: cast_nullable_to_non_nullable
as String?,
dietImageError:
freezed == dietImageError
? _value.dietImageError
: dietImageError // ignore: cast_nullable_to_non_nullable
as String?,
dailyScheduleErrors:
null == dailyScheduleErrors
? _value.dailyScheduleErrors
: dailyScheduleErrors // ignore: cast_nullable_to_non_nullable
as List<String>,
durationIndex:
freezed == durationIndex
? _value.durationIndex
: durationIndex // ignore: cast_nullable_to_non_nullable
as int?,
dietStateIndex:
freezed == dietStateIndex
? _value.dietStateIndex
: dietStateIndex // ignore: cast_nullable_to_non_nullable
as int?,
published:
null == published
? _value.published
: published // ignore: cast_nullable_to_non_nullable
as bool,
drafted:
null == drafted
? _value.drafted
: drafted // ignore: cast_nullable_to_non_nullable
as bool,
isDietBeingEdited:
null == isDietBeingEdited
? _value.isDietBeingEdited
: isDietBeingEdited // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
return _then(_value.copyWith(
isLoading: null == isLoading
? _value.isLoading
: isLoading // ignore: cast_nullable_to_non_nullable
as bool,
isDietPublishing: null == isDietPublishing
? _value.isDietPublishing
: isDietPublishing // ignore: cast_nullable_to_non_nullable
as bool,
errorMessage: freezed == errorMessage
? _value.errorMessage
: errorMessage // ignore: cast_nullable_to_non_nullable
as String?,
dietData: null == dietData
? _value.dietData
: dietData // ignore: cast_nullable_to_non_nullable
as CreateDietModel,
copiedDay: freezed == copiedDay
? _value.copiedDay
: copiedDay // ignore: cast_nullable_to_non_nullable
as List<List<DailySchedule>>?,
dietNameError: freezed == dietNameError
? _value.dietNameError
: dietNameError // ignore: cast_nullable_to_non_nullable
as String?,
dietDescriptionError: freezed == dietDescriptionError
? _value.dietDescriptionError
: dietDescriptionError // ignore: cast_nullable_to_non_nullable
as String?,
dietDurationError: freezed == dietDurationError
? _value.dietDurationError
: dietDurationError // ignore: cast_nullable_to_non_nullable
as String?,
dietStateError: freezed == dietStateError
? _value.dietStateError
: dietStateError // ignore: cast_nullable_to_non_nullable
as String?,
dietImageError: freezed == dietImageError
? _value.dietImageError
: dietImageError // ignore: cast_nullable_to_non_nullable
as String?,
dailyScheduleErrors: null == dailyScheduleErrors
? _value.dailyScheduleErrors
: dailyScheduleErrors // ignore: cast_nullable_to_non_nullable
as List<String>,
durationIndex: freezed == durationIndex
? _value.durationIndex
: durationIndex // ignore: cast_nullable_to_non_nullable
as int?,
dietStateIndex: freezed == dietStateIndex
? _value.dietStateIndex
: dietStateIndex // ignore: cast_nullable_to_non_nullable
as int?,
published: null == published
? _value.published
: published // ignore: cast_nullable_to_non_nullable
as bool,
drafted: null == drafted
? _value.drafted
: drafted // ignore: cast_nullable_to_non_nullable
as bool,
isDietBeingEdited: null == isDietBeingEdited
? _value.isDietBeingEdited
: isDietBeingEdited // ignore: cast_nullable_to_non_nullable
as bool,
) as $Val);
}
/// Create a copy of CreateDietState
@@ -204,30 +182,28 @@ class _$CreateDietStateCopyWithImpl<$Res, $Val extends CreateDietState>
/// @nodoc
abstract class _$$CreateDietStateImplCopyWith<$Res>
implements $CreateDietStateCopyWith<$Res> {
factory _$$CreateDietStateImplCopyWith(
_$CreateDietStateImpl value,
$Res Function(_$CreateDietStateImpl) then,
) = __$$CreateDietStateImplCopyWithImpl<$Res>;
factory _$$CreateDietStateImplCopyWith(_$CreateDietStateImpl value,
$Res Function(_$CreateDietStateImpl) then) =
__$$CreateDietStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
bool isLoading,
bool isDietPublishing,
String? errorMessage,
CreateDietModel dietData,
List<List<DailySchedule>>? copiedDay,
String? dietNameError,
String? dietDescriptionError,
String? dietDurationError,
String? dietStateError,
String? dietImageError,
List<String> dailyScheduleErrors,
int? durationIndex,
int? dietStateIndex,
bool published,
bool drafted,
bool isDietBeingEdited,
});
$Res call(
{bool isLoading,
bool isDietPublishing,
String? errorMessage,
CreateDietModel dietData,
List<List<DailySchedule>>? copiedDay,
String? dietNameError,
String? dietDescriptionError,
String? dietDurationError,
String? dietStateError,
String? dietImageError,
List<String> dailyScheduleErrors,
int? durationIndex,
int? dietStateIndex,
bool published,
bool drafted,
bool isDietBeingEdited});
@override
$CreateDietModelCopyWith<$Res> get dietData;
@@ -238,9 +214,8 @@ class __$$CreateDietStateImplCopyWithImpl<$Res>
extends _$CreateDietStateCopyWithImpl<$Res, _$CreateDietStateImpl>
implements _$$CreateDietStateImplCopyWith<$Res> {
__$$CreateDietStateImplCopyWithImpl(
_$CreateDietStateImpl _value,
$Res Function(_$CreateDietStateImpl) _then,
) : super(_value, _then);
_$CreateDietStateImpl _value, $Res Function(_$CreateDietStateImpl) _then)
: super(_value, _then);
/// Create a copy of CreateDietState
/// with the given fields replaced by the non-null parameter values.
@@ -264,115 +239,97 @@ class __$$CreateDietStateImplCopyWithImpl<$Res>
Object? drafted = null,
Object? isDietBeingEdited = null,
}) {
return _then(
_$CreateDietStateImpl(
isLoading:
null == isLoading
? _value.isLoading
: isLoading // ignore: cast_nullable_to_non_nullable
as bool,
isDietPublishing:
null == isDietPublishing
? _value.isDietPublishing
: isDietPublishing // ignore: cast_nullable_to_non_nullable
as bool,
errorMessage:
freezed == errorMessage
? _value.errorMessage
: errorMessage // ignore: cast_nullable_to_non_nullable
as String?,
dietData:
null == dietData
? _value.dietData
: dietData // ignore: cast_nullable_to_non_nullable
as CreateDietModel,
copiedDay:
freezed == copiedDay
? _value._copiedDay
: copiedDay // ignore: cast_nullable_to_non_nullable
as List<List<DailySchedule>>?,
dietNameError:
freezed == dietNameError
? _value.dietNameError
: dietNameError // ignore: cast_nullable_to_non_nullable
as String?,
dietDescriptionError:
freezed == dietDescriptionError
? _value.dietDescriptionError
: dietDescriptionError // ignore: cast_nullable_to_non_nullable
as String?,
dietDurationError:
freezed == dietDurationError
? _value.dietDurationError
: dietDurationError // ignore: cast_nullable_to_non_nullable
as String?,
dietStateError:
freezed == dietStateError
? _value.dietStateError
: dietStateError // ignore: cast_nullable_to_non_nullable
as String?,
dietImageError:
freezed == dietImageError
? _value.dietImageError
: dietImageError // ignore: cast_nullable_to_non_nullable
as String?,
dailyScheduleErrors:
null == dailyScheduleErrors
? _value._dailyScheduleErrors
: dailyScheduleErrors // ignore: cast_nullable_to_non_nullable
as List<String>,
durationIndex:
freezed == durationIndex
? _value.durationIndex
: durationIndex // ignore: cast_nullable_to_non_nullable
as int?,
dietStateIndex:
freezed == dietStateIndex
? _value.dietStateIndex
: dietStateIndex // ignore: cast_nullable_to_non_nullable
as int?,
published:
null == published
? _value.published
: published // ignore: cast_nullable_to_non_nullable
as bool,
drafted:
null == drafted
? _value.drafted
: drafted // ignore: cast_nullable_to_non_nullable
as bool,
isDietBeingEdited:
null == isDietBeingEdited
? _value.isDietBeingEdited
: isDietBeingEdited // ignore: cast_nullable_to_non_nullable
as bool,
),
);
return _then(_$CreateDietStateImpl(
isLoading: null == isLoading
? _value.isLoading
: isLoading // ignore: cast_nullable_to_non_nullable
as bool,
isDietPublishing: null == isDietPublishing
? _value.isDietPublishing
: isDietPublishing // ignore: cast_nullable_to_non_nullable
as bool,
errorMessage: freezed == errorMessage
? _value.errorMessage
: errorMessage // ignore: cast_nullable_to_non_nullable
as String?,
dietData: null == dietData
? _value.dietData
: dietData // ignore: cast_nullable_to_non_nullable
as CreateDietModel,
copiedDay: freezed == copiedDay
? _value._copiedDay
: copiedDay // ignore: cast_nullable_to_non_nullable
as List<List<DailySchedule>>?,
dietNameError: freezed == dietNameError
? _value.dietNameError
: dietNameError // ignore: cast_nullable_to_non_nullable
as String?,
dietDescriptionError: freezed == dietDescriptionError
? _value.dietDescriptionError
: dietDescriptionError // ignore: cast_nullable_to_non_nullable
as String?,
dietDurationError: freezed == dietDurationError
? _value.dietDurationError
: dietDurationError // ignore: cast_nullable_to_non_nullable
as String?,
dietStateError: freezed == dietStateError
? _value.dietStateError
: dietStateError // ignore: cast_nullable_to_non_nullable
as String?,
dietImageError: freezed == dietImageError
? _value.dietImageError
: dietImageError // ignore: cast_nullable_to_non_nullable
as String?,
dailyScheduleErrors: null == dailyScheduleErrors
? _value._dailyScheduleErrors
: dailyScheduleErrors // ignore: cast_nullable_to_non_nullable
as List<String>,
durationIndex: freezed == durationIndex
? _value.durationIndex
: durationIndex // ignore: cast_nullable_to_non_nullable
as int?,
dietStateIndex: freezed == dietStateIndex
? _value.dietStateIndex
: dietStateIndex // ignore: cast_nullable_to_non_nullable
as int?,
published: null == published
? _value.published
: published // ignore: cast_nullable_to_non_nullable
as bool,
drafted: null == drafted
? _value.drafted
: drafted // ignore: cast_nullable_to_non_nullable
as bool,
isDietBeingEdited: null == isDietBeingEdited
? _value.isDietBeingEdited
: isDietBeingEdited // ignore: cast_nullable_to_non_nullable
as bool,
));
}
}
/// @nodoc
class _$CreateDietStateImpl implements _CreateDietState {
const _$CreateDietStateImpl({
required this.isLoading,
required this.isDietPublishing,
required this.errorMessage,
required this.dietData,
final List<List<DailySchedule>>? copiedDay,
this.dietNameError,
this.dietDescriptionError,
this.dietDurationError,
this.dietStateError,
this.dietImageError,
required final List<String> dailyScheduleErrors,
this.durationIndex,
this.dietStateIndex,
this.published = false,
this.drafted = false,
this.isDietBeingEdited = false,
}) : _copiedDay = copiedDay,
_dailyScheduleErrors = dailyScheduleErrors;
const _$CreateDietStateImpl(
{required this.isLoading,
required this.isDietPublishing,
required this.errorMessage,
required this.dietData,
final List<List<DailySchedule>>? copiedDay,
this.dietNameError,
this.dietDescriptionError,
this.dietDurationError,
this.dietStateError,
this.dietImageError,
required final List<String> dailyScheduleErrors,
this.durationIndex,
this.dietStateIndex,
this.published = false,
this.drafted = false,
this.isDietBeingEdited = false})
: _copiedDay = copiedDay,
_dailyScheduleErrors = dailyScheduleErrors;
@override
final bool isLoading;
@@ -443,10 +400,8 @@ class _$CreateDietStateImpl implements _CreateDietState {
other.errorMessage == errorMessage) &&
(identical(other.dietData, dietData) ||
other.dietData == dietData) &&
const DeepCollectionEquality().equals(
other._copiedDay,
_copiedDay,
) &&
const DeepCollectionEquality()
.equals(other._copiedDay, _copiedDay) &&
(identical(other.dietNameError, dietNameError) ||
other.dietNameError == dietNameError) &&
(identical(other.dietDescriptionError, dietDescriptionError) ||
@@ -457,10 +412,8 @@ class _$CreateDietStateImpl implements _CreateDietState {
other.dietStateError == dietStateError) &&
(identical(other.dietImageError, dietImageError) ||
other.dietImageError == dietImageError) &&
const DeepCollectionEquality().equals(
other._dailyScheduleErrors,
_dailyScheduleErrors,
) &&
const DeepCollectionEquality()
.equals(other._dailyScheduleErrors, _dailyScheduleErrors) &&
(identical(other.durationIndex, durationIndex) ||
other.durationIndex == durationIndex) &&
(identical(other.dietStateIndex, dietStateIndex) ||
@@ -474,24 +427,23 @@ class _$CreateDietStateImpl implements _CreateDietState {
@override
int get hashCode => Object.hash(
runtimeType,
isLoading,
isDietPublishing,
errorMessage,
dietData,
const DeepCollectionEquality().hash(_copiedDay),
dietNameError,
dietDescriptionError,
dietDurationError,
dietStateError,
dietImageError,
const DeepCollectionEquality().hash(_dailyScheduleErrors),
durationIndex,
dietStateIndex,
published,
drafted,
isDietBeingEdited,
);
runtimeType,
isLoading,
isDietPublishing,
errorMessage,
dietData,
const DeepCollectionEquality().hash(_copiedDay),
dietNameError,
dietDescriptionError,
dietDurationError,
dietStateError,
dietImageError,
const DeepCollectionEquality().hash(_dailyScheduleErrors),
durationIndex,
dietStateIndex,
published,
drafted,
isDietBeingEdited);
/// Create a copy of CreateDietState
/// with the given fields replaced by the non-null parameter values.
@@ -500,30 +452,27 @@ class _$CreateDietStateImpl implements _CreateDietState {
@pragma('vm:prefer-inline')
_$$CreateDietStateImplCopyWith<_$CreateDietStateImpl> get copyWith =>
__$$CreateDietStateImplCopyWithImpl<_$CreateDietStateImpl>(
this,
_$identity,
);
this, _$identity);
}
abstract class _CreateDietState implements CreateDietState {
const factory _CreateDietState({
required final bool isLoading,
required final bool isDietPublishing,
required final String? errorMessage,
required final CreateDietModel dietData,
final List<List<DailySchedule>>? copiedDay,
final String? dietNameError,
final String? dietDescriptionError,
final String? dietDurationError,
final String? dietStateError,
final String? dietImageError,
required final List<String> dailyScheduleErrors,
final int? durationIndex,
final int? dietStateIndex,
final bool published,
final bool drafted,
final bool isDietBeingEdited,
}) = _$CreateDietStateImpl;
const factory _CreateDietState(
{required final bool isLoading,
required final bool isDietPublishing,
required final String? errorMessage,
required final CreateDietModel dietData,
final List<List<DailySchedule>>? copiedDay,
final String? dietNameError,
final String? dietDescriptionError,
final String? dietDurationError,
final String? dietStateError,
final String? dietImageError,
required final List<String> dailyScheduleErrors,
final int? durationIndex,
final int? dietStateIndex,
final bool published,
final bool drafted,
final bool isDietBeingEdited}) = _$CreateDietStateImpl;
@override
bool get isLoading;

View File

@@ -62,7 +62,7 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
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(
@@ -97,7 +97,7 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
),
),
),
SizedBox(width: 8),
const SizedBox(width: 8),
BookmarkButton(
isFavorite: widget.diet.isFavorite,
onTap: () {},
@@ -109,7 +109,7 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
),
],
),
SizedBox(height: 8),
const SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
@@ -127,27 +127,27 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
decoration: InputDecoration(
isDense: true,
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
hintText: s.comment.capitalize(),
hintStyle: TextStyles.textMMedium.copyWith(color: appTheme.lightGray600),
filled: true,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
borderSide: const BorderSide(
color: Color(0xFFD1D1D6),
width: 1,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
borderSide: const BorderSide(
color: Color(0xFFD1D1D6),
width: 1,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
borderSide: const BorderSide(
color: Color(0xFFD1D1D6),
width: 1,
),
@@ -156,7 +156,7 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
),
),
),
SizedBox(width: 8),
const SizedBox(width: 8),
GestureDetector(
onTap: () {},
child: Container(
@@ -196,7 +196,7 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
disableActions: true,
path: 'diet/${widget.diet.id}',
),
anchor: Aligned(
anchor: const Aligned(
shiftToWithinBound: AxisFlag(x: true, y: true),
follower: Alignment.topRight,
target: Alignment.bottomRight,
@@ -218,11 +218,11 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
),
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,
@@ -246,20 +246,21 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
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(
widget.diet.totalViews.toString(),
style: TextStyles.textXSSemibold.copyWith(color: appTheme.black),
),
],
backgroundColor: appTheme.whiteA700,
),
SizedBox(width: 12),
const SizedBox(width: 12),
GestureDetector(
onTap: () {},
child: InfoBouble(
backgroundColor: appTheme.whiteA700,
children: [
SvgPicture.asset(
'assets/icons/heart.svg',
@@ -267,33 +268,32 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
height: 12,
colorFilter: widget.diet.wasLikedByMe ? ColorFilter.mode(appTheme.blueA400, BlendMode.srcIn) : null,
),
SizedBox(width: 8),
const SizedBox(width: 8),
Text(
widget.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(
widget.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(
@@ -301,12 +301,12 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
),
),
SizedBox(height: 12),
const SizedBox(height: 12),
InfoRow(diet: widget.diet, type: ProductType.diet,),
ExpandableText(
text: widget.diet.details,
),
SizedBox(height: 20),
const SizedBox(height: 20),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: AuthorCard(
@@ -314,17 +314,17 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
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,
),
@@ -332,9 +332,9 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
),
),
),
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] ?? {}, index, s);
@@ -342,20 +342,20 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
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(
'0' + ' ' + getCommentForm(widget.diet.totalComments, s),
'0 ${getCommentForm(widget.diet.totalComments, s)}',
style: TextStyles.textMMedium.copyWith(
color: appTheme.gray500,
),
),
),
SizedBox(height: 16),
const SizedBox(height: 16),
],
),
),
@@ -366,7 +366,7 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
}
_dayOfPlan(Map<int, Map<int, DailySchedule>> day, int dayNumber, S s) {
_choiceChipWidget(int index) {
choiceChipWidget(int index) {
return ChoiceChip(
selectedColor: appTheme.blueA400,
pressElevation: 0,
@@ -393,7 +393,7 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
return Padding(
padding: const EdgeInsets.only(bottom: 8),
child: MainBackgroundBouble(
padding: EdgeInsets.only(
padding: const EdgeInsets.only(
top: 16,
),
child: Column(
@@ -404,13 +404,13 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
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(
@@ -422,21 +422,21 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
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),
],
),
),
@@ -453,7 +453,7 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
}
_daily(DailySchedule? daily, S s) {
if (daily == null) return SizedBox.shrink();
if (daily == null) return const SizedBox.shrink();
return Padding(
padding: const EdgeInsets.only(bottom: 12),
child: Row(
@@ -467,9 +467,9 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
),
),
),
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

@@ -54,7 +54,7 @@ class _AddMealWidgetState extends State<AddMealWidget> {
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
const Text(
'Добавление блюда',
style: TextStyle(
fontSize: 20,
@@ -75,7 +75,7 @@ class _AddMealWidgetState extends State<AddMealWidget> {
onChanged: (query) {
EasyDebounce.debounce(
'glossary-search',
Duration(milliseconds: 250),
const Duration(milliseconds: 250),
() async {
selectedGlossary = null;
if (query.isEmpty) {
@@ -113,7 +113,7 @@ class _AddMealWidgetState extends State<AddMealWidget> {
),
glossariesList.isEmpty ? const SizedBox(height: 16) : const SizedBox.shrink(),
Container(
constraints: BoxConstraints(
constraints: const BoxConstraints(
maxHeight: 256,
),
child: ListView.separated(
@@ -135,7 +135,7 @@ class _AddMealWidgetState extends State<AddMealWidget> {
),
title: Text(
glossariesList[i].name,
style: TextStyle(
style: const TextStyle(
height: 1,
),
),
@@ -152,12 +152,12 @@ class _AddMealWidgetState extends State<AddMealWidget> {
Icons.add_rounded,
color: Colors.grey.shade400,
),
contentPadding: EdgeInsets.only(left: 12),
contentPadding: const EdgeInsets.only(left: 12),
);
},
itemCount: glossariesList.length,
separatorBuilder: (BuildContext context, int index) {
return CustomDivider();
return const CustomDivider();
},
),
),
@@ -179,9 +179,9 @@ class _AddMealWidgetState extends State<AddMealWidget> {
height: 52,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Color(0xFFF6F6F6),
color: const Color(0xFFF6F6F6),
),
child: Icon(
child: const Icon(
Icons.delete_outline_rounded,
color: Colors.red,
),
@@ -201,7 +201,7 @@ class _AddMealWidgetState extends State<AddMealWidget> {
child: Center(
child: Text(
widget.portionIndex == null ? 'Добавить' : 'Сохранить',
style: TextStyle(
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: Colors.white,
@@ -220,10 +220,10 @@ class _AddMealWidgetState extends State<AddMealWidget> {
Future<void> addPortion() async {
final portionIndex = widget.portionIndex;
var measurementUnits = selectedGlossary?.grInPortion == null
? Portion.PCS
? Portion.pcs
: selectedGlossary?.grInPortion == 0
? Portion.GRAMS
: Portion.PCS;
? Portion.grams
: Portion.pcs;
final glossary = selectedGlossary;
if (glossary != null) {
final [calories, carbohydrates, proteins, fats] = _getCPFC(glossary, measurementUnits);
@@ -265,7 +265,7 @@ class _AddMealWidgetState extends State<AddMealWidget> {
),
);
if (newGlossary != null) {
measurementUnits = Portion.GRAMS;
measurementUnits = Portion.grams;
final [calories, carbohydrates, proteins, fats] = _getCPFC(newGlossary, measurementUnits);
final portion = DailySchedule(
dailyNutrition: DailyNutrition(energy: calories, proteins: proteins, fats: fats, carbohydrates: carbohydrates),
@@ -297,7 +297,7 @@ class _AddMealWidgetState extends State<AddMealWidget> {
final double carbohydrates;
final double proteins;
final double fats;
if (measurementUnits == Portion.GRAMS) {
if (measurementUnits == Portion.grams) {
calories = (glossary.energyOn100Gr * int.parse(quantityController.text) / 100);
carbohydrates = (glossary.carbohydratesOn100Gr * int.parse(quantityController.text) / 100);
proteins = (glossary.proteinsOn100Gr * int.parse(quantityController.text) / 100);
@@ -310,5 +310,4 @@ class _AddMealWidgetState extends State<AddMealWidget> {
}
return [calories, carbohydrates, proteins, fats];
}
}

View File

@@ -17,7 +17,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/svg.dart';
class DayWidget extends StatefulWidget {
DayWidget({
const DayWidget({
super.key,
required this.index,
});
@@ -47,10 +47,10 @@ class _DayWidgetState extends State<DayWidget> {
Row(
children: [
Text(
s.day + ' ${widget.index + 1}',
'${s.day} ${widget.index + 1}',
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
),
Spacer(),
const Spacer(),
GestureDetector(
onTap: () {
context.read<CreateDietCubit>().copyDay(widget.index);
@@ -65,23 +65,23 @@ class _DayWidgetState extends State<DayWidget> {
),
],
),
SizedBox(
const SizedBox(
height: 12,
),
CustomDivider(),
SizedBox(
const CustomDivider(),
const SizedBox(
height: 12,
),
Text(
s.meal,
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
),
SizedBox(height: 16),
const SizedBox(height: 16),
Row(
children: [
ChoiceChipWidget(
chipsLabelList: chipsLabelList,
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 6),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
fontSize: TextStyles.textMMedium.fontSize,
fontWeight: TextStyles.textMMedium.fontWeight,
index: 0,
@@ -92,10 +92,10 @@ class _DayWidgetState extends State<DayWidget> {
});
},
),
Spacer(),
const Spacer(),
ChoiceChipWidget(
chipsLabelList: chipsLabelList,
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 6),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
fontSize: TextStyles.textMMedium.fontSize,
fontWeight: TextStyles.textMMedium.fontWeight,
index: 1,
@@ -106,10 +106,10 @@ class _DayWidgetState extends State<DayWidget> {
});
},
),
Spacer(),
const Spacer(),
ChoiceChipWidget(
chipsLabelList: chipsLabelList,
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 6),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
fontSize: TextStyles.textMMedium.fontSize,
fontWeight: TextStyles.textMMedium.fontWeight,
index: 2,
@@ -120,10 +120,10 @@ class _DayWidgetState extends State<DayWidget> {
});
},
),
Spacer(),
const Spacer(),
ChoiceChipWidget(
chipsLabelList: chipsLabelList,
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 6),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
fontSize: TextStyles.textMMedium.fontSize,
fontWeight: TextStyles.textMMedium.fontWeight,
index: 3,
@@ -134,10 +134,10 @@ class _DayWidgetState extends State<DayWidget> {
});
},
),
Spacer(),
const Spacer(),
ChoiceChipWidget(
chipsLabelList: chipsLabelList,
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 6),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
fontSize: TextStyles.textMMedium.fontSize,
fontWeight: TextStyles.textMMedium.fontWeight,
index: 4,
@@ -151,10 +151,10 @@ class _DayWidgetState extends State<DayWidget> {
],
),
ListView.separated(
separatorBuilder: (context, index) => SizedBox(
separatorBuilder: (context, index) => const SizedBox(
height: 8,
),
padding: EdgeInsets.all(0),
padding: const EdgeInsets.all(0),
itemBuilder: (context, index) {
final product = state.dietData.dailySchedule?[widget.index][_selectedMealIndex][index];
if (product != null) {
@@ -174,9 +174,9 @@ class _DayWidgetState extends State<DayWidget> {
},
itemCount: state.dietData.dailySchedule?[widget.index][_selectedMealIndex].length ?? 0,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
physics: const NeverScrollableScrollPhysics(),
),
SizedBox(height: 16),
const SizedBox(height: 16),
Row(
children: [
GestureDetector(
@@ -184,8 +184,8 @@ class _DayWidgetState extends State<DayWidget> {
context.read<CreateDietCubit>().pasteCopiedDay(widget.index);
},
child: Container(
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 14),
decoration: BoxDecoration(color: appTheme.gray50, borderRadius: BorderRadius.all(Radius.circular(12))),
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 14),
decoration: BoxDecoration(color: appTheme.gray50, borderRadius: const BorderRadius.all(Radius.circular(12))),
child: SvgPicture.asset(
'assets/icons/paste2.svg',
width: 28,
@@ -193,7 +193,7 @@ class _DayWidgetState extends State<DayWidget> {
),
),
),
SizedBox(width: 8),
const SizedBox(width: 8),
Expanded(
child: CustomOutlinedButton(
onPressed: () {
@@ -209,7 +209,7 @@ class _DayWidgetState extends State<DayWidget> {
color: appTheme.whiteA700,
),
buttonStyle: ButtonStyle(
side: WidgetStatePropertyAll(BorderSide.none),
side: const WidgetStatePropertyAll(BorderSide.none),
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
),
),
@@ -217,10 +217,10 @@ class _DayWidgetState extends State<DayWidget> {
],
),
if (state.dailyScheduleErrors[widget.index].isNotEmpty) ...[
SizedBox(height: 12),
const SizedBox(height: 12),
CustomErrorWidget(error: state.dailyScheduleErrors[widget.index]),
],
SizedBox(height: 20),
const SizedBox(height: 20),
],
),
),
@@ -274,7 +274,7 @@ class _DayWidgetState extends State<DayWidget> {
carbohydrates: carbohydrates,
);
}
return CpfcContainer(
return const CpfcContainer(
calories: 0,
proteins: 0,
fats: 0,
@@ -302,7 +302,7 @@ class _DayWidgetState extends State<DayWidget> {
quantityControllerText: quantity.toString(),
);
},
trailing: Icon(Icons.more_vert_rounded),
trailing: const Icon(Icons.more_vert_rounded),
title: Text(product),
subtitle: Text('$quantity $portion'),
shape: RoundedRectangleBorder(
@@ -324,7 +324,7 @@ class _DayWidgetState extends State<DayWidget> {
return showModalBottomSheet(
useRootNavigator: true,
context: context,
shape: RoundedRectangleBorder(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(12)),
),
isScrollControlled: true,

View File

@@ -26,9 +26,9 @@ class _DietDurationDropDownWidgetState extends State<DietDurationDropDownWidget>
super.didChangeDependencies();
final s = S.of(context);
if (durationDropDownTitles.isEmpty) {
durationValues.forEach((element) {
for (var element in durationValues) {
durationDropDownTitles.add('$element ${getDayForm(element, s)}');
});
}
}
}
@@ -54,18 +54,18 @@ class _DietDurationDropDownWidgetState extends State<DietDurationDropDownWidget>
items: durationDropDownTitles
.mapIndexed(
(index, value) => DropdownMenuItem(
value: durationDropDownTitles[index],
child: Text(
durationDropDownTitles[index],
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
),
value: durationDropDownTitles[index],
),
)
.toList(),
value: state.durationIndex == null ? null : durationDropDownTitles[state.durationIndex ?? 0],
),
if (state.dietDurationError != null) ...[
SizedBox(
const SizedBox(
height: 4,
),
CustomErrorWidget(error: state.dietDurationError ?? ''),

View File

@@ -31,12 +31,13 @@ class _DietImagePickerWidgetState extends State<DietImagePickerWidget> {
final picker = ImagePicker();
final image = await picker.pickImage(source: ImageSource.camera);
cubit.setImage(image);
if (!context.mounted) return;
Navigator.of(context).pop();
},
child: Row(
children: [
Icon(Icons.photo_camera),
SizedBox(width: 8),
const Icon(Icons.photo_camera),
const SizedBox(width: 8),
Text(s.photo),
],
),
@@ -46,12 +47,13 @@ class _DietImagePickerWidgetState extends State<DietImagePickerWidget> {
final picker = ImagePicker();
final image = await picker.pickImage(source: ImageSource.gallery);
cubit.setImage(image);
if (!context.mounted) return;
Navigator.of(context).pop();
},
child: Row(
children: [
Icon(Icons.photo),
SizedBox(width: 8),
const Icon(Icons.photo),
const SizedBox(width: 8),
Text(s.gallery),
],
),
@@ -96,7 +98,7 @@ class _DietImagePickerWidgetState extends State<DietImagePickerWidget> {
color: appTheme.gray50,
),
width: MediaQuery.sizeOf(context).width,
padding: hasImage ? null : EdgeInsets.all(8),
padding: hasImage ? null : const EdgeInsets.all(8),
child: hasImage
? Padding(
padding: const EdgeInsets.only(top: 6, right: 6),
@@ -113,7 +115,7 @@ class _DietImagePickerWidgetState extends State<DietImagePickerWidget> {
color: appTheme.dividerColor,
shape: BoxShape.circle,
),
child: Icon(
child: const Icon(
Icons.close_rounded,
color: Colors.grey,
size: 16,
@@ -126,20 +128,20 @@ class _DietImagePickerWidgetState extends State<DietImagePickerWidget> {
children: [
DottedBorder(
stackFit: StackFit.expand,
dashPattern: [14, 14],
dashPattern: const [14, 14],
color: state.dietImageError != null ? appTheme.red : appTheme.dottedBorder,
borderType: BorderType.RRect,
radius: Radius.circular(12),
child: SizedBox.expand(),
radius: const Radius.circular(12),
child: const SizedBox.expand(),
),
Center(
child: Column(
children: [
SizedBox(
const SizedBox(
height: 48,
),
SvgPicture.asset('assets/icons/eatvio_logo.svg'),
SizedBox(
const SizedBox(
height: 24,
),
Text(
@@ -153,7 +155,7 @@ class _DietImagePickerWidgetState extends State<DietImagePickerWidget> {
),
),
),
if (state.dietImageError != null) ...[SizedBox(height: 8), CustomErrorWidget(error: state.dietImageError ?? '')],
if (state.dietImageError != null) ...[const SizedBox(height: 8), CustomErrorWidget(error: state.dietImageError ?? '')],
],
);
},

View File

@@ -9,7 +9,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/svg.dart';
class DietTypeChoiceWidget extends StatefulWidget {
DietTypeChoiceWidget({super.key});
const DietTypeChoiceWidget({super.key});
@override
State<DietTypeChoiceWidget> createState() => _DietTypeChoiceWidgetState();
@@ -76,12 +76,12 @@ class _DietTypeChoiceWidgetState extends State<DietTypeChoiceWidget> {
height: 80,
child: Column(
children: [
SizedBox(height: 16),
const SizedBox(height: 16),
SvgPicture.asset(
choiceContent[index].$1,
height: 30,
),
SizedBox(height: 8),
const SizedBox(height: 8),
Text(
choiceContent[index].$2,
overflow: TextOverflow.clip,

View File

@@ -11,7 +11,7 @@ class CustomErrorWidget extends StatelessWidget {
return Row(
children: [
SvgPicture.asset('assets/icons/error_icon.svg', width: 14, height: 14),
SizedBox(
const SizedBox(
width: 2,
),
Expanded(

View File

@@ -26,7 +26,7 @@ class _StatusDropDownWidgetState extends State<StatusDropDownWidget> {
super.didChangeDependencies();
final s = S.of(context);
if (dietStateTitles.isEmpty) {
dietStates.forEach((elem) {
for (var elem in dietStates) {
switch (elem) {
case DietState.active:
dietStateTitles.add(s.active_diet_state);
@@ -35,7 +35,7 @@ class _StatusDropDownWidgetState extends State<StatusDropDownWidget> {
case DietState.personal:
dietStateTitles.add(s.personal_diet_state);
}
});
}
}
}
@@ -62,18 +62,18 @@ class _StatusDropDownWidgetState extends State<StatusDropDownWidget> {
items: dietStateTitles
.mapIndexed(
(index, value) => DropdownMenuItem(
value: dietStates[index],
child: Text(
dietStateTitles[index],
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
),
value: dietStates[index],
),
)
.toList(),
value: state.dietStateIndex == null ? null : dietStates[state.dietStateIndex ?? 0],
),
if (state.dietStateError != null) ...[
SizedBox(
const SizedBox(
height: 4,
),
CustomErrorWidget(error: state.dietStateError ?? ''),