diff --git a/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj b/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj index cbfc3a3..beb0a2a 100644 --- a/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj +++ b/RedmineMobile/RedmineMobile.xcodeproj/project.pbxproj @@ -11,6 +11,8 @@ 2BCF88101793ABA0006FC859 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BCF880F1793ABA0006FC859 /* Reachability.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 2BCF88121793CB4F006FC859 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2BCF88111793CB4F006FC859 /* CFNetwork.framework */; }; 2BCF88141793CB94006FC859 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2BCF88131793CB94006FC859 /* SystemConfiguration.framework */; }; + 2BCF88181793E353006FC859 /* OZLProjectDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BCF88161793E353006FC859 /* OZLProjectDetailViewController.m */; }; + 2BCF88191793E353006FC859 /* OZLProjectDetailViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2BCF88171793E353006FC859 /* OZLProjectDetailViewController.xib */; }; D5DB805A1792F2BF0081662A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D5DB80591792F2BF0081662A /* UIKit.framework */; }; D5DB805C1792F2BF0081662A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D5DB805B1792F2BF0081662A /* Foundation.framework */; }; D5DB805E1792F2BF0081662A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D5DB805D1792F2BF0081662A /* CoreGraphics.framework */; }; @@ -52,6 +54,9 @@ 2BCF880F1793ABA0006FC859 /* Reachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Reachability.m; sourceTree = ""; }; 2BCF88111793CB4F006FC859 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; }; 2BCF88131793CB94006FC859 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; + 2BCF88151793E352006FC859 /* OZLProjectDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OZLProjectDetailViewController.h; path = ViewControllers/OZLProjectDetailViewController.h; sourceTree = ""; }; + 2BCF88161793E353006FC859 /* OZLProjectDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OZLProjectDetailViewController.m; path = ViewControllers/OZLProjectDetailViewController.m; sourceTree = ""; }; + 2BCF88171793E353006FC859 /* OZLProjectDetailViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = OZLProjectDetailViewController.xib; path = ViewControllers/OZLProjectDetailViewController.xib; sourceTree = ""; }; D5DB80561792F2BF0081662A /* RedmineMobile.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RedmineMobile.app; sourceTree = BUILT_PRODUCTS_DIR; }; D5DB80591792F2BF0081662A /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; D5DB805B1792F2BF0081662A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -282,6 +287,9 @@ D5DB80B21793016B0081662A /* OZLAccountViewController.h */, D5DB80B31793016B0081662A /* OZLAccountViewController.m */, D5DB80B41793016B0081662A /* OZLAccountViewController.xib */, + 2BCF88151793E352006FC859 /* OZLProjectDetailViewController.h */, + 2BCF88161793E353006FC859 /* OZLProjectDetailViewController.m */, + 2BCF88171793E353006FC859 /* OZLProjectDetailViewController.xib */, ); name = ViewControllers; sourceTree = ""; @@ -367,6 +375,7 @@ D5DB80A71792F4DE0081662A /* OZLProjectListViewController.xib in Resources */, D5DB80AD1792F6980081662A /* OZLProjectViewController.xib in Resources */, D5DB80B61793016B0081662A /* OZLAccountViewController.xib in Resources */, + 2BCF88191793E353006FC859 /* OZLProjectDetailViewController.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -401,6 +410,7 @@ D5DB80C217931C8B0081662A /* OZLModelProject.m in Sources */, 2BCF880C1793A26A006FC859 /* MBProgressHUD.m in Sources */, 2BCF88101793ABA0006FC859 /* Reachability.m in Sources */, + 2BCF88181793E353006FC859 /* OZLProjectDetailViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/RedmineMobile/RedmineMobile/OZLAppDelegate.m b/RedmineMobile/RedmineMobile/OZLAppDelegate.m index cb64fb9..cda406d 100644 --- a/RedmineMobile/RedmineMobile/OZLAppDelegate.m +++ b/RedmineMobile/RedmineMobile/OZLAppDelegate.m @@ -28,14 +28,26 @@ #import "OZLAppDelegate.h" #import "OZLProjectViewController.h" +#import "OZLSingleton.h" +#import "OZLModelProject.h" +#import "OZLAccountViewController.h" @implementation OZLAppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = PP_AUTORELEASE([[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]); - - OZLProjectViewController *main = [[OZLProjectViewController alloc] initWithNibName:@"OZLProjectViewController" bundle:nil]; + + id main = nil; + int lastProjectID = [[OZLSingleton sharedInstance] lastProjectID]; + if (lastProjectID < 0) { + main = [[OZLAccountViewController alloc] initWithNibName:@"OZLAccountViewController" bundle:nil]; + }else { + main = [[OZLProjectViewController alloc] initWithNibName:@"OZLProjectViewController" bundle:nil]; + OZLModelProject* data = [[OZLModelProject alloc] init]; + data.index = lastProjectID; + [main setProjectData:data]; + } UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:main]; _revealSideViewController = [[PPRevealSideViewController alloc] initWithRootViewController:nav]; diff --git a/RedmineMobile/RedmineMobile/Utils/OZLNetwork.h b/RedmineMobile/RedmineMobile/Utils/OZLNetwork.h index 8c555b6..b99d624 100644 --- a/RedmineMobile/RedmineMobile/Utils/OZLNetwork.h +++ b/RedmineMobile/RedmineMobile/Utils/OZLNetwork.h @@ -27,9 +27,12 @@ // THE SOFTWARE. #import +#import "OZLModelProject.h" @interface OZLNetwork : NSObject +// project +(void)getProjectListWithParams:(NSDictionary*)params andBlock:(void (^)(NSArray *result, NSError *error))block; ++(void)getDetailForProject:(int)projectid withParams:(NSDictionary*)params andBlock:(void (^)(OZLModelProject *result, NSError *error))block; @end diff --git a/RedmineMobile/RedmineMobile/Utils/OZLNetwork.m b/RedmineMobile/RedmineMobile/Utils/OZLNetwork.m index b094394..40f39ce 100644 --- a/RedmineMobile/RedmineMobile/Utils/OZLNetwork.m +++ b/RedmineMobile/RedmineMobile/Utils/OZLNetwork.m @@ -61,5 +61,29 @@ }]; } ++(void)getDetailForProject:(int)projectid withParams:(NSDictionary*)params andBlock:(void (^)(OZLModelProject *result, NSError *error))block +{ + NSString* path = [NSString stringWithFormat:@"/projects/%d.json",projectid]; + [[OZLNetworkBase sharedClient] getPath:path parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { + + if (block) { + NSLog(@"the repsonse:%@",responseObject); + + NSDictionary* projectDic = [responseObject objectForKey:@"project"]; + OZLModelProject* project = [[OZLModelProject alloc] initWithDictionary:projectDic]; + + block(project,nil); + } + + + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + + + if (block) { + block([NSArray array], error); + } + + }]; +} @end diff --git a/RedmineMobile/RedmineMobile/Utils/OZLSingleton.h b/RedmineMobile/RedmineMobile/Utils/OZLSingleton.h index 30d402f..2ac8a1b 100644 --- a/RedmineMobile/RedmineMobile/Utils/OZLSingleton.h +++ b/RedmineMobile/RedmineMobile/Utils/OZLSingleton.h @@ -36,5 +36,9 @@ @property(nonatomic,strong) NSString* redmineHomeURL; @property(nonatomic,strong) NSString* redmineUserKey; +//app status +@property(nonatomic) int lastProjectID;// last viewed project id + + @end diff --git a/RedmineMobile/RedmineMobile/Utils/OZLSingleton.m b/RedmineMobile/RedmineMobile/Utils/OZLSingleton.m index 8239ab9..4c81dac 100644 --- a/RedmineMobile/RedmineMobile/Utils/OZLSingleton.m +++ b/RedmineMobile/RedmineMobile/Utils/OZLSingleton.m @@ -32,6 +32,7 @@ NSString* USER_DEFUALTS_REDMINE_HOME_URL = @"USER_DEFUALTS_REDMINE_HOME_URL"; NSString* USER_DEFUALTS_REDMINE_USER_KEY = @"USER_DEFUALTS_REDMINE_USER_KEY"; +NSString* USER_DEFUALTS_LAST_PROJECT_ID = @"USER_DEFUALTS_LAST_PROJECT_ID"; static OZLSingleton* sharedInstance = nil; @@ -44,6 +45,7 @@ static OZLSingleton* sharedInstance = nil; NSDictionary* dic = [[NSDictionary alloc] initWithObjectsAndKeys: @"http://demo.redmine.org/",USER_DEFUALTS_REDMINE_HOME_URL, @"",USER_DEFUALTS_REDMINE_USER_KEY, + [NSNumber numberWithInt:-1],USER_DEFUALTS_LAST_PROJECT_ID, nil]; [defaults registerDefaults:dic]; } @@ -72,5 +74,16 @@ static OZLSingleton* sharedInstance = nil; [userdefaults setObject:redmineUserKey forKey:USER_DEFUALTS_REDMINE_USER_KEY]; [userdefaults synchronize]; } +-(int)lastProjectID +{ + NSUserDefaults* userdefaults = [NSUserDefaults standardUserDefaults]; + return [userdefaults integerForKey:USER_DEFUALTS_LAST_PROJECT_ID]; +} +-(void)setLastProjectID:(int)projectid +{ + NSUserDefaults* userdefaults = [NSUserDefaults standardUserDefaults]; + [userdefaults setInteger:projectid forKey:USER_DEFUALTS_LAST_PROJECT_ID]; + [userdefaults synchronize]; +} @end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLAccountViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLAccountViewController.m index bbf07aa..97c0309 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLAccountViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLAccountViewController.m @@ -77,6 +77,7 @@ - (void) showLeft { OZLProjectListViewController *c = [[OZLProjectListViewController alloc] initWithNibName:@"OZLProjectListViewController" bundle:nil]; + [c setNeedRefresh:YES]; [self.revealSideViewController pushViewController:c onDirection:PPRevealSideDirectionLeft withOffset:_sideviewOffset animated:YES]; PP_RELEASE(c); } diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectDetailViewController.h b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectDetailViewController.h new file mode 100644 index 0000000..26f7951 --- /dev/null +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectDetailViewController.h @@ -0,0 +1,23 @@ +// +// OZLProjectDetailViewController.h +// RedmineMobile +// +// Created by lizhijie on 7/15/13. +// Copyright (c) 2013 Lee Zhijie. All rights reserved. +// + +#import +#import "OZLModelProject.h" + +@interface OZLProjectDetailViewController : UIViewController + +@property(nonatomic, strong) OZLModelProject* projectData; + +@property (weak, nonatomic) IBOutlet UILabel *IDLabel; +@property (weak, nonatomic) IBOutlet UILabel *nameLabel; +@property (weak, nonatomic) IBOutlet UILabel *parentIDlabel; +@property (weak, nonatomic) IBOutlet UILabel *createTimeLabel; +@property (weak, nonatomic) IBOutlet UILabel *updateTimeLabel; +@property (weak, nonatomic) IBOutlet UITextView *descriptionTextview; + +@end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectDetailViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectDetailViewController.m new file mode 100644 index 0000000..8ace745 --- /dev/null +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectDetailViewController.m @@ -0,0 +1,60 @@ +// +// OZLProjectDetailViewController.m +// RedmineMobile +// +// Created by lizhijie on 7/15/13. +// Copyright (c) 2013 Lee Zhijie. All rights reserved. +// + +#import "OZLProjectDetailViewController.h" + +@interface OZLProjectDetailViewController () { + +} + +@end + +@implementation OZLProjectDetailViewController + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + [_IDLabel setText:[NSString stringWithFormat:@"%d",_projectData.index]]; + [_nameLabel setText:_projectData.name]; + if (_projectData.parentId < 0) { + [_parentIDlabel setText:@"--"]; + }else { + [_parentIDlabel setText:[NSString stringWithFormat:@"%d",_projectData.parentId]]; + } + [_createTimeLabel setText:_projectData.createdOn]; + [_updateTimeLabel setText:_projectData.updatedOn]; + + [_descriptionTextview setEditable:NO]; + [_descriptionTextview setText:_projectData.description]; +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +- (void)viewDidUnload { + [self setIDLabel:nil]; + [self setNameLabel:nil]; + [self setParentIDlabel:nil]; + [self setCreateTimeLabel:nil]; + [self setUpdateTimeLabel:nil]; + [self setDescriptionTextview:nil]; + [super viewDidUnload]; +} +@end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectDetailViewController.xib b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectDetailViewController.xib new file mode 100644 index 0000000..e6aa4d7 --- /dev/null +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectDetailViewController.xib @@ -0,0 +1,583 @@ + + + + 1552 + 11G63 + 3084 + 1138.51 + 569.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 2083 + + + IBProxyObject + IBUILabel + IBUITextView + IBUIView + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + PluginDependencyRecalculationVersion + + + + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + 274 + + + + 292 + {{20, 20}, {106, 21}} + + + + _NS:9 + NO + YES + 7 + NO + IBCocoaTouchFramework + ID: + + 1 + MCAwIDAAA + darkTextColor + + + 0 + + 1 + 17 + + + Helvetica + 17 + 16 + + NO + + + + 292 + {{20, 49}, {106, 21}} + + + + _NS:9 + NO + YES + 7 + NO + IBCocoaTouchFramework + Name: + + + 0 + + + NO + + + + 292 + {{20, 107}, {106, 21}} + + + + _NS:9 + NO + YES + 7 + NO + IBCocoaTouchFramework + Created On: + + + 0 + + + NO + + + + 292 + {{20, 136}, {106, 21}} + + + + _NS:9 + NO + YES + 7 + NO + IBCocoaTouchFramework + Updated On: + + + 0 + + + NO + + + + 292 + {{20, 165}, {106, 21}} + + + + _NS:9 + NO + YES + 7 + NO + IBCocoaTouchFramework + Description: + + + 0 + + + NO + + + + 292 + {{20, 78}, {106, 21}} + + + + _NS:9 + NO + YES + 7 + NO + IBCocoaTouchFramework + Parent ID: + + + 0 + + + NO + + + + 306 + {{20, 194}, {280, 290}} + + + + _NS:9 + + 1 + MSAxIDEAA + + YES + YES + IBCocoaTouchFramework + Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. + + 2 + IBCocoaTouchFramework + + + 1 + 14 + + + Helvetica + 14 + 16 + + + + + 292 + {{134, 20}, {166, 21}} + + + + _NS:9 + NO + YES + 7 + NO + IBCocoaTouchFramework + ID: + + + 0 + + + NO + + + + 292 + {{134, 49}, {166, 21}} + + + + _NS:9 + NO + YES + 7 + NO + IBCocoaTouchFramework + ID: + + + 0 + + + NO + + + + 292 + {{134, 78}, {166, 21}} + + + + _NS:9 + NO + YES + 7 + NO + IBCocoaTouchFramework + ID: + + + 0 + + + NO + + + + 292 + {{134, 107}, {166, 21}} + + + + _NS:9 + NO + YES + 7 + NO + IBCocoaTouchFramework + ID: + + + 0 + + + NO + + + + 292 + {{134, 136}, {166, 21}} + + + + _NS:9 + NO + YES + 7 + NO + IBCocoaTouchFramework + ID: + + + 0 + + + NO + + + {{0, 64}, {320, 504}} + + + + + 3 + MQA + + 2 + + + + + NO + + + IBUIScreenMetrics + + YES + + + + + + {320, 568} + {568, 320} + + + IBCocoaTouchFramework + Retina 4 Full Screen + 2 + + IBCocoaTouchFramework + + + + + + + view + + + + 3 + + + + IDLabel + + + + 18 + + + + nameLabel + + + + 19 + + + + parentIDlabel + + + + 20 + + + + createTimeLabel + + + + 21 + + + + updateTimeLabel + + + + 22 + + + + descriptionTextview + + + + 23 + + + + + + 0 + + + + + + 1 + + + + + + + + + + + + + + + + + + + -1 + + + File's Owner + + + -2 + + + + + 6 + + + + + 7 + + + + + 8 + + + + + 9 + + + + + 10 + + + + + 11 + + + + + 12 + + + + + 13 + + + + + 14 + + + + + 15 + + + + + 16 + + + + + 17 + + + + + + + OZLProjectDetailViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + 23 + + + + + OZLProjectDetailViewController + UIViewController + + UILabel + UILabel + UITextView + UILabel + UILabel + UILabel + + + + IDLabel + UILabel + + + createTimeLabel + UILabel + + + descriptionTextview + UITextView + + + nameLabel + UILabel + + + parentIDlabel + UILabel + + + updateTimeLabel + UILabel + + + + IBProjectSource + ./Classes/OZLProjectDetailViewController.h + + + + + 0 + IBCocoaTouchFramework + YES + 3 + 2083 + + diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.h b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.h index 628d196..960535d 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.h +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.h @@ -30,6 +30,9 @@ @interface OZLProjectListViewController : UIViewController +@property (nonatomic) BOOL needRefresh; @property (strong, nonatomic) IBOutlet UITableView *projectsTableview; - (IBAction)showAccountView:(id)sender; + + @end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.m index 4b44f16..d00ba53 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectListViewController.m @@ -65,26 +65,31 @@ -(void) viewWillAppear:(BOOL)animated { - [_HUD show:YES]; - - // refresh project list - [OZLNetwork getProjectListWithParams:nil andBlock:^(NSArray *result, NSError *error) { - NSLog(@"respond:%@",result.description); - _projectList = [[NSMutableArray alloc] initWithArray: result]; - [_projectsTableview reloadData]; - [_HUD hide:YES]; - }]; +// if (_needRefresh) { + _needRefresh = NO; + + [_HUD show:YES]; + // refresh project list + [OZLNetwork getProjectListWithParams:nil andBlock:^(NSArray *result, NSError *error) { + NSLog(@"respond:%@",result.description); + _projectList = [[NSMutableArray alloc] initWithArray: result]; + [_projectsTableview reloadData]; + [_HUD hide:YES]; + }]; +// } } + - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -- (void)showProjectView +- (void)showProjectView:(OZLModelProject*)project { - + OZLProjectViewController *c = [[OZLProjectViewController alloc] initWithNibName:@"OZLProjectViewController" bundle:nil]; + [c setProjectData:project]; UINavigationController *n = [[UINavigationController alloc] initWithRootViewController:c]; [self.revealSideViewController popViewControllerWithNewCenterController:n animated:YES]; @@ -178,7 +183,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - + + [self showProjectView:[_projectList objectAtIndex:indexPath.row]]; } diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.h b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.h index a801379..0e70084 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.h +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.h @@ -27,7 +27,8 @@ // THE SOFTWARE. #import +#import "OZLModelProject.h" @interface OZLProjectViewController : UIViewController - +@property (nonatomic,strong) OZLModelProject* projectData; @end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m index 21ee9b4..46806f3 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m @@ -29,9 +29,14 @@ #import "OZLProjectViewController.h" #import "PPRevealSideViewController.h" #import "OZLProjectListViewController.h" +#import "OZLNetwork.h" +#import "MBProgressHUD.h" +#import "OZLProjectDetailViewController.h" + @interface OZLProjectViewController () { float _sideviewOffset; + MBProgressHUD * _HUD; } @end @@ -50,11 +55,48 @@ { [super viewDidLoad]; [self changeSideViewOffset:40]; - + UIBarButtonItem* projectListBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize target:self action:@selector(showLeft)]; [self.navigationItem setLeftBarButtonItem:projectListBtn]; + + UIBarButtonItem* inforBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(showProjectDetail)]; + [self.navigationItem setRightBarButtonItem:inforBtn]; + + _HUD = [[MBProgressHUD alloc] initWithView:self.view]; + [self.view addSubview:_HUD]; + _HUD.labelText = @"Loading..."; + + [self reloadData]; } +-(void) reloadData +{ + if (_projectData == nil) { + NSLog(@"error: _projectData have to be set"); + return; + } + [_HUD show:YES]; + [OZLNetwork getDetailForProject:_projectData.index withParams:nil andBlock:^(OZLModelProject *result, NSError *error) { + _projectData = result; + [self.navigationItem setTitle:_projectData.name]; + + [_HUD hide:YES]; + }]; +} + +- (void) viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(preloadLeft) object:nil]; + [self performSelector:@selector(preloadLeft) withObject:nil afterDelay:0.3]; + +} + +- (void) showProjectDetail +{ + OZLProjectDetailViewController* detail = [[OZLProjectDetailViewController alloc] initWithNibName:@"OZLProjectDetailViewController" bundle:nil]; + [detail setProjectData:_projectData]; + [self.navigationController pushViewController:detail animated:YES]; +} - (void) preloadLeft { OZLProjectListViewController *c = [[OZLProjectListViewController alloc] initWithNibName:@"OZLProjectListViewController" bundle:nil]; @@ -63,11 +105,6 @@ withOffset:_sideviewOffset]; PP_RELEASE(c); } -- (void) viewDidAppear:(BOOL)animated { - [super viewDidAppear:animated]; - [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(preloadLeft) object:nil]; - [self performSelector:@selector(preloadLeft) withObject:nil afterDelay:0.3]; -} - (void) showLeft { OZLProjectListViewController *c = [[OZLProjectListViewController alloc] initWithNibName:@"OZLProjectListViewController" bundle:nil]; diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.xib b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.xib index ade903e..f766380 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.xib +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.xib @@ -2,16 +2,19 @@ 1552 - 12E55 + 11G63 3084 - 1187.39 - 626.00 + 1138.51 + 569.00 com.apple.InterfaceBuilder.IBCocoaTouchPlugin 2083 IBProxyObject + IBUIBarButtonItem + IBUITableView + IBUIToolbar IBUIView @@ -33,7 +36,46 @@ 274 - + + + + 274 + {320, 460} + + _NS:9 + + 3 + MQA + + YES + IBCocoaTouchFramework + YES + 1 + 0 + YES + 44 + 22 + 22 + + + + 266 + {{0, 460}, {320, 44}} + + _NS:9 + NO + NO + IBCocoaTouchFramework + + + Item + IBCocoaTouchFramework + 1 + + + + + {{0, 64}, {320, 504}} @@ -89,7 +131,10 @@ 1 - + + + + @@ -103,6 +148,24 @@ + + 6 + + + + + + + + 7 + + + + + 8 + + + @@ -111,12 +174,15 @@ UIResponder com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin - 5 + 8 0