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

[Feature Request] Jetbrain compose support #1

Closed
kdreamix opened this issue Aug 28, 2021 · 30 comments
Closed

[Feature Request] Jetbrain compose support #1

kdreamix opened this issue Aug 28, 2021 · 30 comments
Labels
enhancement New feature or request

Comments

@kdreamix
Copy link

Any plans on supporting multiplatform with jb compose for desktop app? 🥰

@p-lr
Copy link
Owner

p-lr commented Aug 28, 2021

I will consider that once jb compose hits beta.

@p-lr p-lr added the enhancement New feature or request label Aug 28, 2021
@mcpiroman
Copy link

(According to the names of the of their releases they have hit beta and even RC :))

@p-lr
Copy link
Owner

p-lr commented Nov 29, 2021

This will be my next priority after #19

@acousticksan
Copy link

Any news?)

@p-lr
Copy link
Owner

p-lr commented Mar 3, 2022

I plan to start working on it in a few weeks.

@wefhy
Copy link

wefhy commented Mar 24, 2023

I just found this project and it looks like exactly what I need. My app targets both desktop and android though. Is there any ETA for this?
Seems like Jetbrains plans to make KMM stable by the end of the year

@p-lr
Copy link
Owner

p-lr commented Mar 24, 2023

As I don't have much experience in KMM right now, my initial attempt to make this library a KMM project was a bit too much.
It might be easier to just make it work for desktop, publish a new artifact like mapcompose-desktop, and then figure out a way to unify desktop and android code base under the same project.
In any case, I would love to see this library work on desktop. It's just not my priority right now. Any contributions for the desktop evolution are welcome.

@Lewik
Copy link

Lewik commented Mar 24, 2023

@wefhy Some time ago I was need multiplatform map. So I created one. https://github.com/Lewik/mapview It's a bit outdated, but demos (main.kt files) should work. If it interesting, I can update it. We used it in desktop and android. If you have any questions - feel free to text me, I'll help.

@krzysztofsroga
Copy link

Thanks for the update!

I was able to port the project to desktop compose yesterday: https://github.com/krzysztofsroga/MapComposeDesktop
It's not perfect, dp conversions are done with just an arbitrary number(so clusters and markers are not displayed properly) . But it required only a couple of changes to display the map correctly on desktop.

So to be honest we just need some gradle magician to merge these two projects together. In theory both Compose Desktop and Android Canvas use Skia under the hood so the changes are minimal and could probably be solved with expect/actual.
But it might be better to wait a couple months until compose desktop is stable? Maybe then they'll have some proper android/desktop project support.
PS if I messed something up with licensing, please let me know, I'm not an expert in this.

@p-lr
Copy link
Owner

p-lr commented Mar 29, 2023

@krzysztofsroga That's amazing news! I'll have a look. You're right, ideally desktop and Android should be under the same project. However, having a working desktop version is a major step.

@krzysztofsroga
Copy link

This commit contains all the changes that were required to make it compile for desktop (commits before were just copying the files and correcting package names)
krzysztofsroga/MapComposeDesktop@dcfbe77

Honestly it's just a proof of concept, as much as I could do in a limited amount of time. I left like two TODO items (mainly dp conversion and something with drawing patches). I didn't check whether it all works good, just that it displays the map and lets me move it. But it generally wasn't much work.

I won't have much time for the next two-three weeks, but after that I can work on fixing any issues that might be there and maybe trying to merge these two into one project. I'd just need to learn a little about how gradle work and make sure both can use the same file structure.

@p-lr
Copy link
Owner

p-lr commented Mar 29, 2023

Based on a coarse reading, I made a couple of comments. So that's really interesting. It shows the differences between the two platforms. So I guess the next step it to make it work properly on desktop, and then take a step back and see how the two projects can be merged.
@krzysztofsroga No worries if you can continue in 2-3 weeks. Thanks!

@krzysztofsroga
Copy link

krzysztofsroga commented Mar 29, 2023

I added some small changes.
Looks like dpToPx needs to be initialized
The way I added it might not be pretty, but it changes every time the window is moved between my screens (1f for big screen, 2f for small screen for me). And looks like it recomposes properly which is nice. On android dpi configuration changes are much less common.
Clusters are still a little glitchy when zoomed in or when scrolled to right or bottom edge but now they seem to display equally decent on both screens.

One time after moving the window back and forth I got this though:
obraz
So I guess dpi needs to be updated deeper in the code

Well, yeah, I'll look into this when I have free time. See you until then. For a proof of concept I'm satisfied for now 😅

@p-lr
Copy link
Owner

p-lr commented Mar 29, 2023

Hmm.. tile size does not depend on dpi. If I had to guess, I would say the gap between tiles has something to do with the changes on tile positioning (the comment I made about the state). Anyway, we'll see. This is really nice for a proof of concept ;)

@PicoPocoo
Copy link

Hey guys, I hate to ask this question to open source devs... is this still somewhat of a priority?
I am currently choosing my stack for compose multi-platform and I am desperately trying to avoid G&A-Maps.
Thanks for your awesome work!

@p-lr
Copy link
Owner

p-lr commented Oct 12, 2023

I made this library mostly because I'm using it on Android. Right now, I don't have time to make it multiplatform.
That may change in the future. Meanwhile, I'm relying on open source contributors for this.

@prabinshrestha
Copy link

I was searching for compose library to use for openstreet map tile and i stumbled onto your library which seems promising and nice.Please update it for kotlin multiplatform, compose multiplatform. The usecase might be huge for those who dont want to use google or apple map.Thank you for your contribution and really apreciate it.

@p-lr
Copy link
Owner

p-lr commented Dec 27, 2023

@prabinshrestha Yes. Actually, I'd like to make an ios version. However, Compose for ios is still in alpha. Updating it for compose multiplatform might be a better start as it would require most necessary structural changes.

@rkreienbuehl
Copy link

Would love to see this for compose multiplatform. I started a new repo and started to change the code from of @krzysztofsroga in the repo MapComposeDesktop to make it work for multiplatform, but am not finished yet and couldn't test the changes by now. For me it is more of a learning opportunity, because I am relatively new to kotlin, especially to coroutines. If it helps, I can share my repo with the changes by now.

@p-lr
Copy link
Owner

p-lr commented Mar 10, 2024

I believe making it work for Compose desktop is the first step (and hard enough).
Only then, desktop and Android platforms could be fused in one code base.
If you manage to make it work consistently for desktop, that would be great. Good luck!

@rkreienbuehl
Copy link

I added some small changes. Looks like dpToPx needs to be initialized The way I added it might not be pretty, but it changes every time the window is moved between my screens (1f for big screen, 2f for small screen for me). And looks like it recomposes properly which is nice. On android dpi configuration changes are much less common. Clusters are still a little glitchy when zoomed in or when scrolled to right or bottom edge but now they seem to display equally decent on both screens.

One time after moving the window back and forth I got this though: obraz So I guess dpi needs to be updated deeper in the code

Well, yeah, I'll look into this when I have free time. See you until then. For a proof of concept I'm satisfied for now 😅

@krzysztofsroga I faced the same issue when porting mapcompose to multiplatform by using your code as starting point. by changing drawImage to drawImageRect inside TileCanvas, I could fix this issue.

I now have a working map for iOS, desktop and android. Next step for me is to port all the demos of mapcompose.

@p-lr
Copy link
Owner

p-lr commented Mar 19, 2024

Excellent news ! Looking forward to see all the changes your made to make it work.

@p-lr
Copy link
Owner

p-lr commented Mar 21, 2024

@rkreienbuehl Could you please share your fork of MapCompose? (even it's still in WIP) I'd like to start looking at the changes and think about what to do next.

@rkreienbuehl
Copy link

rkreienbuehl commented Mar 21, 2024

@p-lr I copied the files and made a complete new Repo by using the https://kmp.jetbrains.com. The repo is available at https://github.com/rkreienbuehl/MapComposeKMP.

Biggest changes are:

  • TileStreamProvider's getTileStream returns ByteArray? (InputStream is not possible in multiplatform and the new resources api can also return ByteArray for resource files, but maybe there is a better solution for this?)
  • instead of Bitmap the BitmapForLayer stores ByteArray (skia Bitmap ans android Bitmap aren't compatible as types, maybe theres an other way to deal with this, seemed the easiest for me at the moment)
  • UUID's are changed to be type String
  • TileCanvas is implemented separately for each platform by using code from MapComposeDesktop and fixing the display error mentioned (maybe could be more unified in common code)

With these changes there is very little code that had to be written per platform. The iOS demo app works, but you have to change TEAM_ID inside demo/iosApp/Configuration/Config.xcconfig. the iOS and desktop apps only contain the OSM example by now.

I started porting the demo app, hope to finish this on saturday.

@p-lr
Copy link
Owner

p-lr commented Mar 21, 2024

@rkreienbuehl This is huge! Honestly, I thought making the KMP version would require more structural changes.
You should know, the library has changed since the fork MapComposeDesktop. Consequently, recent changes will have to be back-ported. For example, the file Pool.kt has been replaced by BitmapPool.kt.
You probably shouldn't worry about that right now, and continue your work on the demo app. I will take care of that.

My plan is to make a kmp branch, and start from your work. Of course, it should be done fairly so that your contributions will be clearly visible in git history. We'll talk about those details later. I've created a separate discussion, it will be useful for the next steps.

Finally, thank you very much for what you're doing.

@rkreienbuehl
Copy link

rkreienbuehl commented Mar 21, 2024

@p-lr I saw that the code of MapComposeDesktop was not updated for a year, so I started with your code from commit 4235d0c34752d2845e0da1644b9addbccd156be3 and took the changes from MapComposeDesktop as a little help, so there are only the changes of the last 5 commits missing. I don't know if I changed the code to not use BitmapPool.kt, but I can look at this when I finished porting the demo apps.

@p-lr
Copy link
Owner

p-lr commented Mar 22, 2024

@rkreienbuehl Alright. I answered here.

@p-lr
Copy link
Owner

p-lr commented Mar 27, 2024

Work is underway : https://github.com/p-lr/MapComposeMP
This is promising! 🎉

@p-lr
Copy link
Owner

p-lr commented Apr 6, 2024

MapCompose Multiplatform is officially released.

@p-lr p-lr closed this as completed Apr 6, 2024
@rkreienbuehl
Copy link

Great news, thanks for the work of the past days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

10 participants