2024-11-15 21:47:58 +04:00
|
|
|
import 'package:mobiles_labs_5th_semester/data/dto/games_dto.dart';
|
|
|
|
import 'package:mobiles_labs_5th_semester/domain/models/game.dart';
|
2024-11-19 23:39:56 +04:00
|
|
|
import 'package:mobiles_labs_5th_semester/domain/models/page_of_games_home.dart';
|
|
|
|
|
|
|
|
extension GamesDtoToModel on GamesDto {
|
|
|
|
PageOfGames toDomain() => PageOfGames(
|
|
|
|
data: data?.map((e) => e.toDomain()).toList(),
|
|
|
|
nextPage: next);
|
|
|
|
}
|
2024-11-15 21:47:58 +04:00
|
|
|
|
|
|
|
extension GameDtoToModel on GameDto {
|
|
|
|
GameData toDomain() {
|
2024-11-19 23:39:56 +04:00
|
|
|
// удаление HTML-тегов из описания
|
2024-11-15 21:47:58 +04:00
|
|
|
String cleanedDescription = description ?? '';
|
|
|
|
if (cleanedDescription.isNotEmpty) {
|
2024-11-19 23:39:56 +04:00
|
|
|
cleanedDescription =
|
|
|
|
cleanedDescription.replaceAll(RegExp(r'<[^>]*>'), '');
|
2024-11-15 21:47:58 +04:00
|
|
|
}
|
|
|
|
// return GameData(name: name ?? 'Неизвестная игра', price: 100, image: image?.originalUrl, description: cleanedDescription);
|
2024-11-19 23:39:56 +04:00
|
|
|
return GameData(
|
|
|
|
id: id,
|
|
|
|
name: name ?? 'Неизвестная игра',
|
|
|
|
date: DateTime.parse(date ?? '2000-01-01'),
|
|
|
|
image: image,
|
|
|
|
description: cleanedDescription);
|
2024-11-15 21:47:58 +04:00
|
|
|
}
|
2024-11-19 23:39:56 +04:00
|
|
|
}
|