3lvis / Form

The most flexible and powerful way to build a form on iOS

Home Page:http://hyper.no

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Show/Hide group

AnthoPakPak opened this issue Β· comments

Does anybody has an idea on how to show/hide groups like we can do with targets on fields/sections (even outside of json) ?

I've tried many things, such as removing the cells from collectionView (as groups are composed of cells), but it mess with IDs so I thought it wasn't a good start. I've also tried to collapse group + hide header, but it's not perfect as it leaves a small space (can be tweaked but there must be an easier way).

I think that removing/restoring the cells could be the best thing to do, but I would need some help to implement it.

Any help is appreciated :)

I've succeeded in hiding/showing groups, if anyone is interested, feel free to ask me :)
I'm not making a PR as I don't know if people are interested in this feature.

Hi @AnthoPakPak!

I'm curious to see it, do you have a fork laying around that I can have a look? πŸ˜€

Hi @3lvis :)

With pleasure, I've just pushed the code ;)

Indeed, I've made a few improvements in the lib to fit my needs. Code may (must!) need refactoring/cleaning/testing, but it works great on my side.

Some features :

  • Show/Hide groups (no animation, just adds section to collectionView then reload)
  • Add AutoComplete field, based on Popover (named FORMDropdownFieldCell) and "dropdown" in json #535
  • Ability to add an extra field name in json ("title_custom"), that can be display in validation error message for example. This way you can customize field name from json without changing it's title in form
  • Fix really annoying crash when perform show target while group below is visible (difficult to reproduce, easier on iPad)
  • Fix segment restoring its old state
  • Fix popover (select) not setting its size when nbLines > 6

Here is the link to the forked project : https://github.com/AnthoPakPak/FormCustom

By the way, I would like to thank you and other contributors for this awesome library πŸ‘

I've succeeded in animating show/hide groups, added to the repo ;)

πŸ”₯ πŸ”₯ πŸ”₯ πŸ”₯ πŸ”₯ πŸ”₯ πŸ”₯

@AnthoPakPak thanks for this great work. Could you point me to the changes made to fix this:

  • Fix really annoying crash when perform show target while group below is visible (difficult to reproduce, easier on iPad)

@jeffleeismyhero Sure :)

https://github.com/AnthoPakPak/FormCustom/blob/master/Source/FORMLayout.m#L158
and
https://github.com/AnthoPakPak/FormCustom/blob/master/Source/FORMLayout.m#L178

I had to encapsulate the code in a @Try @catch block to avoid out of bounds as a casual check (if (lastIndexPath.row < fields.count)) returned true, but the concurrency will change number of fields on the same time, which cause out of bounds.

The bug happened for me when changing value of segment, with show target on value, but ONLY if fields of next group (section in UICollectionView) are visible.

Ask me if any other informations are needed :)