RAOrderEditViewController+TableDataSource.m 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // RAOrderEditViewController+TableDataSource.m
  3. // Apex And Drivers
  4. //
  5. // Created by Jack on 2018/6/4.
  6. // Copyright © 2018年 USAI. All rights reserved.
  7. //
  8. #import "RAOrderEditViewController+TableDataSource.h"
  9. #import "RAEditLabelCell.h"
  10. #import "RAEditPhotoCell.h"
  11. #import "RAEditInputModel.h"
  12. #import "RAEditMultInputModel.h"
  13. #import "RAEditLabelModel.h"
  14. #import "RAEditPhotoModel.h"
  15. @implementation RAOrderEditViewController (TableDataSource)
  16. - (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
  17. RAEditBaseModel *model = [self modelForIndexPath:indexPath];
  18. switch (model.type) {
  19. case RAEditTypeLabel: {
  20. RAEditLabelCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RAEditLabelCell" forIndexPath:indexPath];
  21. RAEditLabelModel *labelModel = (RAEditLabelModel *)model;
  22. cell.model = labelModel;
  23. return cell;
  24. }
  25. break;
  26. case RAEditTypeInput: {
  27. RAEditScanInputCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RAEditScanInputCell" forIndexPath:indexPath];
  28. RAEditInputModel *inputModel = (RAEditInputModel *)model;
  29. cell.model = inputModel;
  30. cell.delegate = self;
  31. return cell;
  32. }
  33. break;
  34. case RAEditTypeMultInput: {
  35. RAEditMultInputCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RAEditMultInputCell" forIndexPath:indexPath];
  36. RAEditMultInputModel *multInputModel = (RAEditMultInputModel *)model;
  37. cell.model = multInputModel;
  38. cell.delegate = self;
  39. return cell;
  40. }
  41. break;
  42. case RAEditTypePhoto: {
  43. RAEditPhotoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RAEditPhotoCell" forIndexPath:indexPath];
  44. RAEditPhotoModel *photoModel = (RAEditPhotoModel *)model;
  45. cell.model = photoModel;
  46. return cell;
  47. }
  48. break;
  49. default:
  50. break;
  51. }
  52. UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"detaulCell"];
  53. return cell;
  54. }
  55. - (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  56. return [self itemCountForSection:section];
  57. }
  58. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  59. return [self editSectionCount];
  60. }
  61. #pragma mark - Input Delegate
  62. - (void)beginEditInputCell:(RAEditScanInputCell *)cell {
  63. self.editingIndexPath = [self indexPathForCell:cell];
  64. }
  65. - (void)endEditInputCell:(RAEditScanInputCell *)cell {
  66. self.editingIndexPath = nil;
  67. }
  68. #pragma mark - MultInput Delegate
  69. - (void)beginEditMultInputCell:(RAEditMultInputCell *)cell {
  70. self.editingIndexPath = [self indexPathForCell:cell];
  71. }
  72. - (void)endEditMultInputCell:(RAEditMultInputCell *)cell {
  73. self.editingIndexPath = nil;
  74. }
  75. @end