Skip to content
This repository has been archived by the owner on Feb 3, 2022. It is now read-only.

Commit

Permalink
- Added full screen image viewer
Browse files Browse the repository at this point in the history
- Replaced Chamaleon Framework with ColorArt
  • Loading branch information
lucamozzarelli committed Mar 8, 2017
1 parent 0db10f0 commit 5ca61ee
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 28 deletions.
8 changes: 5 additions & 3 deletions LMArticleViewController.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Pod::Spec.new do |s|


s.name = "LMArticleViewController"
s.version = "1.3"
s.version = "1.4"
s.summary = "An Objective-C subclass of UIViewController inspired by Apple News"
s.description = "This subclass of UIViewController provides an article view controller with one top image, title, date, author and body labels."

Expand All @@ -14,13 +14,15 @@ Pod::Spec.new do |s|

s.platform = :ios, "9.0"

s.source = { :git => "https://github.com/lucamozza/LMArticleViewController.git", :tag => 'v1.3'}
s.source = { :git => "https://github.com/lucamozza/LMArticleViewController.git", :tag => 'v1.4'}

s.source_files = "LMArticleViewController", "LMArticleViewController/**/*.{h,m}"
# s.exclude_files = "Classes/Exclude"

# s.public_header_files = "Classes/**/*.h"

s.dependency 'ChameleonFramework'
s.dependency 'ColorArt'
s.dependency 'TLYShyNavBar'
s.dependency 'IDMPhotoBrowser'

end
30 changes: 26 additions & 4 deletions LMArticleViewController/LMArticleViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

#import "LMArticleViewController.h"
#import <TLYShyNavBar/TLYShyNavBarManager.h>
#import <ChameleonFramework/Chameleon.h>
#import <ColorArt/UIImage+ColorArt.h>
#import <IDMPhotoBrowser/IDMPhotoBrowser.h>

@interface LMArticleViewController () {
BOOL backgroundColorSet;
Expand Down Expand Up @@ -143,6 +144,11 @@ - (void)setupImageView {
self.imageView.contentMode = self.imageViewContentMode;

self.imageView.clipsToBounds = YES;

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(openImage)];
singleTap.numberOfTapsRequired = 1;
self.imageView.userInteractionEnabled = YES;
[self.imageView addGestureRecognizer:singleTap];
}

- (void)setupHeadline {
Expand Down Expand Up @@ -266,8 +272,12 @@ - (void)setImage:(UIImage *)image {
self.heightConstraint.constant = imageViewHeight;

if ( self.autoColored ) {
self.backgroundColor = [UIColor colorWithAverageColorFromImage:image];
self.textColor = [UIColor colorWithContrastingBlackOrWhiteColorOn:self.backgroundColor isFlat:NO];
SLColorArt *colorArt = [image colorArt];
self.backgroundColor = colorArt.backgroundColor;
self.headlineColor = colorArt.primaryColor;
self.dateColor = colorArt.secondaryColor;
self.authorColor = colorArt.secondaryColor;
self.bodyColor = colorArt.detailColor;
}

}
Expand Down Expand Up @@ -334,6 +344,11 @@ - (void)setBodyColor:(UIColor *)bodyColor {
_bodyColor = bodyColor;
bodyColorSet = YES;
self.bodyTextView.textColor = bodyColor;
if (self.attributedBody) {
NSMutableAttributedString *mutable = self.attributedBody.mutableCopy;
[mutable addAttribute:NSForegroundColorAttributeName value:bodyColor range:NSMakeRange(0, self.attributedBody.length)];
self.attributedBody = mutable;
}
}

- (void)setTextColor:(UIColor *)textColor {
Expand Down Expand Up @@ -395,7 +410,6 @@ - (UITextView *)bodyTextView {
// Animation

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {

if ( self.stretchImageView ) {

// Animate imageview when bouncing
Expand All @@ -408,6 +422,14 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
}
}

- (void)openImage {
IDMPhoto *photo = [IDMPhoto photoWithImage:self.image];
IDMPhotoBrowser *browser = [[IDMPhotoBrowser alloc]initWithPhotos:@[photo]animatedFromView:self.imageView];
browser.scaleImage = self.image;
browser.displayActionButton = NO;
[self presentViewController:browser animated:YES completion:^{}];
}

// Links
- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange {
return YES;
Expand Down
21 changes: 0 additions & 21 deletions license.txt

This file was deleted.

0 comments on commit 5ca61ee

Please sign in to comment.