mirror of https://github.com/oxen-io/session-ios
Removing APNavigation as a dependency.
parent
8189e593ef
commit
3d4d4123f7
@ -1 +1 @@
|
||||
Subproject commit 89f829c06ce4605393867fa5660ccdbb3ce7cf53
|
||||
Subproject commit 0f4532971e696c73005950fa7d9154297fdfa746
|
@ -0,0 +1,24 @@
|
||||
//
|
||||
// APNavigationController.h
|
||||
// DropDownToolBar
|
||||
//
|
||||
// Created by Ankur Patel on 2/24/14.
|
||||
// Copyright (c) 2014 Encore Dev Labs LLC. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface APNavigationController : UINavigationController
|
||||
|
||||
@property (nonatomic, strong) UIToolbar *dropDownToolbar; // Reference to dynamically change items based on which bar button item is clicked
|
||||
@property (nonatomic, strong) NSString *activeNavigationBarTitle; // Navigation bar title when the toolbar is shown
|
||||
@property (nonatomic, strong) NSString *activeBarButtonTitle; // UIBarButton title when toolbar is shown
|
||||
@property (nonatomic, assign) BOOL isDropDownVisible;
|
||||
|
||||
- (void)setActiveBarButtonTitle:(NSString*)title;
|
||||
- (void)setActiveNavigationBarTitle:(NSString*)title;
|
||||
- (void)toggleDropDown:(id)sender;
|
||||
- (void)hideDropDown:(id)sender;
|
||||
- (void)showDropDown:(id)sender;
|
||||
|
||||
@end
|
@ -0,0 +1,108 @@
|
||||
//
|
||||
// APNavigationController.m
|
||||
// DropDownToolBar
|
||||
//
|
||||
// Created by Ankur Patel on 2/24/14.
|
||||
// Copyright (c) 2014 Encore Dev Labs LLC. All rights reserved.
|
||||
//
|
||||
|
||||
#import "APNavigationController.h"
|
||||
|
||||
@interface APNavigationController ()
|
||||
|
||||
@property (nonatomic, copy) NSString *originalNavigationBarTitle;
|
||||
@property (nonatomic, copy) NSString *originalBarButtonTitle;
|
||||
|
||||
@end
|
||||
|
||||
@implementation APNavigationController
|
||||
|
||||
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
|
||||
{
|
||||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
||||
if (self) {
|
||||
// Custom initialization
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
self.dropDownToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 64)];
|
||||
self.dropDownToolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
self.dropDownToolbar.tintColor = self.navigationBar.tintColor;
|
||||
[self.navigationBar.superview insertSubview:self.dropDownToolbar belowSubview:self.navigationBar];
|
||||
self.originalNavigationBarTitle = self.navigationBar.topItem.title;
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
{
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
- (void)toggleDropDown:(id)sender
|
||||
{
|
||||
if (self.isDropDownVisible) {
|
||||
[self hideDropDown:sender];
|
||||
} else {
|
||||
[self showDropDown:sender];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)hideDropDown:(id)sender
|
||||
{
|
||||
if(self.isDropDownVisible){
|
||||
__weak APNavigationController *weakSelf = self;
|
||||
CGRect frame = self.dropDownToolbar.frame;
|
||||
frame.origin.y = CGRectGetMaxY(self.navigationBar.frame);
|
||||
self.dropDownToolbar.frame = frame;
|
||||
[UIView animateWithDuration:0.25 animations:^{
|
||||
CGRect frame = self.dropDownToolbar.frame;
|
||||
frame.origin.y = 0.;
|
||||
weakSelf.dropDownToolbar.frame = frame;
|
||||
} completion:^(BOOL finished) {
|
||||
weakSelf.isDropDownVisible = !weakSelf.isDropDownVisible;
|
||||
weakSelf.dropDownToolbar.hidden = YES;
|
||||
}];
|
||||
if (self.activeNavigationBarTitle) {
|
||||
self.navigationBar.topItem.title = self.originalNavigationBarTitle;
|
||||
}
|
||||
if(sender && [sender isKindOfClass:[UIBarButtonItem class]]){
|
||||
[(UIBarButtonItem *)sender setTitle:self.originalBarButtonTitle];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showDropDown:(id)sender
|
||||
{
|
||||
if(!self.isDropDownVisible){
|
||||
__weak APNavigationController *weakSelf = self;
|
||||
CGRect frame = self.dropDownToolbar.frame;
|
||||
frame.origin.y = 0.f;
|
||||
self.dropDownToolbar.hidden = NO;
|
||||
self.dropDownToolbar.frame = frame;
|
||||
[UIView animateWithDuration:0.25 animations:^{
|
||||
CGRect frame = self.dropDownToolbar.frame;
|
||||
frame.origin.y = CGRectGetMaxY(self.navigationBar.frame);
|
||||
weakSelf.dropDownToolbar.frame = frame;
|
||||
} completion:^(BOOL finished) {
|
||||
weakSelf.isDropDownVisible = !weakSelf.isDropDownVisible;
|
||||
}];
|
||||
if (self.activeNavigationBarTitle) {
|
||||
self.navigationBar.topItem.title = self.activeNavigationBarTitle;
|
||||
}
|
||||
if(sender && [sender isKindOfClass:[UIBarButtonItem class]]){
|
||||
self.originalBarButtonTitle = [(UIBarButtonItem *)sender title];
|
||||
if (self.activeBarButtonTitle) {
|
||||
[(UIBarButtonItem *)sender setTitle:self.activeBarButtonTitle];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in New Issue