-
Notifications
You must be signed in to change notification settings - Fork 5
/
PWWidgetItemCell.m
103 lines (73 loc) · 2.14 KB
/
PWWidgetItemCell.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
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
//
// ProWidgets
//
// 1.0.0
//
// Created by Alan Yip on 18 Jan 2014
// Copyright 2014 Alan Yip. All rights reserved.
//
#import "PWWidgetItemCell.h"
@implementation PWWidgetItemCell
//////////////////////////////////////////////////////////////////////
+ (PWWidgetItemCellStyle)cellStyle {
return PWWidgetItemCellStyleNone;
}
+ (instancetype)create:(PWTheme *)theme {
PWWidgetItemCellStyle style = [self cellStyle];
UITableViewCellStyle cellStyle;
switch (style) {
case PWWidgetItemCellStyleNone:
default:
cellStyle = UITableViewCellStyleDefault;
break;
case PWWidgetItemCellStyleText:
cellStyle = UITableViewCellStyleDefault;
break;
case PWWidgetItemCellStyleValue:
cellStyle = UITableViewCellStyleValue1;
break;
}
return [[[self alloc] initWithStyle:cellStyle reuseIdentifier:NSStringFromClass(self) theme:theme] autorelease];
}
- (void)layoutSubviews {
[super layoutSubviews];
// re-position the title label
CGRect labelRect = self.textLabel.frame;
labelRect.origin.x = PWDefaultItemCellPadding;
self.textLabel.frame = labelRect;
}
//////////////////////////////////////////////////////////////////////
/**
* Override this method to update delegates of
* some UI elements
**/
- (void)updateItem:(PWWidgetItem *)item {}
//////////////////////////////////////////////////////////////////////
/**
* Override these methods to update appearance
* Change only appearance, no any callback
**/
- (void)setTitle:(NSString *)title {}
- (void)setIcon:(UIImage *)icon {}
- (void)setValue:(id)value {}
//////////////////////////////////////////////////////////////////////
/**
* Override these methods to configure the cell
**/
- (void)willAppear {}
+ (BOOL)contentCanBecomeFirstResponder { return NO; }
- (void)contentSetFirstResponder {}
- (void)contentResignFirstResponder {}
- (BOOL)shouldShowChevron { return NO; }
//////////////////////////////////////////////////////////////////////
- (void)_setItem:(PWWidgetItem *)item {
_item = item;
[self updateItem:item];
}
//////////////////////////////////////////////////////////////////////
- (void)dealloc {
DEALLOCLOG;
_item = nil;
[super dealloc];
}
@end