123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- //
- // MineServiceView.m
- // KulexiuForStudent
- //
- // Created by 王智 on 2022/9/5.
- //
- #import "MineServiceView.h"
- @interface MineServiceView ()
- @property (nonatomic, copy) MineViewCallback callback;
- @property (nonatomic, strong) NSMutableArray *imageArray;
- @property (nonatomic, strong) NSMutableArray *titleArray;
- @property (nonatomic, strong) NSMutableArray *tagArray;
- @property (weak, nonatomic) IBOutlet UIView *containerView;
- @end
- @implementation MineServiceView
- + (instancetype)shareInstance {
- MineServiceView *view = [[[NSBundle mainBundle] loadNibNamed:@"MineServiceView" owner:nil options:nil] firstObject];
- return view;
- }
- - (void)configView {
- [self.containerView removeAllSubViews];
- CGFloat space = (KPortraitWidth - 28 - 4 * FUNCTIONVIEW_WIDTH) / 5.0f;
- BOOL tagHandle = NO;
- for (NSInteger index = 0; index < self.imageArray.count; index++) {
- if (self.isMember == NO && index == 3) {
- tagHandle = YES;
- continue;
- }
- MineActionView *functionButton = [MineActionView shareInstance];
- NSNumber *tagValue = self.tagArray[index];
- MINEVIEWTYPE type = [tagValue intValue];
- MJWeakSelf;
- [functionButton configWithSource:self.imageArray[index] title:self.titleArray[index] functionType:type callback:^(MINEVIEWTYPE type) {
- if (weakSelf.callback) {
- weakSelf.callback(type);
- }
- }];
- CGRect frame = CGRectZero;
- if (tagHandle) {
- frame = CGRectMake(space + (index - 1) % 4 * (space + FUNCTIONVIEW_WIDTH), FUNCTIONVIEW_WIDTH * ((index-1) / 4), FUNCTIONVIEW_WIDTH, FUNCTIONVIEW_HEIGHT);
- }
- else {
- frame = CGRectMake(space + index % 4 * (space + FUNCTIONVIEW_WIDTH), FUNCTIONVIEW_WIDTH * (index / 4), FUNCTIONVIEW_WIDTH, FUNCTIONVIEW_HEIGHT);
- }
- functionButton.frame = frame;
- [self.containerView addSubview:functionButton];
- }
- }
- - (void)functionViewAction:(MineViewCallback)callback {
- if (callback) {
- self.callback = callback;
- }
- }
- - (CGFloat)getViewHeight {
- return 232.0f;
- }
- - (NSMutableArray *)imageArray {
- if (!_imageArray) {
- _imageArray = [NSMutableArray arrayWithArray:@[@"tool_myLive",@"tool_liveCourse",@"tool_videoCourse",@"tool_musicRoom",@"tool_myAccompany",@"tool_homework",@"tool_evaluate"]];
- }
- return _imageArray;
- }
- - (NSMutableArray *)titleArray {
- if (!_titleArray) {
- _titleArray = [NSMutableArray arrayWithArray:@[@"商品订单",@"交易记录",@"优惠券"]];
- }
- return _titleArray;
- }
- - (NSMutableArray *)tagArray {
- if (!_tagArray) {
- _tagArray = [NSMutableArray arrayWithArray:@[@(MINEVIEWTYPE_ORDER),@(MINEVIEWTYPE_DEAL),@(MINEVIEWTYPE_TICKET)]];
- }
- return _tagArray;
- }
- /*
- // Only override drawRect: if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- - (void)drawRect:(CGRect)rect {
- // Drawing code
- }
- */
- @end
|