-
Notifications
You must be signed in to change notification settings - Fork 526
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
Kotlin Multiplatform support #561
Merged
Merged
Conversation
This file contains 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.
The multiplatform calendar library is ready, you can view the sample project online at https://calendar.kizitonwose.dev
Following the discussions at #554, I decided to publish the multiplatform library under a different module name
com.kizitonwose.calendar:compose-multiplatform
, so the Androidview
andcompose
libraries using thejava.time
APIs will keep existing in their modulescom.kizitonwose.calendar:view
andcom.kizitonwose.calendar:compose
respectively. This was done for a few reasons:The Compose Multiplatform library release happens much later after the Android library is released, which makes sense given the work needed to be done by the JetBrains team for multiplatform support. For example, version 1.7.0-alpha01 of the Android compose library was released on 24th January 2024, while version 1.7.0-alpha01 of the compose multiplatform library was released on 3rd July 2024. Historically, every major compose version has introduced a breaking change in the underlying API used for the calendar page snapping logic and required an urgent fix to support users already on the Alpha or Beta Compose version. Moving the compose project entirely to compose multiplatform means such quick fixes would no longer be possible, as Android users would need to wait until the relevant compose multiplatform project is released.
I do not want to remove the usage of
java.time
APIs in the project as they are quite fun to work with. Also, keep in mind that many Android projects out there do not have multiplatform setup, so I do not want to force the library users to use thekotlinx-datetime
library. I attempted using expect/actual declarations to see if I can have one compose multiplatform project while exposingjava.time
APIs for Android projects, but that got messy as I found myself essentially rewriting a lot of date APIs which is going to be troublesome to maintain.Another approach to ensure that the
java.time
library implementation is available is using generics to create a base calendar implementation and expose what is needed for thejava.time
andkotlinx-datetime
libraries, but this has the problem that library users have to write things likeCalendarState<YearMonth, CalendarMonth>
,CalendarLayoutInfo<CalendarMonth>
all over the place which is not so nice. Also, theview
module users will then have to deal with this compose mess which has nothing to do with them since the core model classes are shared across the compose and view libraries.I concluded that it is easier to just publish a separate artifact for compose multiplatform. Of course, this means that some of the inconvenience saved on the library consumer will be passed on to the library maintainer/developer. However, the library API is quite stable and does not change much, so maintaining the library for
java.time
and compose multiplatform should hopefully not be too much hassle.