|
|
@ -24,33 +24,20 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
|
|
@implementation OWSNavigationController
|
|
|
|
@implementation OWSNavigationController
|
|
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithOWSNavigationBar
|
|
|
|
- (instancetype)init
|
|
|
|
{
|
|
|
|
{
|
|
|
|
self = [self initWithNavigationBarClass:[OWSNavigationBar class] toolbarClass:nil];
|
|
|
|
self = [super initWithNavigationBarClass:[OWSNavigationBar class] toolbarClass:nil];
|
|
|
|
if (!self) {
|
|
|
|
if (!self) {
|
|
|
|
return self;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[self setupNavbar];
|
|
|
|
if (![self.navigationBar isKindOfClass:[OWSNavigationBar class]]) {
|
|
|
|
|
|
|
|
OWSFailDebug(@"navigationBar was unexpected class: %@", self.navigationBar);
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OWSNavigationBar *navbar = (OWSNavigationBar *)self.navigationBar;
|
|
|
|
|
|
|
|
navbar.navBarLayoutDelegate = self;
|
|
|
|
|
|
|
|
[self updateLayoutForNavbar:navbar];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
|
|
|
|
selector:@selector(themeDidChange:)
|
|
|
|
|
|
|
|
name:ThemeDidChangeNotification
|
|
|
|
|
|
|
|
object:nil];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithRootViewController:(UIViewController *)rootViewController
|
|
|
|
- (instancetype)initWithRootViewController:(UIViewController *)rootViewController
|
|
|
|
{
|
|
|
|
{
|
|
|
|
self = [self initWithOWSNavigationBar];
|
|
|
|
self = [self init];
|
|
|
|
if (!self) {
|
|
|
|
if (!self) {
|
|
|
|
return self;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -64,6 +51,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
|
|
|
|
- (void)themeDidChange:(NSNotification *)notification
|
|
|
|
- (void)themeDidChange:(NSNotification *)notification
|
|
|
|
{
|
|
|
|
{
|
|
|
|
OWSAssertIsOnMainThread();
|
|
|
|
OWSAssertIsOnMainThread();
|
|
|
@ -82,6 +71,22 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - UINavigationBarDelegate
|
|
|
|
#pragma mark - UINavigationBarDelegate
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)setupNavbar
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (![self.navigationBar isKindOfClass:[OWSNavigationBar class]]) {
|
|
|
|
|
|
|
|
OWSFailDebug(@"navigationBar was unexpected class: %@", self.navigationBar);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
OWSNavigationBar *navbar = (OWSNavigationBar *)self.navigationBar;
|
|
|
|
|
|
|
|
navbar.navBarLayoutDelegate = self;
|
|
|
|
|
|
|
|
[self updateLayoutForNavbar:navbar];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
|
|
|
|
selector:@selector(themeDidChange:)
|
|
|
|
|
|
|
|
name:ThemeDidChangeNotification
|
|
|
|
|
|
|
|
object:nil];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// All OWSNavigationController serve as the UINavigationBarDelegate for their navbar.
|
|
|
|
// All OWSNavigationController serve as the UINavigationBarDelegate for their navbar.
|
|
|
|
// We override shouldPopItem: in order to cancel some back button presses - for example,
|
|
|
|
// We override shouldPopItem: in order to cancel some back button presses - for example,
|
|
|
|
// if a view has unsaved changes.
|
|
|
|
// if a view has unsaved changes.
|
|
|
|