27 lines
730 B
Dart
27 lines
730 B
Dart
|
|
import 'package:labs_petrushin/Presentation/home_page/home_page.dart';
|
|
import 'package:labs_petrushin/data/dtos/foods_dto.dart';
|
|
|
|
import '../../domain/models/home.dart';
|
|
|
|
extension CharacterDataDtoToModel on FoodDataDto {
|
|
CardData toDomain() => CardData(
|
|
text: brandName ?? "Просто хлэп",
|
|
info: description ?? "Очень кусьна",
|
|
urlImage: image);
|
|
}
|
|
|
|
extension CharactersDtoToModel on FoodsDto {
|
|
HomeData toDomain() {
|
|
int? nextPage = currentPage;
|
|
|
|
if (currentPage != null && totalPages != null && totalPages! > currentPage!) {
|
|
nextPage = currentPage! + 1;
|
|
}
|
|
|
|
return HomeData(
|
|
data: foods?.map((e) => e.toDomain()).toList(),
|
|
nextPage: nextPage,
|
|
);
|
|
}
|
|
} |