Skip to content

Commit 2f629e1

Browse files
committed
Login_Done
1 parent 5064bf0 commit 2f629e1

File tree

7 files changed

+217
-1
lines changed

7 files changed

+217
-1
lines changed

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@
276276
4ED673221A8E0ECC00DF2D1A /* SVWebViewControllerActivityReport.m in Sources */ = {isa = PBXBuildFile; fileRef = 4ED673211A8E0ECC00DF2D1A /* SVWebViewControllerActivityReport.m */; };
277277
4ED673261A8E127100DF2D1A /* SVWebViewControllerActivityReport@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4ED673251A8E127100DF2D1A /* SVWebViewControllerActivityReport@2x.png */; };
278278
4ED673281A8E12F900DF2D1A /* SVWebViewControllerActivityReport-iPad@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4ED673271A8E12F900DF2D1A /* SVWebViewControllerActivityReport-iPad@2x.png */; };
279+
4EDC33CE1AFB4DCC00698315 /* EaseInputTipsView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EDC33CD1AFB4DCC00698315 /* EaseInputTipsView.m */; };
279280
4EDD8F511A36F42200E9E232 /* libXG-SDK.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4EDD8F4D1A36F42200E9E232 /* libXG-SDK.a */; };
280281
4EDD8F521A36F42300E9E232 /* ReleaseNotes.txt in Resources */ = {isa = PBXBuildFile; fileRef = 4EDD8F4E1A36F42200E9E232 /* ReleaseNotes.txt */; };
281282
4EDD8F541A36F4AC00E9E232 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4EDD8F531A36F4AC00E9E232 /* CFNetwork.framework */; };
@@ -1057,6 +1058,8 @@
10571058
4ED673211A8E0ECC00DF2D1A /* SVWebViewControllerActivityReport.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVWebViewControllerActivityReport.m; sourceTree = "<group>"; };
10581059
4ED673251A8E127100DF2D1A /* SVWebViewControllerActivityReport@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "SVWebViewControllerActivityReport@2x.png"; sourceTree = "<group>"; };
10591060
4ED673271A8E12F900DF2D1A /* SVWebViewControllerActivityReport-iPad@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "SVWebViewControllerActivityReport-iPad@2x.png"; sourceTree = "<group>"; };
1061+
4EDC33CC1AFB4DCC00698315 /* EaseInputTipsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EaseInputTipsView.h; sourceTree = "<group>"; };
1062+
4EDC33CD1AFB4DCC00698315 /* EaseInputTipsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EaseInputTipsView.m; sourceTree = "<group>"; };
10601063
4EDD8F4D1A36F42200E9E232 /* libXG-SDK.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = "libXG-SDK.a"; sourceTree = "<group>"; };
10611064
4EDD8F4E1A36F42200E9E232 /* ReleaseNotes.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReleaseNotes.txt; sourceTree = "<group>"; };
10621065
4EDD8F4F1A36F42200E9E232 /* XGPush.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XGPush.h; sourceTree = "<group>"; };
@@ -3015,6 +3018,8 @@
30153018
0AB591AF1AB6D6BE0076C454 /* TweetSendMapAnnotation.m */,
30163019
4E996BCE1ABA774800C704F1 /* EaseUserHeaderView.h */,
30173020
4E996BCF1ABA774800C704F1 /* EaseUserHeaderView.m */,
3021+
4EDC33CC1AFB4DCC00698315 /* EaseInputTipsView.h */,
3022+
4EDC33CD1AFB4DCC00698315 /* EaseInputTipsView.m */,
30183023
);
30193024
path = Views;
30203025
sourceTree = "<group>";
@@ -3849,6 +3854,7 @@
38493854
8E97CEBF1A0CB7E3006F9AD7 /* SMPageControl.m in Sources */,
38503855
8EA6D12A19E240C40076D59C /* Coding_iOS.xcdatamodeld in Sources */,
38513856
8EA6D12D19E240C40076D59C /* ConversationViewController.m in Sources */,
3857+
4EDC33CE1AFB4DCC00698315 /* EaseInputTipsView.m in Sources */,
38523858
4ECE8ADB1A3943E80021E29C /* NSDate+convenience.m in Sources */,
38533859
4E5C06EE1AC4405300F427C5 /* PasswordViewController.m in Sources */,
38543860
4E217F0E1A70EDC700F6DF88 /* SVWebViewController.m in Sources */,

Coding_iOS/Controllers/Login/LoginViewController.m

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
#import <NYXImagesKit/NYXImagesKit.h>
1717
#import <UIImage+BlurredFrame/UIImage+BlurredFrame.h>
1818
#import "UIImageView+WebCache.h"
19-
19+
#import "EaseInputTipsView.h"
2020

2121
@interface LoginViewController ()
2222
@property (assign, nonatomic) BOOL captchaNeeded;
2323
@property (strong, nonatomic) UIButton *loginBtn;
2424
@property (strong, nonatomic) UIActivityIndicatorView *activityIndicator;
2525
@property (strong, nonatomic) UIImageView *iconUserView, *bgBlurredView;
26+
@property (strong, nonatomic) EaseInputTipsView *inputTipsView;
2627
@end
2728

2829
@implementation LoginViewController
@@ -108,6 +109,23 @@ - (void)viewWillAppear:(BOOL)animated{
108109
[self.navigationController setNavigationBarHidden:YES animated:YES];
109110
[self refreshCaptchaNeeded];
110111
}
112+
- (void)viewDidAppear:(BOOL)animated{
113+
[super viewDidAppear:animated];
114+
if (!_inputTipsView) {
115+
_inputTipsView = [EaseInputTipsView tipsViewWithType:EaseInputTipsViewTypeLogin];
116+
_inputTipsView.valueStr = nil;
117+
118+
__weak typeof(self) weakSelf = self;
119+
_inputTipsView.selectedStringBlock = ^(NSString *valueStr){
120+
weakSelf.myLogin.email = valueStr;
121+
[weakSelf.myTableView reloadData];
122+
[weakSelf.view endEditing:YES];
123+
};
124+
UITableViewCell *cell = [_myTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
125+
[_inputTipsView setY:CGRectGetMaxY(cell.frame) - 0.5];
126+
[_myTableView addSubview:_inputTipsView];
127+
}
128+
}
111129

112130
- (void)didReceiveMemoryWarning
113131
{
@@ -152,10 +170,13 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
152170
[cell configWithPlaceholder:@" 电子邮箱/个性后缀" andValue:self.myLogin.email];
153171
cell.textField.secureTextEntry = NO;
154172
cell.textValueChangedBlock = ^(NSString *valueStr){
173+
weakSelf.inputTipsView.valueStr = valueStr;
174+
weakSelf.inputTipsView.active = YES;
155175
weakSelf.myLogin.email = valueStr;
156176
[weakSelf.iconUserView setImage:[UIImage imageNamed:@"icon_user_monkey"]];
157177
};
158178
cell.editDidEndBlock = ^(NSString *textStr){
179+
weakSelf.inputTipsView.active = NO;
159180
[weakSelf refreshIconUserImage:textStr];
160181
};
161182
}else if (indexPath.row == 1){

Coding_iOS/Models/Login.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@
2424
+ (void)setXGAccountWithCurUser;
2525
+ (BOOL)isOwnerOfProjectWithOwnerId:(NSNumber *)owner_id;
2626
+ (User *)userWithGlobaykeyOrEmail:(NSString *)textStr;
27+
+ (NSMutableDictionary *)readLoginDataList;
2728
@end

Coding_iOS/Util/OC_Category/UIView+Common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ typedef NS_ENUM(NSInteger, EaseBlankPageType)
4949
- (void)addLineUp:(BOOL)hasUp andDown:(BOOL)hasDown andColor:(UIColor *)color;
5050
- (void)addLineUp:(BOOL)hasUp andDown:(BOOL)hasDown andColor:(UIColor *)color andLeftSpace:(CGFloat)leftSpace;
5151

52+
- (void)addRoundingCorners:(UIRectCorner)corners cornerRadii:(CGSize)cornerRadii;
53+
5254
- (void)removeViewWithTag:(NSInteger)tag;
5355
- (CGSize)doubleSizeOfFrame;
5456

Coding_iOS/Util/OC_Category/UIView+Common.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,14 @@ - (void)removeViewWithTag:(NSInteger)tag{
214214
}
215215
}
216216

217+
- (void)addRoundingCorners:(UIRectCorner)corners cornerRadii:(CGSize)cornerRadii{
218+
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:cornerRadii];
219+
CAShapeLayer *maskLayer = [CAShapeLayer new];
220+
maskLayer.frame = self.bounds;
221+
maskLayer.path = maskPath.CGPath;
222+
self.layer.mask = maskLayer;
223+
}
224+
217225
- (CGSize)doubleSizeOfFrame{
218226
CGSize size = self.frame.size;
219227
return CGSizeMake(size.width*2, size.height*2);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// EaseInputTipsView.h
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 15/5/7.
6+
// Copyright (c) 2015年 Coding. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
typedef NS_ENUM(NSUInteger, EaseInputTipsViewType) {
12+
EaseInputTipsViewTypeLogin = 0,
13+
EaseInputTipsViewTypeRegister
14+
};
15+
16+
@interface EaseInputTipsView : UIView
17+
@property (strong, nonatomic) NSString *valueStr;
18+
@property (nonatomic, assign, getter=isActive) BOOL active;
19+
@property (nonatomic, assign, readonly) EaseInputTipsViewType type;
20+
21+
@property (nonatomic, copy) void(^selectedStringBlock)(NSString *);
22+
23+
+ (instancetype)tipsViewWithType:(EaseInputTipsViewType)type;
24+
- (instancetype)initWithTipsType:(EaseInputTipsViewType)type;
25+
26+
- (void)refresh;
27+
28+
@end
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
//
2+
// EaseInputTipsView.m
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 15/5/7.
6+
// Copyright (c) 2015年 Coding. All rights reserved.
7+
//
8+
9+
#import "EaseInputTipsView.h"
10+
#import "Login.h"
11+
12+
@interface EaseInputTipsView ()<UITableViewDataSource, UITableViewDelegate>
13+
14+
@property (strong, nonatomic) UITableView *myTableView;
15+
@property (strong, nonatomic) NSArray *dataList;
16+
17+
@property (strong, nonatomic) NSArray *loginAllList, *emailAllList;
18+
19+
@end
20+
21+
@implementation EaseInputTipsView
22+
23+
+ (instancetype)tipsViewWithType:(EaseInputTipsViewType)type{
24+
return [[self alloc] initWithTipsType:type];
25+
}
26+
27+
- (instancetype)initWithTipsType:(EaseInputTipsViewType)type{
28+
self = [super initWithFrame:CGRectMake(kLoginPaddingLeftWidth, 0, kScreen_Width-2*kLoginPaddingLeftWidth, 120)];
29+
if (self) {
30+
[self addRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(2, 2)];
31+
[self setClipsToBounds:YES];
32+
_myTableView = ({
33+
UITableView *tableView = [[UITableView alloc] initWithFrame:self.bounds style:UITableViewStylePlain];
34+
tableView.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.9];
35+
tableView.dataSource = self;
36+
tableView.delegate = self;
37+
tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
38+
[self addSubview:tableView];
39+
[tableView mas_makeConstraints:^(MASConstraintMaker *make) {
40+
make.edges.equalTo(self);
41+
}];
42+
tableView;
43+
});
44+
_type = type;
45+
_active = YES;
46+
}
47+
return self;
48+
}
49+
50+
- (void)refresh{
51+
[self.myTableView reloadData];
52+
self.hidden = self.dataList.count <= 0 || !_active;
53+
}
54+
#pragma mark SetM
55+
56+
- (void)setActive:(BOOL)active{
57+
_active = active;
58+
self.hidden = self.dataList.count <= 0 || !_active;
59+
}
60+
61+
- (void)setValueStr:(NSString *)valueStr{
62+
_valueStr = valueStr;
63+
if (_valueStr.length <= 0) {
64+
self.dataList = nil;
65+
}else if ([_valueStr rangeOfString:@"@"].location == NSNotFound) {
66+
self.dataList = _type == EaseInputTipsViewTypeLogin? [self loginList]: nil;
67+
}else{
68+
self.dataList = [self emailList];
69+
}
70+
[self refresh];
71+
}
72+
73+
- (NSArray *)loginList{
74+
if (_valueStr.length <= 0) {
75+
return nil;
76+
}
77+
NSString *tipStr = [_valueStr copy];
78+
NSMutableArray *list = [NSMutableArray new];
79+
[[self loginAllList] enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL *stop) {
80+
if ([obj rangeOfString:tipStr].location != NSNotFound) {
81+
[list addObject:obj];
82+
}
83+
}];
84+
return list;
85+
}
86+
87+
- (NSArray *)emailList{
88+
if (_valueStr.length <= 0) {
89+
return nil;
90+
}
91+
NSRange range_AT = [_valueStr rangeOfString:@"@"];
92+
if (range_AT.location == NSNotFound) {
93+
return nil;
94+
}
95+
NSString *nameStr = [_valueStr substringToIndex:range_AT.location];
96+
NSString *tipStr = [_valueStr substringFromIndex:range_AT.location + range_AT.length];
97+
NSMutableArray *list = [NSMutableArray new];
98+
[[self emailAllList] enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL *stop) {
99+
if (tipStr.length <= 0 || [obj rangeOfString:tipStr].location != NSNotFound) {
100+
[list addObject:[nameStr stringByAppendingFormat:@"@%@", obj]];
101+
}
102+
}];
103+
return list;
104+
}
105+
106+
- (NSArray *)loginAllList{
107+
if (!_loginAllList) {
108+
_loginAllList = [[Login readLoginDataList] allKeys];
109+
}
110+
return _loginAllList;
111+
}
112+
- (NSArray *)emailAllList{
113+
if (!_emailAllList) {
114+
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";
115+
116+
_emailAllList = [emailListStr componentsSeparatedByString:@", "];
117+
}
118+
return _emailAllList;
119+
}
120+
121+
#pragma mark Table
122+
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
123+
return _dataList.count;
124+
}
125+
126+
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
127+
static NSString *CellIdentifier = @"EaseInputTipsViewCell";
128+
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
129+
if (!cell) {
130+
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
131+
cell.backgroundColor = [UIColor clearColor];
132+
cell.textLabel.font = [UIFont systemFontOfSize:14];
133+
cell.textLabel.textColor = [UIColor colorWithHexString:@"0x222222"];
134+
}
135+
cell.textLabel.text = [_dataList objectAtIndex:indexPath.row];
136+
return cell;
137+
}
138+
139+
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
140+
[tableView deselectRowAtIndexPath:indexPath animated:YES];
141+
if (self.selectedStringBlock && self.dataList.count > indexPath.row) {
142+
self.selectedStringBlock([self.dataList objectAtIndex:indexPath.row]);
143+
}
144+
}
145+
146+
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
147+
return 35;
148+
}
149+
150+
@end

0 commit comments

Comments
 (0)