Skip to content
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

Merged
merged 1 commit into from
Jul 9, 2024
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 @@ -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
Expand All @@ -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,
Expand All @@ -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()
}
),
Comment on lines +67 to +72
Copy link
Member

Choose a reason for hiding this comment

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

줄바꿈 굿!


modifier = Modifier
.fillMaxWidth()
Expand All @@ -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
Copy link
Member

Choose a reason for hiding this comment

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

오호~ 바로 구현해내는 폼 미쳐따

},

textStyle = textStyle.copy(color = textColor),
Expand All @@ -98,7 +111,7 @@ fun TerningBasicTextField(
Text(
text = hint,
style = textStyle,
color = hintColor
color = if (isFocused.value) hintColor else textColor
Copy link
Member

Choose a reason for hiding this comment

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

❤️

)
}
innerTextField()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -23,7 +22,7 @@ class MainNavigator(
@Composable get() = navController
.currentBackStackEntryAsState().value?.destination

val startDestination = SignIn
val startDestination = Search
Comment on lines 24 to +25
Copy link
Member

Choose a reason for hiding this comment

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

잡았다!!


val currentTab: MainTab?
@Composable get() = MainTab.find { tab ->
Expand Down
Loading