Skip to content

Commit

Permalink
Fixed drop down style for numeric answer input
Browse files Browse the repository at this point in the history
  • Loading branch information
sp-nazar committed May 26, 2023
1 parent 8711dbb commit 1a2c258
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
### Faiadashu
* Added displaying units in numeric answer input
* Added questionnaire-unitOption extension support to make ability choose quantity units in numeric answers
* Fixed drop down style for numeric answer input

## 0.9.0-alpha.1
**[Breaking]** This alpha release is beginning to use Flutter 3.10.0 and fhir 0.11.0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class _NumberFieldInputControl

final theme = QuestionnaireTheme.of(context);

final displayUnits = answerModel.qi.computableUnit?.display;
final displayUnits = answerModel.qi.computableUnit;

return Container(
padding: const EdgeInsets.only(top: 8, bottom: 8),
Expand Down Expand Up @@ -212,17 +212,26 @@ class _NumberFieldInputControl
: null,
)
: null,
suffixIcon: (answerModel.hasUnitChoices)
suffixIcon: (answerModel.hasUnitChoices &&
!answerModel.hasSingleUnitChoice)
? SizedBox(
height: 16,
child: _UnitDropDown(
answerModel,
),
)
: null,
suffix: displayUnits != null
? Text(' $displayUnits')
: null,
suffix: answerModel.hasSingleUnitChoice
? Text(
' ${answerModel.unitChoices.first.localizedDisplay(locale)}',
style: Theme.of(context).textTheme.bodyMedium,
)
: displayUnits != null
? Text(
' ${displayUnits.localizedDisplay(locale)}',
style: Theme.of(context).textTheme.bodyMedium,
)
: null,
),
inputFormatters: [numberInputFormatter],
keyboardType: TextInputType.numberWithOptions(
Expand Down Expand Up @@ -256,21 +265,17 @@ class _UnitDropDown extends AnswerInputControl<NumericalAnswerModel> {

@override
Widget build(BuildContext context) {
const unitWidth = 96.0;

return answerModel.hasSingleUnitChoice
? Container(
alignment: Alignment.topLeft,
padding: const EdgeInsets.only(left: 8, top: 10),
width: unitWidth,
child: Text(
answerModel.unitChoices.first.localizedDisplay(locale),
style: Theme.of(context).textTheme.bodyMedium,
),
)
: Container(
padding: const EdgeInsets.only(left: 8),
width: unitWidth,
padding: const EdgeInsets.symmetric(horizontal: 8),
child: DropdownButtonHideUnderline(
child: DropdownButton<String>(
value: answerModel.keyOfUnit,
Expand Down

0 comments on commit 1a2c258

Please sign in to comment.