-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Reimplement Scalebar #232
Reimplement Scalebar #232
Conversation
...libre-compose-material3/src/iosMain/kotlin/dev/sargunv/maplibrecompose/material3/util.ios.kt
Outdated
Show resolved
Hide resolved
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.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
spotless
[spotless] reported by reviewdog 🐶
Lines 233 to 261 in ebf96d2
private val METRIC_STOPS: List<Float> = listOf( | |
0.1f, | |
0.2f, | |
0.5f, | |
1f, | |
2f, | |
5f, | |
10f, | |
20f, | |
50f, | |
100f, | |
200f, | |
500f, | |
1000f, | |
2000f, | |
5000f, | |
10000f, | |
20000f, | |
50000f, | |
100000f, | |
200000f, | |
500000f, | |
1000000f, | |
2000000f, | |
5000000f, | |
10000000f, | |
20000000f, | |
40000000f, | |
) |
[spotless] reported by reviewdog 🐶
Lines 264 to 293 in ebf96d2
private val IMPERIAL_STOPS: List<Float> = listOf( | |
0.1f, | |
0.2f, | |
0.5f, | |
1f, | |
2f, | |
5f, | |
10f, | |
20f, | |
50f, | |
100f, | |
200f, | |
500f, | |
1000f, | |
2000f, | |
1f * FEET_IN_MILE, | |
2f * FEET_IN_MILE, | |
5f * FEET_IN_MILE, | |
10f * FEET_IN_MILE, | |
20f * FEET_IN_MILE, | |
50f * FEET_IN_MILE, | |
100f * FEET_IN_MILE, | |
200f * FEET_IN_MILE, | |
500f * FEET_IN_MILE, | |
1000f * FEET_IN_MILE, | |
2000f * FEET_IN_MILE, | |
5000f * FEET_IN_MILE, | |
10000f * FEET_IN_MILE, | |
20000f * FEET_IN_MILE, | |
) |
[spotless] reported by reviewdog 🐶
Line 26 in ebf96d2
"BZ", "LR", "MM", |
[spotless] reported by reviewdog 🐶
Line 28 in ebf96d2
"AS", "GU", "MH", "MP", "PR", "PW", "VI", //"WS", |
[spotless] reported by reviewdog 🐶
Lines 30 to 31 in ebf96d2
"AG", "AI", "BM", "BS", "FK", "GB", "GD", "GG", "GI", "GS", "IM", "JE", "KN", "KY", "LC", | |
"MS", "TC", "VG", "VC" -> { |
[spotless] reported by reviewdog 🐶
Line 44 in ebf96d2
"en", "my", "sm" -> { |
[spotless] reported by reviewdog 🐶
Lines 5 to 6 in ebf96d2
internal actual fun scaleBareMeasurePreference(): ScaleBarMeasure? = | |
null |
[spotless] reported by reviewdog 🐶
Lines 5 to 6 in ebf96d2
internal actual fun scaleBareMeasurePreference(): ScaleBarMeasure? = | |
null |
[spotless] reported by reviewdog 🐶
Lines 5 to 6 in ebf96d2
internal actual fun scaleBareMeasurePreference(): ScaleBarMeasure? = | |
null |
...e-material3/src/commonMain/kotlin/dev/sargunv/maplibrecompose/material3/controls/ScaleBar.kt
Outdated
Show resolved
Hide resolved
...plibre-compose-material3/src/commonMain/kotlin/dev/sargunv/maplibrecompose/material3/util.kt
Outdated
Show resolved
Hide resolved
...mpose-material3/src/androidMain/kotlin/dev/sargunv/maplibrecompose/material3/util.android.kt
Outdated
Show resolved
Hide resolved
lib/maplibre-compose-material3/src/commonMain/composeResources/values-es/strings.xml
Show resolved
Hide resolved
...mpose-material3/src/desktopMain/kotlin/dev/sargunv/maplibrecompose/material3/util.desktop.kt
Outdated
Show resolved
Hide resolved
(I can also pick this up from here and wrap up Apple implementation and the primary/secondary thing if you'd like) |
I am currently looking into the yard+mile stuff |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
0.1f, | ||
0.2f, | ||
0.5f, | ||
1f, | ||
2f, | ||
5f, | ||
10f, | ||
20f, | ||
50f, | ||
100f, | ||
200f, | ||
500f, | ||
1000f, | ||
2000f, | ||
5000f, | ||
10000f, | ||
20000f, | ||
50000f, | ||
100000f, | ||
200000f, | ||
500000f, | ||
1000000f, | ||
2000000f, | ||
5000000f, | ||
10000000f, | ||
20000000f, | ||
40000000f, |
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.
these can be generated, something like:
private fun buildStops(mantissas: Set<Int>, exponents: IntRange) = buildList {
for (e in exponents)
for (m in mantissas)
add(m.toDouble() * Math.pow(10.0, e.toDouble()))
}
private val METRIC_STOPS = buildStops(mantissas = setOf(1, 2, 5), exponents = -1..7)
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.
Looks quite ingenious! For me at least, this would introduce a readability problem however, as I find it quite hard to understand what would be the resulting list.
This is the sort of complexity where I'd say that this needs a test case. But then, at the end, it will probably not really be less lines of code.
But anyway, if you want to go ahead with this anyway, I don't mind much.
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.
For me at least, this would introduce a readability problem however, as I find it quite hard to understand what would be the resulting list.
I considered that, but I think it's mitigated with just a comment explaining it's based on scientific notation: m*10^e
.
if you want to go ahead with this anyway, I don't mind much.
sure, I'll take care of it; just need to tweak the above pattern for the transition between feet/yards and miles.
hmm, maybe the Measure should be an interface... experimenting with an implementation |
# Conflicts: # lib/maplibre-compose-material3/src/commonMain/kotlin/dev/sargunv/maplibrecompose/material3/controls/ScaleBar.kt
Alright, done! One thing I am a bit worried about is whether the See also https://developer.android.com/develop/ui/compose/performance/stability/fix#immutable-collections Should this library made to depend on kotlinx.collections.immutable to fix this? |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Strong skipping should prevent that, right? We can also tag them with |
I thought strong skipping is only for automatic lambda memoization? The docs make it sound like I have to annotate the thing as If we just annotate it as |
separately, I'm tempted to experiment with https://github.com/kevincianfarini/alchemist to represent the length units and their conversion using their |
ah yeah, I was thinking just our implementations should be
I think
https://developer.android.com/develop/ui/compose/performance/stability/strongskipping#when-skip
|
Hmm okay, sounds like we are good(?) |
yup, |
Screen_recording_20250108_014006.mp420 Megabananas! |
Screen_recording_20250106_222520.mp4
Reimplementation of scalebar. Somewhat similar to the Google Maps one, only better :-)
labelSmall
surface
andonSurface
)