Skip to content

Commit

Permalink
Added Youtube, Vimeo buttons; Fixed critical bug when pressed button …
Browse files Browse the repository at this point in the history
…is defined incorrectly, because of incorrect tag implementation (Some methods were refactored, removed)
  • Loading branch information
mixdesign committed Dec 18, 2013
1 parent de55f4e commit 88c4218
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 53 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions AAShareBubbles/AAShareBubbles.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@protocol AAShareBubblesDelegate;

typedef enum {
typedef enum AAShareBubbleType : int {
AAShareBubbleTypeFacebook = 0,
AAShareBubbleTypeTwitter = 1,
AAShareBubbleTypeGooglePlus = 2,
Expand All @@ -20,16 +20,12 @@ typedef enum {
AAShareBubbleTypeVk = 5, // Vkontakte (vk.com)
AAShareBubbleTypeLinkedIn = 6,
AAShareBubbleTypePinterest = 7,
AAShareBubbleTypeYoutube = 8,
AAShareBubbleTypeVimeo = 9,

} AAShareBubbleType;

@interface AAShareBubbles : UIView
{
NSMutableArray *bubbles;

// Local
UIView *bgView;
}
@interface AAShareBubbles : UIView {}

@property (nonatomic, assign) id<AAShareBubblesDelegate> delegate;

Expand All @@ -41,6 +37,8 @@ typedef enum {
@property (nonatomic, assign) BOOL showVkBubble;
@property (nonatomic, assign) BOOL showLinkedInBubble;
@property (nonatomic, assign) BOOL showPinterestBubble;
@property (nonatomic, assign) BOOL showYoutubeBubble;
@property (nonatomic, assign) BOOL showVimeoBubble;

@property (nonatomic, assign) int radius;
@property (nonatomic, assign) int bubbleRadius;
Expand All @@ -55,6 +53,8 @@ typedef enum {
@property (nonatomic, assign) int vkBackgroundColorRGB;
@property (nonatomic, assign) int linkedInBackgroundColorRGB;
@property (nonatomic, assign) int pinterestBackgroundColorRGB;
@property (nonatomic, assign) int youtubeBackgroundColorRGB;
@property (nonatomic, assign) int vimeoBackgroundColorRGB;

-(id)initWithPoint:(CGPoint)point radius:(int)radiusValue inView:(UIView *)inView;

Expand Down
73 changes: 30 additions & 43 deletions AAShareBubbles/AAShareBubbles.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ @interface AAShareBubbles()
@end

@implementation AAShareBubbles
{
NSMutableArray *bubbles;
NSMutableDictionary *bubbleIndexTypes;

UIView *bgView;
}

@synthesize delegate = _delegate, parentView;

Expand All @@ -33,15 +39,18 @@ - (id)initWithPoint:(CGPoint)point radius:(int)radiusValue inView:(UIView *)inVi
self.vkBackgroundColorRGB = 0x4a74a5;
self.linkedInBackgroundColorRGB = 0x008dd2;
self.pinterestBackgroundColorRGB = 0xb61d23;
self.youtubeBackgroundColorRGB = 0xce3025;
self.vimeoBackgroundColorRGB = 0x00acf2;
}
return self;
}

#pragma mark -
#pragma mark Actions

-(void)buttonWasTapped:(UIButton *)sender{
[self shareButtonTappedWithType:sender.tag];
-(void)buttonWasTapped:(UIButton *)button {
AAShareBubbleType buttonType = [[bubbleIndexTypes objectForKey:[NSNumber numberWithInteger:button.tag]] intValue];
[self shareButtonTappedWithType:buttonType];
}

-(void)shareButtonTappedWithType:(AAShareBubbleType)buttonType {
Expand Down Expand Up @@ -72,39 +81,20 @@ -(void)show
if(bubbles) {
bubbles = nil;
}

bubbles = [[NSMutableArray alloc] init];
if(self.showFacebookBubble) {
UIButton *facebookBubble = [self shareButtonWithIcon:@"icon-aa-facebook.png" backgroundColor:self.facebookBackgroundColorRGB andSite:AAShareBubbleTypeFacebook];
[self addButtonToSubview:facebookBubble];
}
if(self.showTwitterBubble) {
UIButton *twitterBubble = [self shareButtonWithIcon:@"icon-aa-twitter.png" backgroundColor:self.twitterBackgroundColorRGB andSite:AAShareBubbleTypeTwitter];
[self addButtonToSubview:twitterBubble];
}
if(self.showGooglePlusBubble) {
UIButton *googlePlusBubble = [self shareButtonWithIcon:@"icon-aa-googleplus.png" backgroundColor:self.googlePlusBackgroundColorRGB andSite:AAShareBubbleTypeGooglePlus];
[self addButtonToSubview:googlePlusBubble];
}
if(self.showTumblrBubble) {
UIButton *tumblrBubble = [self shareButtonWithIcon:@"icon-aa-tumblr.png" backgroundColor:self.tumblrBackgroundColorRGB andSite:AAShareBubbleTypeTumblr];
[self addButtonToSubview:tumblrBubble];
}
if(self.showMailBubble) {
UIButton *mailBubble = [self shareButtonWithIcon:@"icon-aa-at.png" backgroundColor:self.mailBackgroundColorRGB andSite:AAShareBubbleTypeMail];
[self addButtonToSubview:mailBubble];
}
if(self.showVkBubble) {
UIButton *vkBubble = [self shareButtonWithIcon:@"icon-aa-vk.png" backgroundColor:self.vkBackgroundColorRGB andSite:AAShareBubbleTypeVk];
[self addButtonToSubview:vkBubble];
}
if(self.showLinkedInBubble) {
UIButton *linkedInBubble = [self shareButtonWithIcon:@"icon-aa-linkedin.png" backgroundColor:self.linkedInBackgroundColorRGB andSite:AAShareBubbleTypeLinkedIn];
[self addButtonToSubview:linkedInBubble];
}
if(self.showPinterestBubble) {
UIButton *pinterestBubble = [self shareButtonWithIcon:@"icon-aa-pinterest.png" backgroundColor:self.pinterestBackgroundColorRGB andSite:AAShareBubbleTypePinterest];
[self addButtonToSubview:pinterestBubble];
}
bubbleIndexTypes = [[NSMutableDictionary alloc] init];

if(self.showFacebookBubble) [self createButtonWithIcon:@"icon-aa-facebook.png" backgroundColor:self.facebookBackgroundColorRGB andType:AAShareBubbleTypeFacebook];
if(self.showTwitterBubble) [self createButtonWithIcon:@"icon-aa-twitter.png" backgroundColor:self.twitterBackgroundColorRGB andType:AAShareBubbleTypeTwitter];
if(self.showGooglePlusBubble) [self createButtonWithIcon:@"icon-aa-googleplus.png" backgroundColor:self.googlePlusBackgroundColorRGB andType:AAShareBubbleTypeGooglePlus];
if(self.showTumblrBubble) [self createButtonWithIcon:@"icon-aa-tumblr.png" backgroundColor:self.tumblrBackgroundColorRGB andType:AAShareBubbleTypeTumblr];
if(self.showMailBubble) [self createButtonWithIcon:@"icon-aa-at.png" backgroundColor:self.mailBackgroundColorRGB andType:AAShareBubbleTypeMail];
if(self.showVkBubble) [self createButtonWithIcon:@"icon-aa-vk.png" backgroundColor:self.vkBackgroundColorRGB andType:AAShareBubbleTypeVk];
if(self.showLinkedInBubble) [self createButtonWithIcon:@"icon-aa-linkedin.png" backgroundColor:self.linkedInBackgroundColorRGB andType:AAShareBubbleTypeLinkedIn];
if(self.showPinterestBubble) [self createButtonWithIcon:@"icon-aa-pinterest.png" backgroundColor:self.pinterestBackgroundColorRGB andType:AAShareBubbleTypePinterest];
if(self.showYoutubeBubble) [self createButtonWithIcon:@"icon-aa-youtube.png" backgroundColor:self.youtubeBackgroundColorRGB andType:AAShareBubbleTypeYoutube];
if(self.showVimeoBubble) [self createButtonWithIcon:@"icon-aa-vimeo.png" backgroundColor:self.vimeoBackgroundColorRGB andType:AAShareBubbleTypeVimeo];

if(bubbles.count == 0) return;

Expand Down Expand Up @@ -216,11 +206,11 @@ -(void)hideBubbleWithAnimation:(UIButton *)bubble
}];
}

-(UIButton *)shareButtonWithIcon:(NSString *)iconName backgroundColor:(int)rgb andSite:(NSInteger)site
-(void)createButtonWithIcon:(NSString *)iconName backgroundColor:(int)rgb andType:(AAShareBubbleType)type
{
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button addTarget:self action:@selector(buttonWasTapped:) forControlEvents:UIControlEventTouchUpInside];
button.frame = CGRectMake(0, 0, 2 * self.bubbleRadius, 2 * self.bubbleRadius);
button.tag = site;

// Circle background
UIView *circle = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 2 * self.bubbleRadius, 2 * self.bubbleRadius)];
Expand All @@ -240,7 +230,10 @@ -(UIButton *)shareButtonWithIcon:(NSString *)iconName backgroundColor:(int)rgb a

[button setBackgroundImage:[self imageWithView:circle] forState:UIControlStateNormal];

return button;
[bubbles addObject:button];
[bubbleIndexTypes setObject:[NSNumber numberWithInteger:type] forKey:[NSNumber numberWithInteger:(bubbles.count - 1)]];

[self addSubview:button];
}

-(UIColor *)colorFromRGB:(int)rgb {
Expand All @@ -256,10 +249,4 @@ -(UIImage *)imageWithView:(UIView *)view
return img;
}

-(void)addButtonToSubview:(UIButton *)button
{
[button addTarget:self action:@selector(buttonWasTapped:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:button];
[bubbles addObject:button];
}
@end
8 changes: 8 additions & 0 deletions Demo/AAShareBubbles/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ - (IBAction)shareTapped:(id)sender
shareBubbles.showTumblrBubble = YES;
shareBubbles.showVkBubble = YES;
shareBubbles.showLinkedInBubble = YES;
shareBubbles.showYoutubeBubble = YES;
shareBubbles.showVimeoBubble = YES;
[shareBubbles show];
}

Expand Down Expand Up @@ -81,6 +83,12 @@ -(void)aaShareBubbles:(AAShareBubbles *)shareBubbles tappedBubbleWithType:(AASha
case AAShareBubbleTypeLinkedIn:
NSLog(@"LinkedIn");
break;
case AAShareBubbleTypeYoutube:
NSLog(@"Youtube");
break;
case AAShareBubbleTypeVimeo:
NSLog(@"Vimeo");
break;
default:
break;
}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ Intro
==============

Animated Social share buttons control.<br>
Supported share buttons:<br><b>Facebook</b>, <b>Twitter</b>, <b>Google+</b>, <b>Tumblr</b>, <b>Vkontakte (vk.com)</b>, <b>LinkedIn</b>, <b>Pinterest</b>, <b>E-mail</b>
Supported share buttons:<br><b>Facebook</b>, <b>Twitter</b>, <b>Google+</b>, <b>Tumblr</b>, <b>Vkontakte (vk.com)</b>, <b>LinkedIn</b>, <b>Pinterest</b>, <b>Youtube</b>, <b>Vimeo</b>, <b>E-mail</b>

<img src="http://mixdesign.kz/external/AAShareBubblesAbay.png?tmp"/>&nbsp;&nbsp;
<img src="http://mixdesign.kz/external/AAShareBubbles.png?2"/>
<img src="http://mixdesign.kz/external/AAShareBubbles.png?3"/>

Installation
------
Expand Down

0 comments on commit 88c4218

Please sign in to comment.