Skip to content

Commit ad2e793

Browse files
author
Olga Konoreva
authored
Merge pull request #20 from handsomecode/develop
SideMenu version 2.0
2 parents 20cb401 + 53a67bd commit ad2e793

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+979
-324
lines changed

CHANGELOG.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Change Log
2+
All notable changes to the library will be documented in this file.
3+
4+
## [Unreleased]
5+
### Added
6+
- UITabBarController and UINavigationController menu items support
7+
- Rotation support
8+
- Public methods documentation in code
9+
- CHANGELOG file
10+
11+
### Changed
12+
- Renamed `showMenu()`/`hideMenu()` methods to `showSideMenu()`/`hideSideMenu()`
13+
- Reworked [Sample](./Sample)
14+
15+
### Fixed
16+
- Customization of spring animation parameters: [Issue #17]
17+
- Displaying horizontal images in [Sample](./Sample)
18+
19+
**Migration notes**
20+
21+
- To mark UIViewController as item of SideMenu you should adopt `SideMenuItemContent` protocol instead of inheritance.
22+
To show menu you should call `showSideMenu()` method from this protocol.
23+
```swift
24+
import InteractiveSideMenu
25+
26+
class KittyViewController: UIViewController, SideMenuItemContent {
27+
28+
@IBAction func openMenu(_ sender: UIButton) {
29+
showSideMenu()
30+
}
31+
}
32+
```
33+
- To customize animation you should now update ```transitionOptions``` property in ```MenuContainerViewColtroller``` class.
34+
```swift
35+
override func viewDidLoad() {
36+
super.viewDidLoad()
37+
let screenSize: CGRect = UIScreen.main.bounds
38+
self.transitionOptions = TransitionOptions(duration: 0.4, visibleContentWidth: screenSize.width / 6)
39+
...
40+
}
41+
```
42+
43+
- Now you have possibility to update customization settings using ```viewWillTransition(to:with:)``` mehod.
44+
```swift
45+
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
46+
super.viewWillTransition(to: size, with: coordinator)
47+
var options = TransitionOptions()
48+
options.duration = size.width < size.height ? 0.4 : 0.6
49+
options.visibleContentWidth = size.width / 6
50+
self.transitionOptions = options
51+
}
52+
```
53+
54+
## 1.0 - 2017-01-23
55+
### Added
56+
- Left SideMenu with possibility to customize menu animation and content
57+
- Sample demonstrating using SideMenu library
58+
- README file
59+
60+
[Unreleased]: https://github.com/handsomecode/InteractiveSideMenu/compare/master...feature/nav_and_tab_controllers_support
61+
[Issue #17]: https://github.com/handsomecode/InteractiveSideMenu/issues/17

InteractiveSideMenu.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "InteractiveSideMenu"
3-
s.version = "1.0"
3+
s.version = "2.0"
44
s.summary = "Interactive Side Menu in Swift"
55
s.homepage = "https://github.com/handsomecode/InteractiveSideMenu"
66
s.license = "Apache 2.0 license"
@@ -13,4 +13,4 @@ Pod::Spec.new do |s|
1313
s.source_files = "Sources/*.swift"
1414

1515
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '3' }
16-
end
16+
end

InteractiveSideMenu.xcodeproj/project.pbxproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
881EF07A1E30FFE40035DEB4 /* Project object */ = {
103103
isa = PBXProject;
104104
attributes = {
105-
LastUpgradeCheck = 0820;
105+
LastUpgradeCheck = 0830;
106106
ORGANIZATIONNAME = Handsome;
107107
TargetAttributes = {
108108
881EF0821E30FFE40035DEB4 = {
@@ -258,12 +258,15 @@
258258
buildSettings = {
259259
CLANG_ENABLE_MODULES = YES;
260260
CODE_SIGN_IDENTITY = "";
261+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
261262
DEFINES_MODULE = YES;
263+
DEVELOPMENT_TEAM = "";
262264
DYLIB_COMPATIBILITY_VERSION = 1;
263265
DYLIB_CURRENT_VERSION = 1;
264266
DYLIB_INSTALL_NAME_BASE = "@rpath";
265267
INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist";
266268
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
269+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
267270
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
268271
PRODUCT_BUNDLE_IDENTIFIER = is.handsome.InteractiveSideMenu;
269272
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -279,11 +282,13 @@
279282
CLANG_ENABLE_MODULES = YES;
280283
CODE_SIGN_IDENTITY = "";
281284
DEFINES_MODULE = YES;
285+
DEVELOPMENT_TEAM = "";
282286
DYLIB_COMPATIBILITY_VERSION = 1;
283287
DYLIB_CURRENT_VERSION = 1;
284288
DYLIB_INSTALL_NAME_BASE = "@rpath";
285289
INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist";
286290
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
291+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
287292
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
288293
PRODUCT_BUNDLE_IDENTIFIER = is.handsome.InteractiveSideMenu;
289294
PRODUCT_NAME = "$(TARGET_NAME)";

InteractiveSideMenu.xcodeproj/xcshareddata/xcschemes/InteractiveSideMenu.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0820"
3+
LastUpgradeVersion = "0830"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

README.md

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ It supports following customization:
1515
- Using spring animation with params customization
1616
- Animation options like animation curve
1717

18+
All these parameters could vary for different orientations.
19+
1820
# Installation
1921

2022
## CocoaPods
@@ -31,12 +33,14 @@ github "handsomecode/InteractiveSideMenu"
3133

3234

3335
# Usage
34-
You should use 3 basic ViewControllers for creating subclasses for implementing your side menu.
36+
To implement your side menu you should create subclasses of basic View Controllers.
3537
- ```MenuContainerViewController``` is a host for menu and content views
3638
- ```MenuViewController``` is a container for menu view
37-
- ```MenuItemContentControlller``` is a container for content that corresponds menu item
3839

39-
To setup your side menu you shoud do 3 things:
40+
Also, ensure that every menu item ViewController adopts relevant protocol.
41+
- ```SideMenuItemContent``` is a ViewController's protocol for data that corresponds menu item
42+
43+
To setup your side menu you need to do three things:
4044
- Provide implementation of base ```MenuViewController``` and assing it to ```menuViewController``` property
4145
- Provide implementation of menu content and assing array of content controllers to ```contentViewControllers``` property
4246
- Select initial content controller by calling ```selectContentViewController(_ selectedContentVC: MenuItemContentViewController)```
@@ -48,11 +52,8 @@ class HostViewController: MenuContainerViewController {
4852

4953
override func viewDidLoad() {
5054
super.viewDidLoad()
51-
5255
menuViewController = self.storyboard!.instantiateViewController(withIdentifier: "NavigationMenu") as! MenuViewController
53-
54-
contentViewControllers = contentControllers()
55-
56+
contentViewControllers = contentControllers()
5657
selectContentViewController(contentViewControllers.first!)
5758
}
5859

@@ -61,40 +62,53 @@ class HostViewController: MenuContainerViewController {
6162
contentList.append(self.storyboard?.instantiateViewController(withIdentifier: "First") as! MenuItemContentViewController)
6263
contentList.append(self.storyboard?.instantiateViewController(withIdentifier: "Second") as! MenuItemContentViewController)
6364
return contentList
64-
}
65+
}
6566
}
6667
```
6768

68-
To show menu you should call ```showMenu()``` method that is available in MenuItemContentViewController class.
69+
To show menu, call ```showSideMenu()``` method from `SideMenuItemContent` protocol.
6970
```swift
7071
import InteractiveSideMenu
7172

72-
class FirstViewController: MenuItemContentViewController {
73+
class KittyViewController: UIViewController, SideMenuItemContent {
7374

74-
@IBAction func didOpenMenu(_ sender: UIButton) {
75-
showMenu()
75+
@IBAction func openMenu(_ sender: UIButton) {
76+
showSideMenu()
7677
}
7778
}
7879
```
7980

80-
To change content view you should choose desired content controller and hide menu.
81+
To change content view, choose desired content controller and hide menu.
8182
```swift
82-
let index = 2 // second menu item
83-
guard let menuContainerViewController = self.menuContainerViewController else { return }
84-
let contentController = menuContainerViewController.contentViewControllers[index]
85-
menuContainerViewController.selectContentViewController(contentController)
86-
menuContainerViewController.hideMenu()
83+
let index = 2 // second menu item
84+
guard let menuContainerViewController = self.menuContainerViewController else { return }
85+
let contentController = menuContainerViewController.contentViewControllers[index]
86+
menuContainerViewController.selectContentViewController(contentController)
87+
menuContainerViewController.hideMenu()
8788
```
8889

89-
To customize animation for menu opening or closing you should override ```menuTransitionOptionsBuilder()``` method that is available in ```MenuContainerViewColtroller``` class.
90+
To customize animation for menu opening or closing, update ```transitionOptions``` property that is available in ```MenuContainerViewColtroller``` class. Initial setup could be done, for example, on controller's ```viewDidLoad()```.
9091
```swift
91-
override func menuTransitionOptionsBuilder() -> TransitionOptionsBuilder? {
92-
return TransitionOptionsBuilder() { builder in
93-
builder.duration = 0.5
94-
builder.contentScale = 1
95-
}
92+
override func viewDidLoad() {
93+
super.viewDidLoad()
94+
let screenSize: CGRect = UIScreen.main.bounds
95+
self.transitionOptions = TransitionOptions(duration: 0.4, visibleContentWidth: screenSize.width / 6)
96+
...
9697
}
97-
```
98+
```
99+
100+
Also, you have possibility to update customization settings, e.g. set another options for landscape orientation. To do it, override ```viewWillTransition(to:with:)``` mehod and add desired parameters to ```transitionOptions``` property.
101+
```swift
102+
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
103+
super.viewWillTransition(to: size, with: coordinator)
104+
var options = TransitionOptions()
105+
options.duration = size.width < size.height ? 0.4 : 0.6
106+
options.visibleContentWidth = size.width / 6
107+
self.transitionOptions = options
108+
}
109+
```
110+
111+
Transition options could be used to set different parameters for Compact and Regular sizes as well. Implement ViewController's ```traitCollectionDidChange(_: )``` method to add these settings.
98112

99113
See [Sample](./Sample) for more details.
100114

Sample/Sample.xcodeproj/project.pbxproj

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
881EF0AD1E3102E30035DEB4 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 881EF0AB1E3102E30035DEB4 /* Main.storyboard */; };
1212
881EF0AF1E3102E30035DEB4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 881EF0AE1E3102E30035DEB4 /* Assets.xcassets */; };
1313
881EF0B21E3102E30035DEB4 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 881EF0B01E3102E30035DEB4 /* LaunchScreen.storyboard */; };
14-
881EF0BD1E31037D0035DEB4 /* FirstViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881EF0B91E31037D0035DEB4 /* FirstViewController.swift */; };
14+
881EF0BD1E31037D0035DEB4 /* KittyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881EF0B91E31037D0035DEB4 /* KittyViewController.swift */; };
1515
881EF0BE1E31037D0035DEB4 /* HostViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881EF0BA1E31037D0035DEB4 /* HostViewController.swift */; };
1616
881EF0BF1E31037D0035DEB4 /* NavigationMenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881EF0BB1E31037D0035DEB4 /* NavigationMenuViewController.swift */; };
17-
881EF0C01E31037D0035DEB4 /* SecondViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881EF0BC1E31037D0035DEB4 /* SecondViewController.swift */; };
17+
9A15C5481EDD62BC00C4FD75 /* InteractiveSideMenu.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 881EF0C71E31049C0035DEB4 /* InteractiveSideMenu.framework */; };
18+
9A15C5491EDD62BC00C4FD75 /* InteractiveSideMenu.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 881EF0C71E31049C0035DEB4 /* InteractiveSideMenu.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
19+
9A6755031EA8E30C00F0C71D /* TabBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A6755021EA8E30C00F0C71D /* TabBarViewController.swift */; };
1820
/* End PBXBuildFile section */
1921

2022
/* Begin PBXContainerItemProxy section */
@@ -32,27 +34,49 @@
3234
remoteGlobalIDString = 881EF0821E30FFE40035DEB4;
3335
remoteInfo = InteractiveSideMenu;
3436
};
37+
9A15C54A1EDD62BC00C4FD75 /* PBXContainerItemProxy */ = {
38+
isa = PBXContainerItemProxy;
39+
containerPortal = 881EF0C21E31049C0035DEB4 /* InteractiveSideMenu.xcodeproj */;
40+
proxyType = 1;
41+
remoteGlobalIDString = 881EF0821E30FFE40035DEB4;
42+
remoteInfo = InteractiveSideMenu;
43+
};
3544
/* End PBXContainerItemProxy section */
3645

46+
/* Begin PBXCopyFilesBuildPhase section */
47+
9A15C54C1EDD62BC00C4FD75 /* Embed Frameworks */ = {
48+
isa = PBXCopyFilesBuildPhase;
49+
buildActionMask = 2147483647;
50+
dstPath = "";
51+
dstSubfolderSpec = 10;
52+
files = (
53+
9A15C5491EDD62BC00C4FD75 /* InteractiveSideMenu.framework in Embed Frameworks */,
54+
);
55+
name = "Embed Frameworks";
56+
runOnlyForDeploymentPostprocessing = 0;
57+
};
58+
/* End PBXCopyFilesBuildPhase section */
59+
3760
/* Begin PBXFileReference section */
3861
881EF0A41E3102E30035DEB4 /* Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sample.app; sourceTree = BUILT_PRODUCTS_DIR; };
3962
881EF0A71E3102E30035DEB4 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
4063
881EF0AC1E3102E30035DEB4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
4164
881EF0AE1E3102E30035DEB4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4265
881EF0B11E3102E30035DEB4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
4366
881EF0B31E3102E30035DEB4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
44-
881EF0B91E31037D0035DEB4 /* FirstViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FirstViewController.swift; sourceTree = "<group>"; };
67+
881EF0B91E31037D0035DEB4 /* KittyViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KittyViewController.swift; sourceTree = "<group>"; };
4568
881EF0BA1E31037D0035DEB4 /* HostViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = HostViewController.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
4669
881EF0BB1E31037D0035DEB4 /* NavigationMenuViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationMenuViewController.swift; sourceTree = "<group>"; };
47-
881EF0BC1E31037D0035DEB4 /* SecondViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SecondViewController.swift; sourceTree = "<group>"; };
4870
881EF0C21E31049C0035DEB4 /* InteractiveSideMenu.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = InteractiveSideMenu.xcodeproj; path = ../InteractiveSideMenu.xcodeproj; sourceTree = "<group>"; };
71+
9A6755021EA8E30C00F0C71D /* TabBarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TabBarViewController.swift; sourceTree = "<group>"; };
4972
/* End PBXFileReference section */
5073

5174
/* Begin PBXFrameworksBuildPhase section */
5275
881EF0A11E3102E30035DEB4 /* Frameworks */ = {
5376
isa = PBXFrameworksBuildPhase;
5477
buildActionMask = 2147483647;
5578
files = (
79+
9A15C5481EDD62BC00C4FD75 /* InteractiveSideMenu.framework in Frameworks */,
5680
);
5781
runOnlyForDeploymentPostprocessing = 0;
5882
};
@@ -94,8 +118,8 @@
94118
881EF0C11E3103A80035DEB4 /* MenuContentScreens */ = {
95119
isa = PBXGroup;
96120
children = (
97-
881EF0B91E31037D0035DEB4 /* FirstViewController.swift */,
98-
881EF0BC1E31037D0035DEB4 /* SecondViewController.swift */,
121+
881EF0B91E31037D0035DEB4 /* KittyViewController.swift */,
122+
9A6755021EA8E30C00F0C71D /* TabBarViewController.swift */,
99123
);
100124
name = MenuContentScreens;
101125
sourceTree = "<group>";
@@ -118,11 +142,13 @@
118142
881EF0A01E3102E30035DEB4 /* Sources */,
119143
881EF0A11E3102E30035DEB4 /* Frameworks */,
120144
881EF0A21E3102E30035DEB4 /* Resources */,
145+
9A15C54C1EDD62BC00C4FD75 /* Embed Frameworks */,
121146
);
122147
buildRules = (
123148
);
124149
dependencies = (
125150
881EF0C91E3104AD0035DEB4 /* PBXTargetDependency */,
151+
9A15C54B1EDD62BC00C4FD75 /* PBXTargetDependency */,
126152
);
127153
name = Sample;
128154
productName = Sample;
@@ -197,10 +223,10 @@
197223
isa = PBXSourcesBuildPhase;
198224
buildActionMask = 2147483647;
199225
files = (
200-
881EF0C01E31037D0035DEB4 /* SecondViewController.swift in Sources */,
201-
881EF0BD1E31037D0035DEB4 /* FirstViewController.swift in Sources */,
226+
881EF0BD1E31037D0035DEB4 /* KittyViewController.swift in Sources */,
202227
881EF0BE1E31037D0035DEB4 /* HostViewController.swift in Sources */,
203228
881EF0BF1E31037D0035DEB4 /* NavigationMenuViewController.swift in Sources */,
229+
9A6755031EA8E30C00F0C71D /* TabBarViewController.swift in Sources */,
204230
881EF0A81E3102E30035DEB4 /* AppDelegate.swift in Sources */,
205231
);
206232
runOnlyForDeploymentPostprocessing = 0;
@@ -213,6 +239,11 @@
213239
name = InteractiveSideMenu;
214240
targetProxy = 881EF0C81E3104AD0035DEB4 /* PBXContainerItemProxy */;
215241
};
242+
9A15C54B1EDD62BC00C4FD75 /* PBXTargetDependency */ = {
243+
isa = PBXTargetDependency;
244+
name = InteractiveSideMenu;
245+
targetProxy = 9A15C54A1EDD62BC00C4FD75 /* PBXContainerItemProxy */;
246+
};
216247
/* End PBXTargetDependency section */
217248

218249
/* Begin PBXVariantGroup section */
@@ -329,8 +360,10 @@
329360
881EF0B71E3102E30035DEB4 /* Debug */ = {
330361
isa = XCBuildConfiguration;
331362
buildSettings = {
363+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
332364
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
333365
INFOPLIST_FILE = Sample/Info.plist;
366+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
334367
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
335368
PRODUCT_BUNDLE_IDENTIFIER = is.handsome.Sample;
336369
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -341,8 +374,10 @@
341374
881EF0B81E3102E30035DEB4 /* Release */ = {
342375
isa = XCBuildConfiguration;
343376
buildSettings = {
377+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
344378
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
345379
INFOPLIST_FILE = Sample/Info.plist;
380+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
346381
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
347382
PRODUCT_BUNDLE_IDENTIFIER = is.handsome.Sample;
348383
PRODUCT_NAME = "$(TARGET_NAME)";

0 commit comments

Comments
 (0)