Migrate MoveNodeFragment speech bubble content to Compose (commonMain)#6797
Open
michaelabon wants to merge 1 commit intostreetcomplete:masterfrom
Open
Migrate MoveNodeFragment speech bubble content to Compose (commonMain)#6797michaelabon wants to merge 1 commit intostreetcomplete:masterfrom
michaelabon wants to merge 1 commit intostreetcomplete:masterfrom
Conversation
MoveNodeFragment's UI is split between Android-specific map interaction (arrow drawing, pin positioning, screen coordinate conversion) and portable speech bubble content (title, description, buttons). Only the latter needs to differ per platform, so extracting it to a shared composable lets the upcoming iOS port reuse the same UI without duplicating the layout logic. MeasureDisplayUnit moves to commonMain because the composable's caller needs it to format distances. The file is pure Kotlin (kotlin.math + kotlinx.serialization) with one exception: String.format is unavailable in Kotlin/Native, so it's replaced with a small formatFixed helper that produces identical output for the 0/1/2 decimal cases this class uses. The Fragment wrapper keeps all its existing responsibilities (arrow drawable, pin marker, IsCloseableBottomSheet/IsMapPositionAware interfaces, survey confirmation, edit submission) and passes a MoveNodeDistanceState to the composable instead of imperatively updating TextViews. No changes to MainActivity or the Listener interface. Addresses streetcomplete#6796
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses #6796
MoveNodeFragment's speech bubble content (title, description, cancel/OK buttons) into aMoveNodeFormcomposable incommonMainMeasureDisplayUnittocommonMain(replaceString.formatwith the project'sNumberFormatterexpect/actual for locale-aware formatting on both platforms)androidMainkeeps arrow drawable, pin positioning, map interfaces, survey confirmation, and edit submissionApproach
The split follows the bottom-up pattern from PR #6022 (BuildingLevelsForm): portable UI in
commonMain, platform wrapper inandroidMain. The Fragment now passes aMoveNodeDistanceStatesealed interface to the composable instead of imperatively updating TextViews and togglingpopIn/popOuton the OK button.No changes to
MainActivity,MoveNodeFragment.Listener, or DI wiring.Test plan
./gradlew assembleDebugcompiles cleanly./gradlew :app:compileKotlinIosSimulatorArm64compiles cleanly (with fix branches merged)Again, I'm very happy to change the approach or anything here, based on your feedback.