XLFormViewController.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // XLFormViewController.h
  3. // XLForm ( https://github.com/xmartlabs/XLForm )
  4. //
  5. // Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
  6. //
  7. //
  8. // Permission is hereby granted, free of charge, to any person obtaining a copy
  9. // of this software and associated documentation files (the "Software"), to deal
  10. // in the Software without restriction, including without limitation the rights
  11. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. // copies of the Software, and to permit persons to whom the Software is
  13. // furnished to do so, subject to the following conditions:
  14. //
  15. // The above copyright notice and this permission notice shall be included in
  16. // all copies or substantial portions of the Software.
  17. //
  18. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. // THE SOFTWARE.
  25. #import <UIKit/UIKit.h>
  26. #import "XLFormOptionsViewController.h"
  27. #import "XLFormDescriptor.h"
  28. #import "XLFormSectionDescriptor.h"
  29. #import "XLFormDescriptorDelegate.h"
  30. #import "XLFormRowNavigationAccessoryView.h"
  31. #import "XLFormBaseCell.h"
  32. @class XLFormViewController;
  33. @class XLFormRowDescriptor;
  34. @class XLFormSectionDescriptor;
  35. @class XLFormDescriptor;
  36. @class XLFormBaseCell;
  37. typedef NS_ENUM(NSUInteger, XLFormRowNavigationDirection) {
  38. XLFormRowNavigationDirectionPrevious = 0,
  39. XLFormRowNavigationDirectionNext
  40. };
  41. @protocol XLFormViewControllerDelegate <NSObject>
  42. @optional
  43. -(void)didSelectFormRow:(XLFormRowDescriptor *)formRow;
  44. -(void)deselectFormRow:(XLFormRowDescriptor *)formRow;
  45. -(void)reloadFormRow:(XLFormRowDescriptor *)formRow;
  46. -(XLFormBaseCell *)updateFormRow:(XLFormRowDescriptor *)formRow;
  47. -(NSDictionary *)formValues;
  48. -(NSDictionary *)httpParameters;
  49. -(XLFormRowDescriptor *)formRowFormMultivaluedFormSection:(XLFormSectionDescriptor *)formSection;
  50. -(void)multivaluedInsertButtonTapped:(XLFormRowDescriptor *)formRow;
  51. -(UIStoryboard *)storyboardForRow:(XLFormRowDescriptor *)formRow;
  52. -(NSArray *)formValidationErrors;
  53. -(void)showFormValidationError:(NSError *)error;
  54. -(void)showFormValidationError:(NSError *)error withTitle:(NSString*)title;
  55. -(UITableViewRowAnimation)insertRowAnimationForRow:(XLFormRowDescriptor *)formRow;
  56. -(UITableViewRowAnimation)deleteRowAnimationForRow:(XLFormRowDescriptor *)formRow;
  57. -(UITableViewRowAnimation)insertRowAnimationForSection:(XLFormSectionDescriptor *)formSection;
  58. -(UITableViewRowAnimation)deleteRowAnimationForSection:(XLFormSectionDescriptor *)formSection;
  59. // InputAccessoryView
  60. -(UIView *)inputAccessoryViewForRowDescriptor:(XLFormRowDescriptor *)rowDescriptor;
  61. -(XLFormRowDescriptor *)nextRowDescriptorForRow:(XLFormRowDescriptor*)currentRow withDirection:(XLFormRowNavigationDirection)direction;
  62. // highlight/unhighlight
  63. -(void)beginEditing:(XLFormRowDescriptor *)rowDescriptor;
  64. -(void)endEditing:(XLFormRowDescriptor *)rowDescriptor;
  65. -(void)ensureRowIsVisible:(XLFormRowDescriptor *)inlineRowDescriptor;
  66. @end
  67. @interface XLFormViewController : UIViewController<UITableViewDataSource, UITableViewDelegate, XLFormDescriptorDelegate, UITextFieldDelegate, UITextViewDelegate, XLFormViewControllerDelegate>
  68. @property XLFormDescriptor * form;
  69. @property IBOutlet UITableView * tableView;
  70. -(instancetype)initWithForm:(XLFormDescriptor *)form;
  71. -(instancetype)initWithForm:(XLFormDescriptor *)form style:(UITableViewStyle)style;
  72. -(instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER;
  73. -(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil NS_DESIGNATED_INITIALIZER;
  74. +(NSMutableDictionary *)cellClassesForRowDescriptorTypes;
  75. +(NSMutableDictionary *)inlineRowDescriptorTypesForRowDescriptorTypes;
  76. -(void)performFormSelector:(SEL)selector withObject:(id)sender;
  77. @end