Commit ea4b5f1e authored by Sandy's avatar Sandy

公告模块移植

parent 6506a4d2
This diff is collapsed.
......@@ -13,6 +13,8 @@
/** 从storyBoard获取控制器 */
- (id)controllerWithIdentifier:(NSString *)identifier;
- (id)getMainVCWithIdentifier:(NSString *)identifier;
/**
* 根据storyboarId push到指定的vc
*/
......
......@@ -27,6 +27,11 @@
return [storyboard instantiateViewControllerWithIdentifier:identifier];
}
- (id)getMainVCWithIdentifier:(NSString *)identifier {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
return [storyboard instantiateViewControllerWithIdentifier:identifier];
}
- (void)PushToStoryBoardVCWithIdentifier:(NSString *)identifier isHideTabbar:(BOOL)hide animate:(BOOL)animate {
UIViewController *vc = [self controllerWithIdentifier:identifier];
vc.hidesBottomBarWhenPushed = YES;
......
......@@ -43,13 +43,13 @@ typedef NS_ENUM(NSUInteger, ICRAttachmentType) {
/* 公告列表(读)
获得公告列表
*/
- (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)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;
/* 读取公告(读)
读取单个公告
......
......@@ -401,64 +401,64 @@ acceptTypeJson:(BOOL)bAcceptJson
// failure:failure];
}
#pragma mark - 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 (^success)(AFHTTPRequestOperation *operation, id responseObject) = ^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"%@", responseObject);
if (IsDictObject(responseObject)) {
void (^complete)(void) = ^(void){
if (succ) {
[IBTCommon runOnMainThreadWithoutDeadlocking:^{
succ( responseObject );
}];
}
};
void(^dataHandle)(id<IBTDatabaseObject>) = ^(id<IBTDatabaseObject> model) {
ICRAnnouncement *ann = model;
ann.priority = eType;
};
ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController];
[dbCtrl storageEntities:responseObject[ @"data" ][ @"records" ]
objectClass:NSClassFromString( @"ICRAnnouncement" )
deleteLocal:bDeleteLocal
handleData:dataHandle
complete:complete
fail:fail];
}
else {
if (fail) {
fail( nil );
}
}
};
void (^failure)(AFHTTPRequestOperation *operation, NSError *error) = ^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"%@", error);
if (fail) {
fail( error );
}
};
NSString *urlStr = [[[self class] UrlForPluginHTTPAction:kICRHTTP_BoardQuery] stringByAppendingFormat:@"/%@?start_date=%@&page_number=%@&page_size=%@",[[VankeCommonModel sharedInstance] currentUser].uuid ,updateTime ? : [[NSDate dateWithTimeIntervalSince1970:0] httpParameterString],@( uiPosition ),@( uiSize )];
NSString *encodeUrlStr = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"%@",encodeUrlStr);
[self POST:encodeUrlStr
parameters:nil
needToken:NO
acceptTypeJson:YES
success:success
failure:failure];
}
//#pragma mark - 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 (^success)(AFHTTPRequestOperation *operation, id responseObject) = ^(AFHTTPRequestOperation *operation, id responseObject) {
// NSLog(@"%@", responseObject);
//
// if (IsDictObject(responseObject)) {
// void (^complete)(void) = ^(void){
// if (succ) {
// [IBTCommon runOnMainThreadWithoutDeadlocking:^{
// succ( responseObject );
// }];
// }
// };
//
// void(^dataHandle)(id<IBTDatabaseObject>) = ^(id<IBTDatabaseObject> model) {
// ICRAnnouncement *ann = model;
// ann.priority = eType;
// };
//
// ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController];
// [dbCtrl storageEntities:responseObject[ @"data" ][ @"records" ]
// objectClass:NSClassFromString( @"ICRAnnouncement" )
// deleteLocal:bDeleteLocal
// handleData:dataHandle
// complete:complete
// fail:fail];
// }
// else {
// if (fail) {
// fail( nil );
// }
// }
// };
//
// void (^failure)(AFHTTPRequestOperation *operation, NSError *error) = ^(AFHTTPRequestOperation *operation, NSError *error) {
// NSLog(@"%@", error);
// if (fail) {
// fail( error );
// }
// };
//
// NSString *urlStr = [[[self class] UrlForPluginHTTPAction:kICRHTTP_BoardQuery] stringByAppendingFormat:@"/%@?start_date=%@&page_number=%@&page_size=%@",[[VankeCommonModel sharedInstance] currentUser].uuid ,updateTime ? : [[NSDate dateWithTimeIntervalSince1970:0] httpParameterString],@( uiPosition ),@( uiSize )];
// NSString *encodeUrlStr = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
// NSLog(@"%@",encodeUrlStr);
// [self POST:encodeUrlStr
// parameters:nil
// needToken:NO
//acceptTypeJson:YES
// success:success
// failure:failure];
//}
- (void)doGetBoardWithID:(NSNumber *)boardID
success:(void (^)(id data))succ
......
......@@ -13,7 +13,7 @@
#import "IBTWebViewController.h"
#import "IBTWebViewDelegate.h"
#import "IBTWebProgressBar.h"
#import "VankeUtil.h"
@interface IBTWebViewController ()
<
UIWebViewDelegate
......@@ -83,6 +83,18 @@
[self goToURL:[NSURL URLWithString:self.m_initUrl]];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.navigationController.navigationBar.backgroundImage = [UIImage imageWithColor:[UIColor colorWithR:63 g:134 b:244 a:1]];
UIColor *color = [VankeUtil rgbStringToColor: @"237,27,35"];
if ( IOS7_OR_LATER ) {
self.navigationController.navigationBar.barTintColor = color;
} else {
self.navigationController.navigationBar.tintColor = color;
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
......
{
"images" : [
{
"idiom" : "universal",
"filename" : "AnnounceTitleBG.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "AnnounceTitleBG@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "PriorityTagGreen.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "PriorityTagGreen@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "PriorityTagGrey.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "PriorityTagGrey@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "PriorityTagOrange.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "PriorityTagOrange@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "PriorityTagRed.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "PriorityTagRed@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "announcementDetailCell_bottom.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "announcementDetailCell_bottom@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "announcementDetailCell_center.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "announcementDetailCell_center@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "announcementDetailCell_top.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "announcementDetailCell_top@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -30,6 +30,9 @@ static NSString *const VANKE_SERVER_MEDIA_BASE_URL = @"http://140.206.62.178:808
//static NSString *const VANKE_SERVER_BASE_URL = @"http://139.196.39.77:6080/wanke-server/rest";
//static NSString *const VANKE_SERVER_MEDIA_BASE_URL = @"http://139.196.39.77:6080";
/** 图片URL */
#define IMAGE_URL(url) [NSString stringWithFormat:@"%@%@", VANKE_SERVER_MEDIA_BASE_URL,url]
// 后台服务企业认证码
#define VANKE_AUTHENTI_CODE @"211534962"
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
</dependencies>
<scenes/>
</document>
//
// GTOPaging.h
// total
//
// Created by freecui on 15/10/29.
// Copyright © 2015年 free. All rights reserved.
//
#import "IBTModel.h"
@interface GTOPaging : IBTModel
@property (assign, nonatomic) NSInteger page;//当前页码
@property (assign, nonatomic) NSInteger pageSize;//分页大小
@property (assign, nonatomic) NSInteger pageCount;//总页数
@property (assign, nonatomic) NSInteger recordCount;//总记录数
@end
//
// GTOPaging.m
// total
//
// Created by freecui on 15/10/29.
// Copyright © 2015年 free. All rights reserved.
//
#import "GTOPaging.h"
@implementation GTOPaging
@end
//
// IBTInputViewHandleDelegate.h
// Cruiser
//
// Created by Xummer on 15/6/8.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import <Foundation/Foundation.h>
@protocol IBTInputViewHandleDelegate <NSObject>
@optional
- (void)handleInputView:(id)sender;
@end
//
// ICRAttachment.h
// Cruiser
//
// Created by Xummer on 4/12/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import "IBTModel.h"
@interface ICRAttachment : IBTModel
@property (assign, nonatomic) NSUInteger aID;
@property (copy, nonatomic) NSString *objectId;
//@property (copy, nonatomic) NSString *fileName;
@property (assign, nonatomic) NSUInteger seq;
@property (copy, nonatomic) NSString *attachmentType;
@property (copy, nonatomic) NSString *uuid;
@property (copy, nonatomic) NSString *fileName;
@property (copy, nonatomic) NSString *fileUrl;
@end
//
// NSMutableArray+SafeInsert.h
// Cruiser
//
// Created by Xummer on 4/10/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSMutableArray (SafeInsert)
- (void)safeAddObject:(id)object;
- (void)safeInsertObject:(id)object atIndex:(NSUInteger)index;
- (void)safeRemoveObjectAtIndex:(NSUInteger)index;
- (void)safeReplaceObjectAtIndex:(NSUInteger)index withObject:(id)object;
- (void)removeFirstObject;
@end
@interface NSMutableDictionary (SafeInsert)
- (void)safeSetObject:(id)object forKey:(id<NSCopying>)key;
- (void)safeRemoveObjectForKey:(id)key;
@end
@interface NSMutableSet (SafeInsert)
- (void)safeAddObject:(id)object;
- (void)safeRemoveObject:(id)object;
@end
@interface NSMutableString (SafeInsert)
- (void)safeAppendString:(NSString *)string;
@end
@interface NSArray (SafeFetch)
- (id)safeObjectAtIndex:(NSUInteger)index;
@end
\ No newline at end of file
//
// NSMutableArray+SafeInsert.m
// Cruiser
//
// Created by Xummer on 4/10/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import "NSMutableArray+SafeInsert.h"
#pragma mark - NSMutableArray (SafeInsert)
@implementation NSMutableArray (SafeInsert)
- (void)safeAddObject:(id)object {
if (object) {
[self addObject:object];
}
}
- (void)safeInsertObject:(id)object atIndex:(NSUInteger)index {
if (index < self.count && object) {
[self insertObject:object atIndex:index];
}
}
- (void)safeRemoveObjectAtIndex:(NSUInteger)index {
if (index < self.count) {
[self removeObjectAtIndex:index];
}
}
- (void)safeReplaceObjectAtIndex:(NSUInteger)index withObject:(id)object {
if (index < self.count && object) {
[self replaceObjectAtIndex:index withObject:object];
}
}
- (void)removeFirstObject {
id firstObj = [self firstObject];
if (firstObj) {
[self removeObject:firstObj];
}
}
@end
#pragma mark - NSMutableDictionary (SafeInsert)
@implementation NSMutableDictionary (SafeInsert)
- (void)safeSetObject:(id)object forKey:(id <NSCopying>)key {
if (object) {
[self setObject:object forKey:key];
}
}
- (void)safeRemoveObjectForKey:(id)key {
[self removeObjectForKey:key];
}
@end
#pragma mark - NSMutableSet (SafeInsert)
@implementation NSMutableSet (SafeInsert)
- (void)safeAddObject:(id)object {
if (object) {
[self addObject:object];
}
}
- (void)safeRemoveObject:(id)object {
if (object) {
[self removeObject:object];
}
}
@end
#pragma mark - NSMutableString (SafeInsert)
@implementation NSMutableString (SafeInsert)
- (void)safeAppendString:(NSString *)string {
if ([string isKindOfClass:[NSString class]]) {
[self appendString:string];
}
}
@end
#pragma mark - NSArray (SafeFetch)
@implementation NSArray (SafeFetch)
- (id)safeObjectAtIndex:(NSUInteger)index {
@synchronized(self) {
if (index >= [self count]) return nil;
return [self objectAtIndex:index];
}
}
@end
//
// UILabel+SizeCalculate.h
//
//
// Created by Xummer on 14-2-19.
// Copyright (c) 2014年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UILabel (SizeCalculate)
+ (CGFloat)getLabelWidth:(UILabel *)label;
+ (CGFloat)getLabelHeight:(UILabel *)label;
+ (CGSize)getLabelSize:(UILabel *)label;
+ (CGSize)getSizeWithText:(NSString *)text font:(UIFont *)font andSize:(CGSize)size;
+ (CGSize)getSizeWithText:(NSString *)text font:(UIFont *)font andWidth:(CGFloat)width;
+ (CGFloat)getHeightWithText:(NSString *)text font:(UIFont *)font andWidth:(CGFloat)width;
+ (CGFloat)getWidthWithText:(NSString *)text font:(UIFont *)font andHeight:(CGFloat)height;
- (CGFloat)calculateWidth;
- (CGFloat)calculateHeight;
- (CGSize)calculateSize;
@end
//
// UILabel+SizeCalculate.m
//
//
// Created by Xummer on 14-2-19.
// Copyright (c) 2014年 Xummer. All rights reserved.
//
#import "UILabel+SizeCalculate.h"
@implementation UILabel (SizeCalculate)
+ (CGSize)getSizeWithText:(NSString *)text font:(UIFont *)font andSize:(CGSize)size {
CGSize expectedLabelSize = CGSizeZero;
if (!font || !text ) {
return expectedLabelSize;
}
if (IBT_IOS7_OR_LATER) {
NSDictionary *stringAttributes = @{ NSFontAttributeName : font };
expectedLabelSize =
[text boundingRectWithSize:size
options:NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesLineFragmentOrigin
attributes:stringAttributes
context:nil].size;
}
else {
expectedLabelSize =
[text sizeWithFont:font
constrainedToSize:size
lineBreakMode:NSLineBreakByWordWrapping];
}
return expectedLabelSize;
}
+ (CGSize)getSizeWithText:(NSString *)text font:(UIFont *)font andWidth:(CGFloat)width {
return [[self class] getSizeWithText:text
font:font
andSize:CGSizeMake(width, MAXFLOAT)];
}
+ (CGFloat)getWidthWithText:(NSString *)text font:(UIFont *)font andHeight:(CGFloat)height {
CGSize expectedLabelSize = CGSizeZero;
if (IBT_IOS7_OR_LATER) {
NSDictionary *stringAttributes = @{ NSFontAttributeName : font };
expectedLabelSize =
[text boundingRectWithSize:CGSizeMake(MAXFLOAT, height)
options:NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesLineFragmentOrigin
attributes:stringAttributes
context:nil].size;
}
else {
expectedLabelSize =
[text sizeWithFont:font
constrainedToSize:CGSizeMake(MAXFLOAT, height)
lineBreakMode:NSLineBreakByWordWrapping];
}
return ceil(expectedLabelSize.width);
}
+ (CGFloat)getLabelWidth:(UILabel *)label {
return [[self class] getWidthWithText:label.text
font:label.font
andHeight:CGRectGetHeight(label.frame)];
}
+ (CGFloat)getLabelHeight:(UILabel *)label {
return [[self class] getHeightWithText:label.text
font:label.font
andWidth:label.frame.size.width];
}
+ (CGSize)getLabelSize:(UILabel *)label {
return [[self class] getSizeWithText:label.text
font:label.font
andWidth:CGRectGetWidth(label.frame)];
}
+ (CGFloat)getHeightWithText:(NSString *)text font:(UIFont *)font andWidth:(CGFloat)width {
return ceil([[self class] getSizeWithText:text
font:font
andWidth:width].height);
}
- (CGFloat)calculateWidth {
return [[self class] getLabelWidth:self];
}
- (CGFloat)calculateHeight {
return [[self class] getLabelHeight:self];
}
- (CGSize)calculateSize {
return [[self class] getLabelSize:self];
}
@end
//
// UIView+FindUIViewController.h
// JobTalk
//
// Created by Xummer on 1/20/15.
// Copyright (c) 2015 BST. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface UIView (FindUIViewController)
- (UIViewController *)firstAvailableUIViewController;
- (id)traverseResponderChainForUIViewController;
@end
@interface UIView (Extend)
- (NSArray *)subviewsWithClass:(Class)aClass;
- (id)viewWithClass:(Class)aClass;
- (void)removeSubViewWithClass:(Class)aClass;
- (void)removeSubViewWithTag:(NSInteger)tag;
- (void)removeAllSubViews;
- (void)autoresizingWithStrechFullSize;
- (void)autoresizingWithVerticalCenter;
- (void)autoresizingWithHorizontalCenter;
@end
//
// UIView+FindUIViewController.m
// JobTalk
//
// Created by Xummer on 1/20/15.
// Copyright (c) 2015 BST. All rights reserved.
//
#import "UIView+FindUIViewController.h"
@implementation UIView (FindUIViewController)
- (UIViewController *)firstAvailableUIViewController {
// convenience function for casting and to "mask" the recursive function
return (UIViewController *)[self traverseResponderChainForUIViewController];
}
- (id)traverseResponderChainForUIViewController {
id nextResponder = [self nextResponder];
if ([nextResponder isKindOfClass:[UIViewController class]]) {
return nextResponder;
}
else if ([nextResponder isKindOfClass:[UIView class]]) {
return [nextResponder traverseResponderChainForUIViewController];
}
else {
return nil;
}
}
@end
@implementation UIView (Extend)
- (NSArray *)subviewsWithClass:(Class)aClass {
NSMutableArray *arrTmp = [NSMutableArray array];
for (UIView *view in self.subviews) {
if ([view isKindOfClass:aClass]) {
[arrTmp addObject:view];
}
}
return [arrTmp count] > 0 ? arrTmp : nil;
}
- (id)viewWithClass:(Class)aClass {
__block id machedView = nil;
[self.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
if ([obj isKindOfClass:aClass]) {
machedView = obj;
*stop = YES;
}
}];
return machedView;
}
- (void)removeSubViewWithClass:(Class)aClass {
[[self viewWithClass:aClass] removeFromSuperview];
}
- (void)removeSubViewWithTag:(NSInteger)tag {
[[self viewWithTag:tag] removeFromSuperview];
}
- (void)removeAllSubViews {
[self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
}
- (void)autoresizingWithStrechFullSize {
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}
- (void)autoresizingWithVerticalCenter {
self.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
}
- (void)autoresizingWithHorizontalCenter {
self.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
}
@end
//
// UIView+ViewFrameGeometry.h
// IBTTableViewKit
//
// Created by Xummer on 15/1/9.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIView (ViewFrameGeometry)
@property (assign) CGFloat x;
@property (assign) CGFloat y;
@property (assign) CGFloat width;
@property (assign) CGFloat height;
@property (assign) CGSize size;
@property (assign) CGPoint origin;
@property (assign) CGFloat left;
@property (assign) CGFloat right;
@property (assign) CGFloat top;
@property (assign) CGFloat bottom;
@property (readonly, assign) CGPoint topRight;
@property (readonly, assign) CGPoint bottomRight;
@property (readonly, assign) CGPoint bottomLeft;
//- (void)frameIntegral;
//- (void)ceilAllSubviews;
//- (void)fitTheSubviews;
- (void)fitInSize:(CGSize)aSize;
- (void)scaleBy:(CGFloat)fScaleFactor;
- (void)moveBy:(CGPoint)pDelta;
- (CGSize)widthLimitedSizeThatFits:(CGSize)size;
- (CGSize)heightLimitedSizeThatFits:(CGSize)size;
@end
//
// UIView+ViewFrameGeometry.m
// IBTTableViewKit
//
// Created by Xummer on 15/1/9.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "UIView+ViewFrameGeometry.h"
@implementation UIView (ViewFrameGeometry)
- (CGFloat) x {
return self.frame.origin.x;
}
- (void) setX:(CGFloat)x {
CGRect nframe = self.frame;
nframe.origin.x = x;
self.frame = nframe;
}
- (CGFloat) y {
return self.frame.origin.y;
}
- (void) setY:(CGFloat)y {
CGRect nframe = self.frame;
nframe.origin.y = y;
self.frame = nframe;
}
// Retrieve and set height, width
- (CGFloat) width {
return self.frame.size.width;
}
- (void) setWidth:(CGFloat)width {
CGRect nframe = self.frame;
nframe.size.width = width;
self.frame = nframe;
}
- (CGFloat) height {
return self.frame.size.height;
}
- (void) setHeight:(CGFloat)height {
CGRect nframe = self.frame;
nframe.size.height = height;
self.frame = nframe;
}
// Retrieve and set the origin, size
- (CGPoint) origin {
return self.frame.origin;
}
- (void) setOrigin:(CGPoint)aPoint {
CGRect nframe = self.frame;
nframe.origin = aPoint;
self.frame = nframe;
}
- (CGSize) size {
return self.frame.size;
}
- (void) setSize:(CGSize)aSize {
CGRect nframe = self.frame;
nframe.size = aSize;
self.frame = nframe;
}
// Retrieve and set top, bottom, left, right
- (CGFloat) left {
return self.x;
}
- (void) setLeft:(CGFloat)left {
self.x = left;
}
- (CGFloat) right {
return CGRectGetMaxX(self.frame);
}
- (void) setRight:(CGFloat)right {
self.x = right - self.width;
}
- (CGFloat) top {
return self.y;
}
- (void) setTop:(CGFloat)top {
self.y = top;
}
- (CGFloat) bottom {
return CGRectGetMaxY(self.frame);
}
- (void) setBottom:(CGFloat)bottom {
self.y = bottom - self.height;
}
// Query other frame locations
- (CGPoint) topRight {
return CGPointMake(self.right, self.top);
}
- (CGPoint) bottomRight {
return CGPointMake(self.right, self.bottom);
}
- (CGPoint) bottomLeft {
return CGPointMake(self.left, self.bottom);
}
// Move via offset
- (void) moveBy:(CGPoint)delta
{
CGPoint nCenter = self.center;
nCenter.x += delta.x;
nCenter.y += delta.y;
self.center = nCenter;
}
// Scaling
- (void) scaleBy:(CGFloat)scaleFactor {
CGRect nframe = self.frame;
nframe.size.width *= scaleFactor;
nframe.size.height *= scaleFactor;
self.frame = nframe;
}
// Ensure that both dimensions fit within the given size by scaling down
- (void) fitInSize:(CGSize)aSize {
CGFloat scale;
CGRect nframe = self.frame;
if (nframe.size.height && (nframe.size.height > aSize.height)) {
scale = aSize.height / nframe.size.height;
nframe.size.width *= scale;
nframe.size.height *= scale;
}
if (nframe.size.width && (nframe.size.width >= aSize.width)) {
scale = aSize.width / nframe.size.width;
nframe.size.width *= scale;
nframe.size.height *= scale;
}
self.frame = nframe;
}
- (CGSize) widthLimitedSizeThatFits:(CGSize)size {
CGSize mSize = [self sizeThatFits:size];
if (mSize.width > size.width) {
mSize.width = size.width;
}
return mSize;
}
- (CGSize) heightLimitedSizeThatFits:(CGSize)size {
CGSize mSize = [self sizeThatFits:size];
if (mSize.height > size.height) {
mSize.height = size.height;
}
return mSize;
}
@end
//
// UIViewController+LogicController.h
// Cruiser
//
// Created by Xummer on 15/4/3.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIViewController (LogicController)
- (UIImage *)getViewControllerImage:(CGSize)imageSize;
// Navigation
- (BOOL)isCurrentViewController;
- (void)onBackButtonClicked;
- (UIViewController *)getViewControllerAtIndex:(NSInteger)iIndex;
- (void)PushViewController:(UIViewController *)viewController animated:(BOOL)bAnimated;
- (UIViewController *)PopViewControllerAnimated:(BOOL)bAnimated;
- (NSArray *)PopToViewController:(UIViewController *)viewController animated:(BOOL)bAnimated;
- (NSArray *)PopToRootViewControllerAnimated:(BOOL)bAnimated;
- (NSArray *)PopToViewControllerWithClass:(Class)vcClass animated:(BOOL)bAnimated;
- (NSArray *)PopToViewControllerAtIndex:(NSInteger)index animated:(BOOL)bAnimated;
@end
@interface UIViewController (ModalView)
//- (void)releasePopoverController:(id)controller;
//- (void)popoverControllerDidDismissPopover:(id)popoverController;
- (void)DismissMyselfAnimated:(BOOL)bAnimated;
- (void)DismissModalViewControllerAnimated:(BOOL)bAnimated;
- (void)PresentModalViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)bAnimated;
- (void)PresentViewControllerInNewNavigation:(UIViewController *)viewControllerToPresent animated:(BOOL)bAnimated completion:(void (^)(void))completion;
@end
@interface UIViewController (margin)
- (void)setLeftBarButtonItem:(UIBarButtonItem *)item;
- (UIBarButtonItem *)leftBarButtonItem;
- (void)setRightBarButtonItem:(UIBarButtonItem *)item;
- (UIBarButtonItem *)rightBarButtonItem;
- (void)setLeftBarButtonItems:(NSArray *)items;
- (void)setRightBarButtonItems:(NSArray *)items;
- (UIBarButtonItem *)addLeftBarBtnItemWithName:(NSString *)btnName action:(SEL)selector;
- (UIBarButtonItem *)addRightBarBtnItemWithName:(NSString *)btnName action:(SEL)selector;
@end
......@@ -28,6 +28,8 @@
#import "ChooseProjectTableViewController.h"
#import "ICRAppMacro.h"
#import "SaleInputAuditViewController.h"
#pragma mark -
@interface VankeAffairsBoard_iPhone()
......@@ -96,10 +98,10 @@ ON_DID_DISAPPEAR( signal )
}
ON_SIGNAL3(VankeAffairsBoard_iPhone, btnNotice, signal) {
[[VankeAppBoard_iPhone sharedInstance] hideMenu];
VankeNoticeListBoard_iPhone *board = [VankeNoticeListBoard_iPhone board];
// ICRAnnouncementViewController *board = [ICRAnnouncementViewController board];
[self.stack pushBoard:board animated:YES];
ICRAnnouncementViewController *announcementVC = [[ICRAnnouncementViewController alloc] init];
announcementVC.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:announcementVC animated:YES];
}
ON_SIGNAL3(VankeAffairsBoard_iPhone, btnBill, signal) {
......
//
// AnnouncementDetailViewController.h
// RealEstateManagement
//
// Created by Z on 16/7/4.
// Copyright © 2016年 上海勾芒信息科技. All rights reserved.
//
#import "BaseViewController.h"
#import "ICRAnnouncement.h"
@interface AnnouncementDetailViewController : BaseViewController
@property (nonatomic, strong) ICRAnnouncement *announcement;
@end
//
// AnnouncementDetailViewController.m
// RealEstateManagement
//
// Created by Z on 16/7/4.
// Copyright © 2016年 上海勾芒信息科技. All rights reserved.
//
#import "AnnouncementDetailViewController.h"
#import "ICRAnnouncementDetailHeadView.h"
#import "AnnouncementDetailTableViewCell.h"
#import "IBTWebViewController.h"
#import "VankeUtil.h"
@interface AnnouncementDetailViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UILabel *labelPublisher;
@property (weak, nonatomic) IBOutlet UILabel *labelTime;
@property (weak, nonatomic) IBOutlet UILabel *labelContent;
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, strong) ICRAnnouncement *announcementDetail;
@end
@implementation AnnouncementDetailViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.tableFooterView = [UIView new];
// self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
[self setUpData];
// Do any additional setup after loading the view.
}
- (void)setUpData {
WS(weakSelf);
NSString *url = [NSString stringWithFormat:@"affiche/get/%@", self.announcement.uuid];
[[ICRHTTPController sharedController] getUrl:url params:nil success:^(id data) {
ICRAnnouncement *announcement = [ICRAnnouncement DBObject];
[announcement praseFromJsonDict:data[@"data"]];
announcement.readType = weakSelf.announcement.readType;
weakSelf.announcementDetail = announcement;
if ([weakSelf.announcementDetail.content hasPrefix:@"<p>"]) {
NSRange lastRange = [weakSelf.announcementDetail.content rangeOfString:@"</p>"];
NSString *cutString = [weakSelf.announcementDetail.content substringWithRange:NSMakeRange(3, lastRange.location - 3)];
weakSelf.announcementDetail.content = cutString;
}
weakSelf.labelPublisher.text = weakSelf.announcementDetail.title;
weakSelf.labelTime.text = weakSelf.announcementDetail.lastModify_time;
weakSelf.labelContent.text = weakSelf.announcementDetail.content;
[weakSelf httpAnnouncementRead];
[weakSelf.tableView reloadData];
} failure:^(id data) {
}];
}
/** 上报已读的公告 */
- (void)httpAnnouncementRead{
NSString *url = [NSString stringWithFormat:@"affiche/read/%@?user_uuid=%@&read_time=%@", self.announcementDetail.uuid,[VankeCommonModel sharedInstance].currentUser.uuid,[[NSDate date] httpParameterString]];
NSString *URLString = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[ICRHTTPController sharedController] postUrl:URLString params:nil success:^(id data) {
CLog(@"该公告已标记为已读");
} failure:^(id data) {
}];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.announcementDetail.attachmentUrls.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
AnnouncementDetailTableViewCell *cell;
cell = [tableView dequeueReusableCellWithIdentifier:@"announcementTopCell" forIndexPath:indexPath];
if (indexPath.row == 0) {
cell.type = announcementDetailCellTypeTop;
cell.isOnlyOne = self.announcementDetail.attachmentUrls.count == 1;
}else if(indexPath.row == self.announcementDetail.attachmentUrls.count - 1) {
cell.type = announcementDetailCellTypeBottom;
}else{
cell.type = announcementDetailCellTypeCenter;
}
cell.contentText = self.announcementDetail.attachmentUrls[indexPath.row][@"fileName"];
NSString *url = IMAGE_URL(self.announcementDetail.attachmentUrls[indexPath.row][@"fileUrl"]);
WS(weakSelf);
cell.openFile = ^{
IBTWebViewController *WVC = [[IBTWebViewController alloc] initWithURL:url presentModal:NO extraInfo:nil];
[weakSelf.navigationController pushViewController:WVC animated:YES];
};
return cell;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
......@@ -6,8 +6,8 @@
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import "ICRBaseViewController.h"
#import "BaseViewController.h"
@interface ICRAnnouncementViewController : ICRBaseViewController
@interface ICRAnnouncementViewController : BaseViewController
@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, ICRAnnouncementPriority) {
kICRAnnouncementPriorityLow = 0,
kICRAnnouncementPriorityNormal,
kICRAnnouncementPriorityHigh
};
typedef NS_ENUM(NSUInteger, ICRAnnouncemenState) {
kICRAnnouncementStateUnsubmited = 0,
kICRAnnouncementStateSubmited,
kICRAnnouncementStateCancled
};
typedef NS_ENUM(NSUInteger, ICRAnnouncementReadType) {
kICRAnnouncementTypeUnread = 0,
kICRAnnouncementTypeReaded
};
@interface ICRAnnouncement : IBTModel
@property (copy, nonatomic) NSString *uuid;
@property (assign, nonatomic) NSInteger version;
@property (copy, nonatomic) NSString *create_time;
@property (copy, nonatomic) NSString *create_id;
@property (copy, nonatomic) NSString *create_operName;
@property (copy, nonatomic) NSString *lastModify_time;
@property (copy, nonatomic) NSString *lastModify_id;
@property (copy, nonatomic) NSString *lastModify_operName;
@property (copy, nonatomic) NSString *enterprise;
@property (copy, nonatomic) NSString *title;
@property (copy, nonatomic) NSString *content;
@property (copy, nonatomic) NSString *attachmentId;
@property (copy, nonatomic) NSArray *attachmentUrls;
//附件的url 后台暂时没加
@property (assign, nonatomic) ICRAnnouncementPriority priority;
@property (assign, nonatomic) ICRAnnouncemenState state;
@property (assign, nonatomic) ICRAnnouncementReadType readType;
@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
//
// AnnouncementDetailTableViewCell.h
// RealEstateManagement
//
// Created by Javen on 16/9/5.
// Copyright © 2016年 上海勾芒信息科技. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSInteger, announcementDetailCellType) {
announcementDetailCellTypeTop,
announcementDetailCellTypeCenter,
announcementDetailCellTypeBottom,
};
@interface AnnouncementDetailTableViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UIImageView *topImage;
@property (weak, nonatomic) IBOutlet UIImageView *centerImage;
@property (weak, nonatomic) IBOutlet UIImageView *bottomImage;
@property (nonatomic, copy) NSString *contentText;
@property (weak, nonatomic) IBOutlet UILabel *content;
@property (nonatomic, assign) announcementDetailCellType type;
@property (nonatomic, assign) BOOL isOnlyOne;
@property (nonatomic, copy) NSString *fileUrl;
@property (nonatomic, copy) void (^openFile)(void);
@end
//
// AnnouncementDetailTableViewCell.m
// RealEstateManagement
//
// Created by Javen on 16/9/5.
// Copyright © 2016年 上海勾芒信息科技. All rights reserved.
//
#import "AnnouncementDetailTableViewCell.h"
#import "IBTWebViewController.h"
@implementation AnnouncementDetailTableViewCell
- (void)awakeFromNib {
// Initialization code
self.selectionStyle = UITableViewCellSelectionStyleNone;
}
- (IBAction)open:(id)sender {
self.openFile();
}
- (void)setContentText:(NSString *)contentText {
if (![_contentText isEqualToString:contentText]) {
_contentText = contentText;
}
NSMutableAttributedString *content = [[NSMutableAttributedString alloc]initWithString:contentText];
NSRange contentRange = {0,[content length]};
[content addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:contentRange];
self.content.attributedText = content;
}
- (void)setType:(announcementDetailCellType)type {
_type = type;
switch (type) {
case announcementDetailCellTypeTop: {
self.topImage.hidden = NO;
self.centerImage.hidden = YES;
self.bottomImage.hidden = YES;
break;
}
case announcementDetailCellTypeCenter: {
self.topImage.hidden = YES;
self.centerImage.hidden = NO;
self.bottomImage.hidden = YES;
break;
}
case announcementDetailCellTypeBottom: {
self.topImage.hidden = YES;
self.centerImage.hidden = YES;
self.bottomImage.hidden = NO;
break;
}
}
}
- (void)setIsOnlyOne:(BOOL)isOnlyOne {
_isOnlyOne = isOnlyOne;
_bottomImage.hidden = !isOnlyOne;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@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 "UILabel+SizeCalculate.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 = @"发布人:";
[self addSubview:_m_creatByLabel];
self.m_creatTimeLabel = [[self class ] creatLabelWithTextColor:CREAT_BY_TEXT_COLOR
textFont:[UIFont systemFontOfSize:13]
textAlignment:NSTextAlignmentLeft];
_m_creatTimeLabel.text = @"发布时间:";
[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.readType) {
case kICRAnnouncementTypeUnread:
{
switch (announcement.priority) {
case kICRAnnouncementPriorityLow:
{
self.m_priorityLabel.text = @"低";
self.m_priorityLabel.backgroundColor = [UIColor colorWithPatternImage:
[UIImage imageNamed:@"PriorityTagGreen"]];
}
break;
case kICRAnnouncementPriorityNormal:
{
self.m_priorityLabel.text = [IBTCommon localizableString:@"中"];
self.m_priorityLabel.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"PriorityTagOrange"]];
}
break;
case kICRAnnouncementPriorityHigh:
{
self.m_priorityLabel.text = @"高";
self.m_priorityLabel.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"PriorityTagRed"]];
}
break;
default:
break;
}
}
break;
case kICRAnnouncementTypeReaded:
{
switch (announcement.priority) {
case kICRAnnouncementPriorityLow:
{
self.m_priorityLabel.text = @"低";
}
break;
case kICRAnnouncementPriorityNormal:
{
self.m_priorityLabel.text = @"中";
}
break;
case kICRAnnouncementPriorityHigh:
{
self.m_priorityLabel.text = @"高";
}
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.create_operName;//[announcement createInfo ][@"operator"][@"operName"] ? :@"";
self.m_creatTimeValueLabel.text = announcement.create_time;//[announcement createInfo ][@"time"]? : @"";
}
[self setNeedsLayout];
}
@end
//
// ICRAnnouncementDetailContentView.m
// Cruiser
//
// Created by Lili Wang on 15/4/16.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#define LABEL_LEFT_PANDING (20)
#define LABEL_TOP_PANDING (25)
#define LABEL_HEIGHT (13)
#define LABEL_WIDTH (35)
#define TABLEVIEW_CELL_HEIGHT (35)
#import "ICRAnnouncementDetailContentView.h"
#import "ICRAnnouncementDetailHeadView.h"
#import "IBTTableView.h"
#import "LBorderView.h"
#import "IBTTableViewCell.h"
#import "ICRAttachment.h"
#import "ICRAttachmentCellContentView.h"
#import "ICRAnnouncement.h"
static NSString *TableViewCell = @"IBTTableViewCell";
@interface ICRAnnouncementDetailContentView ()
<
UITableViewDataSource,
UITableViewDelegate
>
@property (strong, nonatomic) LBorderView *m_AttachmentView;
@property (strong, nonatomic) UILabel *m_attachemntLabel;
@property (strong, nonatomic) IBTTableView *m_tableView;
@property (strong, nonatomic) NSArray *m_arrData;
@end
@implementation ICRAnnouncementDetailContentView
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self _init];
}
return self;
}
- (void)layoutSubviews {
_m_attachemntLabel.frame = (CGRect){
.origin.x = LABEL_LEFT_PANDING,
.origin.y = LABEL_TOP_PANDING + _m_headView.bottom,
.size.width = LABEL_WIDTH,
.size.height = LABEL_HEIGHT
};
_m_AttachmentView.frame = (CGRect){
.origin.x = _m_attachemntLabel.left,
.origin.y = _m_attachemntLabel.bottom + 6,
.size.width = self.width - LABEL_LEFT_PANDING * 2,
.size.height = _m_arrData.count * TABLEVIEW_CELL_HEIGHT
};
self.height = _m_AttachmentView.bottom + LABEL_TOP_PANDING;
}
#pragma mark - Private Method
- (void)_init {
CGRect frame = self.frame;
self.m_headView = [[ICRAnnouncementDetailHeadView alloc] initWithFrame:frame];
[self addSubview:_m_headView];
self.m_arrData = [NSArray array];
self.m_attachemntLabel = [[UILabel alloc] init];
_m_attachemntLabel.textColor = [UIColor colorWithRed:0.000f green:0.463f blue:0.925f alpha:1.00f];
_m_attachemntLabel.font = [UIFont systemFontOfSize:12];
_m_attachemntLabel.text = [IBTCommon localizableString:@"Attachment:"];
[self addSubview:_m_attachemntLabel];
// Bottom Refference View
self.m_AttachmentView = [[LBorderView alloc] init];
_m_AttachmentView.cornerRadius = 3.0f;
_m_AttachmentView.borderType = BorderTypeDashed;
_m_AttachmentView.borderWidth = .5f;
_m_AttachmentView.borderColor = [UIColor lightGrayColor];
_m_AttachmentView.dashPattern = 4;
_m_AttachmentView.spacePattern = 2;
[self addSubview:_m_AttachmentView];
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
self.m_tableView = [[IBTTableView alloc]
initWithFrame:_m_AttachmentView.bounds style:UITableViewStylePlain];
_m_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
[_m_tableView registerClass:[IBTTableViewCell class]
forCellReuseIdentifier:TableViewCell];
_m_tableView.scrollEnabled = NO;
_m_tableView.rowHeight = TABLEVIEW_CELL_HEIGHT;
_m_tableView.dataSource = self;
_m_tableView.delegate = self;
_m_tableView.tableFooterView = view;
[_m_tableView autoresizingWithStrechFullSize];
[_m_AttachmentView addSubview:_m_tableView];
}
#pragma mark - UITableViewDatasource -
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _m_arrData.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TableViewCell];
[self configureCell:cell forRowAtIndexPath:indexPath];
return cell;
}
- (void)configureCell:(UITableViewCell *)cell
forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.selectionStyle = UITableViewCellSelectionStyleNone;
id obj = [_m_arrData objectAtIndex:indexPath.row];
UIView *contentView = cell.contentView;
ICRAttachmentCellContentView *aContentView = [contentView viewWithClass:
[ICRAttachmentCellContentView class]];
if (!aContentView) {
aContentView = [[ICRAttachmentCellContentView alloc] initWithFrame:contentView.frame];
[aContentView autoresizingWithStrechFullSize];
[contentView addSubview:aContentView];
aContentView.m_downloadBtn.tag = indexPath.row;
[aContentView.m_downloadBtn addTarget:self action:@selector(downloadButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
[aContentView updateContentWithData:obj];
}
#pragma mark - UITableViewDelegate
//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
// return 35;
//}
#pragma mark - UIButton Actions
- (void)downloadButtonAction:(id)sender {
UIButton *button = (UIButton *)sender;
// button.backgroundColor = [UIColor colorWithRed:0.157f green:0.843f blue:0.463f alpha:1.00f];
// button.userInteractionEnabled = NO;
if ([self.m_delegate respondsToSelector:@selector(AttachmentDetail:downloadBtn:)]) {
[self.m_delegate AttachmentDetail:_m_arrData[ button.tag ] downloadBtn:button];
}
}
#pragma mark - Public Method
- (void)updateWithAnnouncement:(ICRAnnouncement *)announcement {
[self.m_headView updateContentWithData:announcement];
NSUInteger uiAttachCount = [announcement.attachmentUrls count];
if (uiAttachCount > 0) {
_m_attachemntLabel.hidden = NO;
_m_AttachmentView.hidden = NO;
// NSArray *arrAttIDs = [announcement.attachments valueForKeyPath:@"id"];
// ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) {
// NSString * sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@ IN %@ ORDER BY %@", [ICRAttachment TableName], @"id", [IBTModel ValuePlaceholdersWithCount:uiAttachCount] , @"id"];
// return [db executeQuery:sql withArgumentsInArray:arrAttIDs];
// };
//
// __weak typeof(self)weakSelf = self;
// ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) {
// __strong __typeof(weakSelf)strongSelf = weakSelf;
// strongSelf.m_arrData = fetchedObjects;
// [strongSelf layoutSubviews];
// [strongSelf.m_tableView reloadData];
// };
//
// ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController];
// [dbCtrl runFetchForClass:[ICRAttachment class]
// fetchBlock:fetchBlk
// fetchResultsBlock:fetchResultsBlk];
NSMutableArray *muArr = [@[]mutableCopy];
for(NSDictionary *dict in announcement.attachmentUrls) {
ICRAttachment *attachment = [ICRAttachment DBObject];
[attachment praseFromJsonDict:dict];
[muArr addObject:attachment];
}
self.m_arrData = muArr;
[self layoutSubviews];
[_m_tableView reloadData];
}
else {
_m_attachemntLabel.hidden = YES;
_m_AttachmentView.hidden = YES;
}
}
@end
//
// ICRAnnouncementDetailHeadView.m
// Cruiser
//
// Created by Lili Wang on 15/4/15.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#define LABEL_TEXT_COLOR [UIColor colorWithRed:0.286f green:0.549f blue:0.933f alpha:1.00f]
#define CONTENT_LABEL_TEXT_COLOR [UIColor colorWithRed:0.471f green:0.471f blue:0.478f alpha:1.00f]
#define MYSELF_BACKGROUND_COLOR [UIColor colorWithRed:0.941f green:0.965f blue:0.996f alpha:1.00f]
#define LIMITED_SIZE CGSizeMake( self.width/2 , CREAT_BY_LABEL_HEIGHT )
#define TITLE_IMG_TOP_PANDING (5)
#define TITLT_IMG_HEIGHT (55)
#define TITLE_LABEL_HEIGHT (15)
#define TITLE_LABEL_TOP_PANDING (13)
#define CREAT_BY_LABEL_HEIGHT (13)
#define CREAT_BY_LABEL_LEFT_PANDING (20)
#define CREAT_TIME_LABEL_LEFT_PANDING (self.width/2)
#define CREAT_BY_LABEL_INNER (15)
#define CREAT_BY_VALUE_LABEL_INNER (5)
#define TEXTVIEW_BOTTOM_PANDING (20)
#import "ICRAnnouncementDetailHeadView.h"
#import "ICRAnnocementContentView.h"
#import "ICRAnnouncement.h"
@interface ICRAnnouncementDetailHeadView ()
@property (strong, nonatomic) UIImageView *m_titleImageView;
@property (strong, nonatomic) UILabel *m_titleLabel;
@property (strong, nonatomic) UILabel *m_creatByLabel;
@property (strong, nonatomic) UILabel *m_creatByValueLabel;
@property (strong, nonatomic) UILabel *m_creatTimeLabel;
@property (strong, nonatomic) UILabel *m_creatTimeValueLabel;
@property (strong, nonatomic) UILabel *m_announcementContentLabel;
@property (strong, nonatomic) UILabel *m_announcementContentDetail;
@end
@implementation ICRAnnouncementDetailHeadView
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
// code
[self _init];
}
return self;
}
- (void)layoutSubviews {
CGFloat fMaxW = self.width - CREAT_BY_LABEL_LEFT_PANDING;
CGSize size = CGSizeMake( fMaxW , CGFLOAT_MAX );
size = [_m_titleLabel widthLimitedSizeThatFits:size];
_m_titleImageView.frame = (CGRect){
.origin.x = CREAT_BY_LABEL_LEFT_PANDING,
.origin.y = TITLE_IMG_TOP_PANDING,
.size.width = self.width - CREAT_BY_LABEL_LEFT_PANDING * 2,
.size.height = size.height + TITLE_LABEL_TOP_PANDING * 2
};
_m_titleLabel.frame = (CGRect){
.origin.x = (_m_titleImageView.width - size.width)/2,
.origin.y = (_m_titleImageView.height - size.height)/2,
.size = size
};
size = [_m_creatByLabel widthLimitedSizeThatFits:LIMITED_SIZE];
_m_creatByLabel.frame = (CGRect){
.origin.x = _m_titleImageView.left,
.origin.y = _m_titleImageView.bottom + CREAT_BY_LABEL_INNER,
.size = size
};
size = [_m_creatByValueLabel widthLimitedSizeThatFits:LIMITED_SIZE];
_m_creatByValueLabel.frame = (CGRect){
.origin.x = _m_creatByLabel.left,
.origin.y = _m_creatByLabel.bottom + CREAT_BY_VALUE_LABEL_INNER,
.size = size
};
size = [_m_creatTimeLabel widthLimitedSizeThatFits:LIMITED_SIZE];
_m_creatTimeLabel.frame = (CGRect){
.origin.x = CREAT_TIME_LABEL_LEFT_PANDING,
.origin.y = _m_creatByLabel.top,
.size = size
};
size = [_m_creatTimeValueLabel widthLimitedSizeThatFits:LIMITED_SIZE];
_m_creatTimeValueLabel.frame = (CGRect){
.origin.x = _m_creatTimeLabel.left,
.origin.y = _m_creatByValueLabel.top,
.size = size
};
size = [_m_announcementContentLabel widthLimitedSizeThatFits:LIMITED_SIZE];
_m_announcementContentLabel.frame = (CGRect){
.origin.x = _m_creatByLabel.left,
.origin.y = _m_creatByValueLabel.bottom + CREAT_BY_LABEL_INNER,
.size = size
};
size = CGSizeMake( fMaxW , CGFLOAT_MAX);
size = [_m_announcementContentDetail heightLimitedSizeThatFits:size];
_m_announcementContentDetail.frame = (CGRect){
.origin.x = _m_announcementContentLabel.left,
.origin.y = _m_announcementContentLabel.bottom + CREAT_BY_VALUE_LABEL_INNER,
.size.width = fMaxW,
.size.height = size.height
};
self.height = _m_announcementContentDetail.bottom + TEXTVIEW_BOTTOM_PANDING;
}
#pragma mark - Private Method
- (void)_init {
self.backgroundColor = MYSELF_BACKGROUND_COLOR;
self.m_titleImageView = [[UIImageView alloc] init];
_m_titleImageView.backgroundColor = [UIColor clearColor];
_m_titleImageView.image = [[UIImage imageNamed:@"AnnounceTitleBG"]
stretchableImageWithLeftCapWidth:50 topCapHeight:10];
[self addSubview:_m_titleImageView];
self.m_titleLabel = [[ICRAnnocementContentView class]
creatLabelWithTextColor:[UIColor whiteColor]
textFont:[UIFont boldSystemFontOfSize:14]
textAlignment:NSTextAlignmentLeft];
_m_titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
_m_titleLabel.numberOfLines = 0;
[_m_titleImageView addSubview:_m_titleLabel];
self.m_creatByLabel = [[ICRAnnocementContentView class]
creatLabelWithTextColor:LABEL_TEXT_COLOR
textFont:[UIFont systemFontOfSize:12]
textAlignment:NSTextAlignmentLeft];
_m_creatByLabel.text = [IBTCommon localizableString:@"Publisher"];
[self addSubview:_m_creatByLabel];
self.m_creatByValueLabel = [[ICRAnnocementContentView class]
creatLabelWithTextColor:CONTENT_LABEL_TEXT_COLOR
textFont:[UIFont systemFontOfSize:14]
textAlignment:NSTextAlignmentLeft];
[self addSubview:_m_creatByValueLabel];
self.m_creatTimeLabel = [[ICRAnnocementContentView class]
creatLabelWithTextColor:LABEL_TEXT_COLOR
textFont:[UIFont systemFontOfSize:12]
textAlignment:NSTextAlignmentLeft];
_m_creatTimeLabel.text = [IBTCommon localizableString:@"Publish Time"];
[self addSubview:_m_creatTimeLabel];
self.m_creatTimeValueLabel = [[ICRAnnocementContentView class]
creatLabelWithTextColor:CONTENT_LABEL_TEXT_COLOR
textFont:[UIFont systemFontOfSize:14]
textAlignment:NSTextAlignmentLeft];
[self addSubview:_m_creatTimeValueLabel];
self.m_announcementContentLabel = [[ICRAnnocementContentView class]
creatLabelWithTextColor:LABEL_TEXT_COLOR
textFont:[UIFont systemFontOfSize:12]
textAlignment:NSTextAlignmentLeft];
_m_announcementContentLabel.text = [IBTCommon localizableString:@"Content"];
[self addSubview:_m_announcementContentLabel];
self.m_announcementContentDetail = [[ICRAnnocementContentView class]
creatLabelWithTextColor:CONTENT_LABEL_TEXT_COLOR
textFont:[UIFont systemFontOfSize:12]
textAlignment:NSTextAlignmentLeft];
_m_announcementContentDetail.numberOfLines = 0;
[self addSubview:_m_announcementContentDetail];
}
#pragma mark - Public Method
- (void)updateContentWithData:(ICRAnnouncement *)announcement {
self.m_titleLabel.text = announcement.title ? : @"";
self.m_creatByValueLabel.text = announcement.create_operName;//[announcement createInfo][@"operator"][@"operName"] ? : @"";
self.m_creatTimeValueLabel.text = announcement.create_time;//[announcement createInfo][@"time"] ? :@"";
self.m_announcementContentDetail.text = announcement.content ? : @"";
[self setNeedsLayout];
}
@end
//
// ICRAttachmentCellContentView.m
// Cruiser
//
// Created by Lili Wang on 15/4/15.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#define LABEL_LEFT_PANDING (15)
#define LABEL_HEIGHT (11)
#define LABEL_WIDTH (0)
#define TITLE_LABEL_WIDTH (180)
#define BUTTON_HEIGHT (20)
#define BUTTON_WIDTH (50)
#define NAME_LABEL_LEFT_PANDING (20)
#define BUTTON_LEFT_PANDING (25)
#import "ICRAttachmentCellContentView.h"
#import "ICRAttachment.h"
@interface ICRAttachmentCellContentView ()
@property (strong, nonatomic) UILabel *m_attIdLabel;
@property (strong, nonatomic) UILabel *m_attNameLabel;
@property (strong, nonatomic) UIView *view;
@end
@implementation ICRAttachmentCellContentView
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self _init];
}
return self;
}
- (void)layoutSubviews {
_m_attIdLabel.frame = (CGRect){
.origin.x = LABEL_LEFT_PANDING,
.origin.y = (self.height - LABEL_HEIGHT)/2,
.size.width = LABEL_WIDTH,
.size.height = LABEL_HEIGHT
};
_m_attNameLabel.frame = (CGRect){
.origin.x = _m_attIdLabel.right + NAME_LABEL_LEFT_PANDING,
.origin.y = _m_attIdLabel.top,
.size.width = TITLE_LABEL_WIDTH,
.size.height = LABEL_HEIGHT
};
_m_downloadBtn.frame = (CGRect){
.origin.x = _m_attNameLabel.right + BUTTON_LEFT_PANDING,
.origin.y = (self.height - BUTTON_HEIGHT)/2,
.size.width = BUTTON_WIDTH,
.size.height = BUTTON_HEIGHT
};
_view.frame = (CGRect){
.origin.x = _m_attIdLabel.left,
.origin.y = self.height - 1,
.size.width = self.width - 2 * LABEL_LEFT_PANDING,
.size.height = 1
};
}
#pragma mark - Private Method
- (void)_init {
self.m_attIdLabel = [[UILabel alloc] init];
_m_attIdLabel.textColor = [UIColor colorWithRed:0.443f green:0.443f blue:0.443f alpha:1.00f];
_m_attIdLabel.font = [UIFont systemFontOfSize:10];
_m_attIdLabel.textAlignment = NSTextAlignmentLeft;
[self addSubview:_m_attIdLabel];
self.view = [[UIView alloc] init];
_view.backgroundColor = [UIColor lightGrayColor];
[self addSubview:_view];
self.m_attNameLabel = [[UILabel alloc] init];
_m_attNameLabel.textColor = [UIColor colorWithRed:0.000f green:0.463f blue:0.925f alpha:1.00f];
_m_attNameLabel.font = [UIFont systemFontOfSize:10];
_m_attNameLabel.textAlignment = NSTextAlignmentLeft;
[self addSubview:_m_attNameLabel];
self.m_downloadBtn = [UIButton buttonWithType:UIButtonTypeCustom];
_m_downloadBtn.layer.masksToBounds = YES;
_m_downloadBtn.layer.cornerRadius = 5;
[_m_downloadBtn setTitle:@"打开"
forState:UIControlStateNormal];
[_m_downloadBtn setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithRed:0.157f green:0.843f blue:0.463f alpha:1.00f]] forState:UIControlStateNormal];
// [UIColor colorWithRed:0.690f green:0.690f blue:0.690f alpha:1.00f]];
[self addSubview:_m_downloadBtn];
}
#pragma mark - Pubulic Method
- (void)updateContentWithData:(id)data {
if ([data isKindOfClass:[ICRAttachment class]]) {
ICRAttachment *attachment = data;
_m_attIdLabel.text = attachment.uuid;
NSDictionary *underlineAttribute = @{NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle)};
_m_attNameLabel.attributedText = [[NSAttributedString alloc] initWithString:attachment.fileName
attributes:underlineAttribute];
}
}
@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
//
// ICRAnnouncementDetailContentView.h
// Cruiser
//
// Created by Lili Wang on 15/4/16.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "IBTUIView.h"
@protocol ICRAnnouncementDetailHeadViewDelegate;
@class ICRAnnouncement, ICRAttachment;
@class ICRAnnouncementDetailHeadView;
@interface ICRAnnouncementDetailContentView : IBTUIView
@property (strong, nonatomic) ICRAnnouncementDetailHeadView *m_headView;
@property (weak, nonatomic) id <ICRAnnouncementDetailHeadViewDelegate> m_delegate;
- (void)updateWithAnnouncement:(ICRAnnouncement *)announcement;
@end
@protocol ICRAnnouncementDetailHeadViewDelegate <NSObject>
@optional
- (void)AttachmentDetail:(ICRAttachment *)attach downloadBtn:(UIButton *)button;
@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
//
// ICRAnnouncementViewController.h
// Cruiser
//
// Created by Xummer on 4/11/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import "ICRBaseViewController.h"
@interface ICRAnnouncementViewController : ICRBaseViewController
@end
//
// ICRAnnouncementViewController.m
// Cruiser
//
// Created by Xummer on 4/11/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#define MYANNOUNCEMENTCELL_HEIGHT (75)
#import "ICRAnnouncementViewController.h"
#import "ICRAnnouncementDetailViewController.h"
#import "ICRAnnouncement.h"
#import "ICRAnnocementContentView.h"
#import "IBTRefreshTableView.h"
#import "ICRDataBaseController.h"
#import "ICRHTTPController.h"
static NSString *MyTableViewCell = @"IBTTableViewCell";
@interface ICRAnnouncementViewController ()
<
UITableViewDataSource,
UITableViewDelegate,
IBTScrollViewRefreshDelegate
>
@property (strong, nonatomic) IBTRefreshTableView *m_tableView;
@property (strong, nonatomic) IBTSegmentContainer *m_segContainer;
@property (weak, nonatomic) IBTSegmentedControl *m_segmentControl;
@property (strong, nonatomic) NSArray *m_arrData;
@end
@implementation ICRAnnouncementViewController
#pragma mark - Life Cycle
//- (void)viewDidLoad {
// [super viewDidLoad];
// // Do any additional setup after loading the view.
//
// self.title = [IBTCommon localizableString:@"Announcement"];
//
// [self initSegmentConatinerFromOriginY:0];
// [self initTableView];
//
//}
ON_CREATE_VIEWS( signal )
{
self.navigationBarShown = YES;
self.navigationBarTitle = [IBTCommon localizableString:@"Announcement"];
}
ON_DID_APPEAR( signal )
{
[self initSegmentConatinerFromOriginY:64];
[self initTableView];
[self fetchDataMore:NO type:kICRAnnouncementTypeUnread];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Private Method
- (void)initTableView {
CGFloat dy = CGRectGetMaxY(_m_segContainer.frame);
CGRect frame = self.view.bounds;
frame.origin.y = dy;
frame.size.height -= CGRectGetMinY(frame);
self.m_tableView =
[[IBTRefreshTableView alloc] initWithFrame:frame style:UITableViewStylePlain];
[_m_tableView registerClass:[IBTTableViewCell class]
forCellReuseIdentifier:MyTableViewCell];
[_m_tableView autoresizingWithStrechFullSize];
_m_tableView.dataSource = self;
_m_tableView.delegate = self;
_m_tableView.refreshDelegate = self;
[_m_tableView addRefreshControlWithText:[IBTCommon localizableString:@""]];
[_m_tableView addLoadMoreFootWithText:[IBTCommon localizableString:@"Load more"]];
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
_m_tableView.tableFooterView = view;
[self.view addSubview:_m_tableView];
}
- (void)initSegmentConatinerFromOriginY:(CGFloat)y {
if (_m_segContainer) {
return;
}
NSArray *arrSegments =
@[ [IBTCommon localizableString:@"Unread"],
[IBTCommon localizableString:@"Read"], ];
self.m_segContainer = [[IBTSegmentContainer alloc] initWithItems:arrSegments];
self.m_segmentControl = _m_segContainer.segmentControl;
_m_segmentControl.selectedSegmentIndex = 0;
_m_segContainer.frame = (CGRect){
.origin.x = 0,
.origin.y = y,
.size.width = CGRectGetWidth(self.view.bounds),
.size.height = IBT_SEGMENT_CONTAINER_DEFUALT_HEIGHT
};
[self.view addSubview:_m_segContainer];
[_m_segmentControl addTarget:self action:@selector(onSegmentsTapped:)
forControlEvents:UIControlEventValueChanged];
}
#pragma mark - Action
- (void)onSegmentsTapped:(id)sender {
UISegmentedControl *segmentedCtrl = sender;
switch (segmentedCtrl.selectedSegmentIndex) {
case 0: // 未读
{
[self fetchDataMore:NO type:kICRAnnouncementTypeUnread];
}
break;
case 1: // 已读
{
[self fetchDataMore:NO type:kICRAnnouncementTypeReaded];
}
break;
default:
break;
}
}
#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
return [_m_arrData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:MyTableViewCell
forIndexPath:indexPath];
[self configureCell:cell forRowAtIndexPath:indexPath];
return cell;
}
- (void)configureCell:(UITableViewCell *)cell
forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
id obj = _m_arrData[ indexPath.row ];
UIView *contentView = cell.contentView;
ICRAnnocementContentView *aContentView = [contentView viewWithClass:
[ICRAnnocementContentView class]];
if (!aContentView) {
aContentView = [[ICRAnnocementContentView alloc] initWithFrame:contentView.frame];
[aContentView autoresizingWithStrechFullSize];
[contentView addSubview:aContentView];
}
[aContentView updateContentWithData:obj];
}
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
ICRAnnouncement *annocement = [_m_arrData objectAtIndex:indexPath.row];
ICRAnnouncementDetailViewController *dVC = [[ICRAnnouncementDetailViewController alloc] initWithAnnouncementData:annocement];
[self PushViewController:dVC animated:YES];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return MYANNOUNCEMENTCELL_HEIGHT;
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView == _m_tableView) {
[_m_tableView tableViewDidScroll:scrollView];
}
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
if (scrollView == _m_tableView) {
[_m_tableView tableviewDidEndDragging:scrollView];
}
}
#pragma mark - IBTScrollViewRefreshDelegate
- (void)startRefreshData:(UIScrollView *)scrollView {
[self fetchDataMore:NO type:_m_segmentControl.selectedSegmentIndex];
}
- (void)endRefreshData:(UIScrollView *)scrollView {
}
- (void)startLoadMoreData:(UIScrollView *)scrollView {
[self fetchDataMore:YES type:_m_segmentControl.selectedSegmentIndex];
}
- (void)endLoadMoreData:(UIScrollView *)scrollView {
}
#pragma mark - Data Update
- (void)fetchAnnouncementsListWithType:(ICRAnnouncementType)type {
ICRDatabaseFetchBlock fetchBlk = ^FMResultSet *(FMDatabase *db) {
NSString * sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@ = ? ", [ICRAnnouncement TableName], @"priority"];
// , @"createTime" ORDER BY %@ DESC
return [db executeQuery:sql, @( type ) ];
};
__weak typeof(self)weakSelf = self;
ICRDatabaseFetchResultsBlock fetchResultsBlk = ^(NSArray *fetchedObjects) {
__strong __typeof(weakSelf)strongSelf = weakSelf;
strongSelf.m_arrData = fetchedObjects;
[strongSelf.m_tableView reloadData];
};
ICRDataBaseController *dbCtrl = [ICRDataBaseController sharedController];
[dbCtrl runFetchForClass:[ICRAnnouncement class]
fetchBlock:fetchBlk
fetchResultsBlock:fetchResultsBlk];
}
#pragma mark - Get Data
- (void)fetchDataMore:(BOOL)more type:(ICRAnnouncementType)eType {
__weak typeof(self)weakSelf = self;
void(^succ)(id) = ^(id data) {
__strong __typeof(weakSelf)strongSelf = weakSelf;
[strongSelf fetchAnnouncementsListWithType:eType];
if (!more) {
[_m_tableView endRefreshWithState:kRefreshStateFinished];
}
else {
[_m_tableView endLoadMoreWithState:kLoadStateFinished];
}
};
void(^fail)(id) = ^(id data) {
[IBTLoadingView showTips:data];
if (!more) {
[_m_tableView endRefreshWithState:kRefreshStateFailed];
}
else {
[_m_tableView endLoadMoreWithState:kLoadStateFailed];
}
};
ICRHTTPController *httpCtrl = [ICRHTTPController sharedController];
ICRAnnouncement *annocement = [_m_arrData lastObject];
[httpCtrl doGetBoardListFromUpdateTime:more ? nil : annocement.lastModifyInfo[@"time"]
position:0
size:20
type:eType
deleteLocal:!more
success:succ
failure:fail];
}
@end
//
// ICRAttachment.m
// Cruiser
//
// Created by Xummer on 4/12/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import "ICRAttachment.h"
@implementation ICRAttachment
+ (NSDictionary *)specialKeysAndReplaceKeys {
return @{ @"aID" : [[self class] PrimaryKey], };
}
+ (NSString *)PrimaryKey {
return @"id";
}
@end
//
// ICRAttachmentCellContentView.h
// Cruiser
//
// Created by Lili Wang on 15/4/15.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "IBTUIView.h"
@interface ICRAttachmentCellContentView : IBTUIView
@property (strong, nonatomic) UIButton *m_downloadBtn;
- (void)updateContentWithData:(id)data;
@end
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