Skip to content

Commit

Permalink
new
Browse files Browse the repository at this point in the history
  • Loading branch information
DHUsesAll committed Jul 21, 2015
1 parent 44854d0 commit 455ba8c
Show file tree
Hide file tree
Showing 68 changed files with 14,953 additions and 305 deletions.
740 changes: 454 additions & 286 deletions DeepBreathing.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
scope = "0"
stopOnStyle = "0">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
57 changes: 56 additions & 1 deletion DeepBreathing/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@ @implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

NSArray * array = @[@"李波",@"吕玉梅",@"蒲嘉欣",@"李玉辉",@"刘英群",@"肖文",@"刘艺前",@"李晓强",@"王振宇",@"唐德刚",@"唐明斌",@"罗野",@"肖攀",@"牛冠",@"陈立",@"陈伟",@"陈超",@"杜毅"];
NSInteger index = arc4random()%array.count;

NSLog(@"%@",array[index]);



#if TARGET_IPHONE_SIMULATOR
[UserModel defaultUser].token = @"";

#else
if (([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)) {
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeSound |UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
}else {

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge)];
}
#endif

[UserModel defaultUser].token = [[NSUserDefaults standardUserDefaults] objectForKey:@"DeviceToken"];

if ([[NSUserDefaults standardUserDefaults] objectForKey:kUserIdKey]) {

// 各个模块controller的类名
Expand Down Expand Up @@ -55,7 +77,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

[self.window makeKeyAndVisible];

#warning 注册推送
return YES;
}

Expand All @@ -74,6 +95,40 @@ - (UIWindow *)window
return _window;
}

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings{

//register to receive notifications
[application registerForRemoteNotifications];
}

- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler{
//handle the actions
if ([identifier isEqualToString:@"declineAction"]) {

} else if ([identifier isEqualToString:@"answerAction"]) {


}
}

//#endif

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{

//转换成string
NSString *dvsToken = [[deviceToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];

//============保存dvsToken===========================

[UserModel defaultUser].token = [dvsToken stringByReplacingOccurrencesOfString:@" " withString:@""];

[[NSUserDefaults standardUserDefaults] setObject:[UserModel defaultUser].token forKey:@"DeviceToken"]; //将dvsToken存入本地

[[NSUserDefaults standardUserDefaults] synchronize];
}



- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Expand Down
87 changes: 87 additions & 0 deletions DeepBreathing/MainTabViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@
//

#import "MainTabViewController.h"
#import "DHConvenienceAutoLayout.h"
#import "DHFoundationTool.h"

#define BUTTON_TAG 100

@interface MainTabViewController ()

@property (nonatomic, strong) NSArray * viewControllers;
@property (nonatomic, strong) UIView * tabBar;
@property (nonatomic, weak) UIButton * currentButton;

@end

Expand All @@ -32,6 +38,87 @@ - (void)viewDidLoad {

- (void)initialize
{
// tab bar
self.view.backgroundColor = [UIColor whiteColor];
[self.view addSubview:self.tabBar];

// add controllers

[self addChildViewController:self.viewControllers[0]];
}

- (void)addChildViewController:(UIViewController *)childController
{
childController.view.frame = [DHConvenienceAutoLayout frameWithLayoutOption:DHAutoLayoutOptionPosition|DHAutoLayoutOptionScale iPhone5Frame:CGRectMake(0, 0, 320, 568-50) adjustWidth:![DHFoundationTool iPhone4]];
[self.view addSubview:childController.view];
[super addChildViewController:childController];
[childController didMoveToParentViewController:self];
}

#pragma mark - getter
- (UIView *)tabBar
{
if (!_tabBar) {
_tabBar = ({

UIView * view = [[UIView alloc] initWithFrame:[DHConvenienceAutoLayout frameWithLayoutOption:DHAutoLayoutOptionPosition|DHAutoLayoutOptionScale iPhone5Frame:CGRectMake(0, 568-50, 320, 50) adjustWidth:![DHFoundationTool iPhone4]]];

CGFloat width = CGRectGetWidth(view.bounds)/self.viewControllers.count;

// 初始化bar的按钮
for (int i = 0; i < self.viewControllers.count; i++) {
// 正常状态下的图片
NSString * imageName = [NSString stringWithFormat:@"100%d-0.png",i];

// 选中的图片的名字
NSString * selectedName = [NSString stringWithFormat:@"100%d-1.png",i];

UIImage * image = IMAGE_WITH_NAME(imageName);
UIImage * selectedImage = IMAGE_WITH_NAME(selectedName);

UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];

if (i == 0) {
self.currentButton = button;
button.selected = YES;
}

button.frame = CGRectMake(i*width, 0, width, 50);
button.tag = BUTTON_TAG+i;
[button setImage:image forState:UIControlStateNormal];
[button setImage:image forState:UIControlStateHighlighted];
[button setImage:selectedImage forState:UIControlStateSelected];

[button addTarget:self action:@selector(onButton:) forControlEvents:UIControlEventTouchUpInside];
[view addSubview:button];
}

view;

});
}

return _tabBar;
}


#pragma mark - button action
- (void)onButton:(UIButton *)sender
{
_currentButton.selected = NO;
sender.selected = YES;

NSInteger currentIndex = _currentButton.tag - BUTTON_TAG;
UIViewController * currentViewController = [self.viewControllers objectAtIndex:currentIndex];
[currentViewController removeFromParentViewController];
[currentViewController.view removeFromSuperview];
[currentViewController willMoveToParentViewController:nil];

UIViewController * controller = [self.viewControllers objectAtIndex:sender.tag - BUTTON_TAG];
[self addChildViewController:controller];

_currentButton = sender;


}

Expand Down
22 changes: 22 additions & 0 deletions DeepBreathing/PrefixHeader.pch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// PrefixHeader.pch
// DeepBreathing
//
// Created by DreamHack on 15-7-17.
// Copyright (c) 2015年 DreamHack. All rights reserved.
//

#ifndef DeepBreathing_PrefixHeader_pch
#define DeepBreathing_PrefixHeader_pch

#define IMAGE_WITH_NAME(name) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForAuxiliaryExecutable:name]]

#define RGB_COLOR(r,g,b) [UIColor colorWithRed:r/255.f green:g/255.f blue:b/255.f alpha:1]

#define THEME_TEXT_COLOR RGB_COLOR(239, 107, 42)

#import "UserModel.h"
#import "DHConvenienceAutoLayout.h"
#import "DHFoundationTool.h"

#endif
67 changes: 67 additions & 0 deletions DeepBreathing/ThirdLib/AFNetworking/AFHTTPRequestOperation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// AFHTTPRequestOperation.h
//
// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import <Foundation/Foundation.h>
#import "AFURLConnectionOperation.h"

/**
`AFHTTPRequestOperation` is a subclass of `AFURLConnectionOperation` for requests using the HTTP or HTTPS protocols. It encapsulates the concept of acceptable status codes and content types, which determine the success or failure of a request.
*/
@interface AFHTTPRequestOperation : AFURLConnectionOperation

///------------------------------------------------
/// @name Getting HTTP URL Connection Information
///------------------------------------------------

/**
The last HTTP response received by the operation's connection.
*/
@property (readonly, nonatomic, strong) NSHTTPURLResponse *response;

/**
Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an AFHTTPResponse serializer, which uses the raw data as its response object. The serializer validates the status code to be in the `2XX` range, denoting success. If the response serializer generates an error in `-responseObjectForResponse:data:error:`, the `failure` callback of the session task or request operation will be executed; otherwise, the `success` callback will be executed.
@warning `responseSerializer` must not be `nil`. Setting a response serializer will clear out any cached value
*/
@property (nonatomic, strong) AFHTTPResponseSerializer <AFURLResponseSerialization> * responseSerializer;

/**
An object constructed by the `responseSerializer` from the response and response data. Returns `nil` unless the operation `isFinished`, has a `response`, and has `responseData` with non-zero content length. If an error occurs during serialization, `nil` will be returned, and the `error` property will be populated with the serialization error.
*/
@property (readonly, nonatomic, strong) id responseObject;

///-----------------------------------------------------------
/// @name Setting Completion Block Success / Failure Callbacks
///-----------------------------------------------------------

/**
Sets the `completionBlock` property with a block that executes either the specified success or failure block, depending on the state of the request on completion. If `error` returns a value, which can be caused by an unacceptable status code or content type, then `failure` is executed. Otherwise, `success` is executed.
This method should be overridden in subclasses in order to specify the response object passed into the success block.
@param success The block to be executed on the completion of a successful request. This block has no return value and takes two arguments: the receiver operation and the object constructed from the response data of the request.
@param failure The block to be executed on the completion of an unsuccessful request. This block has no return value and takes two arguments: the receiver operation and the error that occurred during the request.
*/
- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;

@end
Loading

0 comments on commit 455ba8c

Please sign in to comment.