Commit 767a02ba authored by Felix Paul Kühne's avatar Felix Paul Kühne
Browse files

subclass UINavigationController for custom appearance instead of using a...

subclass UINavigationController for custom appearance instead of using a category to save selector dispatches and slightly less clutter
parent 0b2d3a7e
......@@ -24,7 +24,6 @@
#import "VLCMovieViewController.h"
#import "VLCPlaybackNavigationController.h"
#import "PAPasscodeViewController.h"
#import "UINavigationController+Theme.h"
#import "VLCHTTPUploaderController.h"
#import "VLCMenuTableViewController.h"
#import "VLCMigrationViewController.h"
......@@ -32,6 +31,7 @@
#import <BoxSDK/BoxSDK.h>
#import "VLCNotificationRelay.h"
#import "VLCPlaybackController.h"
#import "VLCNavigationController.h"
#define HAVE_FABRIC 0
......@@ -97,8 +97,7 @@
// enable crash preventer
void (^setupBlock)() = ^{
_playlistViewController = [[VLCPlaylistViewController alloc] init];
UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:_playlistViewController];
[navCon loadTheme];
UINavigationController *navCon = [[VLCNavigationController alloc] initWithRootViewController:_playlistViewController];
_revealController = [[GHRevealViewController alloc] initWithNibName:nil bundle:nil];
_revealController.wantsFullScreenLayout = YES;
......
......@@ -16,7 +16,6 @@
#import "VLCLocalNetworkListCell.h"
#import "VLCAppDelegate.h"
#import "VLCPlaylistViewController.h"
#import "UINavigationController+Theme.h"
#import "VLCDownloadViewController.h"
#import "NSString+SupportedMedia.h"
#import "VLCStatusLabel.h"
......
......@@ -19,7 +19,6 @@
#import "VLCLocalNetworkListCell.h"
#import "VLCAppDelegate.h"
#import "VLCPlaylistViewController.h"
#import "UINavigationController+Theme.h"
#import "VLCDownloadViewController.h"
#import "WhiteRaccoon.h"
#import "NSString+SupportedMedia.h"
......
......@@ -25,10 +25,10 @@
#import <QuartzCore/QuartzCore.h>
#import "GHRevealViewController.h"
#import "VLCNetworkLoginViewController.h"
#import "UINavigationController+Theme.h"
#import "VLCPlaylistViewController.h"
#import "VLCHTTPUploaderController.h"
#import "Reachability.h"
#import "VLCNavigationController.h"
#define kPlexServiceType @"_plexmediasvr._tcp."
......@@ -395,8 +395,7 @@
else
_connectPlexServer = [[VLCPlexConnectServerViewController alloc] initWithNibName:@"VLCPlexConnectServerViewController" bundle:nil];
UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:_connectPlexServer];
[navCon loadTheme];
UINavigationController *navCon = [[VLCNavigationController alloc] initWithRootViewController:_connectPlexServer];
navCon.navigationBarHidden = NO;
[self.navigationController pushViewController:_connectPlexServer animated:YES];
......@@ -408,8 +407,7 @@
[[self navigationController] pushViewController:targetViewController animated:YES];
}
} else if (section == 2) {
UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:_loginViewController];
[navCon loadTheme];
UINavigationController *navCon = [[VLCNavigationController alloc] initWithRootViewController:_loginViewController];
navCon.navigationBarHidden = NO;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
......
......@@ -29,12 +29,12 @@
#import "VLCLocalServerListViewController.h"
#import "VLCOpenNetworkStreamViewController.h"
#import "VLCSettingsController.h"
#import "UINavigationController+Theme.h"
#import "UIBarButtonItem+Theme.h"
#import "VLCAboutViewController.h"
#import "VLCPlaylistViewController.h"
#import "VLCBugreporter.h"
#import "VLCCloudServicesTableViewController.h"
#import "VLCNavigationController.h"
@interface VLCMenuTableViewController () <UITableViewDataSource, UITableViewDelegate>
{
......@@ -359,17 +359,13 @@
if (!viewController)
return;
UINavigationController *navCon = nil;
GHRevealViewController *revealController = appDelegate.revealController;
if ([revealController.contentViewController isKindOfClass:[UINavigationController class]]) {
navCon = (UINavigationController*)revealController.contentViewController;
UINavigationController *navCon = (UINavigationController*)revealController.contentViewController;
navCon.viewControllers = @[viewController];
} else {
navCon = [[UINavigationController alloc] initWithRootViewController:viewController];
[navCon loadTheme];
revealController.contentViewController = navCon;
}
} else
revealController.contentViewController = [[VLCNavigationController alloc] initWithRootViewController:viewController];
[revealController toggleSidebar:NO duration:kGHRevealSidebarDefaultAnimationDuration];
}
......
/*****************************************************************************
* UINavigationController+Theme.h
* VLCNavigationController.h
* VLC for iOS
*****************************************************************************
* Copyright (c) 2013 VideoLAN. All rights reserved.
* Copyright (c) 2013-2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Romain Goyet <romain.goyet # applidium.com>
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import <UIKit/UIKit.h>
@interface UINavigationController (Theme)
- (void)loadTheme;
@end
@interface VLCNavigationController : UINavigationController
@end
\ No newline at end of file
/*****************************************************************************
* UINavigationController+Theme.m
* VLCNavigationController.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2013 VideoLAN. All rights reserved.
* Copyright (c) 2013-2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
* Romain Goyet <romain.goyet # applidium.com>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import "UINavigationController+Theme.h"
#import "VLCNavigationController.h"
@implementation UINavigationController (Theme)
- (void)loadTheme
@interface VLCNavigationController ()
{
UINavigationBar *navBar = self.navigationBar;
BOOL _setup;
}
@end
@implementation VLCNavigationController
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if (_setup)
return;
UINavigationBar *navigationBar = self.navigationBar;
if (!SYSTEM_RUNS_IOS7_OR_LATER) {
[navBar setBackgroundImage:[UIImage imageNamed:@"navBarBackground"] forBarMetrics:UIBarMetricsDefault];
navBar.barStyle = UIBarStyleBlack;
navBar.translucent = NO;
navBar.opaque = YES;
[navigationBar setBackgroundImage:[UIImage imageNamed:@"navBarBackground"] forBarMetrics:UIBarMetricsDefault];
navigationBar.barStyle = UIBarStyleBlack;
navigationBar.translucent = NO;
navigationBar.opaque = YES;
} else {
navBar.barTintColor = [UIColor VLCOrangeTintColor];
navBar.tintColor = [UIColor whiteColor];
navBar.titleTextAttributes = @{ UITextAttributeTextColor : [UIColor whiteColor] };
navigationBar.barTintColor = [UIColor VLCOrangeTintColor];
navigationBar.tintColor = [UIColor whiteColor];
navigationBar.titleTextAttributes = @{ UITextAttributeTextColor : [UIColor whiteColor] };
}
_setup = YES;
}
@end
......@@ -16,7 +16,6 @@
#import "VLCAppDelegate.h"
#import "VLCPlaylistViewController.h"
#import "UIBarButtonItem+Theme.h"
#import "UINavigationController+Theme.h"
#import "VLCMenuTableViewController.h"
#import "UIDevice+VLC.h"
......
......@@ -27,6 +27,7 @@
#import "LXReorderableCollectionViewFlowLayout.h"
#import "VLCAlertView.h"
#import "VLCOpenInActivity.h"
#import "VLCNavigationController.h"
#import <AssetsLibrary/AssetsLibrary.h>
......@@ -38,9 +39,8 @@ static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutoria
- (IBAction)learnMore:(id)sender
{
UIViewController *firstStepsVC = [[VLCFirstStepsViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:firstStepsVC];
UINavigationController *navCon = [[VLCNavigationController alloc] initWithRootViewController:firstStepsVC];
navCon.modalPresentationStyle = UIModalPresentationFormSheet;
[navCon loadTheme];
[self.window.rootViewController presentViewController:navCon animated:YES completion:nil];
}
......
......@@ -15,7 +15,6 @@
#import "VLCLocalNetworkListCell.h"
#import "VLCAppDelegate.h"
#import "VLCPlaylistViewController.h"
#import "UINavigationController+Theme.h"
#import "VLCDownloadViewController.h"
#import "NSString+SupportedMedia.h"
#import "VLCStatusLabel.h"
......@@ -85,7 +84,7 @@
if (_mutableObjectList.count == 0)
titleValue = _httpServerAddress;
else
titleValue = [_mutableObjectList[0] objectForKey:@"libTitle"];
titleValue = [_mutableObjectList.firstObject objectForKey:@"libTitle"];
self.title = titleValue;
......@@ -322,8 +321,8 @@
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
[_searchData removeAllObjects];
for (int i = 0; i < [_mutableObjectList count]; i++) {
NSUInteger count = _mutableObjectList.count;
for (NSUInteger i = 0; i < count; i++) {
NSRange nameRange;
nameRange = [[[_mutableObjectList objectAtIndex:i] objectForKey:@"title"] rangeOfString:searchString options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
......
......@@ -235,7 +235,6 @@
7D3784AD183A9906009EE944 /* VLCDropboxController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D3784AA183A9906009EE944 /* VLCDropboxController.m */; };
7D3784AE183A9906009EE944 /* VLCDropboxTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D3784AC183A9906009EE944 /* VLCDropboxTableViewController.m */; };
7D3784BE183A9938009EE944 /* UIBarButtonItem+Theme.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D3784B3183A9938009EE944 /* UIBarButtonItem+Theme.m */; };
7D3784BF183A9938009EE944 /* UINavigationController+Theme.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D3784B5183A9938009EE944 /* UINavigationController+Theme.m */; };
7D3784C0183A9938009EE944 /* VLCLinearProgressIndicator.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D3784B7183A9938009EE944 /* VLCLinearProgressIndicator.m */; };
7D3784C1183A9938009EE944 /* VLCMenuButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D3784B9183A9938009EE944 /* VLCMenuButton.m */; };
7D3784C2183A9938009EE944 /* VLCSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D3784BB183A9938009EE944 /* VLCSlider.m */; };
......@@ -314,6 +313,7 @@
7D71395A186B197800D54EDA /* darkButton@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7D713956186B197800D54EDA /* darkButton@2x.png */; };
7D71395B186B197800D54EDA /* darkButtonHighlight.png in Resources */ = {isa = PBXBuildFile; fileRef = 7D713957186B197800D54EDA /* darkButtonHighlight.png */; };
7D71395C186B197800D54EDA /* darkButtonHighlight@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7D713958186B197800D54EDA /* darkButtonHighlight@2x.png */; };
7D74177A1AE2D3CE001F1997 /* VLCNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D7417791AE2D3CE001F1997 /* VLCNavigationController.m */; };
7D7B17F01AD8052B003BF3D7 /* libc++.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D7B17EC1AD8052A003BF3D7 /* libc++.dylib */; };
7D7B17F11AD8052B003BF3D7 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D7B17ED1AD8052B003BF3D7 /* libz.dylib */; };
7D871F521AD7257100348D27 /* UIImage+Scaling.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D871F501AD7257100348D27 /* UIImage+Scaling.m */; };
......@@ -986,8 +986,6 @@
7D3784B0183A990F009EE944 /* VLCCloudStorageTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCCloudStorageTableViewCell.m; path = Sources/VLCCloudStorageTableViewCell.m; sourceTree = SOURCE_ROOT; };
7D3784B2183A9938009EE944 /* UIBarButtonItem+Theme.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIBarButtonItem+Theme.h"; path = "Sources/UIBarButtonItem+Theme.h"; sourceTree = SOURCE_ROOT; };
7D3784B3183A9938009EE944 /* UIBarButtonItem+Theme.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIBarButtonItem+Theme.m"; path = "Sources/UIBarButtonItem+Theme.m"; sourceTree = SOURCE_ROOT; };
7D3784B4183A9938009EE944 /* UINavigationController+Theme.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UINavigationController+Theme.h"; path = "Sources/UINavigationController+Theme.h"; sourceTree = SOURCE_ROOT; };
7D3784B5183A9938009EE944 /* UINavigationController+Theme.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UINavigationController+Theme.m"; path = "Sources/UINavigationController+Theme.m"; sourceTree = SOURCE_ROOT; };
7D3784B6183A9938009EE944 /* VLCLinearProgressIndicator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCLinearProgressIndicator.h; path = Sources/VLCLinearProgressIndicator.h; sourceTree = SOURCE_ROOT; };
7D3784B7183A9938009EE944 /* VLCLinearProgressIndicator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCLinearProgressIndicator.m; path = Sources/VLCLinearProgressIndicator.m; sourceTree = SOURCE_ROOT; };
7D3784B8183A9938009EE944 /* VLCMenuButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCMenuButton.h; path = Sources/VLCMenuButton.h; sourceTree = SOURCE_ROOT; };
......@@ -1181,6 +1179,8 @@
7D713956186B197800D54EDA /* darkButton@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "darkButton@2x.png"; sourceTree = "<group>"; };
7D713957186B197800D54EDA /* darkButtonHighlight.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = darkButtonHighlight.png; sourceTree = "<group>"; };
7D713958186B197800D54EDA /* darkButtonHighlight@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "darkButtonHighlight@2x.png"; sourceTree = "<group>"; };
7D7417781AE2D3CE001F1997 /* VLCNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCNavigationController.h; path = Sources/VLCNavigationController.h; sourceTree = SOURCE_ROOT; };
7D7417791AE2D3CE001F1997 /* VLCNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCNavigationController.m; path = Sources/VLCNavigationController.m; sourceTree = SOURCE_ROOT; };
7D7B17EA1AD8052A003BF3D7 /* Crashlytics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Crashlytics.framework; sourceTree = "<group>"; };
7D7B17EB1AD8052A003BF3D7 /* Fabric.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Fabric.framework; sourceTree = "<group>"; };
7D7B17EC1AD8052A003BF3D7 /* libc++.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libc++.dylib"; path = "usr/lib/libc++.dylib"; sourceTree = SDKROOT; };
......@@ -2108,8 +2108,8 @@
9BADAF44185FBD9D00108BD8 /* VLCFrostedGlasView.m */,
7D3784B2183A9938009EE944 /* UIBarButtonItem+Theme.h */,
7D3784B3183A9938009EE944 /* UIBarButtonItem+Theme.m */,
7D3784B4183A9938009EE944 /* UINavigationController+Theme.h */,
7D3784B5183A9938009EE944 /* UINavigationController+Theme.m */,
7D7417781AE2D3CE001F1997 /* VLCNavigationController.h */,
7D7417791AE2D3CE001F1997 /* VLCNavigationController.m */,
7D3784B6183A9938009EE944 /* VLCLinearProgressIndicator.h */,
7D3784B7183A9938009EE944 /* VLCLinearProgressIndicator.m */,
7D3784B8183A9938009EE944 /* VLCMenuButton.h */,
......@@ -3700,7 +3700,6 @@
7D3784AE183A9906009EE944 /* VLCDropboxTableViewController.m in Sources */,
7D3784BE183A9938009EE944 /* UIBarButtonItem+Theme.m in Sources */,
41B93C051A53835300102E8B /* VLCCloudServiceCell.m in Sources */,
7D3784BF183A9938009EE944 /* UINavigationController+Theme.m in Sources */,
7D4625881A5614A1001A80B4 /* VLCEqualizerView.m in Sources */,
7DF9352F1958AB0600E60FD4 /* UIColor+Presets.m in Sources */,
7D50903218F41C7900180139 /* VLCAlertView.m in Sources */,
......@@ -3741,6 +3740,7 @@
7D30F3D9183AB2F100FFC021 /* VLCLocalServerListViewController.m in Sources */,
7D30F3DC183AB2F900FFC021 /* VLCNetworkLoginViewController.m in Sources */,
7D30F3DF183AB31E00FFC021 /* VLCWiFiUploadTableViewCell.m in Sources */,
7D74177A1AE2D3CE001F1997 /* VLCNavigationController.m in Sources */,
7D30F3E2183AB33200FFC021 /* VLCSidebarViewCell.m in Sources */,
7D30F3EA183AB34200FFC021 /* VLCGoogleDriveController.m in Sources */,
9B088308183D7BEC004B5C2A /* VLCCloudStorageTableViewController.m in Sources */,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment