Skip to content

Commit 1f96018

Browse files
authored
Merge branch 'develop' into ui/#33-group_note_page
2 parents 144bd28 + 47da341 commit 1f96018

36 files changed

Lines changed: 1057 additions & 246 deletions

.idea/gradle.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/texthip/thip/ui/bookSearch/screen/BookSearchScreen.kt renamed to app/src/main/java/com/texthip/thip/ui/booksearch/screen/BookSearchScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.texthip.thip.ui.bookSearch.screen
1+
package com.texthip.thip.ui.booksearch.screen
22

33
import androidx.compose.foundation.layout.Box
44
import androidx.compose.foundation.layout.fillMaxSize

app/src/main/java/com/texthip/thip/ui/common/buttons/ActionMediumButton.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.fillMaxSize
1010
import androidx.compose.foundation.layout.fillMaxWidth
1111
import androidx.compose.foundation.layout.height
1212
import androidx.compose.foundation.layout.padding
13+
import androidx.compose.foundation.layout.size
1314
import androidx.compose.foundation.layout.width
1415
import androidx.compose.foundation.shape.RoundedCornerShape
1516
import androidx.compose.material3.Icon
@@ -31,6 +32,8 @@ import com.texthip.thip.ui.theme.ThipTheme.typography
3132
fun ActionMediumButton(
3233
text: String,
3334
icon: Painter? = null,
35+
iconSize: Int = 24,
36+
iconTint: Color = Color.Unspecified,
3437
contentColor: Color,
3538
backgroundColor: Color,
3639
hasRightIcon: Boolean = false,
@@ -54,7 +57,8 @@ fun ActionMediumButton(
5457
Icon(
5558
painter = icon,
5659
contentDescription = null,
57-
tint = contentColor,
60+
tint = iconTint,
61+
modifier = Modifier.size(iconSize.dp)
5862
)
5963
}
6064

app/src/main/java/com/texthip/thip/ui/common/forms/WarningTextField.kt

Lines changed: 112 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ package com.texthip.thip.ui.common.forms
22

33
import androidx.compose.foundation.clickable
44
import androidx.compose.foundation.layout.Box
5+
import androidx.compose.foundation.layout.Column
56
import androidx.compose.foundation.layout.Spacer
7+
import androidx.compose.foundation.layout.fillMaxSize
68
import androidx.compose.foundation.layout.fillMaxWidth
79
import androidx.compose.foundation.layout.height
10+
import androidx.compose.foundation.layout.padding
811
import androidx.compose.foundation.layout.size
912
import androidx.compose.foundation.shape.RoundedCornerShape
1013
import androidx.compose.foundation.text.KeyboardOptions
@@ -16,6 +19,7 @@ import androidx.compose.runtime.Composable
1619
import androidx.compose.runtime.getValue
1720
import androidx.compose.runtime.mutableStateOf
1821
import androidx.compose.runtime.remember
22+
import androidx.compose.runtime.saveable.rememberSaveable
1923
import androidx.compose.runtime.setValue
2024
import androidx.compose.ui.Alignment
2125
import androidx.compose.ui.Modifier
@@ -37,93 +41,139 @@ fun WarningTextField(
3741
hint: String,
3842
warningMessage: String = "경고 메시지를 입력해주세요.",
3943
showWarning: Boolean = false,
44+
showLimit: Boolean = true,
4045
maxLength: Int = Int.MAX_VALUE,
46+
showIcon: Boolean = false,
47+
containerColor: Color = colors.Black,
4148
isNumberOnly: Boolean = false,
4249
keyboardType: KeyboardType = KeyboardType.Text
4350
) {
4451
val myStyle = typography.menu_r400_s14_h24.copy(lineHeight = 14.sp)
45-
OutlinedTextField(
46-
value = value,
47-
onValueChange = { input ->
48-
var filtered = input
49-
if (isNumberOnly) filtered = filtered.filter { it.isDigit() }
50-
if (filtered.length > maxLength) filtered = filtered.take(maxLength)
51-
onValueChange(filtered)
52-
},
53-
placeholder = {
54-
Text(
55-
text = hint,
56-
color = colors.Grey02,
57-
style = myStyle
52+
53+
Column {
54+
Box(
55+
modifier = modifier
56+
.height(48.dp)
57+
) {
58+
OutlinedTextField(
59+
value = value,
60+
onValueChange = { input ->
61+
var filtered = input
62+
if (isNumberOnly) filtered = filtered.filter { it.isDigit() }
63+
if (filtered.length > maxLength) filtered = filtered.take(maxLength)
64+
onValueChange(filtered)
65+
},
66+
placeholder = {
67+
Text(
68+
text = hint,
69+
color = colors.Grey02,
70+
style = myStyle
71+
)
72+
},
73+
textStyle = myStyle,
74+
modifier = Modifier.fillMaxSize(),
75+
shape = RoundedCornerShape(12.dp),
76+
colors = TextFieldDefaults.colors(
77+
focusedTextColor = colors.White,
78+
focusedIndicatorColor = if (showWarning) colors.Red else Color.Transparent,
79+
unfocusedIndicatorColor = if (showWarning) colors.Red else Color.Transparent,
80+
focusedContainerColor = containerColor,
81+
unfocusedContainerColor = containerColor,
82+
cursorColor = colors.NeonGreen
83+
),
84+
trailingIcon = {
85+
if (showIcon) {
86+
if (value.isNotEmpty()) {
87+
Icon(
88+
painter = painterResource(id = R.drawable.ic_x_circle_white),
89+
contentDescription = "Clear text",
90+
modifier = Modifier.clickable { onValueChange("")},
91+
tint = Color.Unspecified
92+
)
93+
} else {
94+
Icon(
95+
painter = painterResource(id = R.drawable.ic_x_circle),
96+
contentDescription = "Clear text"
97+
)
98+
}
99+
}
100+
},
101+
singleLine = true,
102+
keyboardOptions = KeyboardOptions(keyboardType = keyboardType)
103+
58104
)
59-
},
60-
textStyle = myStyle,
61-
modifier = modifier
62-
.fillMaxWidth()
63-
.height(48.dp),
64-
shape = RoundedCornerShape(12.dp),
65-
colors = TextFieldDefaults.colors(
66-
focusedTextColor = colors.White,
67-
focusedIndicatorColor = if (showWarning) colors.Red else Color.Transparent,
68-
unfocusedIndicatorColor = if (showWarning) colors.Red else Color.Transparent,
69-
focusedContainerColor = colors.DarkGrey50,
70-
unfocusedContainerColor = colors.DarkGrey50,
71-
cursorColor = colors.NeonGreen
72-
),
73-
trailingIcon = {
74-
if (value.isNotEmpty()) {
75-
Icon(
76-
painter = painterResource(id = R.drawable.ic_x_circle_white),
77-
contentDescription = "Clear text",
78-
modifier = Modifier.clickable { onValueChange("") },
79-
tint = Color.Unspecified
80-
)
81-
} else {
82-
Icon(
83-
painter = painterResource(id = R.drawable.ic_x_circle),
84-
contentDescription = "Clear text"
85-
)
105+
106+
if (showLimit && maxLength != Int.MAX_VALUE) {
107+
Box(
108+
modifier = Modifier
109+
.align(Alignment.CenterEnd)
110+
.padding(end = 14.dp)
111+
) {
112+
Text(
113+
text = "${value.length}/$maxLength",
114+
color = colors.White,
115+
style = typography.info_r400_s12_h24
116+
)
117+
}
86118
}
87-
},
88-
singleLine = true,
89-
keyboardOptions = KeyboardOptions(keyboardType = keyboardType)
90-
)
91-
if (showWarning) {
92-
Spacer(modifier = Modifier.height(4.dp))
93-
Text(
94-
text = warningMessage,
95-
color = colors.Red,
96-
style = typography.info_r400_s12.copy(lineHeight = 12.sp)
97-
)
119+
}
120+
if (showWarning) {
121+
Spacer(modifier = Modifier.height(4.dp))
122+
Text(
123+
text = warningMessage,
124+
color = colors.Red,
125+
style = typography.info_r400_s12.copy(lineHeight = 12.sp)
126+
)
127+
}
98128
}
99129
}
100130

101-
102131
@Composable
103132
@Preview(showBackground = true, backgroundColor = 0xFF000000, widthDp = 360, heightDp = 200)
104133
fun WarningTextFieldPreviewEmpty() {
105-
var password by remember { mutableStateOf("") }
134+
var text by rememberSaveable { mutableStateOf("") }
106135

107136
Box(
108137
modifier = Modifier.size(width = 360.dp, height = 200.dp),
109138
contentAlignment = Alignment.Center
110139
) {
111140
WarningTextField(
112-
value = password,
113-
onValueChange = { password = it },
114-
hint = "4자리 숫자로 입장 비밀번호를 설정",
115-
showWarning = password.isNotEmpty() && password.length < 4,
116-
warningMessage = "4자리 숫자를 입력해주세요.",
117-
maxLength = 4,
118-
isNumberOnly = true,
119-
keyboardType = KeyboardType.NumberPassword
141+
value = text,
142+
onValueChange = { text = it },
143+
hint = "인풋 텍스트",
144+
showWarning = true,
145+
showIcon = false,
146+
showLimit = true,
147+
maxLength = 10,
148+
warningMessage = "경고 메시지를 입력해주세요."
120149
)
121150
}
122151
}
123152

124153
@Composable
125154
@Preview(showBackground = true, backgroundColor = 0xFF000000, widthDp = 360, heightDp = 200)
126155
fun WarningTextFieldPreviewNormal() {
156+
var text by rememberSaveable { mutableStateOf("") }
157+
158+
Box(
159+
modifier = Modifier.size(width = 360.dp, height = 200.dp),
160+
contentAlignment = Alignment.Center
161+
) {
162+
WarningTextField(
163+
164+
value = text,
165+
onValueChange = { text = it },
166+
hint = "인풋 텍스트",
167+
showWarning = false,
168+
showIcon = true,
169+
showLimit = false
170+
)
171+
}
172+
}
173+
174+
@Composable
175+
@Preview(showBackground = true, backgroundColor = 0xFF000000, widthDp = 360, heightDp = 200)
176+
fun WarningTextFieldPreviewNormal_numberonly() {
127177
var password by remember { mutableStateOf("") }
128178

129179
Box(
@@ -141,4 +191,4 @@ fun WarningTextFieldPreviewNormal() {
141191
keyboardType = KeyboardType.NumberPassword
142192
)
143193
}
144-
}
194+
}

app/src/main/java/com/texthip/thip/ui/common/header/AuthorHeader.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.Column
99
import androidx.compose.foundation.layout.Row
1010
import androidx.compose.foundation.layout.Spacer
1111
import androidx.compose.foundation.layout.fillMaxWidth
12+
import androidx.compose.foundation.layout.height
1213
import androidx.compose.foundation.layout.padding
1314
import androidx.compose.foundation.layout.size
1415
import androidx.compose.foundation.layout.width
@@ -23,6 +24,7 @@ import androidx.compose.ui.graphics.Color
2324
import androidx.compose.ui.graphics.painter.Painter
2425
import androidx.compose.ui.res.stringResource
2526
import androidx.compose.ui.tooling.preview.Preview
27+
import androidx.compose.ui.unit.Dp
2628
import androidx.compose.ui.unit.dp
2729
import com.texthip.thip.ui.theme.ThipTheme
2830
import com.texthip.thip.ui.theme.ThipTheme.colors
@@ -38,6 +40,7 @@ fun AuthorHeader(
3840
nickname: String,
3941
badgeText: String,
4042
buttonText: String,
43+
buttonWidth: Dp? = null,
4144
onButtonClick: () -> Unit = {}
4245
) {
4346
Row(
@@ -81,9 +84,15 @@ fun AuthorHeader(
8184
}
8285
OutlinedButton(
8386
modifier = Modifier
84-
.size(width = 51.dp, height = 35.dp),
87+
.then(
88+
if (buttonWidth != null)
89+
Modifier
90+
.width(buttonWidth)
91+
.height(33.dp)
92+
else Modifier
93+
),
8594
text = buttonText,
86-
textStyle = typography.menu_m500_s14_h24,
95+
textStyle = typography.view_m500_s14,
8796
onClick = onButtonClick
8897
)
8998
}
@@ -97,7 +106,8 @@ fun PreviewAuthorHeader() {
97106
profileImage = null,
98107
nickname = "열자자제한열열자제한",
99108
badgeText = "칭호칭호칭호",
100-
buttonText = "구독"
109+
buttonText = "구독",
110+
buttonWidth = 60.dp
101111
)
102112
}
103113
}

app/src/main/java/com/texthip/thip/ui/common/header/ProfileBar.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fun ProfileBar(
3939
bottomTextColor: Color = colors.NeonGreen, // todo: 서버에서 색 보내주는걸로 받기?
4040
showSubscriberInfo: Boolean,
4141
subscriberCount: Int = 0,
42-
hoursAgo: Int = 0,
42+
hoursAgo: String = "",
4343
onClick: () -> Unit = { }
4444
) {
4545
Row(
@@ -105,7 +105,7 @@ fun ProfileBar(
105105
}
106106
} else {
107107
Text(
108-
text = stringResource(R.string.hours_ago, hoursAgo),
108+
text = hoursAgo,
109109
style = typography.timedate_r400_s11,
110110
color = colors.Grey01
111111
)
@@ -130,7 +130,7 @@ fun PreviewProfileBar() {
130130
topText = "user.04",
131131
bottomText = stringResource(R.string.influencer),
132132
showSubscriberInfo = false,
133-
hoursAgo = 7
133+
hoursAgo = "10시간 전"
134134
)
135135
}
136136
}

app/src/main/java/com/texthip/thip/ui/common/modal/ToastWithDate.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import com.texthip.thip.ui.theme.ThipTheme.typography
2525
fun ToastWithDate(
2626
modifier: Modifier = Modifier,
2727
message: String,
28-
date: String
28+
date: String? = null
2929
) {
3030
Box(
3131
modifier = modifier
@@ -41,18 +41,20 @@ fun ToastWithDate(
4141
Row(
4242
modifier = Modifier.fillMaxWidth(),
4343
verticalAlignment = Alignment.CenterVertically,
44-
horizontalArrangement = Arrangement.SpaceBetween
44+
horizontalArrangement = if (date != null) Arrangement.SpaceBetween else Arrangement.Start
4545
) {
4646
Text(
4747
text = message,
4848
color = colors.White,
4949
style = typography.view_m500_s12_h20
5050
)
51-
Text(
52-
text = date,
53-
color = colors.Grey02,
54-
style = typography.timedate_r400_s11
55-
)
51+
if (date != null) {
52+
Text(
53+
text = date,
54+
color = colors.Grey02,
55+
style = typography.timedate_r400_s11
56+
)
57+
}
5658
}
5759
}
5860
}

0 commit comments

Comments
 (0)