Skip to content

Commit

Permalink
Add more verbose small stat labels
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsRefsgaard committed Jul 24, 2023
1 parent 393e59f commit 7afb4d8
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 35 deletions.
2 changes: 2 additions & 0 deletions assets/lang/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
"pages.data_viz.thanks": "Tak for din deltagelse i dette studie. Her er et resumé af dit bidrag.",
"pages.data_viz.no_data": "Ingen data at vise",
"cards.scoreboard.days": "Antal dage i studiet",
"cards.scoreboard.days-short": "Dage",
"cards.scoreboard.tasks": "Antal opgaver udført",
"cards.scoreboard.tasks-short": "Opgaver",
"cards.measures.title": "MÅLINGER",
"cards.survey.title": "SPØRGESKEMAER",
"cards.audio.title": "LYDOPTAGELSER",
Expand Down
2 changes: 2 additions & 0 deletions assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"pages.data_viz.no_data": "No data to show",
"cards.no_data": "No data",
"cards.scoreboard.days": "Days in study",
"cards.scoreboard.days-short": "Days",
"cards.scoreboard.tasks": "Tasks completed",
"cards.scoreboard.tasks-short": "Tasks",
"cards.measures.title": "MEASURES",
"cards.survey.title": "SURVEYS",
"cards.audio.title": "AUDIOS",
Expand Down
97 changes: 62 additions & 35 deletions lib/ui/cards/scoreboard_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,48 @@ class ScoreboardPersistentHeaderDelegate
BuildContext context, double shrinkOffset, bool overlapsContent) {
double height = 110;

double offsetForShrink = 60;

List<Widget> childrenTasks = [
Text(model.taskCompleted.toString(),
style: scoreNumberStyle.copyWith(
fontSize: calculateSize(shrinkOffset,
scoreNumberStyleSmall.fontSize!, scoreNumberStyle.fontSize!),
color: Theme.of(context).primaryColor)),
if (shrinkOffset < offsetForShrink)
Text(locale.translate('cards.scoreboard.tasks'),
style:
scoreTextStyle.copyWith(color: Theme.of(context).primaryColor)),
if (shrinkOffset > offsetForShrink)
Expanded(
flex: 0,
child: Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text(locale.translate('cards.scoreboard.tasks-short'),
style: scoreTextStyle.copyWith(
color: Theme.of(context).primaryColor)),
),
)
];
List<Widget> childrenDays = [
Text(model.daysInStudy.toString(),
style: scoreNumberStyle.copyWith(
fontSize: calculateSize(shrinkOffset,
scoreNumberStyleSmall.fontSize!, scoreNumberStyle.fontSize!),
color: Theme.of(context).primaryColor)),
if (shrinkOffset < offsetForShrink)
Text(locale.translate('cards.scoreboard.days'),
style:
scoreTextStyle.copyWith(color: Theme.of(context).primaryColor)),
if (shrinkOffset > offsetForShrink)
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text(locale.translate('cards.scoreboard.days-short'),
style:
scoreTextStyle.copyWith(color: Theme.of(context).primaryColor)),
)
];

return Container(
color: Theme.of(context).colorScheme.secondary,
height: height,
Expand All @@ -62,24 +104,17 @@ class ScoreboardPersistentHeaderDelegate
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(model.daysInStudy.toString(),
style: scoreNumberStyle.copyWith(
fontSize: calculateSize(
shrinkOffset,
scoreNumberStyleSmall.fontSize!,
scoreNumberStyle.fontSize!),
color: Theme.of(context).primaryColor)),
if (shrinkOffset < 60)
Text(locale.translate('cards.scoreboard.days'),
style: scoreTextStyle.copyWith(
color: Theme.of(context).primaryColor)),
],
),
child: shrinkOffset < offsetForShrink
? Column(
mainAxisAlignment: MainAxisAlignment.center,
children: childrenDays,
)
: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: childrenDays,
),
),
// a vertical divider line with rounded corners that spans from 10% to 90% of the height
// A vertical divider line with rounded corners that spans from 10% to 90% of the height
Expanded(
flex: 0,
child: Container(
Expand All @@ -93,23 +128,15 @@ class ScoreboardPersistentHeaderDelegate
),
),
Expanded(
flex: 1,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(model.taskCompleted.toString(),
style: scoreNumberStyle.copyWith(
fontSize: calculateSize(
shrinkOffset,
scoreNumberStyleSmall.fontSize!,
scoreNumberStyle.fontSize!),
color: Theme.of(context).primaryColor)),
if (shrinkOffset < 60)
Text(locale.translate('cards.scoreboard.tasks'),
style: scoreTextStyle.copyWith(
color: Theme.of(context).primaryColor)),
],
),
child: shrinkOffset < offsetForShrink
? Column(
mainAxisAlignment: MainAxisAlignment.center,
children: childrenTasks,
)
: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: childrenTasks,
),
)
],
);
Expand All @@ -132,7 +159,7 @@ class ScoreboardPersistentHeaderDelegate

@override
bool shouldRebuild(ScoreboardPersistentHeaderDelegate oldDelegate) {
return false;
return true;
}

@override
Expand Down

0 comments on commit 7afb4d8

Please sign in to comment.