NYFloatingSuggestView.m 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // NYFloatingSuggestView.m
  3. // jiaPei
  4. //
  5. // Created by Ning.ge on 2023/6/30.
  6. // Copyright © 2023 JCZ. All rights reserved.
  7. //
  8. #import "NYFloatingSuggestView.h"
  9. @interface NYFloatingSuggestView ()
  10. @property (nonatomic,strong) NYFloatingSuggestViewModel *floatingSuggestViewModel;
  11. @end
  12. @implementation NYFloatingSuggestView
  13. #pragma mark - PublicMethods
  14. + (instancetype)floatingSuggestView {
  15. return [super rq_viewFromXib];
  16. }
  17. #pragma mark - SystemMethods
  18. - (void)awakeFromNib {
  19. [super awakeFromNib];
  20. }
  21. - (void)bindViewModel:(id)viewModel
  22. {
  23. self.floatingSuggestViewModel = viewModel;
  24. self.floatingSuggestViewModel.floatingSuggestView = self;
  25. @weakify(self)
  26. // 使用 RAC 建立按钮点击事件与视图模型中的命令的绑定
  27. [[self.icon_button rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
  28. @strongify(self);
  29. [self.floatingSuggestViewModel.iconCommand execute:nil];
  30. }];
  31. //关闭
  32. [[self.close_button rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x){
  33. @strongify(self);
  34. [self.floatingSuggestViewModel.closeCommand execute:nil];
  35. }];
  36. }
  37. @end