Skip to content

Commit

Permalink
components->component로 이름변경 및 기타변경사항
Browse files Browse the repository at this point in the history
- YdsBaseButton defaultMinSize 변경 완료
- modifier들 끌어올리기
  • Loading branch information
Gael-Android committed Nov 9, 2023
1 parent 2552b3f commit 0240b01
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import android.widget.Toast
import androidx.compose.foundation.background
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsFocusedAsState
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardActions
Expand Down Expand Up @@ -67,7 +70,8 @@ fun SearchTextField(
.background(
color = YdsTheme.colors.inputFieldElevated,
shape = RoundedCornerShape(8.dp),
),
)
.height(40.dp),
interactionSource = interactionSource,
decorationBox = { innerTextField ->
TextFieldDefaults.OutlinedTextFieldDecorationBox(
Expand Down Expand Up @@ -95,15 +99,15 @@ fun SearchTextField(
trailingIcon = {
if (isTyping) {
YdsBaseButton(
onClick = {
onValueChange("")
},
colors = ButtonColorState(),
onClick = { onValueChange("") },
colors = ButtonColorState(
contentColor = YdsTheme.colors.buttonNormal,
disabledContentColor = Color.Transparent
)
) {
Icon(
id = R.drawable.ic_x_line,
iconSize = IconSize.ExtraSmall,
tint = YdsTheme.colors.buttonNormal,
iconSize = IconSize.ExtraSmall
)
}
}
Expand Down Expand Up @@ -147,19 +151,26 @@ private fun PreviewSearchTextField() {
val context = LocalContext.current
var text: String by rememberSaveable { mutableStateOf("") }

SearchTextField(
onValueChange = {
text = it
},
onSearch = {
Toast.makeText(
context,
"onSearch!",
Toast.LENGTH_SHORT,
).show()
},
text = text,
placeHolderText = "플레이스 홀더 입니다",
isDisabled = false,
)
Column(
Modifier
.background(Color.White)
.fillMaxWidth()
) {
SearchTextField(
onValueChange = {
text = it
},
onSearch = {
Toast.makeText(
context,
"onSearch!",
Toast.LENGTH_SHORT,
).show()
},
text = text,
placeHolderText = "플레이스 홀더 입니다",
isDisabled = false,
modifier = Modifier.fillMaxWidth()
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import com.yourssu.design.system.compose.states.ButtonColorState

@Composable
fun TopBarButton(
onClick: () -> Unit = {},
modifier: Modifier = Modifier,
onClick: () -> Unit = {},
isDisabled: Boolean = true,
text: String = "",
@DrawableRes icon: Int? = null,
Expand All @@ -38,6 +38,8 @@ fun TopBarButton(
),
enabled = !isDisabled,
rounding = 0.dp,
minWidth = 0.dp,
minHeight = 0.dp,
contentPadding = PaddingValues(horizontal = 12.dp),
) {
if (icon == null && text.isNotEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
Expand Down Expand Up @@ -49,9 +48,7 @@ internal fun YdsBaseButton(

Surface(
onClick = onClick,
modifier = modifier
.width(minWidth)
.height(minHeight),
modifier = modifier,
enabled = enabled,
rounding = rounding,
color = buttonColors.backgroundColor(enabled).value,
Expand All @@ -62,6 +59,10 @@ internal fun YdsBaseButton(
ProvideTextStyle(value = YdsTheme.typography.button2) {
Row(
modifier = Modifier
.defaultMinSize(
minWidth = minWidth,
minHeight = minHeight,
)
.padding(contentPadding),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yourssu.design.system.compose.components
package com.yourssu.design.system.compose.component

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -22,9 +22,9 @@ import com.yourssu.design.system.compose.base.YdsText

@Composable
fun DoubleTitleTopBar(
modifier: Modifier = Modifier,
title: String = "",
subtitle: String = "",
modifier: Modifier = Modifier,
actions: @Composable RowScope.() -> Unit = {},
) {
TopAppBar(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yourssu.design.system.compose.components
package com.yourssu.design.system.compose.component

import android.widget.Toast
import androidx.compose.foundation.interaction.MutableInteractionSource
Expand Down Expand Up @@ -29,9 +29,9 @@ import com.yourssu.design.system.compose.base.YdsScaffold

@Composable
fun SearchTopBar(
modifier: Modifier = Modifier,
text: String = "",
placeHolderText: String = "",
modifier: Modifier = Modifier,
isDisabled: Boolean = false,
onValueChange: (String) -> Unit,
onSearch: () -> Unit,
Expand Down Expand Up @@ -65,6 +65,7 @@ fun SearchTopBar(
interactionSource = interactionSource,
modifier = Modifier
.padding(start = 4.dp, end = 16.dp)
.fillMaxWidth()
.align(alignment = CenterVertically),
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yourssu.design.system.compose.components
package com.yourssu.design.system.compose.component

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
Expand All @@ -9,13 +9,10 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.yourssu.design.system.compose.R
Expand All @@ -26,8 +23,8 @@ import com.yourssu.design.system.compose.base.YdsText

@Composable
fun SingleTitleTopBar(
title: String = "",
modifier: Modifier = Modifier,
title: String = "",
actions: @Composable RowScope.() -> Unit = {},
) {
TopAppBar(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yourssu.design.system.compose.components
package com.yourssu.design.system.compose.component

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
Expand All @@ -8,7 +8,6 @@ import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
Expand All @@ -23,8 +22,8 @@ import com.yourssu.design.system.compose.base.YdsText

@Composable
fun TopBar(
title: String = "",
modifier: Modifier = Modifier,
title: String = "",
navigationIcon: @Composable () -> Unit = {},
actions: @Composable RowScope.() -> Unit = {},
) {
Expand Down

0 comments on commit 0240b01

Please sign in to comment.