Skip to content

Commit 9205831

Browse files
Code formatting and added tabview delegate
1 parent ebdf9a3 commit 9205831

3 files changed

Lines changed: 90 additions & 75 deletions

File tree

AppBox/Base.lproj/Main.storyboard

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,9 @@
417417
</view>
418418
</tabViewItem>
419419
</tabViewItems>
420+
<connections>
421+
<outlet property="delegate" destination="lct-wo-jYo" id="GsN-fY-tSl"/>
422+
</connections>
420423
</tabView>
421424
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="sgg-Iy-WMT">
422425
<rect key="frame" x="0.0" y="263" width="800" height="5"/>
@@ -634,6 +637,7 @@
634637
<outlet property="pathIPAFile" destination="dVX-NT-rjH" id="1fw-fx-eph"/>
635638
<outlet property="pathProject" destination="sWE-nW-t4X" id="5es-lc-EuA"/>
636639
<outlet property="progressIndicator" destination="Iw6-ha-Sj1" id="N0m-Ok-NsH"/>
640+
<outlet property="tabView" destination="ay9-ED-rIF" id="eI7-2C-0MP"/>
637641
<outlet property="textFieldBundleIdentifier" destination="8m1-af-Iwh" id="lIi-e1-oco"/>
638642
<outlet property="textFieldEmail" destination="RKc-Si-2CZ" id="NwO-S6-73O"/>
639643
<outlet property="textFieldMessage" destination="BAA-rE-fh4" id="ACK-7P-3CG"/>

AppBox/ViewController/HomeViewController/HomeViewController.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@
1111
#import "DropboxViewController.h"
1212
#import "ShowLinkViewController.h"
1313

14-
@interface HomeViewController : NSViewController <DBRestClientDelegate, DBSessionDelegate, MailDelegate>{
14+
@interface HomeViewController : NSViewController <DBRestClientDelegate, DBSessionDelegate, MailDelegate, NSTabViewDelegate>{
1515
//Dropbox
1616
DBRestClient *restClient;
1717

18+
//Tab
19+
IBOutlet NSTabView *tabView;
20+
1821
//Build
1922
IBOutlet NSPathControl *pathProject;
2023
IBOutlet NSPathControl *pathBuild;
@@ -38,7 +41,6 @@
3841
IBOutlet NSTextField *labelStatus;
3942
IBOutlet NSView *viewProgressStatus;
4043
IBOutlet NSProgressIndicator *progressIndicator;
41-
4244
}
4345

4446
- (DBRestClient *)restClient;

AppBox/ViewController/HomeViewController/HomeViewController.m

Lines changed: 82 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ - (void)viewWillAppear{
4848
}
4949

5050

51-
#pragma mark - Project / IPA Controls Action
51+
#pragma mark - Controls Action Handler -
52+
#pragma mark → Project / Workspace Controls Action
5253
//Project Path Handler
5354
- (IBAction)projectPathHandler:(NSPathControl *)sender {
5455
if (![project.fullPath isEqualTo:sender.URL]){
5556
[project setFullPath: sender.URL];
56-
[buttonAction setTitle:@"Build Project and Upload IPA"];
5757
[self runGetSchemeScript];
5858
}
5959
}
@@ -67,7 +67,7 @@ - (IBAction)buildPathHandler:(NSPathControl *)sender {
6767

6868
//Scheme Value Changed
6969
- (IBAction)comboBuildSchemeValueChanged:(NSComboBox *)sender {
70-
[self updateBuildButtonState];
70+
[self updateViewState];
7171
}
7272

7373
//Team Value Changed
@@ -80,34 +80,45 @@ - (IBAction)comboTeamIdValueChanged:(NSComboBox *)sender {
8080
}else{
8181
[project setTeamId: sender.stringValue];
8282
}
83-
[self updateBuildButtonState];
83+
[self updateViewState];
8484
}
8585

8686
//Build Type Changed
8787
- (IBAction)comboBuildTypeValueChanged:(NSComboBox *)sender {
8888
if (![project.buildType isEqualToString:sender.stringValue]){
8989
[project setBuildType: sender.stringValue];
90-
[self updateBuildButtonState];
90+
[self updateViewState];
9191
}
9292
}
9393

94-
#pragma mark - IPA File Controlles Actions
94+
#pragma mark IPA File Controlles Actions
9595
//IPA File Path Handler
9696
- (IBAction)ipaFilePathHandle:(NSPathControl *)sender {
97-
project.ipaFullPath = sender.URL;
98-
[buttonAction setTitle:@"Upload IPA"];
99-
[self updateBuildButtonState];
100-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
101-
[self getIPAInfoFromLocalURL:project.ipaFullPath];
102-
});
97+
if (![project.fullPath isEqual:sender.URL]){
98+
project.ipaFullPath = sender.URL;
99+
[self updateViewState];
100+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
101+
[self getIPAInfoFromLocalURL:project.ipaFullPath];
102+
});
103+
}
103104
}
104105

105106
- (IBAction)buttonUniqueLinkTapped:(NSButton *)sender{
106107
//NOT required
107108
}
108109

110+
#pragma mark → Final Action Button (Build/IPA)
111+
//Build Button Action
112+
- (IBAction)actionButtonTapped:(NSButton *)sender {
113+
if (project.fullPath){
114+
[project setIsBuildOnly:NO];
115+
[self runBuildScript];
116+
}else if (project.ipaFullPath){
117+
[self uploadIPAFileWithLocalURL:project.ipaFullPath];
118+
}
119+
}
109120

110-
#pragma mark - Mail and Shutdown controls action
121+
#pragma mark Mail Controls Action
111122
//Send mail option
112123
- (IBAction)sendMailOptionValueChanged:(NSButton *)sender {
113124
if (sender.state == NSOnState && ![UserData isGmailLoggedIn]){
@@ -138,19 +149,8 @@ - (IBAction)textFieldDevMessageValueChanged:(NSTextField *)sender {
138149
}
139150

140151

141-
#pragma mark - Final Action Button (Build/IPA)
142-
//Build Button Action
143-
- (IBAction)actionButtonTapped:(NSButton *)sender {
144-
if (project.fullPath){
145-
[project setIsBuildOnly:NO];
146-
[self runBuildScript];
147-
}else if (project.ipaFullPath){
148-
[self uploadIPAFileWithLocalURL:project.ipaFullPath];
149-
}
150-
}
151-
152-
153-
#pragma mark - Task
152+
#pragma mark - NSTask (Scheme, TeamId and Archive) -
153+
#pragma mark → Task
154154

155155
- (void)runGetSchemeScript{
156156
[self showStatus:@"Getting project scheme..." andShowProgressBar:YES withProgress:-1];
@@ -205,7 +205,7 @@ - (void)runBuildScript{
205205
[self runTaskWithLaunchPath:buildScriptPath andArgument:buildArgument];
206206
}
207207

208-
#pragma mark - Capture task data
208+
#pragma mark → Run and Capture task data
209209

210210
- (void)runTaskWithLaunchPath:(NSString *)launchPath andArgument:(NSArray *)arguments{
211211
NSTask *task = [[NSTask alloc] init];
@@ -304,6 +304,8 @@ - (void)captureStandardOutputWithTask:(NSTask *)task{
304304
}];
305305
}
306306

307+
#pragma mark - Get IPA Info -
308+
307309
-(void)checkIPACreated{
308310
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
309311
if ([[NSFileManager defaultManager] fileExistsAtPath:project.ipaFullPath.resourceSpecifier]){
@@ -314,8 +316,6 @@ -(void)checkIPACreated{
314316
});
315317
}
316318

317-
#pragma mark - Get IPA Info
318-
319319
- (void)getIPAInfoFromLocalURL:(NSURL *)ipaFileURL{
320320
NSString *fromPath = [ipaFileURL.resourceSpecifier stringByRemovingPercentEncoding];
321321
if ([[NSFileManager defaultManager] fileExistsAtPath:fromPath]) {
@@ -374,7 +374,7 @@ -(void)uploadIPAFileWithLocalURL:(NSURL *)ipaURL{
374374
NSLog(@"Temporaray folder %@",NSTemporaryDirectory());
375375
}
376376

377-
#pragma mark - Updating Unique Link
377+
#pragma mark - Updating Unique Link -
378378
-(void)updateUniquLinkDictinory:(NSMutableDictionary *)dictUniqueLink{
379379
if(![dictUniqueLink isKindOfClass:[NSDictionary class]])
380380
dictUniqueLink = [NSMutableDictionary new];
@@ -428,11 +428,13 @@ -(void)handleAfterUniqueJsonMetaDataLoaded{
428428
}
429429
}
430430

431-
#pragma mark - DB Delegate
431+
#pragma mark - DB and RestClient Delegate -
432+
#pragma mark → DB Delegate
432433
- (void)sessionDidReceiveAuthorizationFailure:(DBSession *)session userId:(NSString *)userId{
434+
433435
}
434436

435-
#pragma mark - RestClient Delegate
437+
#pragma mark RestClient Delegate
436438
- (void)restClient:(DBRestClient*)client loadedMetadata:(DBMetadata*)metadata{
437439
NSLog(@"Loaded Meta Data %@",metadata);
438440
if([metadata.path isEqualToString:project.bundleDirectory.absoluteString]){
@@ -480,7 +482,7 @@ -(void)restClient:(DBRestClient *)client uploadedFile:(NSString *)destPath from:
480482
}
481483
}
482484
else if (fileType == FileTypeIPA){
483-
[self disableEmailFields];
485+
484486
}
485487
[restClient loadSharableLinkForFile:metadata.path shortUrl:NO];
486488
NSString *status = [NSString stringWithFormat:@"Creating Sharable Link for %@",(fileType == FileTypeIPA)?@"IPA":@"Manifest"];
@@ -541,7 +543,26 @@ -(void)restClient:(DBRestClient *)restClientLocal loadedSharableLink:(NSString *
541543
}
542544
}
543545

544-
#pragma mark - Create ShortSharable URL
546+
#pragma mark → Dropbox Helper
547+
- (void)authHelperStateChangedNotification:(NSNotification *)notification {
548+
if ([[DBSession sharedSession] isLinked]) {
549+
[self progressCompletedViewState];
550+
}
551+
}
552+
553+
- (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent {
554+
// This gets called when the user clicks Show "App name". You don't need to do anything for Dropbox here
555+
}
556+
557+
- (DBRestClient *)restClient {
558+
if (!restClient) {
559+
restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
560+
restClient.delegate = self;
561+
}
562+
return restClient;
563+
}
564+
565+
#pragma mark - Create ShortSharable URL -
545566
-(void)createUniqueShortSharableUrl{
546567
NSString *originalURL = [project.uniquelinkShareableURL.absoluteString componentsSeparatedByString:@"dropbox.com"][1];
547568
//create short url
@@ -569,46 +590,12 @@ -(void)createManifestShortSharableUrl{
569590
}];
570591
}
571592

572-
#pragma mark - Completion Process
573-
-(void)showURL{
574-
NSString *status = [NSString stringWithFormat:@"App URL - %@",project.appShortShareableURL.absoluteString];
575-
[self showStatus:status andShowProgressBar:NO withProgress:0];
576-
if (textFieldEmail.stringValue.length > 0 && [Common isValidEmail:textFieldEmail.stringValue]) {
577-
[self performSegueWithIdentifier:@"MailView" sender:self];
578-
}else{
579-
[self performSegueWithIdentifier:@"ShowLink" sender:self];
580-
}
581-
[self progressCompletedViewState];
582-
}
583-
584-
#pragma mark - Dropbox Helper
585-
- (void)authHelperStateChangedNotification:(NSNotification *)notification {
586-
if ([[DBSession sharedSession] isLinked]) {
587-
[self progressCompletedViewState];
588-
}
589-
}
590-
591-
- (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent {
592-
// This gets called when the user clicks Show "App name". You don't need to do anything for Dropbox here
593-
}
594-
595-
- (DBRestClient *)restClient {
596-
if (!restClient) {
597-
restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
598-
restClient.delegate = self;
599-
}
600-
return restClient;
601-
}
602593

603-
#pragma mark - Controller Helper
594+
#pragma mark - Controller Helpers -
604595
-(void)progressCompletedViewState{
605596

606597
}
607598

608-
-(void)disableEmailFields{
609-
610-
}
611-
612599
-(void)resetBuildOptions{
613600
[comboTeamId removeAllItems];
614601
[comboBuildScheme removeAllItems];
@@ -637,13 +624,21 @@ -(void)showStatus:(NSString *)status andShowProgressBar:(BOOL)showProgressBar wi
637624
}
638625
}
639626

640-
-(void)updateBuildButtonState{
641-
BOOL enable = ((comboBuildScheme.stringValue != nil && comboBuildType.stringValue.length > 0 &&
642-
comboBuildType.stringValue != nil && comboBuildType.stringValue.length > 0) || project.ipaFullPath != nil);
627+
-(void)updateViewState{
628+
//update action button
629+
BOOL enable = ((comboBuildScheme.stringValue != nil && comboBuildType.stringValue.length > 0 && //build scheme
630+
comboBuildType.stringValue != nil && comboBuildType.stringValue.length > 0 && //build type
631+
comboTeamId.stringValue != nil && comboTeamId.stringValue.length > 0 && //team id
632+
tabView.selectedTabViewItem.tabState == NSSelectedTab) ||
633+
634+
//if ipa selected
635+
(project.ipaFullPath != nil && tabView.selectedTabViewItem.tabState == NSSelectedTab));
643636
[buttonAction setEnabled:enable];
637+
[buttonAction setTitle:(tabView.selectedTabViewItem.label)];
638+
644639
}
645640

646-
#pragma mark - MailDelegate
641+
#pragma mark - MailDelegate -
647642
-(void)mailViewLoadedWithWebView:(WebView *)webView{
648643

649644
}
@@ -653,6 +648,8 @@ -(void)mailSentWithWebView:(WebView *)webView{
653648
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(60 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
654649
[Common shutdownSystem];
655650
});
651+
}else{
652+
[self performSegueWithIdentifier:@"ShowLink" sender:self];
656653
}
657654
}
658655

@@ -681,6 +678,17 @@ -(void)enableMailField:(BOOL)enable{
681678
}
682679

683680
#pragma mark - Navigation
681+
-(void)showURL{
682+
NSString *status = [NSString stringWithFormat:@"App URL - %@",project.appShortShareableURL.absoluteString];
683+
[self showStatus:status andShowProgressBar:NO withProgress:0];
684+
if (textFieldEmail.stringValue.length > 0 && [Common isValidEmail:textFieldEmail.stringValue]) {
685+
[self performSegueWithIdentifier:@"MailView" sender:self];
686+
}else{
687+
[self performSegueWithIdentifier:@"ShowLink" sender:self];
688+
}
689+
[self progressCompletedViewState];
690+
}
691+
684692
-(void)prepareForSegue:(NSStoryboardSegue *)segue sender:(id)sender{
685693
if ([segue.destinationController isKindOfClass:[ShowLinkViewController class]]) {
686694
((ShowLinkViewController *)segue.destinationController).appLink = project.appShortShareableURL.absoluteString;
@@ -695,4 +703,5 @@ -(void)prepareForSegue:(NSStoryboardSegue *)segue sender:(id)sender{
695703
}
696704
}
697705
}
706+
698707
@end

0 commit comments

Comments
 (0)