-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Attendance screen compose setting (#676) * feat: implement NewAttendanceActivity * feat: implement NewAttendanceViewModel * chore: add compose-lifecycle dependency * feat: define AttendanceAction * feat: implement screens * feat: use SoptTheme in designsystem * chore: data class -> class로 변경 * chore: 람다 프로퍼티 이름 명시 * chore: SoptTheme darkTheme 기본값 사용 * chore: 필요없는 함수 제거 * chore: 구현 안 된 함수에 TODO 삽입 * chore: 동작하지 않는 Preview 제거 * chore: AttendanceAction 내 뷰모델 참조 제거 * chore: code format 변경 * chore: make stamp design system internal * chore: extract string resource * feat: implement AttendanceCodeCard * feat: implement AttendanceCodeCardList * chore: change logic * feat: implement AttendanceCodeDialog * feat: implement attendance button * chore: string resource 추출 * chore: change parameter List to ImmutableList * chore: reformat codee # Conflicts: # core/designsystem/src/main/java/org/sopt/official/designsystem/Color.kt
- Loading branch information
1 parent
0dd4036
commit 04d414d
Showing
9 changed files
with
286 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
155 changes: 155 additions & 0 deletions
155
app/src/main/java/org/sopt/official/feature/attendance/compose/AttendanceCodeDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
package org.sopt.official.feature.attendance.compose | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.ButtonColors | ||
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.res.painterResource | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.tooling.preview.PreviewParameter | ||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.window.Dialog | ||
import kotlinx.collections.immutable.ImmutableList | ||
import kotlinx.collections.immutable.persistentListOf | ||
import org.sopt.official.R | ||
import org.sopt.official.designsystem.Black40 | ||
import org.sopt.official.designsystem.Gray60 | ||
import org.sopt.official.designsystem.SoptTheme | ||
import org.sopt.official.feature.attendance.compose.component.AttendanceCodeCardList | ||
import org.sopt.official.feature.attendance.model.AttendanceType | ||
|
||
@Composable | ||
fun AttendanceCodeDialog( | ||
codes: ImmutableList<String>, | ||
inputCodes: ImmutableList<String?>, | ||
attendanceType: AttendanceType, | ||
onDismissRequest: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Dialog(onDismissRequest = onDismissRequest) { | ||
Column( | ||
modifier | ||
.background( | ||
color = SoptTheme.colors.onSurface700, | ||
shape = RoundedCornerShape(size = 10.dp) | ||
) | ||
.padding(all = 16.dp), | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
Icon( | ||
painter = painterResource(id = R.drawable.ic_close), | ||
contentDescription = stringResource(id = R.string.close), | ||
tint = SoptTheme.colors.onSurface10, | ||
modifier = Modifier | ||
.align(Alignment.End) | ||
.clickable(onClick = onDismissRequest) | ||
) | ||
Text( | ||
text = stringResource(R.string.attendance_do, attendanceType.type), | ||
style = SoptTheme.typography.heading18B, | ||
color = SoptTheme.colors.onSurface10 | ||
) | ||
Spacer(modifier = Modifier.height(10.dp)) | ||
Text( | ||
text = stringResource(R.string.attendance_code_description), | ||
style = SoptTheme.typography.body13M, | ||
color = SoptTheme.colors.onSurface300 | ||
) | ||
Spacer(modifier = Modifier.height(24.dp)) | ||
AttendanceCodeCardList( | ||
codes = inputCodes, | ||
onTextChange = {}, | ||
onTextFieldFull = {}, | ||
) | ||
if (codes != inputCodes) { | ||
Spacer(modifier = Modifier.height(24.dp)) | ||
Text( | ||
text = stringResource(R.string.attendance_code_does_not_match), | ||
style = SoptTheme.typography.label12SB, | ||
color = SoptTheme.colors.error | ||
) | ||
} | ||
Spacer(modifier = Modifier.height(32.dp)) | ||
Button( | ||
onClick = { /*TODO*/ }, | ||
modifier = Modifier | ||
.fillMaxWidth(), | ||
shape = RoundedCornerShape(size = 6.dp), | ||
colors = ButtonColors( | ||
containerColor = SoptTheme.colors.onSurface10, | ||
contentColor = SoptTheme.colors.onSurface950, | ||
disabledContainerColor = Black40, | ||
disabledContentColor = Gray60, | ||
), | ||
enabled = codes == inputCodes | ||
) { | ||
Text( | ||
text = stringResource(R.string.attendance_dialog_button), | ||
style = SoptTheme.typography.body13M, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun AttendanceCodeDialogPreview( | ||
@PreviewParameter(AttendanceCodeDialogPreviewParameterProvider::class) parameter: AttendanceCodeDialogPreviewParameter, | ||
) { | ||
SoptTheme { | ||
AttendanceCodeDialog( | ||
codes = parameter.codes, | ||
inputCodes = parameter.inputCodes, | ||
attendanceType = parameter.attendanceType, | ||
modifier = Modifier.fillMaxWidth(), | ||
onDismissRequest = {} | ||
) | ||
} | ||
} | ||
|
||
data class AttendanceCodeDialogPreviewParameter( | ||
val codes: ImmutableList<String>, | ||
val inputCodes: ImmutableList<String?>, | ||
val attendanceType: AttendanceType, | ||
) | ||
|
||
class AttendanceCodeDialogPreviewParameterProvider : | ||
PreviewParameterProvider<AttendanceCodeDialogPreviewParameter> { | ||
override val values: Sequence<AttendanceCodeDialogPreviewParameter> = | ||
sequenceOf( | ||
AttendanceCodeDialogPreviewParameter( | ||
codes = persistentListOf("1", "2", "3", "4", "5"), | ||
inputCodes = persistentListOf("1", "2", "3", null, null), | ||
AttendanceType.FIRST, | ||
), | ||
AttendanceCodeDialogPreviewParameter( | ||
codes = persistentListOf("1", "2", "3", "4", "5"), | ||
inputCodes = persistentListOf("1", "2", "3", "4", "5"), | ||
AttendanceType.FIRST, | ||
), | ||
AttendanceCodeDialogPreviewParameter( | ||
codes = persistentListOf("1", "2", "3", "4", "5"), | ||
inputCodes = persistentListOf("1", "2", "3", null, null), | ||
AttendanceType.SECOND, | ||
), | ||
AttendanceCodeDialogPreviewParameter( | ||
codes = persistentListOf("1", "2", "3", "4", "5"), | ||
inputCodes = persistentListOf("1", "2", "3", "4", "5"), | ||
AttendanceType.SECOND, | ||
), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...rc/main/java/org/sopt/official/feature/attendance/compose/component/AttendanceCodeCard.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package org.sopt.official.feature.attendance.compose.component | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.border | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.foundation.text.BasicTextField | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.tooling.preview.PreviewParameter | ||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider | ||
import androidx.compose.ui.unit.dp | ||
import org.sopt.official.designsystem.SoptTheme | ||
|
||
@Composable | ||
fun AttendanceCodeCard( | ||
text: String, | ||
onTextChange: (String) -> Unit, | ||
onTextFieldFull: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
textMaxLength: Int = 1, | ||
) { | ||
BasicTextField( | ||
value = text, | ||
onValueChange = { newText: String -> | ||
if (newText.length < textMaxLength) { | ||
onTextChange(newText) | ||
} else { | ||
onTextFieldFull() | ||
} | ||
}, | ||
modifier = modifier | ||
.background( | ||
color = if (text.isEmpty()) SoptTheme.colors.onSurface600 | ||
else SoptTheme.colors.onSurface800, | ||
shape = RoundedCornerShape(8.dp) | ||
) | ||
.border( | ||
width = 1.dp, | ||
color = if (text.isEmpty()) SoptTheme.colors.onSurface500 | ||
else SoptTheme.colors.primary, | ||
shape = RoundedCornerShape(8.dp) | ||
) | ||
.padding(horizontal = 17.dp, vertical = 18.dp) | ||
.width(10.dp), | ||
textStyle = SoptTheme.typography.heading16B.copy(color = SoptTheme.colors.primary) | ||
) | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun AttendanceCodeCardPreview( | ||
@PreviewParameter(AttendanceCodeCardPreviewParameterProvider::class) text: String, | ||
) { | ||
SoptTheme { | ||
AttendanceCodeCard( | ||
text = text, | ||
onTextChange = {}, | ||
onTextFieldFull = {} | ||
) | ||
} | ||
} | ||
|
||
private class AttendanceCodeCardPreviewParameterProvider : PreviewParameterProvider<String> { | ||
override val values: Sequence<String> = sequenceOf("", "8") | ||
} |
42 changes: 42 additions & 0 deletions
42
...ain/java/org/sopt/official/feature/attendance/compose/component/AttendanceCodeCardList.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.sopt.official.feature.attendance.compose.component | ||
|
||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import org.sopt.official.designsystem.SoptTheme | ||
|
||
@Composable | ||
fun AttendanceCodeCardList( | ||
codes: List<String?>, | ||
onTextChange: (newText: String) -> Unit, | ||
onTextFieldFull: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Row(modifier = modifier) { | ||
repeat(codes.size) { index -> | ||
AttendanceCodeCard( | ||
text = codes[index] ?: "", | ||
onTextChange = onTextChange, | ||
onTextFieldFull = onTextFieldFull | ||
) | ||
if (index < codes.size) { | ||
Spacer(modifier = Modifier.width(width = 12.dp)) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun AttendanceCodeCardListPreview() { | ||
SoptTheme { | ||
AttendanceCodeCardList( | ||
codes = listOf("8", "8", "8", null, null), | ||
onTextChange = {}, | ||
onTextFieldFull = {}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters