PIbd31_Razubaev.S.M._PMU/lib/data/mappers/mangas_mapper.dart

19 lines
742 B
Dart
Raw Permalink Normal View History

2024-10-16 12:08:15 +04:00
import 'package:flutter_app/data/dtos/mangas_dto.dart';
import 'package:flutter_app/domain/models/carddata.dart';
import 'package:flutter_app/presentation/home_page/home_page.dart';
2024-10-16 12:08:15 +04:00
extension MangaDataDtoMapper on MangaDataDto {
CardData toDomain() => CardData(
title ?? 'UNKNOWN',
imageUrl: images?.jpg?.image_url,
descriptionText:
'Статус: ${status}. Рейтинг: ${score}. Людей поставило оценку: ${scored_by}',
);
}
extension MangasDtoToModel on MangasDto {
HomeData toDomain() => HomeData(
data: data?.map((e) => e.toDomain()).toList(),
nextPage: (pagination?.hasNextPage ?? false)
? ((pagination?.currentPage ?? 0) + 1)
: null);
}