Skip to content

Commit c1343af

Browse files
committed
完成接口部分,UI部分调整
1 parent 29d5b34 commit c1343af

14 files changed

Lines changed: 245 additions & 28 deletions

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@
588588
8EF83F8A19E92AA500E86DE7 /* SettingTagsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EF83F8919E92AA500E86DE7 /* SettingTagsViewController.m */; };
589589
8EF83F8C19E931D200E86DE7 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 8EF83F8B19E931D200E86DE7 /* [email protected] */; };
590590
8EF83F9419EB78CC00E86DE7 /* SettingTextViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EF83F9319EB78CC00E86DE7 /* SettingTextViewController.m */; };
591+
B93D904B1ACBA3110057A6EE /* ProjectDeleteAlertControllerVisualStyle.m in Sources */ = {isa = PBXBuildFile; fileRef = B93D904A1ACBA3110057A6EE /* ProjectDeleteAlertControllerVisualStyle.m */; };
591592
B94C1B691AC945D30000C271 /* NewProjectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B94C1B681AC945D30000C271 /* NewProjectViewController.m */; };
592593
B94C1B6B1AC945FB0000C271 /* NewProject.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B94C1B6A1AC945FB0000C271 /* NewProject.storyboard */; };
593594
B94C1B6E1AC98CCE0000C271 /* NewProjectTypeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B94C1B6D1AC98CCE0000C271 /* NewProjectTypeViewController.m */; };
@@ -1497,6 +1498,8 @@
14971498
8EF83F8B19E931D200E86DE7 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
14981499
8EF83F9219EB78CC00E86DE7 /* SettingTextViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingTextViewController.h; sourceTree = "<group>"; };
14991500
8EF83F9319EB78CC00E86DE7 /* SettingTextViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SettingTextViewController.m; sourceTree = "<group>"; };
1501+
B93D90491ACBA3110057A6EE /* ProjectDeleteAlertControllerVisualStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProjectDeleteAlertControllerVisualStyle.h; sourceTree = "<group>"; };
1502+
B93D904A1ACBA3110057A6EE /* ProjectDeleteAlertControllerVisualStyle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProjectDeleteAlertControllerVisualStyle.m; sourceTree = "<group>"; };
15001503
B94C1B671AC945D30000C271 /* NewProjectViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewProjectViewController.h; sourceTree = "<group>"; };
15011504
B94C1B681AC945D30000C271 /* NewProjectViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NewProjectViewController.m; sourceTree = "<group>"; };
15021505
B94C1B6A1AC945FB0000C271 /* NewProject.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = NewProject.storyboard; sourceTree = "<group>"; };
@@ -3058,6 +3061,8 @@
30583061
B9A00D811ACA3A17008BA008 /* ProjectSettingViewController.m */,
30593062
B9A00D831ACA3A55008BA008 /* ProjectAdvancedSettingViewController.h */,
30603063
B9A00D841ACA3A55008BA008 /* ProjectAdvancedSettingViewController.m */,
3064+
B93D90491ACBA3110057A6EE /* ProjectDeleteAlertControllerVisualStyle.h */,
3065+
B93D904A1ACBA3110057A6EE /* ProjectDeleteAlertControllerVisualStyle.m */,
30613066
);
30623067
path = ProjectSetting;
30633068
sourceTree = "<group>";
@@ -3094,7 +3099,6 @@
30943099
ORGANIZATIONNAME = Coding;
30953100
TargetAttributes = {
30963101
8E47700F198770E700997D05 = {
3097-
DevelopmentTeam = QN5Z87S3LH;
30983102
SystemCapabilities = {
30993103
com.apple.BackgroundModes = {
31003104
enabled = 0;
@@ -3640,6 +3644,7 @@
36403644
4EA7F15A1A6D192B00A046BD /* SDImageCache.m in Sources */,
36413645
4EBB624C1A6F526C0045DAEF /* NJKWebViewProgress.m in Sources */,
36423646
8EA6D13C19E240C40076D59C /* Tweet_RootViewController.m in Sources */,
3647+
B93D904B1ACBA3110057A6EE /* ProjectDeleteAlertControllerVisualStyle.m in Sources */,
36433648
4E1A22851AB172C400CFC14F /* ProjectItemsCell.m in Sources */,
36443649
4ECE8B051A3946C10021E29C /* WebContentManager.m in Sources */,
36453650
8EA6D1F819E240C40076D59C /* MJPhotoBrowser.m in Sources */,

Coding_iOS/Controllers/NewProject/NewProjectTypeViewController.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cel
134134
}
135135

136136
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
137+
[tableView deselectRowAtIndexPath:indexPath animated:YES];
137138

138139
// Checkmark
139140
if (self.checkedIndexPath){

Coding_iOS/Controllers/NewProject/NewProjectViewController.m

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ @interface NewProjectViewController ()<NewProjectTypeDelegate,UITextFieldDelegat
1414

1515
@property (nonatomic, assign) NewProjectType projectType;
1616
@property (nonatomic, strong) UIBarButtonItem *submitButtonItem;
17+
@property (nonatomic, strong) UIImage *projectIconImage;
1718

1819
@end
1920

@@ -62,15 +63,17 @@ -(void)selectProjectImage{
6263
}else{
6364
avatarPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
6465
}
66+
avatarPicker.allowsEditing = YES;
6567
[self presentViewController:avatarPicker animated:YES completion:nil];
6668
}] showInView:self.view];
6769
}
6870

6971
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
70-
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
72+
UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
7173

7274
if (image) {
7375
self.projectImageView.image = image;
76+
self.projectIconImage = image;
7477
}
7578

7679
[picker dismissViewControllerAnimated:YES completion:nil];
@@ -100,9 +103,14 @@ -(void)submit{
100103
project.is_public = @NO;
101104
}
102105

106+
self.submitButtonItem.enabled = NO;
107+
103108
// 效验完成,开始发送请求创建项目
104-
[[Coding_NetAPIManager sharedManager] request_NewProject_WithObj:project andBlock:^(Project *data, NSError *error) {
105-
[self.navigationController popToRootViewControllerAnimated:YES];
109+
[[Coding_NetAPIManager sharedManager] request_NewProject_WithObj:project image:self.projectIconImage andBlock:^(Project *data, NSError *error) {
110+
if (!error) {
111+
[self.navigationController popToRootViewControllerAnimated:YES];
112+
}
113+
self.submitButtonItem.enabled = YES;
106114
}];
107115
}else{
108116
[[[UIAlertView alloc] initWithTitle:@"提示" message:@"项目名只允许字母、数字或者下划线(_)、中划线(-),必须以字母或者数字开头,且不能以.git结尾" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles: nil] show];

Coding_iOS/Controllers/ProjectSetting/ProjectAdvancedSettingViewController.m

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
#import "ProjectAdvancedSettingViewController.h"
1010
#import "Coding_NetAPIManager.h"
1111

12-
@interface ProjectAdvancedSettingViewController ()<UIAlertViewDelegate>
12+
#import <SDCAlertController.h>
13+
#import "ProjectDeleteAlertControllerVisualStyle.h"
14+
15+
@interface ProjectAdvancedSettingViewController ()
1316

1417
@end
1518

@@ -52,15 +55,27 @@ -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cel
5255
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
5356
[tableView deselectRowAtIndexPath:indexPath animated:YES];
5457

55-
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"需要验证密码" message:@"这是一个危险的操作,请提供登录密码确认!" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
56-
alert.alertViewStyle = UIAlertViewStyleSecureTextInput;
57-
[alert show];
58-
}
59-
60-
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
61-
if (buttonIndex == 1) {
62-
// 确定
63-
NSString *password = [[alertView textFieldAtIndex:0].text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
58+
static NSString *title = @"需要验证密码";
59+
static NSString *message = @"这是一个危险的操作,请提供登录密码确认!";
60+
61+
SDCAlertController *alert = [SDCAlertController alertControllerWithTitle:title message:message preferredStyle:SDCAlertControllerStyleAlert];
62+
63+
// Style
64+
alert.visualStyle = [ProjectDeleteAlertControllerVisualStyle new];
65+
66+
// 添加密码框
67+
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
68+
textField.secureTextEntry = YES;
69+
}];
70+
71+
// 添加按钮
72+
alert.actionLayout = SDCAlertControllerActionLayoutHorizontal;
73+
[alert addAction:[SDCAlertAction actionWithTitle:@"取消" style:SDCAlertActionStyleCancel handler:^(SDCAlertAction *action) {
74+
[alert dismissWithCompletion:nil];
75+
}]];
76+
[alert addAction:[SDCAlertAction actionWithTitle:@"确定" style:SDCAlertActionStyleDefault handler:^(SDCAlertAction *action) {
77+
UITextField *passwordTextField = [[alert textFields] firstObject];
78+
NSString *password = [passwordTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
6479

6580
if (password > 0) {
6681
// 删除项目
@@ -71,7 +86,9 @@ -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)button
7186

7287
}];
7388
}
74-
}
89+
}]];
90+
91+
[alert presentWithCompletion:nil];
7592
}
7693

7794
@end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// ProjectDeleteAlertControllerVisualStyle.h
3+
// Coding_iOS
4+
//
5+
// Created by isaced on 15/4/1.
6+
// Copyright (c) 2015年 Coding. All rights reserved.
7+
//
8+
9+
#import "SDCAlertControllerDefaultVisualStyle.h"
10+
11+
@interface ProjectDeleteAlertControllerVisualStyle : SDCAlertControllerDefaultVisualStyle
12+
13+
@end
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// ProjectDeleteAlertControllerVisualStyle.m
3+
// Coding_iOS
4+
//
5+
// Created by isaced on 15/4/1.
6+
// Copyright (c) 2015年 Coding. All rights reserved.
7+
//
8+
9+
#import "ProjectDeleteAlertControllerVisualStyle.h"
10+
11+
@implementation ProjectDeleteAlertControllerVisualStyle
12+
13+
-(UIColor *)titleLabelColor{
14+
return [UIColor colorWithRGBHex:0x222222];
15+
}
16+
17+
-(UIColor *)messageLabelColor{
18+
return [UIColor colorWithRGBHex:0xf34a4a];
19+
}
20+
21+
- (CGFloat)labelSpacing {
22+
return 30;
23+
}
24+
25+
- (CGFloat)messageLabelBottomSpacing {
26+
return 20;
27+
}
28+
29+
@end

Coding_iOS/Controllers/ProjectSetting/ProjectSettingViewController.m

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
#import "UIImageView+WebCache.h"
1212
#import "Coding_NetAPIManager.h"
1313

14-
@interface ProjectSettingViewController ()<UITextViewDelegate>
14+
@interface ProjectSettingViewController ()<UITextViewDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate>
1515

1616
@property (nonatomic, strong) UIBarButtonItem *submitButtonItem;
17+
@property (nonatomic, strong) UIImage *projectIconImage;
1718

1819
@end
1920

@@ -34,6 +35,8 @@ - (void)viewDidLoad {
3435
//
3536
self.projectImageView.layer.cornerRadius = 5;
3637
[self.projectImageView sd_setImageWithURL:[self.project.icon urlImageWithCodePathResizeToView:self.projectImageView]];
38+
UITapGestureRecognizer *tapProjectImageViewGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectProjectImage)];
39+
[self.projectImageView addGestureRecognizer:tapProjectImageViewGR];
3740

3841
// 添加 “完成” 按钮
3942
self.submitButtonItem = [UIBarButtonItem itemWithBtnTitle:@"完成" target:self action:@selector(submit)];
@@ -45,13 +48,52 @@ - (void)viewDidLoad {
4548
-(void)submit{
4649
self.project.description_mine = [self.descTextView.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
4750

51+
self.submitButtonItem.enabled = NO;
52+
4853
// 更新项目
49-
[[Coding_NetAPIManager sharedManager] request_UpdateProject_WithObj:self.project andBlock:^(Project *data, NSError *error) {
50-
[self.navigationController popToRootViewControllerAnimated:YES];
54+
[[Coding_NetAPIManager sharedManager] request_UpdateProject_WithObj:self.project image:self.projectIconImage andBlock:^(Project *data, NSError *error) {
55+
if (!error) {
56+
[self.navigationController popToRootViewControllerAnimated:YES];
57+
}
58+
self.submitButtonItem.enabled = YES;
5159
}];
5260

5361
}
5462

63+
-(void)selectProjectImage{
64+
[[UIActionSheet bk_actionSheetCustomWithTitle:@"选择照片" buttonTitles:@[@"拍照",@"从相册选择"] destructiveTitle:nil cancelTitle:@"取消" andDidDismissBlock:^(UIActionSheet *sheet, NSInteger index) {
65+
66+
if (index > 1) {
67+
return ;
68+
}
69+
70+
UIImagePickerController *avatarPicker = [[UIImagePickerController alloc] init];
71+
avatarPicker.delegate = self;
72+
if (index == 0) {
73+
avatarPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
74+
}else{
75+
avatarPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
76+
}
77+
[self presentViewController:avatarPicker animated:YES completion:nil];
78+
}] showInView:self.view];
79+
}
80+
81+
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
82+
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
83+
84+
if (image) {
85+
self.projectImageView.image = image;
86+
self.projectIconImage = image;
87+
}
88+
89+
[picker dismissViewControllerAnimated:YES completion:nil];
90+
}
91+
92+
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
93+
[picker dismissViewControllerAnimated:YES completion:nil];
94+
}
95+
96+
5597
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
5698
NSString *string = [textView.text stringByReplacingCharactersInRange:range withString:text];
5799

Coding_iOS/Models/Projects.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ -(NSDictionary *)toCreateParams{
137137
return @{@"name":self.name,
138138
@"description":self.description_mine,
139139
@"type":type,
140-
@"gitEnable":@"false",
140+
@"gitEnabled":@"false",
141141
@"gitReadmeEnabled":@"false",
142142
@"gitIgnore":@"no",
143143
@"gitLicense":@"no",
144-
@"importFrom":@"no",
144+
// @"importFrom":@"no",
145145
@"vcsType":@"git"};
146146
}
147147

@@ -162,8 +162,8 @@ -(NSString *)toDeletePath{
162162
}
163163

164164
-(NSDictionary *)toDeleteParamsWithPassword:(NSString *)password{
165-
return @{@"user_name":[Login curLoginUser].email,
166-
@"project_name":self.name,
165+
return @{@"user_name":[Login curLoginUser].name,
166+
@"name":self.name,
167167
@"porject_id":[self.id stringValue],
168168
@"password":[password sha1Str]};
169169
}

Coding_iOS/Util/Manager/CodingNetAPIClient.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ typedef NS_ENUM(NSInteger, IllegalContentType) {
3535
withMethodType:(int)NetworkMethod
3636
andBlock:(void (^)(id data, NSError *error))block;
3737

38+
- (void)requestJsonDataWithPath:(NSString *)aPath
39+
file:(NSDictionary *)file
40+
withParams:(NSDictionary*)params
41+
withMethodType:(int)NetworkMethod
42+
andBlock:(void (^)(id data, NSError *error))block;
43+
44+
3845
- (void)reportIllegalContentWithType:(IllegalContentType)type
3946
withParams:(NSDictionary*)params;
4047

Coding_iOS/Util/Manager/CodingNetAPIClient.m

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,61 @@ - (void)requestJsonDataWithPath:(NSString *)aPath
116116
}
117117
}
118118

119+
-(void)requestJsonDataWithPath:(NSString *)aPath file:(NSDictionary *)file withParams:(NSDictionary *)params withMethodType:(int)NetworkMethod andBlock:(void (^)(id, NSError *))block{
120+
//log请求数据
121+
DebugLog(@"\n===========request===========\n%@:\n%@", aPath, params);
122+
aPath = [aPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
123+
124+
// Data
125+
NSData *data;
126+
NSString *name, *fileName;
127+
128+
if (file) {
129+
UIImage *image = file[@"image"];
130+
131+
// 缩小到最大 800x800
132+
image = [image scaledToMaxSize:CGSizeMake(799, 799)];
133+
134+
// 压缩
135+
data = UIImageJPEGRepresentation(image, 1.0);
136+
if ((float)data.length/1024 > 1000) {
137+
data = UIImageJPEGRepresentation(image, 1024*1000.0/(float)data.length);
138+
}
139+
140+
name = file[@"name"];
141+
fileName = file[@"fileName"];
142+
}
143+
144+
switch (NetworkMethod) {
145+
case Post:{
146+
147+
AFHTTPRequestOperation *operation = [self POST:aPath parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
148+
if (file) {
149+
[formData appendPartWithFileData:data name:name fileName:fileName mimeType:@"image/jpeg"];
150+
}
151+
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
152+
DebugLog(@"\n===========response===========\n%@:\n%@", aPath, responseObject);
153+
id error = [self handleResponse:responseObject];
154+
if (error) {
155+
block(nil, error);
156+
}else{
157+
block(responseObject, nil);
158+
}
159+
160+
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
161+
DebugLog(@"\n===========response===========\n%@:\n%@", aPath, error);
162+
[self showError:error];
163+
block(nil, error);
164+
}];
165+
[operation start];
166+
167+
break;
168+
}
169+
default:
170+
break;
171+
}
172+
}
173+
119174
- (void)reportIllegalContentWithType:(IllegalContentType)type
120175
withParams:(NSDictionary*)params{
121176
NSString *aPath;

0 commit comments

Comments
 (0)