blob: 4485316594c68180ad02100d40155e6a29839e85 (
plain)
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
|
// SDLSoftButton.m
//
#import "SDLSoftButton.h"
#import "SDLImage.h"
#import "SDLNames.h"
NS_ASSUME_NONNULL_BEGIN
@implementation SDLSoftButton
- (instancetype)initWithHandler:(nullable SDLRPCNotificationHandler)handler {
self = [self init];
if (!self) {
return nil;
}
_handler = handler;
return self;
}
- (instancetype)initWithType:(SDLSoftButtonType)type text:(nullable NSString *)text image:(nullable SDLImage *)image highlighted:(BOOL)highlighted buttonId:(UInt16)buttonId systemAction:(nullable SDLSystemAction)systemAction handler:(nullable SDLRPCNotificationHandler)handler {
self = [self initWithHandler:handler];
if (!self) {
return nil;
}
self.type = type;
self.text = text;
self.image = image;
self.isHighlighted = @(highlighted);
self.softButtonID = @(buttonId);
self.systemAction = systemAction;
self.handler = handler;
return self;
}
- (void)setType:(SDLSoftButtonType)type {
if (type != nil) {
[store setObject:type forKey:SDLNameType];
} else {
[store removeObjectForKey:SDLNameType];
}
}
- (SDLSoftButtonType)type {
NSObject *obj = [store objectForKey:SDLNameType];
return (SDLSoftButtonType)obj;
}
- (void)setText:(nullable NSString *)text {
if (text != nil) {
[store setObject:text forKey:SDLNameText];
} else {
[store removeObjectForKey:SDLNameText];
}
}
- (nullable NSString *)text {
return [store objectForKey:SDLNameText];
}
- (void)setImage:(nullable SDLImage *)image {
if (image != nil) {
[store setObject:image forKey:SDLNameImage];
} else {
[store removeObjectForKey:SDLNameImage];
}
}
- (nullable SDLImage *)image {
NSObject *obj = [store objectForKey:SDLNameImage];
if (obj == nil || [obj isKindOfClass:SDLImage.class]) {
return (SDLImage *)obj;
} else {
return [[SDLImage alloc] initWithDictionary:(NSDictionary *)obj];
}
}
- (void)setIsHighlighted:(nullable NSNumber<SDLBool> *)isHighlighted {
if (isHighlighted != nil) {
[store setObject:isHighlighted forKey:SDLNameIsHighlighted];
} else {
[store removeObjectForKey:SDLNameIsHighlighted];
}
}
- (nullable NSNumber<SDLBool> *)isHighlighted {
return [store objectForKey:SDLNameIsHighlighted];
}
- (void)setSoftButtonID:(NSNumber<SDLInt> *)softButtonID {
if (softButtonID != nil) {
[store setObject:softButtonID forKey:SDLNameSoftButtonId];
} else {
[store removeObjectForKey:SDLNameSoftButtonId];
}
}
- (NSNumber<SDLInt> *)softButtonID {
return [store objectForKey:SDLNameSoftButtonId];
}
- (void)setSystemAction:(nullable SDLSystemAction)systemAction {
if (systemAction != nil) {
[store setObject:systemAction forKey:SDLNameSystemAction];
} else {
[store removeObjectForKey:SDLNameSystemAction];
}
}
- (nullable SDLSystemAction)systemAction {
NSObject *obj = [store objectForKey:SDLNameSystemAction];
return (SDLSystemAction)obj;
}
@end
NS_ASSUME_NONNULL_END
|