94 lines
3.0 KiB
Dart
94 lines
3.0 KiB
Dart
class HistoryEntry {
|
|
final String id;
|
|
final DateTime timestamp;
|
|
final String word;
|
|
final int sessionNumber;
|
|
final String partOfSpeech;
|
|
final String symbolicMeaning;
|
|
final String readingType;
|
|
final String? positionTitle;
|
|
final String? question;
|
|
final String? aiInterpretation;
|
|
|
|
const HistoryEntry({
|
|
required this.id,
|
|
required this.timestamp,
|
|
required this.word,
|
|
required this.sessionNumber,
|
|
required this.partOfSpeech,
|
|
required this.symbolicMeaning,
|
|
this.readingType = 'Жребий',
|
|
this.positionTitle,
|
|
this.question,
|
|
this.aiInterpretation,
|
|
});
|
|
|
|
HistoryEntry copyWith({
|
|
String? id,
|
|
DateTime? timestamp,
|
|
String? word,
|
|
int? sessionNumber,
|
|
String? partOfSpeech,
|
|
String? symbolicMeaning,
|
|
String? readingType,
|
|
String? positionTitle,
|
|
String? question,
|
|
String? aiInterpretation,
|
|
}) {
|
|
return HistoryEntry(
|
|
id: id ?? this.id,
|
|
timestamp: timestamp ?? this.timestamp,
|
|
word: word ?? this.word,
|
|
sessionNumber: sessionNumber ?? this.sessionNumber,
|
|
partOfSpeech: partOfSpeech ?? this.partOfSpeech,
|
|
symbolicMeaning: symbolicMeaning ?? this.symbolicMeaning,
|
|
readingType: readingType ?? this.readingType,
|
|
positionTitle: positionTitle ?? this.positionTitle,
|
|
question: question ?? this.question,
|
|
aiInterpretation: aiInterpretation ?? this.aiInterpretation,
|
|
);
|
|
}
|
|
|
|
String get formattedSessionNumber => sessionNumber.toString().padLeft(3, '0');
|
|
|
|
String get formattedDate {
|
|
final day = timestamp.day.toString().padLeft(2, '0');
|
|
final month = timestamp.month.toString().padLeft(2, '0');
|
|
final year = timestamp.year.toString();
|
|
final hour = timestamp.hour.toString().padLeft(2, '0');
|
|
final minute = timestamp.minute.toString().padLeft(2, '0');
|
|
final second = timestamp.second.toString().padLeft(2, '0');
|
|
return '$day.$month.$year $hour:$minute:$second';
|
|
}
|
|
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
'id': id,
|
|
'timestamp': timestamp.toIso8601String(),
|
|
'word': word,
|
|
'sessionNumber': sessionNumber,
|
|
'partOfSpeech': partOfSpeech,
|
|
'symbolicMeaning': symbolicMeaning,
|
|
'readingType': readingType,
|
|
'positionTitle': positionTitle,
|
|
'question': question,
|
|
'aiInterpretation': aiInterpretation,
|
|
};
|
|
}
|
|
|
|
factory HistoryEntry.fromMap(Map<String, dynamic> map) {
|
|
return HistoryEntry(
|
|
id: map['id'] as String? ?? DateTime.now().millisecondsSinceEpoch.toString(),
|
|
timestamp: DateTime.tryParse(map['timestamp'] as String? ?? '') ?? DateTime.now(),
|
|
word: map['word'] as String? ?? '',
|
|
sessionNumber: map['sessionNumber'] as int? ?? 0,
|
|
partOfSpeech: map['partOfSpeech'] as String? ?? '',
|
|
symbolicMeaning: map['symbolicMeaning'] as String? ?? '',
|
|
readingType: map['readingType'] as String? ?? 'Жребий',
|
|
positionTitle: map['positionTitle'] as String?,
|
|
question: map['question'] as String?,
|
|
aiInterpretation: map['aiInterpretation'] as String?,
|
|
);
|
|
}
|
|
}
|