Skip to content

Commit

Permalink
feat: 최신 메시지를 ui에 보여주도록 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
gaeun5744 committed Dec 16, 2024
1 parent 2f24ce7 commit 4a8ef5a
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ fun ChatRoomListDto.toDomain(): ChatRooms =
clubName = it.clubName,
memberCount = it.memberCount,
clubImageUrl = it.clubImageUrl,
recentMessage = it.recentMessage,
recentMessageCreatedAt = it.recentMessageCreatedAt,
)
},
)
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.happy.friendogly.data.model

import java.time.LocalDateTime

data class ChatRoomDto(
val chatRoomId: Long,
val clubName: String,
val memberCount: Int,
val clubImageUrl: String? = null,
val recentMessage: String?,
val recentMessageCreatedAt: LocalDateTime?,
)
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.happy.friendogly.domain.model

import java.time.LocalDateTime

data class ChatRoom(
val chatRoomId: Long,
val clubName: String,
val memberCount: Int,
val clubImageUrl: String? = null,
val recentMessage: String?,
val recentMessageCreatedAt: LocalDateTime?,
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.happy.friendogly.presentation.ui.chatlist

import android.view.View
import android.widget.TextView
import androidx.core.view.isVisible
import androidx.databinding.BindingAdapter
Expand All @@ -10,7 +11,11 @@ import java.time.format.DateTimeFormatter
private const val MAX_MESSAGE_COUNT = 999

@BindingAdapter("chatDateTime")
fun TextView.dateTimeString(dateTime: ChatDateTime) {
fun TextView.dateTimeString(dateTime: ChatDateTime?) {
if (dateTime == null) {
this.visibility = View.GONE
return
}
val timeFormatter = DateTimeFormatter.ofPattern(context.getString(R.string.chat_time))
val dateFormatter = DateTimeFormatter.ofPattern(context.getString(R.string.chat_date))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import java.time.LocalDateTime
fun ChatRoom.toUiModel(): ChatListUiModel =
ChatListUiModel(
clubName,
"",
recentMessage,
memberCount,
0,
LocalDateTime.of(2024, 6, 7, 13, 6).classifyChatDateTime(),
recentMessageCreatedAt?.classifyChatDateTime(),
clubImageUrl,
chatRoomId = chatRoomId,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import java.time.LocalDateTime

data class ChatListUiModel(
val title: String,
val body: String,
val body: String?,
val numberOfPeople: Int,
val unreadMessageCount: Int,
val dateTime: ChatDateTime,
val dateTime: ChatDateTime?,
val imageUrl: String? = null,
val chatRoomId: Long = 0,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ApiClient {

object ChatRoom {
private const val BASE_URL = "/api/chat-rooms"
const val CHAT_LIST = "$BASE_URL/mine"
const val CHAT_LIST = "$BASE_URL/mine/v2"
const val MEMBERS = "$BASE_URL/{chatRoomId}"
const val CLUB = "$BASE_URL/{chatRoomId}/club"
const val LEAVE = "$BASE_URL/leave/{chatRoomId}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ fun ChatRoomListResponse.toData(): ChatRoomListDto =
chatRooms.map {
ChatRoomDto(
chatRoomId = it.chatRoomId,
clubName = it.clubName,
clubName = it.title,
memberCount = it.memberCount,
clubImageUrl = it.clubImageUrl,
clubImageUrl = it.imageUrl,
recentMessage = it.recentMessage,
recentMessageCreatedAt = it.recentMessageCreatedAt,
)
},
)
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package com.happy.friendogly.remote.model.response

import com.happy.friendogly.remote.util.JavaLocalDateTimeSerializer
import kotlinx.serialization.Serializable
import java.time.LocalDateTime

@Serializable
data class ChatRoomResponse(
val chatRoomId: Long,
val clubName: String,
val memberCount: Int,
val clubImageUrl: String? = null,
val title: String,
val imageUrl: String? = null,
val recentMessage: String?,
@Serializable(with = JavaLocalDateTimeSerializer::class)
val recentMessageCreatedAt: LocalDateTime?,
)
3 changes: 1 addition & 2 deletions android/app/src/main/res/layout/item_chat_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginBottom="7dp"
app:layout_constraintStart_toEndOf="@id/iv_chat_group"
app:layout_constraintBottom_toBottomOf="@id/iv_chat_group"
app:layout_constraintTop_toTopOf="@id/iv_chat_group"
Expand All @@ -59,7 +60,6 @@

<TextView
android:id="@+id/tv_chat_body"
android:visibility="gone"
style="@style/Theme.AppCompat.TextView.Regular.Gray07.Size12"
android:layout_width="0dp"
android:layout_height="wrap_content"
Expand All @@ -72,7 +72,6 @@
tools:text="다들 언제 모이시는게 편하세요?" />

<TextView
android:visibility="gone"
android:id="@+id/tv_chat_date_time"
style="@style/Theme.AppCompat.TextView.Regular.Gray07.Size10"
chatDateTime="@{dateTime}"
Expand Down
12 changes: 5 additions & 7 deletions android/app/src/main/res/layout/item_chat_other.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,14 @@
<TextView
android:id="@+id/tv_chat_other_message"
style="@style/Theme.AppCompat.TextView.Regular.Size16"
android:layout_width="0dp"
android:layout_width="wrap_content"
app:layout_constrainedWidth="true"
android:layout_height="wrap_content"
android:layout_marginEnd="100dp"
android:layout_weight="0"
android:background="@drawable/rect_gray03_fill_16"
android:paddingHorizontal="16dp"
android:paddingVertical="11dp"
android:textColor="@color/black"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@id/tv_chat_other_time"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
Expand All @@ -70,16 +69,15 @@
<TextView
android:id="@+id/tv_chat_other_time"
style="@style/Theme.AppCompat.TextView.Regular.Gray07.Size10"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginStart="5dp"
android:layout_marginBottom="2dp"
android:layout_weight="1"
android:minWidth="120dp"
app:layout_constraintBottom_toBottomOf="@id/tv_chat_other_message"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@id/tv_chat_other_message"
app:layout_constraintEnd_toEndOf="parent"
tools:text="오후 2:23" />

</androidx.constraintlayout.widget.ConstraintLayout>
Expand Down

0 comments on commit 4a8ef5a

Please sign in to comment.