RxDataSources
RxDataSources copied to clipboard
is there possible to make collapsed menu
Hello!
I have 3 sections and when user tap it should open and show it child datas when user again tap it should close current table views cell. I mean, I'm trying to make collapsed table view. is there possible to make it. Like this
Hello!
I have 3 sections and when user tap it should open and show it child datas when user again tap it should close current table views cell. I mean, I'm trying to make collapsed table view. is there possible to make it. Like this
Yes, it is possible.
public struct ExpandableListVM<T, H> {
/// Model for cell with expand button
public let headerItem: H
/// raw items
public let _items: [T]
/// items are shown only when isExpanded == true
public var items: [T] {
isExpanded ? _items : []
}
public let isExpanded: Bool
public init(headerItem: H, items: [T], isExpanded: Bool) {
self.headerItem = headerItem
_items = items
self.isExpanded = isExpanded
}
// when expand button is tapped, get new model with this method
public func togglingExpand() -> Self {
copy(isExpanded: !isExpanded)
}
public func copy(isExpanded: Bool) -> Self {
.init(headerItem: headerItem, items: _items, isExpanded: isExpanded)
}
}
@iDmitriyy can you please showed how use this struct in real example ?
@iDmitriyy can you please showed how use this struct in real example ?
Maybe you can use RxRelay as the Observable, when sectionTitle is tapped,change the value of RxRelay object. As the RxRelay object has binded to tableView, the tableView should reload.
@iDmitriyy can you please showed how use this struct in real example ?
this is a demo I write: https://github.com/Dast1Woop/RxFoldableAndEditableSectionsDemo