Skip to content

Commit

Permalink
1594-activity-planner-feedback-new (#1599)
Browse files Browse the repository at this point in the history
* feat(activity_planner): updating for feedback

* fix(main): point to appropriate env

---------

Co-authored-by: ggurdin <ggurdin@gmail.com>
  • Loading branch information
wcjord and ggurdin authored Jan 27, 2025
1 parent e2b991b commit 8478f48
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 49 deletions.
9 changes: 8 additions & 1 deletion assets/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -4757,7 +4757,7 @@
"modePlaceholder": "Choose a mode...",
"learningObjectiveLabel": "Learning Objective",
"learningObjectivePlaceholder": "Choose a learning objective...",
"mediaLabel": "Media students should share",
"mediaLabel": "Media learners should share",
"languageOfInstructionsLabel": "Language of activity instructions",
"targetLanguageLabel": "Target language",
"cefrLevelLabel": "CEFR Level",
Expand All @@ -4770,6 +4770,13 @@
"activityPlannerOverviewInstructionsBody": "Choose a topic, mode, learning objective and generate an activity for the chat!",
"completeActivitiesToUnlock": "Complete the highlighted word activities to unlock",
"myBookmarkedActivities": "My Bookmarked Activities",
"noBookmarkedActivities": "When you bookmark activities, they will appear here. Bookmarked activities can be re-used across spaces and chats.",
"activityTitle": "Activity Title",
"addVocabulary": "Add Vocabulary",
"instructions": "Instructions",
"bookmark": "Bookmark this activity",
"numberOfLearners": "Number of learners",
"mustBeInteger": "Must be an integer e.g. 1, 2, 3, ...",
"noBookmarkedActivities": "No bookmarked activities",
"noLemmasFound": "No lemmas found"
}
10 changes: 9 additions & 1 deletion lib/pangea/activity_planner/activity_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,15 @@ class ActivityListViewState extends State<ActivityListView> {
);
} else if (!snapshot.hasData || snapshot.data!.isEmpty) {
if (showBookmarkedActivities) {
return Center(child: Text(l10n.noBookmarkedActivities));
return Center(
child: Container(
constraints: const BoxConstraints(maxWidth: 200),
child: Text(
l10n.noBookmarkedActivities,
textAlign: TextAlign.center,
),
),
);
}
return Center(child: Text(l10n.noDataFound));
} else {
Expand Down
93 changes: 54 additions & 39 deletions lib/pangea/activity_planner/activity_plan_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ActivityPlanCardState extends State<ActivityPlanCard> {
late TextEditingController _learningObjectiveController;
late TextEditingController _instructionsController;
final TextEditingController _newVocabController = TextEditingController();
final FocusNode _vocabFocusNode = FocusNode();

@override
void initState() {
Expand All @@ -47,14 +48,15 @@ class ActivityPlanCardState extends State<ActivityPlanCard> {
TextEditingController(text: _tempActivity.instructions);
}

static const double itemPadding = 8;
static const double itemPadding = 12;

@override
void dispose() {
_titleController.dispose();
_learningObjectiveController.dispose();
_instructionsController.dispose();
_newVocabController.dispose();
_vocabFocusNode.dispose();
super.dispose();
}

Expand Down Expand Up @@ -99,6 +101,7 @@ class ActivityPlanCardState extends State<ActivityPlanCard> {
setState(() {
_tempActivity.vocab.add(Vocab(lemma: _newVocabController.text, pos: ''));
_newVocabController.clear();
_vocabFocusNode.requestFocus();
});
}

Expand Down Expand Up @@ -134,7 +137,7 @@ class ActivityPlanCardState extends State<ActivityPlanCard> {
? TextField(
controller: _titleController,
decoration: InputDecoration(
labelText: L10n.of(context).title,
labelText: L10n.of(context).activityTitle,
),
maxLines: null,
)
Expand Down Expand Up @@ -166,8 +169,8 @@ class ActivityPlanCardState extends State<ActivityPlanCard> {
child: _isEditing
? TextField(
controller: _learningObjectiveController,
decoration: const InputDecoration(
labelText: 'Learning Objective',
decoration: InputDecoration(
labelText: l10n.learningObjectiveLabel,
),
maxLines: null,
)
Expand All @@ -190,8 +193,8 @@ class ActivityPlanCardState extends State<ActivityPlanCard> {
child: _isEditing
? TextField(
controller: _instructionsController,
decoration: const InputDecoration(
labelText: 'Instructions',
decoration: InputDecoration(
labelText: l10n.instructions,
),
maxLines: null,
)
Expand Down Expand Up @@ -244,50 +247,62 @@ class ActivityPlanCardState extends State<ActivityPlanCard> {
),
],
),
if (_isEditing)
Padding(
padding: const EdgeInsets.only(top: itemPadding),
child: Row(
children: [
Expanded(
child: TextField(
controller: _newVocabController,
decoration: const InputDecoration(
labelText: 'Add Vocabulary',
),
],
if (_isEditing) ...[
const SizedBox(height: itemPadding),
Padding(
padding: const EdgeInsets.only(top: itemPadding),
child: Row(
children: [
Expanded(
child: TextField(
controller: _newVocabController,
focusNode: _vocabFocusNode,
decoration: InputDecoration(
labelText: l10n.addVocabulary,
),
onSubmitted: (value) {
_addVocab();
},
),
IconButton(
icon: const Icon(Icons.add),
onPressed: _addVocab,
),
],
),
),
IconButton(
icon: const Icon(Icons.add),
onPressed: _addVocab,
),
],
),
),
],
const SizedBox(height: 16),
const SizedBox(height: itemPadding),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
IconButton(
icon: Icon(!_isEditing ? Icons.edit : Icons.save),
onPressed: () => !_isEditing
? setState(() {
_isEditing = true;
})
: _saveEdits(),
isSelected: _isEditing,
Tooltip(
message: !_isEditing ? l10n.edit : l10n.saveChanges,
child: IconButton(
icon: Icon(!_isEditing ? Icons.edit : Icons.save),
onPressed: () => !_isEditing
? setState(() {
_isEditing = true;
})
: _saveEdits(),
isSelected: _isEditing,
),
),
if (_isEditing)
IconButton(
icon: const Icon(Icons.cancel),
onPressed: () {
setState(() {
_isEditing = false;
});
},
Tooltip(
message: l10n.cancel,
child: IconButton(
icon: const Icon(Icons.cancel),
onPressed: () {
setState(() {
_isEditing = false;
});
},
),
),
],
),
Expand Down
6 changes: 5 additions & 1 deletion lib/pangea/activity_planner/activity_plan_request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ActivityPlanRequest {
final String languageOfInstructions;
final String targetLanguage;
final int count;
final int numberOfParticipants;

ActivityPlanRequest({
required this.topic,
Expand All @@ -19,6 +20,7 @@ class ActivityPlanRequest {
required this.languageOfInstructions,
required this.targetLanguage,
this.count = 3,
required this.numberOfParticipants,
});

Map<String, dynamic> toJson() {
Expand All @@ -31,6 +33,7 @@ class ActivityPlanRequest {
'language_of_instructions': languageOfInstructions,
'target_language': targetLanguage,
'count': count,
'number_of_participants': numberOfParticipants,
};
}

Expand Down Expand Up @@ -68,11 +71,12 @@ class ActivityPlanRequest {
languageOfInstructions: json['language_of_instructions'],
targetLanguage: json['target_language'],
count: json['count'],
numberOfParticipants: json['number_of_participants'],
);
}

String get storageKey =>
'$topic-$mode-$objective-${media.string}-$cefrLevel-$languageOfInstructions-$targetLanguage';
'$topic-$mode-$objective-${media.string}-$cefrLevel-$languageOfInstructions-$targetLanguage-$numberOfParticipants';

String get cefrLanguageLevel {
switch (cefrLevel) {
Expand Down
58 changes: 52 additions & 6 deletions lib/pangea/activity_planner/activity_planner_page.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:math';

import 'package:flutter/material.dart';

import 'package:dropdown_button2/dropdown_button2.dart';
Expand Down Expand Up @@ -47,6 +49,7 @@ class ActivityPlannerPageState extends State<ActivityPlannerPage> {
String? _selectedLanguageOfInstructions;
String? _selectedTargetLanguage;
int? _selectedCefrLevel;
int? _selectedNumberOfParticipants;

List<String> activities = [];

Expand All @@ -65,6 +68,7 @@ class ActivityPlannerPageState extends State<ActivityPlannerPage> {
_selectedTargetLanguage =
MatrixState.pangeaController.languageController.userL2?.langCode;
_selectedCefrLevel = 0;
_selectedNumberOfParticipants = max(room?.getParticipants().length ?? 1, 1);
}

final _topicController = TextEditingController();
Expand Down Expand Up @@ -149,13 +153,34 @@ class ActivityPlannerPageState extends State<ActivityPlannerPage> {
icon: const Icon(Icons.arrow_back),
),
title: _pageMode == _PageMode.savedActivities
? Text(l10n.myBookmarkedActivities)
: Text(l10n.activityPlannerTitle),
? Center(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.bookmarks),
const SizedBox(width: 8),
Text(l10n.myBookmarkedActivities),
],
),
)
: Center(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.event_note_outlined),
const SizedBox(width: 8),
Text(l10n.activityPlannerTitle),
],
),
),
actions: [
IconButton(
onPressed: () =>
setState(() => _pageMode = _PageMode.savedActivities),
icon: const Icon(Icons.bookmarks),
Tooltip(
message: l10n.myBookmarkedActivities,
child: IconButton(
onPressed: () =>
setState(() => _pageMode = _PageMode.savedActivities),
icon: const Icon(Icons.bookmarks),
),
),
],
),
Expand All @@ -172,6 +197,7 @@ class ActivityPlannerPageState extends State<ActivityPlannerPage> {
languageOfInstructions: _selectedLanguageOfInstructions!,
targetLanguage: _selectedTargetLanguage!,
cefrLevel: _selectedCefrLevel!,
numberOfParticipants: _selectedNumberOfParticipants!,
),
)
: Center(
Expand Down Expand Up @@ -279,6 +305,26 @@ class ActivityPlannerPageState extends State<ActivityPlannerPage> {
isL2List: true,
),
const SizedBox(height: 24),
TextFormField(
decoration: InputDecoration(
labelText: l10n.numberOfLearners,
),
keyboardType: TextInputType.number,
validator: (value) {
if (value == null || value.isEmpty) {
return l10n.mustBeInteger;
}
final n = int.tryParse(value);
if (n == null || n <= 0) {
return l10n.mustBeInteger;
}
return null;
},
onChanged: (val) =>
_selectedNumberOfParticipants = int.tryParse(val),
initialValue: _selectedNumberOfParticipants?.toString(),
),
const SizedBox(height: 24),
ElevatedButton(
onPressed: () {
if (_formKey.currentState?.validate() ?? false) {
Expand Down
3 changes: 3 additions & 0 deletions lib/pangea/activity_planner/suggestion_form_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class SuggestionFormField extends StatelessWidget {
VoidCallback onFieldSubmitted,
) {
textEditingController.value = controller.value;
textEditingController.addListener(() {
onSelected(textEditingController.text);
});
return TextFormField(
controller: textEditingController,
focusNode: focusNode,
Expand Down
5 changes: 4 additions & 1 deletion lib/pangea/toolbar/widgets/overlay_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:matrix/matrix.dart';

import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/pages/chat/chat.dart';
import 'package:fluffychat/pangea/common/constants/model_keys.dart';

class OverlayHeader extends StatelessWidget {
final ChatController controller;
Expand Down Expand Up @@ -53,7 +54,9 @@ class OverlayHeader extends StatelessWidget {
tooltip: L10n.of(context).pinMessage,
color: Theme.of(context).colorScheme.primary,
),
if (controller.canEditSelectedEvents)
if (controller.canEditSelectedEvents &&
controller.selectedEvents.first.content[ModelKey.messageTags] !=
ModelKey.messageTagActivityPlan)
IconButton(
icon: const Icon(Icons.edit_outlined),
tooltip: L10n.of(context).edit,
Expand Down

0 comments on commit 8478f48

Please sign in to comment.