This repository has been archived by the owner on Mar 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
[Dev] Support loading Emission from AppHub #541
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
df608ec
[Dev] Support loading Emission from AppHub
orta 717cbac
[Dev] Improve the AppHub current build button telling you how old you…
orta fc3a438
Merge branch 'master' of https://github.com/artsy/emission into apphu…
orta 401fd2c
[Dev] Revert scheme back to debug
orta e5784f9
Merge master
orta 0dbefdb
[Dev] Addressses feedback in #541
orta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,8 @@ | ||
#import "ARRootViewController.h" | ||
|
||
@class ARSectionData; | ||
@interface ARRootViewController(AppHub) | ||
|
||
- (ARSectionData *)appHubSectionData; | ||
|
||
@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,79 @@ | ||
#import "ARRootViewController+AppHub.h" | ||
#import "NSDateFormatter+TimeAgo.h" | ||
|
||
#import <AppHub/AppHub.h> | ||
#import <ARGenericTableViewController/ARGenericTableViewController.h> | ||
|
||
@implementation ARRootViewController(AppHub) | ||
|
||
- (ARSectionData *)appHubSectionData; | ||
{ | ||
ARSectionData *section = [[ARSectionData alloc] initWithCellDataArray: @[ | ||
[self appHubBuildChooser], | ||
[self appHubMetadata], | ||
[self showPRForBuild] | ||
]]; | ||
section.headerTitle = [@"AppHub" uppercaseString]; | ||
return section; | ||
} | ||
|
||
- (ARCellData *)appHubMetadata | ||
{ | ||
ARCellData *cellData = [[ARCellData alloc] initWithIdentifier:AROptionCell]; | ||
cellData.cellConfigurationBlock = ^(UITableViewCell *cell) { | ||
AHBuild *build = [[AppHub buildManager] currentBuild]; | ||
if (!build) { | ||
cell.textLabel.text = @"Not downloaded yet"; | ||
} if (build && !build.creationDate) { | ||
cell.textLabel.text = @"Current Build: Bundled with Emission"; | ||
} else { | ||
|
||
NSString *timeString = [NSDateFormatter timeAgoFromDate:build.creationDate]; | ||
cell.textLabel.text = [NSString stringWithFormat:@"Current Build: From %@", timeString]; | ||
} | ||
}; | ||
return cellData; | ||
} | ||
|
||
- (ARCellData *)showPRForBuild | ||
{ | ||
ARCellData *cellData = [[ARCellData alloc] initWithIdentifier:AROptionCell]; | ||
AHBuild *build = [[AppHub buildManager] currentBuild]; | ||
NSString *pr = nil; | ||
|
||
if (build && build.buildDescription) { | ||
pr = [[build.buildDescription componentsSeparatedByString:@"- #"] lastObject]; | ||
} | ||
|
||
cellData.cellConfigurationBlock = ^(UITableViewCell *cell) { | ||
if (!pr) { | ||
cell.textLabel.text = @"Not on an AppHub build..."; | ||
} else { | ||
cell.textLabel.text = [NSString stringWithFormat:@"Link to PR %@", pr]; | ||
} | ||
}; | ||
|
||
cellData.cellSelectionBlock = ^(UITableView *tableView, NSIndexPath *indexPath) { | ||
if(pr) { | ||
NSString *prAddresss = [NSString stringWithFormat:@"https://github.com/artsy/emission/pull/%@", pr]; | ||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:prAddresss]]; | ||
} | ||
}; | ||
return cellData; | ||
} | ||
|
||
- (ARCellData *)appHubBuildChooser | ||
{ | ||
ARCellData *cellData = [[ARCellData alloc] initWithIdentifier:AROptionCell]; | ||
cellData.cellConfigurationBlock = ^(UITableViewCell *cell) { | ||
cell.textLabel.text = @"Choose an RN build"; | ||
}; | ||
cellData.cellSelectionBlock = ^(UITableView *tableView, NSIndexPath *indexPath) { | ||
[AppHub presentSelectorOnViewController:self withBuildHandler:^(AHBuild *build, NSError *error) { | ||
[self.tableView reloadData]; | ||
}]; | ||
}; | ||
return cellData; | ||
} | ||
|
||
@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
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
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,10 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
// Based on an implmentation in | ||
// http://stackoverflow.com/questions/902950/iphone-convert-date-string-to-a-relative-time-stamp | ||
|
||
@interface NSDateFormatter (Extras) | ||
|
||
+ (NSString *)timeAgoFromDate:(NSDate *)date; | ||
|
||
@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,45 @@ | ||
#import "NSDateFormatter+TimeAgo.h" | ||
|
||
@implementation NSDateFormatter (Extras) | ||
|
||
+ (NSString *)timeAgoFromDate:(NSDate *)date | ||
{ | ||
NSDate *now = [NSDate date]; | ||
|
||
NSTimeInterval time = [date timeIntervalSinceDate:now]; | ||
time *= -1; | ||
|
||
if(time < 1) { | ||
return @"-"; | ||
|
||
} else if (time < 60) { | ||
return @"less than a minute ago"; | ||
|
||
} else if (time < 3600) { | ||
NSInteger diff = round(time / 60); | ||
if (diff == 1) return @"1 minute ago"; | ||
|
||
return [NSString stringWithFormat:@"%@ minutes ago", @(diff)]; | ||
|
||
} else if (time < 86400) { | ||
NSInteger diff = round(time / 60 / 60); | ||
if (diff == 1) return @"1 hour ago"; | ||
|
||
return [NSString stringWithFormat:@"%@ hours ago", @(diff)]; | ||
|
||
} else if (time < 604800) { | ||
NSInteger diff = round(time / 60 / 60 / 24); | ||
if (diff == 1) return @"yesterday"; | ||
if (diff == 7) return @"last week"; | ||
|
||
return [NSString stringWithFormat:@"%@ days ago", @(diff)]; | ||
|
||
} else { | ||
NSInteger diff = round(time / 60 / 60 / 24 / 7); | ||
if (diff == 1) return @"last week"; | ||
|
||
return [NSString stringWithFormat:@"%@ weeks ago", @(diff)]; | ||
} | ||
} | ||
|
||
@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 |
---|---|---|
|
@@ -24,7 +24,7 @@ target 'Emission' do | |
pod 'Artsy+UIFonts' | ||
|
||
# For easy updating of the JS | ||
pod 'AppHub' | ||
pod 'AppHub', :git => 'https://github.com/orta/apphub.git', :branch => "build_list" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good fix 👍 |
||
|
||
# Native UI tweaks | ||
pod 'FLKAutoLayout' | ||
|
@@ -40,14 +40,14 @@ target 'Emission' do | |
:git => 'https://github.com/artsy/Artsy-Authentication.git', | ||
:branch => 'fetch-user-details' | ||
|
||
target 'EmissionTests' do | ||
inherit! :search_paths | ||
|
||
pod 'React', :path => react_path, :subspecs => %w(RCTTest) | ||
|
||
pod 'Specta' | ||
# pod 'Expecta' | ||
end | ||
# target 'EmissionTests' do | ||
# inherit! :search_paths | ||
# | ||
# pod 'React', :path => react_path, :subspecs => %w(Core RCTTest) | ||
# | ||
# pod 'Specta' | ||
# pod 'Expecta' | ||
# end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair 👍 |
||
end | ||
|
||
post_install do |installer| | ||
|
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you use
ifdef
in the file above but preferif
here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might switch the app entirely to just debug and release, I don't think a third schema is useful as release will not ever be used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use release sometimes to test on a device.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright - I'll keep it around 👍