Реорганизация файлов

This commit is contained in:
mezhendosina 2023-06-12 15:41:17 +05:00
parent 2a6bfb205c
commit 1811a22a5a
4 changed files with 129 additions and 1 deletions

View file

@ -1,6 +1,6 @@
@file:OptIn(ExperimentalMaterial3Api::class)
package ru.nm17.narodmon.ui.elements
package ru.nm17.narodmon.ui.dialogs
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
@ -20,7 +20,9 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.tooling.preview.Preview
import ru.nm17.narodmon.R
import ru.nm17.narodmon.ui.theme.NarodMonTheme
import kotlin.system.exitProcess
@OptIn(ExperimentalMaterial3Api::class)
@ -83,4 +85,14 @@ fun AgreementDialog(modifier: Modifier = Modifier, onClick: () -> Unit) {
modifier = modifier
)
}
@Preview
@Composable
fun PreviewAgreementDialog(){
NarodMonTheme {
AgreementDialog {
}
}
}

View file

@ -0,0 +1,31 @@
package ru.nm17.narodmon.ui.elements
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.Checkbox
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
@ExperimentalMaterial3Api
@Composable
fun FilterCheckbox(checked: Boolean, stringRes: Int, onCheckedChange: () -> Unit) {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
.clickable { onCheckedChange() }
) {
Checkbox(
checked = checked,
onCheckedChange = { onCheckedChange() },
)
Text(
text = stringResource(id = stringRes),
)
}
}

View file

@ -0,0 +1,29 @@
package ru.nm17.narodmon.ui.elements
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.RadioButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
@ExperimentalMaterial3Api
@Composable
fun FilterRadioButton(selected: Boolean, onClick: () -> Unit, stringRes: Int) {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
.clickable { onClick.invoke() }
) {
RadioButton(
selected = selected,
onClick = onClick,
)
Text(text = stringResource(id = stringRes))
}
}

View file

@ -0,0 +1,56 @@
package ru.nm17.narodmon.ui.elements
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.ElevatedCard
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ListItem
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import ru.nm17.narodmon.ui.entities.SensorEntity
import ru.nm17.narodmon.ui.iosevkaFamily
@ExperimentalMaterial3Api
@Composable
fun SensorItem(sensorEntity: SensorEntity) {
ListItem(
overlineContent = { Text(text = "${sensorEntity.deviceName} от ${sensorEntity.deviceOwner}") },
headlineContent = { Text(text = sensorEntity.type.name) },
supportingContent = { Text(text = sensorEntity.name) },
trailingContent = {
Column(
horizontalAlignment = Alignment.End,
) {
Text(text = "${sensorEntity.distance} km")
Spacer(modifier = Modifier.size(2.dp))
ElevatedCard(
shape = RectangleShape,
) {
Text(
text = "${sensorEntity.value} ${sensorEntity.unit}",
fontFamily = iosevkaFamily,
fontWeight = FontWeight.Medium,
fontSize = 14.sp,
modifier = Modifier.padding(horizontal = 3.dp, vertical = 1.dp)
)
}
}
}
)
}
@OptIn(ExperimentalMaterial3Api::class)
@Preview
@Composable
fun PreviewSensorItem() {
// SensorItem(SensorEntity(0, Se))
}