Skip to content

Commit

Permalink
Formatting improvements for the Scale Answer (#122)
Browse files Browse the repository at this point in the history
* Improve view of scale answer with multiline text and spacing plus config of value visibility

* Fix unnecessary reverted text directionality
  • Loading branch information
petcupaula authored Aug 30, 2023
1 parent 5817f14 commit 8867f8c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 15 deletions.
2 changes: 2 additions & 0 deletions lib/src/answer_format/scale_answer_format.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ScaleAnswerFormat implements AnswerFormat {
final double step;
final String maximumValueDescription;
final String minimumValueDescription;
final bool showValue;

const ScaleAnswerFormat({
required this.maximumValue,
Expand All @@ -19,6 +20,7 @@ class ScaleAnswerFormat implements AnswerFormat {
required this.step,
this.maximumValueDescription = '',
this.minimumValueDescription = '',
this.showValue = true,
}) : super();

factory ScaleAnswerFormat.fromJson(Map<String, dynamic> json) =>
Expand Down
2 changes: 2 additions & 0 deletions lib/src/answer_format/scale_answer_format.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 32 additions & 15 deletions lib/src/views/scale_answer_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,30 +66,47 @@ class _ScaleAnswerViewState extends State<ScaleAnswerView> {
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(14.0),
child: Text(
_sliderValue.toInt().toString(),
style: Theme.of(context).textTheme.headlineSmall,
if (_scaleAnswerFormat.showValue)
Padding(
padding: const EdgeInsets.all(14.0),
child: Text(
_sliderValue.toInt().toString(),
style: Theme.of(context).textTheme.headlineSmall,
),
),
),
Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 32.0),
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
_scaleAnswerFormat.minimumValueDescription,
style: TextStyle(
fontSize: 16.0,
Expanded(
child: Text(
_scaleAnswerFormat.minimumValueDescription,
style: TextStyle(
fontSize: 16.0,
),
maxLines: 6,
overflow: TextOverflow.ellipsis,
textDirection: TextDirection.ltr,
textAlign: TextAlign.start,
),
),
Text(
_scaleAnswerFormat.maximumValueDescription,
style: TextStyle(
fontSize: 16.0,
SizedBox(
width: 32.0,
),
Expanded(
child: Text(
_scaleAnswerFormat.maximumValueDescription,
style: TextStyle(
fontSize: 16.0,
),
maxLines: 6,
overflow: TextOverflow.ellipsis,
textDirection: TextDirection.ltr,
textAlign: TextAlign.end,
),
),
],
Expand Down

0 comments on commit 8867f8c

Please sign in to comment.