Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add icon for App #4

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 12 additions & 10 deletions ViperCode/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,61 @@
{
"size" : "16x16",
"idiom" : "mac",
"filename" : "Viper-icon-16.png",
"filename" : "1.png",
"scale" : "1x"
},
{
"size" : "16x16",
"idiom" : "mac",
"filename" : "Viper-icon-16@2x.png",
"filename" : "1-1.png",
"scale" : "2x"
},
{
"size" : "32x32",
"idiom" : "mac",
"filename" : "Viper-icon-16@2x-1.png",
"filename" : "1-2.png",
"scale" : "1x"
},
{
"size" : "32x32",
"idiom" : "mac",
"filename" : "Viper-icon-64.png",
"filename" : "1-3.png",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "128x128",
"idiom" : "mac",
"filename" : "1-4.png",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "128x128",
"idiom" : "mac",
"filename" : "1-5.png",
"scale" : "2x"
},
{
"size" : "256x256",
"idiom" : "mac",
"filename" : "Viper-icon-256.png",
"filename" : "1-8.png",
"scale" : "1x"
},
{
"size" : "256x256",
"idiom" : "mac",
"filename" : "Viper-icon-256@2x.png",
"filename" : "1-9.png",
"scale" : "2x"
},
{
"size" : "512x512",
"idiom" : "mac",
"filename" : "Viper-icon-256@2x-1.png",
"filename" : "1-7.png",
"scale" : "1x"
},
{
"size" : "512x512",
"idiom" : "mac",
"filename" : "Viper-icon-1024.png",
"filename" : "1-6.png",
"scale" : "2x"
}
],
Expand Down
57 changes: 30 additions & 27 deletions ViperCode/View Controllers/ViewController.m
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//
// ViewController.m
// ViperCode
//
// Created by Sameh Mabrouk on 2/1/16.
// Copyright © 2016 smapps. All rights reserved.
//
//
// ViewController.m
// ViperCode
//
// Created by Sameh Mabrouk on 2/1/16.
// Copyright © 2016 smapps. All rights reserved.
//

#import "ViewController.h"
#import "ModuleGenerator.h"
Expand All @@ -15,7 +15,7 @@
#import "NSString+Substring.h"
#import <AddressBook/AddressBook.h>

// Constants for defining alerts types.
// Constants for defining alerts types.
#define kCOPYALERT 0
#define kTESTSALERT 1
#define kREMOVEALERT 2
Expand All @@ -29,7 +29,7 @@ @implementation ViewController
#pragma mark - View Controller methods
- (void)viewDidLoad {
[super viewDidLoad];

self.view.window.title = @"ViperCode";
[self.generatedModuleButton setEnabled:NO];
self.ProjectNameTextField.delegate = self;
Expand Down Expand Up @@ -64,7 +64,7 @@ - (void)updatePreviewHeaderCode {
previewText = [previewText stringByAppendingString:[NSString stringWithFormat:@"// Created by %@ on %@.\n", [self generateUserName], [self generateCurrentDate]]];
previewText = [previewText stringByAppendingString:[NSString stringWithFormat:@"// Copyright (c) %@ %@. All rights reserved.\n", [self generateCurrentYear], [self generateCompanyName]]];
previewText = [previewText stringByAppendingString:@"//\n"];

self.previewHeaderCodeTextView.string = previewText;
}

Expand All @@ -82,15 +82,15 @@ - (void)displayPopupAlert:(NSString*)message withButtons:(NSArray*)buttons alert
}

[alert beginSheetModalForWindow:self.view.window completionHandler:^(NSModalResponse returnCode) {
// Check returnCode here
// Check returnCode here
if (returnCode == NSAlertFirstButtonReturn) {
if (tag == kCOPYALERT) {
//Handling replace case
//Handling replace case
[self fireGenerateAction:YES replaceExistedModuleTest:YES];
}
}
else if (returnCode == NSAlertSecondButtonReturn) {
// Handling stop case
// Handling stop case
}
}];
}
Expand All @@ -104,7 +104,7 @@ - (void)configAvailableTemplates {
#pragma mark - Module Generation methods
- (void)fireGenerateAction:(BOOL)replaceExistedModule replaceExistedModuleTest:(BOOL)replaceExistedModuleTests {

// Generate Class
// Generate Class
self.moduleGenerator = [[ModuleGenerator alloc] init];

[self.moduleGenerator generateViperModuleWithName:[self generateModuleName]
Expand All @@ -122,25 +122,25 @@ - (void)fireGenerateAction:(BOOL)replaceExistedModule replaceExistedModuleTest:(

if (error) {
if (error.code == 516) {
// Handle Copying Error: because an item with the same name already exists.
// Handle Copying Error: because an item with the same name already exists.
NSArray *arr = @[@"Replace", @"Stop"];
[self displayPopupAlert:@"Module could not be created because it already exists. Do you want to replace it with a new one?" withButtons:arr alertTag:kCOPYALERT];
}
else if (error.code == 4) {
// Handle Copying Error: because an item with the same name already exists.
// Handle Copying Error: because an item with the same name already exists.
[self displayPopupAlert:@"Module could not be replaced becasue some files could not be removed." withButtons:nil alertTag:kREMOVEALERT];
}
}
else {
// Module generated successfully
// Module generated successfully
[self displayPopupAlert:@"Module successfully generated. Please check your project directory." withButtons:nil alertTag:kMODULESUCCESSALERT];
}
}];

}

- (IBAction)createModule:(id)sender {
// Check if user selected Include unite tests option and did not enered test file path.
// Check if user selected Include unite tests option and did not enered test file path.
if (self.includeTestsCheckBoxButton.state == 1 && [self.testsPathTextField.stringValue isEqual: @""]) {
NSArray *arr = @[@"Ok"];
[self displayPopupAlert:@"Test File Path cannot be empty. Please select Tests File Path." withButtons:arr alertTag:kTESTSALERT];
Expand All @@ -162,6 +162,9 @@ - (NSString *)fetchUserNameFromAddressBook {
NSString *capitalizedFirstName = [firstName capitalizeFirstCharacterInString:firstName];
NSString *lastName = [currentLoggedInUser valueForKey:kABLastNameProperty];
NSString *capitalizedLastName = [firstName capitalizeFirstCharacterInString:lastName];
if ( capitalizedLastName == nil && capitalizedFirstName == nil){
return NSFullUserName();
}
return [[capitalizedFirstName stringByAppendingString:@" "] stringByAppendingString:capitalizedLastName];
}

Expand All @@ -175,7 +178,7 @@ - (NSString *)generateUserName {
}

- (NSString *)generateModuleName {
// Prevents spaces in the Module Name (filename)
// Prevents spaces in the Module Name (filename)
return [self.moduleNameTextField.stringValue stringByReplacingOccurrencesOfString:@" " withString:@""];
}

Expand All @@ -190,7 +193,7 @@ - (NSString *)generateTemplateName {
- (NSString *)generateLanguage {
return self.languagesPopUpButton.titleOfSelectedItem;
}

- (NSString *)generateCompanyName {
return self.companyTextField.stringValue;
}
Expand Down Expand Up @@ -227,32 +230,32 @@ - (void)controlTextDidEndEditing:(NSNotification *)notification {
#pragma mark - VPTextFieldDelegate methods
- (void)didBecomeFirstResponder:(NSTextField *)textField {

// Check if TextField is of kind to chose path
// Check if TextField is of kind to chose path
if (textField == self.modulePathTexField || textField == self.testsPathTextField) {

NSOpenPanel* openDlg = [NSOpenPanel openPanel];

// Enable the selection of files in the dialog.
// Enable the selection of files in the dialog.
[openDlg setCanChooseFiles:YES];

// Enable the selection of directories in the dialog.
// Enable the selection of directories in the dialog.
[openDlg setCanChooseDirectories:YES];

// Change "Open" dialog button to "Select"
// Change "Open" dialog button to "Select"
[openDlg setPrompt:@"Select"];

// Display the dialog. If the OK button was pressed process the files
// Display the dialog. If the OK button was pressed process the files
if ([openDlg runModal] == NSModalResponseOK ) {
NSURL *result = openDlg.URL;
if (result != nil) {
NSString *path = result.path;
textField.stringValue = path;

// Check if all textfields contain stringValue or not to enable Generate button.
// Check if all textfields contain stringValue or not to enable Generate button.
[self.generatedModuleButton setEnabled:YES];
}
else {
// User clicked on cancel
// User clicked on cancel
return;
}

Expand Down