Skip to content

Commit 14d345e

Browse files
committed
[refactor]: 장르 칩 UI 깨짐 수정 (#127)
1 parent e2ac9d9 commit 14d345e

File tree

2 files changed

+103
-23
lines changed

2 files changed

+103
-23
lines changed
Lines changed: 99 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
package com.texthip.thip.ui.common.buttons
22

3+
import android.annotation.SuppressLint
34
import androidx.compose.foundation.layout.Arrangement
5+
import androidx.compose.foundation.layout.Column
46
import androidx.compose.foundation.layout.Row
57
import androidx.compose.foundation.layout.Spacer
68
import androidx.compose.foundation.layout.fillMaxWidth
9+
import androidx.compose.foundation.layout.height
710
import androidx.compose.foundation.layout.width
811
import androidx.compose.foundation.shape.RoundedCornerShape
912
import androidx.compose.runtime.Composable
13+
import androidx.compose.ui.Alignment
1014
import androidx.compose.ui.Modifier
1115
import androidx.compose.ui.draw.clip
16+
import androidx.compose.ui.platform.LocalConfiguration
1217
import androidx.compose.ui.tooling.preview.Preview
1318
import androidx.compose.ui.unit.dp
1419
import com.texthip.thip.ui.theme.ThipTheme
1520

21+
@SuppressLint("ConfigurationScreenWidthHeight")
1622
@Composable
1723
fun GenreChipRow(
1824
modifier: Modifier = Modifier.width(4.dp),
@@ -21,35 +27,95 @@ fun GenreChipRow(
2127
onSelect: (Int) -> Unit,
2228
horizontalArrangement: Arrangement.Horizontal = Arrangement.Center
2329
) {
24-
Row(
25-
modifier = Modifier.fillMaxWidth(),
26-
horizontalArrangement = horizontalArrangement
27-
) {
28-
genres.forEachIndexed { idx, genre ->
29-
OptionChipButton(
30-
modifier = Modifier
31-
.clip(RoundedCornerShape(20.dp)), // 버튼 모양에 맞게 클리핑
32-
text = genre,
33-
isFilled = true,
34-
isSelected = selectedIndex == idx,
35-
onClick = {
36-
if (selectedIndex == idx) {
37-
onSelect(-1)
38-
} else {
39-
onSelect(idx)
30+
val configuration = LocalConfiguration.current
31+
val screenWidthDp = configuration.screenWidthDp
32+
33+
if (screenWidthDp < 360) {
34+
Column(
35+
horizontalAlignment = Alignment.CenterHorizontally,
36+
modifier = Modifier.fillMaxWidth()
37+
) {
38+
Row(
39+
horizontalArrangement = Arrangement.Center
40+
) {
41+
genres.take(3).forEachIndexed { idx, genre ->
42+
OptionChipButton(
43+
modifier = Modifier
44+
.clip(RoundedCornerShape(20.dp)),
45+
text = genre,
46+
isFilled = true,
47+
isSelected = selectedIndex == idx,
48+
onClick = {
49+
if (selectedIndex == idx) {
50+
onSelect(-1)
51+
} else {
52+
onSelect(idx)
53+
}
54+
}
55+
)
56+
if (idx < 2) {
57+
Spacer(modifier = modifier)
58+
}
59+
}
60+
}
61+
Spacer(modifier = Modifier.height(8.dp))
62+
63+
Row(
64+
horizontalArrangement = Arrangement.Center
65+
) {
66+
genres.drop(3).forEachIndexed { relativeIdx, genre ->
67+
val idx = relativeIdx + 3
68+
OptionChipButton(
69+
modifier = Modifier
70+
.clip(RoundedCornerShape(20.dp)),
71+
text = genre,
72+
isFilled = true,
73+
isSelected = selectedIndex == idx,
74+
onClick = {
75+
if (selectedIndex == idx) {
76+
onSelect(-1)
77+
} else {
78+
onSelect(idx)
79+
}
80+
}
81+
)
82+
if (relativeIdx < genres.drop(3).size - 1) {
83+
Spacer(modifier = modifier)
4084
}
4185
}
42-
)
43-
if (idx < genres.size - 1) {
44-
Spacer(modifier = modifier)
86+
}
87+
}
88+
} else {
89+
Row(
90+
modifier = Modifier.fillMaxWidth(),
91+
horizontalArrangement = horizontalArrangement
92+
) {
93+
genres.forEachIndexed { idx, genre ->
94+
OptionChipButton(
95+
modifier = Modifier
96+
.clip(RoundedCornerShape(20.dp)),
97+
text = genre,
98+
isFilled = true,
99+
isSelected = selectedIndex == idx,
100+
onClick = {
101+
if (selectedIndex == idx) {
102+
onSelect(-1)
103+
} else {
104+
onSelect(idx)
105+
}
106+
}
107+
)
108+
if (idx < genres.size - 1) {
109+
Spacer(modifier = modifier)
110+
}
45111
}
46112
}
47113
}
48114
}
49115

50-
@Preview()
116+
@Preview(name = "Normal Screen (>=360dp)", widthDp = 400)
51117
@Composable
52-
fun PreviewGenreChipRow() {
118+
fun PreviewGenreChipRowNormal() {
53119
ThipTheme {
54120
GenreChipRow(
55121
genres = listOf("문학", "과학·IT", "사회과학", "인문학", "예술"),
@@ -58,3 +124,15 @@ fun PreviewGenreChipRow() {
58124
)
59125
}
60126
}
127+
128+
@Preview(name = "Small Screen (<360dp)", widthDp = 320)
129+
@Composable
130+
fun PreviewGenreChipRowSmall() {
131+
ThipTheme {
132+
GenreChipRow(
133+
genres = listOf("문학", "과학·IT", "사회과학", "인문학", "예술"),
134+
selectedIndex = 2,
135+
onSelect = {}
136+
)
137+
}
138+
}

app/src/main/java/com/texthip/thip/ui/group/myroom/component/GroupDeadlineRoomSection.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,16 @@ fun GroupRoomDeadlineSection(
113113
),
114114
shape = RoundedCornerShape(14.dp)
115115
)
116-
.padding(vertical = 20.dp, horizontal = 20.dp)
116+
.padding(vertical = 20.dp)
117117
) {
118118
Column(
119119
horizontalAlignment = Alignment.CenterHorizontally
120120
) {
121121
Text(
122122
text = sectionTitle,
123123
style = typography.title_b700_s20_h24,
124-
color = colors.White
124+
color = colors.White,
125+
modifier = Modifier.padding(horizontal = 20.dp)
125126
)
126127
Spacer(Modifier.height(40.dp))
127128

@@ -137,6 +138,7 @@ fun GroupRoomDeadlineSection(
137138
modifier = Modifier
138139
.fillMaxWidth()
139140
.height(584.dp)
141+
.padding(horizontal = 20.dp)
140142
) {
141143
when {
142144
// 에러 상태

0 commit comments

Comments
 (0)