atrade/src/main/kotlin/ui/DashboardScreen.kt

78 lines
2.8 KiB
Kotlin
Raw Normal View History

2026-01-13 16:04:25 +09:00
// src/main/kotlin/ui/DashboardScreen.kt
2026-01-10 18:16:50 +09:00
package ui
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
2026-01-13 16:04:25 +09:00
import model.KisSession
2026-01-10 18:16:50 +09:00
import network.KisTradeService
import network.KisWebSocketManager
@Composable
2026-01-13 16:04:25 +09:00
fun DashboardScreen() {
val tradeService = remember { KisTradeService() }
val wsManager = remember { KisWebSocketManager() }
2026-01-10 18:16:50 +09:00
2026-01-13 16:04:25 +09:00
// 전역 상태: 현재 선택된 종목 정보
2026-01-10 18:16:50 +09:00
var selectedStockCode by remember { mutableStateOf("") }
var selectedStockName by remember { mutableStateOf("") }
2026-01-13 16:04:25 +09:00
var isDomestic by remember { mutableStateOf(true) }
2026-01-10 18:16:50 +09:00
2026-01-13 16:04:25 +09:00
// 초기 웹소켓 연결
2026-01-10 18:16:50 +09:00
LaunchedEffect(Unit) {
2026-01-13 16:04:25 +09:00
wsManager.connect()
2026-01-10 18:16:50 +09:00
}
Row(modifier = Modifier.fillMaxSize().background(Color(0xFFF2F2F2))) {
2026-01-13 16:04:25 +09:00
// [좌측 25%] 내 자산 및 통합 잔고
2026-01-10 18:16:50 +09:00
Column(modifier = Modifier.weight(0.25f).fillMaxHeight().padding(8.dp)) {
2026-01-13 16:04:25 +09:00
BalanceSection(tradeService) { code, name, isDom ->
2026-01-10 18:16:50 +09:00
selectedStockCode = code
selectedStockName = name
2026-01-13 16:04:25 +09:00
isDomestic = isDom
println("selectedStockCode $selectedStockCode selectedStockName $selectedStockName isDomestic $isDomestic")
2026-01-10 18:16:50 +09:00
}
}
VerticalDivider()
2026-01-13 16:04:25 +09:00
// [중앙 45%] 실시간 정보 및 주문
Column(modifier = Modifier.weight(0.45f).fillMaxHeight().background(Color.White)) {
2026-01-10 18:16:50 +09:00
if (selectedStockCode.isNotEmpty()) {
2026-01-13 16:04:25 +09:00
StockDetailSection(
stockCode = selectedStockCode,
stockName = selectedStockName,
isDomestic = isDomestic,
tradeService = tradeService,
wsManager = wsManager
)
2026-01-10 18:16:50 +09:00
} else {
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
2026-01-13 16:04:25 +09:00
Text("분석할 종목을 선택하세요", color = Color.Gray)
2026-01-10 18:16:50 +09:00
}
}
}
VerticalDivider()
2026-01-13 16:04:25 +09:00
// [우측 30%] 시장 추천 TOP 20 (실전 데이터)
2026-01-10 18:16:50 +09:00
Column(modifier = Modifier.weight(0.3f).fillMaxHeight().padding(8.dp)) {
2026-01-13 16:04:25 +09:00
MarketSection(tradeService) { code, name, isDom ->
2026-01-10 18:16:50 +09:00
selectedStockCode = code
selectedStockName = name
2026-01-13 16:04:25 +09:00
isDomestic = isDom
println("selectedStockCode $selectedStockCode selectedStockName $selectedStockName isDomestic $isDomestic")
2026-01-10 18:16:50 +09:00
}
}
}
}
@Composable
2026-01-13 16:04:25 +09:00
fun VerticalDivider() {
Box(Modifier.fillMaxHeight().width(1.dp).background(Color.LightGray))
2026-01-10 18:16:50 +09:00
}