From 51632465db206321b21643db95b44757bf7b12af Mon Sep 17 00:00:00 2001 From: arinming Date: Tue, 9 Jul 2024 22:46:25 +0900 Subject: [PATCH] =?UTF-8?q?[FEAT/#23]=20=ED=8F=AC=EC=BB=A4=EC=8A=A4=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=EC=97=90=20=EB=94=B0=EB=9D=BC=20=ED=9E=8C?= =?UTF-8?q?=ED=8A=B8=20=ED=85=8D=EC=8A=A4=ED=8A=B8=20=EC=83=89=EC=83=81=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../textfield/TerningBasicTextField.kt | 27 ++++++++++++++----- .../com/terning/feature/main/MainNavigator.kt | 3 +-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/com/terning/core/designsystem/textfield/TerningBasicTextField.kt b/core/src/main/java/com/terning/core/designsystem/textfield/TerningBasicTextField.kt index d100f999f..7a030647e 100644 --- a/core/src/main/java/com/terning/core/designsystem/textfield/TerningBasicTextField.kt +++ b/core/src/main/java/com/terning/core/designsystem/textfield/TerningBasicTextField.kt @@ -12,9 +12,13 @@ import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material3.Icon import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.MutableState +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.drawWithContent +import androidx.compose.ui.focus.onFocusChanged import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color @@ -33,11 +37,11 @@ import com.terning.core.designsystem.theme.White fun TerningBasicTextField( value: String, onValueChange: (String) -> Unit, + readOnly: Boolean = false, textStyle: TextStyle, textColor: Color, hintColor: Color, drawLineColor: Color, - helperColor: Color, cursorBrush: Brush, strokeWidth: Float = 1f, leftIcon: Int? = null, @@ -47,19 +51,25 @@ fun TerningBasicTextField( hint: String = "", helperMessage: String = "", helperIcon: Int? = null, + helperColor: Color = TerningMain, ) { val keyboardController = LocalSoftwareKeyboardController.current val focusManager = LocalFocusManager.current + val isFocused: MutableState = remember { mutableStateOf(false) } - BasicTextField(value = value, + BasicTextField( + value = value, onValueChange = onValueChange, singleLine = true, maxLines = 1, + readOnly = readOnly, keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done), - keyboardActions = KeyboardActions(onDone = { - keyboardController?.hide() - focusManager.clearFocus() - }), + keyboardActions = KeyboardActions( + onDone = { + keyboardController?.hide() + focusManager.clearFocus() + } + ), modifier = Modifier .fillMaxWidth() @@ -75,6 +85,9 @@ fun TerningBasicTextField( end = Offset(x = canvasWidth, y = canvasHeight), strokeWidth = strokeWidth.dp.toPx(), ) + } + .onFocusChanged { + isFocused.value = it.isFocused }, textStyle = textStyle.copy(color = textColor), @@ -98,7 +111,7 @@ fun TerningBasicTextField( Text( text = hint, style = textStyle, - color = hintColor + color = if (isFocused.value) hintColor else textColor ) } innerTextField() diff --git a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt index 68d33fb38..e67b04927 100644 --- a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt +++ b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt @@ -12,7 +12,6 @@ import androidx.navigation.navOptions import com.terning.feature.calendar.navigation.navigateCalendar import com.terning.feature.home.navigation.navigateHome import com.terning.feature.mypage.navigation.navigateMyPage -import com.terning.feature.onboarding.signin.navigation.SignIn import com.terning.feature.search.navigation.Search import com.terning.feature.search.navigation.navigateSearch @@ -23,7 +22,7 @@ class MainNavigator( @Composable get() = navController .currentBackStackEntryAsState().value?.destination - val startDestination = SignIn + val startDestination = Search val currentTab: MainTab? @Composable get() = MainTab.find { tab ->