-
Notifications
You must be signed in to change notification settings - Fork 947
/
Copy pathMDCInkView.h
188 lines (145 loc) · 7.27 KB
/
MDCInkView.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
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
// Copyright 2015-present the Material Components for iOS authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#import <UIKit/UIKit.h>
// TODO(b/151929968): Delete import of delegate headers when client code has been migrated to no
// longer import delegates as transitive dependencies.
#import "MDCInkViewDelegate.h"
API_DEPRECATED_BEGIN(
"🕘 Schedule time to migrate. "
"Use default system highlight behavior instead: go/material-ios-touch-response. "
"This is go/material-ios-migrations#not-scriptable 🕘",
ios(12, 12))
@protocol MDCInkViewDelegate;
/** Completion block signature for all ink animations. */
typedef void (^MDCInkCompletionBlock)(void);
/** Ink styles. */
typedef NS_ENUM(NSInteger, MDCInkStyle) {
/** Ink is clipped to the view's bounds. */
MDCInkStyleBounded,
/** Ink is not clipped to the view's bounds. */
MDCInkStyleUnbounded
};
/**
A UIView that draws and animates the Material Design ink effect for touch interactions.
There are two kinds of ink:
Bounded ink: Ink that spreads from a point and is contained in the bounds of a UI element such as a
button. The ink is visually clipped to the bounds of the UI element. Bounded ink is the most
commonly-used ink in the system. Examples include basic Material buttons, list menu items, and tile
grids.
Unbounded ink: Ink that spreads out from a point "on top" of other UI elements. It typically
reaches a maximum circle radius and then fades, unclipped by other UI elements. Typically used
when interacting with small UI elements such as navigation bar icons or slider "thumb" controls.
Examples include overflow menus, icon toggle buttons, and phone dialer keys.
Note that the two kinds of ink are designed to have different animation parameters, that is,
bounded ink isn't just clipped unbounded ink. Whether the ink is bounded or not depends on the kind
of UI element the user is interacting with.
*/
__deprecated_msg("Please use MDCRippleView instead.") @interface MDCInkView : UIView
/**
Ink view animation delegate. Clients set this delegate to receive updates when ink animations
start and end.
*/
@property(nonatomic, weak, nullable) id<MDCInkViewDelegate> animationDelegate;
/**
The style of ink for this view. Defaults to MDCInkStyleBounded.
Changes only affect subsequent animations, not animations in progress.
*/
@property(nonatomic, assign) MDCInkStyle inkStyle;
/** The foreground color of the ink. The default value is defaultInkColor. */
@property(nonatomic, strong, null_resettable) UIColor *inkColor UI_APPEARANCE_SELECTOR;
/** Default color used for ink if no color is specified. */
@property(nonatomic, strong, readonly, nonnull) UIColor *defaultInkColor;
/**
Maximum radius of the ink. If the radius <= 0 then half the length of the diagonal of self.bounds
is used. This value is ignored if @c inkStyle is set to MDCInkStyleBounded and @c
usesLegacyInkLayer is set to NO.
*/
@property(nonatomic, assign) CGFloat maxRippleRadius;
/**
Use the older legacy version of the ink ripple. Default is YES.
*/
@property(nonatomic, assign) BOOL usesLegacyInkRipple;
/**
Use a custom center for the ink splash. If YES, then customInkCenter is used, otherwise the
center of self.bounds is used. Default is NO.
Affects behavior only if usesLegacyInkRipple is enabled.
*/
@property(nonatomic, assign) BOOL usesCustomInkCenter;
/**
Custom center for the ink splash in the view’s coordinate system.
Affects behavior only if both usesCustomInkCenter and usesLegacyInkRipple are enabled.
*/
@property(nonatomic, assign) CGPoint customInkCenter;
/**
A block that is invoked when the @c MDCInkView receives a call to @c
traitCollectionDidChange:. The block is called after the call to the superclass.
*/
@property(nonatomic, copy, nullable) void (^traitCollectionDidChangeBlock)
(MDCInkView *_Nonnull ink, UITraitCollection *_Nullable previousTraitCollection);
/**
Start the first part of the "press and release" animation at a particular point.
The "press and release" animation begins by fading in the ink ripple when this method is called.
@param point The user interaction position in the view’s coordinate system.
@param completionBlock Block called after the completion of the animation.
*/
- (void)startTouchBeganAnimationAtPoint:(CGPoint)point
completion:(nullable MDCInkCompletionBlock)completionBlock;
/**
Start the second part of the "press and release" animation at a particular point.
The "press and release" animation ends by completing the ink ripple expansion while fading out when
this method is called.
@param point The user interaction position in the view’s coordinate system.
@param completionBlock Block called after the completion of the animation.
*/
- (void)startTouchEndedAnimationAtPoint:(CGPoint)point
completion:(nullable MDCInkCompletionBlock)completionBlock;
/**
Cancel all animations.
@param animated If false, remove the animations immediately.
*/
- (void)cancelAllAnimationsAnimated:(BOOL)animated;
/**
Start the first part of spreading the ink at a particular point.
This begins by fading in the ink ripple when this method is called.
@param point The user interaction position in the view’s coordinate system.
@param animated to add the ink sublayer with animation or not.
@param completionBlock Block called after the completion of the animation.
*/
- (void)startTouchBeganAtPoint:(CGPoint)point
animated:(BOOL)animated
withCompletion:(nullable MDCInkCompletionBlock)completionBlock;
/**
Start the second part of evaporating the ink at a particular point.
This ends by completing the ink ripple expansion while fading out when
this method is called.
@param point The user interaction position in the view’s coordinate system.
@param animated to remove the ink sublayer with animation or not.
@param completionBlock Block called after the completion of the animation.
*/
- (void)startTouchEndAtPoint:(CGPoint)point
animated:(BOOL)animated
withCompletion:(nullable MDCInkCompletionBlock)completionBlock;
/**
Enumerates the given view's subviews for an instance of MDCInkView and returns it if found, or
creates and adds a new instance of MDCInkView if not.
This method is a convenience method for adding ink to an arbitrary view without needing to subclass
the target view. Use this method in situations where you expect there to be many distinct ink views
in existence for a single ink touch controller. Example scenarios include:
- Adding ink to individual collection view/table view cells
This method can be used in your MDCInkTouchController delegate's
-inkTouchController:inkViewAtTouchLocation; implementation.
*/
+ (nonnull MDCInkView *)injectedInkViewForView:(nonnull UIView *)view;
@end
API_DEPRECATED_END