Always present settings from OWSNavigationController

// FREEBIE
This commit is contained in:
Michael Kirk 2017-09-07 11:03:54 -04:00
parent 29848835f3
commit 25a2646c8b
7 changed files with 30 additions and 4 deletions

View file

@ -20,6 +20,7 @@
#import "OWSDatabaseMigration.h" #import "OWSDatabaseMigration.h"
#import "OWSLogger.h" #import "OWSLogger.h"
#import "OWSMessageEditing.h" #import "OWSMessageEditing.h"
#import "OWSNavigationController.h"
#import "OWSProfileManager.h" #import "OWSProfileManager.h"
#import "OWSProgressView.h" #import "OWSProgressView.h"
#import "OWSViewController.h" #import "OWSViewController.h"

View file

@ -4,6 +4,15 @@
#import "OWSTableViewController.h" #import "OWSTableViewController.h"
NS_ASSUME_NONNULL_BEGIN
@class OWSNavigationController;
@interface AppSettingsViewController : OWSTableViewController @interface AppSettingsViewController : OWSTableViewController
+ (OWSNavigationController *)inModalNavigationController;
- (instancetype)init NS_UNAVAILABLE;
@end @end
NS_ASSUME_NONNULL_END

View file

@ -10,6 +10,7 @@
#import "NotificationSettingsViewController.h" #import "NotificationSettingsViewController.h"
#import "OWSContactsManager.h" #import "OWSContactsManager.h"
#import "OWSLinkedDevicesTableViewController.h" #import "OWSLinkedDevicesTableViewController.h"
#import "OWSNavigationController.h"
#import "PrivacySettingsTableViewController.h" #import "PrivacySettingsTableViewController.h"
#import "ProfileViewController.h" #import "ProfileViewController.h"
#import "PropertyListPreferences.h" #import "PropertyListPreferences.h"
@ -29,6 +30,18 @@
@implementation AppSettingsViewController @implementation AppSettingsViewController
/**
* We always present the settings controller modally, from within an OWSNavigationController
*/
+ (OWSNavigationController *)inModalNavigationController
{
AppSettingsViewController *viewController = [AppSettingsViewController new];
OWSNavigationController *navController =
[[OWSNavigationController alloc] initWithRootViewController:viewController];
return navController;
}
- (instancetype)init - (instancetype)init
{ {
self = [super init]; self = [super init];
@ -64,6 +77,8 @@
[super viewDidLoad]; [super viewDidLoad];
[self.navigationItem setHidesBackButton:YES]; [self.navigationItem setHidesBackButton:YES];
OWSAssert([self.navigationController isKindOfClass:[OWSNavigationController class]]);
[self.navigationController.navigationBar setTranslucent:NO]; [self.navigationController.navigationBar setTranslucent:NO];
self.navigationItem.leftBarButtonItem = self.navigationItem.leftBarButtonItem =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop

View file

@ -905,7 +905,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
assert(fromViewController != nil) assert(fromViewController != nil)
// Construct the "settings" view & push the "privacy settings" view. // Construct the "settings" view & push the "privacy settings" view.
let navigationController = UINavigationController(rootViewController:AppSettingsViewController()) let navigationController = AppSettingsViewController.inModalNavigationController()
navigationController.pushViewController(PrivacySettingsTableViewController(), animated:false) navigationController.pushViewController(PrivacySettingsTableViewController(), animated:false)
fromViewController?.present(navigationController, animated: true, completion: nil) fromViewController?.present(navigationController, animated: true, completion: nil)

View file

@ -126,7 +126,7 @@ private class CallKitExperienceUpgradeViewController: ExperienceUpgradeViewContr
assert(fromViewController != nil) assert(fromViewController != nil)
// Construct the "settings" view & push the "privacy settings" view. // Construct the "settings" view & push the "privacy settings" view.
let navigationController = UINavigationController(rootViewController:AppSettingsViewController()) let navigationController = AppSettingsViewController.inModalNavigationController()
navigationController.pushViewController(PrivacySettingsTableViewController(), animated:false) navigationController.pushViewController(PrivacySettingsTableViewController(), animated:false)
fromViewController?.present(navigationController, animated: true, completion: nil) fromViewController?.present(navigationController, animated: true, completion: nil)

View file

@ -95,6 +95,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
OWSAssert([self.navigationController isKindOfClass:[OWSNavigationController class]]);
// HACK otherwise CNContactViewController Navbar is shown as black. // HACK otherwise CNContactViewController Navbar is shown as black.
// RADAR rdar://28433898 http://www.openradar.me/28433898 // RADAR rdar://28433898 http://www.openradar.me/28433898
// CNContactViewController incompatible with opaque navigation bar // CNContactViewController incompatible with opaque navigation bar

View file

@ -310,8 +310,7 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
} }
- (void)settingsButtonPressed:(id)sender { - (void)settingsButtonPressed:(id)sender {
AppSettingsViewController *vc = [AppSettingsViewController new]; OWSNavigationController *navigationController = [AppSettingsViewController inModalNavigationController];
OWSNavigationController *navigationController = [[OWSNavigationController alloc] initWithRootViewController:vc];
[self presentViewController:navigationController animated:YES completion:nil]; [self presentViewController:navigationController animated:YES completion:nil];
} }