123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- //
- // YMMineCommonFunctionsOneView.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/2/15.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMMineCommonFunctionsOneView.h"
- #import "YMMineViewModel.h"
- #define kCommonFunctionsGridView_rowCount 4
- #define kCommonFunctionsGridView_itemHeight 95
- #define kCommonFunctionsGridView_H BAKit_getColumnCountWithArrayAndRowCount_pod(self.viewModel.commonFunctionsOneGridDataArray, kCommonFunctionsGridView_rowCount) * kCommonFunctionsGridView_itemHeight
- @interface YMMineCommonFunctionsOneView ()
- /// 我的VM
- @property (nonatomic, strong) YMMineViewModel *viewModel;
- /// 常用功能宫格配置
- @property (nonatomic, strong) BAGridView_Config *commonFunctionsGridViewConfig;
- /// 常用功能宫格视图
- @property (nonatomic, strong) BAGridView *commonFunctionsGridView;
- @end
- @implementation YMMineCommonFunctionsOneView
- - (void)ym_setupViews{
- self.backgroundColor = UIColor.clearColor;
- [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.commonFunctionsOneGridDataArray;
- [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 = 26;
- _commonFunctionsGridViewConfig.ba_gridView_imageHeight = 26;
- // 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 = HexColorFromRGB(0xFFFFFF);
- // 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.commonFunctionsOneGridDataArray[indexPath.item].functionsType)];
- }];
- _commonFunctionsGridView.backgroundColor = HexColorFromRGB(0xFFFFFF);
- [_commonFunctionsGridView ym_setGradientBackgroundWithColors:@[HexColorFromRGB(0xFFFFFF),HexColorFromRGB(0xFFFFFF)] locations:@[@0,@1] startPoint:CGPointMake(0, 0) endPoint:CGPointMake(0, 1)];
- _commonFunctionsGridView.layer.cornerRadius = adapt(12);
- _commonFunctionsGridView.layer.masksToBounds = YES;
- }
- return _commonFunctionsGridView;
- }
- @end
|