From 6cf8f314d60bb81e8d4a8becf0fedd7c9bcfa049 Mon Sep 17 00:00:00 2001 From: Kelrap Date: Wed, 12 Jun 2024 14:55:06 -0400 Subject: [PATCH] Only enables Replace if correct option selected --- lib/pangea/widgets/igc/span_card.dart | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/pangea/widgets/igc/span_card.dart b/lib/pangea/widgets/igc/span_card.dart index 09fdba4dd..0e85e4d01 100644 --- a/lib/pangea/widgets/igc/span_card.dart +++ b/lib/pangea/widgets/igc/span_card.dart @@ -272,18 +272,38 @@ class WordMatchContent extends StatelessWidget { if (!controller.widget.scm.pangeaMatch!.isITStart) Expanded( child: Opacity( - opacity: controller.selectedChoiceIndex != null ? 1.0 : 0.5, + opacity: controller.selectedChoice != null && + controller.selectedChoice!.type.name == + 'bestCorrection' + ? 1.0 + : 0.5, child: TextButton( - onPressed: controller.selectedChoiceIndex != null + onPressed: controller.selectedChoice != null && + controller.selectedChoice!.type.name == + 'bestCorrection' ? onReplaceSelected : null, style: ButtonStyle( backgroundColor: MaterialStateProperty.all( - (controller.selectedChoice != null + (controller.selectedChoice != null && + controller.selectedChoice!.type.name == + 'bestCorrection' ? controller.selectedChoice!.color : AppConfig.primaryColor) .withOpacity(0.2), ), + // Outline if Replace button enabled + side: controller.selectedChoice != null && + controller.selectedChoice!.type.name == + 'bestCorrection' + ? MaterialStateProperty.all( + BorderSide( + color: controller.selectedChoice!.color, + style: BorderStyle.solid, + width: 2.0, + ), + ) + : null, ), child: Text(L10n.of(context)!.replace), ),