Skip to content

Commit

Permalink
fix overflow in practice activity card
Browse files Browse the repository at this point in the history
  • Loading branch information
ggurdin committed Nov 15, 2024
1 parent 0633ee9 commit 9cc612e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class ToolbarContentLoadingIndicator extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SizedBox(
width: AppConfig.toolbarMinWidth,
height: AppConfig.toolbarMinHeight,
width: AppConfig.toolbarMinWidth / 2,
height: AppConfig.toolbarMinHeight / 2,
child: Center(
child: SizedBox(
height: 14,
Expand Down
102 changes: 55 additions & 47 deletions lib/pangea/widgets/practice_activity/multiple_choice_activity.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:developer';

import 'package:collection/collection.dart';
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/pangea/choreographer/widgets/choice_array.dart';
import 'package:fluffychat/pangea/controllers/put_analytics_controller.dart';
import 'package:fluffychat/pangea/enum/activity_type_enum.dart';
Expand Down Expand Up @@ -119,55 +120,62 @@ class MultipleChoiceActivityState extends State<MultipleChoiceActivity> {
Widget build(BuildContext context) {
final PracticeActivityModel practiceActivity = widget.currentActivity;

return Padding(
padding: const EdgeInsets.all(8),
child: Column(
children: [
Text(
practiceActivity.content.question,
style: BotStyle.text(context),
),
const SizedBox(height: 8),
if (practiceActivity.activityType ==
ActivityTypeEnum.wordFocusListening)
WordAudioButton(
text: practiceActivity.content.answer,
ttsController: widget.tts,
eventID: widget.eventID,
return Container(
padding: const EdgeInsets.all(20),
constraints: const BoxConstraints(
maxHeight: AppConfig.toolbarMaxHeight,
minWidth: AppConfig.toolbarMinWidth,
minHeight: AppConfig.toolbarMinHeight,
),
child: SingleChildScrollView(
child: Column(
children: [
Text(
practiceActivity.content.question,
style: BotStyle.text(context),
),
if (practiceActivity.activityType ==
ActivityTypeEnum.hiddenWordListening)
MessageAudioCard(
messageEvent:
widget.practiceCardController.widget.pangeaMessageEvent,
overlayController:
widget.practiceCardController.widget.overlayController,
tts: widget.practiceCardController.widget.overlayController.tts,
setIsPlayingAudio: widget.practiceCardController.widget
.overlayController.setIsPlayingAudio,
onError: widget.onError,
const SizedBox(height: 8),
if (practiceActivity.activityType ==
ActivityTypeEnum.wordFocusListening)
WordAudioButton(
text: practiceActivity.content.answer,
ttsController: widget.tts,
eventID: widget.eventID,
),
if (practiceActivity.activityType ==
ActivityTypeEnum.hiddenWordListening)
MessageAudioCard(
messageEvent:
widget.practiceCardController.widget.pangeaMessageEvent,
overlayController:
widget.practiceCardController.widget.overlayController,
tts: widget.practiceCardController.widget.overlayController.tts,
setIsPlayingAudio: widget.practiceCardController.widget
.overlayController.setIsPlayingAudio,
onError: widget.onError,
),
ChoicesArray(
isLoading: false,
uniqueKeyForLayerLink: (index) => "multiple_choice_$index",
originalSpan: "placeholder",
onPressed: updateChoice,
selectedChoiceIndex: selectedChoiceIndex,
choices: practiceActivity.content.choices
.mapIndexed(
(index, value) => Choice(
text: value,
color: currentRecordModel?.hasTextResponse(value) ?? false
? practiceActivity.content.choiceColor(index)
: null,
isGold: practiceActivity.content.isCorrect(value, index),
),
)
.toList(),
isActive: true,
id: currentRecordModel?.hashCode.toString(),
),
ChoicesArray(
isLoading: false,
uniqueKeyForLayerLink: (index) => "multiple_choice_$index",
originalSpan: "placeholder",
onPressed: updateChoice,
selectedChoiceIndex: selectedChoiceIndex,
choices: practiceActivity.content.choices
.mapIndexed(
(index, value) => Choice(
text: value,
color: currentRecordModel?.hasTextResponse(value) ?? false
? practiceActivity.content.choiceColor(index)
: null,
isGold: practiceActivity.content.isCorrect(value, index),
),
)
.toList(),
isActive: true,
id: currentRecordModel?.hashCode.toString(),
),
],
],
),
),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,7 @@ class PracticeActivityCardState extends State<PracticeActivityCard> {
origin: AnalyticsUpdateOrigin.practiceActivity,
),
),
if (activityWidget != null)
Padding(
padding: const EdgeInsets.fromLTRB(16, 20, 16, 16),
child: activityWidget,
),
if (activityWidget != null) activityWidget!,
// Conditionally show the darkening and progress indicator based on the loading state
if (!savoringTheJoy && fetchingActivity) ...[
// Circular progress indicator in the center
Expand Down

0 comments on commit 9cc612e

Please sign in to comment.