Skip to content

Commit

Permalink
Updated code for iOS 10 (iOS)
Browse files Browse the repository at this point in the history
  • Loading branch information
rrgeorge committed Apr 19, 2017
1 parent 6f5fa13 commit 013f7c4
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 18 deletions.
10 changes: 5 additions & 5 deletions external/ISO-8601-date-formatter/ISO8601DateFormatter.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ + (void) purgeGlobalCaches {
}

- (NSCalendar *) makeCalendarWithDesiredConfiguration {
NSCalendar *calendar = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
NSCalendar *calendar = [[[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian] autorelease];
calendar.firstWeekday = 2; //Monday
calendar.timeZone = [NSTimeZone defaultTimeZone];
return calendar;
Expand Down Expand Up @@ -213,7 +213,7 @@ - (NSDateComponents *) dateComponentsFromString:(NSString *)string timeZone:(out
NSDate *now = [NSDate date];

NSDateComponents *components = [[[NSDateComponents alloc] init] autorelease];
NSDateComponents *nowComponents = [parsingCalendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:now];
NSDateComponents *nowComponents = [parsingCalendar components:(NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay) fromDate:now];

NSUInteger
//Date
Expand Down Expand Up @@ -814,13 +814,13 @@ - (NSString *) stringForObjectValue:(id)value {
*/
- (NSString *) weekDateStringForDate:(NSDate *)date timeZone:(NSTimeZone *)timeZone {
unparsingCalendar.timeZone = timeZone;
NSDateComponents *components = [unparsingCalendar components:NSYearCalendarUnit | NSWeekdayCalendarUnit | NSDayCalendarUnit fromDate:date];
NSDateComponents *components = [unparsingCalendar components:NSCalendarUnitYear | NSCalendarUnitWeekday | NSCalendarUnitDay fromDate:date];

//Determine the ordinal date.
NSDateComponents *startOfYearComponents = [unparsingCalendar components:NSYearCalendarUnit fromDate:date];
NSDateComponents *startOfYearComponents = [unparsingCalendar components:NSCalendarUnitYear fromDate:date];
startOfYearComponents.month = 1;
startOfYearComponents.day = 1;
NSDateComponents *ordinalComponents = [unparsingCalendar components:NSDayCalendarUnit fromDate:[unparsingCalendar dateFromComponents:startOfYearComponents] toDate:date options:0];
NSDateComponents *ordinalComponents = [unparsingCalendar components:NSCalendarUnitDay fromDate:[unparsingCalendar dateFromComponents:startOfYearComponents] toDate:date options:0];
ordinalComponents.day += 1;

enum {
Expand Down
2 changes: 1 addition & 1 deletion ios/DockDetailViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ -(CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath
NSString* str = [self attributeForRow: row];

if (str.length > 0) {
CGSize size = [str sizeWithFont: [UIFont systemFontOfSize: 14] constrainedToSize: CGSizeMake(_labelWidth - 5, 9999) lineBreakMode: NSLineBreakByWordWrapping];
CGSize size = [str boundingRectWithSize:CGSizeMake(_labelWidth - 5, 9999) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize: 14]} context:nil].size;
CGFloat rowHeight = size.height + 20;
return rowHeight;
}
Expand Down
4 changes: 2 additions & 2 deletions ios/DockMoveGridView.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ -(void)drawRect:(CGRect)rect
if (j == 0) {
if (hasSpeed) {
NSString* move = [NSString stringWithFormat: @"%d", absSpeed];
CGSize moveStringSize = [move sizeWithFont: font];
CGSize moveStringSize = [move sizeWithAttributes: @{NSFontAttributeName:font}];
CGFloat deltaX = (rowSize - moveStringSize.width) / 2.0;
CGFloat deltaY = (rowSize - moveStringSize.height) / 2.0;
CGPoint movePoint = CGPointMake(x + deltaX, y + deltaY + lineWidth * 0.);
Expand All @@ -120,7 +120,7 @@ -(void)drawRect:(CGRect)rect
[[UIColor whiteColor] set];
}

[move drawAtPoint: movePoint withFont: font];
[move drawAtPoint: movePoint withAttributes: @{NSFontAttributeName:font}];
}
} else if (details != nil) {
NSString* kind = kinds[j - 1];
Expand Down
5 changes: 2 additions & 3 deletions ios/DockResourcesViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,16 @@ -(void)configureCell:(UITableViewCell*)cell atIndexPath:(NSIndexPath*)indexPath
DockResource* resource = resources[row];
cell.textLabel.text = [[resource title] stringByAppendingString:@" "];
cell.textLabel.adjustsFontSizeToFitWidth = YES;
cell.textLabel.adjustsLetterSpacingToFitWidth = YES;
cell.detailTextLabel.text = [[resource costForSquad:_targetSquad] stringValue];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
if (_markExpiredRes) {
DockSet* set = [resource.sets anyObject];
NSCalendar *cal = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSDateComponents *components = [cal components:(NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit) fromDate:set.releaseDate];
NSDateComponents *components = [cal components:(NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay) fromDate:set.releaseDate];
[components setDay:1];

NSDateComponents *ageComponents = [[NSCalendar currentCalendar]
components:NSMonthCalendarUnit
components:NSCalendarUnitMonth
fromDate:[cal dateFromComponents:components]
toDate:[NSDate date] options:0];
if (ageComponents.month >= 18) {
Expand Down
4 changes: 2 additions & 2 deletions ios/DockShipDetailViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ -(CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath
NSString* str = _ship.ability;

if (str.length > 0) {
CGSize size = [str sizeWithFont: [UIFont systemFontOfSize: 14] constrainedToSize: CGSizeMake(_labelWidth - 5, 9999) lineBreakMode: NSLineBreakByWordWrapping];
CGSize size = [str boundingRectWithSize:CGSizeMake(_labelWidth - 5, 9999) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize: 14]} context:nil].size;
CGFloat rowHeight = size.height + 20;
return rowHeight;
}
Expand All @@ -252,7 +252,7 @@ -(CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath
NSString* str = _ship.setName;

if (str.length > 0) {
CGSize size = [str sizeWithFont: [UIFont systemFontOfSize: 14] constrainedToSize: CGSizeMake(_labelWidth - 5, 9999) lineBreakMode: NSLineBreakByWordWrapping];
CGSize size = [str boundingRectWithSize:CGSizeMake(_labelWidth - 5, 9999) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize: 14]} context:nil].size;
CGFloat rowHeight = size.height + 20;
return rowHeight;
}
Expand Down
4 changes: 2 additions & 2 deletions ios/DockSquadDetailController.m
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ - (UITableViewCell *)cellForDetails:(NSIndexPath *)indexPath tableView:(UITableV
if (_markExpiredRes) {
DockSet* set = [_squad.resource.sets anyObject];
NSCalendar *cal = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSDateComponents *components = [cal components:(NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit) fromDate:set.releaseDate];
NSDateComponents *components = [cal components:(NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay) fromDate:set.releaseDate];
[components setDay:1];

NSDateComponents *ageComponents = [[NSCalendar currentCalendar]
components:NSMonthCalendarUnit
components:NSCalendarUnitMonth
fromDate:[cal dateFromComponents:components]
toDate:[NSDate date] options:0];
if (ageComponents.month >= 18) {
Expand Down
5 changes: 2 additions & 3 deletions ios/DockUpgradeDetailViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ -(CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath
NSString* str = _upgrade.ability;

if (str.length > 0) {
CGSize size = [str sizeWithFont: [UIFont systemFontOfSize: 14] constrainedToSize: CGSizeMake(_labelWidth - 5, 9999) lineBreakMode: NSLineBreakByWordWrapping];
CGSize size = [str boundingRectWithSize:CGSizeMake(_labelWidth - 5, 9999) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize: 14]} context:nil].size;
CGFloat rowHeight = size.height + 20;
return rowHeight;
}
Expand All @@ -414,8 +414,7 @@ -(CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath
NSString* str = _upgrade.setName;

if (str.length > 0) {
CGSize size = [str sizeWithFont: [UIFont systemFontOfSize: 14] constrainedToSize: CGSizeMake(_labelWidth - 5, 9999) lineBreakMode: NSLineBreakByWordWrapping];
CGFloat rowHeight = size.height + 20;
CGSize size = [str boundingRectWithSize:CGSizeMake(_labelWidth - 5, 9999) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize: 14]} context:nil].size; CGFloat rowHeight = size.height + 20;
return rowHeight;
}
}
Expand Down

0 comments on commit 013f7c4

Please sign in to comment.