Zhenyi Tan And a Dinosaur

My SwiftUI Wishlist for WWDC

These are some SwiftUI weirdness I discovered while making History Book. I hope they get fixed at WWDC.

This list is incomplete. I only include things that seem straightforward to fix.

1. View modifiers that work as expected

I wish it is possible to change the background of a List with a .background() modifier. Yes, I’m aware of the UIKit workaround.

I also wish it is possible to change the height and width of a .sheet with a .frame(height:width:) modifier. No, I’m not aware any workaround… unless you want to reimplement your own sheet.

2. Some control over the default spacing

Here’s the toolbar of the Notes app:

Here’s the SwiftUI replica:

The alignment of the toolbar buttons are slightly off:

Why? I don’t know. But if you set the maxHeight and maxWidth of the button to .infinity, you’ll notice some non-removable spacing around the button: And no, .ignoresSafeArea() doesn’t work in this case.

Similarly, it happens to views inside NavigationLink as well:

I wish it is possible to ignore the spacing.

3. Miscellaneous improvements to edit mode in List

  1. The “Done” text should be bold in an EditButton.

  2. The chevrons in NavigationLinks should be hidden in edit mode. (It would be even better if we have some control over the accessoryType.) Note the whacky animation of the chevrons.

  3. The items in a List should be clickable (e.g. to rename the items) in edit mode.

  4. The state of the highlighted item is buggy in a multiple-selectable List when the List enters/leaves edit mode.

  5. If the items in a List have rounded corners, the .swipeActions buttons should have rounded corners as well.

  6. Make it possible to attach a .confirmationDialog to a .swipeActions button. Compare it with the confirmation dialog in the Notes app: Notice how the delete button expands instead of disappears when the confirmation dialog shows up.