Reputation: 21
I'm building a tinder-like app, and I'm using a library KolodaView: https://github.com/Yalantis/Koloda
In the library they have functionality setup so when you tab the UIView it triggers an action. At the moment its setup to open up a URL. As seen below:
extension ViewController: KolodaViewDelegate {
func kolodaDidRunOutOfCards(_ koloda: KolodaView) {
print("Out of cards")
}
func koloda(_ koloda: KolodaView, didSelectCardAt index: Int) {
UIApplication.shared.openURL(URL(string: "https://yalantis.com/")!)
}
func koloda(_ koloda: KolodaView, didSwipeCardAt index: Int, in direction: SwipeResultDirection) {
let x = data[index]
print("did swipe \(x) in diredtion: \(direction)")
}
}
How can I set this up so that when you tap on the UIView it expands / collapses and therefore showing more information. Basically working like an accordion. Preferably the information that is shown from the expanding UIView would come from XIB file view.
I already have the main UIView setup in my datasource from another XIB file view.
extension ViewController: KolodaViewDataSource {
func kolodaNumberOfCards(_ koloda: KolodaView) -> Int {
return data.count
}
func koloda(_ koloda: KolodaView, viewForCardAt index: Int) -> UIView {
let swipeView = Bundle.main.loadNibNamed("SwipeView", owner: self, options: nil)![0] as! SwipeView
let x = data[index]
// swipeView.setupView(job: x)
return swipeView
}
func kolodaSpeedThatCardShouldDrag(_ koloda: KolodaView) -> DragSpeed {
return .default
}
}
I am quite new to swift and any help would greatly appreciated.
Upvotes: 2
Views: 771