From 929909a000f61175a753b3ac1e6c7efbc0192da1 Mon Sep 17 00:00:00 2001 From: William Jordan-Cooley Date: Tue, 18 Jun 2024 12:10:49 -0400 Subject: [PATCH] little code cleanup --- .../widgets/igc/pangea_text_controller.dart | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/lib/pangea/widgets/igc/pangea_text_controller.dart b/lib/pangea/widgets/igc/pangea_text_controller.dart index adecb4f00..b91186c22 100644 --- a/lib/pangea/widgets/igc/pangea_text_controller.dart +++ b/lib/pangea/widgets/igc/pangea_text_controller.dart @@ -71,6 +71,16 @@ class PangeaTextController extends TextEditingController { choreographer.igc.igcTextData!.getTopMatchIndexForOffset( selection.baseOffset, ); + + // if autoplay on and it start then just start it + if (matchIndex != -1 && + choreographer.itAutoPlayEnabled && + choreographer.igc.igcTextData!.matches[matchIndex].isITStart) { + return choreographer.onITStart( + choreographer.igc.igcTextData!.matches[matchIndex], + ); + } + final Widget? cardToShow = matchIndex != -1 ? SpanCard( scm: SpanCardModel( @@ -82,8 +92,8 @@ class PangeaTextController extends TextEditingController { debugPrint("onSentenceRewrite $tokenIndex $sentenceRewrite"); }), onIgnore: () => choreographer.onIgnoreMatch( - cursorOffset: selection.baseOffset, - ), + cursorOffset: selection.baseOffset, + ), onITStart: () { choreographer.onITStart( choreographer.igc.igcTextData!.matches[matchIndex], @@ -96,24 +106,15 @@ class PangeaTextController extends TextEditingController { : null; if (cardToShow != null) { - if ( - choreographer.itAutoPlayEnabled && - choreographer.igc.igcTextData!.matches[matchIndex].isITStart - ) { - choreographer.onITStart( - choreographer.igc.igcTextData!.matches[matchIndex], - ); - } else { - OverlayUtil.showPositionedCard( - context: context, - cardSize: matchIndex != -1 && - choreographer.igc.igcTextData!.matches[matchIndex].isITStart - ? const Size(350, 260) - : const Size(350, 400), - cardToShow: cardToShow, - transformTargetId: choreographer.inputTransformTargetKey, - ); - } + OverlayUtil.showPositionedCard( + context: context, + cardSize: matchIndex != -1 && + choreographer.igc.igcTextData!.matches[matchIndex].isITStart + ? const Size(350, 260) + : const Size(350, 400), + cardToShow: cardToShow, + transformTargetId: choreographer.inputTransformTargetKey, + ); } }