fix
This commit is contained in:
@@ -15,18 +15,64 @@
|
||||
#import "IQKeyboardManager.h"
|
||||
#import <SocketIO/SocketIO-Swift.h>
|
||||
#import "NSString+Unicode.h"
|
||||
#import "GIGAMBHUDHelper.h"
|
||||
#import "LXCustomSwith.h"
|
||||
|
||||
//弹幕控制器
|
||||
@interface GiGaFlingCommitVC ()
|
||||
@property (nonatomic,strong) GiGaFlyingCommitInputView *commitInputView;
|
||||
@property (nonatomic,strong) SocketIOClient *client;
|
||||
@property (nonatomic,strong) SocketManager *manager;
|
||||
|
||||
@property (nonatomic,strong) LXCustomSwith *danmuSwitch;
|
||||
|
||||
@end
|
||||
|
||||
@implementation GiGaFlingCommitVC
|
||||
|
||||
- (LXCustomSwith *)danmuSwitch{
|
||||
if (!_danmuSwitch) {
|
||||
_danmuSwitch = [[LXCustomSwith alloc] initWithFrame:CGRectMake(KMainW - 50 - 25 , 64 + PhoneX_TopMargin +10, 50, 18)];
|
||||
|
||||
[_danmuSwitch setOffthumTitle:@"弹幕"];
|
||||
[_danmuSwitch setOnthumTitle:@"弹幕"];
|
||||
[_danmuSwitch setOnTintColor:GIGARGB(91, 0, 2, 1)];
|
||||
[_danmuSwitch setTintColor:GIGARGB(91, 0, 2, 1)];
|
||||
[_danmuSwitch setThumbTintColor:GIGARGB(203, 42, 50, 1)];
|
||||
_danmuSwitch.on = YES;
|
||||
_danmuSwitch.thumbLabel.font = GIGA_TEXTFONTMEDIUM(10);
|
||||
_danmuSwitch.thumbLabel.textColor = [UIColor whiteColor];
|
||||
[_danmuSwitch addTarget:self action:@selector(mycuntomSwitchAction:) forControlEvents:UIControlEventValueChanged];
|
||||
}
|
||||
|
||||
return _danmuSwitch;
|
||||
}
|
||||
|
||||
- (GiGaFlyingCommitInputView *)commitInputView{
|
||||
|
||||
if (!_commitInputView) {
|
||||
_commitInputView = [[GiGaFlyingCommitInputView alloc] initWithFrame:self.view.bounds];
|
||||
[_commitInputView setPalceholderText:@"请输入弹幕"];
|
||||
}
|
||||
return _commitInputView;
|
||||
}
|
||||
|
||||
//弹幕按钮
|
||||
|
||||
-(void)mycuntomSwitchAction:(id)sender{
|
||||
|
||||
LXCustomSwith *nkswitch = (LXCustomSwith *)sender;
|
||||
if (nkswitch.isOn)
|
||||
NSLog(@"switchPressed ON");
|
||||
else
|
||||
[self.manager disconnectSocket:self.client];
|
||||
[self.manager disconnect];
|
||||
[self.client disconnect];
|
||||
self.client = nil;
|
||||
self.manager = nil;
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
NSLog(@"switchPressed OFF");
|
||||
}
|
||||
|
||||
-(void)viewWillAppear:(BOOL)animated{
|
||||
[super viewWillAppear:animated];
|
||||
NC_ADD_TARGET_NAME_OBJECT(self, @selector(maskTimeEnd), kUserNoti_MASKEND, nil);
|
||||
@@ -46,9 +92,13 @@
|
||||
[super viewDidLoad];
|
||||
|
||||
// Do any additional setup after loading the view.
|
||||
[self.view addSubview: self.commitInputView];
|
||||
weakify(self);
|
||||
|
||||
[self.view addSubview: self.commitInputView];
|
||||
[self.view addSubview:self.danmuSwitch];
|
||||
[self.view bringSubviewToFront:self.danmuSwitch];
|
||||
|
||||
|
||||
weakify(self);
|
||||
self.commitInputView.SendCommentHandler = ^(NSString *content) {
|
||||
GILog(@"发送->:%@",content);
|
||||
NSArray *arr = @[@{
|
||||
@@ -62,7 +112,6 @@
|
||||
};
|
||||
|
||||
//开启弹幕
|
||||
|
||||
[[LXDanMuManager shareInstance] createDanmuWithTrackSpeedArray:@[@1.00,@1.00,@3.00,@4.00] centerY:KMainH / 4 trackWidth:KMainW showInView:self.view];
|
||||
[[LXDanMuManager shareInstance] start];
|
||||
//socket
|
||||
@@ -73,26 +122,27 @@
|
||||
-(void)connetction{
|
||||
|
||||
NSURL* url = [[NSURL alloc] initWithString:@"http://wsyts.s1.natapp.cc"];
|
||||
// NSDictionary* headers = @{@"EncodeUTF8":@YES};
|
||||
SocketManager *manager = [[SocketManager alloc] initWithSocketURL:url config:@{@"log": @NO, @"forcePolling": @YES,@"connectParams":@{@"token":@""},@"doubleEncodeUTF8":@YES}];
|
||||
|
||||
SocketManager *manager = [[SocketManager alloc] initWithSocketURL:url config:@{@"log": @NO, @"forcePolling": @YES,@"connectParams":@{@"token":@""}}];
|
||||
|
||||
_manager = manager;
|
||||
_client = manager.defaultSocket;
|
||||
|
||||
[self.manager connect];
|
||||
|
||||
weakify(self);
|
||||
[self.client on:@"connect" callback:^(NSArray* data, SocketAckEmitter* ack) {
|
||||
GIGA_WIndowTost(@"客户端上线");
|
||||
NSLog(@"*************\n\niOS客户端上线\n\n*************");
|
||||
}];
|
||||
|
||||
[self.client on:@"connectedSocket" callback:^(NSArray * _Nonnull event, SocketAckEmitter * _Nonnull ack) {
|
||||
[GIGAMBHUDHelper messageAddto:self.view title:@"弹幕链接成功"];
|
||||
NSLog(@"connectedSocket:%@",event);
|
||||
|
||||
}];
|
||||
|
||||
[self.client on:@"onTalk" callback:^(NSArray * _Nonnull envent, SocketAckEmitter * _Nonnull ack) {
|
||||
[self.client on:@"onTalk" callback:^(NSArray * _Nonnull data, SocketAckEmitter * _Nonnull ack) {
|
||||
|
||||
NSString *json =envent[0];
|
||||
NSString *json =data[0];
|
||||
NSLog(@"callback json***:%@",json);
|
||||
NSDictionary *dic = [GiGaHelper dictionaryWithJsonString:json];
|
||||
|
||||
@@ -105,11 +155,16 @@
|
||||
}
|
||||
}];
|
||||
|
||||
|
||||
[self.client on:@"disconnect" callback:^(NSArray * _Nonnull event, SocketAckEmitter * _Nonnull ack) {
|
||||
|
||||
GIGA_WIndowTost(@"客户端下线");
|
||||
NSLog(@"*************\n\niOS客户端下线\n\n*************%@",event?event[0]:@"");
|
||||
}];
|
||||
|
||||
[self.client on:@"error" callback:^(NSArray * _Nonnull event, SocketAckEmitter * _Nonnull ack) {
|
||||
|
||||
[GIGAMBHUDHelper messageAddto:self.view title:@"连接弹幕"];
|
||||
// NSString *htmlString =event[0];
|
||||
// htmlString = [self htmlEntityDecode:htmlString];
|
||||
//
|
||||
@@ -119,17 +174,8 @@
|
||||
//
|
||||
// NSLog(@"*************\n\n%@\n\n*************",event?event[0]:@"");
|
||||
GILog(@"请求超时");
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
- (GiGaFlyingCommitInputView *)commitInputView{
|
||||
|
||||
if (!_commitInputView) {
|
||||
_commitInputView = [[GiGaFlyingCommitInputView alloc] initWithFrame:self.view.bounds];
|
||||
[_commitInputView setPalceholderText:@"请输入弹幕"];
|
||||
}
|
||||
return _commitInputView;
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
@@ -156,13 +202,5 @@
|
||||
NSLog(@"dealloc");
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
|
||||
[self.manager disconnectSocket:self.client];
|
||||
[self.manager disconnect];
|
||||
[self.client disconnect];
|
||||
self.client = nil;
|
||||
self.manager = nil;
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
|
||||
if (!_cicleProgressView) {
|
||||
|
||||
_cicleProgressView = [[MaskTimeCircularProgressView alloc] initWithFrame:CGRectMake(100, 500, 136, 136) backColor:GIGARGB(22, 22, 22, 1) progressColor:[UIColor blueColor] lineWidth:10 timeinterval:10];
|
||||
_cicleProgressView = [[MaskTimeCircularProgressView alloc] initWithFrame:CGRectMake(100, 500, 136, 136) backColor:GIGARGB(88, 0, 2, 1) progressColor:[UIColor blueColor] lineWidth:10 timeinterval:10];
|
||||
_cicleProgressView.delegate = self;
|
||||
_cicleProgressView.hidden = YES;
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
return _waringView;
|
||||
}
|
||||
|
||||
//弹幕
|
||||
#pragma mark 弹幕
|
||||
-(void)createInputView{
|
||||
|
||||
GiGaFlingCommitVC* GiGaFlingVC = [[GiGaFlingCommitVC alloc] init];
|
||||
@@ -150,8 +150,10 @@
|
||||
#pragma mark - 生命周期
|
||||
-(void)viewWillAppear:(BOOL)animated{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
}
|
||||
|
||||
|
||||
-(void)viewDidAppear:(BOOL)animated{
|
||||
[super viewDidAppear:animated];
|
||||
if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
|
||||
@@ -174,7 +176,7 @@
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
|
||||
self.automaticallyAdjustsScrollViewInsets = NO;
|
||||
[self setUpNav];
|
||||
[self initUI];
|
||||
[self addNotify];
|
||||
@@ -207,7 +209,7 @@
|
||||
[self.view layoutIfNeeded];
|
||||
[UIView animateWithDuration:1.0 animations:^{
|
||||
[self.maskImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.attachPoint.y - 87);
|
||||
make.top.mas_equalTo(self.attachPoint.y - 87 + 4);
|
||||
}];
|
||||
[self.faceView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.attachPoint.y -124);
|
||||
@@ -290,6 +292,7 @@
|
||||
make.size.mas_equalTo(CGSizeMake(117, 25));
|
||||
make.centerX.mas_equalTo(self.view.mas_centerX);
|
||||
}];
|
||||
|
||||
//startTest
|
||||
[self.startTestButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.view.mas_top).offset(486);
|
||||
@@ -297,25 +300,6 @@
|
||||
make.centerX.mas_equalTo(self.view.mas_centerX);
|
||||
}];
|
||||
|
||||
|
||||
|
||||
// UIButton *testBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
// [testBtn setTitle:@"测试肤质" forState:UIControlStateNormal];
|
||||
// [testBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
||||
// testBtn.backgroundColor = [UIColor blueColor];
|
||||
// [testBtn addTarget:self action:@selector(testBtnAcion:) forControlEvents:UIControlEventTouchUpInside];
|
||||
// testBtn.layer.masksToBounds = YES;
|
||||
// testBtn.layer.cornerRadius = 4;
|
||||
// [self.view addSubview:testBtn];
|
||||
//
|
||||
// [testBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.centerX.mas_equalTo(self.view.mas_centerX);
|
||||
// make.width.mas_equalTo(150);
|
||||
// make.height.mas_equalTo(40);
|
||||
// make.bottom.mas_equalTo(self.view.mas_bottom).offset(-130);
|
||||
// }];
|
||||
|
||||
|
||||
[self.view layoutIfNeeded];
|
||||
CGFloat Y = CGRectGetMaxY(self.faceView.frame) + (CGRectGetMaxY(self.maskImageView.frame) - CGRectGetMaxY(self.faceView.frame)) / 2;
|
||||
CGFloat X = CGRectGetMidX(self.view.frame);
|
||||
@@ -374,11 +358,11 @@
|
||||
MPMediaItemArtwork *arwork = [[MPMediaItemArtwork alloc] initWithImage:[UIImage imageNamed:@"MaskTime.png"]];
|
||||
NSDictionary *dic = @{
|
||||
MPMediaItemPropertyTitle:@"面膜时间",
|
||||
MPMediaItemPropertyAlbumArtist:@"专辑专辑专辑专辑",
|
||||
MPMediaItemPropertyArtist:@"lianxiang",
|
||||
MPMediaItemPropertyAlbumTitle:@"hahah",
|
||||
MPMediaItemPropertyAlbumArtist:@"面膜时间",
|
||||
MPMediaItemPropertyArtist:@"敷膜中",
|
||||
MPMediaItemPropertyAlbumTitle:@"敷膜中",
|
||||
MPMediaItemPropertyGenre:@"???",
|
||||
MPMediaItemPropertyLyrics:@"歌词",
|
||||
MPMediaItemPropertyLyrics:@"面膜",
|
||||
MPMediaItemPropertyPodcastTitle:@"PodcastTitle",
|
||||
MPMediaItemPropertyArtwork:arwork
|
||||
};
|
||||
@@ -424,8 +408,8 @@
|
||||
|
||||
#pragma mark 开始测试
|
||||
-(void)testBtnAcion:(UIButton *)btn{
|
||||
[self createInputView];
|
||||
return;
|
||||
// [self createInputView];
|
||||
// return;
|
||||
|
||||
BOOL isUserLogin = [GiGaUserDefault isUserLogin];
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
//
|
||||
|
||||
#import "GiGaFlyingCommitInputView.h"
|
||||
static const CGFloat kInputViewH = 44.f;
|
||||
|
||||
@interface GiGaFlyingCommitInputView()<UITextFieldDelegate>
|
||||
@property(nonatomic,strong) UIView *commitInputView;
|
||||
@property(nonatomic,strong) UITextField * inputTextField;
|
||||
@@ -19,7 +21,7 @@
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
|
||||
self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
|
||||
//self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dismissSelfViewTap)];
|
||||
[self addGestureRecognizer:tap];
|
||||
|
||||
@@ -32,28 +34,41 @@
|
||||
|
||||
-(void)creatInputView{
|
||||
|
||||
UIView *commitView =[[UIView alloc] initWithFrame:CGRectMake(0, self.bounds.size.height - 60, self.bounds.size.width, 60)];
|
||||
// commitView.frame = CGRectMake(0, self.frame.size.height-commitView.frame.size.height, self.frame.size.width, commitView.frame.size.height);
|
||||
UIView *commitView =[[UIView alloc] initWithFrame:CGRectMake(0, self.bounds.size.height - kInputViewH, self.bounds.size.width, kInputViewH)];
|
||||
|
||||
self.commitInputView = commitView;
|
||||
self.commitInputView.backgroundColor = [UIColor redColor];
|
||||
self.commitInputView.backgroundColor = GIGARGB(241, 241, 241, 1);
|
||||
[self addSubview:self.commitInputView];
|
||||
|
||||
UIButton *sendBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
CGFloat topMargin = 5;
|
||||
|
||||
CGFloat leftMargin = 10;
|
||||
sendBtn.frame = CGRectMake(self.frame.size.width - leftMargin - 60,topMargin,60,40);
|
||||
sendBtn.frame = CGRectMake(self.frame.size.width - leftMargin - 60,commitView.frame.size.height /2 - 20,60,40);
|
||||
[sendBtn addTarget:self action:@selector(sendBtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[sendBtn setTitle:@"发送" forState:UIControlStateNormal];
|
||||
//[sendBtn setTitle:@"发送" forState:UIControlStateNormal];
|
||||
[sendBtn setImage:[UIImage imageNamed:@"ic_send"] forState:UIControlStateNormal];
|
||||
[sendBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
||||
sendBtn.backgroundColor = [UIColor purpleColor];
|
||||
sendBtn.layer.masksToBounds = YES;
|
||||
sendBtn.layer.cornerRadius = 4;
|
||||
[commitView addSubview:sendBtn];
|
||||
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 5,self.frame.size.width - sendBtn.frame.size.width - 10*2 - 5, 30)];
|
||||
textField.backgroundColor = [UIColor lightGrayColor];
|
||||
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(44, commitView.frame.size.height /2 -15,self.frame.size.width - sendBtn.frame.size.width - 44 - 10 - leftMargin, 30)];
|
||||
textField.backgroundColor = [UIColor whiteColor];
|
||||
textField.placeholder = @"请输入弹幕";
|
||||
textField.layer.shadowColor = GIGARGB(190, 190, 190, 1).CGColor;
|
||||
textField.layer.shadowOffset = CGSizeMake(5, 5);
|
||||
textField.layer.shadowOpacity = 0.5;
|
||||
textField.layer.shadowRadius = 4;
|
||||
|
||||
textField.layer.masksToBounds = YES;
|
||||
textField.layer.cornerRadius = 2;
|
||||
textField.layer.borderWidth = 1;
|
||||
textField.layer.borderColor = [UIColor whiteColor].CGColor;
|
||||
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
|
||||
textField.delegate = self;
|
||||
textField.returnKeyType = UIReturnKeySend;
|
||||
UIView *textLeftview = [[UIView alloc] initWithFrame:CGRectMake(0, 0,10, textField.frame.size.height)];
|
||||
textField.leftView = textLeftview;
|
||||
textField.leftViewMode = UITextFieldViewModeAlways;
|
||||
[commitView addSubview:textField];
|
||||
self.inputTextField = textField;
|
||||
|
||||
@@ -155,7 +170,7 @@
|
||||
|
||||
- (void) keyboardWillHide:(NSNotification *)note
|
||||
{
|
||||
self.commitInputView.frame = CGRectMake(0, self.bounds.size.height - 60, self.bounds.size.width, 60);
|
||||
self.commitInputView.frame = CGRectMake(0, self.bounds.size.height - kInputViewH, self.bounds.size.width, kInputViewH);
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
|
||||
@@ -78,7 +78,6 @@
|
||||
_countLabel.outLineColor = [UIColor whiteColor];
|
||||
_countLabel.blurColor = [UIColor whiteColor];
|
||||
_countLabel.oinsideColor = [UIColor whiteColor];
|
||||
|
||||
_countLabel.text = @"00:00";
|
||||
_countLabel.font = [UIFont fontWithName:GIGA_FONTBOLD size:22];
|
||||
}
|
||||
@@ -86,6 +85,7 @@
|
||||
}
|
||||
|
||||
- (void)setLineWidth:(CGFloat)lineWidth{
|
||||
|
||||
CAShapeLayer *backgroundLayer = [self createRingLayerWithCenter:CGPointMake(CGRectGetWidth(self.frame) / 2, CGRectGetHeight(self.frame) / 2) radius:CGRectGetWidth(self.bounds) / 2 - lineWidth / 2 lineWidth:lineWidth color:self.backColor];
|
||||
_lineWidth = lineWidth;
|
||||
[self.layer addSublayer:backgroundLayer];
|
||||
@@ -102,7 +102,7 @@
|
||||
|
||||
CAGradientLayer *gradientLayer1 = [CAGradientLayer layer];
|
||||
gradientLayer1.frame = CGRectMake(0, 0, width, height);
|
||||
gradientLayer1.colors = @[(__bridge id) [UIColor colorWithRed:151/255.0 green:253/255.0 blue:255/255.0 alpha:1/1.0].CGColor,(__bridge id)[UIColor colorWithRed:165/255.0 green:81/255.0 blue:216/255.0 alpha:1/1.0].CGColor];
|
||||
gradientLayer1.colors = @[(__bridge id) [UIColor colorWithRed:255/255.0 green:107/255.0 blue:107/255.0 alpha:1/1.0].CGColor,(__bridge id)[UIColor colorWithRed:187/255.0 green:79/255.0 blue:253/255.0 alpha:1/1.0].CGColor];
|
||||
|
||||
//纵向变化
|
||||
gradientLayer1.startPoint = CGPointMake(0.5, 0);
|
||||
|
||||
Reference in New Issue
Block a user