Skip to content

Commit

Permalink
新iOS UI调整
Browse files Browse the repository at this point in the history
  • Loading branch information
sunleepy committed Jul 27, 2012
1 parent eb2a60b commit f4465a6
Show file tree
Hide file tree
Showing 184 changed files with 12,599 additions and 377 deletions.
Binary file modified .DS_Store
Binary file not shown.
8 changes: 8 additions & 0 deletions Cooper/hybrid/windows phone/Cooper.userprefs
@@ -0,0 +1,8 @@
<Properties>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench />
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
</Properties>
Binary file modified Cooper/native/.DS_Store
Binary file not shown.
Binary file modified Cooper/native/ios/.DS_Store
Binary file not shown.
854 changes: 513 additions & 341 deletions Cooper/native/ios/Cooper.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file not shown.
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges</key>
<true/>
<key>SnapshotAutomaticallyBeforeSignificantChanges</key>
<true/>
</dict>
</plist>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "1.0">
</Bucket>
Binary file modified Cooper/native/ios/Cooper/.DS_Store
Binary file not shown.
26 changes: 26 additions & 0 deletions Cooper/native/ios/Cooper/Application/AppDelegate.h
@@ -0,0 +1,26 @@
//
// AppDelegate.h
// Cooper
//
// Created by sunleepy on 12-6-29.
// Copyright (c) 2012年 codesharp. All rights reserved.
//


#import "MainViewController.h"

@interface AppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate>
{
NSManagedObjectModel *managedObjectModel;
NSManagedObjectContext *managedObjectContext;
NSPersistentStoreCoordinator *persistentStoreCoordinator;
}

@property (strong, nonatomic) MainViewController *mainViewController;
@property (strong, nonatomic) UIWindow *window;
@property (retain, nonatomic, readonly) NSManagedObjectModel *managedObjectModel;
@property (retain, nonatomic, readonly) NSManagedObjectContext *managedObjectContext;
@property (retain, nonatomic, readonly) NSPersistentStoreCoordinator *persistantStoreCoordiantor;
@property (retain, nonatomic) NSTimer *timer;

@end
170 changes: 170 additions & 0 deletions Cooper/native/ios/Cooper/Application/AppDelegate.m
@@ -0,0 +1,170 @@
//
// AppDelegate.m
// Cooper
//
// Created by sunleepy on 12-6-29.
// Copyright (c) 2012年 codesharp. All rights reserved.
//

#import "AppDelegate.h"

@implementation AppDelegate

@synthesize window;
@synthesize mainViewController;
@synthesize timer;

#pragma mark - application life cycle

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//load from cache to get user info
[Constant loadFromCache];

#ifdef CODESHARP_VERSION
NSLog(@"当前版本: codesharp");
#else
NSLog(@"当前版本: not codesharp");
#endif

if([[Constant instance] path] == nil)
{
[[Constant instance] setPath:[[[SysConfig instance] keyValue] objectForKey: @"env_path"]];
[Constant savePathToCache];
}

self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
[self.window setBackgroundColor:[UIColor whiteColor]];

//the controller of first load page
self.mainViewController = [[MainViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self.mainViewController];
if (MODEL_VERSION >= 5.0) {
[navController.navigationBar setBackgroundImage:[UIImage imageNamed:NAVIGATIONBAR_BG_IMAGE] forBarMetrics:UIBarMetricsDefault];
}
else {
UIImageView *imageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:NAVIGATIONBAR_BG_IMAGE]] autorelease];
[imageView setFrame:CGRectMake(0, 0, 320, 44)];
[navController.navigationBar insertSubview:imageView atIndex:0];
}

self.window.rootViewController = navController;

[self.window makeKeyAndVisible];

// NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
// NSString *name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
// NSString *version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
// NSString *build = [infoDictionary objectForKey:@"CFBundleVersion"];
// NSString *label = [NSString stringWithFormat:@"%@ v%@ (build %@)", name, version, build];
//
// NSLog(@"version:%@", label);

//init timer
//self.timer = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(handleTimer:) userInfo:nil repeats:YES];

//NSSetUncaughtExceptionHandler(handleRootException);

return YES;
}

//static void hadnleRootExcetion(NSException *exception)
//{
//
//}

- (void)applicationWillResignActive:(UIApplication *)application
{
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
NSLog(@"进入后台运行程序");
//[Constant saveToCache];
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
NSLog(@"重新激活程序");
}

- (void)applicationWillTerminate:(UIApplication *)application
{
//chear managedObjectContext
NSError *error = nil;
if (managedObjectContext != nil) {
if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
}
}

//处理提交同步,每30秒
//- (void)handleTimer:(NSTimer*)timer
//{
//}

- (void)dealloc
{
[managedObjectModel release];
[managedObjectContext release];
[persistentStoreCoordinator release];
//[timer release];
[super dealloc];
}

#pragma mark - Core Data 相关

//返回托管对象上下文,如果不存在,将从持久化存储协调器创建它
- (NSManagedObjectContext *) managedObjectContext {

if (managedObjectContext != nil) {
return managedObjectContext;
}

NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
if (coordinator != nil) {
managedObjectContext = [[NSManagedObjectContext alloc] init];
[managedObjectContext setPersistentStoreCoordinator: coordinator];
}
return managedObjectContext;
}
//返回托管的对象模型,如果模型不存在,将在application bundle找到所有的模型创建它
- (NSManagedObjectModel *)managedObjectModel {

if (managedObjectModel != nil) {
return managedObjectModel;
}
managedObjectModel = [[NSManagedObjectModel mergedModelFromBundles:nil] retain];
return managedObjectModel;
}
//返回应用程序的持久化存储协调器,如果不存在,从应用程序的store创建它
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {

if (persistentStoreCoordinator != nil) {
return persistentStoreCoordinator;
}

NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: STORE_DBNAME]];
NSLog(@"当前sqlite数据库存储路径: %@", [storeUrl relativeString]);
//HACK:可以保持数据库自动兼容
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES],NSMigratePersistentStoresAutomaticallyOption,[NSNumber numberWithBool:YES],NSInferMappingModelAutomaticallyOption, nil];
NSError *error = nil;
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&error]) {
NSLog(@"sqlite数据库异常解析: %@, %@", error, [error userInfo]);
abort();
}
return persistentStoreCoordinator;
}
//应用程序的Documents目录路径
- (NSString *)applicationDocumentsDirectory {
return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
}

@end
10 changes: 10 additions & 0 deletions Cooper/native/ios/Cooper/Config.plist
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>username</key>
<string>用户名</string>
<key>env_path</key>
<string>http://10.13.25.111:9005</string>
</dict>
</plist>
26 changes: 26 additions & 0 deletions Cooper/native/ios/Cooper/Controls/CommentTextField.h
@@ -0,0 +1,26 @@
//
// CommentTextField.h
// Cooper
//
// Created by Ping Li on 12-7-26.
// Copyright (c) 2012年 Alibaba. All rights reserved.
//
#import "CustomButton.h"

@class CommentTextField;

@protocol CommentTextFieldDelegate <NSObject>
@optional
- (void)sendComment:(NSString *)value;
@end

@interface CommentTextField : UITextField
{
// For iPad
UIPopoverController *popoverController;
UIView *inputAccessoryView;
UITextField *addCommentTextField;
}

@property (nonatomic, assign) id <CommentTextFieldDelegate> delegate;
@end

0 comments on commit f4465a6

Please sign in to comment.