Coder Social home page Coder Social logo

jondanao / thesidebarcontroller Goto Github PK

View Code? Open in Web Editor NEW
360.0 15.0 52.0 6.07 MB

A container view controller that implements different popular sidebar view controllers like Facebook, Airbnb, Flipboard, etc.

License: Other

Objective-C 98.59% Ruby 1.41%

thesidebarcontroller's Introduction

TheSidebarController

TheSidebarController is a container view controller that manages 3 main view controllers namely - contentViewController, leftSidebarController and the rightSidebarController. Reveal the sidebar by calling either one of the following methods:

Presentation Methods

  • presentLeftSidebarViewController - presents the left sidebar using the default Facebook type animation
  • presentLeftSidebarViewControllerWithStyle: - presents the left sidebar by specifying one of the available presentation styles
  • presentRightSidebarViewController - presents the right sidebar using the default Facebook type animation
  • presentRightSidebarViewControllerWithStyle: - presents the right sidebar by specifying one of the available presentation styles

Transition Styles

  • SidebarTransitionStyleFacebook - Content slides to reveal sidebar
  • SidebarTransitionStyleAirbnb - Content rotates in 3D space to reveal sidebar
  • SidebarTransitionStyleLuvocracy - Content zooms out to reveal sidebar
  • SidebarTransitionStyleFeedly - Sidebar slides over content
  • SidebarTransitionStyleFlipboard - Sidebar slides over while content zooms out
  • SidebarTransitionStyleWunderlist - Content and sidebar slide making a parallax effect

Delegation Methods

  • sidebarController:willShowViewController:
  • sidebarController:didShowViewController:
  • sidebarController:willHideViewController:
  • sidebarController:didHideViewController:

This project is inspired by RESideMenu. I almost copied everything. Thanks Roman! :)

Installation

Manual

Drag and drop TheSidebarController folder into your project. Add #import "TheSidebarController.h" to all view controllers that need to use it.

Cocoapods

Cocoapods is amazing. If you're still not using it, start now! This is the recommended approach to manage your dependencies. Learn from their official website: http://guides.cocoapods.org/

In the project folder where .xcodeproj resides, create a Podfile:

$ touch Podfile

Edit Podfile and add TheSidebarController:

platform :ios, '7.0'
pod 'TheSidebarController', '~> 0.6'

Install:

$ pod install

Open .xcworkspace and not the .xcodeproj:

$ open MyApp.xcworkspace

Import TheSidebarController where needed:

#import <TheSidebarController/TheSidebarController.h>

Sample Usage

In your AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    ContentViewController *contentViewController = [[ContentViewController alloc] init];
    UINavigationController *contentNavigationController = [[UINavigationController alloc] initWithRootViewController:contentViewController];
    
    LeftSidebarViewController *leftSidebarViewController = [[LeftSidebarViewController alloc] init];    
    RightSidebarViewController *rightSidebarViewController = [[RightSidebarViewController alloc] init];
    
    TheSidebarController *sidebarController = [[TheSidebarController alloc] initWithContentViewController:contentNavigationController
                                                                                leftSidebarViewController:leftSidebarViewController
                                                                               rightSidebarViewController:rightSidebarViewController];
    
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];
    self.window.rootViewController = sidebarController;
    [self.window makeKeyAndVisible];
    return YES;
}

Present the sidebar view controller

[self.sidebarController presentLeftSidebarViewControllerWithStyle:SidebarTransitionStyleFacebook];

Dismiss the sidebar view controller

[self.sidebarController dismissSidebarViewController];

Replace content view controller

self.sidebarController.contentViewController = [[UIViewController alloc] init];

Requirements

  • Xcode 5 or higher
  • iOS 7.0 or higher
  • ARC

Demo

Build and run the Examples/Basic and Examples/KitchenSink projects in Xcode to see TheSidebarController in action.

Known Bugs

CATransform3D does not play well with autorotation. A simple 3D rotate screws up view positions when device orientation changes. Would appreciate some help on this.

Feature Requests and Contributing

Forks, patches and other feedback are welcome.

Contact

Jon Danao

License

TheSidebarController is available under the MIT license.

Copyright (c) 2013 Jon Danao (danao.org | jondanao)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

thesidebarcontroller's People

Contributors

jonahgabriel avatar jondanao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

thesidebarcontroller's Issues

When trying to instantiate from a storyboard, the sidebar screens become unresponsive?

Here's the code I'm using below. When I instantiate a UIViewController from a storyboard rather than a xib, none of the UIButtons are responsive. It's as if they were behind an invisible layer. (I've made sure to enable user interactions)

When I instantiate with alloc init and add UIButtons programatically on the UIViewController's ViewDidLoad method however, it works.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Get the main storyboard    
    UIStoryboard *main = [UIStoryboard storyboardWithName:@"Main" bundle: nil];

    PSMainViewController *centerViewController = [main instantiateViewControllerWithIdentifier:@"PSMainViewController"];
    UINavigationController *contentViewController = [[UINavigationController alloc] initWithRootViewController:centerViewController];

    PSLeftSidebarViewController *leftViewController = [main instantiateViewControllerWithIdentifier:@"PSLeftSidebarViewController"];

    PSRightSidebarViewController *rightViewController = [main instantiateViewControllerWithIdentifier:@"PSRightSidebarViewController"];

    PSRootViewController *sidebarController = [[PSRootViewController alloc] initWithContentViewController:contentViewController leftSidebarViewController:leftViewController rightSidebarViewController:rightViewController];
    sidebarController.delegate = self;

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.rootViewController = sidebarController;
    [self.window makeKeyAndVisible];
}

It seems to be working when I use [[UIViewController alloc]init] and adding UIViews on the main ViewDidLoad though...

sidebarController become unresponsive if the contentViewController is tabBarController

I have a tab bar controller in storyboard that contains a bar button to open a side panel from left side. I used the below code to integrate thesidebarcontroller in my application...

LeftViewController *leftViewController = [[LeftViewController alloc] init];
leftViewController.view.backgroundColor = [UIColor colorWithRed:125.0 green:125.0 blue:125.0 alpha:0.5];
UITabBarController *contentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController"];
TheSidebarController *sidebarController = [[TheSidebarController alloc] initWithContentViewController:contentViewController leftSidebarViewController:leftViewController];

I wrote the code for left bar button (to open sidepanel) in tabcontroller's first selected view controller, and confirmed with break points that it's being called on button press.

- (void)leftButtonClicked
{
   if(self.sidebarController.sidebarIsPresenting)
   {
        [self.sidebarController dismissSidebarViewController];
   }
   else
   {
       [self.sidebarController presentLeftSidebarViewControllerWithStyle:SidebarTransitionStyleAirbnb];
   }
}

But, side panel is not responding or opening !!!..

Nib file autolayout constraints not applied when using TheSidebarController

Hi There, thanks for an awesome library, i really like it.

However, I have an autolayout constraint not being applied on my viewcontroller that gets set as the contentViewController of theSidebarController. I use the constructor that specifies storyboardsUseAutoLayout = YES, but still no constraint on my view.

Any advice?

Thanks

New release for Cocoapods 0.39

It seems that the code has been updated to support cocoapods 0.39 (06c8ef8) but there's no new release for it. Can that and the podspec be updated please. Thanks

Problems with modal views

When presenting a modal view controller and dismiss all the screen is messed up. After dismiss the modal view controller the app is 100% broken.

¿Any idea of what is happening? The same problem appears using modal view controllers in the examples.

Modal presentation issue

Presenting a modal view controller from either TheSidebarController or the main content controller works, but when the modal view controller is dismissed, TheSidebarController (and the sidebar and main content controller) are no longer visible, and all that's left is the UIWindow background color.

I've tried this multiple times and seem to be able to replicate it 100% of the time.

Ideally, I'd like to be able to get the top most view controller (TheSidebarController in this case) and present a modal view controller from it, without any problems.

EDIT: This issue affects both iOS 7 and iOS 8.

Podspec seems a bit broken

After basic pod install and importing <TheSidebarController/TheSidebarController.h>

The project does not build:

../Pods/Headers/TheSidebarController/TheSidebarController.h:26:9: 'SidebarAnimation.h' file not found

iPhone 6 and iPhone 6 Plus issue

static const CGFloat kVisibleWidth = 260.0f;

work properly just for a 320px screen, with iPhone 6 and 6 plus need to define a better constant.

for example:

_visibleWidth = [[UIScreen mainScreen] bounds].size.width/2;

to show half screen.

Hope this help.

push/pop effects on changing the contentViewController

Hi,

I have a contentViewController which has a tableview inside it. I want to push the next view on selection of any row from the tableview.
For that right now I am using this code...

self.sidebarController.contentViewController = contentViewController;

But, as we know it won't show any push effect. How to add push/pop effects in this case?

Suggest

Hi! @jondanao
You will achieve in the future similar to the effect of this picture?
a43cd25cad8b7e64cd0d13a03cbd2e823ff8abf8481714-dwmqi3_fw236

Compiler wants different type instead of UIView *

I brought TheSideBarController.h/m as well as every file from the animations folder. Throughout many of the animations files there is code like

  • (void)animateContentView:(UIView *)contentView sidebarView:(UIView *)sidebarView fromSide:(Side)side visibleWidth:(CGFloat)visibleWidth duration:(NSTimeInterval)animationDuration completion:(void (^)(BOOL))completion
    {

}

My compiler is giving me issues on the (UIView*) parts because it wants a different type. Any ideas on a fix?

Performance issue on real devices

To whom it may concern,

I tried the library and it worked great. However, when the animation happens on a real device (iPhone 5), it is pretty sluggish. When it's compared to what AirBnb animation, the AirBnb animation looks way smoother.
I'm not sure what trick they did to make it smooth but I just wonder if we turn the front view into an image before the animation, would it be faster?

Regards

New CocoaPod version

Hi

A new Pod version with the update to use TheSidebarController with Auto Layout will be really cool

Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.