Skip to content

Commit

Permalink
WTA #40: Extracted streak stats to separate function and fixed build …
Browse files Browse the repository at this point in the history
…issues.
  • Loading branch information
Jacob3075 committed Nov 7, 2022
1 parent 3aeccdf commit 1f7fe8d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.jacob.wakatimeapp.home.ui.components

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.IntrinsicSize.Min
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
Expand Down Expand Up @@ -46,8 +46,29 @@ fun OtherDailyStatsSection(
SectionHeader()
Spacer(modifier = Modifier.height(spacing.extraSmall))

StreakStats(currentStreak, longestStreak)

Spacer(modifier = Modifier.height(spacing.sMedium))

SecondaryStats(
mostUsedLanguage = mostUsedLanguage,
onClick = onClick,
spacing = spacing,
mostUsedOs = mostUsedOs,
mostUsedEditor = mostUsedEditor
)
}

@Composable
private fun StreakStats(
currentStreak: StreakRange,
longestStreak: StreakRange,
) {
val spacing = MaterialTheme.spacing
val gradients = MaterialTheme.gradients

Row(
modifier = Modifier.height(IntrinsicSize.Min),
modifier = Modifier.height(Min),
horizontalArrangement = Arrangement.spacedBy(spacing.small)
) {
CurrentStreakCard(
Expand All @@ -74,16 +95,6 @@ fun OtherDailyStatsSection(
)
}
}

Spacer(modifier = Modifier.height(spacing.sMedium))

SecondaryStats(
mostUsedLanguage = mostUsedLanguage,
onClick = onClick,
spacing = spacing,
mostUsedOs = mostUsedOs,
mostUsedEditor = mostUsedEditor
)
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private fun CurrentStreakCardPreview() = WakaTimeAppTheme {
start = LocalDate(2022, 1, 1),
end = LocalDate(2022, 1, 11)
),
gradient = MaterialTheme.gradients.greenCyan,
gradient = MaterialTheme.gradients.purpink,
cornerPercentage = 20,
modifier = Modifier.weight(0.5F)
)
Expand All @@ -116,7 +116,7 @@ private fun CurrentStreakCardPreview() = WakaTimeAppTheme {
start = LocalDate(2022, 1, 1),
end = LocalDate(2022, 1, 5)
),
gradient = MaterialTheme.gradients.greenCyan,
gradient = MaterialTheme.gradients.tealLove,
cornerPercentage = 20,
modifier = Modifier.weight(0.5F)
)
Expand Down

0 comments on commit 1f7fe8d

Please sign in to comment.