From 0bdf64b7ed0d99eb549625f6009c8f813c4d9d4f Mon Sep 17 00:00:00 2001 From: mezhendosina Date: Fri, 9 Jun 2023 19:31:08 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20Ui=20=D0=B4=D0=BB=D1=8F=20=D0=B2=D0=B5=D0=B1-=D0=BA?= =?UTF-8?q?=D0=B0=D0=BC=D0=B5=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle.kts | 6 +- .../narodmon/ui/webCamsScreen/WebCamItem.kt | 74 +++++++++++++++++++ .../ui/webCamsScreen/WebCamUiEntity.kt | 13 ++++ .../ui/webCamsScreen/WebCamsScreen.kt | 63 ++++++++++++++++ 4 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/ru/nm17/narodmon/ui/webCamsScreen/WebCamItem.kt create mode 100644 app/src/main/java/ru/nm17/narodmon/ui/webCamsScreen/WebCamUiEntity.kt create mode 100644 app/src/main/java/ru/nm17/narodmon/ui/webCamsScreen/WebCamsScreen.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 9be7f7e..153e5da 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -145,4 +145,8 @@ dependencies { // Map Compose library implementation("ovh.plrapps:mapcompose:2.7.1") -} \ No newline at end of file + + // Glide + implementation ("com.github.bumptech.glide:glide:4.14.2") + implementation("com.github.bumptech.glide:compose:1.0.0-alpha.1") + } \ No newline at end of file diff --git a/app/src/main/java/ru/nm17/narodmon/ui/webCamsScreen/WebCamItem.kt b/app/src/main/java/ru/nm17/narodmon/ui/webCamsScreen/WebCamItem.kt new file mode 100644 index 0000000..1bf1928 --- /dev/null +++ b/app/src/main/java/ru/nm17/narodmon/ui/webCamsScreen/WebCamItem.kt @@ -0,0 +1,74 @@ +package ru.nm17.narodmon.ui.webCamsScreen + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp +import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi +import com.bumptech.glide.integration.compose.GlideImage +import ru.nm17.narodmon.ui.iosevkaFamily + +@OptIn(ExperimentalGlideComposeApi::class) +@Composable +fun WebCamItem(webCamEntity: WebCamUiEntity) { + Box( + modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp), + contentAlignment = Alignment.BottomStart + ) { + GlideImage( + model = webCamEntity.imageUrl, + contentDescription = webCamEntity.name, + contentScale = ContentScale.FillHeight, + modifier = Modifier + .clip(RoundedCornerShape(8.dp)) + .height(240.dp) + .fillMaxWidth() + ) + Row( + modifier = Modifier + .clip( + RoundedCornerShape(bottomEnd = 8.dp, bottomStart = 8.dp) + ) + .background(Color(0f, 0f, 0f, 0.55f)) + .padding(start = 16.dp, end = 16.dp, bottom = 12.dp, top = 8.dp), + verticalAlignment = Alignment.CenterVertically + ) { + Column { + Text( + text = webCamEntity.time, + color = Color.White, + fontFamily = iosevkaFamily + ) + Text( + text = webCamEntity.name, + color = Color.White, + maxLines = 1, + fontFamily = iosevkaFamily + ) + + } + Text( + text = "${webCamEntity.distance} км", + color = Color.White, + fontFamily = iosevkaFamily, + modifier = Modifier.fillMaxWidth(), + textAlign = TextAlign.End + ) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/ru/nm17/narodmon/ui/webCamsScreen/WebCamUiEntity.kt b/app/src/main/java/ru/nm17/narodmon/ui/webCamsScreen/WebCamUiEntity.kt new file mode 100644 index 0000000..e17a48e --- /dev/null +++ b/app/src/main/java/ru/nm17/narodmon/ui/webCamsScreen/WebCamUiEntity.kt @@ -0,0 +1,13 @@ +package ru.nm17.narodmon.ui.webCamsScreen + +import android.graphics.Bitmap +import androidx.compose.ui.graphics.ImageBitmap + +data class WebCamUiEntity( + val id: Int, + val name: String, + val distance: Int, + val location: String, + val time: String, + val imageUrl: String +) diff --git a/app/src/main/java/ru/nm17/narodmon/ui/webCamsScreen/WebCamsScreen.kt b/app/src/main/java/ru/nm17/narodmon/ui/webCamsScreen/WebCamsScreen.kt new file mode 100644 index 0000000..98298b9 --- /dev/null +++ b/app/src/main/java/ru/nm17/narodmon/ui/webCamsScreen/WebCamsScreen.kt @@ -0,0 +1,63 @@ +package ru.nm17.narodmon.ui.webCamsScreen + +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items +import androidx.compose.runtime.Composable +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.tooling.preview.Preview +import androidx.compose.ui.viewinterop.AndroidView +import ru.nm17.narodmon.ui.theme.NarodMonTheme + +@Composable +fun WebCamsScreen() { + + var webCams by remember { + mutableStateOf( + listOf( + WebCamUiEntity( + 1, + "Крутая камера", + 1, + "Улица Пушкина, дом Калатушкина, кватира под номером 5", + "12:45", + "https://images-webcams.windy.com/51/1559159251/current/preview/1559159251.jpg?1686320054" + ), + WebCamUiEntity( + 2, + "Крутая камера 2", + 2, + "Улица Пушкина, дом Калатушкина, кватира под номером 5", + "12:45", + "https://images-webcams.windy.com/51/1559159251/current/preview/1559159251.jpg?1686320054" + ), + WebCamUiEntity( + 3, + "Крутая камера 3", + 3, + "Улица Пушкина, дом Калатушкина, кватира под номером 5", + "12:45", + "https://images-webcams.windy.com/51/1559159251/current/preview/1559159251.jpg?1686320054" + ) + ) + ) + } // TODO источник камер + + LazyColumn() { + items(webCams) { + WebCamItem(webCamEntity = it) + } + } +} + +@Preview +@Composable +fun PreviewWebCams() { + NarodMonTheme { + WebCamsScreen() + } +} \ No newline at end of file