Skip to content

Commit

Permalink
Added the ability to change 'sticky' and 'shadow' from option.
Browse files Browse the repository at this point in the history
  • Loading branch information
taglia committed Feb 16, 2016
1 parent 4f88f5e commit 83e334a
Show file tree
Hide file tree
Showing 20 changed files with 660 additions and 167 deletions.
8 changes: 4 additions & 4 deletions ElasticTransistionExample/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
<color key="textColor" red="0.57088900840000001" green="0.66208174850000001" blue="0.76511205810000005" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="aFo-Vw-vSo">
<rect key="frame" x="223" y="4" width="51" height="31"/>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="aFo-Vw-vSo">
<rect key="frame" x="243" y="4" width="51" height="31"/>
<color key="onTintColor" red="0.94117647059999998" green="0.35294117650000001" blue="0.32549019610000002" alpha="1" colorSpace="calibratedRGB"/>
<connections>
<action selector="switchChanged:" destination="827-ga-1bX" eventType="valueChanged" id="b6R-0j-iLR"/>
Expand Down Expand Up @@ -65,7 +65,7 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="fIf-hN-1v3">
<rect key="frame" x="28" y="10" width="264" height="29"/>
<rect key="frame" x="28" y="11" width="264" height="29"/>
<segments>
<segment title="First"/>
<segment title="Second"/>
Expand All @@ -84,7 +84,7 @@
</subviews>
<constraints>
<constraint firstItem="fIf-hN-1v3" firstAttribute="leading" secondItem="M10-ri-d6c" secondAttribute="leadingMargin" constant="20" id="XaB-gA-YNW"/>
<constraint firstItem="fIf-hN-1v3" firstAttribute="top" secondItem="M10-ri-d6c" secondAttribute="topMargin" constant="2" id="Yht-8P-Chs"/>
<constraint firstItem="fIf-hN-1v3" firstAttribute="top" secondItem="M10-ri-d6c" secondAttribute="topMargin" constant="3" id="Yht-8P-Chs"/>
<constraint firstItem="ksf-TV-bpI" firstAttribute="leading" secondItem="M10-ri-d6c" secondAttribute="leadingMargin" constant="8" id="YxX-cc-zwU"/>
<constraint firstAttribute="trailingMargin" secondItem="ksf-TV-bpI" secondAttribute="trailing" constant="8" id="gEd-Cm-LiT"/>
<constraint firstAttribute="bottomMargin" secondItem="ksf-TV-bpI" secondAttribute="bottom" id="sao-2D-faN"/>
Expand Down
27 changes: 27 additions & 0 deletions ElasticTransistionExample/Cell/CellDimensionAndTypeDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// CellDimensionAndTypeDelegate.h
// ElasticTransitionExample
//
// Created by Tigielle on 16/02/16.
// Copyright © 2016 Matteo Tagliafico. All rights reserved.
//

#import <UIKit/UIKit.h>

typedef NS_ENUM(int, PropertyRelated){
STICKY,
SHADOW,
RADIUS
};

@protocol CellDimensionAndTypeDelegate

@required
@property (nonatomic) PropertyRelated type;
@property (nonatomic) CGFloat rowHeigth;
@property (nonatomic) NSString *name;

@optional
-(void)didChangeStateToOn:(BOOL)on;

@end
29 changes: 29 additions & 0 deletions ElasticTransistionExample/Cell/CellModel/SwitchCellModel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// SwitchCellModel.h
// ElasticTransitionExample
//
// Created by Tigielle on 16/02/16.
// Copyright © 2016 Matteo Tagliafico. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "CellDimensionAndTypeDelegate.h"

@protocol CellStateChange;

@interface SwitchCellModel : NSObject <CellDimensionAndTypeDelegate>

@property (nonatomic) BOOL on;
@property (nonatomic, weak) id<CellStateChange> delegate;

- (void)setSwitchOn:(BOOL)on;

@end


@protocol CellStateChange <NSObject>

@optional
-(void)didChangeStateToOn:(BOOL)on AndPropertyRelated:(PropertyRelated)property;

@end
42 changes: 42 additions & 0 deletions ElasticTransistionExample/Cell/CellModel/SwitchCellModel.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// SwitchCellModel.m
// ElasticTransitionExample
//
// Created by Tigielle on 16/02/16.
// Copyright © 2016 Matteo Tagliafico. All rights reserved.
//

#import "SwitchCellModel.h"

@implementation SwitchCellModel

@synthesize type, rowHeigth;
@synthesize name;

-(id)initWithName:(NSString*)aName AndOn:(BOOL)on{

self = [super init];

if(self){

self.rowHeigth = 54.0;
self.name = aName;
self.on = on;
}

return self;
}

- (void)setSwitchOn:(BOOL)on{

self.on = on;

id<CellStateChange> strongDelegate = self.delegate;

if([strongDelegate respondsToSelector:@selector(didChangeStateToOn:AndPropertyRelated:)]){

[strongDelegate didChangeStateToOn:on AndPropertyRelated:self.type];
}
}

@end
21 changes: 21 additions & 0 deletions ElasticTransistionExample/Cell/SegmentCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// SegmentCell.h
// ElasticTransitionExample
//
// Created by Tigielle on 16/02/16.
// Copyright © 2016 Matteo Tagliafico. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "CellDimensionAndTypeDelegate.h"

@interface SegmentCell : UITableViewCell <CellDimensionAndTypeDelegate>

@property (nonatomic) NSMutableArray *values;

@property (nonatomic, weak) IBOutlet UILabel *nameLabel;
@property (nonatomic, weak) IBOutlet UISegmentedControl *segment;

-(IBAction)segmentChanged:(UISegmentedControl*)sender;

@end
36 changes: 36 additions & 0 deletions ElasticTransistionExample/Cell/SegmentCell.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// SegmentCell.m
// ElasticTransitionExample
//
// Created by Tigielle on 16/02/16.
// Copyright © 2016 Matteo Tagliafico. All rights reserved.
//

#import "SegmentCell.h"

@implementation SegmentCell

@synthesize type, rowHeigth;

- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];

if (self) {

self.rowHeigth = 72.0;
}

return self;
}

-(void)onChangeValue:(id)value{

}

-(IBAction)segmentChanged:(UISegmentedControl*)sender{

[self onChangeValue:self.values[sender.selectedSegmentIndex]];
}

@end
19 changes: 19 additions & 0 deletions ElasticTransistionExample/Cell/SliderCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// SliderCell.h
// ElasticTransitionExample
//
// Created by Tigielle on 16/02/16.
// Copyright © 2016 Matteo Tagliafico. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "CellDimensionAndTypeDelegate.h"

@interface SliderCell : UITableViewCell <CellDimensionAndTypeDelegate>

@property (nonatomic, weak) IBOutlet UILabel *nameLabel;
@property (nonatomic, weak) IBOutlet UISlider *slider;

-(IBAction)sliderChanged:(UISlider*)sender;

@end
36 changes: 36 additions & 0 deletions ElasticTransistionExample/Cell/SliderCell.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// SliderCell.m
// ElasticTransitionExample
//
// Created by Tigielle on 16/02/16.
// Copyright © 2016 Matteo Tagliafico. All rights reserved.
//

#import "SliderCell.h"

@implementation SliderCell

@synthesize type, rowHeigth;

- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];

if (self) {

self.rowHeigth = 62.0;
}

return self;
}

-(IBAction)sliderChanged:(UISlider*)sender{

[self onChangeValue:sender.value];
}

-(void)onChangeValue:(CGFloat)value{

}

@end
20 changes: 20 additions & 0 deletions ElasticTransistionExample/Cell/SwitchCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// SwitchCell.h
// ElasticTransitionExample
//
// Created by Tigielle on 16/02/16.
// Copyright © 2016 Matteo Tagliafico. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "SwitchCellModel.h"

@interface SwitchCell : UITableViewCell

@property (nonatomic, weak) IBOutlet UILabel *nameLabel;
@property (nonatomic, weak) IBOutlet UISwitch *control;
@property (nonatomic, weak) SwitchCellModel *cellModel;

-(IBAction)switchChanged:(UISwitch*)sender;

@end
28 changes: 28 additions & 0 deletions ElasticTransistionExample/Cell/SwitchCell.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// SwitchCell.m
// ElasticTransitionExample
//
// Created by Tigielle on 16/02/16.
// Copyright © 2016 Matteo Tagliafico. All rights reserved.
//

#import "SwitchCell.h"

@implementation SwitchCell

@synthesize cellModel;

- (void)setCellModel:(SwitchCellModel *)aCellModel{

self->cellModel = aCellModel;

self.nameLabel.text = aCellModel.name;
[self.control setOn:aCellModel.on];
}

-(IBAction)switchChanged:(UISwitch*)sender{

[self.cellModel setSwitchOn:sender.on];
}

@end
3 changes: 2 additions & 1 deletion ElasticTransistionExample/InitialViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ - (void)viewDidLoad {

transition.sticky = YES;
transition.showShadow = YES;
transition.panThreshold = 0.3;
transition.panThreshold = 0.55;
transition.radiusFactor = 0.3;
transition.transformType = ROTATE;

//transition.overlayColor = [UIColor colorWithWhite:0 alpha:0.5];
Expand Down
31 changes: 0 additions & 31 deletions ElasticTransistionExample/OptionsViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,6 @@
#import <UIKit/UIKit.h>
#import "ElasticTransition.h"


@interface SwitchCell:UITableViewCell

@property (nonatomic, weak) IBOutlet UILabel *nameLabel;
@property (nonatomic, weak) IBOutlet UISwitch *control;

-(IBAction)switchChanged:(UISwitch*)sender;

@end

@interface SliderCell:UITableViewCell

@property (nonatomic, weak) IBOutlet UILabel *nameLabel;
@property (nonatomic, weak) IBOutlet UISlider *slider;

-(IBAction)sliderChanged:(UISlider*)sender;

@end

@interface SegmentCell:UITableViewCell

@property (nonatomic) NSMutableArray *values;

@property (nonatomic, weak) IBOutlet UILabel *nameLabel;
@property (nonatomic, weak) IBOutlet UISegmentedControl *segment;

-(IBAction)segmentChanged:(UISegmentedControl*)sender;

@end


@interface OptionsViewController : UIViewController <ElasticMenuTransitionDelegate, UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, weak) IBOutlet UITableView *tableView;
Expand Down
Loading

0 comments on commit 83e334a

Please sign in to comment.