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

[feature/#12] 공통 아이콘 제작 #13

Merged
merged 13 commits into from
Jan 10, 2025
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
package com.wearerommies.roomie.presentation.core.component

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.wearerommies.roomie.R
import com.wearerommies.roomie.presentation.core.extension.noRippleClickable
import com.wearerommies.roomie.ui.theme.RoomieAndroidTheme
import com.wearerommies.roomie.ui.theme.RoomieTheme

@Composable
fun RoomieTextChip(
text: String,
modifier: Modifier = Modifier,
textStyle: TextStyle = RoomieTheme.typography.body3M14,
textColor: Color = RoomieTheme.colors.primary,
backgroundColor: Color = RoomieTheme.colors.primaryLight4,
onClick: () -> Unit = {},
) {
Text(
modifier = modifier
.background(color = backgroundColor, shape = RoundedCornerShape(size = 4.dp))
.noRippleClickable {
onClick()
}
.padding(horizontal = 8.dp, vertical = 4.dp),
text = text,
style = textStyle,
color = textColor,
textAlign = TextAlign.Center
)
}

@Composable
fun RoomieTextWithDotChip(
firstText: String,
secondText: String,
modifier: Modifier = Modifier,
textStyle: TextStyle = RoomieTheme.typography.body4R12,
contentColor: Color = RoomieTheme.colors.primary,
backgroundColor: Color = RoomieTheme.colors.primaryLight4,
onClick: () -> Unit = {},
) {
Row(
modifier = modifier
.background(color = backgroundColor, shape = RoundedCornerShape(size = 4.dp))
.noRippleClickable {
onClick()
}
.padding(horizontal = 8.dp, vertical = 4.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(2.dp, alignment = Alignment.CenterHorizontally),
) {
Text(
text = firstText,
style = textStyle,
color = contentColor
)
Icon(
painter = painterResource(R.drawable.ic_middle_dot),
contentDescription = "dot",
tint = contentColor
)
Text(
text = secondText,
style = textStyle,
color = contentColor
)
}
}

@Composable
fun RoomieOutlinedChip(
Copy link
Collaborator

Choose a reason for hiding this comment

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

네이밍 센스 죽인다...

text: String,
modifier: Modifier = Modifier,
textStyle: TextStyle = RoomieTheme.typography.caption2Sb10,
textColor: Color = RoomieTheme.colors.grayScale7,
borderColor: Color = RoomieTheme.colors.grayScale5,
backgroundColor: Color = RoomieTheme.colors.grayScale3,
onClick: () -> Unit = {},
) {
Text(
modifier = modifier
.width((LocalConfiguration.current.screenWidthDp * 0.106).dp)
Copy link
Collaborator

@hyeeum hyeeum Jan 10, 2025

Choose a reason for hiding this comment

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

엇 그런데 아래에서 패딩값을 선언해줘서 이 width는 필요없지 않나요??

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

피그마에 있는거로 봐선 글자수에 상관없이 같은 width를 의도하신 것 같은데 width 지정을 안하면 width가 각자 따로 놀더라구용 그래서 지정해줬습니다!!

Copy link
Collaborator

Choose a reason for hiding this comment

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

아하 고정이었군요!! 꼼꼼해서 좋으다.. :)

.border(width = 1.dp, color = borderColor, shape = RoundedCornerShape(size = 4.dp))
.background(color = backgroundColor, shape = RoundedCornerShape(size = 4.dp))
.noRippleClickable {
onClick()
}
.padding(horizontal = 6.dp, vertical = 4.dp),
text = text,
style = textStyle,
color = textColor,
textAlign = TextAlign.Center
)
}

@Composable
fun RoomieHouseNameChip(
text: String,
modifier: Modifier = Modifier,
textStyle: TextStyle = RoomieTheme.typography.body6M12,
textColor: Color = RoomieTheme.colors.primary,
borderColor: Color = RoomieTheme.colors.primaryLight2,
backgroundColor: Color = RoomieTheme.colors.primaryLight5,
onClick: () -> Unit = {},
) {
Text(
modifier = modifier
.width((LocalConfiguration.current.screenWidthDp * 0.275).dp)
.border(width = 1.dp, color = borderColor, shape = RoundedCornerShape(size = 4.dp))
.background(color = backgroundColor, shape = RoundedCornerShape(size = 4.dp))
.noRippleClickable {
onClick()
}
.padding(horizontal = 12.dp, vertical = 4.dp),
text = text,
style = textStyle,
color = textColor,
textAlign = TextAlign.Center
)
}

@Preview
@Composable
private fun RoomieChipPreview() {
RoomieAndroidTheme {
Column(
verticalArrangement = Arrangement.spacedBy(space = 4.dp)
) {
//map 칩
RoomieTextChip(
text = "#차분한",
textStyle = RoomieTheme.typography.body4R12,
textColor = RoomieTheme.colors.grayScale9,
backgroundColor = Color(0xFFF3F1F1)
)

//detail 칩
RoomieTextChip(
text = "#차분한",
)

//detail 칩
RoomieTextWithDotChip(
firstText = "성별",
secondText = "n인실",
Comment on lines +162 to +164
Copy link
Collaborator

Choose a reason for hiding this comment

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

하 여기 짧아져서 너무 마음이 편안해짐 ㅋㅋㅋㅋㅋㅋㅋㅋ

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

프리뷰 만들면서 이게 맞나 싶었는데 디폴트 지정하니 좋네여~!!!!

)

//도로명&지번 칩
RoomieOutlinedChip(
text = "도로명",
)

RoomieOutlinedChip(
text = "지번",
)

//쉐어하우스 이름 칩
RoomieHouseNameChip(
text = "쉐어하우스 이름"
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.wearerommies.roomie.presentation.core.component

import androidx.annotation.DrawableRes
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.wearerommies.roomie.R
import com.wearerommies.roomie.ui.theme.RoomieAndroidTheme
import com.wearerommies.roomie.ui.theme.RoomieTheme

@Composable
fun RoomieRoomAsset(
@DrawableRes imageDrawableId: Int,
text: String,
modifier: Modifier = Modifier,
textStyle: TextStyle = RoomieTheme.typography.caption1R10,
textColor: Color = RoomieTheme.colors.grayScale9,
) {
Column(
modifier = modifier
.padding(horizontal = 8.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(2.dp, alignment = Alignment.CenterVertically)
) {
Image(
painter = painterResource(id = imageDrawableId),
contentDescription = null,
modifier = Modifier
.size(32.dp)
.clip(CircleShape)
)

Text(
text = text,
style = textStyle,
color = textColor
)
}
}

@Preview
@Composable
private fun RoomieRoomAssetPreview() {
RoomieAndroidTheme {
RoomieRoomAsset(
imageDrawableId = R.drawable.ic_launcher_background,
text = "책상",
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.wearerommies.roomie.presentation.core.component

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.wearerommies.roomie.presentation.core.extension.noRippleClickable
import com.wearerommies.roomie.ui.theme.RoomieAndroidTheme
import com.wearerommies.roomie.ui.theme.RoomieTheme

@Composable
fun RoomieTag(
text: String,
modifier: Modifier = Modifier,
textStyle: TextStyle = RoomieTheme.typography.caption2Sb10,
textColor: Color = RoomieTheme.colors.primary,
backgroundColor: Color = RoomieTheme.colors.primaryLight4,
onClick: () -> Unit = {},
) {
Text(
modifier = modifier
.background(color = backgroundColor, shape = RoundedCornerShape(size = 8.dp))
.noRippleClickable {
onClick()
}
.padding(horizontal = 8.dp, vertical = 3.dp),
text = text,
style = textStyle,
color = textColor,
textAlign = TextAlign.Center
)
}

@Preview
@Composable
private fun RoomieTagPreview() {
RoomieAndroidTheme {
RoomieTag(
text = "입주 완료"
)
}
}
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_middle_dot.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="2dp"
android:height="2dp"
android:viewportWidth="2"
android:viewportHeight="2">
<path
android:pathData="M1,1m-1,0a1,1 0,1 1,2 0a1,1 0,1 1,-2 0"
android:fillColor="#626CF6"/>
</vector>