123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- //
- // YOUPAILZChatRoomWindow.m
- // VQU
- //
- // Created by CY on 2021/11/12.
- // Copyright © 2021 MS. All rights reserved.
- //
- #import "YOUPAILZChatRoomWindow.h"
- #import "LOTAnimationView.h"
- @interface YOUPAILZChatRoomWindow ()
- @property (nonatomic,weak)UIImageView *youpaipcoverImgV;
- @end
- @implementation YOUPAILZChatRoomWindow
- - (instancetype)init{
- if (self = [super init]) {
- [self youpaifinitUI];
- self.hidden = YES;
- }
- return self;
- }
- - (void)youpaifinitUI{
- UIImageView *youpaipcoverImgV = [[UIImageView alloc] init];
- youpaipcoverImgV.layer.cornerRadius = 32.0f;
- youpaipcoverImgV.clipsToBounds = YES;
- youpaipcoverImgV.contentMode = UIViewContentModeScaleAspectFill;
- [self addSubview:youpaipcoverImgV];
- self.youpaipcoverImgV = youpaipcoverImgV;
- [youpaipcoverImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.center.equalTo(self);
- make.size.mas_offset(CGSizeMake(64.0f, 64.0f));
- }];
-
-
- LOTAnimationView *youpaiptalkingAnimationView = [LOTAnimationView animationWithFilePath:[[NSBundle mainBundle] pathForResource:@"ic_chatroom_seat_animation" ofType:@"json"]];
- youpaiptalkingAnimationView.frame = CGRectMake(0.0f, 0.0f, 64.0f * 1.7f, 64.0f * 1.7f);
- youpaiptalkingAnimationView.loopAnimation = YES;
- youpaiptalkingAnimationView.contentMode = UIViewContentModeScaleAspectFill;
- [youpaiptalkingAnimationView play];
- [self addSubview:youpaiptalkingAnimationView];
- [youpaiptalkingAnimationView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.center.equalTo(youpaipcoverImgV);
- make.size.mas_offset(CGSizeMake(64.0f * 1.7f, 64.0f * 1.7f));
- }];
- // RippleAnimationView *youpaiptalkingAnimationView = [[RippleAnimationView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 54.0f, 54.0f) animationType:AnimationTypeWithoutBackground];
- // [self addSubview:youpaiptalkingAnimationView];
- // [youpaiptalkingAnimationView mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.center.equalTo(youpaipcoverImgV);
- // make.size.mas_offset(CGSizeMake(54.0f, 54.0f));
- // }];
-
- UIButton *showBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [showBtn addTarget:self action:@selector(youpaifshowBtnClick) forControlEvents:UIControlEventTouchUpInside];
- [self addSubview:showBtn];
- [showBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.top.left.bottom.offset(0.0f);
- }];
-
- UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [closeBtn setImage:[UIImage imageNamed:@"vqu_images_chatroom_end"] forState:UIControlStateNormal];
- [closeBtn addTarget:self action:@selector(youpaifcloseBtnClick) forControlEvents:UIControlEventTouchUpInside];
- [self addSubview:closeBtn];
- [closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(youpaipcoverImgV.mas_top).offset(0.0f);
- make.right.equalTo(youpaipcoverImgV.mas_right).offset(0.0f);
- make.size.mas_offset(CGSizeMake(25.5f, 36.0f));
- }];
-
-
- UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifhandlePan:)];
- [self addGestureRecognizer:panGestureRecognizer];
- }
- - (void)youpaifhandlePan:(UIPanGestureRecognizer*) recognizer{
- CGPoint translation = [recognizer translationInView:self.superview];
- CGFloat centerX = recognizer.view.center.x+ translation.x;
- CGFloat thecenter = 0;
- recognizer.view.center = CGPointMake(centerX,recognizer.view.center.y+ translation.y);
- [recognizer setTranslation:CGPointZero inView:self.superview];
- if(recognizer.state == UIGestureRecognizerStateEnded || recognizer.state == UIGestureRecognizerStateCancelled) {
- if(centerX > KScreenWidth/2) {
- thecenter = KScreenWidth-self.mj_w/2 - 14.0f;
- }else{
- thecenter = self.mj_w / 2 + 14.0f;
- }
- [UIView animateWithDuration:0.25f animations:^{
- CGFloat y = recognizer.view.center.y;
- if (recognizer.view.center.y < NavBarHeight) {
- y = NavBarHeight + 27.0f + self.mj_w / 2.0f;
- }else if (recognizer.view.center.y > KScreenHeight - TabbarHeight - 27.0f - self.mj_w / 2.0f){
- y = KScreenHeight - TabbarHeight - 27.0f - self.mj_w / 2.0f;
- }
- recognizer.view.center=CGPointMake(thecenter, y + translation.y);
- }];
- }
- }
- - (void)setYoupaipchatroomModel:(YOUPAILZChatRoomModel *)youpaipchatroomModel{
- _youpaipchatroomModel = youpaipchatroomModel;
- [self.youpaipcoverImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:youpaipchatroomModel.youpaipcoverimg]];
- }
- - (void)youpaifcloseBtnClick{
- if (self.youpaipcloseBlock != nil) {
- self.hidden = YES;
- self.youpaipcloseBlock();
- }
- }
- - (void)youpaifshowBtnClick{
- if (self.showChatRoomBlock != nil) {
- self.hidden = YES;
- self.showChatRoomBlock();
- }
- }
- @end
|