-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/544-offering-detail-skeleton-ui
- Loading branch information
Showing
15 changed files
with
153 additions
and
91 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
android/app/src/main/java/com/zzang/chongdae/presentation/util/LocalDateTimeToString.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,14 @@ | ||
package com.zzang.chongdae.presentation.util | ||
|
||
import java.time.LocalDate | ||
import java.time.LocalTime | ||
import java.time.format.DateTimeFormatter | ||
import java.util.Locale | ||
|
||
fun LocalDate.toFormattedDate(): String { | ||
return this.format(DateTimeFormatter.ofPattern("yyyy년 M월 d일")) | ||
} | ||
|
||
fun LocalTime.toFormattedTime(): String { | ||
return this.format(DateTimeFormatter.ofPattern(("a h:mm"), Locale.KOREAN)) | ||
} |
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
18 changes: 3 additions & 15 deletions
18
...ava/com/zzang/chongdae/presentation/view/commentdetail/adapter/comment/CommentViewType.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 |
---|---|---|
@@ -1,21 +1,9 @@ | ||
package com.zzang.chongdae.presentation.view.commentdetail.adapter.comment | ||
|
||
import com.zzang.chongdae.domain.model.Comment | ||
|
||
sealed class CommentViewType { | ||
data class MyComment(val comment: Comment) : CommentViewType() | ||
|
||
data class OtherComment(val comment: Comment) : CommentViewType() | ||
data object MyComment : CommentViewType() | ||
|
||
data class DateSeparator(val comment: Comment) : CommentViewType() | ||
data object OtherComment : CommentViewType() | ||
|
||
companion object { | ||
fun fromComment(comment: Comment): CommentViewType { | ||
return if (comment.isMine) { | ||
MyComment(comment) | ||
} else { | ||
OtherComment(comment) | ||
} | ||
} | ||
} | ||
data object DateSeparator : CommentViewType() | ||
} |
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
59 changes: 59 additions & 0 deletions
59
...n/java/com/zzang/chongdae/presentation/view/commentdetail/model/comment/CommentUiModel.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,59 @@ | ||
package com.zzang.chongdae.presentation.view.commentdetail.model.comment | ||
|
||
import com.zzang.chongdae.domain.model.Comment | ||
import com.zzang.chongdae.presentation.util.toFormattedDate | ||
import com.zzang.chongdae.presentation.util.toFormattedTime | ||
import com.zzang.chongdae.presentation.view.commentdetail.adapter.comment.CommentViewType | ||
|
||
data class CommentUiModel( | ||
val content: String, | ||
val date: String, | ||
val time: String, | ||
val isMine: Boolean, | ||
val isProposer: Boolean, | ||
val nickname: String, | ||
val commentViewType: CommentViewType, | ||
) { | ||
companion object { | ||
fun Comment.toUiModel(): CommentUiModel { | ||
val viewType = if (this.isMine) CommentViewType.MyComment else CommentViewType.OtherComment | ||
return CommentUiModel( | ||
content = this.content, | ||
date = this.commentCreatedAt.date.toFormattedDate(), | ||
time = this.commentCreatedAt.time.toFormattedTime(), | ||
isMine = this.isMine, | ||
isProposer = this.isProposer, | ||
nickname = this.nickname, | ||
commentViewType = viewType, | ||
) | ||
} | ||
|
||
fun createDateSeparator(date: String): CommentUiModel { | ||
return CommentUiModel( | ||
content = "", | ||
date = date, | ||
time = "", | ||
isMine = false, | ||
isProposer = false, | ||
nickname = "", | ||
commentViewType = CommentViewType.DateSeparator, | ||
) | ||
} | ||
|
||
fun List<Comment>.toUiModelListWithSeparators(): List<CommentUiModel> { | ||
val uiModels = mutableListOf<CommentUiModel>() | ||
var currentDate: String? = null | ||
|
||
for (comment in this) { | ||
val commentDate = comment.commentCreatedAt.date.toFormattedDate() | ||
if (commentDate != currentDate) { | ||
uiModels.add(CommentUiModel.createDateSeparator(commentDate)) | ||
currentDate = commentDate | ||
} | ||
uiModels.add(comment.toUiModel()) | ||
} | ||
|
||
return uiModels | ||
} | ||
} | ||
} |
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
Oops, something went wrong.