Skip to content
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

[IDLE-490] 채팅방 내역이 없을 경우 보여줄 화면 추가 및 읽지 않은 메세지 개수 100개 이상 일 경우 99+로 표시되도록 변경 #144

Merged
merged 4 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions core/designresource/src/main/res/drawable/ic_chat.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="25dp"
android:viewportWidth="24"
android:viewportHeight="25">
<path
android:fillColor="#383D45"
android:pathData="M4,11.498C4,9.744 4.577,8.039 5.642,6.645C6.706,5.251 8.199,4.245 9.891,3.783C11.583,3.321 13.38,3.427 15.005,4.086C16.631,4.745 17.994,5.92 18.887,7.429C19.779,8.939 20.151,10.701 19.944,12.442C19.738,14.184 18.964,15.81 17.743,17.069C16.523,18.328 14.922,19.151 13.187,19.411C11.453,19.672 9.681,19.355 8.144,18.509L5.034,19.457C4.895,19.499 4.747,19.503 4.607,19.467C4.466,19.432 4.337,19.36 4.235,19.257C4.132,19.154 4.06,19.026 4.024,18.885C3.989,18.744 3.993,18.597 4.035,18.458L4.982,15.343C4.337,14.164 3.999,12.842 4,11.498ZM8.8,10.698C8.8,10.91 8.884,11.114 9.034,11.264C9.184,11.414 9.388,11.498 9.6,11.498H14.4C14.612,11.498 14.816,11.414 14.966,11.264C15.116,11.114 15.2,10.91 15.2,10.698C15.2,10.486 15.116,10.283 14.966,10.132C14.816,9.982 14.612,9.898 14.4,9.898H9.6C9.388,9.898 9.184,9.982 9.034,10.132C8.884,10.283 8.8,10.486 8.8,10.698ZM9.6,13.098C9.388,13.098 9.184,13.182 9.034,13.333C8.884,13.483 8.8,13.686 8.8,13.898C8.8,14.11 8.884,14.314 9.034,14.464C9.184,14.614 9.388,14.698 9.6,14.698H12.8C13.012,14.698 13.216,14.614 13.366,14.464C13.516,14.314 13.6,14.11 13.6,13.898C13.6,13.686 13.516,13.483 13.366,13.333C13.216,13.182 13.012,13.098 12.8,13.098H9.6Z" />
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:pathData="M3,14.497C3.001,11.757 3.902,9.092 5.565,6.914C7.228,4.736 9.561,3.165 12.205,2.442C14.848,1.72 17.656,1.886 20.196,2.915C22.735,3.945 24.867,5.781 26.261,8.14C27.655,10.499 28.236,13.251 27.913,15.972C27.59,18.694 26.382,21.234 24.474,23.201C22.567,25.169 20.065,26.455 17.355,26.862C14.645,27.268 11.876,26.773 9.475,25.452L4.615,26.932C4.398,26.998 4.168,27.004 3.948,26.949C3.728,26.894 3.527,26.781 3.367,26.62C3.207,26.46 3.093,26.259 3.038,26.039C2.983,25.819 2.989,25.589 3.055,25.372L4.535,20.505C3.527,18.663 2.999,16.597 3,14.497ZM10.5,13.247C10.5,13.579 10.632,13.897 10.866,14.131C11.101,14.365 11.418,14.497 11.75,14.497H19.25C19.581,14.497 19.899,14.365 20.134,14.131C20.368,13.897 20.5,13.579 20.5,13.247C20.5,12.916 20.368,12.598 20.134,12.363C19.899,12.129 19.581,11.997 19.25,11.997H11.75C11.418,11.997 11.101,12.129 10.866,12.363C10.632,12.598 10.5,12.916 10.5,13.247ZM11.75,16.997C11.418,16.997 11.101,17.129 10.866,17.363C10.632,17.598 10.5,17.916 10.5,18.247C10.5,18.579 10.632,18.897 10.866,19.131C11.101,19.365 11.418,19.497 11.75,19.497H16.75C17.081,19.497 17.399,19.365 17.634,19.131C17.868,18.897 18,18.579 18,18.247C18,17.916 17.868,17.598 17.634,17.363C17.399,17.129 17.081,16.997 16.75,16.997H11.75Z"
android:fillColor="#7E848F"/>
</vector>
9 changes: 9 additions & 0 deletions core/designresource/src/main/res/drawable/ic_chat_checked.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:pathData="M3,14.497C3.001,11.757 3.902,9.092 5.565,6.914C7.228,4.736 9.561,3.165 12.205,2.442C14.848,1.72 17.656,1.886 20.196,2.915C22.735,3.945 24.867,5.781 26.261,8.14C27.655,10.499 28.236,13.251 27.913,15.972C27.59,18.694 26.382,21.234 24.474,23.201C22.567,25.169 20.065,26.455 17.355,26.862C14.645,27.268 11.876,26.773 9.475,25.452L4.615,26.932C4.398,26.998 4.168,27.004 3.948,26.949C3.728,26.894 3.527,26.781 3.367,26.62C3.207,26.46 3.093,26.259 3.038,26.039C2.983,25.819 2.989,25.589 3.055,25.372L4.535,20.505C3.527,18.663 2.999,16.597 3,14.497ZM10.5,13.247C10.5,13.579 10.632,13.897 10.866,14.131C11.101,14.365 11.418,14.497 11.75,14.497H19.25C19.581,14.497 19.899,14.365 20.134,14.131C20.368,13.897 20.5,13.579 20.5,13.247C20.5,12.916 20.368,12.598 20.134,12.363C19.899,12.129 19.581,11.997 19.25,11.997H11.75C11.418,11.997 11.101,12.129 10.866,12.363C10.632,12.598 10.5,12.916 10.5,13.247ZM11.75,16.997C11.418,16.997 11.101,17.129 10.866,17.363C10.632,17.598 10.5,17.916 10.5,18.247C10.5,18.579 10.632,18.897 10.866,19.131C11.101,19.365 11.418,19.497 11.75,19.497H16.75C17.081,19.497 17.399,19.365 17.634,19.131C17.868,18.897 18,18.579 18,18.247C18,17.916 17.868,17.598 17.634,17.363C17.399,17.129 17.081,16.997 16.75,16.997H11.75Z"
android:fillColor="#26282E"/>
</vector>
2 changes: 1 addition & 1 deletion core/designresource/src/main/res/drawable/ic_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:fillColor="#9EA3AB"
android:fillColor="#7E848F"
android:pathData="M15.479,3.122L3.44,15.805C3.08,16.151 3,16.362 3,16.747V17.246C3,17.535 3.22,17.707 3.48,17.707H6.805V26.297C6.805,26.701 6.926,26.893 7.326,26.912H13.055C13.355,26.912 13.596,26.72 13.596,26.316V22.127C13.596,21.858 13.836,21.628 14.116,21.628H18.363C18.643,21.628 18.884,21.858 18.884,22.127V26.316C18.884,26.701 19.004,26.912 19.365,26.912H25.033C25.454,26.912 25.674,26.72 25.694,26.316V17.707H29.019C29.3,17.707 29.5,17.515 29.5,17.246V16.747C29.5,16.343 29.36,16.112 28.979,15.728L17.061,3.122C16.54,2.623 16.019,2.603 15.479,3.122Z" />
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:fillColor="#9EA3AB"
android:fillColor="#7E848F"
android:pathData="M8.5,4L24.5,4A2,2 0,0 1,26.5 6L26.5,26A2,2 0,0 1,24.5 28L8.5,28A2,2 0,0 1,6.5 26L6.5,6A2,2 0,0 1,8.5 4z" />
<path
android:fillColor="#ffffff"
Expand Down
2 changes: 1 addition & 1 deletion core/designresource/src/main/res/drawable/ic_setting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:fillColor="#9EA3AB"
android:fillColor="#7E848F"
android:pathData="M16.505,12.46C15.658,12.46 14.865,12.797 14.264,13.413C13.667,14.029 13.336,14.843 13.336,15.712C13.336,16.581 13.667,17.394 14.264,18.01C14.865,18.624 15.658,18.963 16.505,18.963C17.351,18.963 18.144,18.624 18.745,18.01C19.342,17.394 19.674,16.581 19.674,15.712C19.674,14.843 19.342,14.029 18.745,13.413C18.451,13.11 18.102,12.87 17.718,12.706C17.333,12.542 16.921,12.459 16.505,12.46ZM28.181,19.303L26.329,17.679C26.417,17.127 26.462,16.563 26.462,16.002C26.462,15.441 26.417,14.875 26.329,14.326L28.181,12.701C28.321,12.578 28.421,12.415 28.468,12.232C28.515,12.049 28.507,11.856 28.444,11.678L28.419,11.603C27.909,10.14 27.145,8.785 26.165,7.601L26.114,7.54C25.994,7.397 25.836,7.293 25.658,7.244C25.481,7.195 25.293,7.202 25.12,7.264L22.82,8.104C21.97,7.389 21.024,6.826 19.999,6.433L19.555,3.966C19.521,3.78 19.433,3.609 19.303,3.476C19.172,3.343 19.005,3.253 18.824,3.219L18.748,3.205C17.275,2.932 15.723,2.932 14.25,3.205L14.174,3.219C13.993,3.253 13.826,3.343 13.695,3.476C13.565,3.609 13.477,3.78 13.443,3.966L12.996,6.445C11.98,6.84 11.034,7.403 10.195,8.11L7.878,7.264C7.705,7.201 7.517,7.194 7.339,7.243C7.162,7.293 7.003,7.396 6.884,7.54L6.833,7.601C5.854,8.786 5.091,10.141 4.579,11.603L4.554,11.678C4.426,12.042 4.531,12.448 4.817,12.701L6.692,14.343C6.604,14.889 6.561,15.447 6.561,16C6.561,16.557 6.604,17.115 6.692,17.656L4.823,19.298C4.683,19.42 4.583,19.584 4.536,19.767C4.488,19.95 4.497,20.143 4.559,20.32L4.585,20.396C5.097,21.858 5.853,23.209 6.839,24.397L6.89,24.458C7.009,24.602 7.168,24.705 7.345,24.755C7.523,24.804 7.711,24.797 7.884,24.735L10.201,23.889C11.045,24.601 11.985,25.165 13.001,25.554L13.449,28.033C13.482,28.219 13.57,28.389 13.701,28.523C13.831,28.656 13.998,28.746 14.179,28.779L14.256,28.794C15.743,29.069 17.266,29.069 18.753,28.794L18.83,28.779C19.011,28.746 19.178,28.656 19.308,28.523C19.439,28.389 19.527,28.219 19.56,28.033L20.005,25.566C21.03,25.17 21.976,24.61 22.826,23.895L25.125,24.735C25.299,24.798 25.487,24.805 25.664,24.756C25.842,24.706 26,24.603 26.119,24.458L26.17,24.397C27.156,23.203 27.912,21.858 28.424,20.396L28.45,20.32C28.572,19.96 28.467,19.556 28.181,19.303ZM16.505,20.82C13.755,20.82 11.526,18.533 11.526,15.712C11.526,12.89 13.755,10.603 16.505,10.603C19.254,10.603 21.483,12.89 21.483,15.712C21.483,18.533 19.254,20.82 16.505,20.82Z" />
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class GetChatRoomListUseCase @Inject constructor(
createdAt = LocalDateTime.now().minusDays(1),
lastMessage = "안녕하세요!안녕하세요!안녕하세요!안녕하세요!안녕하세요!안녕하세요!",
lastSentAt = LocalDateTime.now().minusHours(1),
unReadMessageCount = 3,
unReadMessageCount = 99,
profileImageUrl = "",
),
ChatRoom(
Expand All @@ -25,7 +25,7 @@ class GetChatRoomListUseCase @Inject constructor(
createdAt = LocalDateTime.now().minusDays(3),
lastMessage = "오늘 만날 수 있을까요?",
lastSentAt = LocalDateTime.now().minusHours(5),
unReadMessageCount = 2,
unReadMessageCount = 100,
profileImageUrl = "",
),
ChatRoom(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,12 @@ fun formatBusinessRegistrationNumber(businessRegistrationNumber: String): String

else -> throw IllegalArgumentException("사업자 등록번호 형식이 맞지 않습니다.")
}
}

fun Int.formatUnReadNumber(): String {
return when {
this < 0 -> "0"
this >= 100 -> "99+"
else -> this.toString()
}
}
36 changes: 36 additions & 0 deletions core/domain/src/test/kotlin/com/idle/domain/util/NumberUtilTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,40 @@ class NumberUtilTest {
formatBusinessRegistrationNumber(businessRegistrationNumber)
}
}

@Test
fun `음수일 경우 0으로 반환된다`() {
// Given
val number = -5

// When
val result = number.formatUnReadNumber()

// Then
assertEquals("0", result)
}

@Test
fun `99 이하의 숫자는 그대로 문자열로 반환된다`() {
// Given
val number = 99

// When
val result = number.formatUnReadNumber()

// Then
assertEquals("99", result)
}

@Test
fun `100 이상의 숫자는 '99+'로 반환된다`() {
// Given
val number = 100

// When
val result = number.formatUnReadNumber()

// Then
assertEquals("99+", result)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ import com.idle.network.model.token.TokenResponse
import com.idle.network.util.safeApiCall
import kotlinx.coroutines.suspendCancellableCoroutine
import javax.inject.Inject
import javax.inject.Singleton
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException

@Singleton
class AuthDataSource @Inject constructor(
private val authApi: AuthApi,
private val firebaseMessaging: FirebaseMessaging,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import com.idle.network.model.jobposting.GetWorkerJobPostingDetailResponse
import com.idle.network.model.jobposting.JobPostingRequest
import com.idle.network.util.safeApiCall
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class JobPostingDataSource @Inject constructor(
private val jobPostingApi: JobPostingApi
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import com.idle.network.model.notification.GetMyNotificationResponse
import com.idle.network.model.notification.GetUnreadNotificationCountResponse
import com.idle.network.util.safeApiCall
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class NotificationDataSource @Inject constructor(
private val notificationApi: NotificationApi
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody.Companion.toRequestBody
import java.io.InputStream
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class ProfileDataSource @Inject constructor(
private val userApi: UserApi,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import com.google.firebase.remoteconfig.get
import kotlinx.coroutines.suspendCancellableCoroutine
import kotlinx.serialization.json.Json
import javax.inject.Inject
import javax.inject.Singleton
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException

@Singleton
class ConfigDataSource @Inject constructor(
private val remoteConfig: FirebaseRemoteConfig,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import com.idle.designsystem.compose.foundation.CareTheme
import com.idle.domain.model.auth.UserType
import com.idle.domain.model.chatting.ChatRoom
import com.idle.domain.util.formatRelativeDateTime
import com.idle.domain.util.formatUnReadNumber
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
Expand Down Expand Up @@ -87,20 +88,47 @@ internal fun CenterChattingScreen(
.fillMaxSize()
) {
chatRoomList?.let {
LazyColumn(
modifier = Modifier
.fillMaxSize()
.padding(top = 20.dp, bottom = 36.dp),
) {
items(
items = chatRoomList,
key = { it.id },
) { chatRoom ->
ChatRoomItem(
chatRoom = chatRoom,
navigateTo = navigateTo,
if (chatRoomList.isEmpty()) {
Column(
modifier = Modifier
.align(Alignment.Center)
.padding(bottom = 60.dp),
) {
Text(
text = "아직 채팅 내역이 없어요",
style = CareTheme.typography.heading2,
color = CareTheme.colors.black,
textAlign = TextAlign.Center,
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 8.dp),
)

Text(
text = "센터에 궁금한 점이 있다면 해당 공고에서\n" +
"‘채팅하기’ 버튼을 눌러 채팅을 시작할 수 있어요.",
style = CareTheme.typography.body3,
textAlign = TextAlign.Center,
color = CareTheme.colors.gray300,
modifier = Modifier.fillMaxWidth(),
)
}
} else {
LazyColumn(
modifier = Modifier
.fillMaxSize()
.padding(top = 20.dp, bottom = 36.dp),
) {
items(
items = chatRoomList,
key = { it.id },
) { chatRoom ->
ChatRoomItem(
chatRoom = chatRoom,
navigateTo = navigateTo,
)
}
}
}
} ?: LoadingCircle(modifier = Modifier.align(Alignment.Center))
}
Expand Down Expand Up @@ -207,7 +235,7 @@ internal fun ChatRoomItem(
) {
Text(
text = if (chatRoom.unReadMessageCount != 0)
chatRoom.unReadMessageCount.toString() else "",
chatRoom.unReadMessageCount.formatUnReadNumber() else "",
style = CareTheme.typography.caption1.copy(fontWeight = FontWeight.Bold),
color = CareTheme.colors.white000,
textAlign = TextAlign.Center,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
Expand Down Expand Up @@ -100,7 +101,7 @@ fun CareChatSenderTextBubbleWithImage(
horizontalAlignment = Alignment.Start,
modifier = Modifier
.padding(start = 4.dp)
.width(35.dp)
.wrapContentWidth()
.align(Alignment.Bottom),
) {
if (isRead) {
Expand Down
Loading