Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 667e21ed authored by Ellen Poe's avatar Ellen Poe
Browse files

Merge branch 'ellenhp/new_search_results_design' into 'main'

New design for search results screen (no card)

See merge request e/os/cardinal!56
parents e5f41e0b 0e8ce0e7
Loading
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -34,12 +34,14 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.isImeVisible
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeContent
import androidx.compose.foundation.layout.safeContent
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.safeDrawing
@@ -1305,7 +1307,9 @@ private fun HomeScreenComposable(
}
}




@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class)
@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class,
    ExperimentalLayoutApi::class
)
@Composable
@Composable
fun CardinalAppScaffold(
fun CardinalAppScaffold(
    scaffoldState: BottomSheetScaffoldState,
    scaffoldState: BottomSheetScaffoldState,
@@ -1322,7 +1326,7 @@ fun CardinalAppScaffold(
    val handleHeight = 48.dp
    val handleHeight = 48.dp


    // If toolbar is visible, add padding for it below the scaffold
    // If toolbar is visible, add padding for it below the scaffold
    val bottomPadding = if (showToolbar) TOOLBAR_HEIGHT_DP else 0.dp
    val bottomPadding = if (showToolbar && !WindowInsets.isImeVisible) TOOLBAR_HEIGHT_DP else 0.dp


    Box(modifier = Modifier.fillMaxSize()) {
    Box(modifier = Modifier.fillMaxSize()) {
        BottomSheetScaffold(
        BottomSheetScaffold(
+6 −3
Original line number Original line Diff line number Diff line
@@ -30,10 +30,10 @@ import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.ime
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.Button
@@ -72,6 +72,7 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.max
import androidx.navigation.NavController
import androidx.navigation.NavController
import earth.maps.cardinal.R.dimen
import earth.maps.cardinal.R.dimen
import earth.maps.cardinal.R.drawable
import earth.maps.cardinal.R.drawable
@@ -92,6 +93,7 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import kotlinx.coroutines.launch
import org.maplibre.spatialk.geojson.BoundingBox
import org.maplibre.spatialk.geojson.BoundingBox
import uniffi.ferrostar.Route
import uniffi.ferrostar.Route
import kotlin.math.max


enum class FieldFocusState {
enum class FieldFocusState {
    NONE, FROM, TO
    NONE, FROM, TO
@@ -128,8 +130,9 @@ fun DirectionsScreen(


    val coroutineScope = rememberCoroutineScope()
    val coroutineScope = rememberCoroutineScope()


    val bottomPadding = with(LocalDensity.current) {
    val bottomPadding: Dp = with(LocalDensity.current) {
        WindowInsets.safeDrawing.getBottom(this).toDp()
        // TODO: Find out if there's a way to get the safe drawing insets without the IME insets.
        max(0, WindowInsets.safeDrawing.getBottom(this) - WindowInsets.ime.getBottom(this)).toDp()
    }
    }


    LaunchedEffect(Unit) {
    LaunchedEffect(Unit) {
+10 −3
Original line number Original line Diff line number Diff line
@@ -31,6 +31,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.text.KeyboardOptions
@@ -312,10 +313,13 @@ private fun ContentBelow(


    if (homeInSearchScreen) {
    if (homeInSearchScreen) {
        LazyColumn {
        LazyColumn {
            items(geocodePlaces) {
            itemsIndexed(geocodePlaces) { index, place ->
                if (index != 0) {
                    HorizontalDivider(modifier = Modifier.fillMaxWidth())
                }
                SearchResultItem(
                SearchResultItem(
                    addressFormatter = addressFormatter,
                    addressFormatter = addressFormatter,
                    it,
                    place,
                    onPlaceSelected
                    onPlaceSelected
                )
                )
            }
            }
@@ -332,7 +336,10 @@ private fun ContentBelow(
    } else {
    } else {
        LazyColumn {
        LazyColumn {
            // Show recent searches if any.
            // Show recent searches if any.
            items(recentSearches.value) { recentSearch ->
            itemsIndexed(recentSearches.value) { index, recentSearch ->
                if (index != 0) {
                    HorizontalDivider(modifier = Modifier.fillMaxWidth())
                }
                SearchResultItem(
                SearchResultItem(
                    addressFormatter = addressFormatter,
                    addressFormatter = addressFormatter,
                    place = viewModel.searchToPlace(recentSearch),
                    place = viewModel.searchToPlace(recentSearch),
+7 −3
Original line number Original line Diff line number Diff line
@@ -28,8 +28,10 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.material3.Card
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.MaterialTheme
@@ -60,7 +62,10 @@ fun SearchResults(
) {
) {
    val addressFormatter = remember { AddressFormatter() }
    val addressFormatter = remember { AddressFormatter() }
    LazyColumn(modifier = modifier) {
    LazyColumn(modifier = modifier) {
        items(places) { place ->
        itemsIndexed(places) { index, place ->
            if (index != 0) {
                HorizontalDivider(modifier = Modifier.fillMaxWidth())
            }
            SearchResultItem(
            SearchResultItem(
                addressFormatter = addressFormatter,
                addressFormatter = addressFormatter,
                place = place,
                place = place,
@@ -121,7 +126,7 @@ fun SearchResultItem(
    onPlaceSelected: (Place) -> Unit,
    onPlaceSelected: (Place) -> Unit,
    onRemoveTapped: (() -> Unit)? = null,
    onRemoveTapped: (() -> Unit)? = null,
) {
) {
    Card(
    Box(
        modifier = Modifier
        modifier = Modifier
            .fillMaxWidth()
            .fillMaxWidth()
            .padding(bottom = dimensionResource(dimen.padding))
            .padding(bottom = dimensionResource(dimen.padding))
@@ -129,7 +134,6 @@ fun SearchResultItem(
                // Convert GeocodeResult to Place with a unique ID based on properties
                // Convert GeocodeResult to Place with a unique ID based on properties
                onPlaceSelected(place)
                onPlaceSelected(place)
            },
            },
        elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
    ) {
    ) {
        Row(
        Row(
            modifier = Modifier
            modifier = Modifier