113 lines
3.6 KiB
Mathematica
113 lines
3.6 KiB
Mathematica
|
|
//
|
||
|
|
// YYJYPendantGiftView.m
|
||
|
|
// YaYin
|
||
|
|
//
|
||
|
|
// Created by bj_szd on 2023/7/28.
|
||
|
|
// Copyright © 2023 YaYin. All rights reserved.
|
||
|
|
//
|
||
|
|
|
||
|
|
#import "YYJYPendantGiftView.h"
|
||
|
|
#import "QGVAPWrapView.h"
|
||
|
|
#import "QGVAPWrapView+download.h"
|
||
|
|
|
||
|
|
@interface YYJYPendantGiftView () <VAPWrapViewDelegate, HWDMP4PlayDelegate>
|
||
|
|
|
||
|
|
@property (nonatomic, strong) QGVAPWrapView *wrapView;
|
||
|
|
|
||
|
|
@property (nonatomic, assign)CGPoint originalPoint;
|
||
|
|
|
||
|
|
@end
|
||
|
|
|
||
|
|
@implementation YYJYPendantGiftView
|
||
|
|
|
||
|
|
- (void)awakeFromNib {
|
||
|
|
[super awakeFromNib];
|
||
|
|
|
||
|
|
WEAK_SELF
|
||
|
|
[self.avatarImgV_1 dg_Tapped:^{
|
||
|
|
[UIViewController goUserMainpageWith:[weakSelf.dataDict[@"user_info"] safeStringForKey:@"uid"] withRid:@""];
|
||
|
|
}];
|
||
|
|
[self.avatarImgV_2 dg_Tapped:^{
|
||
|
|
[UIViewController goUserMainpageWith:[weakSelf.dataDict[@"receive_info"] safeStringForKey:@"uid"] withRid:@""];
|
||
|
|
}];
|
||
|
|
|
||
|
|
[self insertSubview:self.wrapView atIndex:0];
|
||
|
|
|
||
|
|
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(onTuodong:)];
|
||
|
|
[self addGestureRecognizer:pan];
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)setDataDict:(NSDictionary *)dataDict {
|
||
|
|
_dataDict = dataDict;
|
||
|
|
|
||
|
|
NSString *head_pic_1 = [dataDict[@"user_info"] safeStringForKey:@"head_pic"];
|
||
|
|
NSString *nick_name_1 = [dataDict[@"user_info"] safeStringForKey:@"nick_name"];
|
||
|
|
NSString *head_pic_2 = [dataDict[@"receive_info"] safeStringForKey:@"head_pic"];
|
||
|
|
NSString *nick_name_2 = [dataDict[@"receive_info"] safeStringForKey:@"nick_name"];
|
||
|
|
|
||
|
|
[self.avatarImgV_1 sd_setImageWithURL:[NSURL URLWithString:head_pic_1] placeholderImage:kDefaultUserIcon];
|
||
|
|
self.nicknameLab_1.text = nick_name_1;
|
||
|
|
|
||
|
|
[self.avatarImgV_2 sd_setImageWithURL:[NSURL URLWithString:head_pic_2] placeholderImage:kDefaultUserIcon];
|
||
|
|
self.nicknameLab_2.text = nick_name_2;
|
||
|
|
|
||
|
|
[self onPlayGiftVap];
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)onPlayGiftVap {
|
||
|
|
NSString *pendant_image = [self.dataDict safeStringForKey:@"pendant_image"];
|
||
|
|
if (pendant_image.length > 0) {
|
||
|
|
self.bgImgV.hidden = YES;
|
||
|
|
self.wrapView.hidden = NO;
|
||
|
|
[self.wrapView playMemoryWithStr:pendant_image Success:^(NSURL * _Nonnull filePath) {
|
||
|
|
NSString *fileStr = [filePath absoluteString];
|
||
|
|
if ([fileStr containsString:@"file://"]) {
|
||
|
|
fileStr = [fileStr substringFromIndex:7];
|
||
|
|
}
|
||
|
|
[self.wrapView playHWDMP4:fileStr repeatCount:-1 delegate:self];
|
||
|
|
} Failure:^(NSError * _Nonnull error) {
|
||
|
|
|
||
|
|
}];
|
||
|
|
}else {
|
||
|
|
self.bgImgV.hidden = NO;
|
||
|
|
self.wrapView.hidden = YES;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
- (IBAction)onClose:(id)sender {
|
||
|
|
[self removeFromSuperview];
|
||
|
|
}
|
||
|
|
|
||
|
|
- (QGVAPWrapView *)wrapView {
|
||
|
|
if (!_wrapView) {
|
||
|
|
_wrapView = [[QGVAPWrapView alloc] initWithFrame:CGRectMake(0, 0, 150, 180)];
|
||
|
|
_wrapView.hwd_Delegate = self;
|
||
|
|
_wrapView.contentMode = QGVAPWrapViewContentModeAspectFit;
|
||
|
|
_wrapView.userInteractionEnabled = NO;
|
||
|
|
// _wrapView.autoDestoryAfterFinish = NO;
|
||
|
|
}
|
||
|
|
return _wrapView;
|
||
|
|
}
|
||
|
|
|
||
|
|
//滑动事件
|
||
|
|
- (void)onTuodong:(UIPanGestureRecognizer *)pan{
|
||
|
|
//获取当前位置
|
||
|
|
CGPoint currentPosition = [pan locationInView:self];
|
||
|
|
if (pan.state == UIGestureRecognizerStateBegan) {
|
||
|
|
_originalPoint = currentPosition;
|
||
|
|
}else if(pan.state == UIGestureRecognizerStateChanged){
|
||
|
|
//偏移量(当前坐标 - 起始坐标 = 偏移量)
|
||
|
|
CGFloat offsetX = currentPosition.x - _originalPoint.x;
|
||
|
|
CGFloat offsetY = currentPosition.y - _originalPoint.y;
|
||
|
|
|
||
|
|
//移动后的按钮中心坐标
|
||
|
|
CGFloat centerX = self.center.x + offsetX;
|
||
|
|
CGFloat centerY = self.center.y + offsetY;
|
||
|
|
self.center = CGPointMake(centerX, centerY);
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@end
|