From 6cf8f314d60bb81e8d4a8becf0fedd7c9bcfa049 Mon Sep 17 00:00:00 2001 From: Kelrap Date: Wed, 12 Jun 2024 14:55:06 -0400 Subject: [PATCH 1/3] 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), ), From 671d27cd23f2541d0eec1e58f364ebe00c91e8d2 Mon Sep 17 00:00:00 2001 From: Kelrap Date: Fri, 14 Jun 2024 13:24:52 -0400 Subject: [PATCH 2/3] Un-unenables replace button on incorrect select --- lib/pangea/widgets/igc/span_card.dart | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/lib/pangea/widgets/igc/span_card.dart b/lib/pangea/widgets/igc/span_card.dart index 0e85e4d01..ff174b7bf 100644 --- a/lib/pangea/widgets/igc/span_card.dart +++ b/lib/pangea/widgets/igc/span_card.dart @@ -272,30 +272,20 @@ class WordMatchContent extends StatelessWidget { if (!controller.widget.scm.pangeaMatch!.isITStart) Expanded( child: Opacity( - opacity: controller.selectedChoice != null && - controller.selectedChoice!.type.name == - 'bestCorrection' - ? 1.0 - : 0.5, + opacity: controller.selectedChoice != null ? 1.0 : 0.5, child: TextButton( - onPressed: controller.selectedChoice != null && - controller.selectedChoice!.type.name == - 'bestCorrection' + onPressed: controller.selectedChoice != null ? onReplaceSelected : null, style: ButtonStyle( backgroundColor: MaterialStateProperty.all( - (controller.selectedChoice != null && - controller.selectedChoice!.type.name == - 'bestCorrection' + (controller.selectedChoice != null ? controller.selectedChoice!.color : AppConfig.primaryColor) .withOpacity(0.2), ), // Outline if Replace button enabled - side: controller.selectedChoice != null && - controller.selectedChoice!.type.name == - 'bestCorrection' + side: controller.selectedChoice != null ? MaterialStateProperty.all( BorderSide( color: controller.selectedChoice!.color, From 9153623a9341f3a039594509630be75ba614166c Mon Sep 17 00:00:00 2001 From: ggurdin Date: Fri, 14 Jun 2024 13:29:41 -0400 Subject: [PATCH 3/3] change deprecated class --- lib/pangea/widgets/igc/span_card.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/pangea/widgets/igc/span_card.dart b/lib/pangea/widgets/igc/span_card.dart index ff174b7bf..0d149eaec 100644 --- a/lib/pangea/widgets/igc/span_card.dart +++ b/lib/pangea/widgets/igc/span_card.dart @@ -251,7 +251,7 @@ class WordMatchContent extends StatelessWidget { opacity: 0.8, child: TextButton( style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( AppConfig.primaryColor.withOpacity(0.1), ), ), @@ -272,13 +272,13 @@ class WordMatchContent extends StatelessWidget { if (!controller.widget.scm.pangeaMatch!.isITStart) Expanded( child: Opacity( - opacity: controller.selectedChoice != null ? 1.0 : 0.5, + opacity: controller.selectedChoiceIndex != null ? 1.0 : 0.5, child: TextButton( - onPressed: controller.selectedChoice != null + onPressed: controller.selectedChoiceIndex != null ? onReplaceSelected : null, style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( (controller.selectedChoice != null ? controller.selectedChoice!.color : AppConfig.primaryColor) @@ -286,7 +286,7 @@ class WordMatchContent extends StatelessWidget { ), // Outline if Replace button enabled side: controller.selectedChoice != null - ? MaterialStateProperty.all( + ? WidgetStateProperty.all( BorderSide( color: controller.selectedChoice!.color, style: BorderStyle.solid, @@ -311,7 +311,7 @@ class WordMatchContent extends StatelessWidget { ); }, style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( (AppConfig.primaryColor).withOpacity(0.1), ), ),