chicio/RangeUISlider

Not working when used as a part of my SwiftUI View.

MohamedSadek07 opened this issue · 2 comments

First of All Thanks for your effort providing us with this pod that also support language flipping, But unfortunately I have faced this issue after integrating it in my SwiftUI project.

Describe the bug

  1. Not respond to user interacts when putting it in my swiftui view hierachy (Design) but worked only when it's the only component inside the Whole view.
  2. Also didn't work when wrapped in scrollView even if it's the only component inside the view.

To Reproduce
Steps to reproduce the behavior:

  1. After integrating RangeSlider in my view it doesn't work i will provide you by my view structure and video showing not responding slider.
  2. Specially After wrapping it in simple view that consists of vstak wrapped in scrollview it doesn't work also.
  3. Finally i will provide you with RangeSliderView Struct and video showing that the slider works if it is the only component in the view.

Expected behavior
The expected behavior is to respond to user interactions as i gave it appropriate frame to allow user change min and max value Knobs.

Screenshots

This my view structure
Screenshot 2023-11-25 at 1 40 03 AM
And this the video showing the issue
https://github.com/chicio/RangeUISlider/assets/47571955/1e21ccf0-eec4-448e-b49c-2652c2212c4f

This is RangeSliderView itself
Screenshot 2023-11-25 at 1 40 39 AM
**Here is a video after showing navigation to the RangeSliderView and it works here **
https://github.com/chicio/RangeUISlider/assets/47571955/82a73f31-e09c-4b97-995c-ab911e719af7

chicio commented

Hi @MohamedSadek07 , thanks for using RangeUISlider in your project.
I checked a bit your issue, and seems like you're right: if I insert RangeUISlider inside a ScrollView it doesn't work.
After debugging for some time, it seems like the problem is not related to RangeUISlider itself. What is happening is that UIViewRepresentable in a ScrollView doesn't always respect the frame calculate on the UIKit side.
To solve the issue you can explicitly set an height for RangeUISlider, like I did in this example I added to the demo app (you can clone the repo and test it)

77dc262#diff-67933792635b8aef27826455098894c1b13e2cfc89a3e58721390ef15e034f5a

This is the result

Simulator.Screen.Recording.-.iPhone.15.Pro.-.2023-11-25.at.12.01.49.mp4

Let me know if you need any other information, and support my work by starring this repo ⭐️. Thanks, Fabrizio.

Thank you so much Fabrizio, it's working fine now.