-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT/#23] 포커스 여부에 따라 힌트 텍스트 색상 변경 #24
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<Boolean> = 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 | ||
Comment on lines
+88
to
+90
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오호~ 바로 구현해내는 폼 미쳐따 |
||
}, | ||
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❤️ |
||
) | ||
} | ||
innerTextField() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
Comment on lines
24
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 잡았다!! |
||
|
||
val currentTab: MainTab? | ||
@Composable get() = MainTab.find { tab -> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
줄바꿈 굿!