Skip to content

Commit 8867f8c

Browse files
authored
Formatting improvements for the Scale Answer (#122)
* Improve view of scale answer with multiline text and spacing plus config of value visibility * Fix unnecessary reverted text directionality
1 parent 5817f14 commit 8867f8c

File tree

3 files changed

+36
-15
lines changed

3 files changed

+36
-15
lines changed

lib/src/answer_format/scale_answer_format.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class ScaleAnswerFormat implements AnswerFormat {
1111
final double step;
1212
final String maximumValueDescription;
1313
final String minimumValueDescription;
14+
final bool showValue;
1415

1516
const ScaleAnswerFormat({
1617
required this.maximumValue,
@@ -19,6 +20,7 @@ class ScaleAnswerFormat implements AnswerFormat {
1920
required this.step,
2021
this.maximumValueDescription = '',
2122
this.minimumValueDescription = '',
23+
this.showValue = true,
2224
}) : super();
2325

2426
factory ScaleAnswerFormat.fromJson(Map<String, dynamic> json) =>

lib/src/answer_format/scale_answer_format.g.dart

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/views/scale_answer_view.dart

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,30 +66,47 @@ class _ScaleAnswerViewState extends State<ScaleAnswerView> {
6666
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
6767
crossAxisAlignment: CrossAxisAlignment.center,
6868
children: [
69-
Padding(
70-
padding: const EdgeInsets.all(14.0),
71-
child: Text(
72-
_sliderValue.toInt().toString(),
73-
style: Theme.of(context).textTheme.headlineSmall,
69+
if (_scaleAnswerFormat.showValue)
70+
Padding(
71+
padding: const EdgeInsets.all(14.0),
72+
child: Text(
73+
_sliderValue.toInt().toString(),
74+
style: Theme.of(context).textTheme.headlineSmall,
75+
),
7476
),
75-
),
7677
Column(
7778
children: [
7879
Padding(
79-
padding: const EdgeInsets.symmetric(horizontal: 32.0),
80+
padding: const EdgeInsets.symmetric(horizontal: 16.0),
8081
child: Row(
8182
mainAxisAlignment: MainAxisAlignment.spaceBetween,
83+
crossAxisAlignment: CrossAxisAlignment.center,
8284
children: [
83-
Text(
84-
_scaleAnswerFormat.minimumValueDescription,
85-
style: TextStyle(
86-
fontSize: 16.0,
85+
Expanded(
86+
child: Text(
87+
_scaleAnswerFormat.minimumValueDescription,
88+
style: TextStyle(
89+
fontSize: 16.0,
90+
),
91+
maxLines: 6,
92+
overflow: TextOverflow.ellipsis,
93+
textDirection: TextDirection.ltr,
94+
textAlign: TextAlign.start,
8795
),
8896
),
89-
Text(
90-
_scaleAnswerFormat.maximumValueDescription,
91-
style: TextStyle(
92-
fontSize: 16.0,
97+
SizedBox(
98+
width: 32.0,
99+
),
100+
Expanded(
101+
child: Text(
102+
_scaleAnswerFormat.maximumValueDescription,
103+
style: TextStyle(
104+
fontSize: 16.0,
105+
),
106+
maxLines: 6,
107+
overflow: TextOverflow.ellipsis,
108+
textDirection: TextDirection.ltr,
109+
textAlign: TextAlign.end,
93110
),
94111
),
95112
],

0 commit comments

Comments
 (0)