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 @@ -161,6 +161,9 @@ fun ClubCodeInputScreen(
focusRequesters[index + 1].requestFocus()
keyboardController?.show()
}
else if (input.isNotEmpty() && index == 5) {
keyboardController?.hide()
}
Comment on lines +164 to +166
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

마지막 자리 입력 시 키보드 자동 숨김 로직이 잘 구현되었습니다.

6번째 칸(index 5)에 숫자가 입력되면 키보드를 자동으로 내리는 로직이 정확합니다. 사용자가 모든 코드를 입력했을 때 키보드가 자동으로 사라지므로 UX가 개선됩니다.

코드 중복 제거를 고려해주세요.

이 로직이 EmailVerificationScreen.kt(lines 137-139)에도 동일하게 구현되어 있습니다. 두 화면의 6자리 코드 입력 처리 로직을 공통 컴포저블 또는 유틸리티 함수로 추출하면 유지보수가 더 쉬워집니다.

다음과 같이 공통 로직을 추출할 수 있습니다:

// 공통 파일에 추가
fun handleCodeInput(
    input: String,
    index: Int,
    code: Array<String>,
    focusRequesters: List<FocusRequester>,
    keyboardController: SoftwareKeyboardController?,
    onCodeUpdate: (Array<String>) -> Unit,
    onFocusIndexUpdate: (Int) -> Unit,
    onErrorClear: (() -> Unit)? = null
) {
    if (input.length <= 1 && input.all { it.isDigit() }) {
        val newCode = code.copyOf()
        newCode[index] = input
        onCodeUpdate(newCode)
        onErrorClear?.invoke()

        when {
            input.isNotEmpty() && index < 5 -> {
                onFocusIndexUpdate(index + 1)
                focusRequesters[index + 1].requestFocus()
                keyboardController?.show()
            }
            input.isNotEmpty() && index == 5 -> {
                keyboardController?.hide()
            }
            input.isEmpty() && index > 0 -> {
                onFocusIndexUpdate(index - 1)
                focusRequesters[index - 1].requestFocus()
                keyboardController?.show()
            }
        }
    }
}

그런 다음 두 화면에서 이 함수를 재사용할 수 있습니다.

🤖 Prompt for AI Agents
In
composeApp/src/commonMain/kotlin/org/whosin/client/presentation/auth/clubcode/ClubCodeInputScreen.kt
around lines 164-166 (and similarly in EmailVerificationScreen.kt lines
137-139), the keyboard-hide/focus-change logic is duplicated; extract this
shared behavior into a single utility/composable (e.g., handleCodeInput) placed
in a common package (shared UI utils) that accepts input, index, code array,
focusRequesters, keyboardController, onCodeUpdate, onFocusIndexUpdate, and
optional onErrorClear, implement the same branching (advance focus and show
keyboard, hide keyboard on last digit, move back on delete), then replace the
duplicated blocks in both screens with a call to that new function and update
imports and parameter wiring accordingly.

// 현재 박스가 비워지고 이전 박스가 있으면 이전으로 이동
else if (input.isEmpty() && index > 0) {
currentFocusIndex = index - 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ fun EmailVerificationScreen(
currentFocusIndex = index + 1
focusRequesters[index + 1].requestFocus()
}
else if (input.isNotEmpty() && index == 5) {
keyboardController?.hide()
}
// 현재 박스가 비워지고 이전 박스가 있으면 이전으로 이동
else if (input.isEmpty() && index > 0) {
currentFocusIndex = index - 1
Expand Down