diff --git a/.travis.yml b/.travis.yml index b627ce5..e7182ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: objective-c xcode_workspace: Tests/VTAck Tests.xcworkspace xcode_scheme: VTAck Tests xcode_sdk: iphonesimulator -osx_image: xcode9 +osx_image: xcode11 script: - - xcodebuild test -workspace "Tests/VTAck Tests.xcworkspace" -scheme "VTAck Tests" -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 7,OS=11.0' ONLY_ACTIVE_ARCH=NO + - xcodebuild test -workspace "Tests/VTAck Tests.xcworkspace" -scheme "VTAck Tests" -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 8,OS=13.0' ONLY_ACTIVE_ARCH=NO diff --git a/CHANGELOG.md b/CHANGELOG.md index ea83334..3d63e0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 1.5.2 (work in progress) + +- Improve Dark Mode support + + ## 1.5.1 (4 December 2018) - Improve Dynamic Type support, by @kiancheong diff --git a/Classes/VTAcknowledgementViewController.m b/Classes/VTAcknowledgementViewController.m index 8f156e8..5966183 100644 --- a/Classes/VTAcknowledgementViewController.m +++ b/Classes/VTAcknowledgementViewController.m @@ -68,7 +68,6 @@ - (void)viewDidLoad { textView.panGestureRecognizer.allowedTouchTypes = @[@(UITouchTypeIndirect)]; #endif textView.textContainerInset = UIEdgeInsetsMake(VTTopBottomDefaultMargin, VTLeftRightDefaultMargin, VTTopBottomDefaultMargin, VTLeftRightDefaultMargin); - self.view.backgroundColor = [UIColor whiteColor]; [self.view addSubview:textView]; self.textView = textView; diff --git a/Classes/VTAcknowledgementsViewController.m b/Classes/VTAcknowledgementsViewController.m index cefdbac..6db3929 100644 --- a/Classes/VTAcknowledgementsViewController.m +++ b/Classes/VTAcknowledgementsViewController.m @@ -182,27 +182,68 @@ - (void)viewDidLoad { #endif } -- (UIFont *)headerFooterFont { - if ([UIFont respondsToSelector:@selector(preferredFontForTextStyle:)]) { - return [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote]; +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + + if (self.presentingViewController && self == [self.navigationController.viewControllers firstObject]) { + UIBarButtonItem *doneItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissViewController:)]; +#if !TARGET_OS_TV + self.navigationItem.leftBarButtonItem = doneItem; +#else + // Add a spacer item because the leftBarButtonItem is misplaced on tvOS (doesn't obey the HIG) + UIBarButtonItem *spacerItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; + spacerItem.width = 90.0; + self.navigationItem.leftBarButtonItems = @[spacerItem, doneItem]; +#endif } - else { - return [UIFont systemFontOfSize:12]; + + [self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:animated]; +} + +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + + if (self.acknowledgements.count == 0) { + NSLog(@"** VTAcknowledgementsViewController Warning **"); + NSLog(@"No acknowledgements found."); + NSLog(@"This probably means that you didn’t import the `Pods-acknowledgements.plist` to your main target."); + NSLog(@"Please take a look at https://github.com/vtourraine/VTAcknowledgementsViewController for instructions."); } } -- (void)configureHeaderView { - UIFont *font = [self headerFooterFont]; - CGFloat labelWidth = CGRectGetWidth(self.view.frame) - 2 * VTLabelMargin; - CGFloat labelHeight = [self heightForLabelWithText:self.headerText andWidth:labelWidth]; +- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { + [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; + + [coordinator animateAlongsideTransition:nil completion:^(id _Nonnull context) { + if (self.headerText) { + [self configureHeaderView]; + } + + if (self.footerText) { + [self configureFooterView]; + } + }]; +} - CGRect labelFrame = CGRectMake(VTLabelMargin, VTLabelMargin, labelWidth, labelHeight); +- (UIFont *)headerFooterFont { + return [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote]; +} - UILabel *label = [[UILabel alloc] initWithFrame:labelFrame]; - label.text = self.headerText; +- (UILabel *)headerFooterLabelWithText:(NSString *)text { + UIFont *font = self.headerFooterFont; + CGFloat width = CGRectGetWidth(self.view.frame) - 2 * VTLabelMargin; + CGFloat height = [self heightForLabelWithText:text andWidth:width]; + CGRect frame = CGRectMake(VTLabelMargin, VTLabelMargin, width, height); + + UILabel *label = [[UILabel alloc] initWithFrame:frame]; + label.text = text; label.font = font; - label.textColor = [UIColor grayColor]; - label.backgroundColor = [UIColor clearColor]; + if (@available(iOS 13.0, *)) { + label.textColor = [UIColor secondaryLabelColor]; + } + else { + label.textColor = [UIColor grayColor]; + } label.numberOfLines = 0; label.textAlignment = NSTextAlignmentCenter; label.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin); @@ -210,6 +251,11 @@ - (void)configureHeaderView { label.adjustsFontForContentSizeCategory = YES; } + return label; +} + +- (void)configureHeaderView { + UILabel *label = [self headerFooterLabelWithText:self.headerText]; CGRect headerFrame = CGRectMake(0, 0, CGRectGetWidth(self.view.frame), CGRectGetHeight(label.frame) + 2 * VTLabelMargin); UIView *headerView = [[UIView alloc] initWithFrame:headerFrame]; [headerView addSubview:label]; @@ -217,28 +263,12 @@ - (void)configureHeaderView { } - (void)configureFooterView { - UIFont *font = [self headerFooterFont]; - CGFloat labelWidth = CGRectGetWidth(self.view.frame) - 2 * VTLabelMargin; - CGFloat labelHeight = [self heightForLabelWithText:self.footerText andWidth:labelWidth]; - - CGRect labelFrame = CGRectMake(VTLabelMargin, 0, labelWidth, labelHeight); - - UILabel *label = [[UILabel alloc] initWithFrame:labelFrame]; - label.text = self.footerText; - label.font = font; - label.textColor = [UIColor grayColor]; - label.backgroundColor = [UIColor clearColor]; - label.numberOfLines = 0; - label.textAlignment = NSTextAlignmentCenter; - label.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin); - label.userInteractionEnabled = YES; - if (@available(iOS 10.0, *)) { - label.adjustsFontForContentSizeCategory = YES; - } + UILabel *label = [self headerFooterLabelWithText:self.footerText]; if ([self.footerText rangeOfString:[NSURL URLWithString:VTCocoaPodsURLString].host].location != NSNotFound) { UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(openCocoaPodsWebsite:)]; [label addGestureRecognizer:tapGestureRecognizer]; + label.userInteractionEnabled = YES; } CGRect footerFrame = CGRectMake(0, 0, CGRectGetWidth(label.frame), CGRectGetHeight(label.frame) + VTFooterBottomMargin); @@ -273,49 +303,6 @@ - (CGFloat)heightForLabelWithText:(NSString *)labelText andWidth:(CGFloat)labelW return ceilf(labelHeight); } -- (void)viewWillAppear:(BOOL)animated { - [super viewWillAppear:animated]; - - if (self.presentingViewController && self == [self.navigationController.viewControllers firstObject]) { - UIBarButtonItem *doneItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissViewController:)]; -#if !TARGET_OS_TV - self.navigationItem.leftBarButtonItem = doneItem; -#else - // Add a spacer item because the leftBarButtonItem is misplaced on tvOS (doesn't obey the HIG) - UIBarButtonItem *spacerItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; - spacerItem.width = 90.0; - self.navigationItem.leftBarButtonItems = @[spacerItem, doneItem]; -#endif - } - - [self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:animated]; -} - -- (void)viewDidAppear:(BOOL)animated { - [super viewDidAppear:animated]; - - if (self.acknowledgements.count == 0) { - NSLog(@"** VTAcknowledgementsViewController Warning **"); - NSLog(@"No acknowledgements found."); - NSLog(@"This probably means that you didn’t import the `Pods-acknowledgements.plist` to your main target."); - NSLog(@"Please take a look at https://github.com/vtourraine/VTAcknowledgementsViewController for instructions."); - } -} - -- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { - [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; - - [coordinator animateAlongsideTransition:nil completion:^(id _Nonnull context) { - if (self.headerText) { - [self configureHeaderView]; - } - - if (self.footerText) { - [self configureFooterView]; - } - }]; -} - #pragma mark - Actions - (void)openCocoaPodsWebsite:(id)sender {