Files
yinmeng-ios/xplan-ios/Base/UI/SendGiftView/View/XPGiftBarView.m

201 lines
6.1 KiB
Mathematica
Raw Normal View History

2021-11-10 18:42:27 +08:00
//
// XPGiftBottomView.m
// xplan-ios
//
// Created by on 2021/11/9.
//
#import "XPGiftBarView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "ThemeColor+SendGift.h"
#import "UIImage+Utils.h"
@interface XPGiftBarView ()
///
@property (nonatomic,strong) UILabel *balanceLabel;
///
@property (nonatomic,strong) UIStackView *rechargeStackView;
///
@property (nonatomic,strong) UILabel *rechargeLabel;
///
@property (nonatomic,strong) UIImageView *rechageImageView;
///
@property (nonatomic,strong) UIView *sendOperationView;
///
@property (nonatomic,strong) UILabel *countLabel;
///
@property (nonatomic,strong) UIButton *arrowButton;
///
@property (nonatomic,strong) UIButton *sendGiftButton;
@end
@implementation XPGiftBarView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Response
- (void)sendButtonAction:(UIButton *)sender {
}
- (void)rechargeButtonAction:(UIButton *)sender {
}
- (void)arrowButtonAction:(UIButton *)sender {
}
#pragma mark - Private Method
- (void)initSubViews {
self.backgroundColor= [UIColor clearColor];
[self addSubview:self.balanceLabel];
[self addSubview:self.rechargeStackView];
[self addSubview:self.sendOperationView];
[self.rechargeStackView addArrangedSubview:self.rechargeLabel];
[self.rechargeStackView addArrangedSubview:self.rechageImageView];
[self.sendOperationView addSubview:self.countLabel];
[self.sendOperationView addSubview:self.arrowButton];
[self.sendOperationView addSubview:self.sendGiftButton];
}
- (void)initSubViewConstraints {
[self mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(45);
}];
[self.balanceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(15);
make.centerY.mas_equalTo(self.sendOperationView);
}];
[self.rechargeStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.sendOperationView);
make.left.mas_equalTo(self.balanceLabel.mas_right).offset(12);
}];
[self.sendOperationView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self).offset(-15);
make.bottom.mas_equalTo(-11);
make.height.mas_equalTo(30);
make.left.mas_equalTo(self.countLabel.mas_left).offset(-13);
}];
[self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.sendGiftButton);
make.right.mas_equalTo(self.arrowButton.mas_left).offset(-10);
}];
[self.arrowButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(10, 10));
make.centerY.mas_equalTo(self.sendGiftButton);
make.right.mas_equalTo(self.sendGiftButton.mas_left).offset(-10);
}];
[self.sendGiftButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(67, 30));
make.right.centerY.mas_equalTo(self.sendOperationView);
}];
}
#pragma mark - Getters And Setters
- (UILabel *)balanceLabel {
if (!_balanceLabel) {
_balanceLabel = [[UILabel alloc] init];
_balanceLabel.textColor = [ThemeColor mainTextColor];
_balanceLabel.font = [UIFont systemFontOfSize:13];
_balanceLabel.text = @"余额10000";
}
return _balanceLabel;
}
- (UIStackView *)rechargeStackView {
if (!_rechargeStackView) {
_rechargeStackView = [[UIStackView alloc] init];
_rechargeStackView.axis = UILayoutConstraintAxisHorizontal;
_rechargeStackView.distribution = UIStackViewDistributionFill;
_rechargeStackView.alignment = UIStackViewAlignmentCenter;
_rechargeStackView.spacing = 5;
}
return _rechargeStackView;
}
- (UILabel *)rechargeLabel {
if (!_rechargeLabel) {
_rechargeLabel = [[UILabel alloc] init];
_rechargeLabel.text = @"充值";
_rechargeLabel.font = [UIFont systemFontOfSize:13];
_rechargeLabel.textColor = [ThemeColor giftRechargeColor];
}
return _rechargeLabel;
}
- (UIImageView *)rechageImageView {
if (!_rechageImageView) {
_rechageImageView = [[UIImageView alloc] init];
_rechageImageView.userInteractionEnabled = YES;
_rechageImageView.image = [UIImage imageNamed:@"gift_bar_recharge_arrow"];
}
return _rechageImageView;
}
- (UIView *)sendOperationView {
if (!_sendOperationView) {
_sendOperationView = [[UIView alloc] init];
_sendOperationView.layer.masksToBounds = YES;
_sendOperationView.layer.cornerRadius = 15;
_sendOperationView.layer.borderColor = [ThemeColor appMainColor].CGColor;
_sendOperationView.layer.borderWidth = 1;
}
return _sendOperationView;
}
- (UILabel *)countLabel {
if (!_countLabel) {
_countLabel = [[UILabel alloc] init];
_countLabel.textAlignment = NSTextAlignmentCenter;
_countLabel.textColor = [ThemeColor mainTextColor];
_countLabel.text = @"1";
_countLabel.font = [UIFont systemFontOfSize:13];
}
return _countLabel;
}
- (UIButton *)arrowButton {
if (!_arrowButton) {
_arrowButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_arrowButton setImage:[UIImage imageNamed:@"gift_bar_count_arrow"] forState:UIControlStateNormal];
[_arrowButton setImage:[UIImage imageNamed:@"gift_bar_count_up_arrow"] forState:UIControlStateSelected];
[_arrowButton addTarget:self action:@selector(arrowButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _arrowButton;
}
- (UIButton *)sendGiftButton {
if (!_sendGiftButton) {
_sendGiftButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_sendGiftButton setTitle:@"赠送" forState:UIControlStateNormal];
[_sendGiftButton setTitleColor:[ThemeColor mainTextColor] forState:UIControlStateNormal];
[_sendGiftButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor], [ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
_sendGiftButton.titleLabel.font = [UIFont systemFontOfSize:13];
_sendGiftButton.layer.masksToBounds = YES;
_sendGiftButton.layer.cornerRadius = 15;
[_sendGiftButton addTarget:self action:@selector(sendButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _sendGiftButton;
}
@end