Skip to content

Commit

Permalink
Merge branch 'Dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Varun Santhanam committed Oct 12, 2017
2 parents 4d2b470 + 208fb38 commit 89d42d3
Show file tree
Hide file tree
Showing 45 changed files with 3,617 additions and 655 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added Release/VSAlert.framework/Modules/.DS_Store
Binary file not shown.
11 changes: 8 additions & 3 deletions Release/VSAlert.framework/Versions/A/Headers/VSAlertAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,22 @@ typedef NS_ENUM(NSInteger, VSAlertActionStyle) {
@property (NS_NONATOMIC_IOSONLY, strong, nonnull) UIFont *cancelActionTextFont UI_APPEARANCE_SELECTOR;

/**
@name Interacting With Actions
@name Interacting with Actions
*/

/**
The block that will be executed when the user interacts with the action. The block is called on the main thread always, and begins executed before the alert is dismissed
The title of the alert
*/
@property (NS_NONATOMIC_IOSONLY, copy, readonly, nullable) void (^action)(VSAlertAction * _Nonnull action);
@property (NS_NONATOMIC_IOSONLY, copy, readonly, nullable) NSString *alertTitle;

/**
The display style of the alert
*/
@property (NS_NONATOMIC_IOSONLY, assign, readonly) VSAlertActionStyle style;

/**
The block that will be executed when the user interacts with the action. The block is called on the main thread always, and begins executed before the alert is dismissed
*/
@property (NS_NONATOMIC_IOSONLY, copy, readonly, nullable) void (^action)(VSAlertAction * _Nonnull action);

@end
123 changes: 107 additions & 16 deletions Release/VSAlert.framework/Versions/A/Headers/VSAlertController.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,35 +48,72 @@ typedef NS_ENUM(NSInteger, VSAlertControllerStyle) {
/**
An enumeration describing the kinds of animations that can be used to present and hide an alert
- VSAlertControllerAnimationStyleRise: The alert rises from the bottom of the screen and falls down when dismissed
- VSAlertControllerAnimationStyleFall: The alert falls from the top of the screen and rises up when dismissed
- VSAlertControllerAnimationStyleSlide: The alert slides from the left of the screen and slides to the right when dismissed
- VSAlertControllerAnimationStyleRise: The alert rises from the bottom of the screen and falls down when dismissed.
- VSAlertControllerAnimationStyleFall: The alert falls from the top of the screen and rises up when dismissed.
- VSAlertControllerAnimationStyleSlide: The alert slides from the left of the screen and slides to the right when dismissed.
- VSAlertControllerAnimationStyleFlip: The alert flips from the right, and flips to the left when dismissed.
- VSAlertControllerAnimationStyleSticker: The alert page flips from the top, then again from the bottom when dismissed.
- VSAlertControllerAnimationStyleCrossDisolve: The alert page fades in, then fades out dismissed.
= VSAlertControllerAnimationStyleAutomatic: The alert chooses its presentation and dismissal styles automatically.
*/
typedef NS_ENUM(NSInteger, VSAlertControllerAnimationStyle) {

/**
The alert rises from the bottom of the screen and falls down when dismissed
The alert rises from the bottom of the screen and falls down when dismissed.
*/
VSAlertControllerAnimationStyleRise,

/**
The alert falls from the top of the screen and rises up when dismissed
The alert falls from the top of the screen and rises up when dismissed.
*/
VSAlertControllerAnimationStyleFall,

/**
The alert slides from the left of the screen and slides to the right when dismissed
The alert slides from the left of the screen and slides to the right when dismissed.
*/
VSAlertControllerAnimationStyleSlide,

/**
The alert flips from the right, and flips to the left when dismissed.
*/
VSAlertControllerAnimationStyleFlip
VSAlertControllerAnimationStyleFlip,

/**
The alert page flips from the top, then again from the bottom when dismissed.
*/
VSAlertControllerAnimationStyleSticker,

/**
The alert page fades in, then fades out dismissed.
*/
VSAlertControllerAnimationStyleCrossDisolve,

/**
The alert chooses its presentation and dismissal styles automatically.
*/
VSAlertControllerAnimationStyleAutomatic

};

@class VSAlertController;

/**
VSAlertControllerDelegate is a protocol used to inform an object about user intractions with alerts
*/
@protocol VSAlertControllerDelegate <NSObject>

@optional

/**
Sent to the delegate when the user taps on an action. Message is sent *before* the action block is executed.
@param alertController The alert controller that houses the action.
@param action The action that was interacted with.
*/
- (void)alertController:(nonnull VSAlertController *)alertController didSelectAction:(nonnull VSAlertAction *)action;

@end

/**
VSAlertController is a drop-in replacement for UIAlertController with more features. It is created using the +alertControllerWithTitle:description:image:style: class method, and configured using instances of VSAlertAction. You can add text fields by calling -addTextField: on an instance of VSAlertController. Instantiate the controller, add your actions and textfieds. and any other configuration you might need. Present the controller modally using UIViewController's -presentViewController:animated:completion: method. VSAlertController respects the animation paramater of this call, and you configure the animation in question by setting your instances animationStyle property before presentation. You can also change this property in the handler of an action to use a different animation on dismissal.
*/
Expand All @@ -90,22 +127,33 @@ typedef NS_ENUM(NSInteger, VSAlertControllerAnimationStyle) {
A factory method to create an instance of VSAlertController. This is the preffered way to instantiate alerts
@param title The title of the alert
@param description The description (message) of the alert
@param message The message of the alert
@param image The image to be displayed in the header of the alert.
@param style The style of the alert
@return The instantiated alert object
*/
+ (nullable instancetype)alertControllerWithTitle:(nullable NSString *)title description:(nullable NSString *)description image:(nullable UIImage *)image style:(VSAlertControllerStyle)style;
+ (nullable instancetype)alertControllerWithTitle:(nullable NSString *)title message:(nullable NSString *)message image:(nullable UIImage *)image style:(VSAlertControllerStyle)style;


/**
A factory method to create an instance of VSAlertController.
@param title The title of the alert
@param message The message of the alert
@param style The style of the alert
@return The instantiated alert object
*/
+ (nullable instancetype)alertControllerWithTitle:(nullable NSString *)title message:(nullable NSString *)message style:(VSAlertControllerStyle)style;

/** Create an instance of VSAlertController
@param title The title of the alert
@param description The description (message) of the alert
@param message The message of the alert
@param image The image to be displayed in the header of the alert.
@param style The style of the alert
@return The instantiated alert object
*/
- (nullable instancetype)initWithTitle:(nullable NSString *)title description:(nullable NSString *)description image:(nullable UIImage *)image style:(VSAlertControllerStyle)style NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithTitle:(nullable NSString *)title message:(nullable NSString *)message image:(nullable UIImage *)image style:(VSAlertControllerStyle)style NS_DESIGNATED_INITIALIZER;

/**
@name Configuring Alert Appearance
Expand All @@ -114,22 +162,22 @@ typedef NS_ENUM(NSInteger, VSAlertControllerAnimationStyle) {
/**
The color of the alert title. The default value is black.
*/
@property (NS_NONATOMIC_IOSONLY, strong, nonnull) UIColor *alertTitleTextColor UI_APPEARANCE_SELECTOR;
@property (NS_NONATOMIC_IOSONLY, strong, nonnull) UIColor *alertTitleTextColor; //UI_APPEARANCE_SELECTOR;

/**
The color of the alert message (description). The default value is black.
*/
@property (NS_NONATOMIC_IOSONLY, strong, nonnull) UIColor *alertDescriptionTextColor UI_APPEARANCE_SELECTOR;
@property (NS_NONATOMIC_IOSONLY, strong, nonnull) UIColor *alertMessageTextColor; //UI_APPEARANCE_SELECTOR;

/**
The font of the alert title. The default value is the system font size 17 weight medium.
*/
@property (NS_NONATOMIC_IOSONLY, strong, nonnull) UIFont *alertTitleTextFont UI_APPEARANCE_SELECTOR;
@property (NS_NONATOMIC_IOSONLY, strong, nonnull) UIFont *alertTitleTextFont; //UI_APPEARANCE_SELECTOR;

/**
The font of the alert message (description). The default value is the system font size 15 weight regular.
*/
@property (NS_NONATOMIC_IOSONLY, strong, nonnull) UIFont *alertDescriptionTextFont UI_APPEARANCE_SELECTOR;
@property (NS_NONATOMIC_IOSONLY, strong, nonnull) UIFont *alertMessageTextFont; //UI_APPEARANCE_SELECTOR;

/**
@name Configuring Interactive Alert Content
Expand Down Expand Up @@ -164,13 +212,56 @@ typedef NS_ENUM(NSInteger, VSAlertControllerAnimationStyle) {
@property (NS_NONATOMIC_IOSONLY, assign) VSAlertControllerAnimationStyle animationStyle;

/**
@name Interacting With Alerts
@name Interacting with Alerts
*/

/**
The delegate object to handle alert action interactions
*/
@property (weak, nullable) id<VSAlertControllerDelegate> delegate;

/**
Returns the array of text field objects that are displayed in the alert, so you can interact with the user's inputs.
*/
@property (NS_NONATOMIC_IOSONLY, strong, readonly, nonnull) NSArray<UITextField *> *textFields;

/**
The style of the alert
*/
@property (NS_NONATOMIC_IOSONLY, assign, readonly) VSAlertControllerStyle style;

/**
The message of the alert
*/
@property (NS_NONATOMIC_IOSONLY, copy, readonly, nonnull) NSString *message;

/**
The image of the alert
*/
@property (NS_NONATOMIC_IOSONLY, strong, readonly, nullable) UIImage *image;

/**
@name Customizing the Class Globally
*/

/**
Default title text color. Affects all instances instantiated after this change.
*/
@property (NS_NONATOMIC_IOSONLY, class, strong, nullable) UIColor *defaultTitleTextColor;

/**
Default description text color. Affects all instances instantiated after this change.
*/
@property (NS_NONATOMIC_IOSONLY, class, strong, nullable) UIColor *defaultMessageTextColor;

/**
Default title text font. Affects all instance instantiated after this change.
*/
@property (NS_NONATOMIC_IOSONLY, class, strong, nullable) UIFont *defaultTitleTextFont;

/**
Default description text font. Affects all instances instantiated after this change.
*/
@property (NS_NONATOMIC_IOSONLY, class, strong, nullable) UIFont *defaultMessageTextFont;

@end
Binary file modified Release/VSAlert.framework/Versions/A/VSAlert
Binary file not shown.
11 changes: 8 additions & 3 deletions VSAlert/VSAlertAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,22 @@ typedef NS_ENUM(NSInteger, VSAlertActionStyle) {
@property (NS_NONATOMIC_IOSONLY, strong, nonnull) UIFont *cancelActionTextFont UI_APPEARANCE_SELECTOR;

/**
@name Interacting With Actions
@name Interacting with Actions
*/

/**
The block that will be executed when the user interacts with the action. The block is called on the main thread always, and begins executed before the alert is dismissed
The title of the alert
*/
@property (NS_NONATOMIC_IOSONLY, copy, readonly, nullable) void (^action)(VSAlertAction * _Nonnull action);
@property (NS_NONATOMIC_IOSONLY, copy, readonly, nullable) NSString *alertTitle;

/**
The display style of the alert
*/
@property (NS_NONATOMIC_IOSONLY, assign, readonly) VSAlertActionStyle style;

/**
The block that will be executed when the user interacts with the action. The block is called on the main thread always, and begins executed before the alert is dismissed
*/
@property (NS_NONATOMIC_IOSONLY, copy, readonly, nullable) void (^action)(VSAlertAction * _Nonnull action);

@end
17 changes: 8 additions & 9 deletions VSAlert/VSAlertAction.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

@interface VSAlertAction ()

@property (NS_NONATOMIC_IOSONLY, strong) NSString *title;
@property (NS_NONATOMIC_IOSONLY, strong) UIImageView *separator;

// Redesignate initializers so you can call 'super'
Expand All @@ -25,11 +24,11 @@ @implementation VSAlertAction
@synthesize destructiveActionTextColor = _destructiveActionTextColor;
@synthesize actionTextFont = _actionTextFont;
@synthesize cancelActionTextFont = _cancelActionTextFont;
@synthesize alertTitle = _alertTitle;
@synthesize style = _style;
@synthesize action = _action;

// Explicitly syenthesize ivars from extension
@synthesize title = _title;
@synthesize separator = _separator;

#pragma mark - Public Class Methods
Expand All @@ -52,7 +51,7 @@ - (instancetype)initWithFrame:(CGRect)frame {

_style = VSAlertActionStyleDefault;
_action = nil;
_title = nil;
_alertTitle = @"";

[self _setUpAlertAction];

Expand All @@ -70,7 +69,7 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder {

_style = VSAlertActionStyleDefault;
_action = nil;
_title = nil;
_alertTitle = @"";

[self _setUpAlertAction];

Expand Down Expand Up @@ -114,7 +113,7 @@ - (void)setDestructiveActionTextColor:(UIColor * _Nonnull)destructiveActionTextC
if (self.style == VSAlertActionStyleDestructive) {

[self setTitleColor:self.destructiveActionTextColor forState:UIControlStateNormal];
[self setTitleColor:[self.destructiveActionTextColor colorWithAlphaComponent:0.5f] forState:UIControlStateNormal];
[self setTitleColor:[self.destructiveActionTextColor colorWithAlphaComponent:0.5f] forState:UIControlStateHighlighted];

}

Expand Down Expand Up @@ -163,10 +162,10 @@ - (instancetype)initWithTitle:(NSString *)title style:(VSAlertActionStyle)style
self = [super initWithFrame:CGRectZero];

if (self) {

_style = style;
_action = action;
_title = title;
_alertTitle = title;

[self _setUpAlertAction];

Expand All @@ -184,10 +183,10 @@ - (void)_setUpAlertAction {
_destructiveActionTextColor = [UIColor redColor];
_actionTextFont = [UIFont systemFontOfSize:17.0f weight:UIFontWeightRegular];

[self setTitle:self.title forState:UIControlStateNormal];
[self setTitle:self.alertTitle forState:UIControlStateNormal];

[self setTitleColor:self.style == VSAlertActionStyleDestructive ? _destructiveActionTextColor : _actionTextColor forState:UIControlStateNormal];
[self setTitleColor:self.state == VSAlertActionStyleDestructive ? [_destructiveActionTextColor colorWithAlphaComponent:0.5f] : [_actionTextColor colorWithAlphaComponent:0.5f] forState:UIControlStateHighlighted];
[self setTitleColor:self.style == VSAlertActionStyleDestructive ? [_destructiveActionTextColor colorWithAlphaComponent:0.5f] : [_actionTextColor colorWithAlphaComponent:0.5f] forState:UIControlStateHighlighted];

self.titleLabel.font = self.style == VSAlertActionStyleCancel ? [UIFont systemFontOfSize:17.0f weight:UIFontWeightSemibold] : _actionTextFont;

Expand Down
Loading

0 comments on commit 89d42d3

Please sign in to comment.