-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,937 additions
and
1,496 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// ZFFileDetailController.h | ||
// Strings | ||
// | ||
// Created by Francesco on 26/06/2013. | ||
// Copyright (c) 2013 ziofritz. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "ZFLangFile.h" | ||
|
||
@interface ZFFileDetailController : NSObject <NSTableViewDataSource, NSTableViewDelegate> | ||
|
||
@property (nonatomic, strong) IBOutlet NSSegmentedControl *segmentedControl; | ||
@property (nonatomic, strong) IBOutlet NSTableView *tableView; | ||
@property (nonatomic, strong) ZFLangFile *langFile; | ||
|
||
- (IBAction)didSwithSegmentedControl:(NSSegmentedControl *)sender; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// | ||
// ZFFileDetailController.m | ||
// Strings | ||
// | ||
// Created by Francesco on 26/06/2013. | ||
// Copyright (c) 2013 ziofritz. All rights reserved. | ||
// | ||
|
||
#import "ZFFileDetailController.h" | ||
|
||
#define KEY_KEY @"Keys" | ||
|
||
@interface ZFFileDetailController () | ||
|
||
@property (nonatomic, strong) NSArray *keys; | ||
@property (nonatomic, strong) NSDictionary *rows; | ||
@property (nonatomic, strong) NSArray *columns; | ||
|
||
@end | ||
|
||
@implementation ZFFileDetailController | ||
|
||
- (void)setLangFile:(ZFLangFile *)langFile { | ||
_langFile = langFile; | ||
|
||
[self didSwithSegmentedControl:self.segmentedControl]; | ||
|
||
} | ||
|
||
#pragma mark - Segmented Controller | ||
|
||
- (IBAction)didSwithSegmentedControl:(NSSegmentedControl *)sender { | ||
self.rows = (self.segmentedControl.selectedSegment == 0)? [self.langFile iOStranslations] : [self.langFile androidTranslations]; | ||
|
||
self.columns = [[NSArray arrayWithObject:KEY_KEY] arrayByAddingObjectsFromArray:[self.rows allKeys]]; | ||
self.keys = (self.columns.count > 1)? [[self.rows objectForKey:[self.columns objectAtIndex:1]] allKeys] : [NSArray array]; | ||
|
||
NSMutableArray *addCol = [self.columns mutableCopy]; | ||
|
||
[self.tableView beginUpdates]; | ||
|
||
NSArray *columns = [self.tableView.tableColumns copy]; | ||
[columns enumerateObjectsUsingBlock:^(NSTableColumn *column, NSUInteger idx, BOOL *stop) { | ||
if ([self.columns containsObject:column.identifier]) { | ||
[addCol removeObject:column.identifier]; | ||
return; | ||
} | ||
|
||
[self.tableView removeTableColumn:column]; | ||
}]; | ||
[addCol enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL *stop) { | ||
NSTableColumn *column = [[NSTableColumn alloc] initWithIdentifier:obj]; | ||
[column setHeaderCell:[[NSCell alloc] initTextCell:obj]]; | ||
[self.tableView addTableColumn:column]; | ||
}]; | ||
|
||
[self.tableView reloadData]; | ||
[self.tableView endUpdates]; | ||
} | ||
|
||
#pragma mark - TableView | ||
|
||
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView { | ||
return [self.rows count]; | ||
} | ||
|
||
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { | ||
if ([tableColumn.identifier isEqualToString:KEY_KEY]) return [self.keys objectAtIndex:row]; | ||
else return [[self.rows objectForKey:tableColumn.identifier] objectForKey:[self.keys objectAtIndex:row]]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// ZFFilesController.h | ||
// Strings | ||
// | ||
// Created by Francesco on 26/06/2013. | ||
// Copyright (c) 2013 ziofritz. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "ZFFileDetailController.h" | ||
|
||
@interface ZFFilesController : NSObject <NSTableViewDataSource, NSTableViewDelegate> | ||
|
||
@property (nonatomic, strong) IBOutlet ZFFileDetailController *fileDetailController; | ||
@property (nonatomic, strong) IBOutlet NSTableView *filesTable; | ||
@property (assign) IBOutlet NSWindow *window; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// | ||
// ZFFilesController.m | ||
// Strings | ||
// | ||
// Created by Francesco on 26/06/2013. | ||
// Copyright (c) 2013 ziofritz. All rights reserved. | ||
// | ||
|
||
#import "ZFFilesController.h" | ||
#import "ZFFileViewCell.h" | ||
#import "ZFStringScanner.h" | ||
#import "ZFLangFile.h" | ||
|
||
@interface ZFFilesController () | ||
|
||
@property (nonatomic, strong) NSURL *sourceURL; | ||
@property (nonatomic, strong) ZFStringScanner *scanner; | ||
|
||
@end | ||
|
||
@implementation ZFFilesController | ||
|
||
#pragma mark - tableview | ||
|
||
- (id)init | ||
{ | ||
self = [super init]; | ||
if (self) { | ||
double delayInSeconds = 1.0; | ||
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); | ||
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ | ||
[self load]; | ||
}); | ||
} | ||
return self; | ||
} | ||
|
||
- (void)load { | ||
[self setURLFromDialog:^(BOOL success) { | ||
if (!self.sourceURL || !success) return; | ||
self.scanner = [[ZFStringScanner alloc] init]; | ||
[self.scanner startScanAtURL:self.sourceURL]; | ||
[self.filesTable reloadData]; | ||
/* | ||
[scanner.files enumerateObjectsUsingBlock:^(ZFLangFile *obj, NSUInteger idx, BOOL *stop) { | ||
NSLog(@"file\n %@[%@]\n %@[%@]", obj.iOSName, [obj.iOStranslations.allKeys componentsJoinedByString:@"|"], obj.androidName, [obj.androidTranslations.allKeys componentsJoinedByString:@"|"]); | ||
}]; | ||
*/ | ||
|
||
}]; | ||
} | ||
|
||
|
||
- (void)setURLFromDialog:(void (^)(BOOL success)) completed { | ||
NSOpenPanel* openDlg = [NSOpenPanel openPanel]; | ||
[openDlg setCanChooseFiles:NO]; | ||
[openDlg setAllowsMultipleSelection:NO]; | ||
[openDlg setCanChooseDirectories:YES]; | ||
|
||
|
||
void (^completitionBlock)(NSInteger) = ^(NSInteger result) { | ||
if (result != NSOKButton) { | ||
if (completed) completed(NO); | ||
return; | ||
} | ||
|
||
self.sourceURL = openDlg.URL; | ||
if (completed) completed(YES); | ||
}; | ||
|
||
if (!self.window) [openDlg beginWithCompletionHandler:completitionBlock]; | ||
else [openDlg beginSheetModalForWindow:self.window completionHandler:completitionBlock]; | ||
} | ||
|
||
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView { | ||
return [self.scanner.files count]; | ||
} | ||
|
||
- (id)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { | ||
ZFFileViewCell *cell = [tableView makeViewWithIdentifier:@"langCell" owner:self]; | ||
[cell setLangFile:[self.scanner.files objectAtIndex:row]]; | ||
|
||
return cell; | ||
} | ||
|
||
- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)row { | ||
if (self.fileDetailController) [self.fileDetailController setLangFile:[self.scanner.files objectAtIndex:row]]; | ||
return YES; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ | |
|
||
#ifdef __OBJC__ | ||
#import <Cocoa/Cocoa.h> | ||
#import "ZFUtils.h" | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// ZFFileViewCell.h | ||
// Strings | ||
// | ||
// Created by Francesco on 26/06/2013. | ||
// Copyright (c) 2013 ziofritz. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
#import "ZFLangFile.h" | ||
|
||
@interface ZFFileViewCell : NSTableCellView | ||
|
||
@property (nonatomic, strong) ZFLangFile *langFile; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// | ||
// ZFFileViewCell.m | ||
// Strings | ||
// | ||
// Created by Francesco on 26/06/2013. | ||
// Copyright (c) 2013 ziofritz. All rights reserved. | ||
// | ||
|
||
#import "ZFFileViewCell.h" | ||
|
||
@interface ZFFileViewCell () | ||
|
||
@property (nonatomic, strong) NSTextView *titleLbl; | ||
@property (nonatomic, strong) NSTextView *detailLbl; | ||
|
||
@end | ||
|
||
@implementation ZFFileViewCell | ||
|
||
- (id)initWithFrame:(NSRect)frame | ||
{ | ||
self = [super initWithFrame:frame]; | ||
if (self) { | ||
// Initialization code here. | ||
frame = self.bounds; | ||
frame.size.height = ceil(frame.size.height /2); | ||
self.titleLbl = [[NSTextView alloc] initWithFrame:frame]; | ||
[self addSubview:self.titleLbl]; | ||
|
||
frame.origin.y += frame.size.height; | ||
self.detailLbl = [[NSTextView alloc] initWithFrame:frame]; | ||
[self addSubview:self.detailLbl]; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (void)setLangFile:(ZFLangFile *)langFile { | ||
_langFile = langFile; | ||
if (_langFile.iOSName.length > 0) [self.textField setStringValue:_langFile.iOSName]; | ||
|
||
if (_langFile.androidName.length > 0) [self.textField setStringValue:_langFile.androidName]; | ||
} | ||
|
||
- (void)drawRect:(NSRect)dirtyRect | ||
{ | ||
// Drawing code here. | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// ZFTranslationCollectionItem.h | ||
// Strings | ||
// | ||
// Created by Francesco on 26/06/2013. | ||
// Copyright (c) 2013 ziofritz. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
@interface ZFTranslationView : NSView | ||
|
||
@property (nonatomic, strong) IBOutlet NSTextView *label; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// ZFTranslationCollectionItem.m | ||
// Strings | ||
// | ||
// Created by Francesco on 26/06/2013. | ||
// Copyright (c) 2013 ziofritz. All rights reserved. | ||
// | ||
|
||
#import "ZFTranslationView.h" | ||
|
||
@interface ZFTranslationView () | ||
|
||
@end | ||
|
||
@implementation ZFTranslationView | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.