3lvis / Form

The most flexible and powerful way to build a form on iOS
http://hyper.no
Other
1.64k stars 145 forks source link

Toggling a section's visibility #434

Open jeffleeismyhero opened 9 years ago

jeffleeismyhero commented 9 years ago

I can hide a section with:

FORMTarget *target = [FORMTarget hideSectionTargetWithID:@"discounts-section"];
[self.dataSource processTargets:@[target]];

Similarly, I can show a section with:

FORMTarget *target = [FORMTarget showSectionTargetWithID:@"discounts-section"];
[self.dataSource processTargets:@[target]];

How can I determine if a section is hidden or visible? I want a button that will toggle the section to display or hide.

Additionally, how can I mark sections as hidden initially without resorting to the code above? That doesn't currently seem to be supported.

3lvis commented 8 years ago

We could do something like we do with fields. A method that takes a boolean to consider or exclude hidden values.

https://github.com/hyperoslo/Form/blob/master/Source/FORMDataSource.h#L193-L194

/*!
 * @discussion A method to find a @c field with its specific @c indexPath
 * @param fieldID The identifier for the field
 * @param includingHiddenFields A flag for whether look for hidden or collapsed fields or not
 */
- (void)fieldWithID:(NSString *)fieldID
includingHiddenFields:(BOOL)includingHiddenFields
         completion:(void (^)(FORMField *field,
                              NSIndexPath *indexPath))completion;