Multiple inserted views in matched geometry group

The error "Multiple inserted views in matched geometry group" occurs when there are multiple source views in the view hierarchy using the same identifier for matched geometry effect. To resolve this issue, ensure that only one view has the identifier as the source for matched geometry effect. This can be done by either removing an unnecessary view or updating the isSource parameter of the matchedGeometryEffect modifier.

struct BookMatchedShape: View, PreviewProvider {
  var body: some View {
    Content()
  }

  static var previews: some View {
    Self()
  }

  private struct Content: View {

    @State var isZooming = false
    @Namespace var local

    var body: some View {

      ZStack {

        let content = RoundedRectangle(cornerRadius: 16, style: .continuous)
          .fill(ColorScheme.type1.background)
          .matchedGeometryEffect(id: 1, in: local, isSource: isZooming == false)
          .frame(width: 200, height: 64)

        content
          .onTapGesture {
            withAnimation {
              isZooming = true
            }
          }

        if isZooming {

          ZStack {
            RoundedRectangle(cornerRadius: 16, style: .continuous)
              .fill(ColorScheme.type1.background)
              .matchedGeometryEffect(id: 1, in: local, isSource: isZooming)
              .frame(width: 300, height: 400)
              .onTapGesture {
                withAnimation {
                  isZooming = false
                }
              }

          }
          .modifier(
            VelocityDraggingModifier(
              springParameter: .interpolation(mass: 10, stiffness: 400, damping: 10),
              handler: .init(onEndDragging: { velocity, offset, size in

                Task {
                  try? await Task.sleep(nanoseconds: 10_000_000)
                  withAnimation(.spring()) {
                    isZooming = false
                  }
                }

                velocity.dy = 3000
                velocity.dx = 6000

                return .zero
              })
            )
          )

        }
      }
    }
  }
}