Skip to content

Commit 057eeb4

Browse files
authored
Merge pull request #180 from YAPP-Github/ui/#179-character_limit
[UI/#179] 글자수 제한 추가 및 제보 최소 대기시간 수정
2 parents 60c6743 + 675ae83 commit 057eeb4

File tree

6 files changed

+36
-8
lines changed

6 files changed

+36
-8
lines changed

presentation/src/main/java/com/threegap/bitnagil/presentation/report/ReportScreen.kt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import androidx.compose.foundation.layout.Row
1818
import androidx.compose.foundation.layout.WindowInsets
1919
import androidx.compose.foundation.layout.fillMaxSize
2020
import androidx.compose.foundation.layout.fillMaxWidth
21-
import androidx.compose.foundation.layout.height
2221
import androidx.compose.foundation.layout.ime
2322
import androidx.compose.foundation.layout.padding
2423
import androidx.compose.foundation.layout.statusBarsPadding
@@ -265,7 +264,6 @@ private fun ReportScreen(
265264
BitnagilTextField(
266265
value = uiState.reportTitle,
267266
onValueChange = onReportTitleChange,
268-
singleLine = true,
269267
keyboardActions = KeyboardActions(
270268
onDone = {
271269
focusManager.clearFocus()
@@ -279,6 +277,15 @@ private fun ReportScreen(
279277
color = BitnagilTheme.colors.coolGray80,
280278
)
281279
},
280+
minLines = 2,
281+
)
282+
283+
Text(
284+
text = "${uiState.reportTitle.length} / ${ReportState.MAX_TITLE_LENGTH}",
285+
style = BitnagilTheme.typography.caption1Medium,
286+
color = BitnagilTheme.colors.coolGray80,
287+
textAlign = TextAlign.End,
288+
modifier = Modifier.fillMaxWidth(),
282289
)
283290
}
284291

@@ -297,7 +304,6 @@ private fun ReportScreen(
297304
value = uiState.reportContent,
298305
onValueChange = onReportContentChange,
299306
modifier = Modifier
300-
.height(88.dp)
301307
.focusRequester(contentFocusRequester),
302308
keyboardOptions = KeyboardOptions(
303309
imeAction = ImeAction.Done,
@@ -309,15 +315,16 @@ private fun ReportScreen(
309315
),
310316
placeholder = {
311317
Text(
312-
text = "어떤 위험인지 간단히 설명해주세요.(100자 내외)",
318+
text = "어떤 위험인지 간단히 설명해주세요.(${ReportState.MAX_CONTENT_LENGTH} 내외)",
313319
style = BitnagilTheme.typography.body2Medium,
314320
color = BitnagilTheme.colors.coolGray80,
315321
)
316322
},
323+
minLines = 3,
317324
)
318325

319326
Text(
320-
text = "${uiState.reportContent.length} / 150",
327+
text = "${uiState.reportContent.length} / ${ReportState.MAX_CONTENT_LENGTH}",
321328
style = BitnagilTheme.typography.caption1Medium,
322329
color = BitnagilTheme.colors.coolGray80,
323330
textAlign = TextAlign.End,

presentation/src/main/java/com/threegap/bitnagil/presentation/report/ReportViewModel.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ class ReportViewModel @Inject constructor(
3636

3737
fun updateReportTitle(title: String) {
3838
intent {
39+
if (title.length > ReportState.MAX_TITLE_LENGTH) return@intent
3940
reduce { state.copy(reportTitle = title) }
4041
}
4142
}
4243

4344
fun updateReportContent(content: String) {
4445
intent {
46+
if (content.length > ReportState.MAX_CONTENT_LENGTH) return@intent
4547
reduce { state.copy(reportContent = content) }
4648
}
4749
}
@@ -129,7 +131,7 @@ class ReportViewModel @Inject constructor(
129131

130132
coroutineScope {
131133
val minDelayJob = async {
132-
delay(1000L)
134+
delay(timeMillis = ReportState.MIN_LOADING_TIME)
133135
}
134136

135137
val processingJob = async {
@@ -174,7 +176,7 @@ class ReportViewModel @Inject constructor(
174176
)
175177
}
176178
},
177-
onFailure = { error ->
179+
onFailure = { _ ->
178180
reduce { state.copy(submitState = SubmitState.IDLE) }
179181
},
180182
)

presentation/src/main/java/com/threegap/bitnagil/presentation/report/contract/ReportState.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ data class ReportState(
3030
currentLongitude != null
3131

3232
companion object {
33+
const val MAX_TITLE_LENGTH = 50
34+
const val MAX_CONTENT_LENGTH = 150
35+
const val MIN_LOADING_TIME = 1500L
36+
3337
const val MAX_IMAGE_COUNT = 3
3438

3539
val Init = ReportState(

presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/WriteRoutineScreen.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ import androidx.compose.foundation.layout.width
1616
import androidx.compose.foundation.layout.windowInsetsPadding
1717
import androidx.compose.foundation.rememberScrollState
1818
import androidx.compose.foundation.verticalScroll
19+
import androidx.compose.material3.Text
1920
import androidx.compose.runtime.Composable
2021
import androidx.compose.runtime.getValue
2122
import androidx.compose.ui.Alignment
2223
import androidx.compose.ui.Modifier
24+
import androidx.compose.ui.text.style.TextAlign
2325
import androidx.compose.ui.tooling.preview.Preview
2426
import androidx.compose.ui.unit.dp
2527
import androidx.hilt.navigation.compose.hiltViewModel
@@ -166,7 +168,17 @@ private fun WriteRoutineScreen(
166168
onClickRemove = null,
167169
)
168170

169-
Spacer(modifier = Modifier.height(40.dp))
171+
Spacer(modifier = Modifier.height(6.dp))
172+
173+
Text(
174+
text = "${state.routineName.length} / ${WriteRoutineState.MAX_ROUTINE_NAME_LENGTH}",
175+
style = BitnagilTheme.typography.caption1Medium,
176+
color = BitnagilTheme.colors.coolGray80,
177+
textAlign = TextAlign.End,
178+
modifier = Modifier.fillMaxWidth(),
179+
)
180+
181+
Spacer(modifier = Modifier.height(28.dp))
170182

171183
Column(
172184
verticalArrangement = Arrangement.spacedBy(12.dp),

presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/WriteRoutineViewModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ class WriteRoutineViewModel @AssistedInject constructor(
158158
}
159159

160160
fun setRoutineName(name: String) = intent {
161+
if (name.length > WriteRoutineState.MAX_ROUTINE_NAME_LENGTH) return@intent
161162
reduce {
162163
state.copy(
163164
routineName = name,

presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/contract/WriteRoutineState.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ data class WriteRoutineState(
3333
val recommendedRoutineType: RecommendCategory?,
3434
) : Parcelable {
3535
companion object {
36+
const val MAX_ROUTINE_NAME_LENGTH = 20
37+
3638
val INIT = WriteRoutineState(
3739
routineName = "",
3840
subRoutineNames = listOf("", "", ""),

0 commit comments

Comments
 (0)