Commit 4493cda7 authored by Achilles's avatar Achilles

添加动画和手势事件处理

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