Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trace UI enhancements #788

Open
wants to merge 7 commits into
base: v.next
Choose a base branch
from
Open

Trace UI enhancements #788

wants to merge 7 commits into from

Conversation

shubham7109
Copy link
Collaborator

@shubham7109 shubham7109 commented Mar 20, 2025

Related to issue: #5512

Description:

PR to update the UtilityNetworkTrace tool's UI to handle user Modifier content sizes dynamically. (fillMaxSize & wrapContentSize etc). Currently, a fillMaxSize Modifier is hard-coded within the Trace surface scaffold.

This PR aims to update the UI to adapt the Trace composable to react dynamically towards constraint sizes between Modifier content size changes, and TraceNavigation composable content changes.

Summary of changes:

  • Removed fillMaxSize from TraceScaffold
  • Removed fillMaxSize from StartingPointRow
  • Added a sizeTransform to the NavHost to be able to react to content size changes like between the TraceOptionsScreen -> AddStartingPointScreen -> TraceOptionsScreen
  • Added max weight to the LazyColumn in TraceOptionsScreen such that the "Trace" button is always visible in the content.
  • Similarly, added max weight to the LazyColumn in TraceResultScreen such that the "Clear all results" button is always visible in the content.
  • Added minor layout fixes to help keep a consistent vertical padding & vertical centering with the above layout content changes.

Test code

package com.arcgismaps.toolkit.utilitynetworktraceapp.screens

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.BottomSheetScaffold
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SheetValue
import androidx.compose.material3.rememberBottomSheetScaffoldState
import androidx.compose.material3.rememberStandardBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import com.arcgismaps.toolkit.geoviewcompose.MapView
import com.arcgismaps.toolkit.utilitynetworks.Trace
import kotlinx.coroutines.launch

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun MainScreen(viewModel: TraceViewModel) {
    val coroutineScope = rememberCoroutineScope()

    val scaffoldState = rememberBottomSheetScaffoldState(
        bottomSheetState = rememberStandardBottomSheetState(
            initialValue = SheetValue.Expanded,
            skipHiddenState = true
        )
    )

    BottomSheetScaffold(
        sheetContent = { Trace(traceState = viewModel.traceState) },
        modifier = Modifier.fillMaxSize(),
        scaffoldState = scaffoldState,
        sheetContainerColor = MaterialTheme.colorScheme.background,
        sheetSwipeEnabled = true,
    ) { padding ->
        MapView(
            arcGISMap = viewModel.arcGISMap,
            mapViewProxy = viewModel.mapViewProxy,
            graphicsOverlays = listOf(viewModel.graphicsOverlay),
            modifier = Modifier
                .padding(padding)
                .fillMaxSize(),
            onSingleTapConfirmed = { singleTapConfirmedEvent ->
                singleTapConfirmedEvent.mapPoint?.let {
                    coroutineScope.launch {
                        viewModel.traceState.addStartingPoint(it)
                    }
                }
            }
        )
    }
}

Pre-merge Checklist

@shubham7109 shubham7109 changed the title Shubham/trace UI changes Trace UI enhancements Mar 20, 2025
@shubham7109 shubham7109 self-assigned this Mar 20, 2025
@shubham7109 shubham7109 marked this pull request as ready for review March 20, 2025 20:23
@@ -106,7 +106,6 @@ private fun TraceScaffold(
Surface(
color = MaterialTheme.colorScheme.surface,
modifier = modifier
.fillMaxSize()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to removing this line, consider editing TraceScaffold to provide a default parameter modifier = Modifier.fillMaxSize(). Current behavior would be preserved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants