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';
|
2024-10-16 14:37:36 +04:00
|
|
|
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,
|
2024-10-17 16:31:39 +04:00
|
|
|
id: id.toString(),
|
2024-10-16 12:08:15 +04:00
|
|
|
descriptionText:
|
|
|
|
'Статус: ${status}. Рейтинг: ${score}. Людей поставило оценку: ${scored_by}',
|
|
|
|
);
|
|
|
|
}
|
2024-10-16 14:37:36 +04:00
|
|
|
extension MangasDtoToModel on MangasDto {
|
|
|
|
HomeData toDomain() => HomeData(
|
|
|
|
data: data?.map((e) => e.toDomain()).toList(),
|
|
|
|
nextPage: (pagination?.hasNextPage ?? false)
|
|
|
|
? ((pagination?.currentPage ?? 0) + 1)
|
|
|
|
: null);
|
|
|
|
}
|