Duo not having different z index with overlay arrangement view style

When using ArrangementView with the overlay style, the Duo simulator does not appear to return a distinct z-index environment value, though it correctly displays z-index 0 and 1 on other iPhone simulators.

I would like to use this value to determine whether the overlay is active. Currently, this does not seem possible.

Is this behavior intended, or is it a bug? If intended, what is the recommended approach to determine if the Duo is displaying the arranged view over another arranged view?

import SwiftUI

struct ContentView: View {
    var body: some View {
        ArrangementView {
            Controls()
        } secondary: {
            Player()
        }
        .arrangementViewStyle(.overlay)

    }
}

struct Controls: View {
    @Environment(\.overlayArrangementZIndex) var zIndex

    var body: some View {
        Text("Controls Z:\(zIndex)")
            .frame(maxWidth: .infinity, alignment: .leading)
    }
}

struct Player: View {
    @Environment(\.overlayArrangementZIndex) var zIndex

    var body: some View {
        Text("Player Z:\(zIndex)")
            .frame(maxWidth: .infinity, alignment: .trailing)
    }
}

#Preview {
    ContentView()
}

Answered by DTS Engineer in 906698022

Hi @u-dan,

Thanks for reporting this issue. The behavior you have experienced is due to a known bug. Please file a bug report via Feedback Assistant. Once submitted, please respond here with the Feedback ID.

As a workaround, please use the following:

struct ContentView: View {
    var body: some View {
        ArrangementView {
            VStack { Controls() }
        } secondary: {
            Player()
        }
        .arrangementViewStyle(.overlay)

    }
}

Note: The expected way to check if the controls (primary view) are overlaid on top of the secondary view is to check the zIndex > 0.

Cheers,

Paris X Pinkney |  WWDR | DTS Engineer

Accepted Answer

Hi @u-dan,

Thanks for reporting this issue. The behavior you have experienced is due to a known bug. Please file a bug report via Feedback Assistant. Once submitted, please respond here with the Feedback ID.

As a workaround, please use the following:

struct ContentView: View {
    var body: some View {
        ArrangementView {
            VStack { Controls() }
        } secondary: {
            Player()
        }
        .arrangementViewStyle(.overlay)

    }
}

Note: The expected way to check if the controls (primary view) are overlaid on top of the secondary view is to check the zIndex > 0.

Cheers,

Paris X Pinkney |  WWDR | DTS Engineer

@DTS Engineer Thank you. Feedback ID here FB24914700

Duo not having different z index with overlay arrangement view style
 
 
Q