Commit 109f149b authored by Achilles's avatar Achilles

提交通知

parent 79976f0e
......@@ -3,14 +3,14 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'
xcodeproj 'vanke.xcodeproj'
#pod 'AFNetworking', '~> 2.3.1'
pod 'AFNetworking', '~> 2.3.1'
#pod 'ASIHTTPRequest', '~> 1.8.2'
#pod 'KissXML', '~> 5.0'
#pod 'SSCheckBoxView', '~> 0.0.1'
#pod 'jastor', '~> 0.2.1'
pod 'PNChart', '~> 0.8.7'
pod 'CocoaSecurity'
#pod 'FMDB', '~> 2.5'
pod 'FMDB', '~> 2.5'
#pod 'MMProgressHUD', '~> 0.3.1'
pod 'MBProgressHUD', '~> 0.9.1'
#pod 'SBJson', '~> 3.2'
......@@ -27,6 +27,8 @@ pod 'SDWebImage', '~> 3.7.1'
#pod 'iVersion','~>1.11.4'
#pod 'Reveal-iOS-SDK', :configurations => ['Debug']
pod 'CustomBadge', '~> 3.0.0'
#should be removed later
#pod 'CocoaAsyncSocket', '~> 7.4.1'
#pod 'CocoaLumberjack', '~> 2.0.0'
\ No newline at end of file
This diff is collapsed.
//
// ICRDataBaseController.h
// Cruiser
//
// Created by Xummer on 4/5/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import "IBTObject.h"
#import "FMDB.h"
typedef void (^ICRDatabaseUpdateBlock)(FMDatabase *db);
typedef FMResultSet *(^ICRDatabaseFetchBlock)(FMDatabase *db);
typedef void(^ICRDatabaseFetchResultsBlock)(NSArray *fetchedObjects);
@protocol IBTDatabaseObject;
@interface ICRDataBaseController : IBTObject
+ (instancetype)sharedController;
+ (NSString *)GetDataBasePath;
+ (void)CleanUpDBPath;
#pragma mark - Storage
- (void)storageEntities:(NSArray *)arrObjects
objectClass:(Class<IBTDatabaseObject>)DBObjClass
deleteLocal:(BOOL)bDeleteLocal
handleData:(void (^)(id <IBTDatabaseObject>))handleDataBlock
complete:(void (^)(void))complete
fail:(void (^)(NSError *))fail;
- (void)storageEntities:(NSArray *)arrObjects
objectClass:(Class<IBTDatabaseObject>)DBObjClass
updateNil:(BOOL)bUpdateNil
deleteLocal:(BOOL)bDeleteLocal
handleData:(void (^)(id <IBTDatabaseObject>))handleDataBlock
complete:(void (^)(void))complete
fail:(void (^)(NSError *))fail;
- (void)storageEntity:(NSDictionary *)dictObject
objectClass:(Class<IBTDatabaseObject>)DBObjClass
handleData:(void (^)(id <IBTDatabaseObject>))handleDataBlock
complete:(void (^)(void))complete
fail:(void (^)(NSError *))fail;
- (void)storageDBObject:(id<IBTDatabaseObject>)dbObj
handleData:(void (^)(id <IBTDatabaseObject>))handleDataBlock
complete:(void (^)(void))complete
fail:(void (^)(NSError *))fail;
#pragma mark - Query
- (void)runFetchForClass:(Class<IBTDatabaseObject>)dbObjClass
fetchBlock:(ICRDatabaseFetchBlock)fetchBlock
fetchResultsBlock:(ICRDatabaseFetchResultsBlock)fetchResultBlock;
@end
//
// ICRDataBaseController.m
// Cruiser
//
// Created by Xummer on 4/5/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import "ICRDataBaseController.h"
//#import "ICRStore.h"
//#import "ICRTask.h"
//#import "ICRPostTask.h"
#import "ICRAttachment.h"
#import "ICRAnnouncement.h"
#import "IBTCommon.h"
#import "ICRUtilsMacro.h"
#import "NSMutableArray+SafeInsert.h"
//#import "ICRPatrolPlan.h"
//#import "ICRPost.h"
//#import "ICRQuestion.h"
//#import "ICRStoreResult.h"
//#import "ICRAnswer.h"
//#import "ICRAnswerDetail.h"
#define ICR_DB_ERROR_PARAMETER @"Parse Error: Bad Parameter(s)"
NSString * const ICRDataBaseErrorDomain = @"ICRDataBaseErrorDomain";
static NSString *ICRDataBasePath = @"";
@interface ICRDataBaseController ()
@property (strong, nonatomic) FMDatabaseQueue *m_dbQueue;
@end
@implementation ICRDataBaseController
#pragma mark - Class Method
+ (instancetype)sharedController {
static ICRDataBaseController *_sharedController = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedController = [[self alloc] init];
});
return _sharedController;
}
+ (NSString *)GetDataBasePath {
if (ICRDataBasePath.length == 0) {
NSString *archivePath = [IBTCommon archivePathForCurrentUser];
if (!archivePath.length) {
return ICRDataBasePath;
}
NSString *dbName = @"db";
NSString *sqliteName = [dbName stringByAppendingPathExtension:@"sqlite"];
ICRDataBasePath = [archivePath stringByAppendingPathComponent:sqliteName];
return ICRDataBasePath;
}
else {
return ICRDataBasePath;
}
}
+ (void)CleanUpDBPath {
ICRDataBasePath = @"";
}
+ (NSError *)ErrorWithMsg:(NSString *)nsErrorMsg code:(NSInteger)uiCode {
NSDictionary *userInfo =
nsErrorMsg ? @{ NSLocalizedFailureReasonErrorKey : nsErrorMsg } : nil;
NSError *error =
[[NSError alloc] initWithDomain:ICRDataBaseErrorDomain
code:uiCode userInfo:userInfo];
return error;
}
#pragma mark - Life Cycle
- (instancetype)init {
self = [super init];
if (!self) {
return nil;
}
NSString *nsDBPath = [[self class] GetDataBasePath];
self.m_dbQueue = [FMDatabaseQueue databaseQueueWithPath:nsDBPath];
[_m_dbQueue inDatabase:^(FMDatabase *db) {
NSArray *tableNameArr =
@[ [ICRAttachment class], [ICRAnnouncement class]];
NSMutableArray *sqlBatch = [NSMutableArray array];
NSString *sql = nil;
for (id <IBTDatabaseObject> cls in tableNameArr) {
sql = [cls SQLForCreateTable];
[sqlBatch safeAddObject:sql];
}
NSMutableString *nsSQLBatch = [[NSMutableString alloc] initWithString:@""];
for (NSString *aSQL in sqlBatch) {
[nsSQLBatch appendFormat:@"%@;", aSQL];
}
BOOL res = [db executeStatements:nsSQLBatch];
if (!res) {
NSLog(@"error to run SQL: %@", sql);
}
}];
return self;
}
#pragma mark - Storage
- (void)storageEntities:(NSArray *)arrObjects
objectClass:(Class<IBTDatabaseObject>)DBObjClass
deleteLocal:(BOOL)bDeleteLocal
handleData:(void (^)(id <IBTDatabaseObject>))handleDataBlock
complete:(void (^)(void))complete
fail:(void (^)(NSError *))fail
{
[self storageEntities:arrObjects objectClass:DBObjClass updateNil:YES deleteLocal:bDeleteLocal handleData:handleDataBlock complete:complete fail:fail];
}
- (void)storageEntities:(NSArray *)arrObjects
objectClass:(Class<IBTDatabaseObject>)DBObjClass
updateNil:(BOOL)bUpdateNil
deleteLocal:(BOOL)bDeleteLocal
handleData:(void (^)(id <IBTDatabaseObject>))handleDataBlock
complete:(void (^)(void))complete
fail:(void (^)(NSError *))fail
{
if (!IsArrayObject(arrObjects)) {
if (fail) {
fail( [[self class] ErrorWithMsg:ICR_DB_ERROR_PARAMETER code:0] );
}
}
NSString *nsTableName = [DBObjClass TableName];
NSString *nsSortKey = [DBObjClass PrimaryKey];
NSString *nsDBSortKey = nsSortKey;
NSArray *arrSortedObjects = [arrObjects sortedArrayUsingComparator:^NSComparisonResult(id a, id b) {
id first = a[ nsSortKey ];
id second = b[ nsSortKey ];
return [first compare:second];
}];
NSArray *arrIDs = [arrSortedObjects valueForKeyPath:nsSortKey];
NSMutableArray *arrModObjs = [NSMutableArray array];
for (id obj in arrObjects) {
id<IBTDatabaseObject> dbObj = [DBObjClass DBObject];
[dbObj praseFromJsonDict:obj isNilLeague:bUpdateNil];
[arrModObjs addObject:dbObj];
}
[_m_dbQueue inTransaction:^(FMDatabase *db, BOOL *rollback) {
if (bDeleteLocal) {
NSMutableString *sql = [NSMutableString stringWithFormat:@"DELETE FROM %@ ", nsTableName];
NSUInteger uiRecordCount = [arrIDs count];
if (uiRecordCount > 0) {
[sql appendFormat:@"WHERE %@ NOT IN %@", nsDBSortKey, [IBTModel ValuePlaceholdersWithCount:uiRecordCount]];
}
NSLog(@"%@", sql);
[db executeUpdate:sql withArgumentsInArray:arrIDs];
}
@autoreleasepool {
NSString *nsSql = nil;
NSArray *arrValues = nil;
for (id<IBTDatabaseObject> dbObj in arrModObjs) {
if (handleDataBlock) {
handleDataBlock( dbObj );
}
nsSql = [dbObj SQLForInsertOrUpdate:&arrValues];
[db executeUpdate:nsSql withArgumentsInArray:arrValues];
for (id<IBTDatabaseObject> subObj in dbObj.arrSubModels) {
nsSql = [subObj SQLForInsertOrUpdate:&arrValues];
[db executeUpdate:nsSql withArgumentsInArray:arrValues];
}
}
}
}];
if (complete) {
complete();
}
}
- (void)storageEntity:(NSDictionary *)dictObject
objectClass:(Class<IBTDatabaseObject>)DBObjClass
handleData:(void (^)(id <IBTDatabaseObject>))handleDataBlock
complete:(void (^)(void))complete
fail:(void (^)(NSError *))fail
{
if (!IsDictObject(dictObject)) {
if (fail) {
fail( [[self class] ErrorWithMsg:ICR_DB_ERROR_PARAMETER code:0] );
}
}
__block id<IBTDatabaseObject> dbObj = [DBObjClass DBObject];
[dbObj praseFromJsonDict:dictObject];
[_m_dbQueue inDatabase:^(FMDatabase *db) {
if (handleDataBlock) {
handleDataBlock( dbObj );
}
NSString *nsSql = nil;
NSArray *arrValues = nil;
nsSql = [dbObj SQLForInsertOrUpdate:&arrValues];
[db executeUpdate:nsSql withArgumentsInArray:arrValues];
for (id<IBTDatabaseObject> subObj in dbObj.arrSubModels) {
nsSql = [subObj SQLForInsertOrUpdate:&arrValues];
[db executeUpdate:nsSql withArgumentsInArray:arrValues];
}
}];
if (complete) {
complete();
}
}
- (void)storageDBObject:(id<IBTDatabaseObject>)dbObj
handleData:(void (^)(id <IBTDatabaseObject>))handleDataBlock
complete:(void (^)(void))complete
fail:(void (^)(NSError *))fail
{
if (!dbObj) {
if (fail) {
fail( [[self class] ErrorWithMsg:ICR_DB_ERROR_PARAMETER code:0] );
}
}
[_m_dbQueue inDatabase:^(FMDatabase *db) {
if (handleDataBlock) {
handleDataBlock( dbObj );
}
NSString *nsSql = nil;
NSArray *arrValues = nil;
nsSql = [dbObj SQLForInsertOrUpdate:&arrValues];
[db executeUpdate:nsSql withArgumentsInArray:arrValues];
for (id<IBTDatabaseObject> subObj in dbObj.arrSubModels) {
nsSql = [subObj SQLForInsertOrUpdate:&arrValues];
[db executeUpdate:nsSql withArgumentsInArray:arrValues];
}
}];
if (complete) {
complete();
}
}
#pragma mark - Query
- (void)runFetchForClass:(Class<IBTDatabaseObject>)dbObjClass
fetchBlock:(ICRDatabaseFetchBlock)fetchBlock
fetchResultsBlock:(ICRDatabaseFetchResultsBlock)fetchResultBlock
{
NSParameterAssert(dbObjClass); NSParameterAssert(fetchBlock); NSParameterAssert(fetchResultBlock);
[_m_dbQueue inDatabase:^(FMDatabase *db) {
FMResultSet *rs = fetchBlock(db);
if (rs == nil && db.lastError != nil) {
[NSException raise:[NSString stringWithFormat:@"%@Exception", self.class]
format:@"Invalid querry: %@", db.lastError];
fetchResultBlock(nil);
return;
}
NSArray *fetchedObjects = [self databaseObjectsWithResultSet:rs
class:dbObjClass];
dispatch_async(dispatch_get_main_queue(), ^{
fetchResultBlock(fetchedObjects);
});
}];
}
- (NSArray *)databaseObjectsWithResultSet:(FMResultSet *)resultSet
class:(Class<IBTDatabaseObject>)dbObjClass
{
NSMutableArray *arrObjs = [NSMutableArray array];
while ([resultSet next]) {
id obj = [dbObjClass objectFromFetchResult:resultSet];
if (obj) {
[arrObjs addObject:obj];
}
}
return [arrObjs count] > 0 ? arrObjs : nil;
}
@end
//
// ICRHTTPController.h
// Cruiser
//
// Created by Xummer on 3/26/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import "IBTObject.h"
#import "ICRAnnouncement.h"
typedef NS_ENUM(NSUInteger, ICRAttachmentType) {
kAttachmentBoard = 0,
kAttachmentAnswer,
kAttachmentTask,
// Insert enum here
kAttachmentTypeCount,
};
@interface ICRHTTPController : IBTObject
+ (instancetype)sharedController;
// Restful API
// User
/* 用户登录验证(读)*/
- (void)doLoginWithUserName:(NSString *)userName
password:(NSString *)password
registerCode:(NSString *)registerCode
success:(void (^)(id data))succ
failure:(void (^)(id data))fail;
/* 密码修改(写)*/
- (void)doChangePassword:(NSString *)nsPassword
newPassword:(NSString *)nsNewPassword
success:(void (^)(id data))succ
failure:(void (^)(id data))fail;
// Data
/* 门店基本资料(读)
返回最后修改日期从某时刻开始的该用户可见的门店
*/
- (void)doGetStoreListFromUpdateTime:(NSTimeInterval)updateTime
position:(NSUInteger)uiPosition
size:(NSUInteger)uiSize
success:(void (^)(id data))succ
failure:(void (^)(id data))fail;
/* 组织架构基本资料(读)
获得本人所属组织
*/
- (void)doGetCurrentOrgWithSuccess:(void (^)(id data))succ
failure:(void (^)(id data))fail;
/* 任务类别基本资料
获得本人所属组织的工单类别信息,提任务单时需要用
*/
- (void)doGetPersonListFromUpdateTime:(NSString *)updateTime
position:(NSUInteger)uiPosition
size:(NSUInteger)uiSize
success:(void (^)(id data))succ
failure:(void (^)(id data))fail;
// Board
/* 公告列表(读)
获得公告列表
*/
- (void)doGetBoardListFromUpdateTime:(NSString *)updateTime
position:(NSUInteger)uiPosition
size:(NSUInteger)uiSize
type:(ICRAnnouncementType)eType
deleteLocal:(BOOL)bDeleteLocal
success:(void (^)(id data))succ
failure:(void (^)(id data))fail;
/* 读取公告(读)
读取单个公告
*/
- (void)doGetBoardWithID:(NSNumber *)boardID
success:(void (^)(id data))succ
failure:(void (^)(id data))fail;
/* 提交公告已读状态(写)*/
- (void)doReadBoardWithID:(NSNumber *)boardID
success:(void (^)(id data))succ
failure:(void (^)(id data))fail;
// Patrol
/* 巡店计划列表(读)
获得发布给自己的巡店计划
*/
- (void)doGetMyPatrolFromUpdateTime:(NSString *)updateTime
position:(NSUInteger)uiPosition
size:(NSUInteger)uiSize
success:(void (^)(id data))succ
failure:(void (^)(id data))fail;
/* 下载某个门店结果(读)*/
- (void)doGetStoreResultWithPlanID:(NSString *)planID
storeID:(NSString *)storeID
success:(void (^)(id data))succ
failure:(void (^)(id data))fail;
/* 巡店计划处理结果(写)*/
- (void)doAnswerPatrolPlanWithID:(NSNumber *)planID
infoData:(id)data
success:(void (^)(id data))succ
failure:(void (^)(id data))fail;
/* 巡店计划某个问题处理结果
需要先调用接口|doAnswerPlanWithID:postData:success:failure:|,得到门店报告id
*/
- (void)doAnswerOnePatrolResultWithID:(NSNumber *)resultID
infoData:(id)data
success:(void (^)(id data))succ
failure:(void (^)(id data))fail;
/* 任务列表(读)*/
- (void)doGetTaskListFromUpdateTime:(NSString *)updateTime
position:(NSUInteger)uiPosition
size:(NSUInteger)uiSize
success:(void (^)(id data))succ
failure:(void (^)(id data))fail;
/* 新增任务(写)*/
- (void)doCreateNewTaskWithInfo:(id)data
success:(void (^)(id data))succ
failure:(void (^)(id data))fail;
/* 任务处理结果(写)*/
- (void)doUpdateTaskResultID:(NSString *)resultID
resultText:(NSString *)resultStr
processDate:(NSTimeInterval)processDate
success:(void (^)(id data))succ
failure:(void (^)(id data))fail;
// Signup
/* 签到信息提交(写)*/
- (void)doSignupWithInfo:(id)data
success:(void (^)(id data))succ
failure:(void (^)(id data))fail;
// Attachment
/* 添加附件(读)*/
- (void)doAddAttachment:(id)data
success:(void (^)(id data))succ
failure:(void (^)(id data))fail;
/* 返回附件列表 */
- (void)doGetAttachmentListWithType:(ICRAttachmentType)eType
objID:(NSString *)objID
success:(void (^)(id data))succ
failure:(void (^)(id data))fail;
/* 下载附件 */
- (void)doDownloadAttachmentWithID:(NSNumber *)attachmentID
success:(void (^)(id data))succ
failure:(void (^)(id data))fail;
/* 添加附件(读)直接上传方式 */
- (void)doAddDirectAttachment:(id)data
success:(void (^)(id))succ
failure:(void (^)(id))fail;
+ (NSString *)AttachmentUrlWithID:(id)attachmentID;
/* 下载附件,直接下载方式 */
- (void)doDownloadDirectAttachment:(NSString *)attachmentId
success:(void (^)(id))succ
failure:(void (^)(id))fail;
// Version
/* 查询版本(读)*/
- (void)doFetchVersionWithCurrent:(NSString *)currentVersion
success:(void (^)(id))succ
failure:(void (^)(id))fail;
@end
This diff is collapsed.
//
// IBTBaseEntity.h
//
//
// Created by Xummer on 15/4/7.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "IBTObject.h"
@class FMResultSet;
@protocol IBTDatabaseObject <NSObject>
@property (strong, nonatomic) NSMutableArray *arrSubModels;
+ (id)DBObject;
+ (id)objectFromFetchResult:(FMResultSet *)result;
- (void)updateFromFetchResult:(FMResultSet *)result;
// Fuctions
- (NSDictionary *)dictForCommit;
- (NSDictionary *)dictForLocalSave;
- (void)praseFromJsonDict:(NSDictionary *)dict;
- (void)praseFromLocalDict:(NSDictionary *)dict;
- (void)praseFromJsonDict:(NSDictionary *)dict isNilLeague:(BOOL)bIsNilLeague;
// SQLite
+ (NSString *)TableName;
+ (NSString *)PrimaryKey;
+ (NSArray *)PrimaryKeys;
- (NSString *)SQLForInsertOrUpdate:(NSArray * __autoreleasing *)pValues;
+ (NSString *)SQLForCreateTable;
+ (NSString *)SQLForUpdateKeyValueDict:(NSDictionary *)kvDict
WhereInfoStr:(NSString *)nsWhereInfoStr;
+ (NSString *)SQLForUpdateKeyValueDict:(NSDictionary *)kvDict
WhereInfo:(NSDictionary *)dictWhere;
- (void)saveToDBWithHandleData:(void (^)(id <IBTDatabaseObject>))handleDataBlock
complete:(void (^)(void))complete
fail:(void (^)(NSError *))fail;
@end
@interface IBTModel : IBTObject <IBTDatabaseObject>
// 需要替换的 keys map, @"|property key|" : @"|json key|", 如: @{ @"customID" : @"id" }
+ (NSDictionary *)specialKeysAndReplaceKeys;
// 不需要解析的键值对 的 Key
+ (NSArray *)customAcitonKeys;
// 不需要从json中解析,但是要写入本地数据库的 Key
+ (NSArray *)localKeys;
/*
formate (?,?,?)
*/
+ (NSString *)ValuePlaceholdersWithCount:(NSUInteger)uiCount;
@end
This diff is collapsed.
//
// IBTWebProgressBar.h
// IBTWebViewController
//
// Created by Xummer on 14/12/31.
// Copyright (c) 2014年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface IBTWebProgressBar : UIView
@property (assign) BOOL bIsFinish;
@property (assign) CGRect oriFrame;
- (CGFloat)durationOfPhase1;
- (CGFloat)durationOfPhase2;
- (CGFloat)durationOfPhase3;
- (CGFloat)durationOfPhase4;
- (void)start;
- (void)progressing;
- (void)end;
- (void)reset;
@end
//
// IBTWebProgressBar.m
// IBTWebViewController
//
// Created by Xummer on 14/12/31.
// Copyright (c) 2014年 Xummer. All rights reserved.
//
#define PROGRESS_PHASE_1 (.1f)
#define PROGRESS_PHASE_2 (.6f)
#define PROGRESS_PHASE_3 (.8f)
#define PROGRESS_PHASE_4 (.9f)
#define ANIM_DURATION_UNIT (.2f)
#define PROGRESS_FADEOUT_DELAY (.1f)
#define PROGRESS_FADE_DURATION (0.27f)
#import "IBTWebProgressBar.h"
//@import QuartzCore;
@interface IBTWebProgressBar ()
@end
@implementation IBTWebProgressBar
#pragma mark - Life Cycle
- (instancetype)initWithFrame:(CGRect)frame {
CGRect rect = frame;
rect.size.width = 0;
self = [super initWithFrame:rect];
if (!self) {
return nil;
}
self.bIsFinish = YES;
self.oriFrame = frame;
UIColor *tintColor = [UIColor colorWithRed:22.f / 255.f green:126.f / 255.f blue:251.f / 255.f alpha:1.0]; // iOS7 Safari bar color
if ([UIApplication.sharedApplication.delegate.window respondsToSelector:@selector(setTintColor:)] && UIApplication.sharedApplication.delegate.window.tintColor) {
tintColor = UIApplication.sharedApplication.delegate.window.tintColor;
}
self.backgroundColor = tintColor;
return self;
}
// 0 - 10% 3
- (CGFloat)durationOfPhase1 {
return ANIM_DURATION_UNIT * 3;
}
// 10 - 60% 2
- (CGFloat)durationOfPhase2 {
return ANIM_DURATION_UNIT * 2 * 5;
}
// 60% - 80% 3
- (CGFloat)durationOfPhase3 {
return ANIM_DURATION_UNIT * 2 * 3;
}
// 80% - 90% 5
- (CGFloat)durationOfPhase4 {
return ANIM_DURATION_UNIT * 5;
}
// 90% - 100%
- (void)progressing {
// Waiting
}
- (void)updateProgress:(CGFloat)fProgress {
fProgress = MIN(MAX(fProgress, 0), 1);
CGRect rect = self.frame;
rect.size.width = fProgress * CGRectGetWidth(self.oriFrame);
self.frame = rect;
}
#pragma mark - Actions
- (void)start {
self.alpha = 1;
self.hidden = NO;
self.bIsFinish = NO;
__weak typeof(self)weakSelf = self;
void (^animOfPhaseProcess)(BOOL) = ^(BOOL finished) {
if (!finished) {
return;
}
__strong __typeof(weakSelf)strongSelf = weakSelf;
strongSelf.bIsFinish = YES;
[strongSelf progressing];
};
void (^animOfPhase4)(BOOL) = ^(BOOL finished) {
if (!finished) {
return;
}
[UIView animateWithDuration:[self durationOfPhase4] delay:0
options:UIViewAnimationOptionCurveEaseOut
animations:^{
__strong __typeof(weakSelf)strongSelf = weakSelf;
[strongSelf updateProgress:PROGRESS_PHASE_4];
}
completion:animOfPhaseProcess];
};
void (^animOfPhase3)(BOOL) = ^(BOOL finished) {
if (!finished) {
return;
}
[UIView animateWithDuration:[self durationOfPhase3] delay:0
options:UIViewAnimationOptionCurveEaseOut
animations:^{
__strong __typeof(weakSelf)strongSelf = weakSelf;
[strongSelf updateProgress:PROGRESS_PHASE_3];
}
completion:animOfPhase4];
};
void (^animOfPhase2)(BOOL) = ^(BOOL finished) {
if (!finished) {
return;
}
[UIView animateWithDuration:[self durationOfPhase2] delay:0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
__strong __typeof(weakSelf)strongSelf = weakSelf;
[strongSelf updateProgress:PROGRESS_PHASE_2];
}
completion:animOfPhase3];
};
[UIView animateWithDuration:[self durationOfPhase1] delay:0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
__strong __typeof(weakSelf)strongSelf = weakSelf;
[strongSelf updateProgress:PROGRESS_PHASE_1];
}
completion:animOfPhase2];
}
- (void)end {
if (!_bIsFinish) {
[self.layer removeAllAnimations];
}
__weak typeof(self)weakSelf = self;
void (^animOfDismiss)(BOOL) = ^(BOOL finished) {
if (!finished) {
return;
}
[UIView animateWithDuration:PROGRESS_FADE_DURATION
delay:PROGRESS_FADEOUT_DELAY
options:UIViewAnimationOptionCurveEaseOut
animations:^{
__strong __typeof(weakSelf)strongSelf = weakSelf;
strongSelf.alpha = 0;
}
completion:^(BOOL finished) {
if (!finished) {
return;
}
__strong __typeof(weakSelf)strongSelf = weakSelf;
strongSelf.hidden = YES;
[strongSelf updateProgress:0];
strongSelf.bIsFinish = YES;
}];
};
[UIView animateWithDuration:ANIM_DURATION_UNIT delay:0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
__strong __typeof(weakSelf)strongSelf = weakSelf;
[strongSelf updateProgress:1];
}
completion:animOfDismiss];
}
- (void)reset {
if (!_bIsFinish) {
[self.layer removeAllAnimations];
self.bIsFinish = YES;
}
[self updateProgress:0];
}
@end
//
// IBTWebViewController.h
// IBTWebViewController
//
// Created by Xummer on 14/12/29.
// Copyright (c) 2014年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "ICRBaseViewController.h"
@protocol IBTWebViewDelegate;
@interface IBTWebViewController : ICRBaseViewController
@property (weak, nonatomic) id<IBTWebViewDelegate> m_delegate;
- (id)initWithURL:(id)url presentModal:(BOOL)modal extraInfo:(NSDictionary *)info;
- (void)setAutoSetTitle:(BOOL)bAutoSet;
@end
\ No newline at end of file
This diff is collapsed.
//
// IBTWebViewDelegate.h
// IBTWebViewController
//
// Created by Xummer on 14/12/30.
// Copyright (c) 2014年 Xummer. All rights reserved.
//
#import <Foundation/Foundation.h>
@protocol IBTWebViewDelegate <NSObject>
@optional
- (void)onWebViewWillClose:(UIWebView *)webView;
- (void)onWebViewDidFinishLoad:(UIWebView *)webView;
- (void)onWebViewDidStartLoad:(UIWebView *)webView;
- (void)webViewFailToLoad:(NSError *)error;
@end
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
typedef enum tagBorderType
{
BorderTypeDashed,
BorderTypeSolid
}BorderType;
@interface LBorderView : UIView
{
CAShapeLayer *_shapeLayer;
BorderType _borderType;
CGFloat _cornerRadius;
CGFloat _borderWidth;
NSUInteger _dashPattern;
NSUInteger _spacePattern;
UIColor *_borderColor;
}
@property (assign, nonatomic) BorderType borderType;
@property (assign, nonatomic) CGFloat cornerRadius;
@property (assign, nonatomic) CGFloat borderWidth;
@property (assign, nonatomic) NSUInteger dashPattern;
@property (assign, nonatomic) NSUInteger spacePattern;
@property (strong, nonatomic) UIColor *borderColor;
@end
\ No newline at end of file
#import "LBorderView.h"
@implementation LBorderView
#pragma mark - Synthesize
@synthesize borderType = _borderType;
@synthesize cornerRadius = _cornerRadius;
@synthesize borderWidth = _borderWidth;
@synthesize dashPattern = _dashPattern;
@synthesize spacePattern = _spacePattern;
@synthesize borderColor = _borderColor;
#pragma mark - Init
- (id)init
{
self = [super init];
if (self)
{
[self initialize];
}
return self;
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
[self initialize];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self)
{
[self initialize];
}
return self;
}
- (void)initialize
{
[self drawDashedBorder];
}
#pragma mark - Drawing
- (void)drawDashedBorder
{
if (_shapeLayer) [_shapeLayer removeFromSuperlayer];
//border definitions
CGFloat cornerRadius = _cornerRadius;
CGFloat borderWidth = _borderWidth;
NSInteger dashPattern1 = _dashPattern;
NSInteger dashPattern2 = _spacePattern;
UIColor *lineColor = _borderColor ? _borderColor : [UIColor blackColor];
//drawing
CGRect frame = self.bounds;
_shapeLayer = [CAShapeLayer layer];
//creating a path
CGMutablePathRef path = CGPathCreateMutable();
//drawing a border around a view
CGPathMoveToPoint(path, NULL, 0, frame.size.height - cornerRadius);
CGPathAddLineToPoint(path, NULL, 0, cornerRadius);
CGPathAddArc(path, NULL, cornerRadius, cornerRadius, cornerRadius, M_PI, -M_PI_2, NO);
CGPathAddLineToPoint(path, NULL, frame.size.width - cornerRadius, 0);
CGPathAddArc(path, NULL, frame.size.width - cornerRadius, cornerRadius, cornerRadius, -M_PI_2, 0, NO);
CGPathAddLineToPoint(path, NULL, frame.size.width, frame.size.height - cornerRadius);
CGPathAddArc(path, NULL, frame.size.width - cornerRadius, frame.size.height - cornerRadius, cornerRadius, 0, M_PI_2, NO);
CGPathAddLineToPoint(path, NULL, cornerRadius, frame.size.height);
CGPathAddArc(path, NULL, cornerRadius, frame.size.height - cornerRadius, cornerRadius, M_PI_2, M_PI, NO);
//path is set as the _shapeLayer object's path
_shapeLayer.path = path;
CGPathRelease(path);
_shapeLayer.backgroundColor = [[UIColor clearColor] CGColor];
_shapeLayer.frame = frame;
_shapeLayer.masksToBounds = NO;
[_shapeLayer setValue:[NSNumber numberWithBool:NO] forKey:@"isCircle"];
_shapeLayer.fillColor = [[UIColor clearColor] CGColor];
_shapeLayer.strokeColor = [lineColor CGColor];
_shapeLayer.lineWidth = borderWidth;
_shapeLayer.lineDashPattern = _borderType == BorderTypeDashed ? [NSArray arrayWithObjects:@( dashPattern1 ), @( dashPattern2 ), nil] : nil;
_shapeLayer.lineCap = kCALineCapRound;
//_shapeLayer is added as a sublayer of the view
[self.layer addSublayer:_shapeLayer];
self.layer.cornerRadius = cornerRadius;
}
#pragma mark - Setters
- (void)setFrame:(CGRect)frame
{
[super setFrame:frame];
[self drawDashedBorder];
}
- (void)setBorderType:(BorderType)borderType
{
_borderType = borderType;
[self drawDashedBorder];
}
- (void)setCornerRadius:(CGFloat)cornerRadius
{
_cornerRadius = cornerRadius;
[self drawDashedBorder];
}
- (void)setBorderWidth:(CGFloat)borderWidth
{
_borderWidth = borderWidth;
[self drawDashedBorder];
}
- (void)setDashPattern:(NSUInteger)dashPattern
{
_dashPattern = dashPattern;
[self drawDashedBorder];
}
- (void)setSpacePattern:(NSUInteger)spacePattern
{
_spacePattern = spacePattern;
[self drawDashedBorder];
}
- (void)setBorderColor:(UIColor *)borderColor
{
_borderColor = borderColor;
[self drawDashedBorder];
}
#pragma mark -
@end
\ No newline at end of file
//
// UIPopoverListView.h
// UIPopoverListViewDemo
//
// Created by su xinde on 13-3-13.
// Copyright (c) 2013年 su xinde. All rights reserved.
//
@class UIPopoverListView;
@protocol UIPopoverListViewDataSource <NSObject>
@required
- (UITableViewCell *)popoverListView:(UIPopoverListView *)popoverListView
cellForIndexPath:(NSIndexPath *)indexPath;
- (NSInteger)popoverListView:(UIPopoverListView *)popoverListView
numberOfRowsInSection:(NSInteger)section;
@end
@protocol UIPopoverListViewDelegate <NSObject>
@optional
- (void)popoverListView:(UIPopoverListView *)popoverListView
didSelectIndexPath:(NSIndexPath *)indexPath;
- (void)popoverListViewCancel:(UIPopoverListView *)popoverListView;
- (CGFloat)popoverListView:(UIPopoverListView *)popoverListView
heightForRowAtIndexPath:(NSIndexPath *)indexPath;
@end
@interface UIPopoverListView : UIView <UITableViewDataSource, UITableViewDelegate>
{
UITableView *_listView;
UILabel *_titleView;
UIControl *_overlayView;
id<UIPopoverListViewDataSource> datasource;
id<UIPopoverListViewDelegate> delegate;
}
@property (nonatomic, assign) id<UIPopoverListViewDataSource> datasource;
@property (nonatomic, assign) id<UIPopoverListViewDelegate> delegate;
@property (nonatomic, retain) UITableView *listView;
- (void)setTitle:(NSString *)title;
- (void)show;
- (void)dismiss;
@end
//
// UIPopoverListView.m
// UIPopoverListViewDemo
//
// Created by su xinde on 13-3-13.
// Copyright (c) 2013年 su xinde. All rights reserved.
//
#import "UIPopoverListView.h"
#import <QuartzCore/QuartzCore.h>
//#define FRAME_X_INSET 20.0f
//#define FRAME_Y_INSET 40.0f
@interface UIPopoverListView ()
- (void)defalutInit;
- (void)fadeIn;
- (void)fadeOut;
@end
@implementation UIPopoverListView
@synthesize datasource = _datasource;
@synthesize delegate = _delegate;
@synthesize listView = _listView;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self defalutInit];
}
return self;
}
- (void)defalutInit
{
self.layer.borderColor = [[UIColor lightGrayColor] CGColor];
self.layer.borderWidth = 1.0f;
self.layer.cornerRadius = 10.0f;
self.clipsToBounds = TRUE;
_titleView = [[UILabel alloc] initWithFrame:CGRectZero];
_titleView.font = [UIFont systemFontOfSize:17.0f];
_titleView.backgroundColor = [UIColor colorWithRed:59./255.
green:89./255.
blue:152./255.
alpha:1.0f];
_titleView.textAlignment = UITextAlignmentCenter;
_titleView.textColor = [UIColor whiteColor];
CGFloat xWidth = self.bounds.size.width;
_titleView.lineBreakMode = UILineBreakModeTailTruncation;
_titleView.frame = CGRectMake(0, 0, xWidth, 32.0f);
[self addSubview:_titleView];
CGRect tableFrame = CGRectMake(0, 32.0f, xWidth, self.bounds.size.height-32.0f);
_listView = [[UITableView alloc] initWithFrame:tableFrame style:UITableViewStylePlain];
_listView.dataSource = self;
_listView.delegate = self;
[self addSubview:_listView];
_overlayView = [[UIControl alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
_overlayView.backgroundColor = [UIColor colorWithRed:.16 green:.17 blue:.21 alpha:.5];
[_overlayView addTarget:self
action:@selector(dismiss)
forControlEvents:UIControlEventTouchUpInside];
}
#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if(self.datasource &&
[self.datasource respondsToSelector:@selector(popoverListView:numberOfRowsInSection:)])
{
return [self.datasource popoverListView:self numberOfRowsInSection:section];
}
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(self.datasource &&
[self.datasource respondsToSelector:@selector(popoverListView:cellForIndexPath:)])
{
return [self.datasource popoverListView:self cellForIndexPath:indexPath];
}
return nil;
}
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(self.delegate &&
[self.delegate respondsToSelector:@selector(popoverListView:heightForRowAtIndexPath:)])
{
return [self.delegate popoverListView:self heightForRowAtIndexPath:indexPath];
}
return 0.0f;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(self.delegate &&
[self.delegate respondsToSelector:@selector(popoverListView:didSelectIndexPath:)])
{
[self.delegate popoverListView:self didSelectIndexPath:indexPath];
}
[self dismiss];
}
#pragma mark - animations
- (void)fadeIn
{
self.transform = CGAffineTransformMakeScale(1.3, 1.3);
self.alpha = 0;
[UIView animateWithDuration:.35 animations:^{
self.alpha = 1;
self.transform = CGAffineTransformMakeScale(1, 1);
}];
}
- (void)fadeOut
{
[UIView animateWithDuration:.35 animations:^{
self.transform = CGAffineTransformMakeScale(1.3, 1.3);
self.alpha = 0.0;
} completion:^(BOOL finished) {
if (finished) {
[_overlayView removeFromSuperview];
[self removeFromSuperview];
}
}];
}
- (void)setTitle:(NSString *)title
{
_titleView.text = title;
}
- (void)show
{
UIWindow *keywindow = [[UIApplication sharedApplication] keyWindow];
[keywindow addSubview:_overlayView];
[keywindow addSubview:self];
self.center = CGPointMake(keywindow.bounds.size.width/2.0f,
keywindow.bounds.size.height/2.0f);
[self fadeIn];
}
- (void)dismiss
{
[self fadeOut];
}
#define mark - UITouch
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
// tell the delegate the cancellation
if (self.delegate && [self.delegate respondsToSelector:@selector(popoverListViewCancel:)]) {
[self.delegate popoverListViewCancel:self];
}
// dismiss self
[self dismiss];
}
//
// draw round rect corner
//
/*
- (void)drawRect:(CGRect)rect
{
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(c, [_fillColor CGColor]);
CGContextSetStrokeColorWithColor(c, [_borderColor CGColor]);
CGContextBeginPath(c);
addRoundedRectToPath(c, rect, 10.0f, 10.0f);
CGContextFillPath(c);
CGContextSetLineWidth(c, 1.0f);
CGContextBeginPath(c);
addRoundedRectToPath(c, rect, 10.0f, 10.0f);
CGContextStrokePath(c);
}
static void addRoundedRectToPath(CGContextRef context, CGRect rect,
float ovalWidth,float ovalHeight)
{
float fw, fh;
if (ovalWidth == 0 || ovalHeight == 0) {// 1
CGContextAddRect(context, rect);
return;
}
CGContextSaveGState(context);// 2
CGContextTranslateCTM (context, CGRectGetMinX(rect),// 3
CGRectGetMinY(rect));
CGContextScaleCTM (context, ovalWidth, ovalHeight);// 4
fw = CGRectGetWidth (rect) / ovalWidth;// 5
fh = CGRectGetHeight (rect) / ovalHeight;// 6
CGContextMoveToPoint(context, fw, fh/2); // 7
CGContextAddArcToPoint(context, fw, fh, fw/2, fh, 1);// 8
CGContextAddArcToPoint(context, 0, fh, 0, fh/2, 1);// 9
CGContextAddArcToPoint(context, 0, 0, fw/2, 0, 1);// 10
CGContextAddArcToPoint(context, fw, 0, fw, fh/2, 1); // 11
CGContextClosePath(context);// 12
CGContextRestoreGState(context);// 13
}
*/
@end
......@@ -32,7 +32,7 @@
@property (nonatomic, strong) NSArray *projectsIn;
// 商铺名称或代码类似于
@property (nonatomic, strong) NSString *shopNameOrCodeLike;
@property (nonatomic, strong) NSString *shopLike;
@end
......@@ -72,6 +72,7 @@
-(NSString*) getPictureUrlOrDefault;
-(NSString*) codeName;
-(BOOL) unconfirmed;
@end
......
......@@ -15,7 +15,7 @@
@synthesize settleEquals = _settleEquals;
@synthesize confirmed = _confirmed;
@synthesize projectsIn = _projectsIn;
@synthesize shopNameOrCodeLike = _shopNameOrCodeLike;
@synthesize shopLike = _shopLike;
-(void) route:(BeeMessage *)msg {
if (self.sending)
......@@ -106,18 +106,21 @@
CONVERT_PROPERTY_CLASS(items, SubjectItem)
-(NSString*) getPictureUrlOrDefault {
return @"bill.png";
// if ([VankeUtil isBlankString:self.picture]) {
// return @"bill.png";
// } else {
// return [NSString stringWithFormat:@"%@/%@", VANKE_SERVER_MEDIA_BASE_URL, self.picture];
// }
if ([VankeUtil isBlankString:self.picture]) {
return @"bill_icon.png";
} else {
return [NSString stringWithFormat:@"%@/%@", VANKE_SERVER_MEDIA_BASE_URL, self.picture];
}
}
-(NSString*) codeName {
return [NSString stringWithFormat:@"%@ %@", _shopCode, _shopName];
}
-(BOOL) unconfirmed {
return [_state eq: @"unconfirmed"];
}
@end
#pragma StatementListResponse
......@@ -164,17 +167,17 @@ CONVERT_PROPERTY_CLASS(records, StatementShop)
summary.contract = @"112233";
summary.shopCode = [NSString stringWithFormat:@"%03d", i];
summary.shopName = @"肯得起";
summary.picture = @"";
// summary.picture = @"";
summary.settle = [NSDate date];
double val = floorf(((double)arc4random() / ARC4RANDOM_MAX) * 10000.0f);
summary.amount = [NSNumber numberWithDouble:val];
val = arc4random() % 100;
if (val > 30) {
val = arc4random() % 3;
if (val == 0) {
summary.state = @"confirmed";
} else if (val > 60) {
} if (val == 1) {
summary.state = @"unconfirmed";
} else {
} else if (val == 2){
summary.state = @"rejected";
}
......@@ -184,11 +187,12 @@ CONVERT_PROPERTY_CLASS(records, StatementShop)
item.subject = @"月固定租金";
item.beginDate = @"2015-12-01";
item.endDate = @"2015-12-30";
item.direction = [NSNumber numberWithInt:0];
item.direction = [NSNumber numberWithInt:1];
val = floorf(((double)arc4random() / ARC4RANDOM_MAX) * 10000.0f);
if (arc4random() % 100 > 50) {
val = -val;
item.direction = [NSNumber numberWithInt:-1];
}
item.amount = [NSNumber numberWithDouble:val];
item.remark = @"有意见,不同意";
......
......@@ -78,6 +78,20 @@
@end
// 授权组织
@interface AuthorizedOrg : BeeActiveObject
// 标识
@property (nonatomic, strong) NSString *uuid;
// 代码
@property (nonatomic, strong) NSString *code;
// 名称
@property (nonatomic, strong) NSString *name;
// 图片
@property (nonatomic, strong) NSString *picture;
@end
// 登录请求返回
@interface LoginResponse : VankeResponse
@property (nonatomic, strong) LoginResponseData *data;
......
......@@ -75,6 +75,14 @@
@synthesize name;
@end
#pragma mark AuthorizedOrg
@implementation AuthorizedOrg
@synthesize uuid;
@synthesize code;
@synthesize name;
@synthesize picture;
@end
#pragma mark LoginResponseData
@implementation LoginResponseData
//@synthesize user;
......
#import "FMDatabase.h"
#import "FMResultSet.h"
#import "FMDatabaseAdditions.h"
#import "FMDatabaseQueue.h"
#import "FMDatabasePool.h"
......@@ -11,6 +11,7 @@
#pragma mark -
// TODO 要按最新的结构调整
@interface VankeCommonModel : NSObject
AS_SINGLETON(VankeCommonModel)
......@@ -25,4 +26,8 @@ AS_SINGLETON(VankeCommonModel)
- (void) removeCurrentUser;
-(NSArray*) getAuthorizedOrgs;
@end
......@@ -56,4 +56,17 @@ DEF_SINGLETON(VankeCommonModel)
[self keychainDelete:KEY_CURRENT_USER_PWD];
}
-(NSArray*) getAuthorizedOrgs {
NSMutableArray *ary = [[NSMutableArray alloc] initWithCapacity:20];
for( int i = 0; i < 20; ++i) {
AuthorizedOrg *org = [[AuthorizedOrg alloc] init];
org.uuid = [NSString stringWithFormat:@"%d", i];
org.code = [NSString stringWithFormat:@"CODE%d", i];
org.name = [NSString stringWithFormat:@"项目%d", i];
org.picture = [NSString stringWithFormat:@"PICTURE%d", i];
[ary addObject:org];
}
return ary;
}
@end
......@@ -68,6 +68,10 @@
}
}
-(void) loadFromServer {
}
- (void)gotoPage:(NSUInteger)page {
[VankeNoticeListAPI cancel];
......
......@@ -21,7 +21,7 @@
@property (nonatomic, strong) NSArray *projectsIn;
// 商铺名称或代码类似于
@property (nonatomic, strong) NSString *shopNameOrCodeLike;
@property (nonatomic, strong) NSString *shopLike;
// 商户列表
@property (nonatomic, strong) NSMutableArray *shops; // StatementShop
......
......@@ -16,7 +16,7 @@
@synthesize settleEquals = _settleEquals;
@synthesize confirmed = _confirmed;
@synthesize projectsIn = _projectsIn;
@synthesize shopNameOrCodeLike = _shopNameOrCodeLike;
@synthesize shopLike = _shopLike;
@synthesize shops = _shops;
@synthesize lastResp = _lastResp;
......@@ -32,7 +32,7 @@
self.settleEquals = nil;
self.confirmed = nil;
self.projectsIn = nil;
self.shopNameOrCodeLike = nil;
self.shopLike = nil;
self.shops = nil;
}
......@@ -62,7 +62,7 @@
api.settleEquals = self.settleEquals;
api.confirmed = self.confirmed;
api.projectsIn = self.projectsIn;
api.shopNameOrCodeLike = self.shopNameOrCodeLike;
api.shopLike = self.shopLike;
api.whenUpdate = ^
{
......
......@@ -16,10 +16,11 @@
//
#import "Bee.h"
#import "UIPopoverListView.h"
#pragma mark -
@interface VankeAffairsBoard_iPhone : BeeUIBoard
@interface VankeAffairsBoard_iPhone : BeeUIBoard<UIPopoverListViewDataSource, UIPopoverListViewDelegate>
AS_OUTLET( BeeUIButton, btnNotice )
AS_OUTLET( BeeUIButton, btnBill )
......
......@@ -17,6 +17,7 @@
#import "VankeAffairsBoard_iPhone.h"
#import "VankeUtil.h"
#import "VankeCommonModel.h"
#import "VankeAppBoard_iPhone.h"
#import "VankeNoticeListBoard_iPhone.h"
#import "VankeStatementListBoard_iPhone.h"
......@@ -26,6 +27,7 @@
@interface VankeAffairsBoard_iPhone()
{
//<#@private var#>
NSArray *authorizedOrgs;
}
@end
......@@ -41,6 +43,8 @@ DEF_OUTLET( BeeUIButton, btnServiceApply )
- (void)load
{
VankeCommonModel *userModel = [VankeCommonModel sharedInstance];
authorizedOrgs = [userModel getAuthorizedOrgs];
}
- (void)unload
......@@ -93,9 +97,22 @@ ON_SIGNAL3(VankeAffairsBoard_iPhone, btnNotice, signal) {
}
ON_SIGNAL3(VankeAffairsBoard_iPhone, btnBill, signal) {
[[VankeAppBoard_iPhone sharedInstance] hideMenu];
VankeStatementListBoard_iPhone *board = [VankeStatementListBoard_iPhone board];
[self.stack pushBoard:board animated:YES];
if (authorizedOrgs.count == 0) {
return;
} else if (authorizedOrgs.count == 1) {
AuthorizedOrg *org = [authorizedOrgs objectAtIndex:0];
[self showStatementList:org];
} else {
CGFloat xWidth = self.view.bounds.size.width - 20.0f;
CGFloat yHeight = 400.0f;
CGFloat yOffset = (self.view.bounds.size.height - yHeight)/2.0f;
UIPopoverListView *poplistview = [[UIPopoverListView alloc] initWithFrame:CGRectMake(10, yOffset, xWidth, yHeight)];
poplistview.delegate = self;
poplistview.datasource = self;
poplistview.listView.scrollEnabled = YES;
[poplistview setTitle:@"请选择查看项目"];
[poplistview show];
}
}
ON_SIGNAL3(VankeAffairsBoard_iPhone, btnSaleInput, signal) {
......@@ -106,5 +123,47 @@ ON_SIGNAL3(VankeAffairsBoard_iPhone, btnServiceApply, signal) {
INFO(@"button service apply pressed.");
}
#pragma mark - UIPopoverListViewDataSource
- (UITableViewCell *)popoverListView:(UIPopoverListView *)popoverListView
cellForIndexPath:(NSIndexPath *)indexPath
{
static NSString *identifier = @"cell";
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:identifier];
AuthorizedOrg *org = [authorizedOrgs objectAtIndex:indexPath.row];
cell.textLabel.text = org.name;
cell.imageView.image = [UIImage imageNamed:org.picture];
return cell;
}
- (NSInteger)popoverListView:(UIPopoverListView *)popoverListView
numberOfRowsInSection:(NSInteger)section
{
return authorizedOrgs.count;
}
#pragma mark - UIPopoverListViewDelegate
- (void)popoverListView:(UIPopoverListView *)popoverListView
didSelectIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"%s : %d", __func__, indexPath.row);
AuthorizedOrg *org = [authorizedOrgs objectAtIndex:indexPath.row];
[self showStatementList:org];
}
- (CGFloat)popoverListView:(UIPopoverListView *)popoverListView
heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 60.0f;
}
-(void) showStatementList: (AuthorizedOrg*) org {
[[VankeAppBoard_iPhone sharedInstance] hideMenu];
VankeStatementListBoard_iPhone *board = [VankeStatementListBoard_iPhone board];
[self.stack pushBoard:board animated:YES];
}
@end
//
// ICRAnnocementContentView.h
// Cruiser
//
// Created by Lili Wang on 15/4/14.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "IBTUIView.h"
@interface ICRAnnocementContentView : IBTUIView
+ (UILabel *)creatLabelWithTextColor:(UIColor *)textColor
textFont:(UIFont *)textFont
textAlignment:(NSTextAlignment)textAlignment;
- (void)updateContentWithData:(id)aAnnouncement;
@end
//
// ICRAnnocementContentView.m
// Cruiser
//
// Created by Lili Wang on 15/4/14.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#define PRIORITY_LABEL_HEIGHT 30
#define PRIORITY_LABEL_LEFT_PANDING 15
#define PRIORITY_IMAGE_TOP_PANDING 20
#define TITLE_LABEL_TOP_PANDING 15
#define TITLE_LABEL_HEIGHT 15
#define CREAT_BY_LABEL_HEIGHT 14
#define CREAT_BY_LABEL_TOP_PANDING 6
#define CREAT_BY_TEXT_COLOR [UIColor colorWithRed:0.749f green:0.749f blue:0.749f alpha:1.00f]
#import "ICRAnnocementContentView.h"
#import "ICRAnnouncement.h"
#import "IBTCommon.h"
#import "UIView+ViewFrameGeometry.h"
@interface ICRAnnocementContentView ()
@property (strong, nonatomic) UILabel *m_priorityLabel;
@property (strong, nonatomic) UILabel *m_titleLabel;
@property (strong, nonatomic) UILabel *m_creatByLabel;
@property (strong, nonatomic) UILabel *m_creatTimeLabel;
@property (strong, nonatomic) UILabel *m_creatByValueLabel;
@property (strong, nonatomic) UILabel *m_creatTimeValueLabel;
@end
@implementation ICRAnnocementContentView
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
// code
[self _init];
}
return self;
}
- (void)layoutSubviews {
_m_priorityLabel.frame = (CGRect){
.origin.x = PRIORITY_LABEL_LEFT_PANDING,
.origin.y = (self.height - PRIORITY_LABEL_HEIGHT)/2,
.size.width = PRIORITY_LABEL_HEIGHT,
.size.height = PRIORITY_LABEL_HEIGHT
};
CGFloat fMaxW = self.width - PRIORITY_LABEL_LEFT_PANDING;
CGSize size = CGSizeMake( fMaxW - _m_priorityLabel.right , TITLE_LABEL_HEIGHT);
size = [_m_titleLabel widthLimitedSizeThatFits:size];
_m_titleLabel.frame = (CGRect){
.origin.x = _m_priorityLabel.right + CREAT_BY_LABEL_TOP_PANDING,
.origin.y = _m_priorityLabel.top,
.size = size
};
size = CGSizeMake( fMaxW - _m_priorityLabel.right , TITLE_LABEL_HEIGHT);
size = [_m_creatByLabel widthLimitedSizeThatFits:size];
_m_creatByLabel.frame = (CGRect){
.origin.x = _m_priorityLabel.right + CREAT_BY_LABEL_TOP_PANDING,
.origin.y = CREAT_BY_LABEL_TOP_PANDING + _m_titleLabel.bottom,
.size = size
};
size = CGSizeMake( fMaxW - _m_creatByLabel.right,CREAT_BY_LABEL_HEIGHT );
size = [_m_creatByValueLabel widthLimitedSizeThatFits:size];
_m_creatByValueLabel.frame = (CGRect){
.origin.x = _m_creatByLabel.right,
.origin.y = _m_creatByLabel.top,
.size.width = size.width,
.size.height = _m_creatByLabel.height
};
size = CGSizeMake( fMaxW - _m_creatByValueLabel.right , _m_creatByLabel.height );
size = [_m_creatTimeLabel widthLimitedSizeThatFits:size];
_m_creatTimeLabel.frame = (CGRect){
.origin.x = _m_creatByValueLabel.right + CREAT_BY_LABEL_TOP_PANDING,
.origin.y = _m_creatByValueLabel.top,
.size.width = size.width,
.size.height = _m_creatByValueLabel.height
};
size = CGSizeMake( fMaxW - _m_creatTimeLabel.right, _m_creatTimeLabel.height);
size = [_m_creatTimeValueLabel widthLimitedSizeThatFits:size];
_m_creatTimeValueLabel.frame = (CGRect){
.origin.x = _m_creatTimeLabel.right,
.origin.y = _m_creatTimeLabel.top,
.size.width = size.width,
.size.height = _m_creatTimeLabel.height
};
}
#pragma mark - Private Method
- (void)_init {
self.m_priorityLabel = [[self class ]creatLabelWithTextColor:[UIColor whiteColor]
textFont:[UIFont systemFontOfSize:14]
textAlignment:NSTextAlignmentCenter];
_m_priorityLabel.backgroundColor = [UIColor colorWithPatternImage:
[UIImage imageNamed:@"PriorityTagGrey"]];
_m_priorityLabel.layer.masksToBounds = YES;
_m_priorityLabel.layer.cornerRadius = PRIORITY_LABEL_HEIGHT * 0.5;
[self addSubview:_m_priorityLabel];
self.m_titleLabel = [[self class ] creatLabelWithTextColor:[UIColor colorWithRed:0.165f green:0.165f blue:0.165f alpha:1.00f]
textFont:[UIFont systemFontOfSize:15]
textAlignment:NSTextAlignmentLeft];
[self addSubview:_m_titleLabel];
self.m_creatByLabel = [[self class ] creatLabelWithTextColor:CREAT_BY_TEXT_COLOR
textFont:[UIFont systemFontOfSize:13]
textAlignment:NSTextAlignmentLeft];
_m_creatByLabel.text = [IBTCommon localizableString:@"Publisher:"];
[self addSubview:_m_creatByLabel];
self.m_creatTimeLabel = [[self class ] creatLabelWithTextColor:CREAT_BY_TEXT_COLOR
textFont:[UIFont systemFontOfSize:13]
textAlignment:NSTextAlignmentLeft];
_m_creatTimeLabel.text = [IBTCommon localizableString:@"Publish Time:"];
[self addSubview:_m_creatTimeLabel];
self.m_creatByValueLabel = [[self class ] creatLabelWithTextColor:CREAT_BY_TEXT_COLOR
textFont:[UIFont systemFontOfSize:13]
textAlignment:NSTextAlignmentLeft];;
[self addSubview:_m_creatByValueLabel];
self.m_creatTimeValueLabel = [[self class ] creatLabelWithTextColor:CREAT_BY_TEXT_COLOR
textFont:[UIFont systemFontOfSize:13]
textAlignment:NSTextAlignmentLeft];;
[self addSubview:_m_creatTimeValueLabel];
}
#pragma mark - Private Method
+ (UILabel *)creatLabelWithTextColor:(UIColor *)textColor
textFont:(UIFont *)textFont
textAlignment:(NSTextAlignment)textAlignment {
UILabel *label = [[UILabel alloc] init];
label.backgroundColor = [UIColor clearColor];
label.textColor = textColor;
label.font = textFont;
label.textAlignment = textAlignment;
return label;
}
#pragma mark - Public Method
- (void)updateContentWithData:(id)aAnnouncement {
/*
kICRAnnouncementStatusHigh = 0,
kICRAnnouncementStatusLow,
kICRAnnouncementStatusNormal
*/
/*
kICRAnnouncementTypeReaded = 0,
kICRAnnouncementTypeUnread
*/
/*
"Low" = "低";
"Normal" = "中";
"High" = "高";
*/
if ([aAnnouncement isKindOfClass:[ICRAnnouncement class]]) {
ICRAnnouncement *announcement = aAnnouncement;
switch (announcement.state) {
case kICRAnnouncementTypeUnread:
{
switch (announcement.priority) {
case kICRAnnouncementStatusLow:
{
self.m_priorityLabel.text = [IBTCommon localizableString:@"Low"];
self.m_priorityLabel.backgroundColor = [UIColor colorWithPatternImage:
[UIImage imageNamed:@"PriorityTagGreen"]];
}
break;
case kICRAnnouncementStatusNormal:
{
self.m_priorityLabel.text = [IBTCommon localizableString:@"Normal"];
self.m_priorityLabel.backgroundColor = [UIColor colorWithPatternImage:
[UIImage imageNamed:@"PriorityTagOrange"]];
}
break;
case kICRAnnouncementStatusHigh:
{
self.m_priorityLabel.text = [IBTCommon localizableString:@"High"];
self.m_priorityLabel.backgroundColor = [UIColor colorWithPatternImage:
[UIImage imageNamed:@"PriorityTagRed"]];
}
break;
default:
break;
}
}
break;
case kICRAnnouncementTypeReaded:
{
switch (announcement.priority) {
case kICRAnnouncementStatusLow:
{
self.m_priorityLabel.text = [IBTCommon localizableString:@"Low"];
}
break;
case kICRAnnouncementStatusNormal:
{
self.m_priorityLabel.text = [IBTCommon localizableString:@"Normal"];
}
break;
case kICRAnnouncementStatusHigh:
{
self.m_priorityLabel.text = [IBTCommon localizableString:@"High"];
}
break;
default:
break;
}
self.m_priorityLabel.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"PriorityTagGrey"]];
}
break;
default:
break;
}
self.m_titleLabel.text = announcement.title ? : @"";
self.m_creatByValueLabel.text = [announcement createInfo ][@"operator"][@"operName"] ? :@"";
self.m_creatTimeValueLabel.text = [announcement createInfo ][@"time"]? : @"";
}
[self setNeedsLayout];
}
@end
//
// ICRAnnouncement.h
// Cruiser
//
// Created by Lili Wang on 15/4/13.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "IBTModel.h"
typedef NS_ENUM(NSUInteger, ICRAnnouncementStatus) {
kICRAnnouncementStatusLow = 0,
kICRAnnouncementStatusNormal,
kICRAnnouncementStatusHigh
};
typedef NS_ENUM(NSUInteger, ICRAnnouncementType) {
kICRAnnouncementTypeUnread = 0,
kICRAnnouncementTypeReaded
};
@interface ICRAnnouncement : IBTModel
@property (copy, nonatomic) NSString *aID;
@property (assign, nonatomic) NSInteger version;
@property (assign, nonatomic) NSUInteger priority;
@property (copy, nonatomic) NSDictionary *createInfo;
@property (copy, nonatomic) NSDictionary *lastModifyInfo;
@property (copy, nonatomic) NSString *enterprise;
@property (copy, nonatomic) NSString *title;
@property (copy, nonatomic) NSString *content;
@property (assign, nonatomic) NSInteger state;
@property (copy, nonatomic) NSString *submitInfo;
@property (copy, nonatomic) NSString *cancelInfo;
@end
//
// ICRAnnouncement.m
// Cruiser
//
// Created by Lili Wang on 15/4/13.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "ICRAnnouncement.h"
#import "ICRAttachment.h"
@implementation ICRAnnouncement
+ (NSDictionary *)specialKeysAndReplaceKeys {
return @{ @"aID" : [[self class] PrimaryKey], };
}
+ (NSString *)PrimaryKey {
return @"uuid";
}
//#pragma mark - Setter
- (void)setAttachments:(NSArray *)attachments {
// if ([_attachments isEqualToArray:attachments]) {
// return;
// }
// _attachments = attachments;
//
// for (NSDictionary *dict in attachments) {
// ICRAttachment *attach = [ICRAttachment DBObject];
// [attach praseFromJsonDict:dict];
//
// [self.arrSubModels addObject:attach];
// }
}
@end
//
// ICRAnnouncementDetailHeadView.h
// Cruiser
//
// Created by Lili Wang on 15/4/15.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "IBTUIView.h"
@class ICRAnnouncement;
@interface ICRAnnouncementDetailHeadView : IBTUIView
- (void)updateContentWithData:(ICRAnnouncement *)announcement;
@end
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment