From 9f485ccb0549f1770f893716e5d024fce845c3da Mon Sep 17 00:00:00 2001 From: ggurdin Date: Tue, 22 Oct 2024 16:42:05 -0400 Subject: [PATCH] dynamic sizing for practice activity toolbar content --- .../multiple_choice_activity.dart | 2 +- .../no_more_practice_card.dart | 22 ++---- .../practice_activity_card.dart | 76 ++++++++----------- 3 files changed, 41 insertions(+), 59 deletions(-) diff --git a/lib/pangea/widgets/practice_activity/multiple_choice_activity.dart b/lib/pangea/widgets/practice_activity/multiple_choice_activity.dart index 5a1f50497..f0ad5b80a 100644 --- a/lib/pangea/widgets/practice_activity/multiple_choice_activity.dart +++ b/lib/pangea/widgets/practice_activity/multiple_choice_activity.dart @@ -94,7 +94,7 @@ class MultipleChoiceActivityState extends State { Widget build(BuildContext context) { final PracticeActivityModel practiceActivity = widget.currentActivity; - return Container( + return Padding( padding: const EdgeInsets.all(8), child: Column( children: [ diff --git a/lib/pangea/widgets/practice_activity/no_more_practice_card.dart b/lib/pangea/widgets/practice_activity/no_more_practice_card.dart index 1cef6c174..d4844ac21 100644 --- a/lib/pangea/widgets/practice_activity/no_more_practice_card.dart +++ b/lib/pangea/widgets/practice_activity/no_more_practice_card.dart @@ -71,24 +71,16 @@ class GamifiedTextWidget extends StatelessWidget { @override Widget build(BuildContext context) { - return Center( + return Padding( + padding: const EdgeInsets.all(8), child: Column( - mainAxisSize: MainAxisSize.min, // Adjusts the size to fit children children: [ - const SizedBox(height: 10), // Spacing between the star and text - // Star animation above the text const StarAnimationWidget(), - const SizedBox(height: 10), // Spacing between the star and text - Container( - constraints: const BoxConstraints( - minHeight: 80, - ), - padding: const EdgeInsets.all(8), - child: Text( - userMessage, - style: BotStyle.text(context), - textAlign: TextAlign.center, // Center-align the text - ), + const SizedBox(height: 10), + Text( + userMessage, + style: BotStyle.text(context), + textAlign: TextAlign.center, ), ], ), diff --git a/lib/pangea/widgets/practice_activity/practice_activity_card.dart b/lib/pangea/widgets/practice_activity/practice_activity_card.dart index 82d3c0a17..113c7573e 100644 --- a/lib/pangea/widgets/practice_activity/practice_activity_card.dart +++ b/lib/pangea/widgets/practice_activity/practice_activity_card.dart @@ -306,54 +306,44 @@ class MessagePracticeActivityCardState extends State { } } - String? get userMessage { - if (!fetchingActivity && currentActivity == null) { - return L10n.of(context)!.noActivitiesFound; - } - return null; - } - @override Widget build(BuildContext context) { - if (userMessage != null) { - return GamifiedTextWidget(userMessage: userMessage!); + if (!fetchingActivity && currentActivity == null) { + return GamifiedTextWidget( + userMessage: L10n.of(context)!.noActivitiesFound, + ); } - return Row( - mainAxisSize: MainAxisSize.min, + return Stack( + alignment: Alignment.center, children: [ - Stack( - alignment: Alignment.center, - children: [ - // Main content - const Positioned( - child: PointsGainedAnimation(), - ), - Container( - padding: const EdgeInsets.all(8), - child: activityWidget, - ), - // Conditionally show the darkening and progress indicator based on the loading state - if (!savoringTheJoy && fetchingActivity) ...[ - // Semi-transparent overlay - Container( - color: Colors.black.withOpacity(0.5), // Darkening effect - ), - // Circular progress indicator in the center - const Center( - child: CircularProgressIndicator(), - ), - ], - // Flag button in the top right corner - Positioned( - top: 0, - right: 0, - child: ContentIssueButton( - isActive: currentActivity != null, - submitFeedback: submitFeedback, - ), - ), - ], + // Main content + const Positioned( + child: PointsGainedAnimation(), + ), + Padding( + padding: const EdgeInsets.fromLTRB(8, 20, 8, 8), + child: activityWidget, + ), + // Conditionally show the darkening and progress indicator based on the loading state + if (!savoringTheJoy && fetchingActivity) ...[ + // Semi-transparent overlay + Container( + color: Colors.black.withOpacity(0.5), // Darkening effect + ), + // Circular progress indicator in the center + const Center( + child: CircularProgressIndicator(), + ), + ], + // Flag button in the top right corner + Positioned( + top: 0, + right: 0, + child: ContentIssueButton( + isActive: currentActivity != null, + submitFeedback: submitFeedback, + ), ), ], );