skiptools / skiptools/skip-ui

TapGesture is not working with Path or Shape

Open
#28 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
330
Forks
76
Avg merge
3h 6m
Merged PRs (30d)
1

Description

This is fine on iOS but not on Android (skip 0.8.28 / skip-ui 0.6.2) :

struct CustomShape: Shape {
    var angle: CGFloat
    var s = 30.0
    
    func path(in rect: CGRect) -> Path {
        let r = min(rect.width, rect.height) / 2.0
        let c = CGPoint(x: rect.midX + r*cos(angle), y: rect.midY + r*sin(angle))
        return Path(ellipseIn: CGRect(x: c.x - s, y: c.y - s, width: s*2.0, height: s*2.0))
    }
}

struct ContentView: View {
    var body: some View {
        ZStack {
            ForEach(0..<8) { n in
                let angle = Double.pi * 2.0 / 8 * CGFloat(n)
                CustomShape(angle: angle)
                    .fill(.green)
                    .onTapGesture {
                        logger.log("tapped \(n)")
                    }
            }
        }
    }
}

It is the same with Path - on Android the message is logged even when tapping outside the shape :

struct ContentView: View {
    var body: some View {
        Path { p in
            p.move(to: CGPoint(x: 100, y: 0))
            p.addLine(to: CGPoint(x: 200, y: 200))
            p.addLine(to: CGPoint(x: 0.0, y: 200))
        }
        .fill(.green)
        .onTapGesture {
            logger.log("tapped inside path")
        }
    }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named; start by running the two ContentView reproductions for CustomShape and Path and then trace Android tap hit testing for Shape and Path. Compare the Android behavior with iOS and verify that taps outside each rendered shape no longer trigger its gesture while taps inside still log.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, swift
Domain
frontend, mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.