Commit 4493cda7 authored by Achilles's avatar Achilles

添加动画和手势事件处理

parent 22e46e23
......@@ -9,9 +9,9 @@
#import "GEToast.h"
@interface VankeMainBoard_iPhone ()
@property (strong, nonatomic) VankeServiceDashBoard_iPhone *communityDashBoard;
@property (strong, nonatomic) VankeServiceDashBoard_iPhone *centerDashBoard;
@property (strong, nonatomic) VankeServiceDashBoard_iPhone *squreDashBoard;
//@property (strong, nonatomic) VankeServiceDashBoard_iPhone *communityDashBoard;
//@property (strong, nonatomic) VankeServiceDashBoard_iPhone *centerDashBoard;
//@property (strong, nonatomic) VankeServiceDashBoard_iPhone *squreDashBoard;
@property (strong, nonatomic) VankeServiceDashBoard_iPhone *currDashBoard;
@end
......@@ -20,6 +20,7 @@
@interface VankeMainBoard_iPhone ()
{
NSInteger _curTopMenuIndex;
NSMutableDictionary *tabCache;
}
@end
......@@ -37,13 +38,15 @@ DEF_MODEL( VankeProjectSummaryModel, summaryModel );
- (void)load
{
_curTopMenuIndex = 0;
_curTopMenuIndex = -1;
tabCache = [[NSMutableDictionary alloc] initWithCapacity:3];
self.summaryModel = [VankeProjectSummaryModel modelWithObserver:self];
}
- (void)unload
{
self.summaryModel = nil;
tabCache = nil;
}
#pragma mark - Signal
......@@ -53,19 +56,9 @@ ON_CREATE_VIEWS( signal )
self.view.backgroundColor = [UIColor whiteColor];
[self addLeftIconToTextField:_txtQuery icon:@"search"];
[_weatherBoard reloadLocationAndWeather];
UISwipeGestureRecognizer *swipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipes:)];
/*Swipes that are performed from right to left are to be detected*/
swipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
/*just one finger needed*/
swipeGestureRecognizer.numberOfTouchesRequired = 1;
/*add it to the view*/
[self.view addGestureRecognizer:swipeGestureRecognizer];
[self initSwipeGesture];
}
-(void)handleSwipes:(UISwipeGestureRecognizer *)paramSender{
NSLog(@"swipe to left");
}
ON_DELETE_VIEWS( signal )
{
......@@ -73,10 +66,6 @@ ON_DELETE_VIEWS( signal )
ON_LAYOUT_VIEWS( signal )
{
// 如果没有设置当前tab,则默认为第一页
if (nil == _currDashBoard) {
[self showCommunityDashBoard];
}
}
ON_WILL_APPEAR( signal )
......@@ -89,6 +78,10 @@ ON_WILL_APPEAR( signal )
ON_DID_APPEAR( signal )
{
// 如果没有设置当前tab,则默认为第一页
if (nil == _currDashBoard) {
[self showTab: 0];
}
}
ON_WILL_DISAPPEAR( signal )
......@@ -117,18 +110,15 @@ ON_SIGNAL3( VankeWeatherCell_iPhone, btnMask, signal )
#pragma VankeTopMenuBoardCell_iPhone
ON_SIGNAL3( VankeTopMenuBoardCell_iPhone, menuCommunity, signal ) {
[self.topMenu selectCommunity];
[self showCommunityDashBoard];
[self showTab: 0];
}
ON_SIGNAL3( VankeTopMenuBoardCell_iPhone, menuCenter, signal ) {
[self.topMenu selectCenter];
[self showCenterDashBoard];
[self showTab: 1];
}
ON_SIGNAL3( VankeTopMenuBoardCell_iPhone, menuSqure, signal ) {
[self.topMenu selectSqure];
[self showSqureDashBoard];
[self showTab: 2];
}
#pragma mark - VankeServiceSaleCell_iPhone
......@@ -151,10 +141,12 @@ ON_SIGNAL3(VankeServiceBoardCell_iPhone, mask, signal) {
#pragma mark - VankeProjectSummaryModel
ON_SIGNAL3(VankeProjectSummaryModel, RELOADING, signal) {
[GEToast showProgress:self.serviceDashBoardView];
}
ON_SIGNAL3(VankeProjectSummaryModel, RELOADED, signal) {
[GEToast hideProgress];
if (![_summaryModel isOk]) {
[GEToast showWithText:[_summaryModel getMessage] bottomOffset:20 duration:1.0f];
return;
......@@ -176,10 +168,8 @@ ON_SIGNAL3(VankeProjectSummaryModel, RELOADED, signal) {
textField.leftViewMode = UITextFieldViewModeAlways;
}
-(void) showCommunityDashBoard {
_curTopMenuIndex = 0;
if (self.currDashBoard != nil && self.currDashBoard == self.communityDashBoard) {
-(void) showTab: (int) tabIndex {
if (tabIndex == _curTopMenuIndex) {
return;
}
......@@ -188,89 +178,50 @@ ON_SIGNAL3(VankeProjectSummaryModel, RELOADED, signal) {
return;
}
if (self.communityDashBoard == nil) {
self.communityDashBoard = [VankeServiceDashBoard_iPhone communityDashBarod];
}
// 修改标签
[self.topMenu selectTabByIndex:tabIndex];
if (self.currDashBoard != nil) {
self.currDashBoard.frame = CGRectMake(0, 0, 0, 0);
[self.currDashBoard removeFromSuperview];
}
[self.serviceDashBoardView addSubview:self.communityDashBoard];
[UIView animateWithDuration:0.25 animations:^{
self.communityDashBoard.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
self.currDashBoard = self.communityDashBoard;
[self RELAYOUT];
}];
// 刷新数据
[_summaryModel reload];
}
-(void) showCenterDashBoard {
_curTopMenuIndex = 1;
if (self.currDashBoard != nil && self.currDashBoard == self.centerDashBoard) {
return;
}
CGRect frame = self.serviceDashBoardView.frame;
if (frame.size.width <= 0) {
return;
}
if (self.centerDashBoard == nil) {
self.centerDashBoard = [VankeServiceDashBoard_iPhone centerDashBarod];
// 查找或创建新的tab页
NSString *key = [NSString stringWithFormat:@"%d", tabIndex];
VankeServiceDashBoard_iPhone *targetTab = (VankeServiceDashBoard_iPhone*) [tabCache objectForKey:key];
if (nil == targetTab) {
targetTab = [VankeServiceDashBoard_iPhone dashBoardByIndex:tabIndex];
[tabCache setObject:targetTab forKey:key];
}
// 隐藏当前页
if (self.currDashBoard != nil) {
self.currDashBoard.frame = CGRectMake(0, 0, 0, 0);
[self.currDashBoard removeFromSuperview];
self.currDashBoard.hidden = YES;
}
[self.serviceDashBoardView addSubview:self.centerDashBoard];
[UIView animateWithDuration:0.25 animations:^{
self.centerDashBoard.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
self.currDashBoard = self.centerDashBoard;
[self RELAYOUT];
}];
// 刷新数据
[_summaryModel reload];
}
-(void) showSqureDashBoard {
_curTopMenuIndex = 2;
if (self.currDashBoard != nil && self.currDashBoard == self.squreDashBoard) {
return;
}
CGRect frame = self.serviceDashBoardView.frame;
if (frame.size.width <= 0) {
return;
}
if (self.squreDashBoard == nil) {
self.squreDashBoard = [VankeServiceDashBoard_iPhone squreDashBarod];
}
if (self.currDashBoard != nil) {
self.currDashBoard.frame = CGRectMake(0, 0, 0, 0);
[self.currDashBoard removeFromSuperview];
// 显示目标页
targetTab.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
if (tabIndex > _curTopMenuIndex) {
targetTab.right = 0.0f;
} else {
targetTab.left = frame.size.width;
}
[self.serviceDashBoardView addSubview:self.squreDashBoard];
[UIView animateWithDuration:0.25 animations:^{
self.squreDashBoard.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
self.currDashBoard = self.squreDashBoard;
[self RELAYOUT];
}];
// 刷新数据
[_summaryModel reload];
[UIView animateWithDuration:0.3f // 动画时长
delay:0.0 // 动画延迟
options:UIViewAnimationOptionCurveLinear // 动画过渡效果
animations:^{
if (tabIndex > _curTopMenuIndex) {
targetTab.right += frame.size.width;
} else {
targetTab.left -= frame.size.width;
}
targetTab.hidden = NO;
[self.serviceDashBoardView addSubview:targetTab];
}
completion:^(BOOL finished) {
self.currDashBoard = targetTab;
_curTopMenuIndex = tabIndex;
// 刷新数据
[_summaryModel reload];
}];
}
-(void) showListView: (CellType) type {
......@@ -297,4 +248,38 @@ ON_SIGNAL3(VankeProjectSummaryModel, RELOADED, signal) {
return [df stringFromDate:[NSDate date]];
}
#pragma SwipeGesture
-(void) initSwipeGesture {
UISwipeGestureRecognizer *swipeGestureRecognizerToLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipesToLeft:)];
/*Swipes that are performed from right to left are to be detected*/
swipeGestureRecognizerToLeft.direction = UISwipeGestureRecognizerDirectionLeft;
/*just one finger needed*/
swipeGestureRecognizerToLeft.numberOfTouchesRequired = 1;
swipeGestureRecognizerToLeft.cancelsTouchesInView = NO;
/*add it to the view*/
[self.serviceDashBoardView addGestureRecognizer:swipeGestureRecognizerToLeft];
UISwipeGestureRecognizer *swipeGestureRecognizerToRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipesToRight:)];
/*Swipes that are performed from right to left are to be detected*/
swipeGestureRecognizerToRight.direction = UISwipeGestureRecognizerDirectionRight;
/*just one finger needed*/
swipeGestureRecognizerToRight.numberOfTouchesRequired = 1;
swipeGestureRecognizerToRight.cancelsTouchesInView = NO;
/*add it to the view*/
[self.serviceDashBoardView addGestureRecognizer:swipeGestureRecognizerToRight];
}
-(void)handleSwipesToLeft:(UISwipeGestureRecognizer *)paramSender {
if (_curTopMenuIndex > 0) {
[self showTab:_curTopMenuIndex - 1];
}
}
-(void)handleSwipesToRight:(UISwipeGestureRecognizer *)paramSender {
if (_curTopMenuIndex < 2) {
[self showTab:_curTopMenuIndex + 1];
}
}
@end
......@@ -22,4 +22,6 @@ AS_OUTLET( VankeServiceBoardCell_iPhone, complaint );
+ (id) centerDashBarod;
+ (id) squreDashBarod;
+ (id) dashBoardByIndex: (int) index;
@end
......@@ -23,6 +23,18 @@ DEF_OUTLET( VankeServiceBoardCell_iPhone, complaint );
@synthesize name = _name;
@synthesize theme = _theme;
+ (id) dashBoardByIndex: (int) index {
if (index == 0) {
return [VankeServiceDashBoard_iPhone communityDashBarod];
} else if (index == 1) {
return [VankeServiceDashBoard_iPhone centerDashBarod];
} else if (index == 2) {
return [VankeServiceDashBoard_iPhone squreDashBarod];
} else {
return nil;
}
}
+ (id) communityDashBarod {
VankeServiceDashBoard_iPhone *board = [super cell];
board.name = @"社区2049";
......
......@@ -11,8 +11,10 @@ AS_OUTLET( BeeUIButton, menuCenter );
AS_OUTLET( BeeUIButton, menuSqure );
AS_OUTLET( BeeUIImageView, indictor );
-(void) selectCommunity;
-(void) selectCenter;
-(void) selectSqure;
//-(void) selectCommunity;
//-(void) selectCenter;
//-(void) selectSqure;
-(void) selectTabByIndex: (int) index;
@end
......@@ -20,6 +20,16 @@ DEF_OUTLET( BeeUIButton, menuCenter );
DEF_OUTLET( BeeUIButton, menuSqure );
DEF_OUTLET( BeeUIImageView, indictor );
-(void) selectTabByIndex: (int) index {
if (index == 0) {
[self selectCommunity];
} else if (index == 1) {
[self selectCenter];
} else if (index == 2) {
[self selectSqure];
}
}
-(void) selectCommunity {
[self removeActiveClass];
$(self.menuCommunity).ADD_CLASS(@"active");
......
......@@ -247,11 +247,10 @@ ON_SIGNAL3(VankeStatementListItemCell_iPhone, mask, signal) {
_model.shopLike = _shopLike;
_model.projectsIn = [[NSArray alloc] initWithObjects:_authorizedOrgUuidEquals, nil];
NSDateFormatter *df = [[NSDateFormatter alloc]init];
df.dateFormat = @"yyyy-MM-dd";
// _model.settleEquals = [NSDate date];
_model.settleEquals = [df dateFromString:@"2015-10-11"];
_model.settleEquals = [NSDate date];
// NSDateFormatter *df = [[NSDateFormatter alloc]init];
// df.dateFormat = @"yyyy-MM-dd";
// _model.settleEquals = [df dateFromString:@"2015-10-11"];
}
@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