FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Coding-iOS/Coding_iOS/Views/EaseInputTipsView.m at master · feihuohua/Coding-iOS · GitHub
feihuohua
/
Coding-iOS
Public
forked from
coding/Coding-iOS
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Coding-iOS
/
Coding_iOS
/
Views
/
EaseInputTipsView.m
Copy path
More file actions
More file actions
Latest commit
History
History
History
166 lines (143 loc) · 5.83 KB
Breadcrumbs
Coding-iOS
/
Coding_iOS
/
Views
/
EaseInputTipsView.m
Copy path
File metadata and controls
166 lines (143 loc) · 5.83 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
//
//
EaseInputTipsView.m
//
Coding_iOS
//
//
Created by Ease on 15/5/7.
//
Copyright (c) 2015年 Coding. All rights reserved.
//
#
import
"
EaseInputTipsView.h
"
#
import
"
Login.h
"
@interface
EaseInputTipsView
()<UITableViewDataSource, UITableViewDelegate>
@property
(
strong
,
nonatomic
) UITableView *myTableView;
@property
(
strong
,
nonatomic
)
NSArray
*dataList;
@property
(
strong
,
nonatomic
)
NSArray
*loginAllList, *emailAllList;
@end
@implementation
EaseInputTipsView
+ (
instancetype
)
tipsViewWithType
:
(EaseInputTipsViewType)
type
{
return
[[
self
alloc
]
initWithTipsType:
type];
}
- (
instancetype
)
initWithTipsType
:
(EaseInputTipsViewType)
type
{
CGFloat padingWith =
0.0
;
self = [
super
initWithFrame:
CGRectMake
(padingWith,
0
,
kScreen_Width
-
2
*padingWith,
120
)];
if
(self) {
[
self
addRoundingCorners:
UIRectCornerBottomLeft | UIRectCornerBottomRight
cornerRadii:
CGSizeMake
(
2
,
2
)];
[
self
setClipsToBounds:
YES
];
_myTableView = ({
UITableView *tableView = [[UITableView
alloc
]
initWithFrame:
self
.bounds
style:
UITableViewStylePlain];
tableView.
backgroundColor
= [UIColor
colorWithWhite:
1.0
alpha:
0.95
];
tableView.
dataSource
= self;
tableView.
delegate
= self;
tableView.
separatorStyle
= UITableViewCellSeparatorStyleNone;
[
self
addSubview:
tableView];
[tableView
mas_makeConstraints:
^(MASConstraintMaker *make) {
make.
edges
.
equalTo
(self);
}];
tableView.
tableFooterView
= [UIView
new
];
tableView.
estimatedRowHeight
=
0
;
tableView.
estimatedSectionHeaderHeight
=
0
;
tableView.
estimatedSectionFooterHeight
=
0
;
tableView;
});
_type = type;
_active =
YES
;
}
return
self;
}
- (
void
)
refresh
{
[
self
.myTableView
reloadData
];
self.
hidden
= self.
dataList
.
count
<=
0
|| !_active;
}
#
pragma mark
SetM
- (
void
)
setActive
:
(
BOOL
)
active
{
_active = active;
self.
hidden
= self.
dataList
.
count
<=
0
|| !_active;
}
- (
void
)
setValueStr
:
(
NSString
*)
valueStr
{
_valueStr = [valueStr
lowercaseString
];
if
(_valueStr.
length
<=
0
) {
self.
dataList
=
nil
;
}
else
if
([_valueStr
rangeOfString:
@"
@
"
].
location
==
NSNotFound
) {
self.
dataList
= _type == EaseInputTipsViewTypeLogin? [
self
loginList
]:
nil
;
}
else
{
self.
dataList
= [
self
emailList
];
}
[
self
refresh
];
}
- (
NSArray
*)
loginList
{
if
(_valueStr.
length
<=
0
) {
return
nil
;
}
NSString
*tipStr = [_valueStr
copy
];
NSMutableArray
*list = [
NSMutableArray
new
];
[[
self
loginAllList
]
enumerateObjectsUsingBlock:
^(
NSString
*obj,
NSUInteger
idx,
BOOL
*stop) {
if
([obj
rangeOfString:
tipStr].
location
!=
NSNotFound
) {
[list
addObject:
obj];
}
}];
return
list;
}
- (
NSArray
*)
emailList
{
if
(_valueStr.
length
<=
0
) {
return
nil
;
}
NSRange
range_AT = [_valueStr
rangeOfString:
@"
@
"
];
if
(range_AT.
location
==
NSNotFound
) {
return
nil
;
}
NSString
*nameStr = [_valueStr
substringToIndex:
range_AT.location];
NSString
*tipStr = [_valueStr
substringFromIndex:
range_AT.location + range_AT.length];
NSMutableArray
*list = [
NSMutableArray
new
];
[[
self
emailAllList
]
enumerateObjectsUsingBlock:
^(
NSString
*obj,
NSUInteger
idx,
BOOL
*stop) {
if
(tipStr.
length
<=
0
|| [obj
rangeOfString:
tipStr].
location
!=
NSNotFound
) {
[list
addObject:
[nameStr
stringByAppendingFormat:
@"
@
%@
"
, obj]];
}
}];
return
list;
}
- (
NSArray
*)
loginAllList
{
if
(!_loginAllList) {
_loginAllList = [[Login
readLoginDataList
]
allKeys
];
}
return
_loginAllList;
}
- (
NSArray
*)
emailAllList
{
if
(!_emailAllList) {
NSString
*emailListStr =
@"
qq.com, 163.com, gmail.com, 126.com, sina.com, sohu.com, hotmail.com, tom.com, sina.cn, foxmail.com, yeah.net, vip.qq.com, 139.com, live.cn, outlook.com, aliyun.com, yahoo.com, live.com, icloud.com, msn.com, 21cn.com, 189.cn, me.com, vip.sina.com, msn.cn, sina.com.cn
"
;
_emailAllList = [emailListStr
componentsSeparatedByString:
@"
,
"
];
}
return
_emailAllList;
}
#
pragma mark
Table
- (
NSInteger
)
tableView
:
(UITableView *)
tableView
numberOfRowsInSection
:
(
NSInteger
)
section
{
return
_dataList.
count
;
}
- (UITableViewCell *)
tableView
:
(UITableView *)
tableView
cellForRowAtIndexPath
:
(
NSIndexPath
*)
indexPath
{
static
NSString
*CellIdentifier =
@"
EaseInputTipsViewCell
"
;
NSInteger
labelTag =
99
;
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:
CellIdentifier];
if
(!cell) {
cell = [[UITableViewCell
alloc
]
initWithStyle:
UITableViewCellStyleDefault
reuseIdentifier:
CellIdentifier];
cell.
backgroundColor
= [UIColor
clearColor
];
UILabel *label = [[UILabel
alloc
]
initWithFrame:
CGRectMake
(
kLoginPaddingLeftWidth
,
0
,
kScreen_Width
-
2
*
kLoginPaddingLeftWidth
,
35
)];
label.
font
= [UIFont
systemFontOfSize:
14
];
label.
tag
= labelTag;
[cell.contentView
addSubview:
label];
}
UILabel *label = (UILabel *)[cell.contentView
viewWithTag:
labelTag];
label.
textColor
=
kColorDark7
;
label.
text
= [_dataList
objectAtIndex:
indexPath.row];
return
cell;
}
- (
void
)
tableView
:
(UITableView *)
tableView
willDisplayCell
:
(UITableViewCell *)
cell
forRowAtIndexPath
:
(
NSIndexPath
*)
indexPath
{
[tableView
addLineforPlainCell:
cell
forRowAtIndexPath:
indexPath
withLeftSpace:
kLoginPaddingLeftWidth
hasSectionLine:
NO
];
}
- (
void
)
tableView
:
(UITableView *)
tableView
didSelectRowAtIndexPath
:
(
NSIndexPath
*)
indexPath
{
[tableView
deselectRowAtIndexPath:
indexPath
animated:
YES
];
if
(self.
selectedStringBlock
&& self.
dataList
.
count
> indexPath.
row
) {
self.
selectedStringBlock
([
self
.dataList
objectAtIndex:
indexPath.row]);
}
}
- (CGFloat)
tableView
:
(UITableView *)
tableView
heightForRowAtIndexPath
:
(
NSIndexPath
*)
indexPath
{
return
35
;
}
@end
Back
|
FazBrowse Home
|
New Git URL