...
This commit is contained in:
@@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.Button
|
||||
import androidx.compose.material.ButtonDefaults
|
||||
import androidx.compose.material.Card
|
||||
import androidx.compose.material.CircularProgressIndicator
|
||||
import androidx.compose.material.Divider
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
@@ -24,11 +25,12 @@ import kotlinx.coroutines.launch
|
||||
import model.KisSession
|
||||
import model.RealTimeTrade
|
||||
import network.AiService
|
||||
import service.StockAnalysisManager
|
||||
|
||||
@Composable
|
||||
fun AiAnalysisView(stockName: String, currentPrice: String, trades: List<model.RealTimeTrade>) {
|
||||
var aiOpinion by remember { mutableStateOf("분석 대기 중...") }
|
||||
var isLoading by remember { mutableStateOf(false) }
|
||||
var isAnalyzing by remember { mutableStateOf(false) }
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
// KisSession의 전역 설정을 참조
|
||||
@@ -53,15 +55,29 @@ fun AiAnalysisView(stockName: String, currentPrice: String, trades: List<model.R
|
||||
Button(
|
||||
onClick = {
|
||||
scope.launch {
|
||||
isLoading = true
|
||||
aiOpinion = "데이터 분석 중..."
|
||||
aiOpinion = network.AiService.fetchAnalysis(stockName, currentPrice, trades)
|
||||
isLoading = false
|
||||
isAnalyzing = true
|
||||
try {
|
||||
// 실시간 데이터 수집부터 분석까지 한 번에 실행
|
||||
aiOpinion = StockAnalysisManager.analyzeStockWithRealTimeData(
|
||||
stockName = stockName,
|
||||
currentPrice = currentPrice
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
aiOpinion = "분석 중 오류 발생: ${e.message}"
|
||||
} finally {
|
||||
isAnalyzing = false
|
||||
}
|
||||
}
|
||||
},
|
||||
enabled = isModelConfigured && !isLoading
|
||||
enabled = !isAnalyzing
|
||||
) {
|
||||
Text(if (isLoading) "분석 중" else "분석 실행", fontSize = 11.sp)
|
||||
if (isAnalyzing) {
|
||||
CircularProgressIndicator(modifier = Modifier.size(20.dp), color = Color.White)
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text("뉴스 분석 중...")
|
||||
} else {
|
||||
Text("AI 실시간 전략 분석")
|
||||
}
|
||||
}
|
||||
}
|
||||
Divider(Modifier.padding(vertical = 8.dp))
|
||||
|
||||
Reference in New Issue
Block a user