Skip to content

Commit

Permalink
[ADD/#19] TextField DecorationBox Add
Browse files Browse the repository at this point in the history
  • Loading branch information
arinming committed Jul 7, 2024
1 parent 8302624 commit 63e2097
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.terning.core.designsystem.textfield

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.terning.core.R
import com.terning.core.designsystem.theme.TerningMain
import com.terning.core.designsystem.theme.TerningTypography
import com.terning.core.designsystem.theme.White

@Composable
fun TerningTextField(
value: String,
onValueChange: (String) -> Unit,
modifier: Modifier = Modifier,
) {
BasicTextField(
value = value,
onValueChange = onValueChange,
modifier = Modifier
.fillMaxWidth()
.background(White),
textStyle = TerningTypography().button3,
decorationBox = { innerTextField ->
Column(modifier = Modifier.drawWithContent {
drawContent()
drawLine(
color = TerningMain,
start = Offset(
x = 0f,
y = size.height - 1.dp.toPx(),
),
end = Offset(
x = size.width,
y = size.height - 1.dp.toPx(),
),
strokeWidth = 2.dp.toPx(),
)
}) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(12.dp),
) {
Icon(
painter = painterResource(id = R.drawable.ic_back),
contentDescription = null,
tint = TerningMain,
)
innerTextField()
}
Spacer(modifier = Modifier.height(8.dp))
}
}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ 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

class MainNavigator(
Expand All @@ -22,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 ->
Expand Down
21 changes: 16 additions & 5 deletions feature/src/main/java/com/terning/feature/main/MainScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import androidx.navigation.compose.NavHost
import com.terning.core.designsystem.theme.Grey300
import com.terning.core.designsystem.theme.TerningMain
import com.terning.core.designsystem.theme.White
import com.terning.core.designsystem.topappbar.BackButtonTopAppBar
import com.terning.core.designsystem.topappbar.LogoTopAppBar
import com.terning.core.designsystem.topappbar.MyPageTopAppBar
import com.terning.core.designsystem.topappbar.TerningTopAppBar
Expand All @@ -42,10 +41,7 @@ fun MainScreen(
topBar = {
when (navigator.currentTab) {
MainTab.HOME -> LogoTopAppBar()
MainTab.CALENDAR -> BackButtonTopAppBar(
title = "dkssud",
onBackButtonClick = { navigator.navigateUp() })

MainTab.CALENDAR -> TerningTopAppBar()
MainTab.SEARCH -> LogoTopAppBar()
MainTab.MY_PAGE -> MyPageTopAppBar()
null -> TerningTopAppBar()
Expand Down Expand Up @@ -80,6 +76,21 @@ fun MainScreen(
}
}



@Composable
private fun MainTopBar(
isVisible: Boolean,
tabs: List<MainTab>,
currentTab: MainTab?,
onTabSelected: (MainTab) -> Unit,
) {
AnimatedVisibility(
visible = isVisible,
) {
}
}

@Composable
private fun MainBottomBar(
isVisible: Boolean,
Expand Down
18 changes: 15 additions & 3 deletions feature/src/main/java/com/terning/feature/search/SearchRoute.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ package com.terning.feature.search
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import com.terning.core.designsystem.topappbar.LogoTopAppBar
import androidx.compose.ui.unit.dp
import com.terning.core.designsystem.textfield.TerningTextField

@Composable
fun SearchRoute() {
Expand All @@ -16,10 +20,18 @@ fun SearchRoute() {

@Composable
fun SearchScreen(modifier: Modifier = Modifier) {
var text by remember { mutableStateOf("") }
Column(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp)
) {
Text(text = "ํƒ์ƒ‰ ์Šคํฌ๋ฆฐ")
TerningTextField(
value = text,
onValueChange = { newText ->
text = newText
}
)
}
}
}

0 comments on commit 63e2097

Please sign in to comment.