-
Notifications
You must be signed in to change notification settings - Fork 279
/
DPLActionDataSource.m
77 lines (53 loc) · 2.08 KB
/
DPLActionDataSource.m
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
#import "DPLActionDataSource.h"
#import "DPLMutableDeepLink.h"
#import "DPLDemoAction.h"
@interface DPLActionDataSource ()
@property (nonatomic, strong) NSArray *actions;
@end
@implementation DPLActionDataSource
- (instancetype)init {
self = [super init];
if (self) {
_actions = @[[self loadBeersAction],
[self loadOktoberfestAction],
[self logHelloWorldAction]];
}
return self;
}
- (DPLDemoAction *)actionAtIndexPath:(NSIndexPath *)indexPath {
return (indexPath.row < [self.actions count]) ? self.actions[indexPath.row] : nil;
}
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.actions count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"action-cell" forIndexPath:indexPath];
DPLDemoAction *demoAction = [self actionAtIndexPath:indexPath];
cell.textLabel.text = demoAction.actionName;
return cell;
}
#pragma mark - Action Construction
- (DPLDemoAction *)loadBeersAction {
DPLMutableDeepLink *link = [[DPLMutableDeepLink alloc] initWithString:@"dpl://beers"];
DPLDemoAction *action = [[DPLDemoAction alloc] init];
action.actionURL = link.URL;
action.actionName = @"Shop: Beers";
return action;
}
- (DPLDemoAction *)loadOktoberfestAction {
DPLMutableDeepLink *link = [[DPLMutableDeepLink alloc] initWithString:@"dpl://dpl.com"];
link.path = @"/product/93598";
DPLDemoAction *action = [[DPLDemoAction alloc] init];
action.actionURL = link.URL;
action.actionName = @"Buy: Shiner Oktoberfest";
return action;
}
- (DPLDemoAction *)logHelloWorldAction {
DPLMutableDeepLink *link = [[DPLMutableDeepLink alloc] initWithString:@"dpl://dpl.com/say/Hello/World"];
DPLDemoAction *action = [[DPLDemoAction alloc] init];
action.actionURL = link.URL;
action.actionName = @"Say: “Hello World”";
return action;
}
@end