2025-11-16 11:25:27 +00:00
|
|
|
import 'package:mnemo_cards_common_backend/mnemo_cards_common_backend.dart';
|
|
|
|
|
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
|
|
|
|
|
|
|
|
|
extension converterExtenxion on GameCardModel {
|
|
|
|
|
GameCardDto toDto() {
|
|
|
|
|
return GameCardDto(
|
2025-12-13 20:55:50 +00:00
|
|
|
id: id,
|
2025-11-16 11:25:27 +00:00
|
|
|
image: image,
|
|
|
|
|
mnemo: mnemo,
|
|
|
|
|
original: original,
|
|
|
|
|
translation: translation,
|
|
|
|
|
transcription: transcription,
|
|
|
|
|
transcriptionMnemo: transcriptionMnemo,
|
|
|
|
|
imageBack: imageBack,
|
|
|
|
|
back: back,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extension listConverterExtenxion on Iterable<GameCardModel> {
|
2025-12-13 20:55:50 +00:00
|
|
|
List<GameCardDto> toDtosList(List<String> cardsOrder) =>
|
2025-12-20 18:26:15 +00:00
|
|
|
map((e) => e.toDto()).toList()..sort((p, n) {
|
|
|
|
|
final pIndex = cardsOrder.indexOf(p.id);
|
|
|
|
|
final nIndex = cardsOrder.indexOf(n.id);
|
|
|
|
|
if (pIndex == -1) {
|
|
|
|
|
return nIndex == -1 ? p.id.compareTo(n.id) : 1;
|
|
|
|
|
} else if (nIndex == -1) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
return pIndex.compareTo(nIndex);
|
|
|
|
|
});
|
2025-11-16 11:25:27 +00:00
|
|
|
}
|