
- Removed YuMi/Library/ (138 MB, not tracked) - Removed YuMi/Resources/ (23 MB, not tracked) - Removed old version assets (566 files, not tracked) - Excluded Pods/, xcuserdata/ and other build artifacts - Clean repository optimized for company server deployment
396 lines
14 KiB
Objective-C
396 lines
14 KiB
Objective-C
//
|
|
// ShoppingMallItemPreview.m
|
|
// YuMi
|
|
//
|
|
// Created by P on 2024/11/18.
|
|
//
|
|
|
|
#import "ShoppingMallItemPreview.h"
|
|
#import "DressUpShopModel.h"
|
|
#import "MyDressingDataModel.h"
|
|
#import "XPSkillCardPlayerManager.h"
|
|
#import <SVGA.h>
|
|
#import <QGVAPWrapView.h>
|
|
#import "XPRoomGiftAnimationParser.h"
|
|
|
|
@interface ShoppingMallItemPreview ()
|
|
|
|
@property(nonatomic, assign) BOOL isForGive;
|
|
@property(nonatomic, assign) BOOL isVaild;
|
|
@property(nonatomic, strong) DressUpShopModel *model;
|
|
@property(nonatomic, strong) MyDressingDataModel *myDressingModel;
|
|
@property(nonatomic, strong) NetImageView *itemImageView;
|
|
@property(nonatomic, strong) UIView *itemImageBGView;
|
|
@property(nonatomic, strong) VAPView *mp4View;
|
|
@property(nonatomic, strong) XPRoomGiftAnimationParser *mp4Parser;
|
|
@property(nonatomic, strong) SVGAImageView *svgaView;
|
|
@property(nonatomic, strong) UILabel *nameLabel;
|
|
@property(nonatomic, strong) UILabel *pricePerDayLabel;
|
|
|
|
@property(nonatomic, strong) UIButton *cancelButton;
|
|
@property(nonatomic, strong) UIButton *buyButton;
|
|
@property(nonatomic, strong) UIButton *giveButton;
|
|
|
|
@property(nonatomic, strong) UserInfoModel *userModel;
|
|
|
|
@end
|
|
|
|
@implementation ShoppingMallItemPreview
|
|
|
|
- (instancetype)init {
|
|
if (self = [super init]) {
|
|
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (instancetype)initWith:(DressUpShopModel *)model isForGive:(BOOL)isForGive {
|
|
if (self = [super init]) {
|
|
[self setupUI];
|
|
self.isForGive = isForGive;
|
|
self.userModel = [[XPSkillCardPlayerManager shareInstance] userInfoModel];
|
|
self.model = model;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (instancetype)initWithMyDress:(MyDressingDataModel *)model isVaild:(BOOL)isVaild {
|
|
if (self = [super init]) {
|
|
[self setupUI];
|
|
self.isVaild = isVaild;
|
|
self.userModel = [[XPSkillCardPlayerManager shareInstance] userInfoModel];
|
|
self.myDressingModel = model;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)setModel:(DressUpShopModel *)model {
|
|
_model = model;
|
|
|
|
self.itemImageView.imageUrl = model.pic;
|
|
self.nameLabel.text = model.name;
|
|
|
|
if (model.dressType == 4) {
|
|
[self.itemImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
make.center.mas_equalTo(self.itemImageBGView);
|
|
make.width.mas_equalTo(kGetScaleWidth(90));
|
|
make.height.mas_equalTo(kGetScaleWidth(46));
|
|
}];
|
|
}
|
|
|
|
if (model.vipLimit > self.userModel.userVipInfoVO.vipLevel) {
|
|
self.buyButton.hidden = YES;
|
|
self.giveButton.hidden = YES;
|
|
[self.cancelButton setAttributedTitle:[[NSAttributedString alloc] initWithString:YMLocalizedString(@"TTAlertConfig0")
|
|
attributes:@{NSFontAttributeName: kFontMedium(14),
|
|
NSForegroundColorAttributeName: [UIColor whiteColor]}]
|
|
forState:UIControlStateNormal];
|
|
[self.cancelButton mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.mas_equalTo(self);
|
|
make.bottom.mas_equalTo(-38);
|
|
make.size.mas_equalTo(CGSizeMake(90, 32));
|
|
}];
|
|
self.pricePerDayLabel.text = [NSString stringWithFormat:YMLocalizedString(@"1.0.30_text_3"), @(model.vipLimit)];
|
|
} else {
|
|
self.pricePerDayLabel.attributedText = [model mallItemPricePerDay:YES isFullDisplay:YES];
|
|
if (model.dressType == 3) {
|
|
switch (model.effectType) {
|
|
case 1:{
|
|
[self addSubview:self.mp4View];
|
|
[self.mp4View mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.mas_equalTo(self.itemImageView);
|
|
}];
|
|
self.mp4Parser = [[XPRoomGiftAnimationParser alloc] init];
|
|
@kWeakify(self);
|
|
[self.mp4Parser parseWithURL:model.effect
|
|
completionBlock:^(NSString * _Nullable videoUrl) {
|
|
@kStrongify(self);
|
|
if (![NSString isEmpty:videoUrl]) {
|
|
[self.mp4View playHWDMP4:videoUrl repeatCount:-1 delegate:nil];
|
|
}
|
|
} failureBlock:^(NSError * _Nullable error) { }];
|
|
}
|
|
self.itemImageView.hidden = YES;
|
|
break;
|
|
case 0:
|
|
case 2:
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
- (void)setMyDressingModel:(MyDressingDataModel *)myDressingModel {
|
|
_myDressingModel = myDressingModel;
|
|
|
|
if (myDressingModel.dressType == 4) {
|
|
[self.itemImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
make.center.mas_equalTo(self.itemImageBGView);
|
|
make.width.mas_equalTo(kGetScaleWidth(90));
|
|
make.height.mas_equalTo(kGetScaleWidth(46));
|
|
}];
|
|
}
|
|
|
|
self.itemImageView.imageUrl = myDressingModel.pic;
|
|
self.nameLabel.text = myDressingModel.name;
|
|
|
|
if (myDressingModel.dressType == 3) {
|
|
switch (myDressingModel.effectType) {
|
|
case 1:{
|
|
[self addSubview:self.mp4View];
|
|
[self.mp4View mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.mas_equalTo(self.itemImageView);
|
|
}];
|
|
self.mp4Parser = [[XPRoomGiftAnimationParser alloc] init];
|
|
|
|
NSString *url = [NSString isEmpty:myDressingModel.effect] ? myDressingModel.pic : myDressingModel.effect;
|
|
|
|
@kWeakify(self);
|
|
[self.mp4Parser parseWithURL:url
|
|
completionBlock:^(NSString * _Nullable videoUrl) {
|
|
@kStrongify(self);
|
|
if (![NSString isEmpty:videoUrl]) {
|
|
[self.mp4View playHWDMP4:videoUrl repeatCount:-1 delegate:nil];
|
|
}
|
|
} failureBlock:^(NSError * _Nullable error) { }];
|
|
}
|
|
self.itemImageView.hidden = YES;
|
|
break;
|
|
case 0:
|
|
case 2:
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (self.isVaild) {
|
|
self.buyButton.hidden = NO;
|
|
self.pricePerDayLabel.attributedText = [myDressingModel generateAttributedStringWithIncludeOriginalPrice:YES];
|
|
} else {
|
|
self.buyButton.hidden = YES;
|
|
self.giveButton.hidden = YES;
|
|
[self.cancelButton setAttributedTitle:[[NSAttributedString alloc] initWithString:YMLocalizedString(@"TTAlertConfig0")
|
|
attributes:@{NSFontAttributeName: kFontMedium(14),
|
|
NSForegroundColorAttributeName: [UIColor whiteColor]}]
|
|
forState:UIControlStateNormal];
|
|
[self.cancelButton mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.mas_equalTo(self);
|
|
make.bottom.mas_equalTo(-38);
|
|
make.size.mas_equalTo(CGSizeMake(90, 32));
|
|
}];
|
|
self.pricePerDayLabel.text = YMLocalizedString(@"1.0.30_text_2");
|
|
}
|
|
}
|
|
|
|
- (void)setupUI {
|
|
UIImageView *bg = [self backgroundImageView];
|
|
[self addSubview:bg];
|
|
[bg mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.mas_equalTo(self);
|
|
}];
|
|
|
|
[self addSubview:self.itemImageBGView];
|
|
[self.itemImageBGView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.mas_equalTo(self);
|
|
make.top.mas_equalTo(32);
|
|
make.size.mas_equalTo(CGSizeMake(155, 155));
|
|
}];
|
|
|
|
[self addSubview:self.itemImageView];
|
|
[self.itemImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.mas_equalTo(self);
|
|
make.top.mas_equalTo(32);
|
|
make.size.mas_equalTo(CGSizeMake(155, 155));
|
|
}];
|
|
|
|
[self addSubview:self.nameLabel];
|
|
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.trailing.mas_equalTo(self).inset(6);
|
|
make.top.mas_equalTo(self.itemImageBGView.mas_bottom).offset(4);
|
|
make.height.mas_equalTo(22);
|
|
}];
|
|
|
|
[self addSubview:self.pricePerDayLabel];
|
|
[self.pricePerDayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.mas_equalTo(self);
|
|
make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(10);
|
|
make.height.mas_equalTo(22);
|
|
}];
|
|
|
|
UIImageView *line = [self line];
|
|
[self addSubview:line];
|
|
[line mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.trailing.mas_equalTo(self).offset(22);
|
|
make.height.mas_equalTo(1.5);
|
|
make.top.mas_equalTo(self.pricePerDayLabel.mas_bottom).offset(18);
|
|
}];
|
|
|
|
[self addSubview:self.cancelButton];
|
|
[self.cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(line.mas_bottom).offset(20);
|
|
make.leading.mas_equalTo(46);
|
|
make.size.mas_equalTo(CGSizeMake(90, 32));
|
|
}];
|
|
|
|
[self addSubview:self.buyButton];
|
|
[self.buyButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(line.mas_bottom).offset(20);
|
|
make.trailing.mas_equalTo(-46);
|
|
make.size.mas_equalTo(CGSizeMake(90, 32));
|
|
}];
|
|
|
|
[self addSubview:self.giveButton];
|
|
[self.giveButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(line.mas_bottom).offset(20);
|
|
make.trailing.mas_equalTo(-46);
|
|
make.size.mas_equalTo(CGSizeMake(90, 32));
|
|
}];
|
|
}
|
|
|
|
#pragma mark -
|
|
|
|
- (void)setIsForGive:(BOOL)isForGive {
|
|
_isForGive = isForGive;
|
|
self.buyButton.hidden = isForGive;
|
|
self.giveButton.hidden = !isForGive;
|
|
}
|
|
|
|
- (void)didTapCancel {
|
|
[TTPopup dismiss];
|
|
}
|
|
|
|
- (void)didTapBuy {
|
|
if (self.buyWith) {
|
|
self.buyWith(self.model);
|
|
} else if (self.rebuyWith) {
|
|
self.rebuyWith(self.myDressingModel);
|
|
}
|
|
}
|
|
|
|
- (void)didTapGive {
|
|
if (self.giveWith) {
|
|
self.giveWith(self.model);
|
|
}
|
|
}
|
|
|
|
#pragma mark -
|
|
- (UIImageView *)backgroundImageView {
|
|
UIImageView *bgImageView = [[UIImageView alloc] initWithImage:kImage(@"mall_item_preview_bg")];
|
|
bgImageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
return bgImageView;
|
|
}
|
|
|
|
- (UIView *)itemImageBGView {
|
|
if (!_itemImageBGView) {
|
|
_itemImageBGView = [[UIView alloc] init];
|
|
}
|
|
return _itemImageBGView;
|
|
}
|
|
|
|
- (NetImageView *)itemImageView {
|
|
if (!_itemImageView) {
|
|
_itemImageView = [[NetImageView alloc] init];
|
|
_itemImageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
}
|
|
return _itemImageView;
|
|
}
|
|
|
|
- (UILabel *)nameLabel {
|
|
if (!_nameLabel) {
|
|
_nameLabel = [UILabel labelInitWithText:@"" font:kFontMedium(14) textColor:UIColorFromRGB(0xd9e7f7)];
|
|
_nameLabel.textAlignment = NSTextAlignmentCenter;
|
|
}
|
|
return _nameLabel;
|
|
}
|
|
|
|
- (UILabel *)pricePerDayLabel {
|
|
if (!_pricePerDayLabel) {
|
|
_pricePerDayLabel = [UILabel labelInitWithText:@""
|
|
font:kFontRegular(14)
|
|
textColor:UIColorRGBAlpha(0xD9E7F7, 0.8)];
|
|
_pricePerDayLabel.textAlignment = NSTextAlignmentCenter;
|
|
}
|
|
return _pricePerDayLabel;
|
|
}
|
|
|
|
- (UIImageView *)line {
|
|
UIImageView *line = [[UIImageView alloc] initWithImage:kImage(@"mall_item_preview_line")];
|
|
line.contentMode = UIViewContentModeScaleAspectFill;
|
|
return line;
|
|
}
|
|
|
|
- (UIButton *)cancelButton {
|
|
if (!_cancelButton) {
|
|
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[b setBackgroundColor:[UIColor colorWithWhite:0 alpha:0.3]];
|
|
[b setAttributedTitle:[[NSAttributedString alloc] initWithString:YMLocalizedString(@"XPShareView7")
|
|
attributes:@{NSFontAttributeName: kFontMedium(14),
|
|
NSForegroundColorAttributeName: [UIColor whiteColor]}]
|
|
forState:UIControlStateNormal];
|
|
[b addTarget:self action:@selector(didTapCancel) forControlEvents:UIControlEventTouchUpInside];
|
|
[b setCornerRadius:16];
|
|
_cancelButton = b;
|
|
}
|
|
|
|
return _cancelButton;
|
|
}
|
|
|
|
- (UIButton *)buyButton {
|
|
if (!_buyButton) {
|
|
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[b addGradientBackgroundWithColors:@[UIColorFromRGB(0xFFE3B2), UIColorFromRGB(0xE9A71D)]
|
|
startPoint:CGPointMake(0.0, 0.5)
|
|
endPoint:CGPointMake(1.0, 0.5)
|
|
cornerRadius:16];
|
|
[b setAttributedTitle:[[NSAttributedString alloc] initWithString:YMLocalizedString(@"XPDressUpShopCardTableViewCell2")
|
|
attributes:@{NSFontAttributeName: kFontMedium(14),
|
|
NSForegroundColorAttributeName: UIColorFromRGB(0x51281b)}]
|
|
forState:UIControlStateNormal];
|
|
[b addTarget:self action:@selector(didTapBuy) forControlEvents:UIControlEventTouchUpInside];
|
|
[b setCornerRadius:16];
|
|
b.hidden = YES;
|
|
_buyButton = b;
|
|
}
|
|
|
|
return _buyButton;
|
|
}
|
|
|
|
- (UIButton *)giveButton {
|
|
if (!_giveButton) {
|
|
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[b addGradientBackgroundWithColors:@[UIColorFromRGB(0xB2FCFF), UIColorFromRGB(0x4DA2EA)]
|
|
startPoint:CGPointMake(0.0, 0.5)
|
|
endPoint:CGPointMake(1.0, 0.5)
|
|
cornerRadius:16];
|
|
[b setAttributedTitle:[[NSAttributedString alloc] initWithString:YMLocalizedString(@"1.0.30_text_6")
|
|
attributes:@{NSFontAttributeName: kFontMedium(14),
|
|
NSForegroundColorAttributeName: UIColorFromRGB(0x172055)}]
|
|
forState:UIControlStateNormal];
|
|
[b addTarget:self action:@selector(didTapGive) forControlEvents:UIControlEventTouchUpInside];
|
|
[b setCornerRadius:16];
|
|
b.hidden = YES;
|
|
_giveButton = b;
|
|
}
|
|
|
|
return _giveButton;
|
|
}
|
|
|
|
- (VAPView *)mp4View {
|
|
if (!_mp4View) {
|
|
_mp4View = [[VAPView alloc] init];
|
|
_mp4View.contentMode = UIViewContentModeScaleAspectFit;
|
|
}
|
|
return _mp4View;
|
|
}
|
|
|
|
- (SVGAImageView *)svgaView {
|
|
if (!_svgaView) {
|
|
_svgaView = [[SVGAImageView alloc] init];
|
|
_svgaView.contentMode = UIViewContentModeScaleAspectFit;
|
|
}
|
|
return _svgaView;
|
|
}
|
|
|
|
@end
|