Issue #850

Erase with AnyShape

struct AnyShape: Shape {
    init<S: Shape>(_ wrapped: S) {
        innerPath = { rect in
            let path = wrapped.path(in: rect)
            return path
        }
    }

    func path(in rect: CGRect) -> Path {
        return innerPath(rect)
    }

    private let innerPath: (CGRect) -> Path
}

extension Shape {
    func erase() -> AnyShape {
        AnyShape(self)
    }
}

Then we can use like

private struct ContentView: View {
    var body: some View {
        ZStack {
            Color.gray
            ViewControllerWrapper(manager: manager)
        }
        .clipShape(shape)
        .overlay(
            shape
                .stroke(Color.accentColor, lineWidth: 4)
        )
    }

    private var shape: some Shape {
        switch manager.configuration.shape {
        case .circle:
            return Circle().erase()
        case .roundedRectangle:
            return RoundedRectangle(cornerRadius: 10).erase()
        case .squircle:
            return SquircleShape().erase()
        }
    }
}