Skip to content

Commit

Permalink
Merge pull request #271 from mash-up-kr/qa/register-ui
Browse files Browse the repository at this point in the history
[QA] 밈 등록 화면 수정
  • Loading branch information
ze-zeh authored Oct 3, 2024
2 parents 1014e91 + 0258b92 commit e535323
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,11 @@ object FarmemeIcon {
)

@Composable
fun Image(
fun Media(
modifier: Modifier = Modifier,
) = Icon(
modifier = modifier,
painter = painterResource(R.drawable.ic_image_24),
painter = painterResource(R.drawable.ic_media_24),
contentDescription = null,
tint = Color.Unspecified
)
Expand Down
13 changes: 0 additions & 13 deletions core/designsystem/src/main/res/drawable/ic_image_24.xml

This file was deleted.

20 changes: 20 additions & 0 deletions core/designsystem/src/main/res/drawable/ic_media_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M4.5,3.5L19.389,3.5A2,2 0,0 1,21.389 5.5L21.389,18.5A2,2 0,0 1,19.389 20.5L4.5,20.5A2,2 0,0 1,2.5 18.5L2.5,5.5A2,2 0,0 1,4.5 3.5z"
android:strokeWidth="2.4"
android:fillColor="#00000000"
android:strokeColor="#1E2227"/>
<path
android:pathData="M2.5,16.5L7.78,11.22C8.176,10.824 8.819,10.83 9.207,11.233L13.329,15.505C13.703,15.893 14.318,15.914 14.718,15.554L16.295,14.135C16.69,13.779 17.295,13.795 17.671,14.171L21,17.5"
android:strokeLineJoin="round"
android:strokeWidth="2.4"
android:fillColor="#00000000"
android:strokeColor="#1E2227"/>
<path
android:pathData="M15.75,8.75m-1.75,0a1.75,1.75 0,1 1,3.5 0a1.75,1.75 0,1 1,-3.5 0"
android:fillColor="#1E2227"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.Divider
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Brush
Expand Down Expand Up @@ -48,6 +49,15 @@ internal fun RegisterScreen(
onIntent(RegisterIntent.SetImageFromGallery(uri.toString()))
}
}

LaunchedEffect(key1 = uiState) {
if (uiState.title.isNotEmpty() && uiState.source.isNotEmpty() && uiState.imageUri.isNotEmpty() && uiState.selectedKeywords.isNotEmpty()) {
onIntent(RegisterIntent.ChangeButtonState(true))
} else {
onIntent(RegisterIntent.ChangeButtonState(false))
}
}

FarmemeScaffold(
modifier = Modifier.navigationBarsPadding(),
topBar = {
Expand All @@ -72,7 +82,7 @@ internal fun RegisterScreen(
.background(
brush = Brush.verticalGradient(
0f to FarmemeTheme.backgroundColor.white.copy(alpha = 0f),
1f to FarmemeTheme.backgroundColor.white.copy(alpha = 1f),
0.7f to FarmemeTheme.backgroundColor.white.copy(alpha = 1f),
)
)
)
Expand All @@ -81,7 +91,7 @@ internal fun RegisterScreen(
.align(Alignment.BottomCenter)
.padding(bottom = 36.dp),
text = "등록하기",
enabled = true,
enabled = uiState.isRegisterButtonEnabled,
onClick = {
onIntent(RegisterIntent.ClickRegister)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ class RegisterViewModel @Inject constructor(
}
}

is RegisterIntent.ChangeButtonState -> {
reduce {
copy(
isRegisterButtonEnabled = intent.enabled
)
}
}

RegisterIntent.ClickRegister -> {
val isUploadSuccess = uploadMemeUseCase(
keywordIds = currentState.selectedKeywords.map { it.id },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ internal fun RegisterImageArea(
withStar = true,
onClick = loadImage,
icon = {
FarmemeIcon.Image(
modifier = Modifier.size(20.dp),
FarmemeIcon.Media(
modifier = Modifier.size(18.dp),
)
}
)
Expand All @@ -82,7 +82,7 @@ internal fun RegisterImageArea(
.padding(12.dp),
backgroundColor = FarmemeTheme.backgroundColor.white,
onClick = loadImage,
icon = { FarmemeIcon.Image(modifier = Modifier.size(20.dp)) },
icon = { FarmemeIcon.Media(modifier = Modifier.size(20.dp)) },
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.Text
Expand Down Expand Up @@ -40,6 +39,7 @@ internal fun RegisterInputArea(
Spacer(modifier = Modifier.height(12.dp))
FarmemeTextField(
text = title,
placeholder = "예) 러키비키잖아",
onTextChanged = {
if (it.length <= MAX_TITLE_LENGTH) {
onTitleChanged(it)
Expand All @@ -65,6 +65,7 @@ internal fun RegisterInputArea(
Spacer(modifier = Modifier.height(12.dp))
FarmemeTextArea(
text = source,
placeholder = "예) 무한도전, 핀터레스트",
onTextChanged = {
if (it.length <= MAX_SOURCE_LENGTH) {
onSourceChanged(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ sealed interface RegisterIntent : UiIntent {
data class InputTitle(val title: String) : RegisterIntent
data class InputSource(val source: String) : RegisterIntent
data class OnKeywordClick(val keyword: Keyword) : RegisterIntent
data class ChangeButtonState(val enabled: Boolean) : RegisterIntent
data object ClickRegister : RegisterIntent
data object OnRetry : RegisterIntent
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import team.ppac.register.model.RegisterCategoryUiModel
data class RegisterUiState(
val isLoading: Boolean,
val isError: Boolean,
val isRegisterButtonEnabled: Boolean,
val registerCategories: ImmutableList<RegisterCategoryUiModel>,
val selectedKeywords: ImmutableSet<Keyword>,
val imageUri: String,
Expand All @@ -23,6 +24,7 @@ data class RegisterUiState(
val INITIAL_STATE = RegisterUiState(
isLoading = false,
isError = false,
isRegisterButtonEnabled = false,
registerCategories = persistentListOf(),
selectedKeywords = persistentSetOf(),
imageUri = "",
Expand Down

0 comments on commit e535323

Please sign in to comment.