-
Notifications
You must be signed in to change notification settings - Fork 4
/
STKGroup.h
68 lines (54 loc) · 2.17 KB
/
STKGroup.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
#import <Foundation/Foundation.h>
#import <SpringBoard/SpringBoard.h>
#import "STKTypes.h"
#ifdef __cplusplus
extern "C" {
#endif
extern NSString * const STKGroupCentralIconKey;
extern NSString * const STKGroupLayoutKey;
extern NSString * const STKGroupCoordinateKey;
#ifdef __cplusplus
}
#endif
typedef NS_ENUM(NSInteger, STKGroupState) {
STKGroupStateInvalid = -1,
STKGroupStateNormal,
STKGroupStateEmpty,
STKGroupStateDirty
};
@class STKGroupView, STKGroupLayout;
@protocol STKGroupObserver;
@interface STKGroup : NSObject
- (instancetype)initWithCentralIcon:(SBIcon *)icon layout:(STKGroupLayout *)layout;
- (instancetype)initWithDictionary:(NSDictionary *)repr;
@property (nonatomic, retain) SBIcon *centralIcon;
@property (nonatomic, readonly) STKGroupLayout *layout;
@property (nonatomic, readonly) STKGroupLayout *placeholderLayout;
@property (nonatomic, readonly) NSDictionary *dictionaryRepresentation;
@property (nonatomic, readonly) BOOL hasPlaceholders;
@property (nonatomic, assign) SBIconCoordinate lastKnownCoordinate;
@property (nonatomic, readonly) BOOL empty;
@property (nonatomic, assign) STKGroupState state;
- (void)relayoutForNewCoordinate:(SBIconCoordinate)coordinate;
// Relayouts if `coordinate` != `lastKnownCoordinate`
- (void)forceRelayout;
// Relayouts because YOLO
- (void)replaceIconInSlot:(STKGroupSlot)slot withIcon:(SBIcon *)icon;
// if `icon` is an empty placeholder, it is treated as such internally
- (void)removeIconInSlot:(STKGroupSlot)slot;
- (void)addPlaceholders;
- (void)removePlaceholders;
- (void)finalizeState;
- (void)addObserver:(id<STKGroupObserver>)observer;
- (void)removeObserver:(id<STKGroupObserver>)observer;
@end
@protocol STKGroupObserver <NSObject>
@optional
- (void)group:(STKGroup *)group removedIcon:(SBIcon *)icon inSlot:(STKGroupSlot)slot;
- (void)group:(STKGroup *)group replacedIcon:(SBIcon *)replacedIcon inSlot:(STKGroupSlot)slot withIcon:(SBIcon *)icon;
- (void)groupDidRelayout:(STKGroup *)group;
- (void)groupDidAddPlaceholders:(STKGroup *)group;
- (void)groupWillRemovePlaceholders:(STKGroup *)group;
- (void)groupDidRemovePlaceholders:(STKGroup *)group;
- (void)groupDidFinalizeState:(STKGroup *)group;
@end