-
Notifications
You must be signed in to change notification settings - Fork 1
Questions fix #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Questions fix #254
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e7269f8
Questions Fix: Fix input
c58cad4
Questions Fix: Add choice initial value
042dfe3
Questions fix: Fix tests
8044929
Question fix: Fix analyze problem
5f4dfc7
Question Fix: Increase coverage check
9fa02a0
Questions fix: Fix pipelines
721006d
Questions fix: Review fix
7b94184
Questions fix: Fix tests
828482a
Questions fix: Fix review
10c8be6
Merge branch 'dev' into feature/questions-fix
05839ab
Merge branch 'dev' into feature/questions-fix
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
147 changes: 147 additions & 0 deletions
147
admin/lib/presentation/widgets/customization_items/default_options_customization_item.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:survey_admin/presentation/app/localization/app_localizations_ext.dart'; | ||
| import 'package:survey_admin/presentation/widgets/customization_items/dropdown_customization_button.dart'; | ||
| import 'package:survey_admin/presentation/widgets/customization_items/option.dart'; | ||
| import 'package:survey_admin/presentation/widgets/customization_items/switch_customization_item.dart'; | ||
| import 'package:survey_sdk/survey_sdk.dart'; | ||
|
|
||
| class DefaultOptionsCustomizationItem extends StatelessWidget { | ||
| final List<String> options; | ||
| final List<String>? defaultOptions; | ||
| final bool isMultipleChoice; | ||
| final ValueChanged<List<String>?> onChanged; | ||
|
|
||
| const DefaultOptionsCustomizationItem({ | ||
| required this.options, | ||
| required this.defaultOptions, | ||
| required this.isMultipleChoice, | ||
| required this.onChanged, | ||
| super.key, | ||
| }); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Column( | ||
| crossAxisAlignment: CrossAxisAlignment.start, | ||
| children: [ | ||
| SwitchCustomizationItem( | ||
| initialValue: defaultOptions != null, | ||
| title: context.localization.defaultOptions, | ||
| onChanged: (isToggled) => onChanged( | ||
| isToggled ? [options.first] : null, | ||
| ), | ||
| ), | ||
| if (defaultOptions != null && options.isNotEmpty) ...[ | ||
| const SizedBox(height: SurveyDimensions.sizeS), | ||
damir-abdulin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (isMultipleChoice) | ||
| _DefaultOptionsForMultipleChoice( | ||
| defaultOptions: defaultOptions!, | ||
| options: options, | ||
| onChanged: onChanged, | ||
| ) | ||
| else | ||
| _DefaultOptionsForSingleChoice( | ||
| defaultOption: defaultOptions!.first, | ||
| options: options, | ||
| onChanged: (selectedOption) => onChanged([selectedOption]), | ||
| ), | ||
| ], | ||
| ], | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class _DefaultOptionsForSingleChoice extends StatelessWidget { | ||
| final String defaultOption; | ||
| final List<String> options; | ||
| final ValueChanged<String> onChanged; | ||
|
|
||
| const _DefaultOptionsForSingleChoice({ | ||
| required this.defaultOption, | ||
| required this.options, | ||
| required this.onChanged, | ||
| }); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return DropdownCustomizationButton<String>( | ||
| value: defaultOption, | ||
| withColor: true, | ||
| items: options | ||
| .map( | ||
damir-abdulin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| (option) => DropdownCustomizationItem( | ||
| value: option, | ||
| onChange: onChanged, | ||
| child: Text( | ||
| option, | ||
| style: context.theme.textTheme.bodyLarge, | ||
| ), | ||
| ), | ||
| ) | ||
| .toList(), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class _DefaultOptionsForMultipleChoice extends StatelessWidget { | ||
| final List<String> defaultOptions; | ||
| final List<String> options; | ||
| final ValueChanged<List<String>?> onChanged; | ||
|
|
||
| const _DefaultOptionsForMultipleChoice({ | ||
| required this.defaultOptions, | ||
| required this.options, | ||
| required this.onChanged, | ||
| }); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Column( | ||
| children: [ | ||
| ...defaultOptions.map( | ||
| (option) => Option( | ||
| option: option, | ||
| onDelete: () { | ||
| final newOptions = | ||
| defaultOptions.where((e) => e != option).toList()..sort(); | ||
|
|
||
| if (newOptions.isNotEmpty) { | ||
| onChanged(newOptions); | ||
| } | ||
| }, | ||
| ), | ||
| ), | ||
| DropdownCustomizationButton<String?>( | ||
| value: null, | ||
| items: [ | ||
| DropdownCustomizationItem( | ||
| value: null, | ||
| child: Text( | ||
| context.localization.clickToSelectTheOption, | ||
| style: const TextStyle( | ||
| color: SurveyColors.textHintGrey, | ||
| ), | ||
| ), | ||
| ), | ||
| ...options.where((option) => !defaultOptions.contains(option)).map( | ||
| (option) => DropdownCustomizationItem( | ||
| value: option, | ||
| onChange: (selectedOption) { | ||
| final newOptions = List.of(defaultOptions) | ||
| ..add(selectedOption!) | ||
| ..sort(); | ||
| onChanged(newOptions); | ||
| }, | ||
| child: Text( | ||
| option, | ||
| style: context.theme.textTheme.bodyLarge, | ||
| ), | ||
| ), | ||
| ), | ||
| ], | ||
| withColor: true, | ||
| ), | ||
| ], | ||
| ); | ||
| } | ||
| } | ||
40 changes: 40 additions & 0 deletions
40
admin/lib/presentation/widgets/customization_items/option.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:survey_sdk/survey_sdk.dart'; | ||
|
|
||
| class Option extends StatelessWidget { | ||
| final String option; | ||
| final VoidCallback onDelete; | ||
|
|
||
| const Option({ | ||
| required this.option, | ||
| required this.onDelete, | ||
| super.key, | ||
| }); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Row( | ||
| children: [ | ||
| const Icon( | ||
damir-abdulin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Icons.fiber_manual_record, | ||
| size: SurveyDimensions.sizeS, | ||
| ), | ||
| const SizedBox(width: SurveyDimensions.margin2XS), | ||
| Expanded( | ||
| child: Text( | ||
| option, | ||
| style: context.theme.textTheme.bodyLarge, | ||
| ), | ||
| ), | ||
| IconButton( | ||
| padding: EdgeInsets.zero, | ||
| icon: const Icon( | ||
| Icons.close, | ||
| size: SurveyDimensions.sizeM, | ||
| ), | ||
| onPressed: onDelete, | ||
| ), | ||
| ], | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.