Skip to content

Commit

Permalink
fix the detekt issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Masaki-U committed Aug 16, 2024
1 parent caed3ef commit 418e372
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ data class ImageData internal constructor(
val image: String,
val imageBase64: ByteArray,
) {
private val imageHash: Int = imageBase64.contentHashCode()

constructor(image: String) : this(image, image.decodeBase64Bytes())
constructor(imageBase64: ByteArray) : this(imageBase64.toBase64(), imageBase64)

private val imageHash: Int = imageBase64.contentHashCode()

override fun equals(other: Any?): Boolean {
return this === other
|| other is ImageData && imageHash == other.imageHash
return this === other ||
other is ImageData && imageHash == other.imageHash
}

override fun hashCode(): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ import androidx.compose.material3.Text
import androidx.compose.material3.TextFieldDefaults.indicatorLine
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -134,30 +132,46 @@ internal sealed interface ProfileCardUiState {
val imageData: ImageData? = null,
val theme: ProfileCardTheme = ProfileCardTheme.Iguana,
) : ProfileCardUiState {
val nicknameError @Composable get() = if (nickname.isEmpty()) stringResource(
ProfileCardRes.string.enter_validate_format,
stringResource(ProfileCardRes.string.nickname),
) else ""

val occupationError @Composable get() = if (occupation.isEmpty()) stringResource(
ProfileCardRes.string.enter_validate_format,
stringResource(ProfileCardRes.string.occupation),
) else ""

val linkError @Composable get() = if (link.isEmpty()) stringResource(
ProfileCardRes.string.enter_validate_format,
stringResource(ProfileCardRes.string.occupation),
) else ""

val imageError @Composable get() = if (imageData == null) stringResource(
ProfileCardRes.string.add_validate_format,
stringResource(ProfileCardRes.string.image),
) else ""

val isValidInputs = nickname.isNotEmpty()
&& occupation.isNotEmpty()
&& link.isNotEmpty()
&& imageData != null
val nicknameError @Composable get() = if (nickname.isEmpty()) {
stringResource(
ProfileCardRes.string.enter_validate_format,
stringResource(ProfileCardRes.string.nickname),
)
} else {
""
}

val occupationError @Composable get() = if (occupation.isEmpty()) {
stringResource(
ProfileCardRes.string.enter_validate_format,
stringResource(ProfileCardRes.string.occupation),
)
} else {
""
}

val linkError @Composable get() = if (link.isEmpty()) {
stringResource(
ProfileCardRes.string.enter_validate_format,
stringResource(ProfileCardRes.string.occupation),
)
} else {
""
}

val imageError @Composable get() = if (imageData == null) {
stringResource(
ProfileCardRes.string.add_validate_format,
stringResource(ProfileCardRes.string.image),
)
} else {
""
}

val isValidInputs = nickname.isNotEmpty() &&
occupation.isNotEmpty() &&
link.isNotEmpty() &&
imageData != null
}

data class Card(
Expand Down Expand Up @@ -341,7 +355,7 @@ internal fun EditScreen(

ThemePiker(
selectedTheme = uiState.theme,
onClickImage = { onUpdateEditingState(uiState.copy(theme = it)) }
onClickImage = { onUpdateEditingState(uiState.copy(theme = it)) },
)

Button(
Expand Down

0 comments on commit 418e372

Please sign in to comment.