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

Scalebar: Refactor ViewModel #715

Open
wants to merge 29 commits into
base: feature-branches/scalebar
Choose a base branch
from

Conversation

eri9000
Copy link
Collaborator

@eri9000 eri9000 commented Jan 22, 2025

Related to issue: https://devtopia.esri.com/runtime/kotlin/issues/5245

Summary of changes:

  • Refactors methods out of the ViewModel and removes it since it isn't needed.
  • Updates test to remove the view model

NOTE: as agreed, we will come back to the other methods that need a composable context

Pre-merge Checklist

@eri9000 eri9000 marked this pull request as ready for review January 22, 2025 22:40
@eri9000 eri9000 self-assigned this Jan 22, 2025
@eri9000 eri9000 requested a review from puneet-pdx January 22, 2025 22:41
Copy link
Collaborator

@puneet-pdx puneet-pdx left a comment

Choose a reason for hiding this comment

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

@eri9000 looks good. One question

} else {
mutableListOf()
}
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are we adding this else block?

The previous implementation was just doing this

if (style == ScalebarStyle.Bar || style == ScalebarStyle.Line) {
            localLabels.lastOrNull()?.let {
                _labels = mutableListOf(it)
            }
        } else {
            _labels = localLabels
        }

Copy link
Collaborator

Choose a reason for hiding this comment

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

can we check early for default values of displayLength and lineMapLength and displayUnit and return an empty list rather than at the end here

Copy link
Collaborator

@puneet-pdx puneet-pdx left a comment

Choose a reason for hiding this comment

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

@eri9000 some naming suggestions

@@ -78,7 +78,7 @@ fun MainScreen(modifier: Modifier) {
.align(Alignment.BottomStart)
) {
Scalebar(
maxWidth = 175.0,
maxDisplayWidth = 175.0,
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should just be maxWidth as the user is only concerned with what is shown on the display. From the user perspective there is only the width of the Scalebar being shown on the screen. I think this should simply be maxWidth

@@ -55,7 +61,7 @@ import kotlin.time.Duration.Companion.seconds
*/
@Composable
public fun Scalebar(
maxWidth: Double, // maximum screen width allotted to the scalebar
maxDisplayWidth: Double, // maximum screen width allotted to the scalebar
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should just be maxWidth as the user is only concerned with what is shown on the display. From the user perspective there is only the width of the Scalebar being shown on the screen. I think this should simply be maxWidth
from the design,

The Scalebar must shrink and grow. It shouldn't grow past what the designer has said it's "width" is.

@@ -201,15 +200,15 @@ private fun measureAvailableLineDisplayLength(
*/
@Composable
internal fun measureMinSegmentWidth(
lineMapLength: Double,
scalebarLineLength: Double,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have 2 lengths for the scalebar. One is for the screen and its equivalent in map units(meters, feet etc). This is representing the second one. The first one we are calling displayLength. We can call this,

  • scalebarLengthGeodetic,
  • scalebarlengthInMapUnits,
  • GeodeticLength,
  • MapUnitLength

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