things working

pull/1/head
Michael Kirk 7 years ago
parent 1af750363a
commit 6d8a7ed800

@ -168,6 +168,7 @@ protocol MediaGalleryDataSourceDelegate: class {
func mediaGalleryDataSource(_ mediaGalleryDataSource: MediaGalleryDataSource, deletedSections: IndexSet, deletedItems: [IndexPath]) func mediaGalleryDataSource(_ mediaGalleryDataSource: MediaGalleryDataSource, deletedSections: IndexSet, deletedItems: [IndexPath])
} }
@objc
class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSource, MediaTileViewControllerDelegate { class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSource, MediaTileViewControllerDelegate {
private var pageViewController: MediaPageViewController? private var pageViewController: MediaPageViewController?
@ -197,7 +198,9 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
self.options = options self.options = options
self.mediaGalleryFinder = OWSMediaGalleryFinder(thread: thread) self.mediaGalleryFinder = OWSMediaGalleryFinder(thread: thread)
super.init(owsNavigationBar: ()) super.init(nibName: nil, bundle: nil)
self.setValue(OWSNavigationBar(), forKey: "navigationBar")
super.setupNavbar()
} }
required init?(coder aDecoder: NSCoder) { required init?(coder aDecoder: NSCoder) {

@ -23,7 +23,8 @@ NS_ASSUME_NONNULL_BEGIN
// unsaved changes. // unsaved changes.
@interface OWSNavigationController : UINavigationController @interface OWSNavigationController : UINavigationController
- (instancetype)initWithOWSNavigationBar; - (instancetype)init;
- (void)setupNavbar;
@end @end

@ -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.

Loading…
Cancel
Save