// // YMMineCommonFunctionsThreeView.m // MSYOUPAI // // Created by YoMi on 2024/2/15. // Copyright © 2024 MS. All rights reserved. // #import "YMMineCommonFunctionsThreeView.h" #import "YMMineViewModel.h" #define kCommonFunctionsGridView_rowCount 4 #define kCommonFunctionsGridView_itemHeight 90 #define kCommonFunctionsGridView_H BAKit_getColumnCountWithArrayAndRowCount_pod(self.viewModel.commonFunctionsThreeGridDataArray, kCommonFunctionsGridView_rowCount) * kCommonFunctionsGridView_itemHeight @interface YMMineCommonFunctionsThreeView () /// 我的VM @property (nonatomic, strong) YMMineViewModel *viewModel; /// 常用功能宫格配置 @property (nonatomic, strong) BAGridView_Config *commonFunctionsGridViewConfig; /// 常用功能宫格视图 @property (nonatomic, strong) BAGridView *commonFunctionsGridView; @end @implementation YMMineCommonFunctionsThreeView - (void)ym_setupViews{ [self addSubview:self.commonFunctionsGridView]; [self setNeedsUpdateConstraints]; [self updateConstraintsIfNeeded]; } - (void)updateConstraints{ [self.commonFunctionsGridView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self).offset(adapt(10)); make.left.equalTo(self).offset(adapt(15)); make.right.equalTo(self).offset(adapt(-15)); make.bottom.equalTo(self).offset(adapt(-10)); make.height.mas_equalTo(kCommonFunctionsGridView_H); }]; [super updateConstraints]; } - (void)ym_bindViewModel:(YMMineViewModel *)viewModel{ if (!viewModel) { return; } _viewModel = viewModel; @weakify(self) [[self.viewModel.refreshUISubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id result) { @strongify(self) self.commonFunctionsGridView.config = self.commonFunctionsGridViewConfig; self.commonFunctionsGridViewConfig.dataArray = self.viewModel.commonFunctionsThreeGridDataArray; [self.commonFunctionsGridView mas_remakeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self).offset(adapt(10)); make.left.equalTo(self).offset(adapt(15)); make.right.equalTo(self).offset(adapt(-15)); make.bottom.equalTo(self).offset(adapt(-10)); make.height.mas_equalTo(kCommonFunctionsGridView_H); }]; }]; } - (BAGridView_Config *)commonFunctionsGridViewConfig{ if (!_commonFunctionsGridViewConfig) { _commonFunctionsGridViewConfig = [[BAGridView_Config alloc]init]; _commonFunctionsGridViewConfig.scrollEnabled = NO; // 是否显示分割线 _commonFunctionsGridViewConfig.showLineView = NO; // item:分割线颜色,默认:BAKit_Color_Gray_11【BAKit_Color_RGB(248, 248, 248)】 _commonFunctionsGridViewConfig.ba_gridView_lineColor = HexColorFromRGB(0xededed); // item:每行 item 的个数 _commonFunctionsGridViewConfig.ba_gridView_rowCount = kCommonFunctionsGridView_rowCount; // item:高度/宽度 _commonFunctionsGridViewConfig.ba_gridView_itemHeight = kCommonFunctionsGridView_itemHeight; _commonFunctionsGridViewConfig.ba_gridView_imageWidth = 24; _commonFunctionsGridViewConfig.ba_gridView_imageHeight = 24; // item:title 颜色,默认:BAKit_Color_Black【[UIColor blackColor]】 _commonFunctionsGridViewConfig.ba_gridView_titleColor = BAKit_Color_Black_pod; // item:title Font,默认:图文样式下 16,两行文字下(上25,下12) _commonFunctionsGridViewConfig.ba_gridView_titleFont = LCFont(14); // item:背景颜色,默认:白色 _commonFunctionsGridViewConfig.ba_gridView_backgroundColor = BAKit_Color_White_pod; // item:背景选中颜色,默认:无色 _commonFunctionsGridViewConfig.ba_gridView_selectedBackgroundColor = BAKit_Color_Clear_pod; // badge _commonFunctionsGridViewConfig.ba_gridView_badgeType = kBAGridViewBadgeType_Center; _commonFunctionsGridViewConfig.ba_gridView_badgeFont = LCFont(10); _commonFunctionsGridViewConfig.ba_gridView_badgeRectCorners = UIRectCornerTopLeft | UIRectCornerTopRight |UIRectCornerBottomLeft| UIRectCornerBottomRight; // _commonFunctionsGridViewConfig.ba_gridView_badgeCornerRadius = 7; // _commonFunctionsGridViewConfig.ba_gridView_badgeBgColor = HexColorFromRGB(0xF4003F); // _commonFunctionsGridViewConfig.ba_gridView_badgeTextColor = HexColorFromRGB(0xFFFFFF); // _commonFunctionsGridViewConfig.ba_gridView_badgeHeight = 14; // _commonFunctionsGridViewConfig.ba_gridView_badgeOffsetPoint = CGPointMake(8, 8); // _commonFunctionsGridViewConfig.ba_gridView_itemEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 10); // _commonFunctionsGridViewConfig.minimumLineSpacing = 10; // _commonFunctionsGridViewConfig.minimumInteritemSpacing = 10; _commonFunctionsGridViewConfig.gridViewType = BAGridViewTypeImageTitle; } return _commonFunctionsGridViewConfig; } - (BAGridView *)commonFunctionsGridView{ if (!_commonFunctionsGridView) { @weakify(self) _commonFunctionsGridView = [BAGridView ba_creatGridViewWithGridViewConfig:self.commonFunctionsGridViewConfig block:^(BAGridItemModel *model, NSIndexPath *indexPath) { @strongify(self) [self.viewModel.commonFunctionsOperationSubject sendNext:@(self.viewModel.commonFunctionsThreeGridDataArray[indexPath.item].functionsType)]; }]; _commonFunctionsGridView.layer.cornerRadius = adapt(8); _commonFunctionsGridView.layer.masksToBounds = YES; } return _commonFunctionsGridView; } @end