feat: after completing match in igc, automatically go to next match (#1396)

* feat: after completing match in igc, automatically go to next match

* fix: if user ever chose correct choice in span card, auto-select it again on open
pull/1593/head
ggurdin 10 months ago committed by GitHub
parent 6cb6b7ebac
commit 064e2c6dd3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -414,7 +414,6 @@ class Choreographer {
);
igc.igcTextData?.matches.clear();
} finally {
giveInputFocus();
setState();
}
}
@ -464,7 +463,6 @@ class Choreographer {
igc.igcTextData?.matches.clear();
} finally {
setState();
giveInputFocus();
}
}

@ -81,6 +81,19 @@ class SpanCardState extends State<SpanCard> {
if (widget.scm.pangeaMatch?.match.choices == null) {
return;
}
// if user ever selected the correct choice, automatically select it
final selectedCorrectIndex =
widget.scm.pangeaMatch!.match.choices!.indexWhere((choice) {
return choice.selected && choice.isBestCorrection;
});
if (selectedCorrectIndex != -1) {
selectedChoiceIndex = selectedCorrectIndex;
currentExpression = BotExpression.gold;
return;
}
if (selectedChoiceIndex == null) {
DateTime? mostRecent;
final numChoices = widget.scm.pangeaMatch!.match.choices!.length;
@ -173,28 +186,36 @@ class SpanCardState extends State<SpanCard> {
);
}
void onReplaceSelected() {
Future<void> onReplaceSelected() async {
addIgnoredTokenUses();
widget.scm
.onReplacementSelect(
await widget.scm.onReplacementSelect(
matchIndex: widget.scm.matchIndex,
choiceIndex: selectedChoiceIndex!,
)
.then((value) => setState(() {}));
);
_showFirstMatch();
}
void onIgnoreMatch() {
MatrixState.pAnyState.closeOverlay();
addIgnoredTokenUses();
Future.delayed(
Duration.zero,
() {
widget.scm.onIgnore();
_showFirstMatch();
},
);
}
void _showFirstMatch() {
if (widget.scm.choreographer.igc.igcTextData != null &&
widget.scm.choreographer.igc.igcTextData!.matches.isNotEmpty) {
widget.scm.choreographer.igc.showFirstMatch(context);
} else {
MatrixState.pAnyState.closeOverlay();
}
}
@override
Widget build(BuildContext context) {
return WordMatchContent(controller: this);

Loading…
Cancel
Save