Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding buttonMenuChatType for showing chats available #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion VBFPopFlatButton/VBFPopFlatButtonClasses/VBFPopFlatButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ typedef NS_ENUM(NSInteger, FlatButtonType) {
buttonRewindType,
buttonFastForwardType,
buttonSquareType,
buttonMenuChatType,
};

typedef NS_ENUM(NSInteger, FlatButtonStyle) {
Expand Down Expand Up @@ -68,4 +69,4 @@ typedef NS_ENUM(NSInteger, FlatButtonStyle) {
- (UIColor *)tintColorForState:(UIControlState)state;
- (void)animateToType:(FlatButtonType)finalType;

@end
@end
34 changes: 27 additions & 7 deletions VBFPopFlatButton/VBFPopFlatButtonClasses/VBFPopFlatButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ @interface VBFPopFlatButton () {
@property (nonatomic, strong) VBFDoubleSegment *firstSegment;
@property (nonatomic, strong) VBFDoubleSegment *secondSegment;
@property (nonatomic, strong) VBFDoubleSegment *thirdSegment; //Only used for menu button
@property (nonatomic, strong) VBFDoubleSegment *fourthSegment;
@property (nonatomic, strong) CALayer *bckgLayer;
@property (nonatomic) BOOL animateToStartPosition;
@end
Expand Down Expand Up @@ -79,6 +80,10 @@ - (void) commonSetup {
_thirdSegment.opacity = 0.0;
[self.layer addSublayer:_thirdSegment];

_fourthSegment = [[VBFDoubleSegment alloc]initWithLength:self.frame.size.width/2 thickness:self.frame.size.width/2 radius:50 color:[UIColor colorWithRed:0.971622 green:0.0655261 blue:0.316449 alpha:1] initialState:doubleSegmentMinusState];
_fourthSegment.opacity = 0.0;
[self.layer addSublayer:_fourthSegment];

if (self.currentButtonStyle == buttonRoundedStyle) {
[self setupBackgroundLayer];
}
Expand All @@ -92,7 +97,7 @@ - (void)setupBackgroundLayer {
self.bckgLayer.frame = CGRectInset(self.bounds, -amount, -amount);
self.bckgLayer.cornerRadius = self.bckgLayer.bounds.size.width/2;
self.bckgLayer.backgroundColor = self.roundBackgroundColor.CGColor;

[self.layer insertSublayer:self.bckgLayer below:_firstSegment];
}

Expand Down Expand Up @@ -192,10 +197,12 @@ - (void)animateToType:(FlatButtonType)finalType {
self.firstSegment.opacity = 1.0f;
self.secondSegment.opacity = 1.0f;
self.thirdSegment.opacity = 0.0f;
self.fourthSegment.opacity = 0.0f;
CGPoint firstOriginPoint = CGPointMake(CGRectGetWidth(self.frame)/2,
CGRectGetHeight(self.frame)/2);
CGPoint secondOriginPoint = firstOriginPoint;
CGPoint thirdOriginPoint = firstOriginPoint;
CGPoint fourthOriginPoint = firstOriginPoint;

switch (finalType) {
case buttonAddType:
Expand Down Expand Up @@ -262,7 +269,7 @@ - (void)animateToType:(FlatButtonType)finalType {
[self.firstSegment moveToState:doubleSegmentDownArrow animated:self.animateToStartPosition];
[self.secondSegment moveToState:doubleSegmentDownArrow animated:self.animateToStartPosition];
self.secondSegment.opacity = 0.0;

firstOriginPoint.y += CGRectGetHeight(self.firstSegment.frame)/5;
break;
case buttonDownArrowType:
Expand All @@ -274,7 +281,7 @@ - (void)animateToType:(FlatButtonType)finalType {
[self.firstSegment moveToState:doubleSegmentUpArrow animated:self.animateToStartPosition];
[self.secondSegment moveToState:doubleSegmentUpArrow animated:self.animateToStartPosition];
self.secondSegment.opacity = 0.0;

firstOriginPoint.y -= CGRectGetHeight(self.firstSegment.frame)/5;
break;
case buttonPausedType:
Expand Down Expand Up @@ -359,16 +366,29 @@ - (void)animateToType:(FlatButtonType)finalType {
firstOriginPoint.x -= offsetAmount;
secondOriginPoint.x += offsetAmount;
break;


case buttonMenuChatType:
self.thirdSegment.opacity = 1.0;
[self.firstSegment moveToState:doubleSegmentMinusState animated:self.animateToStartPosition];
[self.secondSegment moveToState:doubleSegmentMinusState animated:self.animateToStartPosition];
[self.thirdSegment moveToState:doubleSegmentMinusState animated:self.animateToStartPosition];
[self.fourthSegment moveToState:doubleSegmentMinusState animated:self.animateToStartPosition];

CGFloat verticalChatAmount = CGRectGetHeight(self.frame)/3;
fourthOriginPoint.y = self.frame.size.width/4;
fourthOriginPoint.x = self.frame.size.width/4*3;
thirdOriginPoint.y -= verticalChatAmount;
secondOriginPoint.y += verticalChatAmount;
self.fourthSegment.opacity = 1.0;
break;

default:
break;
}

[self.firstSegment movePositionToPoint:firstOriginPoint animated:self.animateToStartPosition];
[self.secondSegment movePositionToPoint:secondOriginPoint animated:self.animateToStartPosition];
[self.thirdSegment movePositionToPoint:thirdOriginPoint animated:self.animateToStartPosition];

[self.fourthSegment movePositionToPoint:fourthOriginPoint animated:self.animateToStartPosition];
if (!self.animateToStartPosition) {
//Setting that line makes sure the above code is only NOT animated first time
self.animateToStartPosition = YES;
Expand All @@ -392,4 +412,4 @@ - (UIColor *)linesColor {
return self.tintColor;
}

@end
@end