Skip to content
Browse files

Made Close Button more general

  • Loading branch information...
1 parent 91a3276 commit a3f98fb5097bd6bdbd6f4b50808ef3e107d1c0e1 @stigi stigi committed
View
BIN SoundCloud.bundle/close@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN SoundCloud.bundle/reload.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN SoundCloud.bundle/reload@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
6 SoundCloudAPI.xcodeproj/project.pbxproj
@@ -105,7 +105,7 @@
9429A5D9122659D500D31807 /* SCSoundCloudAPIConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SCSoundCloudAPIConfiguration.m; sourceTree = "<group>"; };
9429A5F512265A4A00D31807 /* NSString+SoundCloudAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+SoundCloudAPI.h"; sourceTree = "<group>"; };
9429A5F612265A4A00D31807 /* NSString+SoundCloudAPI.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+SoundCloudAPI.m"; sourceTree = "<group>"; };
- 94535F86123FAFDF00BD668A /* SoundCloudAPI.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SoundCloudAPI.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+ 94535F86123FAFDF00BD668A /* SoundCloudAPI */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.framework; path = SoundCloudAPI; sourceTree = BUILT_PRODUCTS_DIR; };
94535F87123FAFDF00BD668A /* SoundCloudAPI.framework-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SoundCloudAPI.framework-Info.plist"; sourceTree = "<group>"; };
945481201248C4C300E6BD3D /* SCAudioStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCAudioStream.h; sourceTree = "<group>"; };
945481211248C4C300E6BD3D /* SCAudioStream.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SCAudioStream.m; sourceTree = "<group>"; };
@@ -157,7 +157,7 @@
isa = PBXGroup;
children = (
D2AAC07E0554694100DB518D /* libSoundCloudAPI.a */,
- 94535F86123FAFDF00BD668A /* SoundCloudAPI.framework */,
+ 94535F86123FAFDF00BD668A /* SoundCloudAPI */,
);
name = Products;
sourceTree = "<group>";
@@ -336,7 +336,7 @@
);
name = SoundCloudAPI.framework;
productName = SoundCloudAPI.framework;
- productReference = 94535F86123FAFDF00BD668A /* SoundCloudAPI.framework */;
+ productReference = 94535F86123FAFDF00BD668A /* SoundCloudAPI */;
productType = "com.apple.product-type.framework";
};
D2AAC07D0554694100DB518D /* SoundCloudAPI */ = {
View
13 Sources/SoundCloudAPI/SCLoginViewController.h
@@ -25,16 +25,23 @@
NSInteger numberOfSections;
NSInteger currentSection;
- UIButton *closeButton;
- BOOL closeButtonHidden;
+ UIButton *titleBarButton;
+ BOOL showReloadButton;
}
- (id)initWithURL:(NSURL *)anURL authentication:(SCSoundCloudAPIAuthentication *)authentication;
-@property (nonatomic, assign, getter=isCloseButtonHidden) BOOL closeButtonHidden; // default = NO
+/*
+ * Replaces the close ('X') button in the top bar with a reload button
+ * Default - NO
+ */
+@property (nonatomic,assign) BOOL showReloadButton;
- (void)updateInterface:(BOOL)animated;
+- (IBAction)close;
+- (IBAction)reload;
+
@end
#endif
View
62 Sources/SoundCloudAPI/SCLoginViewController.m
@@ -24,7 +24,6 @@ @interface SCLoginSectionBar : UIControl {
@interface SCLoginViewController ()
- (void)sectionAnimationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context;
-- (IBAction)close;
- (IBAction)didSelectSectionbar:(SCLoginSectionBar *)sectionBar;
@end
@@ -44,7 +43,7 @@ - (id)initWithURL:(NSURL *)anURL authentication:(SCSoundCloudAPIAuthentication *
numberOfSections = 1;
currentSection = 0;
- closeButtonHidden = NO;
+ showReloadButton = NO;
if ([self respondsToSelector:@selector(setModalPresentationStyle:)]){
[self setModalPresentationStyle:UIModalPresentationFormSheet];
@@ -65,7 +64,7 @@ - (id)initWithURL:(NSURL *)anURL authentication:(SCSoundCloudAPIAuthentication *
- (void)dealloc;
{
- [closeButton release];
+ [titleBarButton release];
[resourceBundle release];
[titleBarView release];
[authentication release];
@@ -79,17 +78,12 @@ - (void)dealloc;
#pragma mark Accessors
-@dynamic closeButtonHidden;
-
-- (BOOL)closeButtonHidden;
-{
- return closeButtonHidden;
-}
+@synthesize showReloadButton;
-- (void)setCloseButtonHidden:(BOOL)value;
+- (void)setShowReloadButton:(BOOL)value;
{
- closeButtonHidden = value;
- closeButton.hidden = closeButtonHidden;
+ showReloadButton = value;
+ [self updateInterface:NO];
}
@@ -131,16 +125,15 @@ - (void)viewDidLoad;
[titleBarView addSubview:titleImageView];
[titleImageView release];
- closeButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
- closeButton.frame = closeRect;
- closeButton.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin);
- closeButton.showsTouchWhenHighlighted = YES;
- [closeButton addTarget:self action:@selector(close) forControlEvents:UIControlEventTouchUpInside];
+ titleBarButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
+ titleBarButton.frame = closeRect;
+ titleBarButton.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin);
+ titleBarButton.showsTouchWhenHighlighted = YES;
+ [titleBarButton addTarget:self action:@selector(close) forControlEvents:UIControlEventTouchUpInside];
UIImage *closeImage = [UIImage imageWithContentsOfFile:[resourceBundle pathForResource:@"close" ofType:@"png"]];
- [closeButton setImage:closeImage forState:UIControlStateNormal];
- closeButton.imageView.contentMode = UIViewContentModeCenter;
- closeButton.hidden = closeButtonHidden;
- [titleBarView addSubview:closeButton];
+ [titleBarButton setImage:closeImage forState:UIControlStateNormal];
+ titleBarButton.imageView.contentMode = UIViewContentModeCenter;
+ [titleBarView addSubview:titleBarButton];
activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
activityIndicator.center = CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds));
@@ -251,6 +244,17 @@ - (void)updateInterface:(BOOL)animated;
}
bar.userInteractionEnabled = !animated; //We don't want no userInteraction during the animation
}
+
+ [titleBarButton removeTarget:nil action:NULL forControlEvents:UIControlEventAllEvents];
+ if (!showReloadButton) {
+ [titleBarButton addTarget:self action:@selector(close) forControlEvents:UIControlEventTouchUpInside];
+ UIImage *closeImage = [UIImage imageWithContentsOfFile:[resourceBundle pathForResource:@"close" ofType:@"png"]];
+ [titleBarButton setImage:closeImage forState:UIControlStateNormal];
+ } else {
+ [titleBarButton addTarget:self action:@selector(reload) forControlEvents:UIControlEventTouchUpInside];
+ UIImage *reloadImage = [UIImage imageWithContentsOfFile:[resourceBundle pathForResource:@"reload" ofType:@"png"]];
+ [titleBarButton setImage:reloadImage forState:UIControlStateNormal];
+ }
if (animated) {
[UIView commitAnimations];
}
@@ -297,12 +301,17 @@ - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)
hasBeenHandled = [authentication handleRedirectURL:request.URL];
if (hasBeenHandled) {
[self close];
- return NO;
}
+ return NO;
}
}
- return YES;
+ if (![[request.URL absoluteString] hasPrefix:[authentication.configuration.authURL absoluteString]]) {
+ [[UIApplication sharedApplication] openURL:request.URL];
+ return NO;
+ }
+
+ return YES;
}
#pragma mark Private
@@ -312,6 +321,13 @@ - (IBAction)close;
[authentication performSelector:@selector(dismissLoginViewController:) withObject:self];
}
+- (IBAction)reload;
+{
+ for (UIWebView *webView in webViews) {
+ [webView reload];
+ }
+}
+
- (IBAction)didSelectSectionbar:(SCLoginSectionBar *)sectionBar;
{
currentSection = [sectionBars indexOfObject:sectionBar];

0 comments on commit a3f98fb

Please sign in to comment.
Something went wrong with that request. Please try again.