fluffychat/lib/pangea/models/pangea_token_text_model.dart
ggurdin 1317989db0
1179 toolbar changes (#1209)
* updated toolbar buttons

* initial work for toolbar updates

* Add WordZoomWidget to display word and lemma information (#1214)

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/pangeachat/client/tree/1179-toolbar-changes?shareId=XXXX-XXXX-XXXX-XXXX).

* word zoom card prototyped, activity generation in progress

* adding copy for new construct uses

* laying down TODOs

* initial work for word zoom card

* Always add part of speech to token's morph list

* Prevent duplicate choices in lemma activity

* Don't play token audio at start of morph activity

* Only grant +1 points for emoji activity

* Uncomment tryToSpeak function

* Always update activity once complete

* Added queuing / UI logic for morph activity buttons

* code cleanup

* added required data argument to logError calls

* fix overflowing practice activity card and audio player on mobile

---------

Co-authored-by: wcjord <32568597+wcjord@users.noreply.github.com>
2024-12-27 12:42:49 -05:00

45 lines
1.1 KiB
Dart

import 'dart:developer';
import 'package:flutter/foundation.dart';
class PangeaTokenText {
int offset;
String content;
int length;
PangeaTokenText({
required this.offset,
required this.content,
required this.length,
});
factory PangeaTokenText.fromJson(Map<String, dynamic> json) {
debugger(when: kDebugMode && json[_offsetKey] == null);
return PangeaTokenText(
offset: json[_offsetKey],
content: json[_contentKey],
length: json[_lengthKey] ?? (json[_contentKey] as String).length,
);
}
static const String _offsetKey = "offset";
static const String _contentKey = "content";
static const String _lengthKey = "length";
Map<String, dynamic> toJson() =>
{_offsetKey: offset, _contentKey: content, _lengthKey: length};
//override equals and hashcode
@override
bool operator ==(Object other) {
if (other is PangeaTokenText) {
return other.offset == offset &&
other.content == content &&
other.length == length;
}
return false;
}
@override
int get hashCode => offset.hashCode ^ content.hashCode ^ length.hashCode;
}