YMMineCommonFunctionsThreeView.m 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // YMMineCommonFunctionsThreeView.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/15.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMMineCommonFunctionsThreeView.h"
  9. #import "YMMineViewModel.h"
  10. #define kCommonFunctionsGridView_rowCount 4
  11. #define kCommonFunctionsGridView_itemHeight 90
  12. #define kCommonFunctionsGridView_H BAKit_getColumnCountWithArrayAndRowCount_pod(self.viewModel.commonFunctionsThreeGridDataArray, kCommonFunctionsGridView_rowCount) * kCommonFunctionsGridView_itemHeight
  13. @interface YMMineCommonFunctionsThreeView ()
  14. /// 我的VM
  15. @property (nonatomic, strong) YMMineViewModel *viewModel;
  16. /// 常用功能宫格配置
  17. @property (nonatomic, strong) BAGridView_Config *commonFunctionsGridViewConfig;
  18. /// 常用功能宫格视图
  19. @property (nonatomic, strong) BAGridView *commonFunctionsGridView;
  20. @end
  21. @implementation YMMineCommonFunctionsThreeView
  22. - (void)ym_setupViews{
  23. [self addSubview:self.commonFunctionsGridView];
  24. [self setNeedsUpdateConstraints];
  25. [self updateConstraintsIfNeeded];
  26. }
  27. - (void)updateConstraints{
  28. [self.commonFunctionsGridView mas_makeConstraints:^(MASConstraintMaker *make) {
  29. make.top.equalTo(self).offset(adapt(10));
  30. make.left.equalTo(self).offset(adapt(15));
  31. make.right.equalTo(self).offset(adapt(-15));
  32. make.bottom.equalTo(self).offset(adapt(-10));
  33. make.height.mas_equalTo(kCommonFunctionsGridView_H);
  34. }];
  35. [super updateConstraints];
  36. }
  37. - (void)ym_bindViewModel:(YMMineViewModel *)viewModel{
  38. if (!viewModel) {
  39. return;
  40. }
  41. _viewModel = viewModel;
  42. @weakify(self)
  43. [[self.viewModel.refreshUISubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id result) {
  44. @strongify(self)
  45. self.commonFunctionsGridView.config = self.commonFunctionsGridViewConfig;
  46. self.commonFunctionsGridViewConfig.dataArray = self.viewModel.commonFunctionsThreeGridDataArray;
  47. [self.commonFunctionsGridView mas_remakeConstraints:^(MASConstraintMaker *make) {
  48. make.top.equalTo(self).offset(adapt(10));
  49. make.left.equalTo(self).offset(adapt(15));
  50. make.right.equalTo(self).offset(adapt(-15));
  51. make.bottom.equalTo(self).offset(adapt(-10));
  52. make.height.mas_equalTo(kCommonFunctionsGridView_H);
  53. }];
  54. }];
  55. }
  56. - (BAGridView_Config *)commonFunctionsGridViewConfig{
  57. if (!_commonFunctionsGridViewConfig) {
  58. _commonFunctionsGridViewConfig = [[BAGridView_Config alloc]init];
  59. _commonFunctionsGridViewConfig.scrollEnabled = NO;
  60. // 是否显示分割线
  61. _commonFunctionsGridViewConfig.showLineView = NO;
  62. // item:分割线颜色,默认:BAKit_Color_Gray_11【BAKit_Color_RGB(248, 248, 248)】
  63. _commonFunctionsGridViewConfig.ba_gridView_lineColor = HexColorFromRGB(0xededed);
  64. // item:每行 item 的个数
  65. _commonFunctionsGridViewConfig.ba_gridView_rowCount = kCommonFunctionsGridView_rowCount;
  66. // item:高度/宽度
  67. _commonFunctionsGridViewConfig.ba_gridView_itemHeight = kCommonFunctionsGridView_itemHeight;
  68. _commonFunctionsGridViewConfig.ba_gridView_imageWidth = 24;
  69. _commonFunctionsGridViewConfig.ba_gridView_imageHeight = 24;
  70. // item:title 颜色,默认:BAKit_Color_Black【[UIColor blackColor]】
  71. _commonFunctionsGridViewConfig.ba_gridView_titleColor = BAKit_Color_Black_pod;
  72. // item:title Font,默认:图文样式下 16,两行文字下(上25,下12)
  73. _commonFunctionsGridViewConfig.ba_gridView_titleFont = LCFont(14);
  74. // item:背景颜色,默认:白色
  75. _commonFunctionsGridViewConfig.ba_gridView_backgroundColor = BAKit_Color_White_pod;
  76. // item:背景选中颜色,默认:无色
  77. _commonFunctionsGridViewConfig.ba_gridView_selectedBackgroundColor = BAKit_Color_Clear_pod;
  78. // badge
  79. _commonFunctionsGridViewConfig.ba_gridView_badgeType = kBAGridViewBadgeType_Center;
  80. _commonFunctionsGridViewConfig.ba_gridView_badgeFont = LCFont(10);
  81. _commonFunctionsGridViewConfig.ba_gridView_badgeRectCorners = UIRectCornerTopLeft | UIRectCornerTopRight |UIRectCornerBottomLeft| UIRectCornerBottomRight;
  82. // _commonFunctionsGridViewConfig.ba_gridView_badgeCornerRadius = 7;
  83. // _commonFunctionsGridViewConfig.ba_gridView_badgeBgColor = HexColorFromRGB(0xF4003F);
  84. // _commonFunctionsGridViewConfig.ba_gridView_badgeTextColor = HexColorFromRGB(0xFFFFFF);
  85. // _commonFunctionsGridViewConfig.ba_gridView_badgeHeight = 14;
  86. // _commonFunctionsGridViewConfig.ba_gridView_badgeOffsetPoint = CGPointMake(8, 8);
  87. // _commonFunctionsGridViewConfig.ba_gridView_itemEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 10);
  88. // _commonFunctionsGridViewConfig.minimumLineSpacing = 10;
  89. // _commonFunctionsGridViewConfig.minimumInteritemSpacing = 10;
  90. _commonFunctionsGridViewConfig.gridViewType = BAGridViewTypeImageTitle;
  91. }
  92. return _commonFunctionsGridViewConfig;
  93. }
  94. - (BAGridView *)commonFunctionsGridView{
  95. if (!_commonFunctionsGridView) {
  96. @weakify(self)
  97. _commonFunctionsGridView = [BAGridView ba_creatGridViewWithGridViewConfig:self.commonFunctionsGridViewConfig block:^(BAGridItemModel *model, NSIndexPath *indexPath) {
  98. @strongify(self)
  99. [self.viewModel.commonFunctionsOperationSubject sendNext:@(self.viewModel.commonFunctionsThreeGridDataArray[indexPath.item].functionsType)];
  100. }];
  101. _commonFunctionsGridView.layer.cornerRadius = adapt(8);
  102. _commonFunctionsGridView.layer.masksToBounds = YES;
  103. }
  104. return _commonFunctionsGridView;
  105. }
  106. @end