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

Migrate "Add Features with Contingent Values" to Compose #283

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

Conversation

01smito01
Copy link
Collaborator

@01smito01 01smito01 commented Dec 2, 2024

Description

Migrates Add Features with Contingent Values sample from XML/views to 💫 Compose 💫

Links and Data

Sample Epic: #4961

What To Review

  • Sample works, doesn't crash, etc. You shouldn't be able to select an invalid combination of values from the bottom sheet - you may still get failures if a value isn't assigned.
  • Is the code easy to follow? Is the level of function extraction good? Are things sensibly grouped together in code?
  • Is exposing flows from the view model a good design decision (vs. putting compose mutableStateOf's in the view model)
  • Slider implementation is a bit messy (needs to be responsive to user input, but also react to feature changes in the view model). Can this be simplified?
  • Does the Readme still make sense?

How to Test

Run the sample on the sample viewer.

@01smito01 01smito01 force-pushed the oliver/contingent_values_migration branch from e5f1361 to 88b1bf9 Compare December 2, 2024 17:41
@01smito01 01smito01 marked this pull request as ready for review December 3, 2024 12:23
samples/add-features-with-contingent-values/README.md Outdated Show resolved Hide resolved
Learn more about contingent values and how to utilize them on the [ArcGIS Pro documentation](https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/contingent-values.htm).

## Tags

coded values, contingent values, feature table, geodatabase
coded values, contingent values, feature table, geodatabase, geoviewcompose, toolkit
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
coded values, contingent values, feature table, geodatabase, geoviewcompose, toolkit
coded values, contingent values, feature table, geodatabase, geoview, mapview, compose, toolkit

Copy link
Collaborator Author

@01smito01 01smito01 Dec 11, 2024

Choose a reason for hiding this comment

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

geoviewcompose and toolkit are the tags the epic recommends to add. I don't think they need to be changed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I find geoviewcompose odd as a tag but maybe there is a good reason for it. \cc @shubham7109

Copy link
Collaborator

@shubham7109 shubham7109 Dec 19, 2024

Choose a reason for hiding this comment

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

@gunt0001 The tag here was meant to match the geoviewcompose Toolkit package name. I see it as little odd too, and I recall tags must use lowercase. Alternatively, a valid option could be to use geoview-compose to match the Toolkit module name instead. (Quick test looks like the PR checker would be happy.)

\cc @TADraeseke Thoughts?

@01smito01 01smito01 requested a review from gunt0001 December 11, 2024 10:41
Learn more about contingent values and how to utilize them on the [ArcGIS Pro documentation](https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/contingent-values.htm).

## Tags

coded values, contingent values, feature table, geodatabase
coded values, contingent values, feature table, geodatabase, geoviewcompose, toolkit
Copy link
Collaborator

Choose a reason for hiding this comment

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

I find geoviewcompose odd as a tag but maybe there is a good reason for it. \cc @shubham7109

feature?.geometry = mapPoint

// create the graphic of the feature
val graphic = feature?.let { createGraphic(it) }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this the buffer graphic?

@01smito01 01smito01 requested a review from gunt0001 December 16, 2024 16:22
Copy link
Collaborator

@gunt0001 gunt0001 left a comment

Choose a reason for hiding this comment

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

@01smito01 - a few more comments.
Note, after I added a new feature, then rotate the screen, the buffer graphic for the added feature disappears, I only see the black dot. Is this expected?

// add the feature to the feature table
viewModelScope.launch {
feature?.let { featureTable!!.addFeature(it) }
feature?.load()?.getOrElse {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Technically there is no need to load the feature explicitly, it will be loaded automatically when rendered in the MapView. Is this more for debugging purposes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The add-then-load logic was copied over from the old version of the sample. Probably was for some debugging purpose - getOrElse makes a lot less sense to use than onFailure. Have removed it at any rate.

*/
fun clearFeature() {
feature = null
_featureEditState.value = FeatureEditState(statusAttributes = featureTable!!.statusFieldCodedValues())
Copy link
Collaborator

Choose a reason for hiding this comment

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

avoid !!. Couldldn't you just use default parameters here?

Suggested change
_featureEditState.value = FeatureEditState(statusAttributes = featureTable!!.statusFieldCodedValues())
_featureEditState.value = FeatureEditState()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Default parameters include an empty statusAttributes list, which is populated during init (after the contingentValuesDefinition is loaded from the feature table). So none of the UI elements would have any options available.

How about featureTable?.let{ ... } ?: return messageDialogVM.showMessage("Feature table not loaded")?

Could alternatively create a method to reload the statusAttributes, called in the mapView's onSingleTapConfirmed.

mapViewModel.clearFeature()
}
) {
val onBottomSheetStateChanged = { state: SheetState ->
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a need for this local variable? This may actually have to be remembered. Alternatively, pass it inline to BottomSheetContents:

BottomSheetContents(
   ...
   onBottomSheetStateChange = { state: SheetState ->
      if (!state.isVisible) {
         showBottomSheet = false
         mapViewModel.clearFeature()
      }
   },
   ...
)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Doesn't need to be local rather than inline - I had it that way for clarity. Will change if you think that's better.

No strict need to remember it, as it's not getting assigned a new value anywhere else. Could remember it for performance, but I don't think it's complex enough to make any appreciable difference.

@01smito01 01smito01 requested a review from gunt0001 December 18, 2024 12:05
Copy link
Collaborator

@gunt0001 gunt0001 left a comment

Choose a reason for hiding this comment

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

@01smito01 - looks great, one minor comment 👍

@01smito01
Copy link
Collaborator Author

Thanks @gunt0001. @shubham7109 can you give this a second review? This is a fairly involved sample.

Copy link
Collaborator

@shubham7109 shubham7109 left a comment

Choose a reason for hiding this comment

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

Reviewed the Kotlin code files, didn't get through with the readme changes yet.

Hope @01smito01 you find these comments helpful, feel free to reach out if you would like me to chat about them more in detail. Sample looks and works great, my main goal is to help improve readability and reduce any complexity in the app.

Feel free to use these review notes to help you with this PR: oliver/contingent_values_migration...shubham/contingent-review

@shubham7109
Copy link
Collaborator

shubham7109 commented Dec 19, 2024

@01smito01 I also noticed that createGeodatabaseCacheDir is not working as expected, since I can see the Geodatabase changes between sample sessions. Ideally, they should be deleted and placed back in the cache on every launch. Didn't get the chance to look into this.

@01smito01
Copy link
Collaborator Author

Thanks for the review @shubham7109 - have implemented most of your changes, so let me know what you think.
I've not had the time to deal with the database cache issue yet - can take a look tomoz.

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.

3 participants