PIbd31_Razubaev.S.M._PMU/lib/data/mappers/mangas_mapper.dart
2024-10-17 16:31:39 +04:00

20 lines
769 B
Dart

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';
extension MangaDataDtoMapper on MangaDataDto {
CardData toDomain() => CardData(
title ?? 'UNKNOWN',
imageUrl: images?.jpg?.image_url,
id: id.toString(),
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);
}