//
// InfoSourceCell.m
// 物流派
//
// Created by wuliupai on 15-3-30.
// Copyright (c) 2015年 於明月. All rights reserved.
//
#import "InfoSourceCell.h"
#import "CommonDefine.h"
#import "UIViewExt.h"
@implementation InfoSourceCell
{
UIView *fullView;
BOOL leftState;
BOOL rightState;
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
leftState = NO;
rightState = NO;
[self P_subviews];
}
return self;
}
- (void)P_subviews
{
// 製作一個打電話按鈕
UIButton *btPhone = [[UIButton alloc]initWithFrame:CGRectMake(self.width-80, 0, 80, self.height*2)];
btPhone.backgroundColor = [kTabBarColor];
[btPhone setImage:[UIImage imageNamed:@"選擇框.png"] forState:UIControlStateNormal];
[btPhone addTarget:self action:@selector(takePhone:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:btPhone];
fullView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.width, self.height*2)];
fullView.backgroundColor = [UIColor whiteColor];
[self addSubview:fullView];
for (NSInteger i = 0; i<2; i++) {
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handlerSwipe:)];
swipe.direction = 1 << i;
[fullView addGestureRecognizer: swipe];
}
_carType = [[UILabel alloc]initWithFrame:CGRectMake(kScreen_width*320/640, kScreen_height*10/1136, kScreen_width*320/640, kScreen_height*60/1136)];
_carType.text = @"重貨 30方 車的類型";
_carType.alpha = 0.7;
_carType.font = [UIFont systemFontOfSize:16.0];
//_carType.textAlignment = UITextLayoutDirectionRight;
[fullView addSubview:_carType];
_dataLabel = [[UILabel alloc]initWithFrame:CGRectMake(kScreen_width*150/640, kScreen_height*110/1136, kScreen_width*420/640, kScreen_height*60/1136)];
_dataLabel.alpha = 0.5;
_dataLabel.font = [UIFont systemFontOfSize:14.0];
// _dataLabel.textAlignment = UITextLayoutDirectionRight;
_dataLabel.text = @"2000-13-14 34:34:90";
[fullView addSubview:_dataLabel];
_addressLabel = [[UILabel alloc]initWithFrame:CGRectMake(kScreen_width *150/640, kScreen_height*10/1136, kScreen_width*200/640, kScreen_height*60/1136)];
_addressLabel.font = [UIFont systemFontOfSize:16.0];
_addressLabel.text = @"開封一鄭州";
_addressLabel.alpha = 0.7;
_addressLabel.textColor = [kTabBarColor];
[fullView addSubview:_addressLabel];
_phoneLabel = [[UILabel alloc]initWithFrame:CGRectMake(kScreen_width*150/640, kScreen_height *60/1136, kScreen_width*250/640, kScreen_height*60/1136)];
_phoneLabel.text = @"張二鐵:已認證";
_phoneLabel.alpha = 0.6;
_phoneLabel.font = [UIFont systemFontOfSize:16.0];
[fullView addSubview:_phoneLabel];
// _approveLabel = [[UILabel alloc]initWithFrame:CGRectMake(kScreen_width *400/640, kScreen_height*60/1136, kScreen_width*200/640, kScreen_height*60/1136)];
// _approveLabel.text = @"是否認證";
// _approveLabel.alpha = 0.6;
// [self addSubview:_approveLabel];
// _phoneImage = [[UIImageView alloc]initWithFrame:CGRectMake(kScreen_width*150/640, kScreen_height*120/1136, kScreen_width*45/640, kScreen_width*45/640)];
// _phoneImage.image = [UIImage imageNamed:@"客服撥打電話.png"];
// [self addSubview:_phoneImage];
//
_bigImage = [[UIImageView alloc]initWithFrame:CGRectMake(kScreen_width*20/640, kScreen_height*30/1136, kScreen_width*120/640, kScreen_width*120/640)];
_bigImage.image = [UIImage imageNamed:@"頭像1.png"];
[fullView addSubview:_bigImage];
// _addressImage = [[UIImageView alloc]initWithFrame:CGRectMake(kScreen_width*150/640, kScreen_height *60/1136, kScreen_width*45/640, kScreen_width*45/640)];
// _addressImage.image = [UIImage imageNamed:@"方線框.png"];
// [self addSubview:_addressImage];
}
-(void)handlerSwipe:(UISwipeGestureRecognizer *)swipeGesture{
if(swipeGesture.direction==UISwipeGestureRecognizerDirectionLeft) {
NSLog(@"向左滑動");
if (!leftState) {
[UIView animateWithDuration:1.0 animations:^{
CGRect temp = fullView.frame;
temp.origin.x -= 80.0;
fullView.frame = temp;
} completion:^(BOOL finished) {
NSLog(@"向左滑動over...");
rightState = YES;
leftState = YES;
}];
}
}else if(swipeGesture.direction == UISwipeGestureRecognizerDirectionRight){
NSLog(@"向右滑動");
if (rightState) {
[UIView animateWithDuration:1.0 animations:^{
CGRect temp = fullView.frame;
temp.origin.x += 80.0;
fullView.frame = temp;
} completion:^(BOOL finished) {
NSLog(@"向右滑動over...");
rightState = NO;
leftState = NO;
}];
}
}else{
NSLog(@"出錯咯");
}
}
//後面的按鈕
-(void)takePhone:(UIButton *)button{
NSLog(@"take phone。。。");
}
@end