Skip to content

Commit

Permalink
Add class method to get all existings LGAlertViews
Browse files Browse the repository at this point in the history
  • Loading branch information
Friend-LGA committed Nov 13, 2015
1 parent 1461769 commit 3f3b8ef
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Demo/LGAlertViewDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@
INFOPLIST_FILE = LGAlertViewDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.test.$(PRODUCT_NAME)";
PRODUCT_BUNDLE_IDENTIFIER = "com.test.LGAlertViewDemo-";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
};
Expand All @@ -350,7 +350,7 @@
INFOPLIST_FILE = LGAlertViewDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.test.$(PRODUCT_NAME)";
PRODUCT_BUNDLE_IDENTIFIER = "com.test.LGAlertViewDemo-";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
};
Expand Down
2 changes: 1 addition & 1 deletion LGAlertView.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = 'LGAlertView'
s.version = '2.0.7'
s.version = '2.0.8'
s.platform = :ios, '6.0'
s.license = 'MIT'
s.homepage = 'https://github.com/Friend-LGA/LGAlertView'
Expand Down
4 changes: 4 additions & 0 deletions LGAlertView/LGAlertView.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,12 @@ typedef NS_ENUM(NSUInteger, LGAlertViewWindowLevel)
- (void)forceDestructive;
- (void)forceActionAtIndex:(NSUInteger)index;

/** Set tint color globally for all LGAlertViews */
+ (void)setTintColor:(UIColor *)color;
/** Set colorful globally for all LGAlertViews */
+ (void)setColorful:(BOOL)colorful;
/** Get array of all existings LGAlertViews */
+ (NSArray *)getAlertViewsArray;

#pragma mark -

Expand Down
28 changes: 27 additions & 1 deletion LGAlertView/LGAlertView.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
static NSMutableArray *kLGAlertViewWindowsArray;
static UIColor *kLGAlertViewTintColor;
static BOOL kLGAlertViewColorful = YES;
static NSMutableArray *kLGAlertViewArray;

#pragma mark - Interface

Expand Down Expand Up @@ -823,6 +824,9 @@ - (void)setupDefaults
if (!kLGAlertViewWindowsArray)
kLGAlertViewWindowsArray = [NSMutableArray new];

if (!kLGAlertViewArray)
kLGAlertViewArray = [NSMutableArray new];

// -----

_buttonsEnabledArray = [NSMutableArray new];
Expand Down Expand Up @@ -1271,6 +1275,13 @@ - (void)setProgressViewProgressTintColor:(UIColor *)progressViewProgressTintColo
_userProgressViewProgressTintColor = YES;
}

- (BOOL)isShowing
{
return (_showing && _window.isKeyWindow && !_window.isHidden);
}

#pragma mark - Class methods

+ (void)setTintColor:(UIColor *)color
{
kLGAlertViewTintColor = color;
Expand All @@ -1281,6 +1292,14 @@ + (void)setColorful:(BOOL)colorful
kLGAlertViewColorful = colorful;
}

+ (NSArray *)getAlertViewsArray
{
if (!kLGAlertViewArray)
kLGAlertViewArray = [NSMutableArray new];

return kLGAlertViewArray;
}

#pragma mark -

- (void)setProgress:(float)progress progressLabelText:(NSString *)progressLabelText
Expand Down Expand Up @@ -1587,6 +1606,9 @@ - (void)showAnimated:(BOOL)animated hidden:(BOOL)hidden completionHandler:(void(

_showing = YES;

if (![kLGAlertViewArray containsObject:self])
[kLGAlertViewArray addObject:self];

// -----

[self addObservers];
Expand Down Expand Up @@ -1809,7 +1831,11 @@ - (void)dismissComplete

// -----

[kLGAlertViewWindowsArray removeObject:_window];
if ([kLGAlertViewWindowsArray containsObject:_window])
[kLGAlertViewWindowsArray removeObject:_window];

if ([kLGAlertViewArray containsObject:self])
[kLGAlertViewArray removeObject:self];

_view = nil;
_viewController = nil;
Expand Down

0 comments on commit 3f3b8ef

Please sign in to comment.