From d2779eaf825fe754f892cc7eff0a8835c5af5d21 Mon Sep 17 00:00:00 2001 From: ggurdin <46800240+ggurdin@users.noreply.github.com> Date: Thu, 16 Jan 2025 14:04:58 -0500 Subject: [PATCH] fix: don't highlight words while doing hwl activity (#1481) --- lib/pangea/toolbar/repo/practice_repo.dart | 2 +- .../toolbar/widgets/message_token_text.dart | 21 ++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/pangea/toolbar/repo/practice_repo.dart b/lib/pangea/toolbar/repo/practice_repo.dart index c02cbcf50..cb748ba53 100644 --- a/lib/pangea/toolbar/repo/practice_repo.dart +++ b/lib/pangea/toolbar/repo/practice_repo.dart @@ -161,9 +161,9 @@ class PracticeGenerationController { req: req, context: context, ); + res.activity.content.choices.sort((a, b) => a.length.compareTo(b.length)); // TODO resolve some wierdness here whereby the activity can be null but then... it's not - final eventCompleter = Completer(); debugPrint('Activity generated: ${res.activity.toJson()}'); diff --git a/lib/pangea/toolbar/widgets/message_token_text.dart b/lib/pangea/toolbar/widgets/message_token_text.dart index 4c04bcebf..49be95482 100644 --- a/lib/pangea/toolbar/widgets/message_token_text.dart +++ b/lib/pangea/toolbar/widgets/message_token_text.dart @@ -171,6 +171,8 @@ class MessageTextWidget extends StatelessWidget { ); } + final hasHiddenTokens = tokenPositions.any((t) => t.hideContent); + return RichText( softWrap: softWrap ?? true, maxLines: maxLines, @@ -196,6 +198,17 @@ class MessageTextWidget extends StatelessWidget { .take(tokenPosition.end - tokenPosition.start) .toString(); + Color backgroundColor = Colors.transparent; + if (!hasHiddenTokens) { + if (tokenPosition.selected) { + backgroundColor = AppConfig.primaryColor.withAlpha(80); + } else if (isSelected != null && shouldDo) { + backgroundColor = !didMeaningActivity + ? AppConfig.success.withAlpha(60) + : AppConfig.gold.withAlpha(60); + } + } + if (tokenPosition.token != null) { if (tokenPosition.hideContent) { return WidgetSpan( @@ -214,13 +227,7 @@ class MessageTextWidget extends StatelessWidget { text: substring, style: style.merge( TextStyle( - backgroundColor: tokenPosition.selected - ? AppConfig.primaryColor.withAlpha(80) - : (isSelected != null && shouldDo) - ? !didMeaningActivity - ? AppConfig.success.withAlpha(60) - : AppConfig.gold.withAlpha(60) - : Colors.transparent, + backgroundColor: backgroundColor, ), ), );