From e7ec8c702d8d4ae428df49f74d376d32c31df294 Mon Sep 17 00:00:00 2001 From: James Tang Date: Mon, 12 Dec 2011 04:26:23 +0800 Subject: [PATCH] - JTRevealSidebarV2. A truly reusable solution which mimic the sidebar pattern which used by new Facebook and Path iOS app --- JTRevealSidebarDemo.xcodeproj/project.pbxproj | 329 ++++++++++++++++++ JTRevealSidebarDemoV2/AppDelegate.h | 15 + JTRevealSidebarDemoV2/AppDelegate.m | 70 ++++ JTRevealSidebarDemoV2/ButtonMenu.png | Bin 0 -> 1118 bytes JTRevealSidebarDemoV2/ButtonMenu@2x.png | Bin 0 -> 1066 bytes .../JTRevealSidebarDemoV2-Info.plist | 47 +++ .../JTRevealSidebarDemoV2-Prefix.pch | 14 + JTRevealSidebarDemoV2/NewViewController.h | 16 + JTRevealSidebarDemoV2/NewViewController.m | 104 ++++++ JTRevealSidebarDemoV2/SidebarViewController.h | 26 ++ JTRevealSidebarDemoV2/SidebarViewController.m | 86 +++++ JTRevealSidebarDemoV2/ViewController.h | 21 ++ JTRevealSidebarDemoV2/ViewController.m | 185 ++++++++++ .../en.lproj/InfoPlist.strings | 2 + JTRevealSidebarDemoV2/main.m | 18 + .../JTRevealSidebarDemoV2Tests-Info.plist | 22 ++ .../JTRevealSidebarDemoV2Tests.h | 13 + .../JTRevealSidebarDemoV2Tests.m | 32 ++ .../en.lproj/InfoPlist.strings | 2 + JTRevealSidebarV2/JTRevealSidebarV2Delegate.h | 17 + .../UINavigationItem+JTRevealSidebarV2.h | 17 + .../UINavigationItem+JTRevealSidebarV2.m | 24 ++ .../UIViewController+JTRevealSidebarV2.h | 28 ++ .../UIViewController+JTRevealSidebarV2.m | 167 +++++++++ 24 files changed, 1255 insertions(+) create mode 100644 JTRevealSidebarDemoV2/AppDelegate.h create mode 100644 JTRevealSidebarDemoV2/AppDelegate.m create mode 100644 JTRevealSidebarDemoV2/ButtonMenu.png create mode 100644 JTRevealSidebarDemoV2/ButtonMenu@2x.png create mode 100644 JTRevealSidebarDemoV2/JTRevealSidebarDemoV2-Info.plist create mode 100644 JTRevealSidebarDemoV2/JTRevealSidebarDemoV2-Prefix.pch create mode 100644 JTRevealSidebarDemoV2/NewViewController.h create mode 100644 JTRevealSidebarDemoV2/NewViewController.m create mode 100644 JTRevealSidebarDemoV2/SidebarViewController.h create mode 100644 JTRevealSidebarDemoV2/SidebarViewController.m create mode 100644 JTRevealSidebarDemoV2/ViewController.h create mode 100644 JTRevealSidebarDemoV2/ViewController.m create mode 100644 JTRevealSidebarDemoV2/en.lproj/InfoPlist.strings create mode 100644 JTRevealSidebarDemoV2/main.m create mode 100644 JTRevealSidebarDemoV2Tests/JTRevealSidebarDemoV2Tests-Info.plist create mode 100644 JTRevealSidebarDemoV2Tests/JTRevealSidebarDemoV2Tests.h create mode 100644 JTRevealSidebarDemoV2Tests/JTRevealSidebarDemoV2Tests.m create mode 100644 JTRevealSidebarDemoV2Tests/en.lproj/InfoPlist.strings create mode 100644 JTRevealSidebarV2/JTRevealSidebarV2Delegate.h create mode 100644 JTRevealSidebarV2/UINavigationItem+JTRevealSidebarV2.h create mode 100644 JTRevealSidebarV2/UINavigationItem+JTRevealSidebarV2.m create mode 100644 JTRevealSidebarV2/UIViewController+JTRevealSidebarV2.h create mode 100644 JTRevealSidebarV2/UIViewController+JTRevealSidebarV2.m diff --git a/JTRevealSidebarDemo.xcodeproj/project.pbxproj b/JTRevealSidebarDemo.xcodeproj/project.pbxproj index 2fa9ac8..6de87d7 100644 --- a/JTRevealSidebarDemo.xcodeproj/project.pbxproj +++ b/JTRevealSidebarDemo.xcodeproj/project.pbxproj @@ -7,6 +7,24 @@ objects = { /* Begin PBXBuildFile section */ + 1A057B6E1495400F0069D7AD /* NewViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A057B6D1495400F0069D7AD /* NewViewController.m */; }; + 1A057B7A149547F20069D7AD /* ButtonMenu.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A057B78149547F10069D7AD /* ButtonMenu.png */; }; + 1A057B7B149547F20069D7AD /* ButtonMenu@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A057B79149547F10069D7AD /* ButtonMenu@2x.png */; }; + 1A617E8D148FC4A6005EC465 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AD4708514446391002EE1B0 /* UIKit.framework */; }; + 1A617E8E148FC4A6005EC465 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AD4708714446391002EE1B0 /* Foundation.framework */; }; + 1A617E8F148FC4A6005EC465 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AD4708914446392002EE1B0 /* CoreGraphics.framework */; }; + 1A617E95148FC4A7005EC465 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1A617E93148FC4A7005EC465 /* InfoPlist.strings */; }; + 1A617E97148FC4A7005EC465 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A617E96148FC4A7005EC465 /* main.m */; }; + 1A617E9B148FC4A7005EC465 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A617E9A148FC4A7005EC465 /* AppDelegate.m */; }; + 1A617EA2148FC4A7005EC465 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AD470A614446392002EE1B0 /* SenTestingKit.framework */; }; + 1A617EA3148FC4A7005EC465 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AD4708514446391002EE1B0 /* UIKit.framework */; }; + 1A617EA4148FC4A7005EC465 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AD4708714446391002EE1B0 /* Foundation.framework */; }; + 1A617EAC148FC4A7005EC465 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1A617EAA148FC4A7005EC465 /* InfoPlist.strings */; }; + 1A617EAF148FC4A7005EC465 /* JTRevealSidebarDemoV2Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A617EAE148FC4A7005EC465 /* JTRevealSidebarDemoV2Tests.m */; }; + 1A617EB9148FC4DB005EC465 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A617EB8148FC4DB005EC465 /* ViewController.m */; }; + 1A617EC1148FC612005EC465 /* UINavigationItem+JTRevealSidebarV2.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A617EC0148FC612005EC465 /* UINavigationItem+JTRevealSidebarV2.m */; }; + 1A617EC4148FC706005EC465 /* UIViewController+JTRevealSidebarV2.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A617EC3148FC706005EC465 /* UIViewController+JTRevealSidebarV2.m */; }; + 1A81A5D814951CEF00BF03B8 /* SidebarViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A81A5D714951CEE00BF03B8 /* SidebarViewController.m */; }; 1A89988D1445FBDB001C5FFB /* JTNavigationView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A89988C1445FBDB001C5FFB /* JTNavigationView.m */; }; 1ACADFFA145720F4000F5E15 /* JTNavigationBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 1ACADFF9145720F4000F5E15 /* JTNavigationBar.m */; }; 1AD4708614446391002EE1B0 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AD4708514446391002EE1B0 /* UIKit.framework */; }; @@ -30,6 +48,13 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + 1A617EA5148FC4A7005EC465 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1AD4707814446391002EE1B0 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 1A617E8A148FC4A6005EC465; + remoteInfo = JTRevealSidebarDemoV2; + }; 1AD470AA14446392002EE1B0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1AD4707814446391002EE1B0 /* Project object */; @@ -40,6 +65,31 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 1A057B6C1495400F0069D7AD /* NewViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewViewController.h; sourceTree = ""; }; + 1A057B6D1495400F0069D7AD /* NewViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NewViewController.m; sourceTree = ""; }; + 1A057B78149547F10069D7AD /* ButtonMenu.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ButtonMenu.png; sourceTree = ""; }; + 1A057B79149547F10069D7AD /* ButtonMenu@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ButtonMenu@2x.png"; sourceTree = ""; }; + 1A617E8B148FC4A6005EC465 /* JTRevealSidebarDemoV2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JTRevealSidebarDemoV2.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 1A617E92148FC4A7005EC465 /* JTRevealSidebarDemoV2-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "JTRevealSidebarDemoV2-Info.plist"; sourceTree = ""; }; + 1A617E94148FC4A7005EC465 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 1A617E96148FC4A7005EC465 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 1A617E98148FC4A7005EC465 /* JTRevealSidebarDemoV2-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "JTRevealSidebarDemoV2-Prefix.pch"; sourceTree = ""; }; + 1A617E99148FC4A7005EC465 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 1A617E9A148FC4A7005EC465 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 1A617EA1148FC4A7005EC465 /* JTRevealSidebarDemoV2Tests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = JTRevealSidebarDemoV2Tests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; + 1A617EA9148FC4A7005EC465 /* JTRevealSidebarDemoV2Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "JTRevealSidebarDemoV2Tests-Info.plist"; sourceTree = ""; }; + 1A617EAB148FC4A7005EC465 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 1A617EAD148FC4A7005EC465 /* JTRevealSidebarDemoV2Tests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JTRevealSidebarDemoV2Tests.h; sourceTree = ""; }; + 1A617EAE148FC4A7005EC465 /* JTRevealSidebarDemoV2Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JTRevealSidebarDemoV2Tests.m; sourceTree = ""; }; + 1A617EB7148FC4DB005EC465 /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 1A617EB8148FC4DB005EC465 /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 1A617EBB148FC5B4005EC465 /* JTRevealSidebarV2Delegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JTRevealSidebarV2Delegate.h; sourceTree = ""; }; + 1A617EBF148FC612005EC465 /* UINavigationItem+JTRevealSidebarV2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UINavigationItem+JTRevealSidebarV2.h"; sourceTree = ""; }; + 1A617EC0148FC612005EC465 /* UINavigationItem+JTRevealSidebarV2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UINavigationItem+JTRevealSidebarV2.m"; sourceTree = ""; }; + 1A617EC2148FC706005EC465 /* UIViewController+JTRevealSidebarV2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+JTRevealSidebarV2.h"; sourceTree = ""; }; + 1A617EC3148FC706005EC465 /* UIViewController+JTRevealSidebarV2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+JTRevealSidebarV2.m"; sourceTree = ""; }; + 1A81A5D614951CEE00BF03B8 /* SidebarViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SidebarViewController.h; sourceTree = ""; }; + 1A81A5D714951CEE00BF03B8 /* SidebarViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SidebarViewController.m; sourceTree = ""; }; 1A89988B1445FBDB001C5FFB /* JTNavigationView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JTNavigationView.h; sourceTree = ""; }; 1A89988C1445FBDB001C5FFB /* JTNavigationView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JTNavigationView.m; sourceTree = ""; }; 1ACADFF8145720F4000F5E15 /* JTNavigationBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JTNavigationBar.h; sourceTree = ""; }; @@ -75,6 +125,26 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 1A617E88148FC4A6005EC465 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 1A617E8D148FC4A6005EC465 /* UIKit.framework in Frameworks */, + 1A617E8E148FC4A6005EC465 /* Foundation.framework in Frameworks */, + 1A617E8F148FC4A6005EC465 /* CoreGraphics.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 1A617E9D148FC4A7005EC465 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 1A617EA2148FC4A7005EC465 /* SenTestingKit.framework in Frameworks */, + 1A617EA3148FC4A7005EC465 /* UIKit.framework in Frameworks */, + 1A617EA4148FC4A7005EC465 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 1AD4707E14446391002EE1B0 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -98,12 +168,75 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 1A617E90148FC4A6005EC465 /* JTRevealSidebarDemoV2 */ = { + isa = PBXGroup; + children = ( + 1A617E99148FC4A7005EC465 /* AppDelegate.h */, + 1A617E9A148FC4A7005EC465 /* AppDelegate.m */, + 1A617EB7148FC4DB005EC465 /* ViewController.h */, + 1A617EB8148FC4DB005EC465 /* ViewController.m */, + 1A81A5D614951CEE00BF03B8 /* SidebarViewController.h */, + 1A81A5D714951CEE00BF03B8 /* SidebarViewController.m */, + 1A057B6C1495400F0069D7AD /* NewViewController.h */, + 1A057B6D1495400F0069D7AD /* NewViewController.m */, + 1A617E91148FC4A7005EC465 /* Supporting Files */, + ); + path = JTRevealSidebarDemoV2; + sourceTree = ""; + }; + 1A617E91148FC4A7005EC465 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 1A057B78149547F10069D7AD /* ButtonMenu.png */, + 1A057B79149547F10069D7AD /* ButtonMenu@2x.png */, + 1A617E92148FC4A7005EC465 /* JTRevealSidebarDemoV2-Info.plist */, + 1A617E93148FC4A7005EC465 /* InfoPlist.strings */, + 1A617E96148FC4A7005EC465 /* main.m */, + 1A617E98148FC4A7005EC465 /* JTRevealSidebarDemoV2-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 1A617EA7148FC4A7005EC465 /* JTRevealSidebarDemoV2Tests */ = { + isa = PBXGroup; + children = ( + 1A617EAD148FC4A7005EC465 /* JTRevealSidebarDemoV2Tests.h */, + 1A617EAE148FC4A7005EC465 /* JTRevealSidebarDemoV2Tests.m */, + 1A617EA8148FC4A7005EC465 /* Supporting Files */, + ); + path = JTRevealSidebarDemoV2Tests; + sourceTree = ""; + }; + 1A617EA8148FC4A7005EC465 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 1A617EA9148FC4A7005EC465 /* JTRevealSidebarDemoV2Tests-Info.plist */, + 1A617EAA148FC4A7005EC465 /* InfoPlist.strings */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 1A617EBA148FC4FB005EC465 /* JTRevealSidebarV2 */ = { + isa = PBXGroup; + children = ( + 1A617EBB148FC5B4005EC465 /* JTRevealSidebarV2Delegate.h */, + 1A617EBF148FC612005EC465 /* UINavigationItem+JTRevealSidebarV2.h */, + 1A617EC0148FC612005EC465 /* UINavigationItem+JTRevealSidebarV2.m */, + 1A617EC2148FC706005EC465 /* UIViewController+JTRevealSidebarV2.h */, + 1A617EC3148FC706005EC465 /* UIViewController+JTRevealSidebarV2.m */, + ); + path = JTRevealSidebarV2; + sourceTree = ""; + }; 1AD4707614446391002EE1B0 = { isa = PBXGroup; children = ( 1AD470BD144463B4002EE1B0 /* JTRevealSidebar */, 1AD4708B14446392002EE1B0 /* JTRevealSidebarDemo */, 1AD470AC14446392002EE1B0 /* JTRevealSidebarDemoTests */, + 1A617EBA148FC4FB005EC465 /* JTRevealSidebarV2 */, + 1A617E90148FC4A6005EC465 /* JTRevealSidebarDemoV2 */, + 1A617EA7148FC4A7005EC465 /* JTRevealSidebarDemoV2Tests */, 1AD4708414446391002EE1B0 /* Frameworks */, 1AD4708214446391002EE1B0 /* Products */, ); @@ -114,6 +247,8 @@ children = ( 1AD4708114446391002EE1B0 /* JTRevealSidebarDemo.app */, 1AD470A514446392002EE1B0 /* JTRevealSidebarDemoTests.octest */, + 1A617E8B148FC4A6005EC465 /* JTRevealSidebarDemoV2.app */, + 1A617EA1148FC4A7005EC465 /* JTRevealSidebarDemoV2Tests.octest */, ); name = Products; sourceTree = ""; @@ -195,6 +330,42 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + 1A617E8A148FC4A6005EC465 /* JTRevealSidebarDemoV2 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1A617EB4148FC4A7005EC465 /* Build configuration list for PBXNativeTarget "JTRevealSidebarDemoV2" */; + buildPhases = ( + 1A617E87148FC4A6005EC465 /* Sources */, + 1A617E88148FC4A6005EC465 /* Frameworks */, + 1A617E89148FC4A6005EC465 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = JTRevealSidebarDemoV2; + productName = JTRevealSidebarDemoV2; + productReference = 1A617E8B148FC4A6005EC465 /* JTRevealSidebarDemoV2.app */; + productType = "com.apple.product-type.application"; + }; + 1A617EA0148FC4A7005EC465 /* JTRevealSidebarDemoV2Tests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1A617EB5148FC4A7005EC465 /* Build configuration list for PBXNativeTarget "JTRevealSidebarDemoV2Tests" */; + buildPhases = ( + 1A617E9C148FC4A7005EC465 /* Sources */, + 1A617E9D148FC4A7005EC465 /* Frameworks */, + 1A617E9E148FC4A7005EC465 /* Resources */, + 1A617E9F148FC4A7005EC465 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 1A617EA6148FC4A7005EC465 /* PBXTargetDependency */, + ); + name = JTRevealSidebarDemoV2Tests; + productName = JTRevealSidebarDemoV2Tests; + productReference = 1A617EA1148FC4A7005EC465 /* JTRevealSidebarDemoV2Tests.octest */; + productType = "com.apple.product-type.bundle"; + }; 1AD4708014446391002EE1B0 /* JTRevealSidebarDemo */ = { isa = PBXNativeTarget; buildConfigurationList = 1AD470B714446392002EE1B0 /* Build configuration list for PBXNativeTarget "JTRevealSidebarDemo" */; @@ -253,11 +424,31 @@ targets = ( 1AD4708014446391002EE1B0 /* JTRevealSidebarDemo */, 1AD470A414446392002EE1B0 /* JTRevealSidebarDemoTests */, + 1A617E8A148FC4A6005EC465 /* JTRevealSidebarDemoV2 */, + 1A617EA0148FC4A7005EC465 /* JTRevealSidebarDemoV2Tests */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 1A617E89148FC4A6005EC465 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1A617E95148FC4A7005EC465 /* InfoPlist.strings in Resources */, + 1A057B7A149547F20069D7AD /* ButtonMenu.png in Resources */, + 1A057B7B149547F20069D7AD /* ButtonMenu@2x.png in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 1A617E9E148FC4A7005EC465 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1A617EAC148FC4A7005EC465 /* InfoPlist.strings in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 1AD4707F14446391002EE1B0 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -279,6 +470,19 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 1A617E9F148FC4A7005EC465 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; + }; 1AD470A314446392002EE1B0 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -295,6 +499,28 @@ /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 1A617E87148FC4A6005EC465 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1A617E97148FC4A7005EC465 /* main.m in Sources */, + 1A617E9B148FC4A7005EC465 /* AppDelegate.m in Sources */, + 1A617EB9148FC4DB005EC465 /* ViewController.m in Sources */, + 1A617EC1148FC612005EC465 /* UINavigationItem+JTRevealSidebarV2.m in Sources */, + 1A617EC4148FC706005EC465 /* UIViewController+JTRevealSidebarV2.m in Sources */, + 1A81A5D814951CEF00BF03B8 /* SidebarViewController.m in Sources */, + 1A057B6E1495400F0069D7AD /* NewViewController.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 1A617E9C148FC4A7005EC465 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1A617EAF148FC4A7005EC465 /* JTRevealSidebarDemoV2Tests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 1AD4707D14446391002EE1B0 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -322,6 +548,11 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ + 1A617EA6148FC4A7005EC465 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 1A617E8A148FC4A6005EC465 /* JTRevealSidebarDemoV2 */; + targetProxy = 1A617EA5148FC4A7005EC465 /* PBXContainerItemProxy */; + }; 1AD470AB14446392002EE1B0 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 1AD4708014446391002EE1B0 /* JTRevealSidebarDemo */; @@ -330,6 +561,22 @@ /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ + 1A617E93148FC4A7005EC465 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 1A617E94148FC4A7005EC465 /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; + 1A617EAA148FC4A7005EC465 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 1A617EAB148FC4A7005EC465 /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; 1AD4708E14446392002EE1B0 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( @@ -365,6 +612,70 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + 1A617EB0148FC4A7005EC465 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "JTRevealSidebarDemoV2/JTRevealSidebarDemoV2-Prefix.pch"; + INFOPLIST_FILE = "JTRevealSidebarDemoV2/JTRevealSidebarDemoV2-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + 1A617EB1148FC4A7005EC465 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "JTRevealSidebarDemoV2/JTRevealSidebarDemoV2-Prefix.pch"; + INFOPLIST_FILE = "JTRevealSidebarDemoV2/JTRevealSidebarDemoV2-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; + 1A617EB2148FC4A7005EC465 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/JTRevealSidebarDemoV2.app/JTRevealSidebarDemoV2"; + CLANG_ENABLE_OBJC_ARC = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(DEVELOPER_LIBRARY_DIR)/Frameworks", + ); + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "JTRevealSidebarDemoV2/JTRevealSidebarDemoV2-Prefix.pch"; + INFOPLIST_FILE = "JTRevealSidebarDemoV2Tests/JTRevealSidebarDemoV2Tests-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 5.0; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUNDLE_LOADER)"; + WRAPPER_EXTENSION = octest; + }; + name = Debug; + }; + 1A617EB3148FC4A7005EC465 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/JTRevealSidebarDemoV2.app/JTRevealSidebarDemoV2"; + CLANG_ENABLE_OBJC_ARC = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(DEVELOPER_LIBRARY_DIR)/Frameworks", + ); + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "JTRevealSidebarDemoV2/JTRevealSidebarDemoV2-Prefix.pch"; + INFOPLIST_FILE = "JTRevealSidebarDemoV2Tests/JTRevealSidebarDemoV2Tests-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 5.0; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUNDLE_LOADER)"; + WRAPPER_EXTENSION = octest; + }; + name = Release; + }; 1AD470B514446392002EE1B0 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -469,6 +780,24 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 1A617EB4148FC4A7005EC465 /* Build configuration list for PBXNativeTarget "JTRevealSidebarDemoV2" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1A617EB0148FC4A7005EC465 /* Debug */, + 1A617EB1148FC4A7005EC465 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1A617EB5148FC4A7005EC465 /* Build configuration list for PBXNativeTarget "JTRevealSidebarDemoV2Tests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1A617EB2148FC4A7005EC465 /* Debug */, + 1A617EB3148FC4A7005EC465 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 1AD4707B14446391002EE1B0 /* Build configuration list for PBXProject "JTRevealSidebarDemo" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/JTRevealSidebarDemoV2/AppDelegate.h b/JTRevealSidebarDemoV2/AppDelegate.h new file mode 100644 index 0000000..c016269 --- /dev/null +++ b/JTRevealSidebarDemoV2/AppDelegate.h @@ -0,0 +1,15 @@ +// +// AppDelegate.h +// JTRevealSidebarDemoV2 +// +// Created by James Apple Tang on 7/12/11. +// Copyright (c) 2011 __MyCompanyName__. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@end diff --git a/JTRevealSidebarDemoV2/AppDelegate.m b/JTRevealSidebarDemoV2/AppDelegate.m new file mode 100644 index 0000000..9fd204b --- /dev/null +++ b/JTRevealSidebarDemoV2/AppDelegate.m @@ -0,0 +1,70 @@ +// +// AppDelegate.m +// JTRevealSidebarDemoV2 +// +// Created by James Apple Tang on 7/12/11. +// Copyright (c) 2011 __MyCompanyName__. All rights reserved. +// + +#import "AppDelegate.h" +#import "ViewController.h" + +@implementation AppDelegate + +@synthesize window = _window; + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + // Override point for customization after application launch. + self.window.backgroundColor = [UIColor whiteColor]; + + ViewController *controller = [[ViewController alloc] init]; + controller.title = @"ViewController"; + UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller]; + + self.window.rootViewController = navController; + [self.window makeKeyAndVisible]; + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application +{ + /* + Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. + */ +} + +- (void)applicationDidEnterBackground:(UIApplication *)application +{ + /* + Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + */ +} + +- (void)applicationWillEnterForeground:(UIApplication *)application +{ + /* + Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. + */ +} + +- (void)applicationDidBecomeActive:(UIApplication *)application +{ + /* + Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + */ +} + +- (void)applicationWillTerminate:(UIApplication *)application +{ + /* + Called when the application is about to terminate. + Save data if appropriate. + See also applicationDidEnterBackground:. + */ +} + +@end diff --git a/JTRevealSidebarDemoV2/ButtonMenu.png b/JTRevealSidebarDemoV2/ButtonMenu.png new file mode 100644 index 0000000000000000000000000000000000000000..4a4d467a971aaf8a7f6fbc9c06a1a3fc2f9680a4 GIT binary patch literal 1118 zcmbVLO-K|`93Qiy1P?(7)}hB39;DrQGrR8W4!dr;vztq`Jqpo!jg9c{a$NYc4-~aPgy8BFh z-LX1~qUw{KVuq{@_`-}oEN*1Ep6(f&8Qj-Qz21!ck;u{pE zsM>;>&EZ_COOOrCE4emaM>7eUqQX(fl;mNAK^_gNdW2qmxkv+5iO~J6DVQ>2Xh`iG zvrykycUB%7mO~01Z3AIPAOsr15^%H;-4>h(y~!((y?f2jVABK-N9Zl5a;Y?k85RPq zUg(iw0D=JPWqp30=T89+vXFrs!*U*$7kr!mA=rLsqGl-tAtNTXwa6(#4`FNy3{xx? zy+xnbum%}66biW<9Ooex9=oJt$?@oRQAsr{h2u=QY6;%-uJfC1$-Vb>W27)XbOa!<%?@vGo{hu}R&=k}jjFu1a*bvA#XALd-%EHms~+j8r=y zJ!D|R9x_Z2>uUumNmh0D?3QOMS`k_5C8Q)QLj#-n71Uky{~h-hR{5WtF~k|hZH~X1 zrFum=(B1B|J~`|R57NoRSY$L#?tgfXjMZdPY|lC$^Ba{)wAMqt|ML3I`oxbb7xGi{ zw=3$3(mX!Cj+O&QmFA|Y$$fbS%srld(R0-~zBJGa<__fBS{gSF-#p>FAF^-EmdoX@ z>pxe!mf`Ho%-ZLL^NX)w`0}r(mFR5E(%W}g_HN6!`Ihf%YsKDA>8be#OJ{5H{h;B| f^oxZFhd(`0LviIwYY9AGaVI_*?-rkQ3|#vSeok*< literal 0 HcmV?d00001 diff --git a/JTRevealSidebarDemoV2/ButtonMenu@2x.png b/JTRevealSidebarDemoV2/ButtonMenu@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..08dc402d36592d39015c091c7c615097eee26b90 GIT binary patch literal 1066 zcmaJ=OH30%7+wU4K~dvHFcH^9jmCB#E%dQavF*0d;1W`r&;(6bc87LTc4yh0(xn%P zny3dKF-DDv9*i2f7(5a+pdOIKgI@JujCj!C`h+CjUHGRqG~#v7`L0R4wW3%W4Z(3#kW4^?6*vaSgeGM`5=hGQnt{CuqPxd7Bsm8VIR-MS9-_WJT%br*2~oqHA}bnEkX8GN zCKxIXq~u~w4k}d7A+p=%F@Xk|8SxS%RQkh*}es76-{FGy&O3 zvu>I7v80cqId6yG?{|?NmSY*#!*Cuq=jXj1o@L4MN8xCuGR`N3csUlfLR1zZgJ+mR zp+FbBG&C~|7Yqg+4v)u;5pHW*N0RNXs;_@noq#8ztB08A2CFmKAZapUbyD1(ohKtj+= zK{!#V;$RjcXl0>6Mu$2{QIb{Nu}gSSsv$0^sSAcR}13IesDpg`0=2X-SPbJd_OC`)uJH6Y$LiQ(qdNFN$J1`&u^wjMY{5_BWVF4d-M$aIk$Xi;!E$or4KFr2ZDEHw0NgD^Y+-u z>*w~rY8hR4*=jd_ORRgeY5tkezIwVqzgQP8L~lq+%%^<1{39~8a&P3;;&;C7!QtNA z + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFiles + + CFBundleIdentifier + com.mystcolor.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/JTRevealSidebarDemoV2/JTRevealSidebarDemoV2-Prefix.pch b/JTRevealSidebarDemoV2/JTRevealSidebarDemoV2-Prefix.pch new file mode 100644 index 0000000..04bee52 --- /dev/null +++ b/JTRevealSidebarDemoV2/JTRevealSidebarDemoV2-Prefix.pch @@ -0,0 +1,14 @@ +// +// Prefix header for all source files of the 'JTRevealSidebarDemoV2' target in the 'JTRevealSidebarDemoV2' project +// + +#import + +#ifndef __IPHONE_3_0 +#warning "This project uses features only available in iOS SDK 3.0 and later." +#endif + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/JTRevealSidebarDemoV2/NewViewController.h b/JTRevealSidebarDemoV2/NewViewController.h new file mode 100644 index 0000000..32557da --- /dev/null +++ b/JTRevealSidebarDemoV2/NewViewController.h @@ -0,0 +1,16 @@ +// +// NewViewController.h +// JTRevealSidebarDemo +// +// Created by James Apple Tang on 12/12/11. +// Copyright (c) 2011 __MyCompanyName__. All rights reserved. +// + +#import + +@interface NewViewController : UIViewController + +@property (nonatomic, strong) UILabel *label; +@property (nonatomic, strong) UITableView *rightSidebarView; + +@end diff --git a/JTRevealSidebarDemoV2/NewViewController.m b/JTRevealSidebarDemoV2/NewViewController.m new file mode 100644 index 0000000..0e62b07 --- /dev/null +++ b/JTRevealSidebarDemoV2/NewViewController.m @@ -0,0 +1,104 @@ +// +// NewViewController.m +// JTRevealSidebarDemo +// +// Created by James Apple Tang on 12/12/11. +// Copyright (c) 2011 __MyCompanyName__. All rights reserved. +// + +#import "NewViewController.h" +#import "UINavigationItem+JTRevealSidebarV2.h" +#import "UIViewController+JTRevealSidebarV2.h" +#import "JTRevealSidebarV2Delegate.h" + +@interface NewViewController () +@end + +@implementation NewViewController +@synthesize label; +@synthesize rightSidebarView; +#pragma mark - View lifecycle + +// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. +- (void)viewDidLoad +{ + [super viewDidLoad]; + self.label = [[UILabel alloc] initWithFrame:CGRectMake(30, 30, 290, 30)]; + [self.view addSubview:self.label]; + + self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(revealRightSidebar:)]; + + self.navigationItem.revealSidebarDelegate = self; +} + +- (void)viewDidUnload +{ + [super viewDidUnload]; + // Release any retained subviews of the main view. + // e.g. self.myOutlet = nil; +} + +#pragma mark Action + +- (void)revealRightSidebar:(id)sender { + JTRevealedState state = JTRevealedStateRight; + if (self.navigationController.revealedState == JTRevealedStateRight) { + state = JTRevealedStateNo; + } + [self.navigationController setRevealedState:state]; +} + + +#pragma mark UITableViewDatasource + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return 8; +} + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + static NSString *cellIdentifier = @"CellIdentifier"; + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; + if ( ! cell) { + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; + cell.selectionStyle = UITableViewCellSelectionStyleGray; + } + cell.textLabel.text = [NSString stringWithFormat:@"%d", indexPath.row]; + return cell; +} + +- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { + if (tableView == self.rightSidebarView) { + return @"RightSidebar"; + } + return nil; +} + +#pragma mark UITableViewDelegate + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + [self.navigationController setRevealedState:JTRevealedStateNo]; + if (tableView == self.rightSidebarView) { + self.label.text = [NSString stringWithFormat:@"Selected %d at RightSidebarView", indexPath.row]; + } +} + + +#pragma mark JTRevealSidebarV2Delegate + +- (UIView *)viewForRightSidebar { + CGRect mainFrame = [[UIScreen mainScreen] applicationFrame]; + UITableView *view = self.rightSidebarView; + if ( ! view) { + view = self.rightSidebarView = [[UITableView alloc] initWithFrame:CGRectMake(160, mainFrame.origin.y, 160, mainFrame.size.height) style:UITableViewStyleGrouped]; + view.dataSource = self; + view.delegate = self; + view.backgroundColor = [UIColor groupTableViewBackgroundColor]; + } + return view; +} + +@end diff --git a/JTRevealSidebarDemoV2/SidebarViewController.h b/JTRevealSidebarDemoV2/SidebarViewController.h new file mode 100644 index 0000000..3fe2745 --- /dev/null +++ b/JTRevealSidebarDemoV2/SidebarViewController.h @@ -0,0 +1,26 @@ +// +// LeftSidebarViewController.h +// JTRevealSidebarDemo +// +// Created by James Apple Tang on 12/12/11. +// Copyright (c) 2011 __MyCompanyName__. All rights reserved. +// + +#import + +@protocol SidebarViewControllerDelegate; + +@interface SidebarViewController : UITableViewController + +@property (nonatomic, assign) id sidebarDelegate; + +@end + +@protocol SidebarViewControllerDelegate + +- (void)sidebarViewController:(SidebarViewController *)sidebarViewController didSelectObject:(NSObject *)object atIndexPath:(NSIndexPath *)indexPath; + +@optional +- (NSIndexPath *)lastSelectedIndexPathForSidebarViewController:(SidebarViewController *)sidebarViewController; + +@end diff --git a/JTRevealSidebarDemoV2/SidebarViewController.m b/JTRevealSidebarDemoV2/SidebarViewController.m new file mode 100644 index 0000000..e31e775 --- /dev/null +++ b/JTRevealSidebarDemoV2/SidebarViewController.m @@ -0,0 +1,86 @@ +// +// LeftSidebarViewController.m +// JTRevealSidebarDemo +// +// Created by James Apple Tang on 12/12/11. +// Copyright (c) 2011 __MyCompanyName__. All rights reserved. +// + +#import "SidebarViewController.h" + + +@implementation SidebarViewController +@synthesize sidebarDelegate; + +- (id)initWithStyle:(UITableViewStyle)style +{ + self = [super initWithStyle:style]; + if (self) { + // Custom initialization + } + return self; +} + +#pragma mark - View lifecycle + +- (void)viewDidLoad +{ + [super viewDidLoad]; +} + +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + + if ([self.sidebarDelegate respondsToSelector:@selector(lastSelectedIndexPathForSidebarViewController:)]) { + NSIndexPath *indexPath = [self.sidebarDelegate lastSelectedIndexPathForSidebarViewController:self]; + [self.tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; + } +} + +- (void)viewDidUnload +{ + [super viewDidUnload]; + // Release any retained subviews of the main view. + // e.g. self.myOutlet = nil; +} + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + return 5; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + static NSString *CellIdentifier = @"Cell"; + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; + if (cell == nil) { + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; + } + + cell.textLabel.text = [NSString stringWithFormat:@"ViewController%d", indexPath.row]; + + return cell; +} + +- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { + return self.title; +} + +#pragma mark - Table view delegate + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + if (self.sidebarDelegate) { + NSObject *object = [NSString stringWithFormat:@"ViewController%d", indexPath.row]; + [self.sidebarDelegate sidebarViewController:self didSelectObject:object atIndexPath:indexPath]; + } +} + +@end diff --git a/JTRevealSidebarDemoV2/ViewController.h b/JTRevealSidebarDemoV2/ViewController.h new file mode 100644 index 0000000..c8bdf23 --- /dev/null +++ b/JTRevealSidebarDemoV2/ViewController.h @@ -0,0 +1,21 @@ +// +// ViewController.h +// JTRevealSidebarDemo +// +// Created by James Apple Tang on 7/12/11. +// Copyright (c) 2011 __MyCompanyName__. All rights reserved. +// + +#import +#import "JTRevealSidebarV2Delegate.h" + +@class SidebarViewController; + +@interface ViewController : UIViewController + +@property (nonatomic, strong) SidebarViewController *leftSidebarViewController; +@property (nonatomic, strong) UITableView *rightSidebarView; +@property (nonatomic, strong) NSIndexPath *leftSelectedIndexPath; +@property (nonatomic, strong) UILabel *label; + +@end diff --git a/JTRevealSidebarDemoV2/ViewController.m b/JTRevealSidebarDemoV2/ViewController.m new file mode 100644 index 0000000..e5122f8 --- /dev/null +++ b/JTRevealSidebarDemoV2/ViewController.m @@ -0,0 +1,185 @@ +// +// ViewController.m +// JTRevealSidebarDemo +// +// Created by James Apple Tang on 7/12/11. +// Copyright (c) 2011 __MyCompanyName__. All rights reserved. +// + +#import "ViewController.h" +#import "UIViewController+JTRevealSidebarV2.h" +#import "UINavigationItem+JTRevealSidebarV2.h" +#import "SidebarViewController.h" +#import "NewViewController.h" +#import "JTRevealSidebarV2Delegate.h" + +@interface ViewController (Private) +@end + +@implementation ViewController + +@synthesize leftSidebarViewController; +@synthesize rightSidebarView; +@synthesize leftSelectedIndexPath; +@synthesize label; + +- (id)init { + self = [super init]; + return self; +} + +// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. +- (void)viewDidLoad +{ + [super viewDidLoad]; + + self.view.backgroundColor = [UIColor scrollViewTexturedBackgroundColor]; + + + self.label = [[UILabel alloc] initWithFrame:CGRectMake(30, 50, 260, 30)]; + self.label.backgroundColor = [UIColor clearColor]; + self.label.textColor = [UIColor whiteColor]; + self.label.textAlignment = UITextAlignmentCenter; + [self.view addSubview:self.label]; + + self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"ButtonMenu.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(revealLeftSidebar:)]; + self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize target:self action:@selector(revealRightSidebar:)]; + + UIButton *pushButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; + [pushButton setTitle:@"Push NewViewController" forState:UIControlStateNormal]; + [pushButton sizeToFit]; + [pushButton addTarget:self action:@selector(pushNewViewController:) forControlEvents:UIControlEventTouchUpInside]; + pushButton.frame = (CGRect){60, 150, pushButton.frame.size}; + [self.view addSubview:pushButton]; + + self.navigationItem.revealSidebarDelegate = self; +} + +- (void)viewDidUnload +{ + [super viewDidUnload]; + + self.label = nil; + self.rightSidebarView = nil; +} + +// Doesn't support rotating to other orientation at this moment +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation +{ + // Return YES for supported orientations + return interfaceOrientation == UIInterfaceOrientationPortrait; +} + +#pragma mark Action + +- (void)revealLeftSidebar:(id)sender { + JTRevealedState state = JTRevealedStateLeft; + if (self.navigationController.revealedState == JTRevealedStateLeft) { + state = JTRevealedStateNo; + } + [self.navigationController setRevealedState:state]; +} + +- (void)revealRightSidebar:(id)sender { + JTRevealedState state = JTRevealedStateRight; + if (self.navigationController.revealedState == JTRevealedStateRight) { + state = JTRevealedStateNo; + } + [self.navigationController setRevealedState:state]; +} + +- (void)pushNewViewController:(id)sender { + NewViewController *controller = [[NewViewController alloc] init]; + controller.view.backgroundColor = [UIColor whiteColor]; + controller.title = @"NewViewController"; + [self.navigationController pushViewController:controller animated:YES]; +} + +#pragma mark JTRevealSidebarDelegate + +- (UIView *)viewForLeftSidebar { + CGRect mainFrame = [[UIScreen mainScreen] applicationFrame]; + UITableViewController *controller = self.leftSidebarViewController; + if ( ! controller) { + self.leftSidebarViewController = [[SidebarViewController alloc] init]; + self.leftSidebarViewController.sidebarDelegate = self; + controller = self.leftSidebarViewController; + controller.view.frame = CGRectMake(0, mainFrame.origin.y, 270, mainFrame.size.height); + controller.title = @"LeftSidebarViewController"; + } + return controller.view; +} + +- (UIView *)viewForRightSidebar { + CGRect mainFrame = [[UIScreen mainScreen] applicationFrame]; + UITableView *view = self.rightSidebarView; + if ( ! view) { + view = self.rightSidebarView = [[UITableView alloc] initWithFrame:CGRectMake(50, mainFrame.origin.y, 270, mainFrame.size.height)]; + view.dataSource = self; + view.delegate = self; + } + return view; +} + +@end + + +@implementation ViewController (Private) + +#pragma mark UITableViewDatasource + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return 20; +} + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + static NSString *cellIdentifier = @"CellIdentifier"; + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; + if ( ! cell) { + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; + } + cell.textLabel.text = [NSString stringWithFormat:@"%d", indexPath.row]; + return cell; +} + +- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { + if (tableView == self.rightSidebarView) { + return @"RightSidebar"; + } + return nil; +} + +#pragma mark UITableViewDelegate + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + [self.navigationController setRevealedState:JTRevealedStateNo]; + if (tableView == self.rightSidebarView) { + self.label.text = [NSString stringWithFormat:@"Selected %d at RightSidebarView", indexPath.row]; + } +} + +#pragma mark SidebarViewControllerDelegate + +- (void)sidebarViewController:(SidebarViewController *)sidebarViewController didSelectObject:(NSObject *)object atIndexPath:(NSIndexPath *)indexPath { + + [self.navigationController setRevealedState:JTRevealedStateNo]; + + ViewController *controller = [[ViewController alloc] init]; + controller.view.backgroundColor = [UIColor viewFlipsideBackgroundColor]; + controller.title = (NSString *)object; + controller.leftSidebarViewController = sidebarViewController; + controller.leftSelectedIndexPath = indexPath; + sidebarViewController.sidebarDelegate = controller; + [self.navigationController setViewControllers:[NSArray arrayWithObject:controller] animated:NO]; + +} + +- (NSIndexPath *)lastSelectedIndexPathForSidebarViewController:(SidebarViewController *)sidebarViewController { + return self.leftSelectedIndexPath; +} + +@end \ No newline at end of file diff --git a/JTRevealSidebarDemoV2/en.lproj/InfoPlist.strings b/JTRevealSidebarDemoV2/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/JTRevealSidebarDemoV2/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/JTRevealSidebarDemoV2/main.m b/JTRevealSidebarDemoV2/main.m new file mode 100644 index 0000000..8ed0f59 --- /dev/null +++ b/JTRevealSidebarDemoV2/main.m @@ -0,0 +1,18 @@ +// +// main.m +// JTRevealSidebarDemoV2 +// +// Created by James Apple Tang on 7/12/11. +// Copyright (c) 2011 __MyCompanyName__. All rights reserved. +// + +#import + +#import "AppDelegate.h" + +int main(int argc, char *argv[]) +{ + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/JTRevealSidebarDemoV2Tests/JTRevealSidebarDemoV2Tests-Info.plist b/JTRevealSidebarDemoV2Tests/JTRevealSidebarDemoV2Tests-Info.plist new file mode 100644 index 0000000..1a16235 --- /dev/null +++ b/JTRevealSidebarDemoV2Tests/JTRevealSidebarDemoV2Tests-Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + com.mystcolor.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/JTRevealSidebarDemoV2Tests/JTRevealSidebarDemoV2Tests.h b/JTRevealSidebarDemoV2Tests/JTRevealSidebarDemoV2Tests.h new file mode 100644 index 0000000..d74cc01 --- /dev/null +++ b/JTRevealSidebarDemoV2Tests/JTRevealSidebarDemoV2Tests.h @@ -0,0 +1,13 @@ +// +// JTRevealSidebarDemoV2Tests.h +// JTRevealSidebarDemoV2Tests +// +// Created by James Apple Tang on 7/12/11. +// Copyright (c) 2011 __MyCompanyName__. All rights reserved. +// + +#import + +@interface JTRevealSidebarDemoV2Tests : SenTestCase + +@end diff --git a/JTRevealSidebarDemoV2Tests/JTRevealSidebarDemoV2Tests.m b/JTRevealSidebarDemoV2Tests/JTRevealSidebarDemoV2Tests.m new file mode 100644 index 0000000..42faf9f --- /dev/null +++ b/JTRevealSidebarDemoV2Tests/JTRevealSidebarDemoV2Tests.m @@ -0,0 +1,32 @@ +// +// JTRevealSidebarDemoV2Tests.m +// JTRevealSidebarDemoV2Tests +// +// Created by James Apple Tang on 7/12/11. +// Copyright (c) 2011 __MyCompanyName__. All rights reserved. +// + +#import "JTRevealSidebarDemoV2Tests.h" + +@implementation JTRevealSidebarDemoV2Tests + +- (void)setUp +{ + [super setUp]; + + // Set-up code here. +} + +- (void)tearDown +{ + // Tear-down code here. + + [super tearDown]; +} + +- (void)testExample +{ + STFail(@"Unit tests are not implemented yet in JTRevealSidebarDemoV2Tests"); +} + +@end diff --git a/JTRevealSidebarDemoV2Tests/en.lproj/InfoPlist.strings b/JTRevealSidebarDemoV2Tests/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/JTRevealSidebarDemoV2Tests/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/JTRevealSidebarV2/JTRevealSidebarV2Delegate.h b/JTRevealSidebarV2/JTRevealSidebarV2Delegate.h new file mode 100644 index 0000000..4d653f8 --- /dev/null +++ b/JTRevealSidebarV2/JTRevealSidebarV2Delegate.h @@ -0,0 +1,17 @@ +// +// JTRevealSidebarV2.h +// JTRevealSidebarDemo +// +// Created by James Apple Tang on 8/12/11. +// Copyright (c) 2011 __MyCompanyName__. All rights reserved. +// + +#import + +@protocol JTRevealSidebarV2Delegate + +@optional +- (UIView *)viewForLeftSidebar; +- (UIView *)viewForRightSidebar; + +@end diff --git a/JTRevealSidebarV2/UINavigationItem+JTRevealSidebarV2.h b/JTRevealSidebarV2/UINavigationItem+JTRevealSidebarV2.h new file mode 100644 index 0000000..ca89462 --- /dev/null +++ b/JTRevealSidebarV2/UINavigationItem+JTRevealSidebarV2.h @@ -0,0 +1,17 @@ +// +// UINavigationItem+JTRevealSidebarV2.h +// JTRevealSidebarDemo +// +// Created by James Apple Tang on 8/12/11. +// Copyright (c) 2011 __MyCompanyName__. All rights reserved. +// + +#import + +@protocol JTRevealSidebarV2Delegate; + +@interface UINavigationItem (JTRevealSidebarV2) + +@property (nonatomic, assign) id revealSidebarDelegate; + +@end diff --git a/JTRevealSidebarV2/UINavigationItem+JTRevealSidebarV2.m b/JTRevealSidebarV2/UINavigationItem+JTRevealSidebarV2.m new file mode 100644 index 0000000..18325a6 --- /dev/null +++ b/JTRevealSidebarV2/UINavigationItem+JTRevealSidebarV2.m @@ -0,0 +1,24 @@ +// +// UINavigationItem+JTRevealSidebarV2.m +// JTRevealSidebarDemo +// +// Created by James Apple Tang on 8/12/11. +// Copyright (c) 2011 __MyCompanyName__. All rights reserved. +// + +#import "UINavigationItem+JTRevealSidebarV2.h" +#import + +@implementation UINavigationItem (JTRevealSidebarV2) + +static char *revealSidebarDelegateKey; + +- (void)setRevealSidebarDelegate:(id)revealSidebarDelegate { + objc_setAssociatedObject(self, &revealSidebarDelegateKey, revealSidebarDelegate, OBJC_ASSOCIATION_ASSIGN); +} + +- (id )revealSidebarDelegate { + return (id )objc_getAssociatedObject(self, &revealSidebarDelegateKey); +} + +@end diff --git a/JTRevealSidebarV2/UIViewController+JTRevealSidebarV2.h b/JTRevealSidebarV2/UIViewController+JTRevealSidebarV2.h new file mode 100644 index 0000000..ff8a909 --- /dev/null +++ b/JTRevealSidebarV2/UIViewController+JTRevealSidebarV2.h @@ -0,0 +1,28 @@ +// +// UINavigationController+JTRevealSidebarV2.h +// JTRevealSidebarDemo +// +// Created by James Apple Tang on 8/12/11. +// Copyright (c) 2011 __MyCompanyName__. All rights reserved. +// + +#import + +typedef enum { + JTRevealedStateNo, + JTRevealedStateLeft, + JTRevealedStateRight, +} JTRevealedState; + +@interface UIViewController (JTRevealSidebarV2) + +@property (nonatomic, assign) JTRevealedState revealedState; +- (CGAffineTransform)baseTransform; + +@end + + +@interface UINavigationController (JTRevealSidebarV2) +- (UIViewController *)selectedViewController; +@end + diff --git a/JTRevealSidebarV2/UIViewController+JTRevealSidebarV2.m b/JTRevealSidebarV2/UIViewController+JTRevealSidebarV2.m new file mode 100644 index 0000000..6a01f1d --- /dev/null +++ b/JTRevealSidebarV2/UIViewController+JTRevealSidebarV2.m @@ -0,0 +1,167 @@ +// +// UINavigationController+JTRevealSidebarV2.m +// JTRevealSidebarDemo +// +// Created by James Apple Tang on 8/12/11. +// Copyright (c) 2011 __MyCompanyName__. All rights reserved. +// + +#import "UIViewController+JTRevealSidebarV2.h" +#import "UINavigationItem+JTRevealSidebarV2.h" +#import "JTRevealSidebarV2Delegate.h" +#import + +@interface UIViewController (JTRevealSidebarV2Private) + +- (void)revealLeftSidebar:(BOOL)showLeftSidebar; +- (void)revealRightSidebar:(BOOL)showRightSidebar; + +@end + +@implementation UIViewController (JTRevealSidebarV2) + +static char *revealedStateKey; + +- (void)setRevealedState:(JTRevealedState)revealedState { + + JTRevealedState currentState = self.revealedState; + + objc_setAssociatedObject(self, &revealedStateKey, [NSNumber numberWithInt:revealedState], OBJC_ASSOCIATION_RETAIN); + + switch (currentState) { + case JTRevealedStateNo: + if (revealedState == JTRevealedStateLeft) { + [self revealLeftSidebar:YES]; + } else { + [self revealRightSidebar:YES]; + } + break; + case JTRevealedStateLeft: + if (revealedState == JTRevealedStateNo) { + [self revealLeftSidebar:NO]; + } else { + [self revealLeftSidebar:NO]; + [self revealRightSidebar:YES]; + } + break; + case JTRevealedStateRight: + if (revealedState == JTRevealedStateNo) { + [self revealRightSidebar:NO]; + } else { + [self revealRightSidebar:NO]; + [self revealLeftSidebar:YES]; + } + default: + break; + } +} + +- (JTRevealedState)revealedState { + return (JTRevealedState)[objc_getAssociatedObject(self, &revealedStateKey) intValue]; +} + +- (CGAffineTransform)baseTransform { + CGAffineTransform baseTransform; + switch (self.interfaceOrientation) { + case UIInterfaceOrientationPortrait: + baseTransform = CGAffineTransformIdentity; + break; + case UIInterfaceOrientationLandscapeLeft: + baseTransform = CGAffineTransformMakeRotation(-M_PI/2); + break; + case UIInterfaceOrientationLandscapeRight: + baseTransform = CGAffineTransformMakeRotation(M_PI/2); + break; + default: + baseTransform = CGAffineTransformMakeRotation(M_PI); + break; + } + return baseTransform; +} + +@end + +#define SIDEBAR_VIEW_TAG 10000 + +@implementation UINavigationController (JTRevealSidebarV2Private) + +- (UIViewController *)selectedViewController { + return self; +} + +- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { + UIView *view = [self.view.superview viewWithTag:(int)context]; + [view removeFromSuperview]; +} + +- (void)revealLeftSidebar:(BOOL)showLeftSidebar { + + id delegate = [self selectedViewController].navigationItem.revealSidebarDelegate; + + if ( ! [delegate respondsToSelector:@selector(viewForLeftSidebar)]) { + return; + } + + UIView *revealedView = [delegate viewForLeftSidebar]; + revealedView.tag = SIDEBAR_VIEW_TAG; + + if (showLeftSidebar) { + CGFloat width = CGRectGetWidth(revealedView.frame); + [self.view.superview insertSubview:revealedView belowSubview:self.view]; + + [UIView beginAnimations:@"" context:nil]; + self.view.transform = CGAffineTransformTranslate([self baseTransform], width, 0); + } else { + [UIView beginAnimations:@"hideSidebarView" context:(void *)SIDEBAR_VIEW_TAG]; + self.view.transform = CGAffineTransformTranslate([self baseTransform], 0, 0); + + [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)]; + [UIView setAnimationDelegate:self]; + } + + NSLog(@"%@", NSStringFromCGAffineTransform(self.view.transform)); + + + [UIView commitAnimations]; +} + +- (void)revealRightSidebar:(BOOL)showRightSidebar { + + id delegate = [self selectedViewController].navigationItem.revealSidebarDelegate; + + if ( ! [delegate respondsToSelector:@selector(viewForRightSidebar)]) { + return; + } + + UIView *revealedView = [delegate viewForRightSidebar]; + revealedView.tag = SIDEBAR_VIEW_TAG; + + if (showRightSidebar) { + CGFloat width = CGRectGetWidth(revealedView.frame); + [self.view.superview insertSubview:revealedView belowSubview:self.view]; + + [UIView beginAnimations:@"" context:nil]; + self.view.transform = CGAffineTransformTranslate([self baseTransform], -width, 0); + } else { + [UIView beginAnimations:@"hideSidebarView" context:(void *)SIDEBAR_VIEW_TAG]; + self.view.transform = CGAffineTransformTranslate([self baseTransform], 0, 0); + + [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)]; + [UIView setAnimationDelegate:self]; + } + + NSLog(@"%@", NSStringFromCGAffineTransform(self.view.transform)); + + [UIView commitAnimations]; +} + +@end + + +@implementation UINavigationController (JTRevealSidebarV2) + +- (UIViewController *)selectedViewController { + return self.topViewController; +} + +@end \ No newline at end of file