8000 Add iOS SwiftUI sample by avdim · Pull Request #1 · avdim/compose-mapview · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add iOS SwiftUI sample #1

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

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open

Add iOS SwiftUI sample #1

wants to merge 33 commits into from

Conversation

avdim
Copy link
Owner
@avdim avdim commented Jan 23, 2022

Добавил реализацию MapView на SwiftUI.
При этом уже написанный код почти не поменялся.

Места, на которые стоит обратить внимание:

  • iOS специфичный код в общих модулях:
typealias ImageIos = UIImage
actual class TileImage(
    val platformSpecificData: ImageIos, // Единственное iOS специфичное место в общем коде
    ...
)
  • Вся логика отрисовки уместилась в одной SwiftUI структуре MapViewSwiftUI.swift
  • MapStoreAdapter.kt и MapViewModel.swift нужны чтобы адаптировать MapState под SwiftUI
    StateFlow становится простым callback-ом в Swift
fun addListener(listener: (MapState) -> Unit) {
            stateFlow.collectLatest {
                listener(it)
            }
    }

image

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.

1 participant
0