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

20 lines
769 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,
2024-10-17 16:31:39 +04:00
id: id.toString(),
2024-10-16 12:08:15 +04:00
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);
}