Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
M B. Bitar committed Jan 15, 2013
1 parent 128ebab commit d1261b9
Show file tree
Hide file tree
Showing 38 changed files with 2,291 additions and 1 deletion.
382 changes: 382 additions & 0 deletions AlertsDemo/AlertsDemo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges</key>
<true/>
<key>SnapshotAutomaticallyBeforeSignificantChanges</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0450"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "04E09F9F16A5D7B3008764C0"
BuildableName = "AlertsDemo.app"
BlueprintName = "AlertsDemo"
ReferencedContainer = "container:AlertsDemo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "04E09F9F16A5D7B3008764C0"
BuildableName = "AlertsDemo.app"
BlueprintName = "AlertsDemo"
ReferencedContainer = "container:AlertsDemo.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "04E09F9F16A5D7B3008764C0"
BuildableName = "AlertsDemo.app"
BlueprintName = "AlertsDemo"
ReferencedContainer = "container:AlertsDemo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "04E09F9F16A5D7B3008764C0"
BuildableName = "AlertsDemo.app"
BlueprintName = "AlertsDemo"
ReferencedContainer = "container:AlertsDemo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>AlertsDemo.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>04E09F9F16A5D7B3008764C0</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
38 changes: 38 additions & 0 deletions AlertsDemo/AlertsDemo/AlertsDemo-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.progenius.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
14 changes: 14 additions & 0 deletions AlertsDemo/AlertsDemo/AlertsDemo-Prefix.pch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Prefix header for all source files of the 'AlertsDemo' target in the 'AlertsDemo' project
//

#import <Availability.h>

#ifndef __IPHONE_3_0
#warning "This project uses features only available in iOS SDK 3.0 and later."
#endif

#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
Binary file added AlertsDemo/AlertsDemo/Default-568h@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AlertsDemo/AlertsDemo/Default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AlertsDemo/AlertsDemo/Default@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions AlertsDemo/AlertsDemo/MBAppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// MBAppDelegate.h
// AlertsDemo
//
// Created by M B. Bitar on 1/15/13.
// Copyright (c) 2013 progenius, inc. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface MBAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end
95 changes: 95 additions & 0 deletions AlertsDemo/AlertsDemo/MBAppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
//
// MBAppDelegate.m
// AlertsDemo
//
// Created by M B. Bitar on 1/15/13.
// Copyright (c) 2013 progenius, inc. All rights reserved.
//

#import "MBAppDelegate.h"
#import "MBHUDView.h"

@implementation MBAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];

UIViewController *controller = [UIViewController new];
self.window.rootViewController = controller;

[MBHUDView hudWithBody:@"Hello" type:MBAlertViewHUDTypeCheckmark hidesAfter:1.0 show:YES];
MBAlertView *alert = [MBAlertView alertWithBody:@"Do you want to see more? (Note: you don't have a choice)" cancelTitle:nil cancelBlock:nil];
[alert addButtonWithText:@"Yes" type:MBAlertViewItemTypePositive block:^{
[MBHUDView hudWithBody:@"Say please" type:MBAlertViewHUDTypeExclamationMark hidesAfter:1.5 show:YES];
MBAlertView *please = [MBAlertView alertWithBody:@"Did you say please?" cancelTitle:nil cancelBlock:nil];
please.size = CGSizeMake(280, 180);
[please addButtonWithText:@"Yes" type:MBAlertViewItemTypePositive block:^{

[MBHUDView hudWithBody:@"Good boy." type:MBAlertViewHUDTypeCheckmark hidesAfter:1.0 show:YES];
[MBHUDView hudWithBody:@"Wait." type:MBAlertViewHUDTypeActivityIndicator hidesAfter:4.0 show:YES];
[MBHUDView hudWithBody:@"Ready?" type:MBAlertViewHUDTypeDefault hidesAfter:2.0 show:YES];

MBAlertView *destruct = [MBAlertView alertWithBody:@"Do you want your device to self-destruct?" cancelTitle:nil cancelBlock:nil];
destruct.imageView.image = [UIImage imageNamed:@"image.png"];
[destruct addButtonWithText:@"Yes please" type:MBAlertViewItemTypeDestructive block:^{
[MBHUDView hudWithBody:@"Ok" type:MBAlertViewHUDTypeCheckmark hidesAfter:1.0 show:YES];
[MBHUDView hudWithBody:@"5" type:MBAlertViewHUDTypeDefault hidesAfter:1.0 show:YES];
[MBHUDView hudWithBody:@"4" type:MBAlertViewHUDTypeDefault hidesAfter:1.0 show:YES];
[MBHUDView hudWithBody:@"3" type:MBAlertViewHUDTypeDefault hidesAfter:1.0 show:YES];
[MBHUDView hudWithBody:@"2" type:MBAlertViewHUDTypeDefault hidesAfter:1.0 show:YES];
[MBHUDView hudWithBody:@"1" type:MBAlertViewHUDTypeDefault hidesAfter:2.0 show:YES];
[self doSomething:^{
MBHUDView *hud = [MBHUDView hudWithBody:@"Goodbye" type:MBAlertViewHUDTypeExclamationMark hidesAfter:2.0 show:YES];
hud.uponDismissalBlock = ^{
[UIView animateWithDuration:0.5 animations:^{ [controller.view setBackgroundColor:[UIColor blackColor]]; }];
};
} afterDelay:2.0];
}];
[destruct addToDisplayQueue];

}];
[please addToDisplayQueue];
}];
[alert addToDisplayQueue];
return YES;
}

-(void)doSomething:(id)block afterDelay:(float)delay
{
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
((void (^)())block)();
});
}

- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
2 changes: 2 additions & 0 deletions AlertsDemo/AlertsDemo/en.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

Binary file added AlertsDemo/AlertsDemo/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions AlertsDemo/AlertsDemo/main.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// main.m
// AlertsDemo
//
// Created by M B. Bitar on 1/15/13.
// Copyright (c) 2013 progenius, inc. All rights reserved.
//

#import <UIKit/UIKit.h>

#import "MBAppDelegate.h"

int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([MBAppDelegate class]));
}
}
13 changes: 13 additions & 0 deletions MBAlertView/Categories/NSString+Trim.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// NSString+Trim.h
// AlertsDemo
//
// Created by M B. Bitar on 1/15/13.
// Copyright (c) 2013 progenius, inc. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NSString (Trim)
-(NSString*)stringByTruncatingToSize:(CGSize)size withFont:(UIFont*)font addQuotes:(BOOL)addQuotes;
@end
42 changes: 42 additions & 0 deletions MBAlertView/Categories/NSString+Trim.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// NSString+Trim.m
// AlertsDemo
//
// Created by M B. Bitar on 1/15/13.
// Copyright (c) 2013 progenius, inc. All rights reserved.
//

#import "NSString+Trim.h"

@implementation NSString (Trim)

-(NSString*)stringByTruncatingToSize:(CGSize)size withFont:(UIFont*)font addQuotes:(BOOL)addQuotes
{
int min = 0, max = self.length, mid;
while (min < max) {
mid = (min+max)/2;

NSString *currentString = [self substringWithRange:[self rangeOfComposedCharacterSequencesForRange:NSMakeRange(0, mid)]];
CGSize currentSize = [currentString sizeWithFont:font constrainedToSize:CGSizeMake(size.width, MAXFLOAT)];
currentString = nil;

if (currentSize.height < size.height){
min = mid + 1;
} else if (currentSize.height > size.height) {
max = mid - 1;
} else {
min = mid;
break;
}
}
/* handle emoji */
NSMutableString *finalString = [[self substringWithRange:[self rangeOfComposedCharacterSequencesForRange:NSMakeRange(0, min)]] mutableCopy];
int length = addQuotes ? 4 : 3;
NSString *appendString = addQuotes ? @"...\"" : @"...";
if(finalString.length < self.length && finalString.length > length) {
[finalString replaceCharactersInRange:[finalString rangeOfComposedCharacterSequencesForRange:NSMakeRange(finalString.length - length, length)] withString:appendString];
}
return finalString;
}

@end
13 changes: 13 additions & 0 deletions MBAlertView/Categories/UIFont+Alert.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// UIFont+Alert.h
// AlertsDemo
//
// Created by M B. Bitar on 1/15/13.
// Copyright (c) 2013 progenius, inc. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UIFont (Alert)
+(UIFont*)boldSystemFontThatFitsSize:(CGSize)size maxFontSize:(int)max minSize:(int)min text:(NSString*)text;
@end
Loading

0 comments on commit d1261b9

Please sign in to comment.