2026-01-13 16:04:25 +09:00
|
|
|
// src/main/kotlin/ui/StockHeader.kt
|
|
|
|
|
package ui
|
|
|
|
|
|
|
|
|
|
import androidx.compose.foundation.layout.*
|
2026-01-14 15:42:26 +09:00
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
2026-01-13 16:04:25 +09:00
|
|
|
import androidx.compose.material.*
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
|
import androidx.compose.ui.Alignment
|
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
|
|
import androidx.compose.ui.text.font.FontWeight
|
|
|
|
|
import androidx.compose.ui.text.style.TextAlign
|
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun StockHeader(
|
|
|
|
|
name: String,
|
|
|
|
|
code: String,
|
|
|
|
|
isDomestic: Boolean,
|
2026-01-14 15:42:26 +09:00
|
|
|
previousClose: String, // 추가: 전일 종가
|
|
|
|
|
openPrice: String, // 추가: 금일 시가
|
2026-01-13 16:04:25 +09:00
|
|
|
resultMessage: String,
|
|
|
|
|
isSuccess: Boolean
|
|
|
|
|
) {
|
2026-01-14 15:42:26 +09:00
|
|
|
Column(modifier = Modifier.wrapContentWidth()) {
|
|
|
|
|
// [1] 알림 메시지 영역 (기존 동일)
|
2026-01-13 16:04:25 +09:00
|
|
|
if (resultMessage.isNotEmpty()) {
|
|
|
|
|
Surface(
|
2026-01-14 15:42:26 +09:00
|
|
|
color = if (isSuccess) Color(0xFF4CAF50) else Color(0xFFF44336),
|
2026-01-13 16:04:25 +09:00
|
|
|
modifier = Modifier.fillMaxWidth().padding(bottom = 8.dp),
|
2026-01-14 15:42:26 +09:00
|
|
|
shape = RoundedCornerShape(4.dp)
|
2026-01-13 16:04:25 +09:00
|
|
|
) {
|
2026-01-14 15:42:26 +09:00
|
|
|
Text(text = resultMessage, color = Color.White, modifier = Modifier.padding(8.dp), fontWeight = FontWeight.Bold)
|
2026-01-13 16:04:25 +09:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-14 15:42:26 +09:00
|
|
|
// [2] 종목명 및 정보
|
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
2026-01-13 16:04:25 +09:00
|
|
|
Surface(
|
2026-01-14 15:42:26 +09:00
|
|
|
color = if (isDomestic) Color(0xFFE03E2D) else Color(0xFF0E62CF),
|
|
|
|
|
shape = RoundedCornerShape(4.dp)
|
2026-01-13 16:04:25 +09:00
|
|
|
) {
|
2026-01-14 15:42:26 +09:00
|
|
|
Text(text = if (isDomestic) "국내" else "해외", color = Color.White, fontSize = 10.sp, modifier = Modifier.padding(horizontal = 6.dp, vertical = 2.dp))
|
2026-01-13 16:04:25 +09:00
|
|
|
}
|
|
|
|
|
Spacer(modifier = Modifier.width(8.dp))
|
2026-01-14 15:42:26 +09:00
|
|
|
Text(text = name, style = MaterialTheme.typography.h5, fontWeight = FontWeight.Bold)
|
2026-01-13 16:04:25 +09:00
|
|
|
Spacer(modifier = Modifier.width(6.dp))
|
2026-01-14 15:42:26 +09:00
|
|
|
Text(text = "($code)", color = Color.Gray)
|
|
|
|
|
}
|
2026-01-13 16:04:25 +09:00
|
|
|
|
2026-01-14 15:42:26 +09:00
|
|
|
// [3] 전일 종가 및 시가 정보 행 추가
|
|
|
|
|
Row(modifier = Modifier.padding(top = 4.dp)) {
|
|
|
|
|
PriceSummaryItem("전일 종가", previousClose)
|
|
|
|
|
Spacer(modifier = Modifier.width(16.dp))
|
|
|
|
|
PriceSummaryItem("금일 시가", openPrice)
|
2026-01-13 16:04:25 +09:00
|
|
|
}
|
|
|
|
|
}
|
2026-01-14 15:42:26 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun PriceSummaryItem(label: String, price: String) {
|
|
|
|
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
|
|
|
|
Text(text = label, fontSize = 11.sp, color = Color.Gray)
|
|
|
|
|
Spacer(modifier = Modifier.width(4.dp))
|
|
|
|
|
val formattedPrice = price.toLongOrNull()?.let { String.format("%,d", it) } ?: price
|
|
|
|
|
Text(text = "${formattedPrice}원", fontSize = 12.sp, fontWeight = FontWeight.Medium)
|
|
|
|
|
}
|
2026-01-13 16:04:25 +09:00
|
|
|
}
|