wxr
2020-06-15 b8e94316e41eba72d927d5ca7d931b26139ee8ff
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
//
//  AMPopTip.h
//  AMPopTip
//
//  Created by Andrea Mazzini on 11/07/14.
//  Copyright (c) 2014 Fancy Pixel. All rights reserved.
//
 
#import <UIKit/UIKit.h>
 
/**-----------------------------------------------------------------------------
 * @name AMPopTip Options
 * -----------------------------------------------------------------------------
 */
 
/** @enum AMPopTipDirection
 *
 * Enum that specifies the direction of the poptip.
 */
typedef NS_ENUM(NSInteger, AMPopTipDirection) {
    /** Shows the poptip up */
    AMPopTipDirectionUp,
    /** Shows the poptip down */
    AMPopTipDirectionDown,
    /** Shows the poptip to the left */
    AMPopTipDirectionLeft,
    /** Shows the poptip to the right */
    AMPopTipDirectionRight,
    /** Shows the poptip up, with no arrow */
    AMPopTipDirectionNone
};
 
/** @enum AMPopTipEntranceAnimation
 *
 * Enum that specifies the type of entrance animation. Entrance animations are performed
 * while showing the poptip.
 */
typedef NS_ENUM(NSInteger, AMPopTipEntranceAnimation) {
    /** The poptip scales from 0% to 100% */
    AMPopTipEntranceAnimationScale,
    /** The poptip moves in position from the edge of the screen */
    AMPopTipEntranceAnimationTransition,
    /** No animation */
    AMPopTipEntranceAnimationNone,
    /** The Animation is provided by the user */
    AMPopTipEntranceAnimationCustom
};
 
/** @enum AMPopTipActionAnimation
 *
 * Enum that specifies the type of action animation. Action animations are performed
 * after the poptip is visible and the entrance animation completed.
 */
typedef NS_ENUM(NSInteger, AMPopTipActionAnimation) {
    /** The poptip bounces following its direction */
    AMPopTipActionAnimationBounce,
    /** The poptip floats in place */
    AMPopTipActionAnimationFloat,
    /** The poptip pulsates by changing its size */
    AMPopTipActionAnimationPulse,
    /** No animation */
    AMPopTipActionAnimationNone
};
 
@interface AMPopTip : UIView
 
 
/** Start the popover action animation
 *
 * Starts the popover action animation. Does nothing if the popover wasn't animating in the first place.
 */
- (void)performActionAnimation;
 
/** Stops the popover action animation
 *
 * Stops the popover action animation. Does nothing if the popover wasn't animating in the first place.
 */
- (void)dismissActionAnimation;
 
- (UIBezierPath *)pathWithRect:(CGRect)rect direction:(AMPopTipDirection)direction;
 
- (void)performEntranceAnimation:(void (^)())completion;
 
/**-----------------------------------------------------------------------------
 * @name AMPopTip
 * -----------------------------------------------------------------------------
 */
 
/** Create a popotip
 *
 * Create a new popotip object
 */
+ (instancetype)popTip;
 
/** Show the popover
 *
 * Shows an animated popover in a given view, from a given rectangle.
 * The property isVisible will be set as YES as soon as the popover is added to the given view.
 *
 * @param text The text displayed.
 * @param direction The direction of the popover.
 * @param maxWidth The maximum width of the popover. If the popover won't fit in the given space, this will be overridden.
 * @param view The view that will hold the popover.
 * @param frame The originating frame. The popover's arrow will point to the center of this frame.
 */
- (void)showText:(NSString *)text direction:(AMPopTipDirection)direction maxWidth:(CGFloat)maxWidth inView:(UIView *)view fromFrame:(CGRect)frame;
 
/** Show the popover
 *
 * Shows an animated popover in a given view, from a given rectangle.
 * The property isVisible will be set as YES as soon as the popover is added to the given view.
 *
 * @param text The attributed text displayed.
 * @param direction The direction of the popover.
 * @param maxWidth The maximum width of the popover. If the popover won't fit in the given space, this will be overridden.
 * @param view The view that will hold the popover.
 * @param frame The originating frame. The popover's arrow will point to the center of this frame.
 */
- (void)showAttributedText:(NSAttributedString *)text direction:(AMPopTipDirection)direction maxWidth:(CGFloat)maxWidth inView:(UIView *)view fromFrame:(CGRect)frame;
 
/** Show the popover with a custom view
 *
 * Shows an animated popover in a given view, from a given rectangle.
 * The property isVisible will be set as YES as soon as the popover is added to the given view.
 *
 * @param customView The custom view
 * @param direction The direction of the popover.
 * @param view The view that will hold the popover.
 * @param frame The originating frame. The popover's arrow will point to the center of this frame.
 */
- (void)showCustomView:(UIView *)customView direction:(AMPopTipDirection)direction inView:(UIView *)view fromFrame:(CGRect)frame;
 
/** Show the popover
 *
 * Shows an animated popover in a given view, from a given rectangle.
 * The property isVisible will be set as YES as soon as the popover is added to the given view.
 *
 * @param text The text displayed.
 * @param direction The direction of the popover.
 * @param maxWidth The maximum width of the popover. If the popover won't fit in the given space, this will be overridden.
 * @param view The view that will hold the popover.
 * @param frame The originating frame. The popover's arrow will point to the center of this frame.
 * @param interval The time interval that determines when the poptip will self-dismiss
 */
- (void)showText:(NSString *)text direction:(AMPopTipDirection)direction maxWidth:(CGFloat)maxWidth inView:(UIView *)view fromFrame:(CGRect)frame duration:(NSTimeInterval)interval;
 
/** Show the popover
 *
 * Shows an animated popover in a given view, from a given rectangle.
 * The property isVisible will be set as YES as soon as the popover is added to the given view.
 *
 * @param text The attributed text displayed.
 * @param direction The direction of the popover.
 * @param maxWidth The maximum width of the popover. If the popover won't fit in the given space, this will be overridden.
 * @param view The view that will hold the popover.
 * @param frame The originating frame. The popover's arrow will point to the center of this frame.
 * @param interval The time interval that determines when the poptip will self-dismiss
 */
- (void)showAttributedText:(NSAttributedString *)text direction:(AMPopTipDirection)direction maxWidth:(CGFloat)maxWidth inView:(UIView *)view fromFrame:(CGRect)frame duration:(NSTimeInterval)interval;
 
/** Show the popover with a custom view
 *
 * Shows an animated popover in a given view, from a given rectangle.
 * The property isVisible will be set as YES as soon as the popover is added to the given view.
 *
 * @param customView The custom view
 * @param direction The direction of the popover.
 * @param view The view that will hold the popover.
 * @param frame The originating frame. The popover's arrow will point to the center of this frame.
 * @param interval The time interval that determines when the poptip will self-dismiss
 */
- (void)showCustomView:(UIView *)customView direction:(AMPopTipDirection)direction inView:(UIView *)view fromFrame:(CGRect)frame duration:(NSTimeInterval)interval;
 
/** Hide the popover
 *
 * Hides the popover and removes it from the view.
 * The property isVisible will be set to NO when the animation is complete and the popover is removed from the parent view.
 */
- (void)hide;
 
/** Update the text
 *
 * Set the new text shown in the poptip
 * @param text The new text
 */
- (void)updateText:(NSString *)text;
 
/** Makes the popover perform the action animation
 *
 * Makes the popover perform the action indefinitely. The action animation calls for the user's attention after the popover is shown
 */
- (void)startActionAnimation;
 
/** Stops the popover action animation
 *
 * Stops the popover action animation. Does nothing if the popover wasn't animating in the first place.
 */
- (void)stopActionAnimation;
 
/**-----------------------------------------------------------------------------
* @name AMPopTip Properties
* -----------------------------------------------------------------------------
*/
 
/** Font
 *
 * Holds the UIFont used in the popover
 */
@property (nonatomic, strong) UIFont *font UI_APPEARANCE_SELECTOR;
 
/** Text Color
 *
 * Holds the UIColor of the text
 */
@property (nonatomic, strong) UIColor *textColor UI_APPEARANCE_SELECTOR;
 
/** Text Alignment
 *  Holds the NSTextAlignment of the text
 */
@property (nonatomic, assign) NSTextAlignment textAlignment UI_APPEARANCE_SELECTOR;
 
/** Popover Background Color
 *
 * Holds the UIColor for the popover's background
 */
@property (nonatomic, strong) UIColor *popoverColor UI_APPEARANCE_SELECTOR;
 
/** Popover Border Color
 *
 * Holds the UIColor for the popover's bordedr
 */
@property (nonatomic, strong) UIColor *borderColor UI_APPEARANCE_SELECTOR;
 
/** Popover Border Width
 *
 * Holds the width for the popover's border
 */
@property (nonatomic, assign) CGFloat borderWidth UI_APPEARANCE_SELECTOR;
 
/** Popover border radius
 *
 * Holds the CGFloat with the popover's border radius
 */
@property (nonatomic, assign) CGFloat radius UI_APPEARANCE_SELECTOR;
 
/** Rounded popover
 *
 * Holds the BOOL that determines wether the popover is rounded. If set to YES the radius will equal frame.height / 2
 */
@property (nonatomic, assign, getter=isRounded) BOOL rounded UI_APPEARANCE_SELECTOR;
 
/** Offset from the origin
 *
 * Holds the offset between the popover and origin
 */
@property (nonatomic, assign) CGFloat offset UI_APPEARANCE_SELECTOR;
 
/** Text Padding
 *
 * Holds the CGFloat with the padding used for the inner text
 */
@property (nonatomic, assign) CGFloat padding UI_APPEARANCE_SELECTOR;
 
/** Text EdgeInsets
 *
 * Holds the insets setting for padding different direction
 */
@property (nonatomic, assign) UIEdgeInsets edgeInsets UI_APPEARANCE_SELECTOR;
 
/** Arrow size
 *
 * Holds the CGSize with the width and height of the arrow
 */
@property (nonatomic, assign) CGSize arrowSize UI_APPEARANCE_SELECTOR;
 
/** Revealing Animation time
 *
 * Holds the NSTimeInterval with the duration of the revealing animation
 */
@property (nonatomic, assign) NSTimeInterval animationIn UI_APPEARANCE_SELECTOR;
 
/** Disappearing Animation time
 *
 * Holds the NSTimeInterval with the duration of the disappearing animation
 */
@property (nonatomic, assign) NSTimeInterval animationOut UI_APPEARANCE_SELECTOR;
 
/** Revealing Animation delay
 *
 * Holds the NSTimeInterval with the delay of the revealing animation
 */
@property (nonatomic, assign) NSTimeInterval delayIn UI_APPEARANCE_SELECTOR;
 
/** Disappearing Animation delay
 *
 * Holds the NSTimeInterval with the delay of the disappearing animation
 */
@property (nonatomic, assign) NSTimeInterval delayOut UI_APPEARANCE_SELECTOR;
 
/** Entrance animation type
 *
 * Holds the enum with the type of entrance animation (triggered once the popover is shown)
 */
@property (nonatomic, assign) AMPopTipEntranceAnimation entranceAnimation UI_APPEARANCE_SELECTOR;
 
/** Action animation type
 *
 * Holds the enum with the type of action animation (triggered once the popover is shown)
 */
@property (nonatomic, assign) AMPopTipActionAnimation actionAnimation UI_APPEARANCE_SELECTOR;
 
/** Offset for the float action animation
 *
 * Holds the offset between the popover initial and ending state during the float action animation
 */
@property (nonatomic, assign) CGFloat actionFloatOffset UI_APPEARANCE_SELECTOR;
 
/** Offset for the float action animation
 *
 * Holds the offset between the popover initial and ending state during the float action animation
 */
@property (nonatomic, assign) CGFloat actionBounceOffset UI_APPEARANCE_SELECTOR;
 
/** Offset for the pulse action animation
 *
 * Holds the offset in the popover size during the  pulse action animation
 */
@property (nonatomic, assign) CGFloat actionPulseOffset UI_APPEARANCE_SELECTOR;
 
/** Action Animation time
 *
 * Holds the NSTimeInterval with the duration of the action animation
 */
@property (nonatomic, assign) NSTimeInterval actionAnimationIn UI_APPEARANCE_SELECTOR;
 
/** Action Animation stop time
 *
 * Holds the NSTimeInterval with the duration of the action stop animation
 */
@property (nonatomic, assign) NSTimeInterval actionAnimationOut UI_APPEARANCE_SELECTOR;
 
/** Action Animation delay
 *
 * Holds the NSTimeInterval with the delay of the action animation
 */
@property (nonatomic, assign) NSTimeInterval actionDelayIn UI_APPEARANCE_SELECTOR;
 
/** Action Animation stop delay
 *
 * Holds the NSTimeInterval with the delay of the action animation stop
 */
@property (nonatomic, assign) NSTimeInterval actionDelayOut UI_APPEARANCE_SELECTOR;
 
/** Margin from the left efge
 *
 * CGfloat value that determines the leftmost margin from the screen
 */
@property (nonatomic, assign) CGFloat edgeMargin UI_APPEARANCE_SELECTOR;
 
/** The frame the poptip is pointing to
 *
 * Holds the CGrect with the rect the tip is pointing to
 */
@property (nonatomic, assign) CGRect fromFrame;
 
/** Visibility
 *
 * Holds the readonly BOOL with the popover visiblity. The popover is considered visible as soon as
 * the animation is complete, and invisible when the subview is removed from its parent.
 */
@property (nonatomic, assign, readonly) BOOL isVisible;
 
/** Animating
 *
 * Holds the readonly BOOL with the popover animation state.
 */
@property (nonatomic, assign, readonly) BOOL isAnimating;
 
/** Dismiss on tap
 *
 * A boolean value that determines whether the poptip is dismissed on tap.
 */
@property (nonatomic, assign) BOOL shouldDismissOnTap;
 
/** Dismiss on tap outside
 *
 * A boolean value that determines whether to dismiss when tapping outside the popover.
 */
@property (nonatomic, assign) BOOL shouldDismissOnTapOutside;
 
/** Dismiss on swipe outside
*
* A boolean value that determines whether to dismiss when swiping outside the popover.
*/
@property (nonatomic, assign) BOOL shouldDismissOnSwipeOutside;
 
/** Direction to dismiss on swipe outside
*
* A direction that determines what swipe direction to dismiss when swiping outside the popover.
* The default direction is UISwipeGestureRecognizerDirectionRight if this is not set.
*/
@property (nonatomic, assign) UISwipeGestureRecognizerDirection swipeRemoveGestureDirection;
 
/** Tap handler
 *
 * A block that will be fired when the user taps the popover.
 */
@property (nonatomic, copy) void (^tapHandler)();
 
/** Dismiss handler
 *
 * A block that will be fired when the popover appears.
 */
@property (nonatomic, copy) void (^appearHandler)();
 
/** Dismiss handler
 *
 * A block that will be fired when the popover is dismissed.
 */
@property (nonatomic, copy) void (^dismissHandler)();
 
/** Entrance animation
 *
 * A block block that handles the entrance animation of the poptip. Should be provided
 * when using a AMPopTipActionAnimationCustom entrance animation type.
 * Please note that the poptip will be automatically added as a subview before firing the block
 * Remember to call the completion block provided
 */
@property (nonatomic, copy) void (^entranceAnimationHandler)(void (^completion)(void));
 
/** Arrow position
 *
 * The CGPoint originating the arrow. Read only.
 */
@property (nonatomic, readonly) CGPoint arrowPosition;
 
/** Container View
 *
 * A read only reference to the view containing the poptip
 */
@property (nonatomic, weak, readonly) UIView *containerView;
 
/** Direction
 *
 * The direction from which the poptip is shown. Read only.
 */
@property (nonatomic, assign, readonly) AMPopTipDirection direction;
 
@end