feat: initial release of Oracle 999 divination app
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
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;
|
||||
|
||||
const HistoryEntry({
|
||||
required this.id,
|
||||
required this.timestamp,
|
||||
required this.word,
|
||||
required this.sessionNumber,
|
||||
required this.partOfSpeech,
|
||||
required this.symbolicMeaning,
|
||||
this.readingType = 'Жребий',
|
||||
this.positionTitle,
|
||||
});
|
||||
|
||||
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,
|
||||
};
|
||||
}
|
||||
|
||||
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?,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
class WordItem {
|
||||
final int id; // Base index 0..999
|
||||
final int sessionNumber; // Dynamic randomized session number 0..999
|
||||
final String word;
|
||||
final String partOfSpeech;
|
||||
final double frequency;
|
||||
final String category;
|
||||
final String description;
|
||||
|
||||
const WordItem({
|
||||
required this.id,
|
||||
this.sessionNumber = 0,
|
||||
required this.word,
|
||||
required this.partOfSpeech,
|
||||
required this.frequency,
|
||||
this.category = '',
|
||||
this.description = '',
|
||||
});
|
||||
|
||||
WordItem copyWith({
|
||||
int? id,
|
||||
int? sessionNumber,
|
||||
String? word,
|
||||
String? partOfSpeech,
|
||||
double? frequency,
|
||||
String? category,
|
||||
String? description,
|
||||
}) {
|
||||
return WordItem(
|
||||
id: id ?? this.id,
|
||||
sessionNumber: sessionNumber ?? this.sessionNumber,
|
||||
word: word ?? this.word,
|
||||
partOfSpeech: partOfSpeech ?? this.partOfSpeech,
|
||||
frequency: frequency ?? this.frequency,
|
||||
category: category ?? this.category,
|
||||
description: description ?? this.description,
|
||||
);
|
||||
}
|
||||
|
||||
String get formattedSessionNumber => sessionNumber.toString().padLeft(3, '0');
|
||||
String get formattedId => formattedSessionNumber;
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'id': id,
|
||||
'sessionNumber': sessionNumber,
|
||||
'word': word,
|
||||
'partOfSpeech': partOfSpeech,
|
||||
'frequency': frequency,
|
||||
'category': category,
|
||||
'description': description,
|
||||
};
|
||||
}
|
||||
|
||||
factory WordItem.fromMap(Map<String, dynamic> map) {
|
||||
return WordItem(
|
||||
id: map['id'] as int,
|
||||
sessionNumber: map['sessionNumber'] as int? ?? (map['id'] as int),
|
||||
word: map['word'] as String,
|
||||
partOfSpeech: map['partOfSpeech'] as String,
|
||||
frequency: (map['frequency'] as num).toDouble(),
|
||||
category: map['category'] as String? ?? '',
|
||||
description: map['description'] as String? ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => '#$formattedSessionNumber: $word ($partOfSpeech)';
|
||||
}
|
||||
Reference in New Issue
Block a user