Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions admin/lib/presentation/pages/builder/builder_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ class _BuilderPageState extends State<BuilderPage> {
}

void _onChangePage() {
final questions = _cubit.state.surveyData.questions;
final index = _surveyController.pageController.page;
final question = index == questions.length
? _cubit.state.surveyData.endPage
: index != null && index % 1 == 0
? questions[index.toInt()]
: null;

if (index != null && index % 1 == 0) {
_cubit.select(_cubit.state.surveyData.questions[index.toInt()]);
if (question != null) {
_cubit.select(question);
}
}

Expand Down
4 changes: 4 additions & 0 deletions admin/lib/presentation/widgets/builder_page/editor_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,25 @@ class EditorBar extends StatelessWidget {
switch (questionData.type) {
case QuestionTypes.choice:
return ChoiceCustomizationPanel(
key: UniqueKey(),
onChange: onChange,
editable: questionData as ChoiceQuestionData,
);
case QuestionTypes.input:
return InputCustomizationPanel(
key: UniqueKey(),
onChange: onChange,
editable: questionData as InputQuestionData,
);
case QuestionTypes.info:
return InfoCustomizationPanel(
key: UniqueKey(),
onChange: onChange,
editable: questionData as InfoQuestionData,
);
case QuestionTypes.slider:
return SliderCustomizationPanel(
key: UniqueKey(),
onChange: onChange,
editable: questionData as SliderQuestionData,
);
Expand Down
13 changes: 5 additions & 8 deletions admin/lib/presentation/widgets/builder_page/question_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,15 @@ class _QuestionListState extends State<QuestionList> {
? widget.questions.length - 1
: newIndex;

final itemOld = widget.questions.removeAt(oldIndex);

widget.questions.insert(
updatedIndex,
itemOld,
);
final questions = List.of(widget.questions);
final itemOld = questions.removeAt(oldIndex);
questions.insert(updatedIndex, itemOld);

for (var i = 0; i < widget.questions.length; i++) {
widget.questions[i] = widget.questions[i].copyWith(index: i + 1);
questions[i] = questions[i].copyWith(index: i + 1);
}

widget.onUpdate(widget.questions);
widget.onUpdate(questions);
}

@override
Expand Down