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
This commit is contained in:
parent
6cb6b7ebac
commit
064e2c6dd3
2 changed files with 29 additions and 10 deletions
|
|
@ -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(
|
||||
matchIndex: widget.scm.matchIndex,
|
||||
choiceIndex: selectedChoiceIndex!,
|
||||
)
|
||||
.then((value) => setState(() {}));
|
||||
await widget.scm.onReplacementSelect(
|
||||
matchIndex: widget.scm.matchIndex,
|
||||
choiceIndex: selectedChoiceIndex!,
|
||||
);
|
||||
_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…
Add table
Reference in a new issue