Skip to content

Commit

Permalink
chore: ktlint, detekt
Browse files Browse the repository at this point in the history
  • Loading branch information
jinukeu committed Jan 24, 2024
1 parent 0655e26 commit ee16e68
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.compose.ui.tooling.preview.Preview
import com.susu.core.designsystem.R
import com.susu.core.designsystem.theme.Gray100
import com.susu.core.designsystem.theme.SusuTheme
import com.susu.core.ui.extension.susuClickable

@Composable
fun RegisterText(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.susu.core.designsystem.component.button

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Icon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ enum class TextFieldButtonColor(
editTextColor = Gray100,
savedTextColor = Gray100,
placeholderColor = Gray40,
)
),
}

enum class TextButtonInnerButtonColor(
Expand Down
2 changes: 1 addition & 1 deletion core/model/src/main/java/com/susu/core/model/Vote.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ data class Vote(
val category: String,
val content: String,
val isModified: Boolean,
val optionList: List<String>
val optionList: List<String>,
)
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
package com.susu.data.data.repository

import com.susu.core.android.Dispatcher
import com.susu.core.android.SusuDispatchers
import com.susu.core.model.Category
import com.susu.core.model.Vote
import com.susu.data.local.dao.CategoryConfigDao
import com.susu.data.local.model.toEntity
import com.susu.data.local.model.toModel
import com.susu.data.remote.api.CategoryService
import com.susu.data.remote.api.VoteService
import com.susu.data.remote.model.request.CreateVoteRequest
import com.susu.data.remote.model.request.VoteOption
import com.susu.data.remote.model.response.toModel
import com.susu.domain.repository.CategoryConfigRepository
import com.susu.domain.repository.VoteRepository
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.withContext
import javax.inject.Inject

class VoteRepositoryImpl @Inject constructor(
Expand Down
2 changes: 1 addition & 1 deletion data/src/main/java/com/susu/data/remote/api/VoteService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ interface VoteService {

@POST("/api/v1/votes")
suspend fun createVote(
@Body createVoteRequest: CreateVoteRequest
@Body createVoteRequest: CreateVoteRequest,
): ApiResult<VoteResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ data class CreateVoteRequest(
@SerialName("options")
val optionList: List<VoteOption>,
@SerialName("postCategoryId")
val categoryId: Int
val categoryId: Int,
)

@Serializable
data class VoteOption(
val content: String,
val seq: Int
val seq: Int,
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data class VoteResponse(
val content: String,
val isModified: Boolean,
@SerialName("options")
val optionList: List<VoteOption>
val optionList: List<VoteOption>,
)

internal fun VoteResponse.toModel() = Vote(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import com.susu.core.model.Vote

interface VoteRepository {
suspend fun createVote(
content: String,
optionList: List<String>,
categoryId: Int
content: String,
optionList: List<String>,
categoryId: Int,
): Vote
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.susu.domain.usecase.vote

import com.susu.core.common.runCatchingIgnoreCancelled
import com.susu.domain.repository.CategoryConfigRepository
import com.susu.domain.repository.VoteRepository
import javax.inject.Inject

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ fun NavGraphBuilder.communityNavGraph(
padding: PaddingValues,
navigateVoteAdd: () -> Unit,
popBackStack: () -> Unit,
@Suppress("detekt:UnusedParameter")
onShowSnackbar: (SnackbarToken) -> Unit,
@Suppress("detekt:UnusedParameter")
onShowDialog: (DialogToken) -> Unit,
handleException: (Throwable, () -> Unit) -> Unit,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.susu.core.ui.base.SideEffect
import com.susu.core.ui.base.UiState
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.persistentListOf
import java.util.UUID

data class VoteAddState(
val categoryConfigList: PersistentList<Category> = persistentListOf(),
Expand All @@ -14,8 +13,8 @@ data class VoteAddState(
val content: String = "",
val isLoading: Boolean = false,
) : UiState {
val buttonEnabled = content.length in 1 .. 50 &&
voteOptionStateList.all { it.content.length in 1 ..10 }
val buttonEnabled = content.length in 1..50 &&
voteOptionStateList.all { it.content.length in 1..10 }
}

data class VoteOptionState(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.susu.feature.community.voteadd

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
Expand All @@ -14,10 +12,8 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
Expand All @@ -26,13 +22,10 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.susu.core.designsystem.component.appbar.SusuDefaultAppBar
import com.susu.core.designsystem.component.appbar.icon.BackIcon
import com.susu.core.designsystem.component.appbar.icon.DeleteText
import com.susu.core.designsystem.component.appbar.icon.EditText
import com.susu.core.designsystem.component.appbar.icon.RegisterText
import com.susu.core.designsystem.component.button.FilledButtonColor
import com.susu.core.designsystem.component.button.SusuFilledButton
Expand All @@ -41,7 +34,6 @@ import com.susu.core.designsystem.component.textfield.SusuBasicTextField
import com.susu.core.designsystem.component.textfieldbutton.SusuTextFieldFillMaxButton
import com.susu.core.designsystem.component.textfieldbutton.TextFieldButtonColor
import com.susu.core.designsystem.component.textfieldbutton.style.MediumTextFieldButtonStyle
import com.susu.core.designsystem.component.textfieldbutton.style.TextFieldButtonStyle
import com.susu.core.designsystem.theme.Gray10
import com.susu.core.designsystem.theme.Gray100
import com.susu.core.designsystem.theme.Gray40
Expand Down Expand Up @@ -116,9 +108,9 @@ fun VoteAddScreen(
.susuClickable(
rippleEnabled = false,
runIf = uiState.buttonEnabled,
onClick = onClickRegister
onClick = onClickRegister,
),
color = if (uiState.buttonEnabled) Gray100 else Gray40
color = if (uiState.buttonEnabled) Gray100 else Gray40,
)
},
)
Expand All @@ -130,7 +122,7 @@ fun VoteAddScreen(
.verticalScroll(rememberScrollState()),
) {
Row(
horizontalArrangement = Arrangement.spacedBy(SusuTheme.spacing.spacing_xxxxs)
horizontalArrangement = Arrangement.spacedBy(SusuTheme.spacing.spacing_xxxxs),
) {
uiState.categoryConfigList.dropLast(1).forEach {
SusuFilledButton(
Expand Down Expand Up @@ -167,7 +159,7 @@ fun VoteAddScreen(
Spacer(modifier = Modifier.size(SusuTheme.spacing.spacing_xl))

Column(
verticalArrangement = Arrangement.spacedBy(SusuTheme.spacing.spacing_xxs)
verticalArrangement = Arrangement.spacedBy(SusuTheme.spacing.spacing_xxs),
) {
uiState.voteOptionStateList.forEachIndexed { index, option ->
SusuTextFieldFillMaxButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,23 @@ class VoteAddViewModel @Inject constructor(
fun updateOptionContent(index: Int, content: String) = intent {
copy(
voteOptionStateList = voteOptionStateList.mapIndexed { voteIndex, voteOptionState ->
if (index == voteIndex) voteOptionState.copy(content = content)
else voteOptionState
if (index == voteIndex) {
voteOptionState.copy(content = content)
} else {
voteOptionState
}
}.toPersistentList(),
)
}

fun toggleOptionSavedState(index: Int) = intent {
copy(
voteOptionStateList = voteOptionStateList.mapIndexed { voteIndex, voteOptionState ->
if (index == voteIndex) voteOptionState.copy(isSaved = voteOptionState.isSaved.not())
else voteOptionState
if (index == voteIndex) {
voteOptionState.copy(isSaved = voteOptionState.isSaved.not())
} else {
voteOptionState
}
}.toPersistentList(),
)
}
Expand Down

0 comments on commit ee16e68

Please sign in to comment.