things working

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

@ -168,6 +168,7 @@ protocol MediaGalleryDataSourceDelegate: class {
func mediaGalleryDataSource(_ mediaGalleryDataSource: MediaGalleryDataSource, deletedSections: IndexSet, deletedItems: [IndexPath])
}
@objc
class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSource, MediaTileViewControllerDelegate {
private var pageViewController: MediaPageViewController?
@ -197,7 +198,9 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
self.options = options
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) {

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

@ -24,33 +24,20 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSNavigationController
- (instancetype)initWithOWSNavigationBar
- (instancetype)init
{
self = [self initWithNavigationBarClass:[OWSNavigationBar class] toolbarClass:nil];
self = [super initWithNavigationBarClass:[OWSNavigationBar class] toolbarClass:nil];
if (!self) {
return self;
}
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];
[self setupNavbar];
return self;
}
- (instancetype)initWithRootViewController:(UIViewController *)rootViewController
{
self = [self initWithOWSNavigationBar];
self = [self init];
if (!self) {
return self;
}
@ -64,6 +51,8 @@ NS_ASSUME_NONNULL_BEGIN
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
#pragma mark -
- (void)themeDidChange:(NSNotification *)notification
{
OWSAssertIsOnMainThread();
@ -82,6 +71,22 @@ NS_ASSUME_NONNULL_BEGIN
#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.
// We override shouldPopItem: in order to cancel some back button presses - for example,
// if a view has unsaved changes.

Loading…
Cancel
Save