Update UI theme

* new dark UI
* new app lists
This commit is contained in:
Yuki MIZUNO
2014-12-04 18:41:01 +09:00
parent 79e51defe1
commit 582dda5727
8 changed files with 162 additions and 70 deletions

View File

@@ -29,10 +29,10 @@
UIAlertView* _pairAlert;
UIScrollView* hostScrollView;
UIScrollView* appScrollView;
}
static NSString* deviceName = @"roth";
static NSMutableSet* hostList;
static NSArray* appList;
static StreamConfiguration* streamConfig;
+ (StreamConfiguration*) getStreamConfiguration {
@@ -67,19 +67,16 @@ static StreamConfiguration* streamConfig;
HttpManager* hMan = [[HttpManager alloc] initWithHost:_selectedHost.hostName uniqueId:_uniqueId deviceName:deviceName cert:_cert];
NSData* appListResp = [hMan executeRequestSynchronously:[hMan newAppListRequest]];
NSArray* appList = [HttpManager getAppListFromXML:appListResp];
appList = [HttpManager getAppListFromXML:appListResp];
dispatch_async(dispatch_get_main_queue(), ^{
[self updateApps:appList];
[self updateApps];
});
[AppManager retrieveAppAssets:appList withManager:hMan andCallback:self];
});
}
- (void) receivedAssetForApp:(App*)app {
NSArray* subviews = [appScrollView subviews];
for (UIAppView* appView in subviews) {
[appView updateAppImage];
}
[self.collectionView reloadData];
}
- (void)displayDnsFailedDialog {
@@ -161,12 +158,8 @@ static StreamConfiguration* streamConfig;
{
[super viewDidLoad];
// Change button color
_settingsSidebarButton.tintColor = [UIColor colorWithRed:.2 green:.9 blue:0.f alpha:1.f];
// Set the side bar button action. When it's tapped, it'll show up the sidebar.
_settingsSidebarButton.target = self.revealViewController;
_settingsSidebarButton.action = @selector(revealToggle:);
[_limelightLogoButton addTarget:self.revealViewController action:@selector(revealToggle:) forControlEvents:UIControlEventTouchDown];
// Set the gesture
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
@@ -191,20 +184,21 @@ static StreamConfiguration* streamConfig;
hostScrollView.frame = CGRectMake(0, self.navigationController.navigationBar.frame.origin.y + self.navigationController.navigationBar.frame.size.height, self.view.frame.size.width, self.view.frame.size.height / 2);
[hostScrollView setShowsHorizontalScrollIndicator:NO];
appScrollView = [[UIScrollView alloc] init];
appScrollView.frame = CGRectMake(0, hostScrollView.frame.size.height, self.view.frame.size.width, self.view.frame.size.height / 2);
[appScrollView setShowsHorizontalScrollIndicator:NO];
[self retrieveSavedHosts];
[self updateHosts:[hostList allObjects]];
[self.view addSubview:hostScrollView];
[self.view addSubview:appScrollView];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
// Hide 1px border line
UIImage* fakeImage = [[UIImage alloc] init];
[self.navigationController.navigationBar setShadowImage:fakeImage];
[self.navigationController.navigationBar setBackgroundImage:fakeImage forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
_mDNSManager = [[MDNSManager alloc] initWithCallback:self];
[_mDNSManager searchForHosts];
}
@@ -255,29 +249,36 @@ static StreamConfiguration* streamConfig;
}
}
- (void) updateApps:(NSArray*)apps {
[[appScrollView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
App* fakeApp = [[App alloc] init];
fakeApp.appName = @"No App Name";
UIAppView* noAppImage = [[UIAppView alloc] initWithApp:fakeApp andCallback:nil];
float prevEdge = -1;
UIAppView* appView;
for (App* app in apps) {
appView = [[UIAppView alloc] initWithApp:app andCallback:self];
prevEdge = [self getAppViewX:appView noApp:noAppImage prevEdge:prevEdge];
appView.center = CGPointMake(prevEdge, appScrollView.frame.size.height / 2);
prevEdge = appView.frame.origin.x + appView.frame.size.width;
[appScrollView addSubview:appView];
}
[appScrollView setContentSize:CGSizeMake(prevEdge + noAppImage.frame.size.width, appScrollView.frame.size.height)];
- (void) updateApps {
[hostScrollView removeFromSuperview];
[self.collectionView reloadData];
}
- (float) getAppViewX:(UIAppView*)app noApp:(UIAppView*)noAppImage prevEdge:(float)prevEdge {
if (prevEdge == -1) {
return appScrollView.frame.origin.x + app.frame.size.width / 2 + noAppImage.frame.size.width / 2;
} else {
return prevEdge + app.frame.size.width / 2 + noAppImage.frame.size.width / 2;
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"AppCell" forIndexPath:indexPath];
App* app = appList[indexPath.row];
UIAppView* appView = [[UIAppView alloc] initWithApp:app andCallback:self];
[appView updateAppImage];
if (appView.bounds.size.width > 10.0) {
CGFloat scale = cell.bounds.size.width / appView.bounds.size.width;
[appView setCenter:CGPointMake(appView.bounds.size.width / 2 * scale, appView.bounds.size.height / 2 * scale)];
appView.transform = CGAffineTransformMakeScale(scale, scale);
}
[cell.subviews.firstObject removeFromSuperview]; // Remove a view that was previously added
[cell addSubview:appView];
return cell;
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1; // App collection only
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return appList.count;
}
- (BOOL)validatePcSelected {