RxDataSources icon indicating copy to clipboard operation
RxDataSources copied to clipboard

is there possible to make collapsed menu

Open YunusDeveloper opened this issue 4 years ago • 4 comments

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 cell

YunusDeveloper avatar Sep 14 '20 01:09 YunusDeveloper

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 avatar Nov 18 '20 20:11 iDmitriyy

@iDmitriyy can you please showed how use this struct in real example ?

tsomaev avatar Jul 13 '21 19:07 tsomaev

@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.

Dast1Woop avatar Aug 30 '23 05:08 Dast1Woop

@iDmitriyy can you please showed how use this struct in real example ?

this is a demo I write: https://github.com/Dast1Woop/RxFoldableAndEditableSectionsDemo

Dast1Woop avatar Aug 30 '23 10:08 Dast1Woop