diff --git a/Example/Example/View Controllers/RootViewController.swift b/Example/Example/View Controllers/RootViewController.swift index c4c3363..c8283e4 100644 --- a/Example/Example/View Controllers/RootViewController.swift +++ b/Example/Example/View Controllers/RootViewController.swift @@ -42,7 +42,8 @@ class RootViewController: UITableViewController { // Create menu controller with actions let controller = PopMenuViewController(actions: [ PopMenuDefaultAction(title: "Click me to", image: #imageLiteral(resourceName: "Plus"), color: .yellow), - PopMenuDefaultAction(title: "Pop another menu", image: #imageLiteral(resourceName: "Heart"), color: #colorLiteral(red: 0.9816910625, green: 0.5655395389, blue: 0.4352460504, alpha: 1)) + PopMenuDefaultAction(title: "Pop another menu", image: #imageLiteral(resourceName: "Heart"), color: #colorLiteral(red: 0.9816910625, green: 0.5655395389, blue: 0.4352460504, alpha: 1)), + PopMenuDefaultAction(title: "Try it out!", image: nil, color: .white) ]) // Customize appearance diff --git a/NewPopMenu.podspec b/NewPopMenu.podspec index ac52d5c..eb794aa 100644 --- a/NewPopMenu.podspec +++ b/NewPopMenu.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |spec| spec.name = 'NewPopMenu' - spec.version = '1.0.1' + spec.version = '1.0.2' spec.license = { :type => 'MIT', :file => "LICENSE" } spec.homepage = 'https://github.com/CaliCastle/PopMenu' spec.authors = { 'Cali Castle' => 'cali@calicastle.com' } - spec.summary = 'A cool and customizable menu action sheet for iOS' - spec.source = { :git => 'https://github.com/CaliCastle/PopMenu.git', :tag => 'v1.0.1' } + spec.summary = 'A cool and customizable popup action sheet for iOS' + spec.source = { :git => 'https://github.com/CaliCastle/PopMenu.git', :tag => 'v1.0.2' } spec.source_files = 'PopMenu/**/*.{h,swift}' spec.platform = :ios, "9.0" diff --git a/PopMenu.xcodeproj/project.pbxproj b/PopMenu.xcodeproj/project.pbxproj index 0926789..3605cd6 100644 --- a/PopMenu.xcodeproj/project.pbxproj +++ b/PopMenu.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 8DA31A6B208134EF001498B9 /* PopMenuAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DA31A6A208134EF001498B9 /* PopMenuAction.swift */; }; + 9D0A90382086B2FA008A4700 /* NewPopMenu.podspec in Resources */ = {isa = PBXBuildFile; fileRef = 9D0A90372086B2FA008A4700 /* NewPopMenu.podspec */; }; 9D397A9B20802C1700C58037 /* PopMenu.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9D397A9120802C1600C58037 /* PopMenu.framework */; }; 9D397AA020802C1700C58037 /* PopMenuTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D397A9F20802C1700C58037 /* PopMenuTests.swift */; }; 9D397AA220802C1700C58037 /* PopMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D397A9420802C1600C58037 /* PopMenu.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -35,6 +36,7 @@ /* Begin PBXFileReference section */ 8DA31A6A208134EF001498B9 /* PopMenuAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PopMenuAction.swift; sourceTree = ""; }; + 9D0A90372086B2FA008A4700 /* NewPopMenu.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; fileEncoding = 4; path = NewPopMenu.podspec; sourceTree = SOURCE_ROOT; }; 9D397A9120802C1600C58037 /* PopMenu.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PopMenu.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 9D397A9420802C1600C58037 /* PopMenu.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PopMenu.h; sourceTree = ""; }; 9D397A9520802C1700C58037 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -93,6 +95,7 @@ 9D397A9320802C1600C58037 /* PopMenu */ = { isa = PBXGroup; children = ( + 9D0A90372086B2FA008A4700 /* NewPopMenu.podspec */, 9D397AD320805F3700C58037 /* View Controller & Views */, 9D397AD220805F1800C58037 /* Classes */, 9D397AD120805E8900C58037 /* Transitions */, @@ -246,6 +249,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 9D0A90382086B2FA008A4700 /* NewPopMenu.podspec in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/README.md b/README.md index fe05b53..6fbca80 100644 --- a/README.md +++ b/README.md @@ -234,9 +234,27 @@ menu.setBarButtonItemForSourceView(yourBarButtonItem) ------- -### Action Callback +### Selection Callback -In order to know which action button is tapped, you'll need to comform to `PopMenuViewControllerDelegate` protocol and then implement the method `popMenuDidSelectItem(at index: Int)` in your view controller: +In order to know which action button is tapped, there are two ways of doing that: +- Action Handler +- Delegate + +### Action Handler + +Simply pass the handler when instanstiating the action: + +```swift +let action1 = PopMenuDefaultAction(title: "Action 1", handler: { action in + // action is a `PopMenuAction`, in this case it's a `PopMenuDefaultAction` + + // Print out: 'Action 1 is tapped' + print("\(action.title) is tapped") +}) +``` + +### Delegate Method + You'll need to comform to `PopMenuViewControllerDelegate` protocol and then implement the method `popMenuDidSelectItem(at index: Int)` in your view controller: ```swift class ViewController: UIViewController { @@ -271,6 +289,20 @@ extension ViewController: PopMenuViewControllerDelegate { } ``` +### Dismissal Callback + +If you'd want more control to do additional steps when the menu is dismssed, you can do it like this: + +```swift +// The manager way +manager.popMenuDismissalHandler = { selected in + // `selected` is a bool indicating if a selection has been made + + if !selected { + // When the user tapped outside of the menu + } +} +``` That's basically it! Congrats!