This commit is contained in:
2026-01-14 15:42:26 +09:00
parent 2bb94e2856
commit bdc268e325
18 changed files with 1193 additions and 205 deletions
+31 -42
View File
@@ -2,6 +2,7 @@
package ui
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
@@ -17,64 +18,52 @@ fun StockHeader(
name: String,
code: String,
isDomestic: Boolean,
previousClose: String, // 추가: 전일 종가
openPrice: String, // 추가: 금일 시가
resultMessage: String,
isSuccess: Boolean
) {
Column(modifier = Modifier.fillMaxWidth()) {
// [1] 알림 메시지 영역 (주문 성공/실패 시 상단에 표시)
Column(modifier = Modifier.wrapContentWidth()) {
// [1] 알림 메시지 영역 (기존 동일)
if (resultMessage.isNotEmpty()) {
Surface(
color = if (isSuccess) Color(0xFF4CAF50) else Color(0xFFF44336), // 성공 초록, 실패 빨강
color = if (isSuccess) Color(0xFF4CAF50) else Color(0xFFF44336),
modifier = Modifier.fillMaxWidth().padding(bottom = 8.dp),
shape = androidx.compose.foundation.shape.RoundedCornerShape(4.dp)
shape = RoundedCornerShape(4.dp)
) {
Text(
text = resultMessage,
color = Color.White,
modifier = Modifier.padding(8.dp),
textAlign = TextAlign.Center,
fontSize = 12.sp,
fontWeight = FontWeight.Bold
)
Text(text = resultMessage, color = Color.White, modifier = Modifier.padding(8.dp), fontWeight = FontWeight.Bold)
}
}
// [2] 종목명 및 국가 배지 영역
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.padding(vertical = 4.dp)
) {
// 국가 구분 배지
// [2] 종목명 및 정보
Row(verticalAlignment = Alignment.CenterVertically) {
Surface(
color = if (isDomestic) Color(0xFFE03E2D) else Color(0xFF0E62CF), // 국내 빨강, 해외 파랑
shape = androidx.compose.foundation.shape.RoundedCornerShape(4.dp)
color = if (isDomestic) Color(0xFFE03E2D) else Color(0xFF0E62CF),
shape = RoundedCornerShape(4.dp)
) {
Text(
text = if (isDomestic) "국내" else "해외",
color = Color.White,
fontSize = 10.sp,
fontWeight = FontWeight.Bold,
modifier = Modifier.padding(horizontal = 6.dp, vertical = 2.dp)
)
Text(text = if (isDomestic) "국내" else "해외", color = Color.White, fontSize = 10.sp, modifier = Modifier.padding(horizontal = 6.dp, vertical = 2.dp))
}
Spacer(modifier = Modifier.width(8.dp))
// 종목 이름
Text(
text = name,
style = MaterialTheme.typography.h5,
fontWeight = FontWeight.Bold
)
Text(text = name, style = MaterialTheme.typography.h5, fontWeight = FontWeight.Bold)
Spacer(modifier = Modifier.width(6.dp))
Text(text = "($code)", color = Color.Gray)
}
// 종목 코드
Text(
text = "($code)",
style = MaterialTheme.typography.body1,
color = Color.Gray
)
// [3] 전일 종가 및 시가 정보 행 추가
Row(modifier = Modifier.padding(top = 4.dp)) {
PriceSummaryItem("전일 종가", previousClose)
Spacer(modifier = Modifier.width(16.dp))
PriceSummaryItem("금일 시가", openPrice)
}
}
}
@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)
}
}