RQCommonCollectionViewModel.m 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. //
  2. // RQCommonCollectionViewModel.m
  3. // YueXueChe
  4. //
  5. // Created by 张嵘 on 2018/12/19.
  6. // Copyright © 2018 lee. All rights reserved.
  7. //
  8. #import "RQCommonCollectionViewModel.h"
  9. @implementation RQCommonCollectionViewModel
  10. - (void)initialize {
  11. [super initialize];
  12. @weakify(self);
  13. /// 选中cell的命令
  14. /// UI Test
  15. self.didSelectCommand = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(NSIndexPath *indexPath) {
  16. @strongify(self);
  17. RQCommonGroupViewModel *groupViewModel = self.dataSource[indexPath.section] ;
  18. RQCommonCollectionItemViewModel *itemViewModel = groupViewModel.itemViewModels[indexPath.row];
  19. if (itemViewModel.operation) {
  20. /// 有操作执行操作
  21. itemViewModel.operation();
  22. }else if(itemViewModel.destViewModelClass){
  23. /// 没有操作就跳转VC
  24. Class viewModelClass = itemViewModel.destViewModelClass;
  25. RQBaseViewModel *viewModel = [[viewModelClass alloc] initWithServices:self.services params:@{RQViewModelTitleKey:itemViewModel.title}];
  26. [self.services pushViewModel:viewModel animated:YES];
  27. }
  28. return [RACSignal empty];
  29. }];
  30. }
  31. @end