SwiftUI: safeAreaInset/safeAreaBar modifier used on a NavigationStack should automatically update the content inset (margins) of Views in the NavigationStack

[Submitted as FB23732628]

Hello,

In my app, I want a content to be always visible at the bottom of the UI such as a button (onboarding) or a mini player (Apple Music or Apple Podcasts). It should be visible even if I navigate to a destination view (using a NavigationLink or updating the NavigationStack path). And I don't use a TabView so I can't use the tabViewBottomAccessory.

If I use the safeAreaInset/safeAreaBar modifier on the NavigationStack in SwiftUI, the content insets (margins) is not automatically updated for the Views within the stack.

Expected behaviour: if I use the safeAreaInset/safeAreaBar, the Views in the NavigationStack should have their content inset (margins) updated like if the safeAreaInset/safeAreaBar is applied on the NavigationStack content directly.

Steps to reproduce: check the attached project, scroll at the bottom of the first List, notice the content is hidden below the button. Navigate to the detail view, scroll at the bottom and notice the content is hidden below the button.

Regards

Axel

import SwiftUI

struct NavigationStackSafeAreaInset: View {
    var body: some View {
        NavigationStack {
            List {
                ForEach(0...20, id: \.self) { int in
                    NavigationLink {
                        List {
                            ForEach(0...20, id: \.self) { int in
                                Text(int.formatted())
                            }
                        }
                    } label: {
                        Text(int.formatted())
                    }
                }
            }
        }
        .safeAreaInset(edge: .bottom) {
            Button { } label: {
                Text("New")
                    .frame(maxWidth: .infinity)
            }
            .buttonStyle(.borderedProminent)
            .controlSize(.large)
            .buttonBorderShape(.capsule)
            .padding()
        }
    }
}

#Preview {
    NavigationStackSafeAreaInset()
}
SwiftUI: safeAreaInset/safeAreaBar modifier used on a NavigationStack should automatically update the content inset (margins) of Views in the NavigationStack
 
 
Q