Skip to content

Commit 23c94fa

Browse files
authored
Merge pull request #49 from Nico1eKim/ui/#34-group_note_create_page
[UI] 기록장 상세 페이지 구현 완료
2 parents 6fa3d25 + 01c17d5 commit 23c94fa

13 files changed

Lines changed: 818 additions & 116 deletions

File tree

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fun ExpandableFloatingButton(
6565
) {
6666
Column(
6767
modifier = Modifier
68-
.padding(bottom = 94.dp, end = 20.dp)
68+
.padding(bottom = 62.dp)
6969
.width(184.dp)
7070
.background(
7171
color = colors.Black,
@@ -100,8 +100,7 @@ fun ExpandableFloatingButton(
100100
contentColor = colors.NeonGreen,
101101
shape = CircleShape,
102102
modifier = Modifier
103-
.padding(16.dp)
104-
.size(56.dp)
103+
.size(50.dp)
105104
.border(width = 2.dp, color = colors.NeonGreen50, shape = CircleShape)
106105
) {
107106
Icon(

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.texthip.thip.ui.common.buttons
22

33
import androidx.compose.foundation.layout.Column
44
import androidx.compose.foundation.layout.fillMaxSize
5+
import androidx.compose.foundation.layout.height
56
import androidx.compose.foundation.layout.padding
67
import androidx.compose.material3.Icon
78
import androidx.compose.material3.Switch
@@ -22,20 +23,26 @@ import com.texthip.thip.ui.theme.ThipTheme.colors
2223
@Composable
2324
fun ToggleSwitchButton(
2425
isChecked: Boolean,
26+
enabled: Boolean = true,
2527
onToggleChange: (Boolean) -> Unit
2628
) {
27-
//var isChecked by remember { mutableStateOf(true) }
2829
Switch(
29-
modifier = Modifier.padding(4.dp),
30+
modifier = Modifier.height(30.dp),
3031
checked = isChecked,
3132
onCheckedChange = onToggleChange,
3233
colors = SwitchDefaults.colors(
3334
checkedThumbColor = colors.White,
35+
disabledCheckedThumbColor = colors.White,
3436
checkedTrackColor = colors.Purple,
37+
disabledCheckedTrackColor = colors.Purple,
3538
uncheckedThumbColor = colors.White,
39+
disabledUncheckedThumbColor = colors.White,
3640
uncheckedTrackColor = colors.DarkGrey,
41+
disabledUncheckedTrackColor = colors.DarkGrey,
3742
uncheckedBorderColor = Color.Transparent,
43+
disabledUncheckedBorderColor = Color.Transparent,
3844
),
45+
enabled = enabled,
3946
thumbContent = {
4047
Icon(
4148
painter = painterResource(R.drawable.ic_circle),

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

Lines changed: 65 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package com.texthip.thip.ui.common.forms
22

33

4+
import androidx.compose.foundation.border
45
import androidx.compose.foundation.clickable
56
import androidx.compose.foundation.layout.Box
67
import androidx.compose.foundation.layout.Column
7-
import androidx.compose.foundation.layout.Spacer
88
import androidx.compose.foundation.layout.height
9+
import androidx.compose.foundation.layout.padding
910
import androidx.compose.foundation.layout.size
1011
import androidx.compose.foundation.shape.RoundedCornerShape
1112
import androidx.compose.foundation.text.KeyboardOptions
@@ -41,79 +42,93 @@ import com.texthip.thip.ui.theme.ThipTheme.typography
4142
@Composable
4243
fun BookPageTextField(
4344
modifier: Modifier = Modifier,
44-
bookPage: Int
45+
bookTotalPage: Int,
46+
enabled: Boolean = true,
47+
text: String,
48+
onValueChange: (String) -> Unit,
4549
) {
46-
var text by rememberSaveable { mutableStateOf("") }
4750
var isError by rememberSaveable { mutableStateOf(false) }
4851
var errorMessageRes by rememberSaveable { mutableStateOf<Int?>(null) }
49-
var errorMessageParam by rememberSaveable { mutableStateOf(0) }
5052

5153
Column {
5254
OutlinedTextField(
5355
value = text,
5456
onValueChange = { newText: String ->
5557
if (newText.isEmpty() || newText.all { it.isDigit() }) {
56-
text = newText
58+
onValueChange(newText)
59+
5760
if (newText.isNotEmpty()) {
5861
val pageNum = newText.toInt()
59-
isError = pageNum > bookPage
60-
if (isError) {
61-
errorMessageRes = R.string.error_page_over
62-
errorMessageParam = bookPage
62+
isError = pageNum > bookTotalPage
63+
errorMessageRes = if (isError) {
64+
R.string.error_page_over
6365
} else {
64-
errorMessageRes = null
66+
null
6567
}
6668
} else {
6769
isError = false
6870
errorMessageRes = null
6971
}
7072
}
7173
},
72-
visualTransformation = SuffixTransformation(
73-
suffix = "/${bookPage}p",
74-
suffixColor = colors.Grey02
75-
),
74+
enabled = enabled,
75+
visualTransformation = if (enabled) {
76+
SuffixTransformation("/${bookTotalPage}p", colors.Grey02)
77+
} else {
78+
VisualTransformation.None
79+
},
7680
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
77-
modifier = modifier.size(width = 320.dp, height = 48.dp),
81+
modifier = modifier
82+
.size(width = 320.dp, height = 48.dp)
83+
.then(
84+
if (isError)
85+
Modifier.border(
86+
width = 1.dp,
87+
color = colors.Red,
88+
shape = RoundedCornerShape(12.dp)
89+
)
90+
else Modifier
91+
),
7892
textStyle = typography.menu_r400_s14_h24.copy(lineHeight = 12.sp),
7993
maxLines = 1,
8094
shape = RoundedCornerShape(12.dp),
8195
colors = TextFieldDefaults.colors(
8296
focusedTextColor = colors.White,
83-
focusedIndicatorColor = if (isError) colors.Red else Color.Transparent,
84-
unfocusedIndicatorColor = if (isError) colors.Red else Color.Transparent,
85-
focusedContainerColor = colors.Black,
86-
unfocusedContainerColor = colors.Black,
87-
cursorColor = colors.NeonGreen
97+
unfocusedTextColor = colors.White,
98+
disabledTextColor = colors.White,
99+
focusedIndicatorColor = Color.Transparent,
100+
unfocusedIndicatorColor = Color.Transparent,
101+
disabledIndicatorColor = Color.Transparent,
102+
focusedContainerColor = colors.DarkGrey02,
103+
unfocusedContainerColor = colors.DarkGrey02,
104+
disabledContainerColor = colors.DarkGrey02,
105+
cursorColor = colors.NeonGreen,
88106
),
89107
trailingIcon = {
90-
if (text.isNotEmpty()) {
91-
Icon(
92-
painter = painterResource(id = R.drawable.ic_x_circle_white),
93-
contentDescription = "Clear text",
94-
modifier = Modifier.clickable {
95-
text = ""
108+
Icon(
109+
painter = painterResource(id = R.drawable.ic_x_circle_grey),
110+
contentDescription = "Clear text",
111+
modifier = Modifier.clickable {
112+
if (text.isNotEmpty()) {
113+
onValueChange("")
96114
isError = false
97115
errorMessageRes = null
98-
},
99-
tint = Color.Unspecified
100-
)
101-
} else {
102-
Icon(
103-
painter = painterResource(id = R.drawable.ic_x_circle),
104-
contentDescription = "Clear text"
105-
)
106-
}
116+
}
117+
},
118+
tint = Color.Unspecified
119+
)
107120
}
108121
)
109122

110-
if (isError && errorMessageRes != null) {
111-
Spacer(modifier = Modifier.height(4.dp))
112-
Text(
113-
text = stringResource(id = errorMessageRes!!, errorMessageParam),
114-
color = colors.Red,
115-
style = typography.menu_r400_s14_h24.copy(lineHeight = 12.sp)
116-
)
123+
Box(modifier = Modifier.height(22.dp)) {
124+
if (isError && errorMessageRes != null) {
125+
Text(
126+
modifier = Modifier.padding(start = 4.dp, top = 8.dp),
127+
text = stringResource(id = errorMessageRes!!),
128+
color = colors.Red,
129+
style = typography.menu_r400_s14_h24.copy(lineHeight = 12.sp)
130+
)
131+
}
117132
}
118133
}
119134
}
@@ -135,6 +150,7 @@ class SuffixTransformation(
135150
val offsetMapping = object : OffsetMapping {
136151
override fun originalToTransformed(offset: Int): Int =
137152
offset.coerceAtMost(original.length)
153+
138154
override fun transformedToOriginal(offset: Int): Int =
139155
offset.coerceAtMost(original.length)
140156
}
@@ -147,12 +163,18 @@ class SuffixTransformation(
147163
@Composable
148164
@Preview(showBackground = true, backgroundColor = 0xFF000000, widthDp = 360, heightDp = 200)
149165
fun BookPageTextFieldPreviewEmpty() {
166+
var text by rememberSaveable { mutableStateOf("") }
167+
150168
Box(
151169
modifier = Modifier.size(width = 360.dp, height = 200.dp),
152170
contentAlignment = Alignment.Center
153171
) {
154172
BookPageTextField(
155-
bookPage = 456
173+
bookTotalPage = 456,
174+
text = text,
175+
onValueChange = {
176+
text = it
177+
}
156178
)
157179
}
158180
}

0 commit comments

Comments
 (0)