1.0.19 feat:个性化房间背景 API / 新礼物飘屏 UI

This commit is contained in:
eggmanQQQ
2024-11-01 20:49:31 +08:00
parent ec70554f9d
commit faacf7b22d
23 changed files with 504 additions and 34 deletions

View File

@@ -0,0 +1,189 @@
//
// RoomHighValueGiftBanner.m
// YuMi
//
// Created by P on 2024/11/1.
//
#import "RoomHighValueGiftBannerAnimation.h"
#import "SVGA.h"
@interface RoomHighValueGiftBannerAnimation ()
///
@property (nonatomic,strong) UIImageView *backImageView;
@property (nonatomic, strong) SVGAImageView *svgaImageView;
///
@property(nonatomic,strong) NetImageView *senderAvatarView;
///who send who
@property(nonatomic,strong) MarqueeLabel *senderScrollLabel;
///
@property(nonatomic,strong) MarqueeLabel *roomNameScrollLabel;
///
@property (nonatomic,strong) NetImageView *giftImageView;
///
@property (nonatomic,strong) UILabel *giftContentLabel;
///
@property(nonatomic,strong) UIButton *goButton;
@property (nonatomic, copy) void(^animationComplete)(void);
@end
@implementation RoomHighValueGiftBannerAnimation
+ (void)display:(UIView *)superView
with:(id)attachment
tapToRoom:(BOOL)handleTapToRoom
complete:(void(^)(void))complete {
NSInteger height = kGetScaleWidth(110);
NSInteger y = kStatusBarHeight;
RoomHighValueGiftBannerAnimation *banner = [[RoomHighValueGiftBannerAnimation alloc] initWithFrame:CGRectMake(KScreenWidth, y, KScreenWidth, height)];
banner.animationComplete = complete;
[superView addSubview:banner];
@kWeakify(banner);
[UIView animateWithDuration:0.25 animations:^{
banner.frame = CGRectMake(0, y, KScreenWidth, height);
} completion:^(BOOL finished) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
banner.frame = CGRectMake(-KScreenWidth, y, KScreenWidth, height);
} completion:^(BOOL finished) {
@kStrongify(banner);
[banner removeFromSuperview];
}];
});
}];
}
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self setupUI];
@kWeakify(self);
SVGAParser *parser = [[SVGAParser alloc] init];
[parser parseWithNamed:@"gift_VIP_1" inBundle:[NSBundle mainBundle] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
@kStrongify(self);
self.svgaImageView.videoItem = videoItem;
[self.svgaImageView startAnimation];
} failureBlock:^(NSError * _Nonnull error) {
// TODO:
}];
}
return self;
}
- (void)setupUI {
[self addSubview:self.backImageView];
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
[self addSubview:self.svgaImageView];
[self.svgaImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
[self addSubview:self.senderAvatarView];
[self.senderAvatarView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self);
make.leading.mas_equalTo(kGetScaleWidth(38));
make.size.mas_equalTo(CGSizeMake(36, 36));
}];
[self addSubview:self.giftImageView];
[self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self);
make.trailing.mas_equalTo(kGetScaleWidth(-106));
make.size.mas_equalTo(CGSizeMake(46, 46));
}];
}
#pragma mark -
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
}
return _backImageView;
}
- (SVGAImageView *)svgaImageView {
if (!_svgaImageView) {
_svgaImageView = [[SVGAImageView alloc] init];
}
return _svgaImageView;
}
- (NetImageView *)senderAvatarView {
if (!_senderAvatarView) {
NetImageConfig * config = [[NetImageConfig alloc] init];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
config.imageType = ImageTypeUserIcon;
_senderAvatarView = [[NetImageView alloc] initWithConfig:config];
_senderAvatarView.layer.masksToBounds = YES;
_senderAvatarView.layer.cornerRadius = 18;
_senderAvatarView.contentMode = UIViewContentModeScaleAspectFill;
}
return _senderAvatarView;
}
- (MarqueeLabel *)senderScrollLabel{
if(!_senderScrollLabel){
_senderScrollLabel = [[MarqueeLabel alloc] init];
_senderScrollLabel.scrollDuration = 6.0;
_senderScrollLabel.fadeLength = 8.0f;
_senderScrollLabel.textAlignment = NSTextAlignmentCenter;
}
return _senderScrollLabel;
}
- (MarqueeLabel *)roomNameScrollLabel{
if(!_roomNameScrollLabel){
_roomNameScrollLabel = [[MarqueeLabel alloc] init];
_roomNameScrollLabel.scrollDuration = 6.0;
_roomNameScrollLabel.fadeLength = 8.0f;
_roomNameScrollLabel.textAlignment = NSTextAlignmentCenter;
}
return _roomNameScrollLabel;
}
- (NetImageView *)giftImageView {
if (!_giftImageView) {
NetImageConfig * config = [[NetImageConfig alloc] init];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
config.imageType = ImageTypeUserIcon;
_giftImageView = [[NetImageView alloc] initWithConfig:config];
_giftImageView.layer.masksToBounds = YES;
_giftImageView.layer.cornerRadius = 4;
_giftImageView.contentMode = UIViewContentModeScaleAspectFill;
}
return _giftImageView;
}
- (UILabel *)giftContentLabel {
if (!_giftContentLabel) {
_giftContentLabel = [[UILabel alloc] init];
_giftContentLabel.textColor = UIColorFromRGB(0xFFE468);
_giftContentLabel.font = kFontHeavy(16);
}
return _giftContentLabel;
}
- (UIButton *)goButton{
if(!_goButton){
_goButton = [UIButton new];
[_goButton setTitle:YMLocalizedString(@"XPAcrossRoomPKPanelView3") forState:UIControlStateNormal];
_goButton.titleLabel.font = kFontRegular(10);
_goButton.layer.cornerRadius = kGetScaleWidth(20)/2;
_goButton.layer.borderWidth = 1;
_goButton.layer.masksToBounds = YES;
}
return _goButton;
}
@end