How to use vars or print inside in GeometryReader?

I get error: "Cannot convert return expression of type 'GeometryReader<_>' to return type 'some View'" when I try 'print' inside in 'GeometryReader'. What type should return?

        GeometryReader { geometry in //Cannot convert return expression of type 'GeometryReader<_>' to return type 'some View'
            print(geometry.frame(in: .global).minX)
            
            return Image("back-playing-card")
                .resizable()
                .rotation3DEffect(
                    Angle(degrees:
                        Double(geometry.frame(in: .global).minX) / 20),
                    axis: (x: 0, y: 10.0, z: 0)
                )
        }
        .frame(width: 150, height: 250)
        .padding()

I moved create image to a method and noticed that I couldn't use 'some' keyword in closure like so 'geometry -> some View in'

struct CardView2: View {
    fileprivate func createImage(geometry: GeometryProxy) -> some View {
        print(geometry.frame(in: .global).minX)
        
        return Image("back-playing-card")
            .resizable()
            .rotation3DEffect(Angle(degrees: Double((geometry.frame(in: .global).minX) / 20)), axis: (x: 10.0, y: 10.0, z: 10.0))
    }

    var body: some View {
        GeometryReader { geometry in
            self.createImage(geometry: geometry)
        }
        .frame(width: 150, height: 250)
        .padding()
    }
}
Terms of Service

Privacy Policy

Cookie Policy