// // YMGuildManagementMyEarningsInfoView.m // MSYOUPAI // // Created by YoMi on 2024/3/26. // Copyright © 2024 MS. All rights reserved. // #import "YMGuildManagementMyEarningsInfoView.h" @interface YMGuildManagementMyEarningsInfoView () @property (nonatomic, strong) UIView *bgView; @property (nonatomic, strong) UIImageView *bgImgv; @property (nonatomic, strong) UILabel *imgvMask; @property (nonatomic, strong) UILabel *timeMidLab; @property (nonatomic, strong) UILabel *coinLab; @property (nonatomic, strong) UILabel *contentLab; @property (nonatomic, strong) UIView *bottomView; @property (nonatomic, strong) UILabel *earnCountLab; @property (nonatomic, strong) UIButton *memberBtn; @property (nonatomic, strong) YMGuildManagementViewModel *viewModel; @end @implementation YMGuildManagementMyEarningsInfoView -(void)ym_setupViews{ [self addSubview:self.bgView]; [self.bgView addSubview:self.bgImgv]; [self.bgImgv addSubview:self.imgvMask]; [self.bgView addSubview:self.btnView]; [self.btnView addSubview:self.timeMidLab]; [self.btnView addSubview:self.timeBtn1]; [self.btnView addSubview:self.timeBtn2]; [self.bgView addSubview:self.coinLab]; [self.bgView addSubview:self.contentLab]; [self addSubview:self.bottomView]; [self.bottomView addSubview:self.earnCountLab]; [self.bottomView addSubview:self.memberBtn]; [self.bottomView addSubview:self.sortBtn]; [self setNeedsUpdateConstraints]; [self updateConstraintsIfNeeded]; } - (void)updateConstraints{ [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.left.right.equalTo(self); make.height.mas_equalTo(adapt(256)); }]; [self.bgImgv mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self.bgView); }]; [self.imgvMask mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self.bgImgv); }]; [self.btnView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.bgView); make.top.equalTo(self.bgView).offset(adapt(102)); make.width.equalTo(adapt(204)); make.height.mas_equalTo(adapt(26)); }]; [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.bgView.mas_bottom); make.left.right.equalTo(self); make.height.mas_equalTo(adapt(60)); }]; [self.timeMidLab mas_makeConstraints:^(MASConstraintMaker *make) { make.center.equalTo(self.btnView); make.width.mas_equalTo(adapt(20)); }]; [self.timeBtn1 mas_makeConstraints:^(MASConstraintMaker *make) { make.top.leading.bottom.equalTo(self.btnView); make.trailing.equalTo(self.timeMidLab.leading); }]; [self.timeBtn2 mas_makeConstraints:^(MASConstraintMaker *make) { make.top.trailing.bottom.equalTo(self.btnView); make.leading.equalTo(self.timeMidLab.trailing); }]; [self.coinLab mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.btnView.mas_bottom).offset(adapt(10)); make.centerX.equalTo(self.bgView); }]; [self.contentLab mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.bgView); make.top.equalTo(self.coinLab.mas_bottom).offset(adapt(10)); }]; [self.earnCountLab mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.bottomView); make.left.equalTo(self.bottomView).offset(15); }]; [self.memberBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.bottomView); make.left.equalTo(self.earnCountLab.mas_right).offset(15); }]; [self.sortBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.bottomView); make.right.equalTo(self.bottomView).offset(-15); make.width.mas_equalTo(adapt(60)); make.height.mas_equalTo(adapt(30)); }]; [super updateConstraints]; } - (void)ym_bindViewModel:(YMGuildManagementViewModel *)viewModel{ if (!viewModel) { return; } _viewModel = viewModel; @weakify(self) [[[[RACObserve(self.viewModel, startTime) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString * startTime) { @strongify(self) [self.timeBtn1 setTitle:startTime forState:UIControlStateNormal]; }]; [[[[RACObserve(self.viewModel, endTime) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString * endTime) { @strongify(self) [self.timeBtn2 setTitle:endTime forState:UIControlStateNormal]; }]; [[[[RACObserve(self.viewModel, myEarnStr) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString * myEarnStr) { @strongify(self) self.coinLab.text = myEarnStr; }]; [[[[RACObserve(self.viewModel, peopleStr) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString * peopleStr) { @strongify(self) self.earnCountLab.text = [NSString stringWithFormat:@"产生收益(%@)人",peopleStr]; }]; } - (UIView *)bgView{ if (!_bgView) { _bgView = [[UIView alloc]init]; _bgView.backgroundColor = UIColor.whiteColor; } return _bgView; } - (UIImageView *)bgImgv { if (!_bgImgv) { _bgImgv = [[UIImageView alloc] init]; _bgImgv.image = [UIImage imageNamed:@"gonghui_nav_bg"]; } return _bgImgv; } - (UILabel *)imgvMask { if (!_imgvMask) { _imgvMask = [[UILabel alloc] init]; } return _imgvMask; } - (UIView *)bottomView{ if (!_bottomView) { _bottomView = [[UIView alloc]init]; _bottomView.backgroundColor = UIColor.whiteColor; } return _bottomView; } - (UIButton *)btnView{ if (!_btnView) { _btnView = [[UIButton alloc]init]; _btnView.layer.cornerRadius = adapt(13); _btnView.layer.borderWidth = 0.5; _btnView.layer.borderColor = UIColor.whiteColor.CGColor; } return _btnView; } - (UILabel *)timeMidLab{ if (!_timeMidLab) { _timeMidLab = [[UILabel alloc]init]; _timeMidLab.textAlignment = NSTextAlignmentCenter; _timeMidLab.font = LCFont(15); _timeMidLab.textColor = UIColor.whiteColor; _timeMidLab.text = @"至"; } return _timeMidLab; } - (UIButton *)timeBtn1{ if (!_timeBtn1) { _timeBtn1 = [UIButton buttonWithType:UIButtonTypeCustom]; _timeBtn1.contentHorizontalAlignment = UIControlContentHorizontalAlignmentTrailing; _timeBtn1.titleLabel.font = LCFont(15); _timeBtn1.userInteractionEnabled = NO; [_timeBtn1 setTitleColor:UIColor.whiteColor forState:UIControlStateNormal]; } return _timeBtn1; } - (UIButton *)timeBtn2{ if (!_timeBtn2) { _timeBtn2 = [UIButton buttonWithType:UIButtonTypeCustom]; _timeBtn2.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeading; _timeBtn2.titleLabel.font = LCFont(15); _timeBtn2.userInteractionEnabled = NO; [_timeBtn2 setTitleColor:UIColor.whiteColor forState:UIControlStateNormal]; } return _timeBtn2; } - (UILabel *)coinLab{ if (!_coinLab) { _coinLab = [[UILabel alloc]init]; _coinLab.textAlignment = NSTextAlignmentCenter; _coinLab.font = LCBoldFont(20); _coinLab.textColor = UIColor.whiteColor; } return _coinLab; } - (UILabel *)contentLab{ if (!_contentLab) { _contentLab = [[UILabel alloc]init]; _contentLab.textAlignment = NSTextAlignmentCenter; _contentLab.font = LCFont(15); _contentLab.textColor = UIColor.whiteColor; _contentLab.text = @"我的收益(金币)"; } return _contentLab; } - (UILabel *)earnCountLab{ if (!_earnCountLab) { _earnCountLab = [[UILabel alloc]init]; _earnCountLab.font = LCFont(15); _earnCountLab.textColor = [UIColor secondaryLabelColor]; _earnCountLab.text = @"产生收益(*)人"; } return _earnCountLab; } - (UIButton *)memberBtn{ if (!_memberBtn) { _memberBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _memberBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeading; _memberBtn.titleLabel.font = LCFont(15); [_memberBtn setTitleColor:HexColorFromRGBA(0xFF76C0, 1) forState:UIControlStateNormal]; [_memberBtn setTitle:@"公会成员列表" forState:UIControlStateNormal]; WS(weakSelf) [[[_memberBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) { [weakSelf.viewModel gotoMember]; }]; } return _memberBtn; } - (UIButton *)sortBtn{ if (!_sortBtn) { _sortBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _sortBtn.titleLabel.font = LCFont(13); [_sortBtn setTitle:@"排序" forState:UIControlStateNormal]; [_sortBtn setTitleColor:HexColorFromRGB(0xFFFFFF) forState:UIControlStateNormal]; _sortBtn.backgroundColor = HexColorFromRGBA(0xFF76C0, 1); _sortBtn.layer.cornerRadius = 5; _sortBtn.layer.masksToBounds = true; } return _sortBtn; } @end