add delta sync for dm-v9
This commit is contained in:
parent
49f9661ff3
commit
1c0348ab6e
5 changed files with 21 additions and 30 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
<component name="PlanningModeManager">
|
<component name="PlanningModeManager">
|
||||||
<option name="approvalStates">
|
<option name="approvalStates">
|
||||||
<map>
|
<map>
|
||||||
|
<entry key="1d62ea36-17b5-411c-87a3-77b82c8bb3b5" value="false" />
|
||||||
<entry key="53d32dd4-9fa5-47db-9a92-2613918d056e" value="false" />
|
<entry key="53d32dd4-9fa5-47db-9a92-2613918d056e" value="false" />
|
||||||
</map>
|
</map>
|
||||||
</option>
|
</option>
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ data class Friend(
|
||||||
|
|
||||||
val username: String?, // 建議 username 也改可空
|
val username: String?, // 建議 username 也改可空
|
||||||
|
|
||||||
@Json(name = "display_name") // 移除 field: 試試看
|
@Json(name = "display_name")
|
||||||
val displayName: String?,
|
val displayName: String?,
|
||||||
|
|
||||||
@Json(name = "avatar_url")
|
@Json(name = "avatar_url")
|
||||||
|
|
@ -35,7 +35,7 @@ val Friend.fullFriendsAvatarUrl: Any
|
||||||
return when {
|
return when {
|
||||||
url.isBlank() -> R.drawable.avatar_v1
|
url.isBlank() -> R.drawable.avatar_v1
|
||||||
url.startsWith("http") -> url
|
url.startsWith("http") -> url
|
||||||
else -> "http://192.168.0.217$url"
|
else -> "https://tg.technologia-tw.com$url"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ class FriendsRepository @Inject constructor(
|
||||||
username = entity.username,
|
username = entity.username,
|
||||||
displayName = entity.displayName,
|
displayName = entity.displayName,
|
||||||
avatarUrl = entity.avatarUrl,
|
avatarUrl = entity.avatarUrl,
|
||||||
status = entity.status,
|
status = entity.presenceStatus,
|
||||||
acceptedAt = null // Sync API 目前沒給這個,先設為 null
|
acceptedAt = null // Sync API 目前沒給這個,先設為 null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,8 @@ import com.example.login_v3.home.Message.ViewModel.Detail.ContactListViewModel
|
||||||
import com.example.login_v3.navigation.BottomBarViewModel
|
import com.example.login_v3.navigation.BottomBarViewModel
|
||||||
import androidx.compose.ui.text.input.ImeAction
|
import androidx.compose.ui.text.input.ImeAction
|
||||||
import com.example.login_v3.data.api.api_class.fullSearchedAvatarUrl
|
import com.example.login_v3.data.api.api_class.fullSearchedAvatarUrl
|
||||||
|
import com.example.login_v3.home.Message.UI.Detail.Message_Component.UserStatusDot
|
||||||
|
import com.example.login_v3.home.Message.ViewModel.UserStatus
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
@ -225,13 +227,6 @@ fun FriendRow(
|
||||||
// 1. 定義展開狀態
|
// 1. 定義展開狀態
|
||||||
var isExpanded by remember { mutableStateOf(false) }
|
var isExpanded by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
// 定義狀態顏色
|
|
||||||
val statusColor = when (friend.status?.lowercase()) {
|
|
||||||
"online" -> Color(0xFF4CAF50) // 鮮豔的綠色
|
|
||||||
"busy" -> Color(0xFFF44336) // 紅色
|
|
||||||
else -> Color(0xFF9E9E9E) // 灰色 (offline/away)
|
|
||||||
}
|
|
||||||
|
|
||||||
Card(
|
Card(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
|
@ -308,20 +303,8 @@ fun FriendRow(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val isOnline = friend.status?.lowercase() == "online"
|
UserStatusDot(
|
||||||
// 定義圓點顏色
|
status = UserStatus.fromString(friend.status)
|
||||||
val dotColor = if (isOnline) {
|
|
||||||
Color(0xFF4CAF50) // 綠色 (Online)
|
|
||||||
} else {
|
|
||||||
Color(0xFF9E9E9E) // 灰色 (Offline)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 實作圓點
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.size(10.dp) // 圓點大小
|
|
||||||
.clip(CircleShape)
|
|
||||||
.background(dotColor)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.width(10.dp))
|
Spacer(modifier = Modifier.width(10.dp))
|
||||||
|
|
|
||||||
|
|
@ -49,9 +49,10 @@ class ChatRoomsViewModel @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class UserStatus(val color: Color) {
|
enum class UserStatus(val color: Color) {
|
||||||
ONLINE(Color.Green),
|
ONLINE(Color(0xFF4CAF50)),
|
||||||
OFFLINE(Color.Gray),
|
BUSY(Color(0xFFF44336)),
|
||||||
UNKNOWN(Color.Transparent); // 或者是你原本設定的顏色
|
OFFLINE(Color(0xFF9E9E9E)),
|
||||||
|
UNKNOWN(Color.Transparent);
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun fromString(status: String?): UserStatus {
|
fun fromString(status: String?): UserStatus {
|
||||||
|
|
@ -60,9 +61,15 @@ enum class UserStatus(val color: Color) {
|
||||||
// 使用 try-catch 或者是 safe valueOf 確保絕對不閃退
|
// 使用 try-catch 或者是 safe valueOf 確保絕對不閃退
|
||||||
return try {
|
return try {
|
||||||
// uppercase() 預防後端一下給大寫一下給小寫 (例如 "online" vs "ONLINE")
|
// uppercase() 預防後端一下給大寫一下給小寫 (例如 "online" vs "ONLINE")
|
||||||
valueOf(status.uppercase())
|
val normalizedStatus = status.uppercase()
|
||||||
} catch (e: IllegalArgumentException) {
|
when (normalizedStatus) {
|
||||||
UNKNOWN // 找不到對應的狀態就安全地回傳 UNKNOWN
|
"ONLINE" -> ONLINE
|
||||||
|
"BUSY" -> BUSY
|
||||||
|
"OFFLINE" -> OFFLINE
|
||||||
|
else -> OFFLINE // 如果是其他自定義狀態,統一顯示為離線 (灰色)
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
OFFLINE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue