shaps80 / SwiftUIBackports

A collection of SwiftUI backports for iOS, macOS, tvOS and watchOS
MIT License
960 stars 60 forks source link

Added navigation ToolbarItemPlacement #41

Closed simonmaddox closed 1 year ago

simonmaddox commented 1 year ago

Have you read the Contributing Guidelines?

Yes

Describe your changes

iOS 14.0 added the navigation ToolbarItemPlacement type:

In macOS and in Mac Catalyst apps, the system places navigation items in the leading edge of the toolbar ahead of the inline title if that is present in the toolbar. In iOS, iPadOS, and tvOS, navigation items appear in the leading edge of the navigation bar. If a system navigation item such as a back button is present in a compact width, it instead appears in the primaryAction placement.

This is a straightforward change - most of the work is already done. This just adds a navigation value to the ToolbarItemPlacement enum, then ensures it's added to the leading side of the navigation bar.

shaps80 commented 1 year ago

I'll review this shortly but I think I might have left that out on purpose. Can't remember why though, will check my notes and let you know.

Might have been because I couldn't get this to work elegantly across platforms. Ill update next Week.

Thanks for this!

simonmaddox commented 1 year ago

It’s probably worth holding off merging this - I was following an issue where it didn’t quite behave identically around the back button, and ended up down a hole where using backport.toolbarwould always crash on iOS 13. Consider this PR incomplete for now.