|
| 1 | +package com.kms.onboarding |
| 2 | + |
| 3 | +import androidx.compose.foundation.layout.Column |
| 4 | +import androidx.compose.foundation.layout.Spacer |
| 5 | +import androidx.compose.foundation.layout.fillMaxSize |
| 6 | +import androidx.compose.foundation.layout.fillMaxWidth |
| 7 | +import androidx.compose.material3.Text |
| 8 | +import androidx.compose.runtime.Composable |
| 9 | +import androidx.compose.ui.Modifier |
| 10 | +import androidx.compose.ui.platform.LocalFocusManager |
| 11 | +import androidx.compose.ui.res.stringResource |
| 12 | +import androidx.compose.ui.text.style.TextAlign |
| 13 | +import androidx.compose.ui.tooling.preview.Preview |
| 14 | +import com.yapp.designsystem.theme.OrbitTheme |
| 15 | +import com.yapp.ui.component.textfield.OrbitTextField |
| 16 | +import com.yapp.ui.extensions.customClickable |
| 17 | +import com.yapp.ui.utils.heightForScreenPercentage |
| 18 | +import com.yapp.ui.utils.paddingForScreenPercentage |
| 19 | +import feature.onboarding.R |
| 20 | + |
| 21 | +@Composable |
| 22 | +fun OnboardingNameScreen( |
| 23 | + state: OnboardingContract.State, |
| 24 | + currentStep: Int, |
| 25 | + totalSteps: Int, |
| 26 | + onNextClick: () -> Unit, |
| 27 | + onBackClick: () -> Unit, |
| 28 | + onTextChange: (String) -> Unit, |
| 29 | +) { |
| 30 | + val focusManager = LocalFocusManager.current |
| 31 | + |
| 32 | + OnboardingScreen( |
| 33 | + currentStep = currentStep, |
| 34 | + totalSteps = totalSteps, |
| 35 | + isButtonEnabled = state.isButtonEnabled, |
| 36 | + onNextClick = onNextClick, |
| 37 | + onBackClick = onBackClick, |
| 38 | + ) { |
| 39 | + Column( |
| 40 | + modifier = Modifier |
| 41 | + .fillMaxSize() |
| 42 | + .customClickable( |
| 43 | + rippleEnabled = false, |
| 44 | + onClick = { focusManager.clearFocus() }, |
| 45 | + ), |
| 46 | + ) { |
| 47 | + Spacer(modifier = Modifier.heightForScreenPercentage(0.05f)) |
| 48 | + Text( |
| 49 | + text = stringResource(id = R.string.onboarding_step5_text_title), |
| 50 | + style = OrbitTheme.typography.heading1SemiBold, |
| 51 | + color = OrbitTheme.colors.white, |
| 52 | + modifier = Modifier.fillMaxWidth(), |
| 53 | + textAlign = TextAlign.Center, |
| 54 | + ) |
| 55 | + OrbitTextField( |
| 56 | + text = state.textFieldValue, |
| 57 | + onTextChange = { value -> |
| 58 | + onTextChange(value) |
| 59 | + }, |
| 60 | + hint = "이름 입력", |
| 61 | + showWarning = state.showWarning, |
| 62 | + warningMessage = stringResource(id = R.string.onboarding_step5_textfield_warning), |
| 63 | + modifier = Modifier |
| 64 | + .fillMaxWidth() |
| 65 | + .paddingForScreenPercentage(horizontalPercentage = 0.192f, verticalPercentage = 0.086f), |
| 66 | + ) |
| 67 | + } |
| 68 | + } |
| 69 | +} |
| 70 | + |
| 71 | +@Composable |
| 72 | +@Preview |
| 73 | +fun PreviewOnboardingNameScreen() { |
| 74 | + OnboardingNameScreen( |
| 75 | + state = OnboardingContract.State( |
| 76 | + textFieldValue = "김민수", |
| 77 | + isButtonEnabled = true, |
| 78 | + showWarning = false, |
| 79 | + ), |
| 80 | + currentStep = 1, |
| 81 | + totalSteps = 5, |
| 82 | + onNextClick = {}, |
| 83 | + onBackClick = {}, |
| 84 | + onTextChange = {}, |
| 85 | + ) |
| 86 | +} |
0 commit comments