-
-
Notifications
You must be signed in to change notification settings - Fork 358
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
iOS - Planning #5421
Comments
On what needs to be done on the UI side of things: TL;DR:
(Disclaimer: I (too) need to find my feet with those Jetpack Frameworks I haven't worked with yet, namely mostly Composables and Navigation. The below is a result of some research, looking at example code etc., so if I did misunderstand something I describe below, please call it out!) Current UI architectureAndroid Activitys are mostly just containers and Fragments make up the brunt of components that define the view behavior, state, manage lifecycle, handle data (updates) and communication and navigation with/to their parent and child components. Views are generally defined with Android XML layouts, a few "*ViewController" classes exist that define the behavior of certain view constructs in a reusable manner. Some compound/custom views may also (still) exist. Projected UI architectureOn Android, it would look something like this: View layout, their behavior and their (ui) state is done via Composables from Jetpack Compose / Compose Multiplatform. The data used for display in the UI is accessed through ViewModels. It is probably better to use Kotlin's Finally, the navigation in-between the different composables is managed using NavHost of Jetpack Navigation somehow (didn't read much into that yet). This means that the Activity is just the entry-point of the app and there are actually no Fragments left, everything is Composables and ViewModels, which means everything can be shared. (Hooray) UI architecture stepsNow, we must avoid at all costs to open up too many construction sites at the same time. It is not feasible to go from our current architecture to the other one in one big step. Instead, we must split up the migration in as many self-contained steps that make sure the codebase stays consistent in itself: Step 1. ViewModelSlim Fragments: The data access and view state management shall go into ViewModels, owned by the Fragments. We have a ticket for that already: #5530. Even independently of iOS, this makes sense, as it properly encapsulates view logic from accessing data / managing state. Step 2. Jetpack ComposeConvert the UI layout definition and behavior code bottom-up (see migration guide, migration tutorial) to Jetpack Compose. This involves not only converting the Android XML layouts to Compose code, but also the code of "*ViewController"s, RecyclerView view holders and finally of course also Fragments, as that's where most of the view behavior is currently defined. Step 3. Compose MultiplatformGo the (hopefully small) step from Jetpack Compose to Compose Multiplatform. The biggest issue here will be how to access resources in a multiplatform way. There are some libraries already which facilitate this, like MOKO resources, but hopefully a popular and stable solution will have emerged by then. I really hope there will be something official from JetBrains. (They did announce this.) Step 4. Multiplatform ViewModel / NavigationEdit 2024-09: The ecosystem changed! It will be possible to use the Android ViewModels and Android Navigation for multiplatform, too, so this makes the below research obsolete, we can just keep using what we are using now. Already by the end of step 2, Fragments will be very slim. We have the option to stop here view-architecture-wise and just duplicate the rest of the code that still lives in these Fragments on iOS in UIViewControllers defined in Swift. I think we should revisit this when we finished these steps, as these steps are really big on its own already anyway. However, we still need to make at least ViewModels multiplatform. Interestingly, most libraries that provide some concept of ViewModels but as multiplatform also come with a solution to completely do away with Fragments (i.e. a replacement for Navigation and related things). Those that provide a multiplatform replacement for only ViewModels are KMM-ViewModel, MOKO MVVM, Summer, kmp-viewmodel and others but most of these are either kind of alpha or older and quite inactive. Here's a list of frameworks I had a little longer look at, all of these do something something ViewModel and also provide some glue for navigation: PreComposePreCompose provides both ViewModels and Navigation whose API is pretty similar to the Android equivalent in Android. The project's readme itself mentions...
Additionally, it has some integration with Koin, which is the dependency injection framework we use. The project exists since 2021 and is continuously active since mid-2022, 0.6k people starred it on GitHub. VoyagerVoyager also provides both for view models and navigation. In particular, it introduces the concept of Screens. A Screen conceptually is a replacement for a Activity or full-screen Fragment. Instead of ViewModels, we have ScreenModels, which have the same purpose as ViewModels. Good thing: Additionally, it has some setup for navigation with bottom sheets (which we use extensively) as well as tab navigation (used in profile screen). The project exists since end of 2021 and continues to be very active, 1.8k people starred it on GitHub. Version 1.0.0 was released in December 2023 and shall bring API stability, the documentation is quite good. Of the three projects I've looked at, it is the youngest. DecomposeDecompose can also serve as a replacement for the functionality described, although of the three libraries, it brings the greatest departure from the terminology, concepts and APIs from Android Jetpack:
One feature of Decompose is that it works well not only with Compose but also with SwiftUI and other UI frameworks, but I think we do not need that. But it means that Decompose is designed to be more of a general framework rather than being made for or tied to any specific UI framework. The project exists since 2020 (thus the oldest) and has been continuously very active (most active of those compared) ever since, 1.7k+ people starred it on GitHub. They are working on a new major version since at least December 2023. Striking is the extremely low number of open issues. ConclusionTo be honest, I didn't really grasp the concepts of Decompose and the independency from Compose Multiplatform is nothing we would require. The migration to ViewModels + Composables + Navigation seems to me is already enough to chew, it does not help to then learn even new (even if related) concepts. This is why I currently slightly favour Voyager, because just as PreCompose, it sticks quite closely to the concepts from Android Jetpack while at the same time is more popular and has more documentation + useful components than PreCompose has to offer, apparently. The final decision on this lies somewhat in the future, though. The goal of this preliminary research has been to first ascertain whether the concepts of ViewModel + Navigation can be transferred to multiplatform too, so that the iterative steps 1 & 2 (before 3 & 4) are possible. The outcome: Yes, it's possible, frameworks exist whose concepts and APIs are quite similar to what we have with Android Jetpack. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Thanks for the great discussions at State of the Map EU. With regards to MapLibre Native for Compose Multiplatform, it seems someone already got it to work, someone else is building a library. 👍 |
Not exactly sure where to place, but this might be useful: |
The funding through Prototype Fund ended, time for some progress update, retrospective and outlook! Progress UpdateThe work that has to be done can chiefly be grouped into two areas:
1. Replacing dependencies to JavaThe biggest tasks completed within the funding period in this regard were replacing the Java Http Client with the KMP library Ktor-Client, porting the osmfeatures library to Kotlin Multiplatform and creating the osm-opening-hours Kotlin Multiplatform library. In detail:
(blue = already done before the funding period started) What remains? Mostly fitzelkram and glue. But, well, that kind of stuff is often what takes longer than expected. One of the larger things in terms of lines of code that still needs to be done are
1. Re-Implementing the UI in Compose...and introducing ViewModels + Navigation. Approximately, the absolute effort for this is about double that of the above, so this makes up the bulk of the to-be-done work. MapLibreAn essential and large part of this undertaking was to migrate from the abandoned map renderer tangram-es to MapLibre-native, done by @Helium314 and me. It was merged to master recently because we finally found a workaround for a critical error in MapLibre. ComposeI first focused on implementing all screens except the main screen. Recently, I broke forth into the main screen though, but mostly just the controls, dialogs etc.
So, what's still to do are all the quest and overlay forms (and you know, they are often custom, that's why it is a lot of UI code) and abstracting the Android-specific implementation of MapLibre, i.e. use MapLibre in Compose. Now, I would love to not have to do the latter myself, but a library for this does not exist yet. There is, however, some developer interest in this. It looks like a group is forming to implement a library, but as it stands, there are currently 3-4 competing projects, so I hope there will be some consolidation soon: maplibre/maplibre-native#2638 RetrospectiveThe time estimations made for a full iOS-version of the app (one year full-time for one developer) are still quite on point. The MapLibre integration took about 6 weeks more than expected even though @Helium314 did preliminary work on it before and then substantially helped me complete it. Other than what has been mentioned, there were unfortunately no contributions made to this effort from other developers since I began to work full-time on it. So, now that I have worked on it for half a year, it would be roughly half a year more to complete this effort. (Plus, realistically, some generous buffer for unforeseen extra effort.) OutlookMy to dosDespite the funding having ended, there are a few things I still want to complete in order to get to a round conclusion of the work done so far. The time frame is 1-2 months (with less speed, need also some time out, really)
ContinuingExtrapolating from the last half a year, I am now less hopeful about that it would be possible to complete this project by community contributions alone. The remaining work is also still substantial. ContributingOf course, dear interested developer, any contribution done to this effort will just make completing it more feasible and no work towards that goal is lost, because we continuously integrate it into new versions of the app. If you are inclined to help, the next steps in this process are to, bit by bit, reimplement the current UI in (Jetpack) Compose and use ViewModels. The migration to Compose happens in a bottom-up sort of fashion (widgets first, then parts of the screen, at the end, the whole screen). So, a most sustainable contribution would be to start with reimplementing widgets, such as the opening hours form (big effort), the hydrant diameter form (medium effort) or the building levels input form (small effort) (or many more). Now, there could theoretically be a version of the app for iOS with limited functionality before we reached the 100%, by excluding those quests whose UI haven't been migrated yet. Tasks that have to definitely be done before that, however, are,
As required by the Prototype Fund, I also created a report that will vanish in some archive that noone will read. Maybe you'd like to read it instead, however, it is in German and contains mostly the same stuff I wrote here: |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
First of all, thanks a lot for your efforts in any case!
One speculation I'd like to make about this: Most users in the community here (aka StreetComplete) likely are Android users. So while I guess most of them see the point in a cross-platform app and supporting that case, fewer actually feel like contributing or would actively see the benefit (for themselves)? As such, I agree having an MVP and a published iOS app would likely attackt iOS users and thus maybe also iOS developers or at least developers intended to supporting "their" "own" platform. After all, having an app to use by yourself is probably the best motivation for building it (in OSS world IMHO). Edit: BTW, I've tried to spread the word about this on Mastodon. |
Another note on funding, and yes, I try to keep it short. Regarding:
Note if I understand it correctly, this is because the EU commission made the decicion to stop funding Generation Internet initiative (NGI) resulting “in a loss of €27 million for software freedom.” That said, you – yes, you who are reading this and possibly using SC – can do something about it, because they actually offer a public consultation, where you can criticize that decision! (And yes, non-EU citizens, too!) More information and arguments here: https://fsfe.org/news/2024/news-20240911-02.html Only thing I want to add is: The target audience searched there that is likely most relevant here are "members of the public (e.g. pupils and students interested in an ICT-related career or employees in the digital field).". Especially, you can mention this app here or others and explain it has been funded by that specific fund, actually. So make your voices heard! |
I noticed there's no CONTRIBUTING_IOS.md file. When I want to contribute, I don’t know where to start, how to set up, or run the project—like which branch to use, what tools are needed, etc. It would be helpful if you could provide a step-by-step guide on setting up the project, or at least include links to tutorials to help get started. |
Currently, the project setup is still 100% an Android app as #5412 hasn't been done yet, so the prior project setup instructions apply. But yeah, in frame of solving the mentioned task, the documentation could/should be adapted and extended to include project setup for iOS. |
Just a datapoint: ios user here and android in the past: the available apps on ios are not bad, but streetcomplete has been a much better experience I can help as soon as testflight is available a d would be willing to sponsor (parts?) if the Apple developer thingy that costs money. |
Same here, i have migrated to iOS many years ago and while i was amazed how much better apps are (better design, more usability) on iOS, StreetComplete was the only app ive been missing ever since. Would love to chip in too. |
This ticket is something like the master ticket to coordinate development on an iOS port of StreetComplete. It replaces #1892 which also included a lot of discussion and research / observation work.
TLDR: Have a look at the Project Board for a list of tasks. Contributions are welcome!
Also have a look at the Slides from SotM Europe 2024 talk (I added speaker notes to make this understandable when flipping through).
Approach
The code base of this app is written in 100% Kotlin, a modern programming language that is quite similar to Swift. Kotlin code can be transpiled to JavaScript and also to machine code, just like Swift. Furthermore, many dependencies of this app by now are pure Kotlin libraries.
An iOS version of this app hence can be done with Kotlin Multiplatform.
The UI code can be shared using Compose Multiplatform, which is currently in
alphabeta for iOS. It is a fork/extension of Jetpack Compose with largely the same API. Jetpack Compose is a reactive UI framework in which developers define the UI completely in code (similar idea as SwiftUI, Flutter, ...). We'll have to re-create the entire UI (incrementally) in Compose, though.This will keep the amount of code that needs to be platform dependent (Android / iOS) to a minimum.
This approach has the big advantage over others in that further maintenance of this project will not increase significantly, as there will continue to be just one code base. In comparison to using the framework Flutter for multiplatform (as used by Every Door), it allows us to largely not touch the Kotlin codebase. When using Flutter, we'd need to rewrite it all in Dart.
Steps in a nutshell
Separate all platform specific code from application logic. Replace Android/Java dependencies for application logic with Kotlin multiplatform dependencies
Incrementally migrate the UI code to Compose Multiplatform:
Separate data access and UI state code from pure UI code (use view models: Use ViewModels #5070 )
Migrate the UI code that currently uses Android XML layouts to Android Jetpack Compose. This can be done incrementally when done bottom-up (see migration strategy guide)
Then, migrate from Jetpack Compose to Compose Multiplatform. This is a small step compared with the first one.
Current State
This section will be updated continuously.
The steps necessary are described in detail in a Kanban-style Project Board. (Some tasks have not been created yet because they 100% depend on other tasks completed first and some research). Unless stated otherwise, they are explicitly up for the taking by people who read this and (I hope 😊) want to contribute to the development towards an iOS port. If you would like to implement one of the tasks described, comment in that ticket.
We very roughly estimated some time ago that developing a full port to iOS would take one man-year of work. So, the scope of this remains very large. We will only realistically achieve it together with lots of contributions from the community. Luckily, this is exactly what has been happening in the last years.
In the first half of 2024, I have been able to work on this full-time. The migration is now about 50% complete.
So, let's shift gears!
How you can help
You could take over a task from the project board! Or, you could familiarize yourself with the mentioned technologies / frameworks to make meaningful contributions later. In particular: Jetpack Compose / Compose Multiplatform. This is very new to me too, so I have to find my feet here, too
You can sponsor development! See the title "Sponsor this project" in the sidebar on the main page. More money allows me to devote more time to development on this app in general. If you know any eligible sources for larger scale funding, talk to me!
You can help with maintenance and issue triage in general. Time saved on that is time I can put into furthering development on this!
The text was updated successfully, but these errors were encountered: