Skip to content

Commit

Permalink
Refactor custom themed colors
Browse files Browse the repository at this point in the history
No clue what the hell i was smoking when i wrote this
  • Loading branch information
wingio committed Sep 17, 2024
1 parent 452c67e commit 735178c
Show file tree
Hide file tree
Showing 21 changed files with 121 additions and 377 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.materiiapps.gloom.ui.theme

import androidx.compose.material3.ColorScheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import com.materiiapps.gloom.util.supportsMonet

@Composable
actual fun getColorSchemes(darkTheme: Boolean, dynamicColor: Boolean): Pair<ColorScheme, GloomColorScheme> {
// We don't technically need to check for dynamic theming support
// here because its locked behind a setting that itself is SDK restricted
// but its good to be cautious anyways.
return when {
dynamicColor && darkTheme && supportsMonet -> dynamicDarkColorScheme(LocalContext.current) to darkGloomColorScheme()
dynamicColor && !darkTheme && supportsMonet -> dynamicLightColorScheme(LocalContext.current) to lightGloomColorScheme()
darkTheme -> darkColorScheme() to darkGloomColorScheme()
else -> lightColorScheme() to lightGloomColorScheme()
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.materiiapps.gloom.ui.theme.colors

/**
* A full-width banner that displays text
Expand All @@ -32,9 +31,9 @@ fun TextBanner(
text: @Composable () -> Unit,
modifier: Modifier = Modifier,
icon: (@Composable () -> Unit)? = null,
backgroundColor: Color = MaterialTheme.colors.secondaryContainer,
contentColor: Color = MaterialTheme.colors.onSecondaryContainer,
outlineColor: Color = MaterialTheme.colors.secondary
backgroundColor: Color = MaterialTheme.colorScheme.secondaryContainer,
contentColor: Color = MaterialTheme.colorScheme.onSecondaryContainer,
outlineColor: Color = MaterialTheme.colorScheme.secondary
) {
Row(
horizontalArrangement = Arrangement.spacedBy(ButtonDefaults.IconSpacing, Alignment.CenterHorizontally),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.materiiapps.gloom.ui.theme.colors
import com.materiiapps.gloom.ui.util.toDp
import com.materiiapps.gloom.ui.util.toPx
import kotlinx.coroutines.delay
Expand All @@ -40,7 +39,7 @@ fun ScrollBar(
orientation: Orientation = Orientation.Vertical,
thickness: Dp = 6.dp,
safeAreaPadding: Dp = 6.dp,
thumbColor: Color = MaterialTheme.colors.tertiary,
thumbColor: Color = MaterialTheme.colorScheme.tertiary,
trackColor: Color = Color.Transparent,
idleOpacity: Float = 0.07f,
activeOpacity: Float = 0.65f,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import com.materiiapps.gloom.api.dto.user.User
import com.materiiapps.gloom.domain.manager.TrendingPeriodPreference
import com.materiiapps.gloom.gql.fragment.TrendingRepository
import com.materiiapps.gloom.ui.component.Avatar
import com.materiiapps.gloom.ui.theme.colors
import com.materiiapps.gloom.ui.theme.gloomColorScheme
import com.materiiapps.gloom.ui.util.NumberFormatter
import com.materiiapps.gloom.ui.util.parsedColor
import com.seiko.imageloader.rememberImagePainter
Expand Down Expand Up @@ -110,8 +110,8 @@ fun TrendingRepoItem(
if (shouldStar) onStarClick() else onUnstarClick()
},
colors = IconButtonDefaults.filledTonalIconToggleButtonColors(
checkedContentColor = MaterialTheme.colors.statusYellow,
checkedContainerColor = MaterialTheme.colors.statusYellow.copy(alpha = 0.2f)
checkedContentColor = MaterialTheme.gloomColorScheme.statusYellow,
checkedContainerColor = MaterialTheme.gloomColorScheme.statusYellow.copy(alpha = 0.2f)
),
enabled = starToggleEnabled
) {
Expand All @@ -132,7 +132,7 @@ fun TrendingRepoItem(

LabeledIcon(
icon = Icons.Filled.Star,
iconTint = MaterialTheme.colors.statusYellow,
iconTint = MaterialTheme.gloomColorScheme.statusYellow,
label = stringResource(
when (trendingPeriod) {
TrendingPeriodPreference.MONTHLY -> Res.strings.label_stars_month
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.materiiapps.gloom.ui.screen.release

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.basicMarquee
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
Expand Down Expand Up @@ -45,7 +43,7 @@ import com.materiiapps.gloom.domain.manager.ShareManager
import com.materiiapps.gloom.gql.fragment.ReleaseDetails
import com.materiiapps.gloom.ui.component.BackButton
import com.materiiapps.gloom.ui.component.ThinDivider
import com.materiiapps.gloom.ui.theme.colors
import com.materiiapps.gloom.ui.theme.gloomColorScheme
import com.materiiapps.gloom.ui.screen.release.viewmodel.ReleaseViewModel
import com.materiiapps.gloom.ui.widget.Markdown
import com.materiiapps.gloom.ui.widget.alert.LocalAlertController
Expand Down Expand Up @@ -174,7 +172,7 @@ class ReleaseScreen(
Text(
text = stringResource(Res.strings.title_contributors),
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colors.primary,
color = MaterialTheme.colorScheme.primary,
modifier = Modifier.padding(horizontal = 16.dp)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import com.materiiapps.gloom.gql.fragment.ReleaseDetails
import com.materiiapps.gloom.ui.component.Avatar
import com.materiiapps.gloom.ui.component.Label
import com.materiiapps.gloom.ui.screen.repo.RepoScreen
import com.materiiapps.gloom.ui.theme.colors
import com.materiiapps.gloom.ui.theme.gloomColorScheme
import com.materiiapps.gloom.util.ifNullOrBlank
import dev.icerock.moko.resources.compose.stringResource

Expand Down Expand Up @@ -80,14 +80,14 @@ fun ReleaseHeader(
if (details.isLatest) {
Label(
text = stringResource(Res.strings.label_latest),
textColor = MaterialTheme.colors.statusGreen
textColor = MaterialTheme.gloomColorScheme.statusGreen
)
}

if (details.isPrerelease) {
Label(
text = stringResource(Res.strings.label_prerelease),
textColor = MaterialTheme.colors.statusYellow
textColor = MaterialTheme.gloomColorScheme.statusYellow
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.materiiapps.gloom.ui.screen.repo

import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.basicMarquee
import androidx.compose.foundation.clickable
Expand Down Expand Up @@ -34,7 +33,6 @@ import androidx.compose.material3.Tab
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.TopAppBarScrollBehavior
import androidx.compose.material3.surfaceColorAtElevation
import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -62,7 +60,7 @@ import com.materiiapps.gloom.ui.component.BackButton
import com.materiiapps.gloom.ui.component.Collapsable
import com.materiiapps.gloom.ui.component.TextBanner
import com.materiiapps.gloom.ui.screen.profile.ProfileScreen
import com.materiiapps.gloom.ui.theme.colors
import com.materiiapps.gloom.ui.theme.gloomColorScheme
import com.materiiapps.gloom.ui.util.navigate
import com.materiiapps.gloom.ui.screen.repo.viewmodel.RepoViewModel
import dev.icerock.moko.resources.compose.stringResource
Expand Down Expand Up @@ -136,9 +134,9 @@ class RepoScreen(
modifier = Modifier.size(18.dp)
)
},
backgroundColor = MaterialTheme.colors.warningContainer,
contentColor = MaterialTheme.colors.onWarningContainer,
outlineColor = MaterialTheme.colors.warning
backgroundColor = MaterialTheme.gloomColorScheme.warningContainer,
contentColor = MaterialTheme.gloomColorScheme.onWarningContainer,
outlineColor = MaterialTheme.gloomColorScheme.warning
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ import androidx.compose.runtime.Composable
import com.materiiapps.gloom.Res
import com.materiiapps.gloom.gql.fragment.IssueOverview
import com.materiiapps.gloom.gql.type.IssueStateReason
import com.materiiapps.gloom.ui.theme.colors
import com.materiiapps.gloom.ui.theme.gloomColorScheme
import dev.icerock.moko.resources.compose.stringResource

@Composable
fun IssueItem(issue: IssueOverview) {
val (icon, color, titleCDRes) = when (issue.stateReason) {
IssueStateReason.COMPLETED -> Triple(
Icons.Outlined.CheckCircle,
MaterialTheme.colors.statusPurple,
MaterialTheme.gloomColorScheme.statusPurple,
Res.strings.cd_issue_title_completed
)

IssueStateReason.NOT_PLANNED -> Triple(
Icons.Outlined.DoNotDisturb,
MaterialTheme.colors.statusGrey,
MaterialTheme.gloomColorScheme.statusGrey,
Res.strings.cd_issue_title_not_planned
)

else -> Triple(
Icons.Outlined.ModeStandby,
MaterialTheme.colors.statusGreen,
MaterialTheme.gloomColorScheme.statusGreen,
Res.strings.cd_issue_title_opened
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import com.materiiapps.gloom.Res
import com.materiiapps.gloom.gql.type.PullRequestReviewDecision
import com.materiiapps.gloom.gql.type.StatusState
import com.materiiapps.gloom.ui.component.Label
import com.materiiapps.gloom.ui.theme.colors
import com.materiiapps.gloom.ui.theme.gloomColorScheme
import com.materiiapps.gloom.ui.util.TimeUtils.getTimeSince
import com.materiiapps.gloom.ui.util.parsedColor
import com.seiko.imageloader.rememberImagePainter
Expand Down Expand Up @@ -173,25 +173,25 @@ fun IssueOrPRItem(
val (statusIcon, statusColor, statusLabelRes) = when (checksStatus) {
StatusState.EXPECTED -> Triple(
Icons.Outlined.Circle,
MaterialTheme.colors.surfaceTint,
MaterialTheme.colorScheme.surfaceTint,
Res.strings.label_checks
)

StatusState.PENDING -> Triple(
Icons.Filled.Circle,
MaterialTheme.colors.statusYellow,
MaterialTheme.gloomColorScheme.statusYellow,
Res.strings.label_checks
)

StatusState.SUCCESS -> Triple(
Icons.Filled.CheckCircle,
MaterialTheme.colors.statusGreen,
MaterialTheme.gloomColorScheme.statusGreen,
Res.strings.label_checks
)

else -> Triple(
Icons.Filled.Cancel,
MaterialTheme.colors.error,
MaterialTheme.colorScheme.error,
Res.strings.label_checks_failed
)
}
Expand All @@ -208,9 +208,9 @@ fun IssueOrPRItem(

if (reviewDecision != null) {
val (statusIcon, statusColor) = when (reviewDecision) {
PullRequestReviewDecision.CHANGES_REQUESTED -> Icons.Filled.Cancel to MaterialTheme.colors.error
PullRequestReviewDecision.APPROVED -> Icons.Filled.CheckCircle to MaterialTheme.colors.statusGreen
else -> Icons.Filled.Circle to MaterialTheme.colors.surfaceTint
PullRequestReviewDecision.CHANGES_REQUESTED -> Icons.Filled.Cancel to MaterialTheme.colorScheme.error
PullRequestReviewDecision.APPROVED -> Icons.Filled.CheckCircle to MaterialTheme.gloomColorScheme.statusGreen
else -> Icons.Filled.Circle to MaterialTheme.colorScheme.surfaceTint
}

Label(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.materiiapps.gloom.Res
import com.materiiapps.gloom.gql.fragment.RepoLicense
import com.materiiapps.gloom.ui.theme.colors
import com.materiiapps.gloom.ui.theme.gloomColorScheme
import dev.icerock.moko.resources.compose.stringResource

@Composable
Expand Down Expand Up @@ -80,7 +80,7 @@ fun LicenseDetails(
label = stringResource(Res.strings.label_permissions),
conditions = license.permissions.mapNotNull { it?.label },
icon = Icons.Outlined.Check,
iconColor = MaterialTheme.colors.statusGreen
iconColor = MaterialTheme.gloomColorScheme.statusGreen
)
}

Expand All @@ -89,7 +89,7 @@ fun LicenseDetails(
label = stringResource(Res.strings.label_limitations),
conditions = license.limitations.mapNotNull { it?.label },
icon = Icons.Outlined.Close,
iconColor = MaterialTheme.colors.statusRed
iconColor = MaterialTheme.gloomColorScheme.statusRed
)
}

Expand All @@ -98,7 +98,7 @@ fun LicenseDetails(
label = stringResource(Res.strings.label_conditions),
conditions = license.conditions.mapNotNull { it?.label },
icon = Icons.Outlined.Info,
iconColor = MaterialTheme.colors.secondary
iconColor = MaterialTheme.colorScheme.secondary
)
}
}
Expand Down
Loading

0 comments on commit 735178c

Please sign in to comment.