diff --git a/CHANGELOG.md b/CHANGELOG.md index bcd18d6f..e27cd0cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/lib/questionnaires/view/item/answer/src/numerical_answer_filler.dart b/lib/questionnaires/view/item/answer/src/numerical_answer_filler.dart index 6d2312c3..6bc5bca7 100644 --- a/lib/questionnaires/view/item/answer/src/numerical_answer_filler.dart +++ b/lib/questionnaires/view/item/answer/src/numerical_answer_filler.dart @@ -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), @@ -212,7 +212,8 @@ class _NumberFieldInputControl : null, ) : null, - suffixIcon: (answerModel.hasUnitChoices) + suffixIcon: (answerModel.hasUnitChoices && + !answerModel.hasSingleUnitChoice) ? SizedBox( height: 16, child: _UnitDropDown( @@ -220,9 +221,17 @@ class _NumberFieldInputControl ), ) : 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( @@ -256,21 +265,17 @@ class _UnitDropDown extends AnswerInputControl { @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( value: answerModel.keyOfUnit,