Coder Social home page Coder Social logo

Comments (7)

prashantAlgante avatar prashantAlgante commented on May 16, 2024

For you information
I also tried putting this library in TabbarViewController class and hiding default tabbar. This loads perfectly but Does not scroll to higher position at all. Please advise something , what needs to be done in second case

Below is the code attached from your example

class CustomTabBarVC: UITabBarController {
    var sheetCoordinator: UBottomSheetCoordinator!
    
    var sheetVC: DraggableItem!
    var useNavController = false
    var dataSource: UBottomSheetCoordinatorDataSource?
    
    override func viewDidLoad() {
        super.viewDidLoad()

        self.tabBar.isHidden = true
        self.sheetVC = ListViewController()
        self.dataSource = MyDataSource()
    }
        
    override func viewWillLayoutSubviews() {
        super.viewWillLayoutSubviews()
        
        guard sheetCoordinator == nil else {return}
        print("Called from subviews")
        sheetCoordinator = UBottomSheetCoordinator(parent: self)
        if dataSource != nil{
            sheetCoordinator.dataSource = dataSource!
        }

        let vc: UIViewController
        if useNavController{
            vc = UINavigationController(rootViewController: sheetVC)
            sheetVC.title = "Navigation Bar Title"
        }else{
            vc = sheetVC
        }
        sheetVC.sheetCoordinator = sheetCoordinator
        sheetCoordinator.addSheet(vc, to: self, didContainerCreate: { container in
            let f = self.view.frame
            let rect = CGRect(x: f.minX, y: f.minY, width: f.width, height: f.height)
            container.roundCorners(corners: [.topLeft, .topRight], radius: 10, rect: rect)
        })
    }

}

from ubottomsheet.

OfTheWolf avatar OfTheWolf commented on May 16, 2024

@prashantAlgante I will try to look at it this week asap.

from ubottomsheet.

prashantAlgante avatar prashantAlgante commented on May 16, 2024

Hello @OfTheWolf Can you please also look for #36 . That will also be much simpler for you to do. Thanks

from ubottomsheet.

GerdC avatar GerdC commented on May 16, 2024

Edit: my fault. See my comment below

I think I have the same problem.

A MapViewController inside a UITabBarController
The MapViewController controller presents the Sheet controller.

This is an actual screenshot using UBottomSheet:

Simulator Screen Shot - iPhone SE (2nd generation) - 2020-08-07 at 19 42 33

The SheetViewController has no UIScrollView but implements Draggable.

I use this code from the MapViewController:

    let dataSource = StackDataSourceProxy(viewController: transitPlanViewController)
    self.stackDataSourceProxy = dataSource // strong reference
    self.sheetCoordinator.dataSource = dataSource // weak reference

    sheetCoordinator.addSheet(transitPlanViewController, to: self, didContainerCreate: { container in
        let f = self.view.frame
        let rect = CGRect(x: f.minX, y: f.minY, width: f.width, height: f.height)
        container.roundCorners(corners: [.topLeft, .topRight], radius: 10, rect: rect)
    })
    sheetCoordinator.setCornerRadius(10)

Expected behaviour: scrolling on pan gesture.
Actual behaviour: not scrolling on pan gesture.

(availableHeight does not respect the tabBar height but that's easy to work around)

from ubottomsheet.

OfTheWolf avatar OfTheWolf commented on May 16, 2024

@prashantAlgante @GerdC
Interesting bug. It seems TabBarController causes child vc's viewWillAppear is not called. So as a workaround put all startTracking logics in viewWillLayoutSubviews.

//***ListViewController.swift***

 var isTracking = false

 override func viewWillLayoutSubviews() {
     super.viewWillLayoutSubviews()
     
     if !isTracking{
         isTracking = true
         sheetCoordinator?.startTracking(item: self)
     }
 }

from ubottomsheet.

OfTheWolf avatar OfTheWolf commented on May 16, 2024

(availableHeight does not respect the tabBar height but that's easy to work around)

This should be the problem.
@GerdC

    public var availableHeight: CGFloat{
        if #available(iOS 11.0, *) {
            return parent.view.frame.inset(by: parent.view.safeAreaInsets).height
        } else {
            return parent.view.frame.height
        }
    }

from ubottomsheet.

GerdC avatar GerdC commented on May 16, 2024

@prashantAlgante @GerdC
Interesting bug. It seems TabBarController causes child vc's viewWillAppear is not called. So as a workaround put all startTracking logics in viewWillLayoutSubviews.

//***ListViewController.swift***

 var isTracking = false

 override func viewWillLayoutSubviews() {
     super.viewWillLayoutSubviews()
     
     if !isTracking{
         isTracking = true
         sheetCoordinator?.startTracking(item: self)
     }
 }

it was my fault, but your answer was a great help to find it.
I did not set the sheetCoordinator in the presented sheet, only in the presenting controller.

Will never happen again:

public override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    if let sheetCoordinator = self.sheetCoordinator {
        sheetCoordinator.startTracking(item: self)
    } else {
        assertionFailure()
    }
}

I don't think any more that there is a problem using UBottomSheet in a TabBarController.
You could add an assertion to your example code as I did to make it easy to find this type of mistake.

Thanks

from ubottomsheet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.