-
Notifications
You must be signed in to change notification settings - Fork 0
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/#18] : 타임테이블 수정 #19
Conversation
val selectedCells = remember { mutableStateListOf<Pair<Int, Int>>() } // Row, Column 저장 | ||
val days = availablePeriods.dates.size | ||
val timeSlots = | ||
TimeTable().calculateTimeSlots(availablePeriods.startTime, availablePeriods.endTime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3 : TimeTable()을 여러번 사용하고있는것같은데 한번 생성하고 재사용하는건 별로일까용?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
와 여기 계산 머에요 . .?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
독감 걸려서 힘드셧을텐데 고생 많으셧슴니도
.drawBehind { | ||
val borderWidth = 1.dp.toPx() | ||
val borderColor = Gray200 | ||
|
||
if (rowIndex > 0) { | ||
drawLine( | ||
color = borderColor, | ||
start = Offset(0f, 0f), | ||
end = Offset(size.width, 0f), | ||
strokeWidth = borderWidth | ||
) | ||
} | ||
|
||
if (columnIndex > 0) { | ||
drawLine( | ||
color = borderColor, | ||
start = Offset(0f, 0f), | ||
end = Offset(0f, size.height), | ||
strokeWidth = borderWidth | ||
) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: 오 이렇게 Box의 배경 레이어에 직접 테두리를 그리면 불필요한 중복을 제거할 수 있군요? 배워갑니다!
Box( | ||
modifier = when (cellType) { | ||
CellType.Blank -> | ||
Modifier | ||
.width(42.dp) | ||
.height(36.dp) | ||
|
||
NoostakEditableTimeTableBox( | ||
index = index, | ||
days = days, | ||
timeSlots = timeSlots, | ||
backgroundColor = backgroundColor, | ||
text = text, | ||
onClick = { | ||
if (cellType == CellType.Data) { | ||
val cell = rowIndex to columnIndex | ||
if (selectedCells.contains(cell)) { | ||
selectedCells.remove(cell) | ||
} else { | ||
selectedCells.add(cell) | ||
CellType.TimeHeader -> | ||
Modifier | ||
.width(42.dp) | ||
.height(32.dp) | ||
|
||
CellType.DateHeader -> | ||
Modifier | ||
.weight(1f) | ||
.height(36.dp) | ||
|
||
else -> | ||
Modifier | ||
.weight(1f) | ||
.height(32.dp) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: 요렇게 크기 고정하셨군요! 👍👍
fun determineCellType(rowIndex: Int, columnIndex: Int): CellType = when { | ||
rowIndex == 0 && columnIndex == 0 -> CellType.Blank | ||
rowIndex == 0 -> CellType.DateHeader | ||
columnIndex == 0 -> CellType.TimeHeader | ||
else -> CellType.Data | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: 오 어떻게 셀을 구분하나 궁금했었는ㄷㅔ 간단하네요!!
@Composable | ||
fun getColorByLevel(level: Int): Color = | ||
when (AvailabilityLevel.entries.firstOrNull { level in it.range }) { | ||
AvailabilityLevel.NONE -> Color.Transparent | ||
AvailabilityLevel.FEW -> NoostakTheme.colors.blue50 | ||
AvailabilityLevel.SOME -> NoostakTheme.colors.blue200 | ||
AvailabilityLevel.MANY -> NoostakTheme.colors.blue400 | ||
AvailabilityLevel.MOST -> NoostakTheme.colors.blue700 | ||
else -> NoostakTheme.colors.blue800 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: 깔끔하고 너무 좋습니다ㅏㅏㅏ
CellType.Blank, CellType.DateHeader, CellType.TimeHeader -> Color.Transparent | ||
CellType.Data -> { | ||
val startHour = extractHour(extractTime(availablePeriods.startTime)) | ||
val currentHour = startHour + (rowIndex - 1) | ||
|
||
val date = | ||
availablePeriods.dates.getOrNull(columnIndex - 1) ?: return Color.Transparent | ||
// 해당 열(columnIndex) 날짜 데이터 가져오기 | ||
val formattedDate = extractDate(date) | ||
val availableTimesForDate = availableTimes.members.flatMap { member -> | ||
member.times.filter { extractDate(it.date) == formattedDate } | ||
} | ||
|
||
// 현재 시간에 해당하는 가능 레벨 계산 | ||
val totalMembers = availableTimes.members.size | ||
val availableMembers = availableTimesForDate.count { availableTime -> | ||
availableTime.times.any { timeEntity -> | ||
val entityStartHour = extractHour(extractTime(timeEntity.memberStartTime)) | ||
val entityEndHour = extractHour(extractTime(timeEntity.memberEndTime)) | ||
currentHour in entityStartHour until entityEndHour | ||
} | ||
} | ||
val percentage = | ||
if (totalMembers == 0) 0 else (availableMembers * 100 / totalMembers) | ||
getColorByLevel(percentage) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: 와 이거 계산 어케하셨어요? 완전 천재자나😲
fun getSelectedTimes( | ||
selectedCells: List<Pair<Int, Int>>, | ||
availablePeriods: PeriodEntity | ||
): List<AvailableTimeEntity> { | ||
val selectedTimes = mutableListOf<AvailableTimeEntity>() | ||
val selectedCellsByDate = selectedCells.groupBy { it.second } | ||
selectedCellsByDate.forEach { (dateColumnIndex, cells) -> | ||
val date = availablePeriods.dates.getOrNull(dateColumnIndex - 1) ?: return@forEach | ||
val times = cells.map { (rowIndex, _) -> | ||
val startHour = extractHour(extractTime(availablePeriods.startTime)) + (rowIndex - 1) | ||
val endHour = startHour + 1 | ||
TimeEntity( | ||
memberStartTime = "${extractDate(date)}T${String.format("%02d", startHour)}:00:00", | ||
memberEndTime = "${extractDate(date)}T${String.format("%02d", endHour)}:00:00" | ||
) | ||
} | ||
if (times.isNotEmpty()) { | ||
selectedTimes.add(AvailableTimeEntity(date = date, times = times)) | ||
} | ||
} | ||
|
||
return selectedTimes | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: 와 이거 진심 대단한데요..? (진심 어케함..)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넘넘 고생 많으셨습니다! 코드 이해하느라 코리가 늦어진 점 너무 죄송해요...
저라면 아직도 오열하며 붙잡고 있을 것 같은데, 아프신 와중에도 너무 멋지게 구현하셔서 대단하다는 생각 뿐입니다..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 엄청 복잡하고 빡셌을 텐데 잘하셨어요!!!
로직이 복잡해서 리팩은 나중에 천천히 해도 될 것 같네욤 ㅜ
✅ 𝗖𝗵𝗲𝗰𝗸-𝗟𝗶𝘀𝘁
📌 𝗜𝘀𝘀𝘂𝗲𝘀
📎 𝗪𝗼𝗿𝗸 𝗗𝗲𝘀𝗰𝗿𝗶𝗽𝘁𝗶𝗼𝗻
📷 𝗦𝗰𝗿𝗲𝗲𝗻𝘀𝗵𝗼𝘁
💬 𝗧𝗼 𝗥𝗲𝘃𝗶𝗲𝘄𝗲𝗿𝘀
진짜 너무 어려워서 눈물 나왔어요.. 타임테이블로 트슛 쓸거임 ssibal
(구라 안치고 독감 더 심해지는 느낌 머리도 아프고 정신도 아프고 하.................. 토나와)
🚨 아래 내용 꼭 읽고 코리 달아주세요 ㅠㅠ 🚨
일단 앱바나 나머지 UI 요소들은 스크롤 안되고 고정입니다. 캘린더 내부에서 스크롤 한다고 하니까 참고해주세요.
캘린더 영역은 항상 RoundedCornerShape(8.dp)로 보여야 한다고 합니다. 아래 사진과 같이 피그마에서는 스크롤되는 캘린더일 때 양옆이 일직선으로 그려져 있던데 제가 구현한 방식이 맞는거라고 서희 언니한테 확인 받았습니다. 타임테이블에서 더이상 구현하지 못한 UI 디테일은 없는 것 같습니다.
스트링 추출하면 함수 이해하는게 더 어려울 것 같아서 스트링 추출 안하겠습니다.