mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 08:15:16 +00:00
Allow to create new choices on survey on its creation
This commit is contained in:
@ -29,12 +29,15 @@ class __SurveyDialogState extends State<_SurveyDialog> {
|
||||
TextEditingController _questionController;
|
||||
final _choiceController = TextEditingController();
|
||||
var _choices = Set<String>();
|
||||
var _allowNewChoices = false;
|
||||
|
||||
bool get canConfirm =>
|
||||
_questionController.text.length > 2 && _choices.length > 1;
|
||||
|
||||
NewSurvey get newSurvey =>
|
||||
NewSurvey(question: _questionController.text, answers: _choices);
|
||||
NewSurvey get newSurvey => NewSurvey(
|
||||
question: _questionController.text,
|
||||
answers: _choices,
|
||||
allowNewChoicesCreation: _allowNewChoices);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -42,7 +45,10 @@ class __SurveyDialogState extends State<_SurveyDialog> {
|
||||
_questionController = TextEditingController(
|
||||
text: widget.initialSurvey == null ? "" : widget.initialSurvey.question,
|
||||
);
|
||||
if (widget.initialSurvey != null) _choices = widget.initialSurvey.answers;
|
||||
if (widget.initialSurvey != null) {
|
||||
_choices = widget.initialSurvey.answers;
|
||||
_allowNewChoices = widget.initialSurvey.allowNewChoicesCreation;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@ -105,6 +111,15 @@ class __SurveyDialogState extends State<_SurveyDialog> {
|
||||
: null,
|
||||
)),
|
||||
),
|
||||
|
||||
// Allow users to create new choices
|
||||
ListTile(
|
||||
leading: Switch.adaptive(
|
||||
value: _allowNewChoices,
|
||||
onChanged: (v) => setState(() => _allowNewChoices = v),
|
||||
),
|
||||
title: Text(tr("Allow users to create new choices")),
|
||||
)
|
||||
]),
|
||||
),
|
||||
);
|
||||
|
Reference in New Issue
Block a user