Skip to content

Commit

Permalink
Prepare Dark Theme
Browse files Browse the repository at this point in the history
Remove the [UIApplication statusBarHidden] use (deprecated since iOS 9).
Use the default UIViewController-based status bar system.

Hide the user interface theme option in Settings.

element-hq/riot-meta#22
  • Loading branch information
giomfo committed Jul 21, 2017
1 parent 40b8bba commit 887d9de
Show file tree
Hide file tree
Showing 14 changed files with 268 additions and 59 deletions.
6 changes: 6 additions & 0 deletions Riot.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
32FD0A3D1EB0CD9B0072B066 /* BugReportViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 32FD0A3B1EB0CD9B0072B066 /* BugReportViewController.m */; };
32FD0A3E1EB0CD9B0072B066 /* BugReportViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 32FD0A3C1EB0CD9B0072B066 /* BugReportViewController.xib */; };
E2EAC1A4FBD6FE5228584591 /* libPods-Riot.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D8737F782E108CFD6908691 /* libPods-Riot.a */; };
F0131DE51F2200D600CBF707 /* RiotSplitViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F0131DE41F2200D600CBF707 /* RiotSplitViewController.m */; };
F02C1A861E8EB04C0045A404 /* PeopleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F02C1A841E8EB04C0045A404 /* PeopleViewController.m */; };
F05BD79E1E7AEBF800C69941 /* UnifiedSearchViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F05BD79D1E7AEBF800C69941 /* UnifiedSearchViewController.m */; };
F05BD7A11E7C0E4500C69941 /* MasterTabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = F05BD7A01E7C0E4500C69941 /* MasterTabBarController.m */; };
Expand Down Expand Up @@ -529,6 +530,8 @@
32FD0A3B1EB0CD9B0072B066 /* BugReportViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BugReportViewController.m; sourceTree = "<group>"; };
32FD0A3C1EB0CD9B0072B066 /* BugReportViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = BugReportViewController.xib; sourceTree = "<group>"; };
7D8737F782E108CFD6908691 /* libPods-Riot.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Riot.a"; sourceTree = BUILT_PRODUCTS_DIR; };
F0131DE31F2200D600CBF707 /* RiotSplitViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RiotSplitViewController.h; sourceTree = "<group>"; };
F0131DE41F2200D600CBF707 /* RiotSplitViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RiotSplitViewController.m; sourceTree = "<group>"; };
F02C1A831E8EB04C0045A404 /* PeopleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PeopleViewController.h; sourceTree = "<group>"; };
F02C1A841E8EB04C0045A404 /* PeopleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PeopleViewController.m; sourceTree = "<group>"; };
F05BD79C1E7AEBF800C69941 /* UnifiedSearchViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnifiedSearchViewController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1563,6 +1566,8 @@
F083BC191E7009EC00A9B29C /* ViewController */ = {
isa = PBXGroup;
children = (
F0131DE31F2200D600CBF707 /* RiotSplitViewController.h */,
F0131DE41F2200D600CBF707 /* RiotSplitViewController.m */,
F0E059FE1E963103004B83FB /* FavouritesViewController.h */,
F0E059FF1E963103004B83FB /* FavouritesViewController.m */,
F0E05A001E963103004B83FB /* RoomsViewController.h */,
Expand Down Expand Up @@ -2529,6 +2534,7 @@
F083BE861E7009ED00A9B29C /* RoomTableViewCell.m in Sources */,
F083BDF51E7009ED00A9B29C /* main.m in Sources */,
F083BDEE1E7009ED00A9B29C /* MXRoom+Riot.m in Sources */,
F0131DE51F2200D600CBF707 /* RiotSplitViewController.m in Sources */,
F083BE331E7009ED00A9B29C /* DeviceView.m in Sources */,
32471CDC1F1373A100BDF50A /* RoomMembershipCollapsedWithPaginationTitleBubbleCell.m in Sources */,
F083BE2B1E7009ED00A9B29C /* AuthInputsView.m in Sources */,
Expand Down
30 changes: 2 additions & 28 deletions Riot/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -2390,12 +2390,6 @@ - (void)dismissCallViewController:(MXKCallViewController *)callViewController co
BOOL callIsEnded = (callViewController.mxCall.state == MXCallStateEnded);
NSLog(@"Call view controller is dismissed (%d)", callIsEnded);

if (callIsEnded)
{
// Restore system status bar
[UIApplication sharedApplication].statusBarHidden = NO;
}

[callViewController dismissViewControllerAnimated:YES completion:^{

if (!callIsEnded)
Expand Down Expand Up @@ -2530,31 +2524,11 @@ - (void)presentCallViewController:(void (^)())completion
{
if (self.window.rootViewController.presentedViewController)
{
[self.window.rootViewController.presentedViewController presentViewController:currentCallViewController animated:YES completion:^{

// Hide system status bar
[UIApplication sharedApplication].statusBarHidden = YES;

if (completion)
{
completion ();
}

}];
[self.window.rootViewController.presentedViewController presentViewController:currentCallViewController animated:YES completion:completion];
}
else
{
[self.window.rootViewController presentViewController:currentCallViewController animated:YES completion:^{

// Hide system status bar
[UIApplication sharedApplication].statusBarHidden = YES;

if (completion)
{
completion ();
}

}];
[self.window.rootViewController presentViewController:currentCallViewController animated:YES completion:completion];
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions Riot/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="H1p-Uh-vWS">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="H1p-Uh-vWS">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -335,7 +335,7 @@
<!--RecentsSplitVC-->
<scene sceneID="Nki-YV-4Qg">
<objects>
<splitViewController title="RecentsSplitVC" id="H1p-Uh-vWS" sceneMemberID="viewController">
<splitViewController title="RecentsSplitVC" id="H1p-Uh-vWS" customClass="RiotSplitViewController" sceneMemberID="viewController">
<toolbarItems/>
<navigationItem key="navigationItem" id="EB5-8V-irH"/>
<connections>
Expand Down Expand Up @@ -428,7 +428,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="logo.png" translatesAutoresizingMaskIntoConstraints="NO" id="6LG-qc-7jf">
<rect key="frame" x="127" y="284" width="120" height="99"/>
<rect key="frame" x="127" y="283" width="120" height="101"/>
</imageView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
Expand Down Expand Up @@ -564,7 +564,7 @@
</scene>
</scenes>
<resources>
<image name="logo.png" width="120" height="99"/>
<image name="logo.png" width="120" height="101"/>
<image name="search_icon.png" width="22" height="22"/>
<image name="settings_icon.png" width="24" height="24"/>
<image name="tab_favourites.png" width="25" height="25"/>
Expand All @@ -577,10 +577,10 @@
<image name="tab_rooms_selected.png" width="25" height="25"/>
</resources>
<inferredMetricsTieBreakers>
<segue reference="tk8-vF-K4T"/>
<segue reference="Tfl-tq-LQp"/>
<segue reference="fNQ-S3-DbZ"/>
<segue reference="ziz-Xl-QVg"/>
<segue reference="mFs-HA-7Oo"/>
<segue reference="fNQ-S3-DbZ"/>
<segue reference="0ws-cL-0tk"/>
<segue reference="Tfl-tq-LQp"/>
</inferredMetricsTieBreakers>
</document>
2 changes: 1 addition & 1 deletion Riot/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<true/>
<key>UserDefaults</key>
<string>${PRODUCT_NAME}-Defaults</string>
</dict>
Expand Down
6 changes: 6 additions & 0 deletions Riot/ViewController/CallViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ - (void)userInterfaceThemeDidChange
self.defaultBarTintColor = kRiotSecondaryBgColor;
}

- (BOOL)prefersStatusBarHidden
{
// Hide the status bar on the call view controller.
return YES;
}

- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
Expand Down
22 changes: 22 additions & 0 deletions Riot/ViewController/ContactDetailsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ Current alert (if any).
Observe kRiotDesignValuesDidChangeThemeNotification to handle user interface theme change.
*/
id kRiotDesignValuesDidChangeThemeNotificationObserver;

/**
The current visibility of the status bar in this view controller.
*/
BOOL isStatusBarHidden;
}
@end

Expand Down Expand Up @@ -107,6 +112,9 @@ - (void)finalizeInit
// Setup `MXKViewControllerHandling` properties
self.enableBarTintColorStatusChange = NO;
self.rageShakeManager = [RageShakeManager sharedManager];

// Keep visible the status bar by default.
isStatusBarHidden = NO;
}

- (void)viewDidLoad
Expand Down Expand Up @@ -221,6 +229,12 @@ - (void)userInterfaceThemeDidChange
self.defaultBarTintColor = kRiotSecondaryBgColor;
}

- (BOOL)prefersStatusBarHidden
{
// Return the current status bar visibility.
return isStatusBarHidden;
}

- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
Expand Down Expand Up @@ -1096,6 +1110,10 @@ - (void)handleTapGesture:(UITapGestureRecognizer*)tapGestureRecognizer
[avatarFullScreenView removeFromSuperview];

avatarFullScreenView = nil;

isStatusBarHidden = NO;
// Trigger status bar update
[self setNeedsStatusBarAppearanceUpdate];
}];

NSString *avatarURL = nil;
Expand All @@ -1113,6 +1131,10 @@ - (void)handleTapGesture:(UITapGestureRecognizer*)tapGestureRecognizer
previewImage:contactAvatar.image];

[avatarFullScreenView showFullScreen];
isStatusBarHidden = YES;

// Trigger status bar update
[self setNeedsStatusBarAppearanceUpdate];
}
}

Expand Down
26 changes: 13 additions & 13 deletions Riot/ViewController/CountryPickerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,7 @@ - (void)viewDidLoad

// Hide line separators of empty cells
self.tableView.tableFooterView = [[UIView alloc] init];
}

- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];

// Screen tracking (via Google Analytics)
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
if (tracker)
{
[tracker set:kGAIScreenName value:@"CountryPicker"];
[tracker send:[[GAIDictionaryBuilder createScreenView] build]];
}

// Observe user interface theme change.
kRiotDesignValuesDidChangeThemeNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kRiotDesignValuesDidChangeThemeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {

Expand All @@ -73,6 +60,19 @@ - (void)userInterfaceThemeDidChange
self.defaultBarTintColor = kRiotSecondaryBgColor;
}

- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];

// Screen tracking (via Google Analytics)
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
if (tracker)
{
[tracker set:kGAIScreenName value:@"CountryPicker"];
[tracker send:[[GAIDictionaryBuilder createScreenView] build]];
}
}

- (void)destroy
{
[super destroy];
Expand Down
35 changes: 34 additions & 1 deletion Riot/ViewController/LanguagePickerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,23 @@

#import "AppDelegate.h"

@interface LanguagePickerViewController ()
{
/**
Observe kRiotDesignValuesDidChangeThemeNotification to handle user interface theme change.
*/
id kRiotDesignValuesDidChangeThemeNotificationObserver;
}

@end

@implementation LanguagePickerViewController

- (void)finalizeInit
{
[super finalizeInit];

// Setup `MXKViewControllerHandling` properties
self.defaultBarTintColor = kRiotNavBarTintColor;
self.enableBarTintColorStatusChange = NO;
self.rageShakeManager = [RageShakeManager sharedManager];
}
Expand All @@ -36,6 +45,30 @@ - (void)viewDidLoad

// Hide line separators of empty cells
self.tableView.tableFooterView = [[UIView alloc] init];

// Observe user interface theme change.
kRiotDesignValuesDidChangeThemeNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kRiotDesignValuesDidChangeThemeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {

[self userInterfaceThemeDidChange];

}];
[self userInterfaceThemeDidChange];
}

- (void)userInterfaceThemeDidChange
{
self.defaultBarTintColor = kRiotSecondaryBgColor;
}

- (void)destroy
{
[super destroy];

if (kRiotDesignValuesDidChangeThemeNotificationObserver)
{
[[NSNotificationCenter defaultCenter] removeObserver:kRiotDesignValuesDidChangeThemeNotificationObserver];
kRiotDesignValuesDidChangeThemeNotificationObserver = nil;
}
}

- (void)viewWillAppear:(BOOL)animated
Expand Down
13 changes: 13 additions & 0 deletions Riot/ViewController/MediaAlbumContentViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,19 @@ - (void)userInterfaceThemeDidChange
self.defaultBarTintColor = kRiotSecondaryBgColor;
}

- (BOOL)prefersStatusBarHidden
{
// Return the preferred value of the delegate if it is a view controller itself.
// This is required to handle correctly the full screen mode when a media is selected.
if ([self.delegate isKindOfClass:UIViewController.class])
{
return [(UIViewController*)self.delegate prefersStatusBarHidden];
}

// Keep visible the status bar by default.
return NO;
}

- (void)destroy
{
[super destroy];
Expand Down
Loading

0 comments on commit 887d9de

Please sign in to comment.