Фикс #10 #15

Merged
nm17 merged 13 commits from issue-#10 into master 2023-06-22 11:18:11 +03:00
Showing only changes of commit 80f8cc77b6 - Show all commits

View file

@ -14,13 +14,16 @@ import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowDropDown
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material.icons.rounded.ArrowDropDown
import androidx.compose.material.icons.rounded.Check
import androidx.compose.material.icons.rounded.Person
import androidx.compose.material.icons.rounded.Settings
import androidx.compose.material3.BottomSheetScaffold
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilterChip
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.SearchBar
@ -59,13 +62,14 @@ import ru.nm17.narodmon.ui.elements.TileMap
import ru.nm17.narodmon.ui.entities.SensorEntity
import ru.nm17.narodmon.ui.entities.SensorSortingUiEntity
import ru.nm17.narodmon.ui.entities.SortingTypes
import ru.nm17.narodmon.ui.navHost.MainScreenSealed
import ru.nm17.narodmon.ui.theme.NarodMonTheme
import ru.nm17.narodmon.ui.toChipTitle
@OptIn(ExperimentalMaterial3Api::class, ExperimentalAnimationApi::class)
@Composable
fun SensorsScreen(navController: NavController) {
fun SensorsScreen(navController: NavController, onSettingsClick: () -> Unit) {
val coroutineScope = rememberCoroutineScope()
var searchQuery by remember { mutableStateOf("") }
@ -119,15 +123,11 @@ fun SensorsScreen(navController: NavController) {
mutableStateOf(SheetHeight.ExtraExpanded)
}
BottomSheetScaffold(
modifier = Modifier.fillMaxSize(),
sheetPeekHeight = when (sheetHeight) {
BottomSheetScaffold(modifier = Modifier.fillMaxSize(), sheetPeekHeight = when (sheetHeight) {
SheetHeight.ExtraExpanded -> 256.dp
SheetHeight.Expanded -> 128.dp
SheetHeight.Hidden -> 0.dp
},
scaffoldState = scaffoldState,
sheetContent = {
}, scaffoldState = scaffoldState, sheetContent = {
AnimatedVisibility(visible = scaffoldState.bottomSheetState.currentValue == SheetValue.Expanded) {
OutlinedTextField(
value = searchQuery,
@ -168,8 +168,7 @@ fun SensorsScreen(navController: NavController) {
)
}
item {
FilterChip(
selected = sortingType.sortingType != SortingTypes.DISTANCE,
FilterChip(selected = sortingType.sortingType != SortingTypes.DISTANCE,
onClick = { sortingShow = true },
leadingIcon = {
Icon(
@ -191,8 +190,7 @@ fun SensorsScreen(navController: NavController) {
else sortingType.stringRes
).toChipTitle(),
)
}
)
})
}
item {
@ -202,8 +200,7 @@ fun SensorsScreen(navController: NavController) {
leadingIcon = {
if (filterMine) {
Icon(
Icons.Rounded.Check,
contentDescription = ""
Icons.Rounded.Check, contentDescription = ""
)
}
},
@ -219,8 +216,7 @@ fun SensorsScreen(navController: NavController) {
SensorItem(sensor)
}
}
}
) {
}) {
Box(modifier = Modifier.fillMaxSize()) {
SearchBar(
query = searchQuery,
@ -231,18 +227,24 @@ fun SensorsScreen(navController: NavController) {
},
onQueryChange = { query -> searchQuery = query },
onSearch = { searchActive = false },
placeholder = { Text(stringResource(R.string.search)) },
placeholder = { Text(stringResource(R.string.search_sensors)) },
trailingIcon = {
IconButton(onClick = { onSettingsClick.invoke() }) {
Icon(
Icons.Outlined.Settings,
contentDescription = stringResource(R.string.settings)
)
}
},
modifier = Modifier
.fillMaxWidth()
.padding(
horizontal = if (!searchActive) 8.dp else 0.dp,
vertical = if (!searchActive) 16.dp else 0.dp
)
) {}
TileMap(
modifier = Modifier
.fillMaxSize()
modifier = Modifier.fillMaxSize()
) {
sheetHeight =
SheetHeight.Expanded // TODO придумать, чтобы менялось на SheetHeight.ExtraExpanded после взаимодействия с картой
@ -251,25 +253,18 @@ fun SensorsScreen(navController: NavController) {
}
}
if (sortingShow) {
SortSensorsDialog(
sortingType,
onApply = {
SortSensorsDialog(sortingType, onApply = {
sortingType = it
sortingShow = false
},
onDismissRequest = {
}, onDismissRequest = {
sortingShow = false
}
)
})
}
if (filterShow) {
FilterSensorsDialog(
onApply = {
FilterSensorsDialog(onApply = {
// TODO применение фильтров
filterShow = false
},
onDismissRequest = { filterShow = false }
)
}, onDismissRequest = { filterShow = false })
}
}
@ -277,6 +272,6 @@ fun SensorsScreen(navController: NavController) {
@Composable
fun PreviewNewSensors() {
NarodMonTheme {
SensorsScreen(rememberNavController())
SensorsScreen(rememberNavController()) {}
}
}