import SwiftUI

struct SelectedContentView<Contained>: View where Contained: MainContentView {

    @Binding
    var selected: Contained.Item?

    init(selected: Binding<Contained.Item?>) {
        self._selected = selected
    }

    var body: some View {
        if let item = selected {
            Contained(item: item)
                .id(item.id)
        } else {
            HStack {
                Spacer()
                Text("Select \(Contained.itemDescription) from the sidebar")
                    .font(.largeTitle)
                    .foregroundColor(.secondary)
                Spacer()
            }
        }
    }
}
