-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add option to navigate to new trace from resultscreen #597
Changes from 5 commits
c54d61a
620fec3
effe5f9
02d9e3a
14b8f76
85a5e87
8ef418b
048642b
303fbed
a0d4df8
069f389
094570c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ import androidx.compose.runtime.Immutable | |
import androidx.compose.runtime.MutableState | ||
import androidx.compose.runtime.Stable | ||
import androidx.compose.runtime.State | ||
import androidx.compose.runtime.mutableIntStateOf | ||
import androidx.compose.runtime.mutableStateListOf | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.snapshots.SnapshotStateList | ||
|
@@ -119,7 +120,8 @@ public class TraceState( | |
private val _currentScreen: MutableState<TraceNavRoute> = mutableStateOf(TraceNavRoute.TraceOptions) | ||
internal var currentScreen: State<TraceNavRoute> = _currentScreen | ||
|
||
private val completedTraces: MutableList<TraceRun> = mutableListOf() | ||
private val _completedTraces: SnapshotStateList<TraceRun> = mutableStateListOf() | ||
internal val completedTraces: List<TraceRun> = _completedTraces | ||
|
||
private var _currentTraceName: MutableState<String> = mutableStateOf("") | ||
/** | ||
|
@@ -194,7 +196,7 @@ public class TraceState( | |
|
||
internal fun setSelectedTraceConfiguration(config: UtilityNamedTraceConfiguration) { | ||
_selectedTraceConfiguration.value = config | ||
_currentTraceName.value = "${config.name} ${(completedTraces.count { it.configuration.name == config.name } + 1)}" | ||
_currentTraceName.value = "${config.name} ${(_completedTraces.count { it.configuration.name == config.name } + 1)}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I set the name in advanced options before running the trace, this is overwriting it. I would set the currentTraceName to the default value at initialization and in resetCurrentTrace, then just not do this here at all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as per our discussion this is working as expected. |
||
} | ||
|
||
internal fun showScreen(screen: TraceNavRoute) { | ||
|
@@ -277,7 +279,7 @@ public class TraceState( | |
featureResults = currentTraceElementResults, | ||
functionResults = currentTraceFunctionResults, | ||
geometryTraceResult = currentTraceGeometryResults | ||
).also { completedTraces.add(it) } | ||
).also { _completedTraces.add(it) } | ||
|
||
if (_currentTraceZoomToResults.value) { | ||
currentTraceResultGeometriesExtent?.let { | ||
|
@@ -288,10 +290,18 @@ public class TraceState( | |
) | ||
} | ||
} | ||
|
||
resetCurrentTrace() | ||
return true | ||
} | ||
|
||
private fun resetCurrentTrace() { | ||
_selectedTraceConfiguration.value = null | ||
_currentTraceStartingPoints.clear() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the design spec has a user story that says I'd interpret this as meaning the starting points should remain between traces. |
||
_currentTraceName.value = "" | ||
currentTraceGraphicsColor = Color.green | ||
_currentTraceZoomToResults.value = false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the design spec also says |
||
} | ||
|
||
private fun createGraphicForSimpleLineSymbol(geometry: Geometry, style: SimpleLineSymbolStyle, color: Color) = | ||
Graphic( | ||
geometry = geometry, | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -47,14 +47,17 @@ import androidx.compose.material3.ElevatedButton | |||||||||||||||||||||||||||||||||||||
import androidx.compose.material3.FilterChipDefaults | ||||||||||||||||||||||||||||||||||||||
import androidx.compose.material3.Icon | ||||||||||||||||||||||||||||||||||||||
import androidx.compose.material3.MaterialTheme | ||||||||||||||||||||||||||||||||||||||
import androidx.compose.material3.TabRow | ||||||||||||||||||||||||||||||||||||||
import androidx.compose.material3.OutlinedTextField | ||||||||||||||||||||||||||||||||||||||
import androidx.compose.material3.Surface | ||||||||||||||||||||||||||||||||||||||
import androidx.compose.material3.Switch | ||||||||||||||||||||||||||||||||||||||
import androidx.compose.material3.Tab | ||||||||||||||||||||||||||||||||||||||
import androidx.compose.material3.Text | ||||||||||||||||||||||||||||||||||||||
import androidx.compose.runtime.Composable | ||||||||||||||||||||||||||||||||||||||
import androidx.compose.runtime.LaunchedEffect | ||||||||||||||||||||||||||||||||||||||
import androidx.compose.runtime.MutableState | ||||||||||||||||||||||||||||||||||||||
import androidx.compose.runtime.getValue | ||||||||||||||||||||||||||||||||||||||
import androidx.compose.runtime.mutableIntStateOf | ||||||||||||||||||||||||||||||||||||||
import androidx.compose.runtime.mutableStateOf | ||||||||||||||||||||||||||||||||||||||
import androidx.compose.runtime.remember | ||||||||||||||||||||||||||||||||||||||
import androidx.compose.runtime.saveable.Saver | ||||||||||||||||||||||||||||||||||||||
|
@@ -95,7 +98,9 @@ internal fun TraceOptionsScreen( | |||||||||||||||||||||||||||||||||||||
defaultTraceName: String, | ||||||||||||||||||||||||||||||||||||||
selectedColor: Color, | ||||||||||||||||||||||||||||||||||||||
zoomToResult: Boolean, | ||||||||||||||||||||||||||||||||||||||
showResultsTab: Boolean, | ||||||||||||||||||||||||||||||||||||||
onStartingPointRemoved: (StartingPoint) -> Unit, | ||||||||||||||||||||||||||||||||||||||
onBackToResults: () -> Unit, | ||||||||||||||||||||||||||||||||||||||
onConfigSelected: (UtilityNamedTraceConfiguration) -> Unit, | ||||||||||||||||||||||||||||||||||||||
onPerformTraceButtonClicked: () -> Unit, | ||||||||||||||||||||||||||||||||||||||
onAddStartingPointButtonClicked: () -> Unit, | ||||||||||||||||||||||||||||||||||||||
|
@@ -108,10 +113,20 @@ internal fun TraceOptionsScreen( | |||||||||||||||||||||||||||||||||||||
modifier = Modifier | ||||||||||||||||||||||||||||||||||||||
.fillMaxSize() | ||||||||||||||||||||||||||||||||||||||
) { | ||||||||||||||||||||||||||||||||||||||
Column (horizontalAlignment = Alignment.CenterHorizontally) { | ||||||||||||||||||||||||||||||||||||||
Column (modifier = Modifier.padding(horizontal = 10.dp), | ||||||||||||||||||||||||||||||||||||||
horizontalAlignment = Alignment.CenterHorizontally) { | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
if (showResultsTab) { | ||||||||||||||||||||||||||||||||||||||
TabRow(onBackToResults) | ||||||||||||||||||||||||||||||||||||||
Spacer( | ||||||||||||||||||||||||||||||||||||||
modifier = Modifier | ||||||||||||||||||||||||||||||||||||||
.fillMaxWidth() | ||||||||||||||||||||||||||||||||||||||
.height(15.dp) | ||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
LazyColumn( | ||||||||||||||||||||||||||||||||||||||
modifier = Modifier | ||||||||||||||||||||||||||||||||||||||
.padding(10.dp, 3.dp) | ||||||||||||||||||||||||||||||||||||||
.padding(vertical = 3.dp) | ||||||||||||||||||||||||||||||||||||||
.weight(1f), | ||||||||||||||||||||||||||||||||||||||
horizontalAlignment = Alignment.CenterHorizontally | ||||||||||||||||||||||||||||||||||||||
) { | ||||||||||||||||||||||||||||||||||||||
|
@@ -161,6 +176,29 @@ internal fun TraceOptionsScreen( | |||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
@Composable | ||||||||||||||||||||||||||||||||||||||
private fun TabRow(onBackToResults: () -> Unit) { | ||||||||||||||||||||||||||||||||||||||
val tabItems = listOf("New Trace", "Results") | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these should be localized |
||||||||||||||||||||||||||||||||||||||
var selectedTabIndex by remember { mutableIntStateOf(0) } | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
TabRow(selectedTabIndex = selectedTabIndex) { | ||||||||||||||||||||||||||||||||||||||
tabItems.forEachIndexed { index, title -> | ||||||||||||||||||||||||||||||||||||||
var selected by remember { mutableStateOf(index == 0) } | ||||||||||||||||||||||||||||||||||||||
Tab( | ||||||||||||||||||||||||||||||||||||||
selected = selected, | ||||||||||||||||||||||||||||||||||||||
onClick = { | ||||||||||||||||||||||||||||||||||||||
selectedTabIndex = index | ||||||||||||||||||||||||||||||||||||||
selected = true | ||||||||||||||||||||||||||||||||||||||
if (index == 1) { | ||||||||||||||||||||||||||||||||||||||
onBackToResults() | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||
text = { Text(title) } | ||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
@Composable | ||||||||||||||||||||||||||||||||||||||
private fun TraceConfigurations( | ||||||||||||||||||||||||||||||||||||||
configs: List<UtilityNamedTraceConfiguration>, | ||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,8 +23,10 @@ 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.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.foundation.shape.RoundedCornerShape | ||
|
@@ -39,9 +41,12 @@ import androidx.compose.material3.HorizontalDivider | |
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.material3.Tab | ||
import androidx.compose.material3.TabRow | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableIntStateOf | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
|
@@ -64,28 +69,68 @@ import com.arcgismaps.utilitynetworks.UtilityTraceFunctionOutput | |
@Composable | ||
internal fun TraceResultScreen( | ||
traceRun: TraceRun, | ||
onBackToNewTrace: () -> Unit, | ||
onDeleteResult: () -> Unit, | ||
onZoomToResults: () -> Unit, | ||
onClearAllResults: () -> Unit | ||
) { | ||
Surface(modifier = Modifier.fillMaxSize()) { | ||
LazyColumn { | ||
item { | ||
TraceTitle(traceRun.name, onZoomToResults = onZoomToResults, onDeleteResult = onDeleteResult) | ||
} | ||
item { | ||
FeatureResult(traceRun.featureResults) | ||
} | ||
item { | ||
FunctionResult(traceRun.functionResults) | ||
} | ||
item { | ||
ClearAllResultsButton(onClearAllResults) | ||
Column(modifier = Modifier | ||
.fillMaxSize() | ||
.padding(horizontal = 10.dp)) { | ||
|
||
TabRow(onBackToNewTrace) | ||
Spacer( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.height(15.dp) | ||
) | ||
Comment on lines
+81
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would suggest moving this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reading this in the code here makes more sense, as we are adding the tabrow and the tabrow should not be adding additional space after it implicitly. |
||
LazyColumn { | ||
item { | ||
TraceTitle( | ||
traceRun.name, | ||
onZoomToResults = onZoomToResults, | ||
onDeleteResult = onDeleteResult | ||
) | ||
} | ||
item { | ||
FeatureResult(traceRun.featureResults) | ||
} | ||
item { | ||
FunctionResult(traceRun.functionResults) | ||
} | ||
item { | ||
ClearAllResultsButton(onClearAllResults) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same advice as above. Also, it seems like the internal |
||
private fun TabRow(onBackToNewTrace: () -> Unit) { | ||
val tabItems = listOf("New Trace", "Results") | ||
var selectedTabIndex by remember { mutableIntStateOf(1) } | ||
|
||
TabRow(selectedTabIndex = selectedTabIndex) { | ||
tabItems.forEachIndexed { index, title -> | ||
var selected by remember { mutableStateOf(index == 1) } | ||
Tab( | ||
selected = selected, | ||
onClick = { | ||
selectedTabIndex = index | ||
selected = true | ||
if (index == 0) { | ||
onBackToNewTrace() | ||
} | ||
}, | ||
text = { Text(title) } | ||
) | ||
} | ||
} | ||
} | ||
|
||
|
||
@Composable | ||
private fun TraceTitle(traceName: String, onZoomToResults: () -> Unit, onDeleteResult: () -> Unit) { | ||
var expanded by remember { mutableStateOf(false) } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused import