2025-04-02 11:04:07 +08:00
|
|
|
|
//
|
2025-04-21 13:52:13 +08:00
|
|
|
|
// BravoGiftWinningFlagView.m
|
2025-04-02 11:04:07 +08:00
|
|
|
|
// YuMi
|
|
|
|
|
//
|
|
|
|
|
// Created by P on 2025/3/25.
|
|
|
|
|
//
|
|
|
|
|
|
2025-04-21 13:52:13 +08:00
|
|
|
|
#import "BravoGiftWinningFlagView.h"
|
2025-04-02 11:04:07 +08:00
|
|
|
|
#import "MoliMoneyLabel.h"
|
|
|
|
|
#import "AttachmentModel.h"
|
|
|
|
|
|
|
|
|
|
//{"data":"{\"uid\":3224,\"receiverUidList\":[3224],\"roomUid\":3184,\"tip\":{\"times\":\"0.70\",\"coins\":\"700.0\",\"level\":1},\"receiverProfit\":\"50.00\",\"roomId\":6076861580}","first":106,"second":1065}
|
|
|
|
|
|
|
|
|
|
|
2025-04-21 13:52:13 +08:00
|
|
|
|
@implementation BravoGiftWinningFlagViewModel
|
2025-04-02 11:04:07 +08:00
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
2025-04-21 13:52:13 +08:00
|
|
|
|
@interface BravoGiftWinningFlagView ()
|
2025-04-02 11:04:07 +08:00
|
|
|
|
|
2025-04-21 13:52:13 +08:00
|
|
|
|
@property (nonatomic, strong) BravoGiftWinningFlagViewModel *model;
|
2025-04-02 11:04:07 +08:00
|
|
|
|
@property (nonatomic, strong) UIImageView *backgroundImageView;
|
|
|
|
|
//@property (nonatomic, strong) MoliMoneyLabel *moneyLabel;
|
|
|
|
|
@property (nonatomic, strong) UILabel *moneyLabel_2;
|
|
|
|
|
@property (nonatomic, strong) UILabel *timesLabel;
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
2025-04-21 13:52:13 +08:00
|
|
|
|
@implementation BravoGiftWinningFlagView
|
2025-04-02 11:04:07 +08:00
|
|
|
|
|
2025-04-21 13:52:13 +08:00
|
|
|
|
+ (BravoGiftWinningFlagViewModel *)display:(UIView *)superView with:(AttachmentModel *)attachment roomID:(NSInteger)roomID uID:(NSString *)UID {
|
|
|
|
|
BravoGiftWinningFlagViewModel *model = [BravoGiftWinningFlagViewModel modelWithJSON:attachment.data];
|
2025-04-02 11:04:07 +08:00
|
|
|
|
if (model.roomId != roomID || model.uid != UID.integerValue || model.tip == nil) {
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-21 13:52:13 +08:00
|
|
|
|
BravoGiftWinningFlagView *flagView = [[BravoGiftWinningFlagView alloc] init];
|
2025-04-02 11:04:07 +08:00
|
|
|
|
flagView.model = model;
|
|
|
|
|
flagView.alpha = 0;
|
|
|
|
|
flagView.frame = CGRectMake(0, 0, kGetScaleWidth(274), kGetScaleWidth(216));
|
|
|
|
|
flagView.center = CGPointMake(superView.center.x, kGetScaleWidth(216) + kGetScaleWidth(216)/2 - 40);
|
|
|
|
|
flagView.transform = CGAffineTransformMakeScale(0.1, 0.1);
|
|
|
|
|
[superView addSubview:flagView];
|
|
|
|
|
|
|
|
|
|
// 使用弹簧动画执行放大动画,alpha从0变为1,带有弹性效果
|
|
|
|
|
[UIView animateWithDuration:0.8
|
|
|
|
|
delay:0
|
|
|
|
|
usingSpringWithDamping:0.3 // 弹性系数,数值越小弹性越强
|
|
|
|
|
initialSpringVelocity:0.5 // 初始速度
|
|
|
|
|
options:UIViewAnimationOptionCurveEaseInOut
|
|
|
|
|
animations:^{
|
|
|
|
|
flagView.alpha = 1.0;
|
|
|
|
|
flagView.transform = CGAffineTransformMakeScale(1.0, 1.0); // 还原为正常大小
|
|
|
|
|
} completion:^(BOOL finished) {
|
|
|
|
|
// 动画完成后,等待2秒再执行反向动画
|
|
|
|
|
[UIView animateWithDuration:0.5
|
|
|
|
|
delay:2.0 // 延迟2秒执行反向动画
|
|
|
|
|
options:UIViewAnimationOptionCurveEaseInOut
|
|
|
|
|
animations:^{
|
|
|
|
|
flagView.alpha = 0.0;
|
|
|
|
|
flagView.transform = CGAffineTransformMakeScale(0.1, 0.1); // 缩小回原始大小
|
|
|
|
|
} completion:^(BOOL finished) {
|
|
|
|
|
// 动画完成后移除 view
|
|
|
|
|
[flagView removeFromSuperview];
|
|
|
|
|
}];
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (instancetype)init
|
|
|
|
|
{
|
|
|
|
|
self = [super init];
|
|
|
|
|
if (self) {
|
|
|
|
|
[self setupUI];
|
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)setupUI {
|
|
|
|
|
[self addSubview:self.backgroundImageView];
|
|
|
|
|
[self.backgroundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.edges.mas_equalTo(self);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self addSubview:self.moneyLabel_2];
|
|
|
|
|
[self.moneyLabel_2 mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.centerX.mas_equalTo(self);
|
|
|
|
|
make.bottom.mas_equalTo(-70);
|
|
|
|
|
make.height.mas_equalTo(24);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
UIStackView *stackView = [[UIStackView alloc] initWithArrangedSubviews:@[
|
|
|
|
|
[self winLabel],
|
|
|
|
|
self.timesLabel
|
|
|
|
|
]];
|
|
|
|
|
stackView.spacing = 4;
|
|
|
|
|
stackView.alignment = UIStackViewAlignmentCenter;
|
|
|
|
|
[self addSubview:stackView];
|
|
|
|
|
[stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.centerX.mas_equalTo(self);
|
|
|
|
|
make.bottom.mas_equalTo(-48);
|
|
|
|
|
}];
|
|
|
|
|
[self.timesLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.height.mas_equalTo(10);
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-21 13:52:13 +08:00
|
|
|
|
- (void)setModel:(BravoGiftWinningFlagViewModel *)model {
|
2025-04-02 11:04:07 +08:00
|
|
|
|
NSNumber *level = [model.tip objectForKey:@"level"];
|
|
|
|
|
NSString *times = [model.tip objectForKey:@"times"];
|
|
|
|
|
NSNumber *coins = [model.tip objectForKey:@"coins"];
|
|
|
|
|
// [self.moneyLabel updateContent:coins.stringValue];
|
|
|
|
|
self.backgroundImageView.image = level.integerValue >= 3 ? kImage(@"brove_tips_high") : kImage(@"brove_tips_low");
|
|
|
|
|
self.timesLabel.text = [NSString stringWithFormat:@"%@ %@", [NSString stringByRemovingRedundantZeros:times], YMLocalizedString(@"Combo_9")];
|
|
|
|
|
|
|
|
|
|
NSTextAttachment *moneyIcon = [[NSTextAttachment alloc] init];
|
|
|
|
|
moneyIcon.image = kImage(@"moli_money_icon");
|
|
|
|
|
NSMutableAttributedString *money = [[NSMutableAttributedString alloc] initWithString:[NSString stringByRemovingRedundantZeros:coins.stringValue] attributes:@{
|
|
|
|
|
NSFontAttributeName: kFontMedium(26),
|
|
|
|
|
NSForegroundColorAttributeName: UIColorFromRGB(0xffe169)
|
|
|
|
|
}];
|
|
|
|
|
[money appendAttributedString:[NSAttributedString attributedStringWithAttachment:moneyIcon]];
|
|
|
|
|
self.moneyLabel_2.attributedText = money.copy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIImageView *)backgroundImageView {
|
|
|
|
|
if (!_backgroundImageView) {
|
|
|
|
|
_backgroundImageView = [[UIImageView alloc] init];//WithImage:kImage(@"brove_tips_high")];
|
|
|
|
|
_backgroundImageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
|
|
|
}
|
|
|
|
|
return _backgroundImageView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//- (MoliMoneyLabel *)moneyLabel {
|
|
|
|
|
// if (!_moneyLabel) {
|
|
|
|
|
// _moneyLabel = [MoliMoneyLabel moneyLabelWithTextColot:UIColorFromRGB(0xFFE169)
|
|
|
|
|
// font:kFontMedium(26)
|
|
|
|
|
// moneyPostion:2
|
|
|
|
|
// moneySize:CGSizeMake(24, 24)];
|
|
|
|
|
// [_moneyLabel removeSpace];
|
|
|
|
|
// [_moneyLabel updateSpacing:0];
|
|
|
|
|
// [_moneyLabel updateLabelAlignment:NSTextAlignmentRight];
|
|
|
|
|
// [_moneyLabel insertSpaceAtLeast];
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// return _moneyLabel;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
- (UILabel *)moneyLabel_2 {
|
|
|
|
|
if (!_moneyLabel_2) {
|
|
|
|
|
_moneyLabel_2 = [[UILabel alloc] init];
|
|
|
|
|
}
|
|
|
|
|
return _moneyLabel_2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UILabel *)winLabel {
|
|
|
|
|
return [UILabel labelInitWithText:YMLocalizedString(@"Combo_4")
|
|
|
|
|
font:kFontRegular(13)
|
|
|
|
|
textColor:[UIColor whiteColor]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UILabel *)timesLabel {
|
|
|
|
|
if (!_timesLabel) {
|
|
|
|
|
_timesLabel = [UILabel labelInitWithText:@""
|
|
|
|
|
font:kFontMedium(13)
|
|
|
|
|
textColor:UIColorFromRGB(0xFFE169)];
|
|
|
|
|
}
|
|
|
|
|
return _timesLabel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|