-
Notifications
You must be signed in to change notification settings - Fork 947
/
Copy pathMDCProgressView.h
174 lines (133 loc) · 5.63 KB
/
MDCProgressView.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
// Copyright 2016-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>
NS_ASSUME_NONNULL_BEGIN
/** The animation mode when animating backward progress. */
typedef NS_ENUM(NSInteger, MDCProgressViewBackwardAnimationMode) {
/** Animate negative progress by resetting to 0 and then animating to the new value. */
MDCProgressViewBackwardAnimationModeReset,
/** Animate negative progress by animating from the current value. */
MDCProgressViewBackwardAnimationModeAnimate
};
/** The mode the progress bar is in. */
typedef NS_ENUM(NSInteger, MDCProgressViewMode) {
/** Display the progress in a determinate way. */
MDCProgressViewModeDeterminate,
/** Display the progress in an indeterminate way. */
MDCProgressViewModeIndeterminate
};
/**
A Material linear determinate progress view.
See https://material.io/go/design-progress-indicators
*/
IB_DESIGNABLE
@interface MDCProgressView : UIView
/**
The color shown for the portion of the progress view that is filled.
The default is a blue color.
*/
@property(nonatomic, strong, nullable) UIColor *progressTintColor UI_APPEARANCE_SELECTOR;
/**
An array of CGColorRef objects used to defining the color of each gradient stop.
All colors are spread uniformly across the range.
Setting @c progressTintColor resets this property to @c nil.
The default is nil.
*/
@property(nonatomic, copy, nullable) NSArray<UIColor *> *progressTintColors;
/**
The color shown for the portion of the progress view that is not filled.
The default is a light blue color.
*/
@property(nonatomic, strong, nullable) UIColor *trackTintColor UI_APPEARANCE_SELECTOR;
/**
The corner radius for both the portion of the progress view that is filled and the track.
This is not equivalent to configuring self.layer.cornerRadius; it instead configures the progress
and track views directly.
Under @c MDCProgressViewModeIndeterminate mode, the progress view is fully rounded if this value
is larger than 0.
The default is 0.
*/
@property(nonatomic) CGFloat cornerRadius;
/**
The current progress.
The current progress is represented by a floating-point value between 0.0 and 1.0, inclusive, where
1.0 indicates the completion of the task. The default value is 0.0. Values less than 0.0 and
greater than 1.0 are pinned to those limits.
To animate progress changes, use -setProgress:animated:completion:.
*/
@property(nonatomic, assign) float progress;
/**
If the progress view shows a constant loading animation (MDCProgressViewModeIndeterminate) or is
based on the progress property (MDCProgressViewModeDeterminate).
The default value is MDCProgressViewModeDeterminate.
*/
@property(nonatomic, assign) MDCProgressViewMode mode;
/**
Indicates if the progress view is animating when @c mode is @MDCProgressViewModeIndeterminate.
The default value is NO.
*/
@property(nonatomic, assign, getter=isAnimating) BOOL animating;
/**
The backward progress animation mode.
When animating progress which is lower than the current progress value, this mode
will determine which animation to use. The default is MDCProgressViewBackwardAnimationModeReset.
*/
@property(nonatomic, assign) MDCProgressViewBackwardAnimationMode backwardProgressAnimationMode;
/**
Adjusts the current progress, optionally animating the change.
@param progress The progress to set.
@param animated Whether the change should be animated.
@param completion The completion block executed at the end of the animation.
*/
- (void)setProgress:(float)progress
animated:(BOOL)animated
completion:(void (^__nullable)(BOOL finished))completion;
/**
Changes the hidden state, optionally animating the change.
@param hidden The hidden state to set.
@param animated Whether the change should be animated.
@param completion The completion block executed at the end of the animation.
*/
- (void)setHidden:(BOOL)hidden
animated:(BOOL)animated
completion:(void (^__nullable)(BOOL finished))completion;
/**
Start the progress bar's indeterminate animation.
*/
- (void)startAnimating;
/**
Stop the progress bar's indeterminate animation.
*/
- (void)stopAnimating;
/**
A block that is invoked when the @c MDCProgressView receives a call to @c
traitCollectionDidChange:. The block is called after the call to the superclass.
*/
@property(nonatomic, copy, nullable) void (^traitCollectionDidChangeBlock)
(MDCProgressView *_Nonnull progressView, UITraitCollection *_Nullable previousTraitCollection);
/**
The property that gates the NTC Determinate progress view changes. This enables the stop mark,
rounded corners, and gap.
For accessibility, this should be enabled for most determinate progress indicators. However, it may
be disabled when the determinate track extends the full width of the screen.
The default value is NO.
*/
@property(nonatomic, assign) BOOL enableDeterminateStopMark;
/**
The color shown for the gap(s) between the progress bar(s) and the track.
The default is clearColor, which results in an appearance with no visible gaps.
*/
@property(nonatomic, strong, nullable) UIColor *gapColor UI_APPEARANCE_SELECTOR;
@end
NS_ASSUME_NONNULL_END