Commit 1df7dae8 authored by 勾芒's avatar 勾芒

优化加入购物车动画、优化商品筛选

parent bc97f64a
......@@ -25,7 +25,7 @@
-(void)configSubView
{
self.productModelArray=[[NSMutableArray alloc]init];
self.backGroundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"backView.png"]];
self.backGroundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"默认场景"]];
self.backGroundImageView.frame=CGRectMake(0, 0, ScreenWidth, ScreenHeight);
[self.view addSubview:self.backGroundImageView];
self.leftSubView=[[LeftSubView alloc]initWithFrame:CGRectMake(0, 0, 200, ScreenHeight-150)];
......
......@@ -35,7 +35,7 @@
/**
* 点击加入购物车回调 ,返回当前按钮的CGPoint、及当前下标
*/
@property (nonatomic,copy) void(^ReturnCellCgpoint)(CGPoint point,NSInteger cellindex);
@property (nonatomic,copy) void(^ReturnCellCgpoint)(CGPoint point,NSInteger cellindex,CGSize size);
/**
......
......@@ -20,14 +20,14 @@
*/
- (IBAction)AddShoppingcarButtonClick:(UIButton *)sender {
CGPoint carButtonCenter = sender.center;
CGPoint carButtonCenter = self.productImageView.center;
//把button在cell坐标转化为在tableView上的坐标
CGPoint point = [self convertPoint:carButtonCenter toView:self.superview.window];
//回调
if (_ReturnCellCgpoint)
{
_ReturnCellCgpoint(point,_cellindex);
_ReturnCellCgpoint(point,_cellindex,self.productImageView.frame.size);
}
}
......
......@@ -319,47 +319,65 @@
//@synthesize consumerId;
#pragma mark -开发加入购物车动画
- (void)StartAddShoppingCarAnimationWithimage:(UIImage *)image withStartpoint:(CGPoint)point
- (void)StartAddShoppingCarAnimationWithimage:(UIImage *)image withStartpoint:(CGPoint)point withSize:(CGSize)size
{
//起点
// //起点
CGPoint startPoint = point;
//终点
// //终点
CGPoint endPoint = SHARED_APPDELEGATE.shoppingCarPoint;
//控点
// //控点
CGPoint controlPoint = CGPointMake(endPoint.x, startPoint.x);
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 60, 42)];
imageView.layer.position = point;
imageView.tag = 100;
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, size.width, size.height)];
imageView.backgroundColor = kTCColor(252, 248, 239);
imageView.image = image;
imageView.center = point;
[self.view.layer addSublayer:imageView.layer];
[self.view.window.layer addSublayer:imageView.layer];
//创建关键帧
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
animation.delegate = self;
//动画时间
animation.duration = 1;
//路径曲线
UIBezierPath *movePath = [UIBezierPath bezierPath];
[movePath moveToPoint:imageView.center];
[movePath addQuadCurveToPoint:endPoint
controlPoint:controlPoint];
//关键帧
CAKeyframeAnimation *moveAnim = [CAKeyframeAnimation animationWithKeyPath:@"position"];
//当动画完成,停留到结束位置
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;
//当方法名字遇到create,new,copy,retain,都需要管理内存
CGMutablePathRef path = CGPathCreateMutable();
//设置起点
CGPathMoveToPoint(path, NULL, startPoint.x, startPoint.y);
CGPathAddQuadCurveToPoint(path, NULL, controlPoint.x, controlPoint.y, endPoint.x,endPoint.y);
moveAnim.path = movePath.CGPath;
moveAnim.removedOnCompletion = YES;
//旋转变化
CABasicAnimation *scaleAnim = [CABasicAnimation animationWithKeyPath:@"transform"];
scaleAnim.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
//x,y轴缩小到0.1,Z 轴不变
scaleAnim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)];
scaleAnim.removedOnCompletion = YES;
//透明度变化
CABasicAnimation *opacityAnim = [CABasicAnimation animationWithKeyPath:@"alpha"];
opacityAnim.fromValue = [NSNumber numberWithFloat:1.0];
opacityAnim.toValue = [NSNumber numberWithFloat:0.1];
opacityAnim.removedOnCompletion = YES;
//设置动画路径
animation.path = path;
//关键帧,旋转,透明度组合起来执行
CAAnimationGroup *animGroup = [CAAnimationGroup animation];
//当动画完成,停留到结束位置
animGroup.removedOnCompletion = NO;
animGroup.fillMode = kCAFillModeForwards;
animGroup.animations = [NSArray arrayWithObjects:moveAnim, scaleAnim,opacityAnim, nil];
animGroup.duration = 1;
animGroup.delegate = self;
[imageView.layer addAnimation:animGroup forKey:nil];
[self performSelector:@selector(removeFromLayer:) withObject:imageView.layer afterDelay:1];
//执行动画
[imageView.layer addAnimation:animation forKey:nil];
}
#pragma mark -动画完成后移除
- (void)removeFromLayer:(CALayer *)layerAnimation{
//释放路径
CGPathRelease(path);
[layerAnimation removeFromSuperlayer];
}
#pragma mark -完成加入购物车动画完成后回调
......@@ -379,7 +397,7 @@
[self ErrorMBProgressView:@"必须设置当前客户"];
return;
}
[self StartAddShoppingCarAnimationWithimage:self.headerView.goodsImageview.image withStartpoint:[self.headerView convertPoint:[button center] toView:self.view.window]];
[self StartAddShoppingCarAnimationWithimage:self.headerView.goodsImageview.image withStartpoint:[self.headerView convertPoint:[self.headerView.goodsImageview center] toView:self.view.window] withSize:self.headerView.goodsImageview.frame.size];
SaveShoppingCartRequest *shopCar = [[SaveShoppingCartRequest alloc]init];
shopCar.consumerId = [[Customermanager manager] customerID];
shopCar.goodsId = _goodsID;
......
......@@ -133,20 +133,13 @@
__weak typeof(self)weakSelf = self;
[self getGoodsListdatas:conditon returnResponse:^(GoodsResponse *response) {
if (response.goodsEntity.count == 0) {
[self ErrorMBProgressView:@"暂无数据"];
}else
{
if (remove) {
[self.datasArray removeAllObjects];
}
for (TOGoodsEntity *model in response.goodsEntity) {
[weakSelf.datasArray addObject:model];
}
[weakSelf.productCollectionView reloadData];
if (remove) {
[self.datasArray removeAllObjects];
}
for (TOGoodsEntity *model in response.goodsEntity) {
[weakSelf.datasArray addObject:model];
}
[weakSelf.productCollectionView reloadData];
}];
}
......@@ -413,7 +406,7 @@
//加入购物车
__weak typeof(self) weakSelf = self;
__weak typeof(ProductCollectionViewCell *) weakCell = cell;
[cell setReturnCellCgpoint:^void(CGPoint centerPoint,NSInteger cellindex) {
[cell setReturnCellCgpoint:^void(CGPoint centerPoint,NSInteger cellindex ,CGSize size) {
//判断是否有当前客户
if (![Shoppersmanager manager].currentCustomer) {
......@@ -425,56 +418,72 @@
[self addGoodsShoppingbags:model complate:^{
NSLog(@"加入购物车完成");
}];
[weakSelf StartAddShoppingCarAnimationWithimage:weakCell.productImageView.image withStartpoint:centerPoint];
[weakSelf StartAddShoppingCarAnimationWithimage:weakCell.productImageView.image withStartpoint:centerPoint withSize:size];
}];
return cell;
}
#pragma mark -开发加入购物车动画
- (void)StartAddShoppingCarAnimationWithimage:(UIImage *)image withStartpoint:(CGPoint)point
- (void)StartAddShoppingCarAnimationWithimage:(UIImage *)image withStartpoint:(CGPoint)point withSize:(CGSize)size
{
//起点
// //起点
CGPoint startPoint = point;
//终点
// //终点
CGPoint endPoint = SHARED_APPDELEGATE.shoppingCarPoint;
//控点
// //控点
CGPoint controlPoint = CGPointMake(endPoint.x, startPoint.x);
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 60, 42)];
imageView.layer.position = point;
// imageView.layer.masksToBounds = YES;
// imageView.layer.cornerRadius = 50;
imageView.tag = 100;
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, size.width, size.height)];
imageView.backgroundColor = kTCColor(252, 248, 239);
imageView.image = image;
imageView.center = point;
[self.view.window.layer addSublayer:imageView.layer];
[self.view.layer addSublayer:imageView.layer];
//创建关键帧
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
animation.delegate = self;
//动画时间
animation.duration = 1;
//当动画完成,停留到结束位置
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;
//路径曲线
UIBezierPath *movePath = [UIBezierPath bezierPath];
[movePath moveToPoint:imageView.center];
[movePath addQuadCurveToPoint:endPoint
controlPoint:controlPoint];
//关键帧
CAKeyframeAnimation *moveAnim = [CAKeyframeAnimation animationWithKeyPath:@"position"];
moveAnim.path = movePath.CGPath;
moveAnim.removedOnCompletion = YES;
//当方法名字遇到create,new,copy,retain,都需要管理内存
CGMutablePathRef path = CGPathCreateMutable();
//设置起点
CGPathMoveToPoint(path, NULL, startPoint.x, startPoint.y);
CGPathAddQuadCurveToPoint(path, NULL, controlPoint.x, controlPoint.y, endPoint.x,endPoint.y);
//旋转变化
CABasicAnimation *scaleAnim = [CABasicAnimation animationWithKeyPath:@"transform"];
scaleAnim.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
//x,y轴缩小到0.1,Z 轴不变
scaleAnim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)];
scaleAnim.removedOnCompletion = YES;
//设置动画路径
animation.path = path;
//透明度变化
CABasicAnimation *opacityAnim = [CABasicAnimation animationWithKeyPath:@"alpha"];
opacityAnim.fromValue = [NSNumber numberWithFloat:1.0];
opacityAnim.toValue = [NSNumber numberWithFloat:0.1];
opacityAnim.removedOnCompletion = YES;
//执行动画
[imageView.layer addAnimation:animation forKey:nil];
//关键帧,旋转,透明度组合起来执行
CAAnimationGroup *animGroup = [CAAnimationGroup animation];
//当动画完成,停留到结束位置
animGroup.removedOnCompletion = NO;
animGroup.fillMode = kCAFillModeForwards;
animGroup.animations = [NSArray arrayWithObjects:moveAnim, scaleAnim,opacityAnim, nil];
animGroup.duration = 1;
animGroup.delegate = self;
[imageView.layer addAnimation:animGroup forKey:nil];
[self performSelector:@selector(removeFromLayer:) withObject:imageView.layer afterDelay:1];
}
#pragma mark -动画完成后移除
- (void)removeFromLayer:(CALayer *)layerAnimation{
//释放路径
CGPathRelease(path);
[layerAnimation removeFromSuperlayer];
}
......@@ -610,18 +619,17 @@
#pragma mark -选中条件
- (void)selectedItem:(NSString *)typecode withTitle:(NSString *)title
{
self.condtionModel.styleEquals = nil;
self.condtionModel.spaceEquals = nil;
self.condtionModel.categoryEquals = nil;
self.condtionModel.startprice = nil;
self.condtionModel.endprice = nil;
self.condtionModel.materialEqueals = nil;
[self DismissScreenView];
if (self.selectedIndex == 4) {
self.selectedCode = title;
}else
{
self.condtionModel.styleEquals = nil;
self.condtionModel.spaceEquals = nil;
self.condtionModel.categoryEquals = nil;
self.condtionModel.startprice = nil;
self.condtionModel.endprice = nil;
self.condtionModel.materialEqueals = nil;
self.selectedCode = typecode;
}
[self.productCollectionView.mj_header beginRefreshing];
......
......@@ -61,7 +61,7 @@
[self dismissViewControllerAnimated:YES completion:nil];
NSData *imageData = UIImageJPEGRepresentation(self.shareImage, 1.0);
// 0b44439e5504e371015504f73d4f0025,0b44439e5504e371015504feae270028
NSDictionary *parameterDict = [NSDictionary dictionaryWithObjectsAndKeys:@"这里是截图上所有商品的goodsId ,分割 后面不动",@"goodsIds",@"",@"title",@"",@"remark",nil];
NSDictionary *parameterDict = [NSDictionary dictionaryWithObjectsAndKeys:@"0b44439e5504e371015504f73d4f0025,0b44439e5504e371015504feae270028",@"goodsIds",@"",@"title",@"",@"remark",nil];
//上传图片
[[NetworkRequestClassManager Manager] UploadImageWithURL:[NSString stringWithFormat:@"%@%@",ServerAddress,@"/system/shareGoods"] WithRequestType:0 WithImageDatas:imageData WithParameter:parameterDict WithReturnValueBlock:^(id returnValue) {
......
......@@ -59,6 +59,8 @@
293393551CD3379E000D997B /* ShoppingTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 293393541CD3379E000D997B /* ShoppingTableViewCell.m */; };
29360C2F1CDDC47E002A5D89 /* ScreeningView.m in Sources */ = {isa = PBXBuildFile; fileRef = 29360C2E1CDDC47E002A5D89 /* ScreeningView.m */; };
29360C311CDDC487002A5D89 /* ScreeningView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 29360C301CDDC487002A5D89 /* ScreeningView.xib */; };
2936F28C1D014147007CA67C /* sceneScreeningCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2936F28B1D014147007CA67C /* sceneScreeningCollectionViewCell.m */; };
2936F28F1D0141FD007CA67C /* ProductScreeningTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2936F28E1D0141FD007CA67C /* ProductScreeningTableViewCell.m */; };
2942F8A61CDD80C2005B377E /* authenticateView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2942F8A51CDD80C2005B377E /* authenticateView.m */; };
2942F8A81CDD80CE005B377E /* authenticateView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2942F8A71CDD80CE005B377E /* authenticateView.xib */; };
2949BABD1CD2EFA00049385A /* InformationTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2949BABC1CD2EFA00049385A /* InformationTableViewCell.m */; };
......@@ -256,6 +258,10 @@
29360C2D1CDDC47E002A5D89 /* ScreeningView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScreeningView.h; sourceTree = "<group>"; };
29360C2E1CDDC47E002A5D89 /* ScreeningView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ScreeningView.m; sourceTree = "<group>"; };
29360C301CDDC487002A5D89 /* ScreeningView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ScreeningView.xib; sourceTree = "<group>"; };
2936F28A1D014147007CA67C /* sceneScreeningCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sceneScreeningCollectionViewCell.h; sourceTree = "<group>"; };
2936F28B1D014147007CA67C /* sceneScreeningCollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = sceneScreeningCollectionViewCell.m; sourceTree = "<group>"; };
2936F28D1D0141FD007CA67C /* ProductScreeningTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProductScreeningTableViewCell.h; sourceTree = "<group>"; };
2936F28E1D0141FD007CA67C /* ProductScreeningTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProductScreeningTableViewCell.m; sourceTree = "<group>"; };
2942F8A41CDD80C2005B377E /* authenticateView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = authenticateView.h; sourceTree = "<group>"; };
2942F8A51CDD80C2005B377E /* authenticateView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = authenticateView.m; sourceTree = "<group>"; };
2942F8A71CDD80CE005B377E /* authenticateView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = authenticateView.xib; sourceTree = "<group>"; };
......@@ -783,6 +789,17 @@
name = view;
sourceTree = "<group>";
};
2936F2861D014094007CA67C /* view */ = {
isa = PBXGroup;
children = (
2936F28A1D014147007CA67C /* sceneScreeningCollectionViewCell.h */,
2936F28B1D014147007CA67C /* sceneScreeningCollectionViewCell.m */,
2936F28D1D0141FD007CA67C /* ProductScreeningTableViewCell.h */,
2936F28E1D0141FD007CA67C /* ProductScreeningTableViewCell.m */,
);
name = view;
sourceTree = "<group>";
};
2942F8A21CDD7ECD005B377E /* controller */ = {
isa = PBXGroup;
children = (
......@@ -948,6 +965,7 @@
29808A611CFEC287001D1020 /* Experiencecentre */ = {
isa = PBXGroup;
children = (
2936F2861D014094007CA67C /* view */,
29808A681CFED712001D1020 /* Controller */,
29808A651CFED6E5001D1020 /* Scene */,
);
......@@ -1620,6 +1638,7 @@
29EAAEA01CDC79DC00C4DBA2 /* CustomerOrderViewController.m in Sources */,
04F9EE1E1CF25F7300BD729F /* ShareViewController.m in Sources */,
2928F8321CD09E320036D761 /* Toolview.m in Sources */,
2936F28C1D014147007CA67C /* sceneScreeningCollectionViewCell.m in Sources */,
2942F8A61CDD80C2005B377E /* authenticateView.m in Sources */,
041636C21CF395B7008CE961 /* NSObject+UIImagePickerController.m in Sources */,
291D6A581CFFD45F007891AE /* SceneSectionHeaderView.m in Sources */,
......@@ -1634,6 +1653,7 @@
29BB27681CD9D38E009A0813 /* AllpriceTableViewCell.m in Sources */,
29BB27771CD9DFBA009A0813 /* ProductLibraryViewController.m in Sources */,
04F9EE181CF2235000BD729F /* ShoppingView.m in Sources */,
2936F28F1D0141FD007CA67C /* ProductScreeningTableViewCell.m in Sources */,
29EAAEAA1CDC7FE800C4DBA2 /* AllCutomerTableViewCell.m in Sources */,
29808A6B1CFED730001D1020 /* SceneViewController.m in Sources */,
04F9EE1B1CF22B5900BD729F /* ShoppingCell.m in Sources */,
......@@ -1854,7 +1874,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.gomore.opple;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "f89bebf5-81e2-4c61-9052-8c7bb0f9ddd6";
PROVISIONING_PROFILE = "e9bd3600-5e9c-4cd0-a0d5-b7d8b0882ca8";
STRIP_PNG_TEXT = NO;
USER_HEADER_SEARCH_PATHS = "$(PODS_ROOT)/**";
};
......@@ -1910,7 +1930,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.gomore.opple;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "f89bebf5-81e2-4c61-9052-8c7bb0f9ddd6";
PROVISIONING_PROFILE = "e9bd3600-5e9c-4cd0-a0d5-b7d8b0882ca8";
STRIP_PNG_TEXT = NO;
USER_HEADER_SEARCH_PATHS = "$(PODS_ROOT)/**";
};
......
......@@ -59,8 +59,8 @@
/**
* 场景展示
*/
@property (weak, nonatomic) IBOutlet UIScrollView *sceneScrollview;
@property (weak, nonatomic) IBOutlet UICollectionView *sceneScrollview;
@property (weak, nonatomic) IBOutlet UICollectionViewFlowLayout *sceneLayout;
/**
* 产品筛选
......@@ -71,7 +71,7 @@
/**
* 产品展示
*/
@property (weak, nonatomic) IBOutlet UIScrollView *productScrollview;
@property (weak, nonatomic) IBOutlet UITableView *productScrollview;
......
......@@ -8,32 +8,111 @@
#import "ExperienceCentreViewController.h"
#import "SceneViewController.h"
#import "sceneScreeningCollectionViewCell.h"
#import "ProductScreeningTableViewCell.h"
@interface ExperienceCentreViewController ()<AddImagesDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UITableViewDelegate,UITableViewDataSource>
/**
* 选中场景数据
*/
@property (nonatomic,strong) NSMutableArray *sceneDatasArray;
/**
* 选中产品数据源
*/
@property (nonatomic,strong) NSMutableArray *productDatasArray;
@interface ExperienceCentreViewController ()
@end
@implementation ExperienceCentreViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
- (NSMutableArray *)sceneDatasArray
{
if (!_sceneDatasArray) {
_sceneDatasArray = [NSMutableArray array];
}
return _sceneDatasArray;
}
- (NSMutableArray *)productDatasArray
{
if (!_productDatasArray) {
_productDatasArray = [NSMutableArray array];
}
return _productDatasArray;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self uiConfigAction];
}
#pragma mark -UI
- (void)uiConfigAction
{
//场景
self.sceneLayout.itemSize = CGSizeMake(133, 100);
self.sceneLayout.minimumLineSpacing = 10;
self.sceneLayout.sectionInset = UIEdgeInsetsMake(0, 10, 0, 10);
self.sceneScrollview.delegate = self;
self.sceneScrollview.dataSource = self;
//产品
self.productScrollview.dataSource = self;
self.productScrollview.delegate = self;
}
#pragma mark -UICollectionViewDataSource场景
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return self.sceneDatasArray.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
sceneScreeningCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"sceneScreeningCollectionViewCell" forIndexPath:indexPath];
cell.selectedScrenImageView.image = [self.sceneDatasArray objectAtIndex_opple:indexPath.item];
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
self.sceneImageView.image = [self.sceneDatasArray objectAtIndex_opple:indexPath.item];
}
#pragma mark -UITableViewDataSource商品
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.productDatasArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ProductScreeningTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ProductScreeningTableViewCell" forIndexPath:indexPath];
cell.backgroundColor = [UIColor clearColor];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.selectedGoodsImageView.image = [self.productDatasArray objectAtIndex_opple:indexPath.row];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 100;
}
......@@ -83,6 +162,8 @@
sceneVC.materialButton.hidden = YES;
sceneVC.priceButton.hidden = YES;
sceneVC.typeButton.hidden = YES;
sceneVC.delegate = self;
sceneVC.endAnimationPoint = self.sceneSelectedButton.center;
sceneVC.modalPresentationStyle = UIModalPresentationOverFullScreen;
UIPopoverPresentationController *pop = sceneVC.popoverPresentationController;
pop.sourceView = sceneVC.view;
......@@ -99,6 +180,8 @@
sceneVC.materialButton.hidden = NO;
sceneVC.priceButton.hidden = NO;
sceneVC.typeButton.hidden = NO;
sceneVC.delegate = self;
sceneVC.endAnimationPoint = self.productSelectedButton.center;
sceneVC.modalPresentationStyle = UIModalPresentationOverFullScreen;
UIPopoverPresentationController *pop = sceneVC.popoverPresentationController;
pop.sourceView = sceneVC.view;
......@@ -107,6 +190,44 @@
#pragma mark -AddImagesDelegate选中图片
- (void)SelectedImages:(UIImage *)image withisScene:(BOOL)isScene returnResponse:(void (^)(BOOL))isThere
{
if (isScene) {
if (![self.sceneDatasArray containsObject:image]) {
[self.sceneDatasArray addObject:image];
}else
{
isThere(YES);
}
}else
{
if (![self.productDatasArray containsObject:image]) {
[self.productDatasArray addObject:image];
}else
{
isThere(YES);
}
}
}
#pragma mark -刷新
- (void)RefreshSceneAndProduct:(BOOL)isScene
{
if (isScene) {
[self.sceneScrollview reloadData];
[self.sceneScrollview selectItemAtIndexPath:[NSIndexPath indexPathForRow:self.sceneDatasArray.count-1 inSection:0] animated:YES scrollPosition:UICollectionViewScrollPositionRight];
}else
{
[self.productScrollview reloadData];
[self.productScrollview scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:self.productDatasArray.count-1 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
......
//
// ProductScreeningTableViewCell.h
// Lighting
//
// Created by 曹云霄 on 16/6/3.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ProductScreeningTableViewCell : UITableViewCell
/**
* 选中商品图片
*/
@property (weak, nonatomic) IBOutlet UIImageView *selectedGoodsImageView;
@end
//
// ProductScreeningTableViewCell.m
// Lighting
//
// Created by 曹云霄 on 16/6/3.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "ProductScreeningTableViewCell.h"
@implementation ProductScreeningTableViewCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
......@@ -8,6 +8,22 @@
#import "BaseViewController.h"
/**
* 选中场景或者商品回传
*/
@protocol AddImagesDelegate <NSObject>
@required
//增加图片
- (void)SelectedImages:(UIImage *)image withisScene:(BOOL)isScene returnResponse:(void(^)(BOOL boolValue))isThere;
//刷新
- (void)RefreshSceneAndProduct:(BOOL)isScene;
//删除图片
@end
@interface SceneViewController : BaseViewController
......@@ -86,10 +102,15 @@
@property (weak, nonatomic) IBOutlet UIView *searchBackView;
/**
* 选中场景或商品,动画终点坐标
*/
@property (nonatomic,assign) CGPoint endAnimationPoint;
/**
* 选中商品回传
*/
@property (nonatomic,assign) id<AddImagesDelegate> delegate;
@end
......@@ -707,7 +707,7 @@
[index addIndex:i];
}
[self.openArray replaceObjectAtIndex:button.tag-100 withObject:boolValue?@"0":@"1"];
[self.screeningTableView reloadSections:index withRowAnimation:UITableViewRowAnimationFade];
[self.screeningTableView reloadSections:index withRowAnimation:UITableViewRowAnimationMiddle];
}else
{
......@@ -727,16 +727,22 @@
}else
{
if (self.rightSelectedIndex == 2) {
array = [[self.productScreeningDatasArray objectAtIndex_opple:self.rightSelectedIndex] firstObject];
array = [[[self.productScreeningDatasArray objectAtIndex_opple:self.rightSelectedIndex] firstObject] children];
}else
{
array = [self.productScreeningDatasArray objectAtIndex_opple:self.rightSelectedIndex];
}
}
for (int i=0; i<array.count; i++) {
SceneSectionHeaderView *sectionView = [self.screeningTableView headerViewForSection:i];
sectionView.sectionButton.selected = NO;
sectionView.sectionButton.backgroundColor = [UIColor whiteColor];
UITableViewHeaderFooterView *sectionView = [self.screeningTableView headerViewForSection:i];
for (id objc in sectionView.subviews) {
if ([objc isKindOfClass:[UIButton class]]) {
UIButton *button = (UIButton *)objc;
button.selected = NO;
button.backgroundColor = [UIColor whiteColor];
}
}
}
}
......@@ -773,9 +779,118 @@
}
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
__weak typeof(self) weakSelf = self;
if (self.isScene) {
ScreeningCollectionViewCell *cell = (ScreeningCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
CGPoint startPoint = [cell convertPoint:cell.sceneImageView.center toView:self.sceneOrProductClollectionView.window];
if ([self.delegate respondsToSelector:@selector(SelectedImages:withisScene:returnResponse:)]) {
[self.delegate SelectedImages:cell.sceneImageView.image withisScene:self.isScene returnResponse:^(BOOL boolValue) {
//判断选中的图片是否存在
if (!boolValue) {
[weakSelf StartAddShoppingCarAnimationWithimage:[cell.sceneImageView image] withStartpoint:startPoint withSize:cell.mj_size];
SceneListModel *model = [self.sceneDatasArray objectAtIndex_opple:indexPath.item];
model.isSelectedSate = YES;
}else
{
SceneListModel *model = [self.sceneDatasArray objectAtIndex_opple:indexPath.item];
model.isSelectedSate = NO;
}
}];
}
[self.sceneOrProductClollectionView reloadItemsAtIndexPaths:@[indexPath]];
}else
{
ProductScreeningCollectionViewCell *cell = (ProductScreeningCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
CGPoint startPoint = [cell convertPoint:cell.goodsImageView.center toView:self.sceneOrProductClollectionView.window];
if ([self.delegate respondsToSelector:@selector(SelectedImages:withisScene:returnResponse:)]) {
[self.delegate SelectedImages:cell.goodsImageView.image withisScene:self.isScene returnResponse:^(BOOL boolValue) {
//判断图片是否存在
if (!boolValue) {
[self StartAddShoppingCarAnimationWithimage:[cell.goodsImageView image] withStartpoint:startPoint withSize:cell.mj_size];
GoodsCategoryModel *model = [self.productDatasArray objectAtIndex_opple:indexPath.item];
model.isSelectedState = YES;
}else
{
GoodsCategoryModel *model = [self.productDatasArray objectAtIndex_opple:indexPath.item];
model.isSelectedState = NO;
}
}];
}
[self.sceneOrProductClollectionView reloadItemsAtIndexPaths:@[indexPath]];
}
}
#pragma mark -加入场景库、产品库动画
- (void)StartAddShoppingCarAnimationWithimage:(UIImage *)image withStartpoint:(CGPoint)point withSize:(CGSize)imageSize
{
CGPoint startPoint = point;
CGPoint endPoint = self.endAnimationPoint;
CGPoint controlPoint = CGPointMake(endPoint.x, startPoint.x);
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, imageSize.width, imageSize.height)];
imageView.center = point;
imageView.tag = 100;
imageView.image = image;
[self.view.window.layer addSublayer:imageView.layer];
//路径曲线
UIBezierPath *movePath = [UIBezierPath bezierPath];
[movePath moveToPoint:imageView.center];
[movePath addQuadCurveToPoint:endPoint
controlPoint:controlPoint];
//关键帧
CAKeyframeAnimation *moveAnim = [CAKeyframeAnimation animationWithKeyPath:@"position"];
moveAnim.path = movePath.CGPath;
moveAnim.removedOnCompletion = YES;
//旋转变化
CABasicAnimation *scaleAnim = [CABasicAnimation animationWithKeyPath:@"transform"];
scaleAnim.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
//x,y轴缩小到0.1,Z 轴不变
scaleAnim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)];
scaleAnim.removedOnCompletion = YES;
//透明度变化
CABasicAnimation *opacityAnim = [CABasicAnimation animationWithKeyPath:@"alpha"];
opacityAnim.fromValue = [NSNumber numberWithFloat:1.0];
opacityAnim.toValue = [NSNumber numberWithFloat:0.1];
opacityAnim.removedOnCompletion = YES;
//关键帧,旋转,透明度组合起来执行
CAAnimationGroup *animGroup = [CAAnimationGroup animation];
//当动画完成,停留到结束位置
animGroup.removedOnCompletion = NO;
animGroup.fillMode = kCAFillModeForwards;
animGroup.animations = [NSArray arrayWithObjects:moveAnim, scaleAnim,opacityAnim, nil];
animGroup.duration = 1;
animGroup.delegate = self;
[imageView.layer addAnimation:animGroup forKey:nil];
[self performSelector:@selector(removeFromLayer:) withObject:imageView.layer afterDelay:1];
}
#pragma mark -移除
- (void)removeFromLayer:(CALayer *)layerAnimation{
[layerAnimation removeFromSuperlayer];
}
#pragma mark -动画完成
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
if ([self.delegate respondsToSelector:@selector(RefreshSceneAndProduct:)]) {
[self.delegate RefreshSceneAndProduct:self.isScene];
}
}
#pragma mark -友好界面
......@@ -792,15 +907,6 @@
#pragma mark -筛选条件
- (IBAction)ScreeningConditionsSelectedButtonClick:(UIButton *)sender {
......
......@@ -14,6 +14,14 @@
- (void)setModel:(SceneListModel *)model
{
[self.sceneImageView sd_setImageWithURL:[NSURL URLWithString:model.pricure] placeholderImage:REPLACEIMAGE];
if (model.isSelectedSate) {
self.layer.borderWidth = 2.0f;
self.layer.borderColor = kMainBlueColor.CGColor;
}else
{
self.layer.borderWidth = 0;
self.layer.borderColor = kMainBlueColor.CGColor;
}
}
@end
//
// sceneScreeningCollectionViewCell.h
// Lighting
//
// Created by 曹云霄 on 16/6/3.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface sceneScreeningCollectionViewCell : UICollectionViewCell
/**
* 选中场景图片
*/
@property (weak, nonatomic) IBOutlet UIImageView *selectedScrenImageView;
@end
//
// sceneScreeningCollectionViewCell.m
// Lighting
//
// Created by 曹云霄 on 16/6/3.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "sceneScreeningCollectionViewCell.h"
@implementation sceneScreeningCollectionViewCell
@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