Skip to content

Commit

Permalink
Merge pull request #39 from aparedes/ios7
Browse files Browse the repository at this point in the history
iOS 7 Support
  • Loading branch information
SantiagoTorres committed Oct 3, 2013
2 parents 4d8283c + 7e058d1 commit b7bd3aa
Show file tree
Hide file tree
Showing 15 changed files with 1,078 additions and 1,718 deletions.
23 changes: 22 additions & 1 deletion MATSOL/Classes/CreditsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
#import "CreditsViewController.h"
#pragma mark -

@interface CreditsViewController ()
@property (weak, nonatomic) IBOutlet UINavigationBar *bar;

@end

@implementation CreditsViewController

@synthesize delegate, versionLabel;
Expand All @@ -23,14 +28,30 @@ -(void)viewDidLoad{
NSString *status = [dictionary objectForKey:@"GitStatus"];
NSString *branch = [dictionary objectForKey:@"GitBranch"];
NSString *version = [dictionary objectForKey:@"CFBundleShortVersionString"];

[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"BrushedMetalBackground"]]];
UIImageView *logo = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"MATSOLLogo"]];
[logo setFrame:CGRectMake(60, 30, 200, 200)];
[self.view addSubview:logo];
// If the current branch is master do not output any extra information but
// the SHA, else then print SHA@BRANCH_NAME for the info in head
NSString *head = [NSString stringWithFormat:@"%@%@", hash, ([branch isEqualToString:@"master"] ? @"" : [NSString stringWithFormat:@"@%@", branch])];

// when status is 1 the repository has unstaged changes, therefore append a
// star to tipify a non-clean repository, else just print the SHA1
[versionLabel setText:[NSString stringWithFormat:@"Ver. %@ (%@%@)", version,head,([status isEqualToString:@"1"] ? @" *" : @"")]];

CGFloat iosVer = [[[UIDevice currentDevice] systemVersion] floatValue];
if (iosVer >= 7.0) {
CGRect frame = _bar.frame;
frame.size.height += 20;
[_bar setFrame:frame];
[_bar setTintColor:[UIColor whiteColor]];
[_bar setBarTintColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"BrushedMetalBackground"]]];
[_bar setTranslucent:NO];
} else {
[_bar setBackgroundColor:[UIColor darkGrayColor]];
}

}

-(IBAction)presionaBotonOcultaCreditos:(id)sender{
Expand Down
11 changes: 7 additions & 4 deletions MATSOL/Classes/InputResistorViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ - (void)viewDidLoad {
UIBarButtonItem *bbi = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(goNext:)];
UIBarButtonItem *spa = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIToolbar *tool = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width,30)];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
[tool setTintColor:[UIColor whiteColor]];
}
[tool setItems:[NSArray arrayWithObjects:spa,bbi, nil]];
[tool setBarStyle:UIBarStyleBlackTranslucent];
[targetResistance setInputAccessoryView:tool];
Expand Down Expand Up @@ -136,10 +139,10 @@ - (BOOL)textFieldShouldReturn:(UITextField *)textField{
if (resistorValue>=6800000.0) {
//Show an alert view the size is not valid : O
GIDAAlertView *sizeAlert=[[GIDAAlertView alloc] initWithTitle:NSLocalizedString(@"Error", @"Error string")
message:NSLocalizedString(@"The resistor value should be less than 6800000.", @"Resistor label for error 68000000")
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
message:NSLocalizedString(@"The resistor value should be less than 6800000.", @"Resistor label for error 68000000")
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
//Display the alert dialog
[sizeAlert show];

Expand Down
11 changes: 9 additions & 2 deletions MATSOL/Classes/MATSOLAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[homeButton addTarget:self action:@selector(goToRootViewController:) forControlEvents:UIControlEventTouchUpInside];

navigationController=[[UINavigationController alloc] initWithRootViewController:firstViewController];
[[navigationController navigationBar] setTintColor:[UIColor darkGrayMATSOL]];

[navigationController.navigationBar setTranslucent:NO];
[navigationController.navigationBar setOpaque:YES];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
[navigationController.navigationBar setTintColor:[UIColor whiteColor]];
[navigationController.navigationBar setBarTintColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"BrushedMetalBackground"]]];
} else {
[[navigationController navigationBar] setTintColor:[UIColor darkGrayMATSOL]];
}

//The homeButton must be added after the navigationController
//in order to make it work
//[window addSubview:navigationController.view];
Expand Down
25 changes: 14 additions & 11 deletions MATSOL/Classes/ScrollViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,38 @@ - (void)scrollViewDidScroll:(UIScrollView *)sender;

@implementation ScrollViewController

@synthesize scrollView;
@synthesize scrollView;
@synthesize pageControl;
@synthesize viewControllers;
@synthesize creditsButton;

#pragma mark Initialization
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
// Custom initialization
[self setTitle:@"MATSOL"];

#ifdef DEBUG_INTERFACE
#ifdef DEBUG_INTERFACE
[self setTitle:@"MATSOL_MENU"];
#endif
#endif

creditsButton=[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"About", @"About string") style:UIBarButtonItemStyleBordered target:self action:@selector(credits)];
[[self navigationItem] setLeftBarButtonItem:creditsButton];
[[self navigationItem] setLeftBarButtonItem:creditsButton];
}
return self;
}

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
[self.navigationController.navigationBar setTitleTextAttributes:@{ UITextAttributeTextColor : [UIColor whiteColor] }];
}

//Set some colors
[scrollView setBackgroundColor:[UIColor clearColor]];
[pageControl setBackgroundColor:[UIColor colorWithRed:.161 green:.161 blue:0.161 alpha:0.6]];
[scrollView setBackgroundColor:[UIColor clearColor]];
[pageControl setBackgroundColor:[UIColor colorWithRed:.161 green:.161 blue:0.161 alpha:0.6]];

// view controllers are created lazily
// in the meantime, load the array with placeholders which will be replaced on demand
Expand All @@ -69,13 +72,13 @@ - (void)viewDidLoad {
[[self pageControl] setNumberOfPages:kNumberOfPages];
[[self pageControl] setCurrentPage:0];
[[self pageControl] setHidesForSinglePage:YES];


// pages are created on demand
// load the visible page
// load the page on either side to avoid flashes when the user starts scrolling
[self loadScrollViewWithPage:0];
[self loadScrollViewWithPage:1];
[self loadScrollViewWithPage:1];
}


Expand Down
18 changes: 13 additions & 5 deletions MATSOL/Classes/SlaveViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ - (id)initWithPageNumber:(int)page {

// Set the label and background color when the view has finished loading.
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor clearColor];
[self placeButtonsAndSetBackgroundForIndex:pageNumber];
}
Expand Down Expand Up @@ -98,17 +99,20 @@ -(void)alertOnClicked:(GIDAAlertView *)alertView {
if ([alertView accepted]) {
int matrixSize = [[alertView enteredText] intValue];
if ([[alertView title] isEqualToString:NSLocalizedString(@"LinearSize",@"Linear Equation Matrix Size")]) {
if (matrixSize > 26 || matrixSize <= 0 || [[alertView enteredText] isEqualToString:@""]) {
if (matrixSize > 26 || matrixSize <= 1 || [[alertView enteredText] isEqualToString:@""]) {
GIDAAlertView *gsaExtra = [[GIDAAlertView alloc] initWithPrompt:NSLocalizedString(@"LinearSize" ,@"Linear Equation Matrix Size") cancelButtonTitle:NSLocalizedString(@"Cancel",@"Cancel") acceptButtonTitle:NSLocalizedString(@"Accept", @"Accept")];
[gsaExtra setDelegate:self];
[gsaExtra setKeyboard:UIKeyboardTypeNumberPad];
[gsaExtra show];
} else {
GIDAMatrixViewController *viewController = [[GIDAMatrixViewController alloc] initWithMatrixSize:matrixSize andSolver:GIDALinearEquations];
[self endUIViewController:viewController];
}
} else {
if (matrixSize > 26 || matrixSize <= 0 || [[alertView enteredText] isEqualToString:@""]) {
GIDAAlertView *gsaExtra = [[GIDAAlertView alloc] initWithPrompt:NSLocalizedString(@"DeterminantSize" ,@"Determinant Matrix Size") cancelButtonTitle:NSLocalizedString(@"Cancel",@"Cancel") acceptButtonTitle:NSLocalizedString(@"Accept", @"Accept") andKeyBoard:UIKeyboardTypeNumberPad];
if (matrixSize > 26 || matrixSize <= 1 || [[alertView enteredText] isEqualToString:@""]) {
GIDAAlertView *gsaExtra = [[GIDAAlertView alloc] initWithPrompt:NSLocalizedString(@"DeterminantSize" ,@"Determinant Matrix Size") cancelButtonTitle:NSLocalizedString(@"Cancel",@"Cancel") acceptButtonTitle:NSLocalizedString(@"Accept", @"Accept") ];

[gsaExtra setKeyboard:UIKeyboardTypeNumberPad];
[gsaExtra show];
} else {
GIDAMatrixViewController *viewController = [[GIDAMatrixViewController alloc] initWithMatrixSize:matrixSize andSolver:GIDADeterminant];
Expand All @@ -131,7 +135,8 @@ -(void)creatingUIViewController:(id)sender{
#ifdef DEBUG
NSLog(@"LES");
#endif
GIDAAlertView *gsa = [[GIDAAlertView alloc] initWithPrompt:NSLocalizedString(@"LinearSize" ,@"Linear Equation Matrix Size") cancelButtonTitle:NSLocalizedString(@"Cancel",@"Cancel") acceptButtonTitle:NSLocalizedString(@"Accept", @"Accept") andKeyBoard:UIKeyboardTypeNumberPad];
GIDAAlertView *gsa = [[GIDAAlertView alloc] initWithPrompt:NSLocalizedString(@"LinearSize" ,@"Linear Equation Matrix Size") cancelButtonTitle:NSLocalizedString(@"Cancel",@"Cancel") acceptButtonTitle:NSLocalizedString(@"Accept", @"Accept")];
[gsa setKeyboard:UIKeyboardTypeNumberPad];
[gsa setDelegate:self];
[gsa show];
return ;
Expand All @@ -140,7 +145,10 @@ -(void)creatingUIViewController:(id)sender{
#ifdef DEBUG
NSLog(@"DET");
#endif
GIDAAlertView *gsa = [[GIDAAlertView alloc] initWithPrompt:NSLocalizedString(@"DeterminantSize" ,@"Determinant Matrix Size") cancelButtonTitle:NSLocalizedString(@"Cancel",@"Cancel") acceptButtonTitle:NSLocalizedString(@"Accept", @"Accept") andKeyBoard:UIKeyboardTypeNumberPad];
GIDAAlertView *gsa = [[GIDAAlertView alloc] initWithPrompt:NSLocalizedString(@"DeterminantSize" ,@"Determinant Matrix Size")
cancelButtonTitle:NSLocalizedString(@"Cancel",@"Cancel")
acceptButtonTitle:NSLocalizedString(@"Accept", @"Accept")];
[gsa setKeyboard:UIKeyboardTypeNumberPad];
[gsa setDelegate:self];
[gsa show];
return;
Expand Down
100 changes: 73 additions & 27 deletions MATSOL/GIDAUtilities/GIDAAlertView.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,58 +17,104 @@
#import <QuartzCore/QuartzCore.h>

typedef enum {
GIDAAlertViewMessageImage = 0,
GIDAAlertViewSpinner = 1,
GIDAAlertViewPrompt = 2,
GIDAAlertViewNoPrompt = 3,
GIDAAlertViewProgressTime = 4,
GIDAAlertViewProgressURL = 5,
GIDAAlertViewCheck = 6,
GIDAAlertViewXMark = 7
GIDAAlertViewMessageImage,
GIDAAlertViewSpinner,
GIDAAlertViewPrompt,
GIDAAlertViewNoPrompt,
GIDAAlertViewProgressTime,
GIDAAlertViewProgressURL,
GIDAAlertViewCheck,
GIDAAlertViewXMark
}GIDAAlertViewType;

@interface ProgressBar : UIView
-(id)initWithFrame:(CGRect)frame andProgressBarColor:(UIColor *)pcolor;
-(void)moveBar:(CGFloat)progress;
-(void)setProgressBarColor:(UIColor *)color;
@end

@class GIDAAlertView;
/**
* Methods that the GIDAAlertView delegate must implement.
*/
@protocol GIDAAlertViewDelegate <NSObject>
@optional
/** Tells the delegate that an alert has been clicked.
@param alertView The alert view that sends the notification */
-(void)alertOnClicked:(GIDAAlertView *)alertView;
/** Tells the delegate that an alert has been dismised.
@param alertView The alert view that sends the notification */
-(void)alertOnDismiss:(GIDAAlertView *)alertView;
/** Tells the delegate that an alert has been clicked, dismissed and finished background activities.
@param alertView The alert view that sends the notification */
-(void)alertFinished:(GIDAAlertView *)alertView;
@end

/**
* Description of GIDAAlertView
*/
@interface GIDAAlertView : UIAlertView <NSURLConnectionDataDelegate, UIAlertViewDelegate>
/** @name Attributes */
@property (nonatomic, strong) NSString *identifier;
@property (readonly) GIDAAlertViewType type;
@property (readonly) BOOL accepted;
@property (nonatomic, strong) id <GIDAAlertViewDelegate> gavdelegate;

/** @name Initialization */

/** Initialization of a GIDAAlertView with an check mark and a message.
An NSString presented along with a check mark
@param message String with the message to present
@return A GIDAAlertView object or `nil` if it could not be created. */
- (id)initWithCheckMarkAndMessage:(NSString *)message;

/** Initialization of a GIDAAlertView with an exclamation mark and a message.
An NSString presented along with a exclamation mark
@param message String with the message to present
@return A GIDAAlertView object or `nil` if it could not be created. */
- (id)initWithExclamationMarkAndMessage:(NSString *)message;

/** Initialization of a GIDAAlertView with an image and prompt
Creates an alert that presents an image and a prompt. This can be used for confirming that the user is a real user. This can be used for CAPTCHA requests
@param image An image to present in the alertview
@param message The message to present in the alert
@param cancelTitle String for the cancel button
@param acceptTitle String for the accept button
@return A GIDAAlertView object or `nil` if it could not be created. */
- (id)initWithImage:(UIImage *)image andMessage:(NSString *)message cancelButtonTitle:(NSString *)cancelTitle acceptButtonTitle:(NSString *)acceptTitle;

/** Initialization of a GIDAAlertView with a message and an image.
An NSString and a UIImage to be presented in the alert
@param someMessage String with the message
@param someImage Image to show in alert
@return A GIDAAlertView object or `nil` if it could not be created.*/
- (id)initWithMessage:(NSString *)someMessage andAlertImage:(UIImage *)someImage;
- (id) initWithSpinnerAndMessage:(NSString *)message;
-(id)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ...;
- (id)initWithImage:(UIImage *)image andPrompt:(NSString *)prompt cancelButtonTitle:(NSString *)cancelTitle acceptButtonTitle:(NSString *)acceptTitle;

/** Initialization of a GIDAAlertView with a message and a graphic spinner.
An NSString presented along with a UIActivityIndicatorView in the alert
@param message String with the message to present
@return A GIDAAlertView object or `nil` if it could not be created. */
- (id) initWithSpinnerWith:(NSString *)message;
- (id)initWithPrompt:(NSString *)prompt cancelButtonTitle:(NSString *)cancelTitle acceptButtonTitle:(NSString *)acceptTitle;
- (id)initWithPrompt:(NSString *)prompt cancelButtonTitle:(NSString *)cancelTitle acceptButtonTitle:(NSString *)acceptTitle andKeyBoard:(UIKeyboardType)keyboard;

- (id)initWithTitle:(NSString *)title cancelButtonTitle:(NSString *)cancelTitle acceptButtonTitle:(NSString *)acceptTitle andMessage:(NSString *)message;
- (id)initWithProgressBarAndMessage:(NSString *)message andTime:(NSInteger)seconds;
- (id)initWithProgressBarAndMessage:(NSString *)message andURL:(NSURL *)url;
- (id)initWithProgressBarAndMessage:(NSString *)message andURL:(NSURL *)url andProgressBarColor:(UIColor *)pcolor;
- (id)initWithCheckMarkAndMessage:(NSString *)message;
-(id)initWithXMarkAndMessage:(NSString *)message;
-(id)initWithExclamationMarkAndMessage:(NSString *)message;
- (id)initWithProgressBarWith:(NSString *)message andTime:(NSInteger)seconds;
- (id)initWithProgressBarWith:(NSString *)message andURL:(NSURL *)url;
- (id)initWithProgressCircleWith:(NSString *)message andURL:(NSURL *)url;
- (id)initWithXMarkWith:(NSString *)message;

/** @name Other Methods */
- (void)setColor:(UIColor *)color;
- (NSString *) enteredText;
- (NSString *) message;
- (void)presentProgressBar;
- (void)presentAlertFor:(float)seconds;
- (void)presentAlertWithSpinnerAndHideAfterSelector:(SEL)selector from:(id)sender withObject:(id)object;
- (void)progresBarStartDownload;

-(NSDictionary *)getDownloadedData;
-(void)setProgressBarColor:(UIColor *)color;
- (NSDictionary *)getDownloadedData;
- (void)setProgressBarColor:(UIColor *)color;
- (void)setKeyboard:(UIKeyboardType)keyboard;
@end
Loading

0 comments on commit b7bd3aa

Please sign in to comment.