Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.ime
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
Expand Down Expand Up @@ -265,7 +264,6 @@ private fun ReportScreen(
BitnagilTextField(
value = uiState.reportTitle,
onValueChange = onReportTitleChange,
singleLine = true,
keyboardActions = KeyboardActions(
onDone = {
focusManager.clearFocus()
Expand All @@ -279,6 +277,15 @@ private fun ReportScreen(
color = BitnagilTheme.colors.coolGray80,
)
},
minLines = 2,
)

Text(
text = "${uiState.reportTitle.length} / ${ReportState.MAX_TITLE_LENGTH}",
style = BitnagilTheme.typography.caption1Medium,
color = BitnagilTheme.colors.coolGray80,
textAlign = TextAlign.End,
modifier = Modifier.fillMaxWidth(),
)
}

Expand All @@ -297,7 +304,6 @@ private fun ReportScreen(
value = uiState.reportContent,
onValueChange = onReportContentChange,
modifier = Modifier
.height(88.dp)
.focusRequester(contentFocusRequester),
keyboardOptions = KeyboardOptions(
imeAction = ImeAction.Done,
Expand All @@ -309,15 +315,16 @@ private fun ReportScreen(
),
placeholder = {
Text(
text = "어떤 위험인지 간단히 설명해주세요.(100자 내외)",
text = "어떤 위험인지 간단히 설명해주세요.(${ReportState.MAX_CONTENT_LENGTH}자 내외)",
style = BitnagilTheme.typography.body2Medium,
color = BitnagilTheme.colors.coolGray80,
)
},
minLines = 3,
)

Text(
text = "${uiState.reportContent.length} / 150",
text = "${uiState.reportContent.length} / ${ReportState.MAX_CONTENT_LENGTH}",
style = BitnagilTheme.typography.caption1Medium,
color = BitnagilTheme.colors.coolGray80,
textAlign = TextAlign.End,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ class ReportViewModel @Inject constructor(

fun updateReportTitle(title: String) {
intent {
if (title.length > ReportState.MAX_TITLE_LENGTH) return@intent
reduce { state.copy(reportTitle = title) }
}
}

fun updateReportContent(content: String) {
intent {
if (content.length > ReportState.MAX_CONTENT_LENGTH) return@intent
reduce { state.copy(reportContent = content) }
}
}
Expand Down Expand Up @@ -129,7 +131,7 @@ class ReportViewModel @Inject constructor(

coroutineScope {
val minDelayJob = async {
delay(1000L)
delay(timeMillis = ReportState.MIN_LOADING_TIME)
}

val processingJob = async {
Expand Down Expand Up @@ -174,7 +176,7 @@ class ReportViewModel @Inject constructor(
)
}
},
onFailure = { error ->
onFailure = { _ ->
reduce { state.copy(submitState = SubmitState.IDLE) }
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ data class ReportState(
currentLongitude != null

companion object {
const val MAX_TITLE_LENGTH = 50
const val MAX_CONTENT_LENGTH = 150
const val MIN_LOADING_TIME = 1500L

const val MAX_IMAGE_COUNT = 3

val Init = ReportState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
Expand Down Expand Up @@ -166,7 +168,17 @@ private fun WriteRoutineScreen(
onClickRemove = null,
)

Spacer(modifier = Modifier.height(40.dp))
Spacer(modifier = Modifier.height(6.dp))

Text(
text = "${state.routineName.length} / ${WriteRoutineState.MAX_ROUTINE_NAME_LENGTH}",
style = BitnagilTheme.typography.caption1Medium,
color = BitnagilTheme.colors.coolGray80,
textAlign = TextAlign.End,
modifier = Modifier.fillMaxWidth(),
)

Spacer(modifier = Modifier.height(28.dp))

Column(
verticalArrangement = Arrangement.spacedBy(12.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ class WriteRoutineViewModel @AssistedInject constructor(
}

fun setRoutineName(name: String) = intent {
if (name.length > WriteRoutineState.MAX_ROUTINE_NAME_LENGTH) return@intent
reduce {
state.copy(
routineName = name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ data class WriteRoutineState(
val recommendedRoutineType: RecommendCategory?,
) : Parcelable {
companion object {
const val MAX_ROUTINE_NAME_LENGTH = 20

val INIT = WriteRoutineState(
routineName = "",
subRoutineNames = listOf("", "", ""),
Expand Down