Fix dto
This commit is contained in:
parent
a05311d3e1
commit
06273a64fe
@ -1,8 +1,8 @@
|
||||
{
|
||||
"@@locale": "ru",
|
||||
|
||||
"cardLiked": "Сладость добавлена в понравившиеся :)",
|
||||
"cardDisliked": "Сладость удалена из понравившегося :(",
|
||||
"cardLiked": "Конфета добавлена в понравившиеся :)",
|
||||
"cardDisliked": "Конфета удалена из понравившегося :(",
|
||||
"searchInputPlaceholder": "Поиск ..",
|
||||
|
||||
"titleCard" : "Название",
|
||||
|
@ -23,36 +23,22 @@ class CandiesResponseDto {
|
||||
@JsonSerializable(createToJson: false)
|
||||
class CandyItemDto {
|
||||
@JsonKey(name: "beanId")
|
||||
final int? candyId;
|
||||
|
||||
@JsonKey(name: "groupName")
|
||||
final List<String>? manufacturer;
|
||||
final List<String>? ingredients;
|
||||
final int? id;
|
||||
|
||||
@JsonKey(name: "flavorName")
|
||||
final String? name;
|
||||
final String? description;
|
||||
final String? colorGroup;
|
||||
final String? backgroundColor;
|
||||
final String? imageUrl;
|
||||
final bool? glutenFree;
|
||||
final bool? sugarFree;
|
||||
final bool? seasonal;
|
||||
final bool? kosher;
|
||||
|
||||
@JsonKey(name: "groupName")
|
||||
final List<String>? manufacturer;
|
||||
|
||||
const CandyItemDto(
|
||||
{this.candyId,
|
||||
this.manufacturer,
|
||||
this.ingredients,
|
||||
{this.id,
|
||||
this.name,
|
||||
this.description,
|
||||
this.colorGroup,
|
||||
this.backgroundColor,
|
||||
this.imageUrl,
|
||||
this.glutenFree,
|
||||
this.sugarFree,
|
||||
this.seasonal,
|
||||
this.kosher});
|
||||
this.manufacturer});
|
||||
|
||||
factory CandyItemDto.fromJson(Map<String, dynamic> json) => _$CandyItemDtoFromJson(json);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ extension CandyItemDtoToModel on CandyItemDto {
|
||||
"https://upload.wikimedia.org/wikipedia/commons/a/a2/Person_Image_Placeholder.png",
|
||||
description: description ?? "UNKNOWN",
|
||||
manufacturer: manufacturer ?? ["UNKNOWN"],
|
||||
candyId: candyId);
|
||||
id: id);
|
||||
}
|
||||
|
||||
extension CandiesDtoToModel on CandiesResponseDto {
|
||||
|
@ -3,12 +3,12 @@ class CardData {
|
||||
final String imageUrl;
|
||||
final String description;
|
||||
final List<String> manufacturer;
|
||||
final int? candyId;
|
||||
final int? id;
|
||||
|
||||
const CardData(
|
||||
{required this.name,
|
||||
required this.imageUrl,
|
||||
required this.description,
|
||||
required this.manufacturer,
|
||||
required this.candyId});
|
||||
required this.id});
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ class _MyCandyPageState extends State<MyCandyPage> {
|
||||
: Card.fromData(
|
||||
data,
|
||||
isLiked:
|
||||
likeState.likedIds?.contains(data.candyId) == true,
|
||||
likeState.likedIds?.contains(data.id) == true,
|
||||
onLike: (int? id, String text, bool isLiked) =>
|
||||
_onLike(id, text, isLiked),
|
||||
onTap: () => _navigateToDetailsPage(context, data),
|
||||
|
@ -27,7 +27,7 @@ class Card extends StatelessWidget {
|
||||
VoidCallback? onTap,
|
||||
bool isLiked = false}) =>
|
||||
Card(
|
||||
id: data.candyId,
|
||||
id: data.id,
|
||||
name: data.name,
|
||||
description: data.description,
|
||||
image: data.imageUrl,
|
||||
@ -81,16 +81,22 @@ class Card extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 20, width: 150),
|
||||
Center(
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxWidth: 270, // Максимальная ширина изображения
|
||||
),
|
||||
child: AspectRatio(
|
||||
aspectRatio: 4 / 3, // Соотношение сторон (4:3)
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(20.0),
|
||||
child: Image.network(
|
||||
image,
|
||||
fit: BoxFit.cover,
|
||||
aspectRatio: 6 / 4, // Соотношение сторон (4:3)
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(20.0),
|
||||
child: Image.network(
|
||||
image,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 50),
|
||||
child: Column(
|
||||
@ -98,7 +104,7 @@ class Card extends StatelessWidget {
|
||||
children: [
|
||||
Text(name, style: const TextStyle(fontSize: 24)),
|
||||
Text(
|
||||
"${context.locale.price}: ${(((id ?? 1) % 10 + 1) * (Random().nextDouble() * 0.6 + 0.1)).toStringAsFixed(2)} \$",
|
||||
"${context.locale.price}: ${(((id ?? 1) % 10 + 1) * (pi * 0.2 + 0.1)).toStringAsFixed(2)} \$",
|
||||
style: const TextStyle(fontSize: 18)),
|
||||
],
|
||||
))
|
||||
|
Loading…
x
Reference in New Issue
Block a user