diff --git a/core/model/src/commonMain/kotlin/io/github/droidkaigi/confsched/model/ProfileCard.kt b/core/model/src/commonMain/kotlin/io/github/droidkaigi/confsched/model/ProfileCard.kt index 707457439..8b800f00c 100644 --- a/core/model/src/commonMain/kotlin/io/github/droidkaigi/confsched/model/ProfileCard.kt +++ b/core/model/src/commonMain/kotlin/io/github/droidkaigi/confsched/model/ProfileCard.kt @@ -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 { diff --git a/feature/profilecard/src/commonMain/kotlin/io/github/droidkaigi/confsched/profilecard/ProfileCardScreen.kt b/feature/profilecard/src/commonMain/kotlin/io/github/droidkaigi/confsched/profilecard/ProfileCardScreen.kt index 31bf3ee86..90e66a4de 100644 --- a/feature/profilecard/src/commonMain/kotlin/io/github/droidkaigi/confsched/profilecard/ProfileCardScreen.kt +++ b/feature/profilecard/src/commonMain/kotlin/io/github/droidkaigi/confsched/profilecard/ProfileCardScreen.kt @@ -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 @@ -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( @@ -341,7 +355,7 @@ internal fun EditScreen( ThemePiker( selectedTheme = uiState.theme, - onClickImage = { onUpdateEditingState(uiState.copy(theme = it)) } + onClickImage = { onUpdateEditingState(uiState.copy(theme = it)) }, ) Button(