diff --git a/app/build.gradle.kts b/app/build.gradle.kts index f0a4028..cd601d2 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -49,6 +49,7 @@ dependencies { implementation(project(":features:main")) implementation(project(":features:auth")) implementation(project(":features:splash")) + implementation ("io.github.ehsannarmani:compose-charts:0.0.18") implementation(libs.bundles.koin) implementation(libs.bundles.ktor) @@ -64,6 +65,9 @@ dependencies { implementation(libs.androidx.ui.graphics) implementation(libs.androidx.ui.tooling.preview) implementation(libs.androidx.material3) + implementation(libs.material) + implementation(libs.material) + implementation(libs.material) testImplementation(libs.junit) androidTestImplementation(libs.androidx.junit) androidTestImplementation(libs.androidx.espresso.core) diff --git a/app/src/main/java/com/chillrate/MainActivity.kt b/app/src/main/java/com/chillrate/MainActivity.kt index c96e49d..f927d56 100644 --- a/app/src/main/java/com/chillrate/MainActivity.kt +++ b/app/src/main/java/com/chillrate/MainActivity.kt @@ -4,9 +4,25 @@ import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge -import com.chillrate.foundation.services.ProvideGlobalSheet -import com.chillrate.navigation.AppNavHost +import androidx.compose.animation.core.tween +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.SolidColor +import androidx.compose.ui.unit.dp import com.chillrate.ui.theme.AppTheme +import ir.ehsannarmani.compose_charts.LineChart +import ir.ehsannarmani.compose_charts.models.DrawStyle +import ir.ehsannarmani.compose_charts.models.Line +import kotlinx.coroutines.delay + class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -14,11 +30,44 @@ class MainActivity : ComponentActivity() { enableEdgeToEdge() setContent { AppTheme { - ProvideGlobalSheet { - AppNavHost() -// val splash = remember { SplashFeature(SplashProvider) } -// splash.content(Modifier) + var liveinfo by remember { + mutableStateOf(listOf(28.0, 41.0, 5.0, 10.0, 35.0)) + } + + val data = remember(liveinfo) { + listOf( + Line( + label = "Windows", + values = liveinfo.subList((liveinfo.size - 10).coerceAtLeast(0), liveinfo.lastIndex), + color = SolidColor(Color(0xFF23af92)), + firstGradientFillColor = Color.Transparent, + secondGradientFillColor = Color.Transparent, + drawStyle = DrawStyle.Stroke(width = 2.dp), + curvedEdges = false, + gradientAnimationDelay = 0L, + gradientAnimationSpec = tween(0), + strokeAnimationSpec = tween(0) + ) + ) + } + + LineChart( + modifier = Modifier + .padding(horizontal = 40.dp) + .height(200.dp), + data = data, + maxValue = 200.0, + minValue = 0.0 + ) + + + LaunchedEffect(Unit) { + while (true) { + liveinfo += liveinfo.random() + delay(1000L) + } } + } } } diff --git a/features/main/src/main/java/com/chillrate/main/children/live/presentation/LiveView.kt b/features/main/src/main/java/com/chillrate/main/children/live/presentation/LiveView.kt index cd0e597..e170a0b 100644 --- a/features/main/src/main/java/com/chillrate/main/children/live/presentation/LiveView.kt +++ b/features/main/src/main/java/com/chillrate/main/children/live/presentation/LiveView.kt @@ -22,7 +22,7 @@ fun RoomView( val sheetProvider = LocalSheetProvider.current val sensorConnected by callibriRepository.controller.sensorConnected.collectAsState() - + val data by callibriRepository.data.collectAsState() sheetProvider.setContent(SensorConnect) LaunchedEffect(sensorConnected) {