D-32/SegmentedProgressBar

Gesture/taps : an enhancement

hcrgithub opened this issue · 2 comments

Hi, this is an enhancement suggestion for this library.

We can have tap to each of the segment to move to that part as well as have tap gesture on the left edge and right edge of the screen to move between segments.

In addition to this, when doing long press on screen, the transition can pause and when finger is lifted, the transition can resume.

Inspired from status option in whats app.

Regards
Hooda

Hi,

I have coded like below its working fine for me.

/// Adding long-press gesture

    let longGesture = UILongPressGestureRecognizer(target: self, action: #selector(self.longTap(_:)))
    longGesture.minimumPressDuration = 0.15
    statusImageView.isUserInteractionEnabled = true
    statusImageView.addGestureRecognizer(longGesture)
    
    let longGestureVideo = UILongPressGestureRecognizer(target: self, action: #selector(self.longTap(_:)))
    longGestureVideo.minimumPressDuration = 0.15
    
    videoView.isUserInteractionEnabled = true

    videoView.addGestureRecognizer(longGestureVideo)

/// on long tap

@objc func longTap(_ sender: UITapGestureRecognizer){

    if sender.state == .ended {

        SPB.isPaused = false
        if storyDict["storyType"] as! String == "video"
        {
            self.player.play()
        }
    }
    else if sender.state == .began {
        
        SPB.isPaused = true
        if storyDict["storyType"] as! String == "video"
        {
            self.player.pause()
        }
    }
}

This would not be a valid requirement on this library, the library provides access to pausing and resuming functions that would be triggered by a gesture on your ViewController.