YMMineCommonFunctionsOneView.m 5.9 KB

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