Skip to content

Commit

Permalink
Merge pull request #61
Browse files Browse the repository at this point in the history
Fixed most detekt lint issues
  • Loading branch information
Jacob3075 authored Dec 11, 2022
2 parents 9ae3f8a + e0f2319 commit 72812bf
Show file tree
Hide file tree
Showing 46 changed files with 215 additions and 264 deletions.
9 changes: 7 additions & 2 deletions app/src/main/java/com/jacob/wakatimeapp/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ import dagger.hilt.android.AndroidEntryPoint
@ExperimentalMaterial3Api
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
/**
* `NavGraphs` not being indexed but works when built
*
* @see [Issue](https://github.com/raamcosta/compose-destinations/issues/314)
*/
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Expand All @@ -37,15 +42,15 @@ class MainActivity : AppCompatActivity() {
val snackbarHostState = remember { SnackbarHostState() }
Scaffold(
snackbarHost = { SnackbarHost(snackbarHostState) },
modifier = Modifier.fillMaxSize()
modifier = Modifier.fillMaxSize(),
) {
LockScreenOrientation()
DestinationsNavHost(
navGraph = NavGraphs.root,
dependenciesContainerBuilder = {
dependency(ApplicationNavigator(navController))
dependency(snackbarHostState)
}
},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ fun HomePage(
scaffoldState: SnackbarHostState,
) = HomePageScreen(
navigator = homePageNavigator,
snackbarHostState = scaffoldState
snackbarHostState = scaffoldState,
)
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ android {
buildFeatures { compose = true }
composeOptions { kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() }

// Compose Destination config
// Compose Destination config (https://github.com/raamcosta/compose-destinations/issues/314)
applicationVariants.all { variant ->
kotlin.sourceSets {
getByName(variant.name) {
Expand Down
5 changes: 2 additions & 3 deletions buildSrc/src/main/kotlin/wakatimeapp.tooling.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ plugins {
}

dependencies {
detektPlugins("ru.kode:detekt-rules-compose:1.2.2") // https://github.com/appKODE/detekt-rules-compose
detektPlugins("com.twitter.compose.rules:detekt:0.0.26") // https://github.com/twitter/compose-rules/
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.22.0") // https://detekt.dev
}
Expand All @@ -15,13 +14,13 @@ detekt {
buildUponDefaultConfig = true
}

tasks.detekt.configure {
tasks.withType(io.gitlab.arturbosch.detekt.Detekt).configureEach {
jvmTarget = "11"
reports {
html.required.set(false)
md.required.set(true)
md.outputLocation.set(file("${rootProject.rootDir}/tools/reports/${project.name}-detekt.md"))
}
jvmTarget = "11"
}

def isNonStable = { String version ->
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AuthDataStore @Inject constructor(

suspend fun updateAuthState(newAuthState: AuthState?) {
dataStore.edit {
it[KEY_AUTH_STATE] = newAuthState?.jsonSerializeString() ?: ""
it[KEY_AUTH_STATE] = newAuthState?.jsonSerializeString().orEmpty()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ fun ProjectDTO.toModel() = Project(
time = Time(
hours = hours,
minutes = minutes,
decimal = decimal.toFloat()
decimal = decimal.toFloat(),
),
name = name,
percent = percent
percent = percent,
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.jacob.wakatimeapp.core.common.di

import android.content.Context
import com.jacob.wakatimeapp.core.common.UserSession
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
Expand All @@ -17,10 +16,7 @@ import net.openid.appauth.AuthorizationService
object CommonModule {
@Singleton
@Provides
fun provideUserSession() = UserSession()

@Singleton
@Provides
@Suppress("InjectDispatcher")
fun provideCoroutineContext(): CoroutineContext = Dispatchers.IO

@Singleton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ object DataModule {

@Singleton
@Provides
@Suppress("InjectDispatcher")
fun providePreferencesDataStore(@ApplicationContext appContext: Context) =
PreferenceDataStoreFactory.create(
scope = CoroutineScope(Dispatchers.IO + SupervisorJob()),
produceFile = { appContext.preferencesDataStoreFile(STORE_NAME) }
produceFile = { appContext.preferencesDataStoreFile(STORE_NAME) },
)

@Singleton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ data class Time(
decimal = decimal,
hours = hours,
minutes = minutes,
totalSeconds = totalSeconds
totalSeconds = totalSeconds,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ import androidx.compose.ui.tooling.preview.Preview
@Preview(
name = "Light Mode",
uiMode = Configuration.UI_MODE_NIGHT_NO or Configuration.UI_MODE_TYPE_NORMAL,
group = "component"
group = "component",
)
@Preview(
name = "Dark Mode",
showBackground = true,
uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL,
group = "component"
group = "component",
)
@Preview(
name = "Full Device Light ",
showBackground = true,
uiMode = Configuration.UI_MODE_NIGHT_NO or Configuration.UI_MODE_TYPE_NORMAL,
showSystemUi = true,
group = "full"
group = "full",
)
@Preview(
name = "Full Device Dark ",
showBackground = true,
uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL,
showSystemUi = true,
group = "full"
group = "full",
)
annotation class WtaPreviews
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ fun WtaAnimation(
) = Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
modifier = modifier.fillMaxSize()
modifier = modifier.fillMaxSize(),
) {
val composition by rememberLottieComposition(RawRes(animation))
Spacer(modifier = Modifier.weight(0.5f))
Spacer(modifier = Modifier.weight(weight = 0.5f))
LottieAnimation(
composition = composition,
iterations = LottieConstants.IterateForever,
Expand All @@ -41,6 +41,6 @@ fun WtaAnimation(
Text(
text = text,
style = MaterialTheme.typography.titleMedium,
modifier = Modifier.weight(1f)
modifier = Modifier.weight(1f),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ fun WtaIllustration(
) = Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
modifier = modifier.fillMaxSize()
modifier = modifier.fillMaxSize(),
) {
Image(
painter = painterResource(id = illustration),
contentDescription = "",
contentScale = ContentScale.Fit,
modifier = Modifier.testTag(illustrationTestTag)
modifier = Modifier.testTag(illustrationTestTag),
)
Spacer(modifier = Modifier.height(MaterialTheme.spacing.lMedium))
Text(
text = text,
style = MaterialTheme.typography.titleMedium
style = MaterialTheme.typography.titleMedium,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ fun OtherStatsCard(
onClick = onClick,
roundedCornerPercent = 25,
iconOffset = 90.dp,
iconSize = 70.dp
iconSize = 70.dp,
)
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@ internal fun StatsCard(
@DrawableRes iconId: Int,
onClick: () -> Unit,
roundedCornerPercent: Int = 25,
weights: Pair<Float, Float> = Pair(1f, 0.5f),
statsTypeWeight: Float = 1f,
statsValueWeight: Float = 0.5f,
iconOffset: Dp = 50.dp,
iconSize: Dp = 80.dp,
) {
val cardGradient = Brush.horizontalGradient(
listOf(
gradient.startColor,
gradient.endColor
)
gradient.endColor,
),
)
val cardShape = RoundedCornerShape(roundedCornerPercent)
Box(
Expand All @@ -61,29 +62,29 @@ internal fun StatsCard(
.clickable { onClick() }
.fillMaxWidth()
.background(cardGradient, cardShape)
.padding(horizontal = MaterialTheme.spacing.lMedium)
.padding(horizontal = MaterialTheme.spacing.lMedium),
) {
Image(
painter = painterResource(id = iconId),
contentDescription = "",
contentScale = ContentScale.FillBounds,
modifier = Modifier
.padding(start = iconOffset)
.size(iconSize)
.size(iconSize),
)
Row(
verticalAlignment = Alignment.CenterVertically
verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = statsType,
maxLines = 2,
modifier = Modifier.weight(weights.first, true),
modifier = Modifier.weight(statsTypeWeight, true),
style = MaterialTheme.typography.cardContent,
color = gradient.onStartColor,
)
Text(
text = statsValue,
modifier = Modifier.weight(weights.second, true),
modifier = Modifier.weight(statsValueWeight, true),
textAlign = TextAlign.End,
style = TextStyle(
color = Color.White,
Expand All @@ -98,15 +99,15 @@ internal fun StatsCard(

@WtaPreviews
@Composable
fun StatsCardPreview() = WakaTimeAppTheme {
private fun StatsCardPreview() = WakaTimeAppTheme {
Surface {
Row {
StatsCard(
statsType = "Stats Type",
statsValue = "Stats Value",
gradient = MaterialTheme.gradients.reef,
iconId = MaterialTheme.assets.icons.time,
onClick = {}
onClick = {},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fun StatsChip(
.fillMaxWidth()
.clip(shape)
.clickable(onClick = onClick)
.background(gradientBrush, shape)
.background(gradientBrush, shape),
) {
Image(
painter = painterResource(iconId),
Expand All @@ -63,10 +63,10 @@ fun StatsChip(
modifier = Modifier
.padding(
end = MaterialTheme.spacing.small,
bottom = MaterialTheme.spacing.extraSmall
bottom = MaterialTheme.spacing.extraSmall,
)
.size(size = 50.dp)
.align(Alignment.BottomEnd)
.align(Alignment.BottomEnd),
)
Column(
modifier = Modifier
Expand All @@ -84,30 +84,30 @@ fun StatsChip(
}
withStyle(
style = MaterialTheme.typography.headlineSmall.copy(
baselineShift = BaselineShift(0.5f)
).toSpanStyle()
baselineShift = BaselineShift(multiplier = 0.5f),
).toSpanStyle(),
) {
append(" $statsValueSubText")
}
},
color = gradient.onStartColor,
modifier = Modifier.removeFontPadding(streakValueTextStyle)
modifier = Modifier.removeFontPadding(streakValueTextStyle),
)
Text(
text = statsType,
color = gradient.onStartColor,
style = MaterialTheme.typography.bodyMedium.copy(fontWeight = FontWeight.Light)
style = MaterialTheme.typography.bodyMedium.copy(fontWeight = FontWeight.Light),
)
}
}
}

@WtaPreviews
@Composable
fun StatsChipPreview() = WakaTimeAppTheme {
private fun StatsChipPreview() = WakaTimeAppTheme {
Surface {
Row(
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.spacing.small)
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.spacing.small),
) {
StatsChip(
statsType = "Stats Type",
Expand All @@ -127,7 +127,7 @@ fun StatsChipPreview() = WakaTimeAppTheme {
iconId = MaterialTheme.assets.icons.time,
onClick = {},
roundedCornerPercent = 25,
modifier = Modifier.weight(1f)
modifier = Modifier.weight(1f),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import com.jacob.wakatimeapp.core.ui.theme.assets
import com.jacob.wakatimeapp.core.ui.theme.colors.Gradient
import com.jacob.wakatimeapp.core.ui.theme.gradients

// TODO: FIX MAGIC NUMBERS

@Composable
fun TimeSpentCard(
statsType: String,
Expand All @@ -28,7 +26,7 @@ fun TimeSpentCard(
gradient = gradient,
iconId = iconId,
onClick = onClick,
roundedCornerPercent = roundedCornerPercent
roundedCornerPercent = roundedCornerPercent,
)

@WtaPreviews
Expand All @@ -41,7 +39,7 @@ private fun TimeSpentCardPreview() = WakaTimeAppTheme {
time = Time(42, 22, 0f),
gradient = MaterialTheme.gradients.facebookMessenger,
iconId = MaterialTheme.assets.icons.time,
roundedCornerPercent = 25
roundedCornerPercent = 25,
) {}
}
}
Expand Down
Loading

0 comments on commit 72812bf

Please sign in to comment.