dimillian, (edited )
@dimillian@mastodon.social avatar

, the size class is set to regular when the iPad app enters background. WTF. Apparently, it’s not a bug, as the iPad needs to take snapshots. Good luck in SwiftUI keeping the whole view hierarchy state when transitioning between a sidebar (custom) and a tabbar. This thing was built only with the NavigationSplitView in mind. Very stupid you can’t disable it.

wouter01,

@dimillian Another approach could be to only use a TabView, and hide the tab bar when the size class is compact. This can be done easily with introspect. Tab state is managed by tabview, which also makes it easier to keep state of all tabs compared to using a switch (And in Ice Cubes case, probably also faster as the views don’t need to be rebuilt on a tab change).
Tested the idea out real quick, seems to work great

dimillian,
@dimillian@mastodon.social avatar

@wouter01 huh this is really smart. And I can remove all my custom tab bar-like code to control the view appearance. I'll try that out!

dimillian,
@dimillian@mastodon.social avatar

@wouter01 switching hidden state correctly set the bottom inset?

wouter01,

@dimillian It looks like it does! I haven’t tried it out with extra bottom toolbars though

video/mp4

dimillian,
@dimillian@mastodon.social avatar

@wouter01 Real code! This is wonders dude! I'll test it more and probably ship it!

wouter01,

@dimillian That’s awesome! Glad I could help

dimillian,
@dimillian@mastodon.social avatar

@wouter01 Nice side effect is that swapping tabs is now much faster as it use the UITabViewController backed thing instead of my horrible ZStack view stacking + opacity.

rabc,
@rabc@hachyderm.io avatar

@dimillian it is incredible that since the beginning of iPad some kind of Split View/navigator is always pushed down our throats but it has few customisations and practical use after you leave the prototype version.

dimillian,
@dimillian@mastodon.social avatar

@rabc yup and the SwiftUI one is really in a bad state. Never used it. Never will.

alpennec,
@alpennec@iosdev.space avatar

@dimillian oh I did not know that! I’ll check how it goes for my apps. Have you thought about using SceneStorage to persist and restore the state? This is what I use for apps that can be resized on iPad (thus using either a NavigationSplitView or a NavigationStack based on the horizontalClass).

dimillian,
@dimillian@mastodon.social avatar

@alpennec I wound need to save the whole app in there. It's not designed like that at the moment.

alpennec,
@alpennec@iosdev.space avatar

@dimillian yep it would probably need some refactor to store the selected tab, navigation path and others app states elements.

dimillian,
@dimillian@mastodon.social avatar

@alpennec but even there. Swapping hiearchy mean rebuilding the whole timeline etc… this is what happen right now. And you loose presented sheet etc…

alpennec,
@alpennec@iosdev.space avatar

@dimillian oh yeah, I know, it sucks performance wise… but we don’t have any other options right now afaik, until Apple finally fixes the NavigationSplitView component. When they will focus less on visionOS and more on the other platforms?!

dimillian,
@dimillian@mastodon.social avatar

@alpennec I've sent a hotfix that disables the sidebar to tab bar transition on size class change :/

alpennec,
@alpennec@iosdev.space avatar

@dimillian so Split View on iPad will be partly broken?

dimillian,
@dimillian@mastodon.social avatar

@alpennec as it was since the beginning. I've made the slide over change very recently. A solution could be to build a custom tab bar. Display the sidebar at the bottom.

mberk,

@dimillian Whether in SwiftUI or UIKit, there's really no easy way to keep a sidebar and tab bar synced in iOS sadly

dimillian,
@dimillian@mastodon.social avatar

@mberk Well in UIKit the state is kept. In SwiftUI is you swap rootview, everything is discarded.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • SwiftUI
  • Durango
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • tacticalgear
  • khanakhh
  • Youngstown
  • mdbf
  • slotface
  • rosin
  • everett
  • ngwrru68w68
  • kavyap
  • InstantRegret
  • JUstTest
  • cubers
  • GTA5RPClips
  • cisconetworking
  • ethstaker
  • osvaldo12
  • modclub
  • normalnudes
  • provamag3
  • tester
  • anitta
  • Leos
  • megavids
  • lostlight
  • All magazines