Skip to content

Commit

Permalink
UN Trace Tool: Applies modifier (#638)
Browse files Browse the repository at this point in the history
  • Loading branch information
eri9000 authored and puneet-pdx committed Nov 6, 2024
1 parent cb9e39f commit 88fb197
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 269 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fun MainScreen(viewModel: TraceViewModel) {
label = "trace tool",
modifier = Modifier.heightIn(min = 0.dp, max = 350.dp)
) {
Trace(viewModel.traceState)
Trace(traceState = viewModel.traceState)
}
},
modifier = Modifier.fillMaxSize(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ import com.arcgismaps.toolkit.utilitynetworks.ui.TraceNavHost
@Composable
public fun Trace(
traceState: TraceState,
@Suppress("unused_parameter")
modifier: Modifier = Modifier
) {
val initializationStatus by traceState.initializationStatus
Expand All @@ -71,16 +70,15 @@ public fun Trace(

Surface(
color = MaterialTheme.colorScheme.surface,
modifier = Modifier
modifier = modifier
.fillMaxSize()
.padding(horizontal = 16.dp)
.semantics { contentDescription = localContext.getString(R.string.trace_component) }
) {
when (initializationStatus) {
InitializationStatus.NotInitialized, InitializationStatus.Initializing -> {
Box(
modifier = Modifier
.size(100.dp),
modifier = modifier,
contentAlignment = Alignment.Center
) {
CircularProgressIndicator()
Expand All @@ -89,8 +87,7 @@ public fun Trace(

else -> {
Column(
modifier = Modifier
.fillMaxSize(),
modifier = modifier,
horizontalAlignment = Alignment.CenterHorizontally
) {
if (traceState.initializationStatus.value is InitializationStatus.FailedToInitialize) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package com.arcgismaps.toolkit.utilitynetworks.internal.util

import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Tab
import androidx.compose.material3.Text
Expand All @@ -37,24 +35,20 @@ internal fun TabRow(
stringResource(R.string.new_trace) to TraceNavRoute.TraceOptions,
stringResource(R.string.results) to TraceNavRoute.TraceResults
)
Row(
Modifier
.fillMaxWidth()
.padding(bottom = 16.dp)
TabRow(
selectedTabIndex = selectedIndex,
modifier = Modifier.padding(bottom = 16.dp)
) {
TabRow(selectedTabIndex = selectedIndex) {
tabItems.forEachIndexed { index, tab ->
Tab(
selected = index == selectedIndex,
onClick = {
if (index != selectedIndex) {
onNavigateTo(index to tab.second)
}
},
text = { Text(tab.first) }
)
}
tabItems.forEachIndexed { index, tab ->
Tab(
selected = index == selectedIndex,
onClick = {
if (index != selectedIndex) {
onNavigateTo(index to tab.second)
}
},
text = { Text(tab.first) }
)
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@ import androidx.activity.compose.BackHandler
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.material3.Button
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
Expand All @@ -47,21 +44,18 @@ internal fun AddStartingPointScreen(
onStopPointSelection()
}

Surface(modifier = Modifier.fillMaxSize()) {
Column(horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Top) {
Column(horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Top) {
Spacer(
modifier = Modifier
.fillMaxWidth()
.height(5.dp)
)

Spacer(
modifier = Modifier
.fillMaxWidth()
.height(5.dp)
)

Button(
onClick = {
onStopPointSelection()
}) {
Text(text = stringResource(id = R.string.cancel_starting_point_selection))
}
Button(
onClick = {
onStopPointSelection()
}) {
Text(text = stringResource(id = R.string.cancel_starting_point_selection))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,14 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.sharp.ZoomInMap
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -60,61 +56,54 @@ internal fun FeatureResultsDetailsScreen(
onBackToResults()
}

Surface(modifier = Modifier.fillMaxSize()) {
Column(
Column {
UpButton(stringResource(id = R.string.feature_results), onBackToResults)

Row(
modifier = Modifier
.fillMaxSize()
.fillMaxWidth()
.padding(bottom = 16.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center
) {
UpButton(stringResource(id = R.string.feature_results), onBackToResults)

Row(
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 16.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center
) {
Text(
text = selectedGroupName,
style = MaterialTheme.typography.titleLarge,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
LazyColumn {
item {
FeatureList(elementListWithSelectedGroupName, onFeatureSelected)
}
Text(
text = selectedGroupName,
style = MaterialTheme.typography.titleLarge,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
LazyColumn {
item {
FeatureList(elementListWithSelectedGroupName, onFeatureSelected)
}
}
}
}

@Composable
private fun FeatureList(assetTypeList: List<UtilityElement>, onFeatureSelected: (UtilityElement) -> Unit) {
Surface(modifier = Modifier.fillMaxWidth()) {
ExpandableCardWithLabel(assetTypeList[0].assetType.name, contentTitle = assetTypeList.size.toString()) {
Column {
assetTypeList.forEach { utilityElement ->
HorizontalDivider()
Row(
modifier = Modifier
.fillMaxWidth()
.padding(start = 32.dp, end = 16.dp, top = 8.dp, bottom = 8.dp)
.clickable { onFeatureSelected(utilityElement) },
) {
Icon(
imageVector = Icons.Sharp.ZoomInMap,
contentDescription = stringResource(R.string.zoom_in),
tint = MaterialTheme.colorScheme.primary
)
Text(
modifier = Modifier.padding(start = 10.dp),
text = stringResource(R.string.object_id, utilityElement.objectId),
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.primary
)
}
ExpandableCardWithLabel(assetTypeList[0].assetType.name, contentTitle = assetTypeList.size.toString()) {
Column {
assetTypeList.forEach { utilityElement ->
HorizontalDivider()
Row(
modifier = Modifier
.fillMaxWidth()
.padding(start = 32.dp, end = 16.dp, top = 8.dp, bottom = 8.dp)
.clickable { onFeatureSelected(utilityElement) },
) {
Icon(
imageVector = Icons.Sharp.ZoomInMap,
contentDescription = stringResource(R.string.zoom_in),
tint = MaterialTheme.colorScheme.primary
)
Text(
modifier = Modifier.padding(start = 10.dp),
text = stringResource(R.string.object_id, utilityElement.objectId),
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.primary
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
Expand All @@ -40,7 +39,6 @@ import androidx.compose.material3.FilterChipDefaults
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -81,35 +79,29 @@ internal fun StartingPointDetailsScreen(
onBackPressed()
}

Surface(modifier = Modifier.fillMaxSize()) {
Column(
modifier = Modifier
.fillMaxWidth(),
) {
Column {
UpButton(stringResource(id = R.string.starting_points), onBackPressed)

UpButton(stringResource(id = R.string.starting_points), onBackPressed)
Title(startingPoint.name, onZoomTo, onDelete)

Title(startingPoint.name, onZoomTo, onDelete)

LazyColumn(
horizontalAlignment = Alignment.CenterHorizontally
) {
if (startingPoint.utilityElement.networkSource.sourceType == UtilityNetworkSourceType.Edge) {
item {
FractionAlongEdgeSlider(startingPoint, onFractionChanged)
}
} else if (startingPoint.utilityElement.networkSource.sourceType == UtilityNetworkSourceType.Junction
&& startingPoint.utilityElement.terminal != null
&& !startingPoint.utilityElement.assetType.terminalConfiguration?.terminals.isNullOrEmpty()
) {
item {
TerminalConfiguration(startingPoint, onTerminalSelected)
}
LazyColumn(
horizontalAlignment = Alignment.CenterHorizontally
) {
if (startingPoint.utilityElement.networkSource.sourceType == UtilityNetworkSourceType.Edge) {
item {
FractionAlongEdgeSlider(startingPoint, onFractionChanged)
}
} else if (startingPoint.utilityElement.networkSource.sourceType == UtilityNetworkSourceType.Junction
&& startingPoint.utilityElement.terminal != null
&& !startingPoint.utilityElement.assetType.terminalConfiguration?.terminals.isNullOrEmpty()
) {
item {
Attributes(startingPoint)
TerminalConfiguration(startingPoint, onTerminalSelected)
}
}
item {
Attributes(startingPoint)
}
}
}
}
Expand Down
Loading

0 comments on commit 88fb197

Please sign in to comment.