PMU-PIbd-32-Fedorenko-G-Y/flutter_app/lib/data/mappers/characters_mapper.dart

30 lines
879 B
Dart
Raw Normal View History

2024-10-17 15:20:02 +04:00
import 'package:flutter_app/data/dtos/thrones_character_dto.dart';
import 'package:flutter_app/domain/models/card.dart';
2024-11-12 00:23:53 +04:00
import 'package:flutter_app/domain/models/home.dart';
2024-10-17 15:20:02 +04:00
const _imagePlaceholder =
'https://upload.wikimedia.org/wikipedia/en/archive/b/b1/20210811082420%21Portrait_placeholder.png';
2024-11-13 20:17:46 +04:00
extension ThronesCharacterDtoToModel on ThronesCharacterDto {
2024-10-17 15:20:02 +04:00
CardData toDomain() => CardData(
descriptionText: _makeDescriptionText(title, family),
2024-11-04 16:34:24 +04:00
firstName: firstName,
lastName: lastName,
title: title,
family: family,
fullName: fullName,
2024-11-12 00:23:53 +04:00
imageUrl: imageUrl,
2024-11-04 16:34:24 +04:00
text: '',
2024-10-17 15:20:02 +04:00
);
String _makeDescriptionText(String? title, String? family) {
return title != null && family != null
? '$title of $family'
: title != null
? 'Title: $title'
: family != null
? 'Family: $family'
: '';
}
2024-11-12 00:23:53 +04:00
}