forked from rnystrom/RNGridMenu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RNGridMenu.h
132 lines (92 loc) · 4.13 KB
/
RNGridMenu.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//
// RNGridMenu.h
// RNGridMenu
//
// Created by Ryan Nystrom on 6/11/13.
// Copyright (c) 2013 Ryan Nystrom. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSInteger, RNGridMenuStyle) {
RNGridMenuStyleGrid,
RNGridMenuStyleList
};
@class RNGridMenu;
@interface RNGridMenuItem : NSObject
@property (nonatomic, readonly) UIImage *image;
@property (nonatomic, readonly) NSString *title;
@property (nonatomic, copy) dispatch_block_t action;
+ (instancetype)emptyItem;
- (instancetype)initWithImage:(UIImage *)image title:(NSString *)title action:(dispatch_block_t)action;
- (instancetype)initWithImage:(UIImage *)image title:(NSString *)title;
- (instancetype)initWithImage:(UIImage *)image;
- (instancetype)initWithTitle:(NSString *)title;
- (BOOL)isEmpty;
@end
@protocol RNGridMenuDelegate <NSObject>
@optional
- (void)gridMenu:(RNGridMenu *)gridMenu willDismissWithSelectedItem:(RNGridMenuItem *)item atIndex:(NSInteger)itemIndex;
- (void)gridMenuWillDismiss:(RNGridMenu *)gridMenu;
@end
@interface RNGridMenu : UIViewController
+ (instancetype)visibleGridMenu;
@property (nonatomic, readonly) UIView *menuView;
// the menu items. Instances of RNGridMenuItem
@property (nonatomic, readonly) NSArray *items;
// An optional delegate to receive information about what items were selected
@property (nonatomic, weak) id<RNGridMenuDelegate> delegate;
// The color that items will be highlighted with on selection.
// default table view selection blue
@property (nonatomic, strong) UIColor *highlightColor;
// The background color of the main view (note this is a UIViewController subclass)
// default black with 0.7 alpha
@property (nonatomic, strong) UIColor *backgroundColor;
// defaults to nil, the path to be applied as a mask to the background image. if this path is set, cornerRadius is ignored
@property (nonatomic, strong) UIBezierPath *backgroundPath;
// defaults to 8 (only applied if backgroundPath == nil)
@property (nonatomic, assign) CGFloat cornerRadius;
// The size of an item
// default {100, 100}
@property (nonatomic, assign) CGSize itemSize;
// The level of blur for the background image. Range is 0.0 to 1.0
// default 0.3
@property (nonatomic, assign) CGFloat blurLevel;
// defaults to nil ( == the whole background gets blurred)
@property (nonatomic, strong) UIBezierPath *blurExclusionPath;
// The time in seconds for the show and dismiss animation
// default 0.25f
@property (nonatomic, assign) CGFloat animationDuration;
// The text color for list items
// default white
@property (nonatomic, strong) UIColor *itemTextColor;
// The font used for list items
// default bold size 14
@property (nonatomic, strong) UIFont *itemFont;
// The text alignment of the item titles
// default center
@property (nonatomic, assign) NSTextAlignment itemTextAlignment;
// The list layout
// default RNGridMenuStyleGrid
@property (nonatomic, assign) RNGridMenuStyle menuStyle;
// An optional header view. Make sure to set the frame height when setting.
@property (nonatomic, strong) UIView *headerView;
// An optional block that gets executed before the gridMenu gets dismissed
@property (nonatomic, copy) dispatch_block_t dismissAction;
// Determine whether or not to bounce in the animation
// default YES
@property (nonatomic, assign) BOOL bounces;
// Initialize the menu with a list of menu items.
// Note: this changes the view to style RNGridMenuStyleList if no images are supplied
- (instancetype)initWithItems:(NSArray *)items;
// Initialize the menu with a list of images. Maintains style RNGridMenuStyleGrid
- (instancetype)initWithImages:(NSArray *)images;
// Initialize the menu with a list of titles. Note: this changes the view to style RNGridMenuStyleList since no images are supplied
- (instancetype)initWithTitles:(NSArray *)titles;
// Show the menu
- (void)showInViewController:(UIViewController *)parentViewController center:(CGPoint)center;
// Dismiss the menu
// This is called when the window is tapped. If tapped inside the view an item will be selected.
// If tapped outside the view, the menu is simply dismissed.
- (void)dismissAnimated:(BOOL)animated;
@end
@interface RNLongPressGestureRecognizer : UILongPressGestureRecognizer
@end