RQExerciseSettingViewModel.m 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // RQExerciseSettingViewModel.m
  3. // JSJP
  4. //
  5. // Created by RONGQING on 2022/1/14.
  6. //
  7. #import "RQExerciseSettingViewModel.h"
  8. @implementation RQExerciseSettingViewModel
  9. #pragma mark - Public Method
  10. - (instancetype)initWithServices:(id<RQViewModelServices>)services params:(NSDictionary *)params {
  11. if (self = [super initWithServices:services params:params]) {
  12. }
  13. return self;
  14. }
  15. - (void)initialize {
  16. [super initialize];
  17. self.title = @"";
  18. /// 隐藏导航栏的细线
  19. self.prefersNavigationBarBottomLineHidden = YES;
  20. ///配置数据
  21. [self rq_configureData];
  22. }
  23. #pragma mark - PrivateMethod
  24. - (void)rq_configureData {
  25. /// 第零组
  26. RQCommonGroupViewModel *group0 = [RQCommonGroupViewModel groupViewModel];
  27. /// 用户信息
  28. group0.headerHeight = CGFLOAT_MIN;
  29. group0.footerHeight = CGFLOAT_MIN;
  30. RQCommonSwitchItemViewModel *item0 = [[RQCommonSwitchItemViewModel alloc] init];
  31. item0.title = @"答对跳转下一题";
  32. item0.off = !RQ_Exercise_Module.isRightAutoJumpToNext;
  33. [[RACObserve(item0, off) takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id _Nullable x) {
  34. if (item0.off) {
  35. NSLog(@"答对跳转下一题关闭");
  36. } else {
  37. NSLog(@"答对跳转下一题开启");
  38. }
  39. RQ_Exercise_Module.isRightAutoJumpToNext = !item0.off;
  40. }];
  41. RQCommonSwitchItemViewModel *item1 = [[RQCommonSwitchItemViewModel alloc] init];
  42. item1.title = @"答题音效提示";
  43. item1.off = !RQ_Exercise_Module.isExerciseSound;
  44. [[RACObserve(item1, off) takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id _Nullable x) {
  45. if (item1.off) {
  46. NSLog(@"答题音效提示关闭");
  47. } else {
  48. NSLog(@"答题音效提示开启");
  49. }
  50. RQ_Exercise_Module.isExerciseSound = !item1.off;
  51. }];
  52. RQExerciseSettingItemViewModel *item2 = [[RQExerciseSettingItemViewModel alloc] init];
  53. item2.title = @"字体大小";
  54. group0.itemViewModels = @[item0, item2];
  55. self.dataSource = @[group0];
  56. }
  57. @end