add connection status & bump build 4

master
esterTion 2020-03-03 20:11:57 +08:00
parent 3a22523ed1
commit dc5e07f3c4
4 changed files with 43 additions and 3 deletions

View File

@ -334,7 +334,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_TEAM = K9CP5766XY;
INFOPLIST_FILE = "Brokenithm-iOS/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
@ -357,7 +357,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_TEAM = K9CP5766XY;
INFOPLIST_FILE = "Brokenithm-iOS/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;

View File

@ -38,6 +38,7 @@
NSData *initResp = [initResponse dataUsingEncoding:NSASCIIStringEncoding];
[newSocket writeData:initResp withTimeout:-1 tag:0];
[newSocket readDataToLength:1 withTimeout:5 tag:0];
[self.parentVc connected];
}
- (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag {}
- (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag {
@ -72,6 +73,7 @@
{
[connectedSockets removeObject:sock];
}
[self.parentVc disconnected];
}
}

View File

@ -23,10 +23,13 @@
}
@property UIView *airIOView;
@property UIView *sliderIOView;
@property UILabel *connectStatusView;
@property CAGradientLayer *ledBackground;
-(void)updateLed:(NSData*)rgbData;
-(void)updateTouches:(UIEvent *)event;
-(void)connected;
-(void)disconnected;
@end

View File

@ -8,7 +8,9 @@
#import "ViewController.h"
@interface ViewController ()
@interface ViewController () {
BOOL pendingHideStatus;
}
@end
@ -16,6 +18,7 @@
- (void)viewDidLoad {
[super viewDidLoad];
pendingHideStatus = NO;
// network permission
/*
@ -41,6 +44,17 @@
[self.view addSubview:self.airIOView];
[self.view addSubview:self.sliderIOView];
self.connectStatusView = [[UILabel alloc] initWithFrame:CGRectMake(screenWidth - 200.0, screenHeight * 0.1, 200.0, 50.0)];
self.connectStatusView.userInteractionEnabled = false;
self.connectStatusView.text = @"Not connected";
self.connectStatusView.textAlignment = NSTextAlignmentCenter;
self.connectStatusView.textColor = [UIColor whiteColor];
self.connectStatusView.numberOfLines = 1;
self.connectStatusView.backgroundColor = [UIColor blackColor];
self.connectStatusView.layer.borderColor = [UIColor whiteColor].CGColor;
self.connectStatusView.layer.borderWidth = 1.0;
[self.view addSubview:self.connectStatusView];
self.ledBackground = [CAGradientLayer layer];
self.ledBackground.frame = CGRectMake(0, 0, screenWidth, sliderHeight);
[self.sliderIOView.layer addSublayer:self.ledBackground];
@ -164,4 +178,25 @@
[server updateIO:io];
}
-(void)hideStatus {
pendingHideStatus = NO;
[UIView animateWithDuration:0.5 animations:^{
self.connectStatusView.frame = CGRectMake(self->screenWidth, self->screenHeight * 0.1, 200.0, 50.0);
}];
}
-(void)connected {
self.connectStatusView.text = @"Connected";
[self performSelector:@selector(hideStatus) withObject:nil afterDelay:3];
pendingHideStatus = YES;
}
-(void)disconnected {
if (pendingHideStatus) {
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(hideStatus) object:nil];
}
self.connectStatusView.text = @"Not connected";
[UIView animateWithDuration:0.3 animations:^{
self.connectStatusView.frame = CGRectMake(self->screenWidth - 200.0, self->screenHeight * 0.1, 200.0, 50.0);
}];
}
@end