mastodon / mastodon-ios

Official iOS app for Mastodon
https://app.joinmastodon.org/ios
GNU General Public License v3.0
2.08k stars 268 forks source link

Multiple Windows support on iPadOS #435

Open S0ulf3re opened 2 years ago

S0ulf3re commented 2 years ago

It would be nice to have support for multiple windows on iPad. I know that Tweetbot supports this function and adding it would allow us to use multiple accounts with Mastodon at the same time. It could also be useful for moderators as well

MainasuK commented 2 years ago

The app implementation not consider this feature. I'm not sure how many people using multiple windows feature on iPad. And I think it's needs some efforts to make it.

S0ulf3re commented 2 years ago

Desperately wanting this feature, I ponied up the 99$ developer fee and compiled the app myself with "Supports Multiple Windows" Toggled to "YES". And surprisingly, with no changes to the code required, it seems to work in the Simulator. About to test it on my iPad, just gotta fix one little problem with app groups over in MastodonSDK

S0ulf3re commented 2 years ago

Ok, so I solved the problem (turns out I forgot to change the appGroup variable) and so far, mastodon is running very well on my iPad after compiling on the main branch with "Enable Multiple Windows" set to "YES".

IMG_731A986C9DB3-1

Seeing as though that Mastodon is built with SceneDelegate, optimizing mastodon for Multiple Windows should be relatively easy.

S0ulf3re commented 2 years ago

Things that don't seem to work:

Within App Exposé in the app switcher (accessed by selecting the two squares icon by an app windows name), whenever a window is closed by swiping it upward, an option appears to "Reopen Closed Window" by the + button. When tapped however, this seems to terminate the entire app (and subsequently, all of its windows) causing them all to lose their position.

Although I haven't tested this, my hypothesis for other potential problems that would cause them to lose state would be background app terminations, as well as system restarts (similar to macOS).

MainasuK commented 2 years ago

Hi @S0ulf3re,

Sorry for the late reply. The first version of this app supports hot reloading the active user. But that may cause leaking. And the app actually reset the window to force reload the app now.

To makes the multiple windows work. We need to add an additional layer to handle the authentication info alongside the AppContext. A good place the inject it is SceneCoordinator. The coordinator could present the Onboarding scene when no authentication is available. And reset to normal app after user login. Then inject this into every ViewController & ViewModel.

I'm making some exploration on that project. A PR with that concept will be finished recently. But that needs a lot of work to refactor and migrate back to the Mastodon app.