fix: don't highlight words while doing hwl activity (#1481)

This commit is contained in:
ggurdin 2025-01-16 14:04:58 -05:00 committed by GitHub
parent e8d1bba77c
commit d2779eaf82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 8 deletions

View file

@ -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<PracticeActivityEvent?>();
debugPrint('Activity generated: ${res.activity.toJson()}');

View file

@ -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,
),
),
);