So a protocol doesn't support some View as a return type... I'm trying this:
public extension View {
func popSheet(isPresented: Binding<Bool>, arrowEdge: Edge = .bottom, content: @escaping () -> PopSheet) -> some View {
Group {
if UIDevice.current.userInterfaceIdiom == .pad {
popover(isPresented: isPresented, attachmentAnchor: .rect(.bounds), arrowEdge: arrowEdge, content: {
content().popover()
})
} else {
actionSheet(isPresented: isPresented, content: {
content().actionSheet()
})
}
}
}
}
protocol PopSheet {
func actionSheet() -> ActionSheet
associatedtype View
func popover() -> View
}
But the whole function declaration fails and the content().popover() errors as well.
Method must be declared internal because its parameter uses an internal type
Protocol 'PopSheet' can only be used as a generic constraint because it has Self or associated type requirements
Member 'popover' cannot be used on value of protocol type 'PopSheet'; use a generic constraint instead