Skip to content

Commit f13c2dd

Browse files
committed
add getStreaks() to StatisticsPage
1 parent b6b5615 commit f13c2dd

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

lib/pages/statistics_page.dart

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class StatisticsView extends ConsumerWidget {
5757
return Padding(
5858
padding: const EdgeInsets.all(40),
5959
child: Column(
60+
crossAxisAlignment: CrossAxisAlignment.start,
6061
children: [
6162
gapHeight16,
6263
LabelAndValue(
@@ -79,7 +80,19 @@ class StatisticsView extends ConsumerWidget {
7980
'${notifier.countDaysWithCommit(days: 360).intValue} → ${notifier.countDaysWithCommit(days: 360).inPercent}%',
8081
),
8182
gapHeight24,
82-
StreakView('Longest Streak', notifier.longestStreak()),
83+
const Text(
84+
'Streaks',
85+
style: TextStyle(
86+
fontSize: 14,
87+
fontWeight: FontWeight.bold,
88+
),
89+
),
90+
gapHeight8,
91+
for (final streak in notifier.getStreaks())
92+
Padding(
93+
padding: const EdgeInsets.only(bottom: 4),
94+
child: StreakView(streak),
95+
),
8396
],
8497
),
8598
);
@@ -111,23 +124,35 @@ class LabelAndValue extends StatelessWidget {
111124

112125
class StreakView extends StatelessWidget {
113126
const StreakView(
114-
this.label,
115127
this.streak, {
116128
super.key,
117129
});
118-
final String label;
119130
final Streak streak;
120131

121132
@override
122133
Widget build(BuildContext context) {
123134
return Row(
124135
children: [
125136
SizedBox(
126-
width: 200,
127-
child: Text(label),
137+
width: 30,
138+
child: Text(
139+
'${streak.length}',
140+
),
141+
),
142+
Text(
143+
'days, ',
144+
),
145+
SizedBox(
146+
width: 90,
147+
child: Text(
148+
'${streak.startDate.inIsoFormat}',
149+
),
150+
),
151+
Text(
152+
' - ',
128153
),
129154
Text(
130-
'${streak.length} days from ${streak.startDate.inIsoFormat} to ${streak.endDate.inIsoFormat}',
155+
'${streak.endDate.inIsoFormat}',
131156
),
132157
],
133158
);

0 commit comments

Comments
 (0)