Skip to content

Commit

Permalink
Merge pull request #80 from monstar-lab-oss/build/klint-spotless-update
Browse files Browse the repository at this point in the history
Build/klint spotless update
  • Loading branch information
levinzonr authored Nov 27, 2023
2 parents 06e9ba7 + 4cbf101 commit cec9fff
Show file tree
Hide file tree
Showing 42 changed files with 150 additions and 158 deletions.
4 changes: 0 additions & 4 deletions .editorconfig

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Test
name: Verify

on:
pull_request:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.monstarlab.core.extensions

import kotlin.time.Duration
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlin.time.Duration

fun tickerFlow(interval: Duration, initialDelay: Duration = Duration.ZERO): Flow<Unit> {
return flow {
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/monstarlab/core/network/OkHttpModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.json.Json
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import java.util.concurrent.TimeUnit
import javax.inject.Singleton
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.json.Json

@InstallIn(SingletonComponent::class)
@Module
Expand Down Expand Up @@ -52,7 +52,7 @@ class OkHttpModule {
.client(client)
.baseUrl(BuildConfig.API_URL)
.addConverterFactory(
json.asConverterFactory("application/json".toMediaType())
json.asConverterFactory("application/json".toMediaType()),
)
.build()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.monstarlab.core.network.errorhandling

import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
import okhttp3.Interceptor
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.Response
import okhttp3.ResponseBody.Companion.toResponseBody
import timber.log.Timber
import javax.inject.Inject
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json

/**
* Intercepts API errors and converts them into [ApiException] by decoding the Error response body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.stringPreferencesKey
import timber.log.Timber
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerializationException
import kotlinx.serialization.json.Json
import timber.log.Timber

abstract class SingleSharedPreferenceDataStore<T> constructor(
private val dataStore: DataStore<Preferences>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class DataStoreModule {
listOf(
SharedPreferencesMigration(
context,
"preferences"
)
"preferences",
),
)
}
},
)

@Singleton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ abstract class ComposeFragment : Fragment() {
return ComposeView(requireContext()).apply {
setContent {
setViewCompositionStrategy(
ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed
ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed,
)
content.invoke()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ fun Context.checkPermission(permission: String): Boolean {
PackageManager.PERMISSION_GRANTED
}

fun Context.openShareSheet(
title: String,
message: String,
intentTitle: String = title,
) {
fun Context.openShareSheet(title: String, message: String, intentTitle: String = title) {
val shareIntent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TITLE, title)
Expand All @@ -64,6 +60,6 @@ fun Context.openBrowser(url: String) {
startActivity(
Intent(Intent.ACTION_VIEW).apply {
data = url.toUri()
}
},
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ fun LazyListScope.animatedVisibilityItem(
visible = visible,
enter = enter,
exit = exit,
content = { content.invoke() }
content = { content.invoke() },
)
}
},
)
}

Expand All @@ -49,8 +49,8 @@ fun LazyListScope.animatedVisibilityHeader(
visible = visible,
enter = enter,
exit = exit,
content = { content.invoke() }
content = { content.invoke() },
)
}
},
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private data class ContentChild(val height: Int)
@Preview(name = "Column With Separators", showBackground = true)
@Composable
private fun PreviewColumnWithSeparators() {
ColumnWithSeparators() {
ColumnWithSeparators {
repeat(10) { Text(text = "Hello $it") }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import androidx.compose.ui.tooling.preview.Preview
name = "Light",
group = "Theme",
showBackground = true,
uiMode = Configuration.UI_MODE_NIGHT_NO or Configuration.UI_MODE_TYPE_NORMAL
uiMode = Configuration.UI_MODE_NIGHT_NO or Configuration.UI_MODE_TYPE_NORMAL,
)
@Preview(
name = "Dark",
group = "Theme",
showBackground = true,
uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL
uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL,
)
annotation class LightDarkPreview
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ import com.monstarlab.designsystem.theme.Theme
fun AppTopBar(
title: String,
modifier: Modifier = Modifier,
onBackButtonClick: (() -> Unit)? = null
onBackButtonClick: (() -> Unit)? = null,
) {
TopAppBar(
modifier = modifier,
backgroundColor = Theme.colors.primary,
contentColor = Theme.colors.onPrimary
contentColor = Theme.colors.onPrimary,
) {
onBackButtonClick?.let { onBackClick ->
IconButton(onClick = onBackClick) {
Icon(
imageVector = Icons.Default.ArrowBack,
contentDescription = "back"
contentDescription = "back",
)
}
}

Text(
text = title,
style = Theme.typography.headline2.bold
style = Theme.typography.headline2.bold,
)
}
}
Expand All @@ -54,7 +54,7 @@ private fun PreviewAppTopBarWithBackButton() {
AppTheme {
AppTopBar(
title = "Top Bar",
onBackButtonClick = { }
onBackButtonClick = { },
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ fun AppButton(
enabled: Boolean = true,
isLoading: Boolean = false,
type: AppButtonType = AppButtonType.Filled,
onClick: () -> Unit
onClick: () -> Unit,
) {
when (type) {
AppButtonType.Filled -> PrimaryButton(
modifier = modifier,
onClick = onClick,
enabled = enabled && !isLoading,
content = { ButtonContent(text = text, isLoading = isLoading) }
content = { ButtonContent(text = text, isLoading = isLoading) },
)

AppButtonType.Outlined -> OutlinedButton(
Expand All @@ -44,9 +44,9 @@ fun AppButton(
content = { ButtonContent(text = text, isLoading = isLoading) },
colors = ButtonDefaults.outlinedButtonColors(
contentColor = Theme.colors.secondary,
backgroundColor = Color.Transparent
backgroundColor = Color.Transparent,
),
border = BorderStroke(1.dp, Theme.colors.secondary)
border = BorderStroke(1.dp, Theme.colors.secondary),
)

AppButtonType.Text -> {
Expand All @@ -56,7 +56,7 @@ fun AppButton(
enabled = enabled && !isLoading,
content = {
ButtonContent(text = text, isLoading = isLoading)
}
},
)
}
}
Expand All @@ -67,7 +67,7 @@ private fun PrimaryButton(
modifier: Modifier = Modifier,
onClick: () -> Unit = {},
enabled: Boolean = false,
content: @Composable RowScope.() -> Unit
content: @Composable RowScope.() -> Unit,
) {
val colors = ButtonDefaults.buttonColors()
Button(
Expand All @@ -76,7 +76,7 @@ private fun PrimaryButton(
enabled = enabled,
content = content,
colors = colors,
contentPadding = PaddingValues(vertical = Theme.dimensions.medium2)
contentPadding = PaddingValues(vertical = Theme.dimensions.medium2),
)
}

Expand All @@ -87,12 +87,12 @@ private fun RowScope.ButtonContent(text: String, isLoading: Boolean) {
CircularProgressIndicator(
color = Theme.colors.primary,
modifier = Modifier.size(24.dp),
strokeWidth = 1.dp
strokeWidth = 1.dp,
)
} else {
Text(
text = text,
style = Theme.typography.button
style = Theme.typography.button,
)
}
}
Expand All @@ -105,7 +105,7 @@ private fun PreviewButtonPrimary() {
AppButton(
text = "Primary",
onClick = {},
modifier = Modifier.fillMaxWidth()
modifier = Modifier.fillMaxWidth(),
)
}
}
Expand All @@ -118,7 +118,7 @@ private fun PreviewButtonPrimaryWithLoading() {
text = "Primary",
onClick = {},
isLoading = true,
modifier = Modifier.fillMaxWidth()
modifier = Modifier.fillMaxWidth(),
)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.monstarlab.designsystem.components.appbutton

enum class AppButtonType {
Filled, Outlined, Text
Filled,
Outlined,
Text,
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fun AppTextField(
maxLines: Int = Int.MAX_VALUE,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
trailingIcon: @Composable (() -> Unit)? = null,
leadingIcon: @Composable (() -> Unit)? = null
leadingIcon: @Composable (() -> Unit)? = null,
) {
Column {
OutlinedTextField(
Expand All @@ -55,13 +55,13 @@ fun AppTextField(
leadingIcon = leadingIcon,
label = { Text(text = label) },
placeholder = { Text(text = placeholder) },
isError = error != null
isError = error != null,
)

AnimatedVisibility(visible = error != null) {
Text(
text = error ?: "",
color = Theme.colors.error
color = Theme.colors.error,
)
}
}
Expand All @@ -78,7 +78,7 @@ private fun PreviewTextField() {
onValueChange = { value = it },
placeholder = "Placeholder",
label = "Label",
error = if (value == "error") "This is error" else null
error = if (value == "error") "This is error" else null,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fun AppTheme(
typography = Typography,
shapes = Shapes,
content = content,
colors = if (isDarkMode) DarkColors else LightColors
colors = if (isDarkMode) DarkColors else LightColors,
)
}
}
Expand All @@ -58,7 +58,7 @@ private val LightColors = lightColors(
onBackground = DarkGrey,
onSurface = Black,
surface = White,
error = Red
error = Red,
)

private val DarkColors = darkColors(
Expand All @@ -68,7 +68,7 @@ private val DarkColors = darkColors(
onBackground = White,
onSurface = White,
surface = Black,
error = Red
error = Red,
)

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import androidx.compose.ui.unit.dp
val Shapes = Shapes(
small = RoundedCornerShape(4.dp),
medium = RoundedCornerShape(8.dp),
large = RoundedCornerShape(32.dp)
large = RoundedCornerShape(32.dp),
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ class Dimensions(
medium2 = 9.dp,
medium3 = 6.dp,
big1 = 18.dp,
big2 = 16.dp
big2 = 16.dp,
)

val Default = Dimensions(
medium1 = 16.dp,
medium2 = 12.dp,
medium3 = 8.dp,
big1 = 24.dp,
big2 = 32.dp
big2 = 32.dp,
)
}
}
Loading

0 comments on commit cec9fff

Please sign in to comment.