RAOrderDetailViewController+TableViewDataSource.m 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //
  2. // RAOrderDetailViewController+TableViewDataSource.m
  3. // Apex And Drivers
  4. //
  5. // Created by Jack on 2018/6/2.
  6. // Copyright © 2018年 USAI. All rights reserved.
  7. //
  8. #import "RAOrderDetailViewController+TableViewDataSource.h"
  9. #import "RADetailBaseModel.h"
  10. #import "RADetailSingleLineModel.h"
  11. #import "RADetailMultLineModel.h"
  12. #import "RADetailLocationModel.h"
  13. #import "RADetailActionCollectionModel.h"
  14. #import "RADetailSingleLineCell.h"
  15. #import "RADetailMultLineCell.h"
  16. #import "RADetailActionsCell.h"
  17. #import "RADetailLocationCell.h"
  18. @implementation RAOrderDetailViewController (TableViewDataSource)
  19. - (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
  20. RADetailBaseModel *model = [self modelForIndexPath:indexPath];
  21. RAOrderDetailValueType type = model.type;
  22. switch (type) {
  23. case RAOrderDetailValueTypeSingleLine: {
  24. RADetailSingleLineModel *singleModel = (RADetailSingleLineModel *)model;
  25. RADetailSingleLineCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RADetailSingleLineCell" forIndexPath:indexPath];
  26. [cell setModel:singleModel];
  27. return cell;
  28. }
  29. break;
  30. case RAOrderDetailValueTypeMultipleLine: {
  31. RADetailMultLineModel *multModel = (RADetailMultLineModel *)model;
  32. RADetailMultLineCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RADetailMultLineCell" forIndexPath:indexPath];
  33. [cell setModel:multModel];
  34. return cell;
  35. }
  36. break;
  37. case RAOrderDetailValueTypeAction: {
  38. RADetailActionCollectionModel *actionModel = (RADetailActionCollectionModel *)model;
  39. RADetailActionsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RADetailActionsCell" forIndexPath:indexPath];
  40. cell.actionLayout.delegate = actionModel;
  41. [cell setModel:actionModel];
  42. return cell;
  43. }
  44. break;
  45. case RAOrderDetailValueTypeLocation: {
  46. RADetailLocationModel *locationModel = (RADetailLocationModel *)model;
  47. RADetailLocationCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RADetailLocationCell" forIndexPath:indexPath];
  48. [cell setModel:locationModel];
  49. return cell;
  50. }
  51. break;
  52. default:
  53. break;
  54. }
  55. UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"detaulCell"];
  56. return cell;
  57. }
  58. - (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  59. return [self numberOfItemForSection:section];
  60. }
  61. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  62. return [self sectionNumber];
  63. }
  64. @end