Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -40,6 +40,7 @@ fun DateRoadCourseCard(
Row(
modifier = modifier
.fillMaxWidth()
.padding(end = 16.dp)
.height(130.dp)
.background(DateRoadTheme.colors.white)
.noRippleClickable(onClick = { onClick(course.courseId) })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import org.sopt.teamdateroad.R
import org.sopt.teamdateroad.presentation.ui.component.textfield.DateRoadBasicTextField
import org.sopt.teamdateroad.presentation.ui.component.textfield.DateRoadTextArea
import org.sopt.teamdateroad.presentation.util.view.LoadState
import org.sopt.teamdateroad.presentation.util.view.NumberCommaTransformation
import org.sopt.teamdateroad.ui.theme.DATEROADTheme

@Composable
Expand Down Expand Up @@ -45,7 +46,8 @@ fun EnrollThirdScreen(
onValueChange = { newValue ->
if (newValue.all { it.isDigit() }) onCostValueChange(newValue)
},
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Number)
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Number),
visualTransformation = NumberCommaTransformation(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이런것도 커스텀할 수 있군요~ 굳!

)
Spacer(modifier = Modifier.height(6.dp))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.sopt.teamdateroad.presentation.util.view

import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.input.OffsetMapping
import androidx.compose.ui.text.input.TransformedText
import androidx.compose.ui.text.input.VisualTransformation
import java.text.NumberFormat
import java.util.Locale

class NumberCommaTransformation : VisualTransformation {

private fun Long?.formatWithComma(): String =
NumberFormat.getNumberInstance(Locale.US).format(this ?: 0)

override fun filter(text: AnnotatedString): TransformedText {
val newText = AnnotatedString(
text = if (text.text.isEmpty()) "" else text.text.toLongOrNull().formatWithComma()
)
return TransformedText(
text = newText,
offsetMapping = object : OffsetMapping {
override fun originalToTransformed(offset: Int): Int {
return if (offset != newText.length) newText.length else text.length

}

override fun transformedToOriginal(offset: Int): Int {
return text.length
}
}
)
}
}