Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is there possible to make collapsed menu #370

Open
YunusDeveloper opened this issue Sep 14, 2020 · 4 comments
Open

is there possible to make collapsed menu #370

YunusDeveloper opened this issue Sep 14, 2020 · 4 comments

Comments

@YunusDeveloper
Copy link

YunusDeveloper commented Sep 14, 2020

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

@iDmitriyy
Copy link

iDmitriyy commented Nov 18, 2020

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)
  }
}

@tsomaev
Copy link
Member

tsomaev commented Jul 13, 2021

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

@Dast1Woop
Copy link

@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
Copy link

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants