...
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// src/main/kotlin/ui/ActiveTradeRow.kt
|
||||
package ui
|
||||
|
||||
import AutoTradeItem
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
@@ -13,20 +14,21 @@ import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import model.ActiveTradeItem
|
||||
import model.ActiveTradeType
|
||||
|
||||
@Composable
|
||||
fun ActiveTradeRow(
|
||||
item: ActiveTradeItem,
|
||||
onCancelClick: (String) -> Unit = {}, // 미체결 취소용
|
||||
item: AutoTradeItem, // UI 모델 대신 통합 데이터 모델 사용
|
||||
onCancelClick: () -> Unit, // 미체결 취소 시 주문번호(orderNo) 전달
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
val isMonitoring = item.type == ActiveTradeType.MONITORING
|
||||
|
||||
// 상태에 따른 배경색 설정 (미체결은 연노랑으로 강조)
|
||||
val backgroundColor = if (isMonitoring) Color.White else Color(0xFFFFF9C4)
|
||||
val badgeColor = if (isMonitoring) Color(0xFF0E62CF) else Color(0xFFE03E2D)
|
||||
// 상태에 따른 UI 구성 요소 정의
|
||||
val (statusText, statusColor, backgroundColor) = when (item.status) {
|
||||
"PENDING_BUY" -> Triple("매수중", Color(0xFFFBC02D), Color(0xFFFFF9C4)) // 노랑
|
||||
"MONITORING" -> Triple("감시중", Color(0xFF0E62CF), Color.White) // 파랑
|
||||
"SELLING" -> Triple("매도중", Color(0xFFE03E2D), Color(0xFFFFF4F4)) // 빨강
|
||||
"COMPLETED" -> Triple("완료", Color.Gray, Color(0xFFF5F5F5)) // 회색
|
||||
else -> Triple("알 수 없음", Color.Black, Color.White)
|
||||
}
|
||||
|
||||
Card(
|
||||
modifier = Modifier
|
||||
@@ -39,65 +41,67 @@ fun ActiveTradeRow(
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.padding(12.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
// 좌측 정보 영역
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
// 상태 배지 (자동감시 / 미체결)
|
||||
// 상태 배지 표시
|
||||
Surface(
|
||||
color = badgeColor,
|
||||
shape = RoundedCornerShape(4.dp)
|
||||
color = statusColor,
|
||||
shape = RoundedCornerShape(2.dp),
|
||||
modifier = Modifier.padding(end = 6.dp)
|
||||
) {
|
||||
Text(
|
||||
text = if (isMonitoring) "자동감시" else "미체결",
|
||||
text = statusText,
|
||||
color = Color.White,
|
||||
fontSize = 10.sp,
|
||||
modifier = Modifier.padding(horizontal = 4.dp, vertical = 2.dp)
|
||||
fontSize = 9.sp,
|
||||
modifier = Modifier.padding(horizontal = 4.dp, vertical = 2.dp),
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.width(6.dp))
|
||||
Text(
|
||||
text = item.name,
|
||||
style = MaterialTheme.typography.body2,
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 14.sp,
|
||||
maxLines = 1
|
||||
)
|
||||
}
|
||||
|
||||
// 상세 가격 정보 (상태에 따라 비율 또는 목표가 표시)
|
||||
val detailText = when (item.status) {
|
||||
"PENDING_BUY" -> "설정 비율: 익절 ${item.profitRate}% / 손절 ${item.stopLossRate}%"
|
||||
"MONITORING" -> "목표가: ${String.format("%,.0f", item.targetPrice)} / 손절가: ${String.format("%,.0f", item.stopLossPrice)}"
|
||||
else -> "주문번호: ${item.orderNo}"
|
||||
}
|
||||
|
||||
Text(
|
||||
text = "${item.code} | ${if (isMonitoring) "목표가" else "주문가"}: ${String.format("%,.0f", item.price)}",
|
||||
text = "${item.code} | $detailText",
|
||||
fontSize = 11.sp,
|
||||
color = Color.Gray
|
||||
)
|
||||
}
|
||||
|
||||
// 우측 액션 영역
|
||||
// 우측 액션 및 수량 영역
|
||||
Column(horizontalAlignment = Alignment.End) {
|
||||
if (!isMonitoring) {
|
||||
// 미체결인 경우 취소 버튼 표시
|
||||
if (item.status == "PENDING_BUY" || item.status == "SELLING") {
|
||||
// 진행 중인 주문인 경우 취소 버튼 노출
|
||||
Button(
|
||||
onClick = { onCancelClick(item.id) },
|
||||
onClick = { onCancelClick() },
|
||||
contentPadding = PaddingValues(horizontal = 8.dp),
|
||||
modifier = Modifier.height(28.dp),
|
||||
colors = ButtonDefaults.buttonColors(backgroundColor = Color.LightGray)
|
||||
) {
|
||||
Text("취소", fontSize = 11.sp)
|
||||
}
|
||||
Text(
|
||||
text = "${item.quantity}주",
|
||||
fontSize = 12.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = Color(0xFFE03E2D)
|
||||
)
|
||||
} else {
|
||||
// 자동감시 중인 경우 상태 텍스트 표시
|
||||
Text(
|
||||
text = "감시중",
|
||||
fontSize = 12.sp,
|
||||
color = badgeColor,
|
||||
fontWeight = FontWeight.Medium
|
||||
)
|
||||
}
|
||||
|
||||
Text(
|
||||
text = "${item.quantity}주",
|
||||
fontSize = 12.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = statusColor
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user