|
|
|
|
@ -55,18 +55,36 @@ class SpanCardState extends State<SpanCard> {
|
|
|
|
|
// debugger(when: kDebugMode);
|
|
|
|
|
super.initState();
|
|
|
|
|
getSpanDetails();
|
|
|
|
|
// fetchSelected();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//get selected choice
|
|
|
|
|
SpanChoice? get selectedChoice {
|
|
|
|
|
if (selectedChoiceIndex == null ||
|
|
|
|
|
widget.scm.pangeaMatch?.match.choices == null ||
|
|
|
|
|
widget.scm.pangeaMatch!.match.choices!.length >= selectedChoiceIndex!) {
|
|
|
|
|
widget.scm.pangeaMatch!.match.choices!.length <= selectedChoiceIndex!) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return widget.scm.pangeaMatch?.match.choices?[selectedChoiceIndex!];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void fetchSelected() {
|
|
|
|
|
if (widget.scm.pangeaMatch?.match.choices == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (selectedChoiceIndex == null) {
|
|
|
|
|
DateTime? mostRecent;
|
|
|
|
|
for (int i = 0; i < widget.scm.pangeaMatch!.match.choices!.length; i++) {
|
|
|
|
|
final choice = widget.scm.pangeaMatch?.match.choices![i];
|
|
|
|
|
if (choice!.timestamp != null &&
|
|
|
|
|
(mostRecent == null || choice.timestamp!.isAfter(mostRecent))) {
|
|
|
|
|
mostRecent = choice.timestamp;
|
|
|
|
|
selectedChoiceIndex = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> getSpanDetails() async {
|
|
|
|
|
try {
|
|
|
|
|
if (widget.scm.pangeaMatch?.isITStart ?? false) return;
|
|
|
|
|
@ -110,6 +128,16 @@ class WordMatchContent extends StatelessWidget {
|
|
|
|
|
|
|
|
|
|
Future<void> onChoiceSelect(int index) async {
|
|
|
|
|
controller.selectedChoiceIndex = index;
|
|
|
|
|
controller
|
|
|
|
|
.widget
|
|
|
|
|
.scm
|
|
|
|
|
.choreographer
|
|
|
|
|
.igc
|
|
|
|
|
.igcTextData
|
|
|
|
|
?.matches[controller.widget.scm.matchIndex]
|
|
|
|
|
.match
|
|
|
|
|
.choices?[index]
|
|
|
|
|
.timestamp = DateTime.now();
|
|
|
|
|
controller
|
|
|
|
|
.widget
|
|
|
|
|
.scm
|
|
|
|
|
@ -152,6 +180,7 @@ class WordMatchContent extends StatelessWidget {
|
|
|
|
|
offset: controller.widget.scm.pangeaMatch?.match.offset,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final MatchCopy matchCopy = MatchCopy(
|
|
|
|
|
context,
|
|
|
|
|
controller.widget.scm.pangeaMatch!,
|
|
|
|
|
|