{"action":"created","comment":{"url":"https://api.github.com/repos/framgia/ShareMe/pulls/comments/85689575","pull_request_review_id":6389981,"id":85689575,"diff_hunk":"@@ -0,0 +1,81 @@\n+//\n+//  ImageDetailCollectionViewCell.m\n+//  ShareMe\n+//\n+//  Created by Nguyen Xuan Thanh on 10/28/16.\n+//  Copyright © 2016 Framgia. All rights reserved.\n+//\n+\n+#import \"ImageDetailCollectionViewCell.h\"\n+\n+@interface ImageDetailCollectionViewCell () {\n+    void (^handleZooming)(BOOL);\n+}\n+\n+@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;\n+@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imageViewTrailingConstraint;\n+@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imageViewBottomConstraint;\n+@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imageViewLeadingConstraint;\n+@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imageViewTopConstraint;\n+\n+@end\n+\n+@implementation ImageDetailCollectionViewCell\n+\n+- (void)setImageDetail:(UIImage *)image withHandler:(void(^)(BOOL isZooming))handler {\n+    self.scrollView.delegate = self;\n+    self.imvDetail.image = image;\n+    [self layoutIfNeeded];\n+    [self updateMinZoomScaleForSize];\n+    [self updateConstraintsForSize];\n+    UITapGestureRecognizer *zoomTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self\n+        action:@selector(zoomWhenDoubleTapped:)];\n+    zoomTapGestureRecognizer.numberOfTapsRequired = 2;\n+    [self.scrollView addGestureRecognizer:zoomTapGestureRecognizer];\n+    handleZooming = handler;\n+}\n+\n+#pragma  mark - UIScrollViewDelegate\n+\n+- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {\n+    return self.imvDetail;\n+}\n+\n+- (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view {\n+    BOOL isZooming = self.scrollView.zoomScale > self.scrollView.minimumZoomScale;\n+    if (handleZooming) {\n+        handleZooming(isZooming);\n+    }\n+}\n+\n+- (void)scrollViewDidZoom:(UIScrollView *)scrollView {\n+    [self updateConstraintsForSize];\n+}\n+\n+- (void)updateMinZoomScaleForSize {\n+    float widthScale = self.contentView.bounds.size.width / self.imvDetail.bounds.size.width;\n+    float heightScale = self.contentView.bounds.size.height / self.imvDetail.bounds.size.height;\n+    float minScale = widthScale < heightScale ? widthScale : heightScale;\n+    self.scrollView.minimumZoomScale = minScale;\n+    self.scrollView.zoomScale = minScale;\n+}\n+\n+- (void)updateConstraintsForSize {\n+    CGFloat xOffset = MAX(0.0f, (self.contentView.bounds.size.width - self.imvDetail.frame.size.width) / 2);\n+    self.imageViewLeadingConstraint.constant = xOffset;\n+    self.imageViewTrailingConstraint.constant = xOffset;\n+    CGFloat yOffset = MAX(0.0f, (self.contentView.bounds.size.height - self.imvDetail.frame.size.height) / 2);\n+    self.imageViewTopConstraint.constant = yOffset;\n+    self.imageViewBottomConstraint.constant = yOffset;\n+    [self layoutIfNeeded];\n+}\n+\n+- (void)zoomWhenDoubleTapped:(UIGestureRecognizer *)gesture {\n+    if (self.scrollView.zoomScale > self.scrollView.minimumZoomScale) {\n+        [self.scrollView setZoomScale:self.scrollView.minimumZoomScale animated:YES];","path":"ShareMe/ShareMe/CollectionViewCell/ImageDetailCollectionViewCell.m","position":75,"original_position":75,"commit_id":"b1e1852af20649e8d935f596f42aed063f182100","original_commit_id":"b1e1852af20649e8d935f596f42aed063f182100","user":{"login":"quocnb","id":4478445,"avatar_url":"https://avatars.githubusercontent.com/u/4478445?v=3","gravatar_id":"","url":"https://api.github.com/users/quocnb","html_url":"https://github.com/quocnb","followers_url":"https://api.github.com/users/quocnb/followers","following_url":"https://api.github.com/users/quocnb/following{/other_user}","gists_url":"https://api.github.com/users/quocnb/gists{/gist_id}","starred_url":"https://api.github.com/users/quocnb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quocnb/subscriptions","organizations_url":"https://api.github.com/users/quocnb/orgs","repos_url":"https://api.github.com/users/quocnb/repos","events_url":"https://api.github.com/users/quocnb/events{/privacy}","received_events_url":"https://api.github.com/users/quocnb/received_events","type":"User","site_admin":false},"body":"có bị nhầm logic chỗ này không, thấy hơi dị dị. Tại sao zoomScale > minScale rồi mà phải ép nó về Min, và < min Scale lại ép nó về max","created_at":"2016-10-31T06:15:45Z","updated_at":"2016-10-31T06:16:44Z","html_url":"https://github.com/framgia/ShareMe/pull/36#discussion_r85689575","pull_request_url":"https://api.github.com/repos/framgia/ShareMe/pulls/36","_links":{"self":{"href":"https://api.github.com/repos/framgia/ShareMe/pulls/comments/85689575"},"html":{"href":"https://github.com/framgia/ShareMe/pull/36#discussion_r85689575"},"pull_request":{"href":"https://api.github.com/repos/framgia/ShareMe/pulls/36"}}},"pull_request":{"url":"https://api.github.com/repos/framgia/ShareMe/pulls/36","id":91559537,"html_url":"https://github.com/framgia/ShareMe/pull/36","diff_url":"https://github.com/framgia/ShareMe/pull/36.diff","patch_url":"https://github.com/framgia/ShareMe/pull/36.patch","issue_url":"https://api.github.com/repos/framgia/ShareMe/issues/36","number":36,"state":"open","locked":false,"title":"add image details","user":{"login":"thanhfnx","id":20332901,"avatar_url":"https://avatars.githubusercontent.com/u/20332901?v=3","gravatar_id":"","url":"https://api.github.com/users/thanhfnx","html_url":"https://github.com/thanhfnx","followers_url":"https://api.github.com/users/thanhfnx/followers","following_url":"https://api.github.com/users/thanhfnx/following{/other_user}","gists_url":"https://api.github.com/users/thanhfnx/gists{/gist_id}","starred_url":"https://api.github.com/users/thanhfnx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thanhfnx/subscriptions","organizations_url":"https://api.github.com/users/thanhfnx/orgs","repos_url":"https://api.github.com/users/thanhfnx/repos","events_url":"https://api.github.com/users/thanhfnx/events{/privacy}","received_events_url":"https://api.github.com/users/thanhfnx/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-31T05:48:13Z","updated_at":"2016-10-31T06:16:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"178e10eca30c01a2b9d61b0ddd086e53ca57f6f4","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/framgia/ShareMe/pulls/36/commits","review_comments_url":"https://api.github.com/repos/framgia/ShareMe/pulls/36/comments","review_comment_url":"https://api.github.com/repos/framgia/ShareMe/pulls/comments{/number}","comments_url":"https://api.github.com/repos/framgia/ShareMe/issues/36/comments","statuses_url":"https://api.github.com/repos/framgia/ShareMe/statuses/b1e1852af20649e8d935f596f42aed063f182100","head":{"label":"thanhfnx:add_image_detail","ref":"add_image_detail","sha":"b1e1852af20649e8d935f596f42aed063f182100","user":{"login":"thanhfnx","id":20332901,"avatar_url":"https://avatars.githubusercontent.com/u/20332901?v=3","gravatar_id":"","url":"https://api.github.com/users/thanhfnx","html_url":"https://github.com/thanhfnx","followers_url":"https://api.github.com/users/thanhfnx/followers","following_url":"https://api.github.com/users/thanhfnx/following{/other_user}","gists_url":"https://api.github.com/users/thanhfnx/gists{/gist_id}","starred_url":"https://api.github.com/users/thanhfnx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thanhfnx/subscriptions","organizations_url":"https://api.github.com/users/thanhfnx/orgs","repos_url":"https://api.github.com/users/thanhfnx/repos","events_url":"https://api.github.com/users/thanhfnx/events{/privacy}","received_events_url":"https://api.github.com/users/thanhfnx/received_events","type":"User","site_admin":false},"repo":{"id":65912833,"name":"ShareMe","full_name":"thanhfnx/ShareMe","owner":{"login":"thanhfnx","id":20332901,"avatar_url":"https://avatars.githubusercontent.com/u/20332901?v=3","gravatar_id":"","url":"https://api.github.com/users/thanhfnx","html_url":"https://github.com/thanhfnx","followers_url":"https://api.github.com/users/thanhfnx/followers","following_url":"https://api.github.com/users/thanhfnx/following{/other_user}","gists_url":"https://api.github.com/users/thanhfnx/gists{/gist_id}","starred_url":"https://api.github.com/users/thanhfnx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thanhfnx/subscriptions","organizations_url":"https://api.github.com/users/thanhfnx/orgs","repos_url":"https://api.github.com/users/thanhfnx/repos","events_url":"https://api.github.com/users/thanhfnx/events{/privacy}","received_events_url":"https://api.github.com/users/thanhfnx/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/thanhfnx/ShareMe","description":"Share Me (training)","fork":true,"url":"https://api.github.com/repos/thanhfnx/ShareMe","forks_url":"https://api.github.com/repos/thanhfnx/ShareMe/forks","keys_url":"https://api.github.com/repos/thanhfnx/ShareMe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thanhfnx/ShareMe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thanhfnx/ShareMe/teams","hooks_url":"https://api.github.com/repos/thanhfnx/ShareMe/hooks","issue_events_url":"https://api.github.com/repos/thanhfnx/ShareMe/issues/events{/number}","events_url":"https://api.github.com/repos/thanhfnx/ShareMe/events","assignees_url":"https://api.github.com/repos/thanhfnx/ShareMe/assignees{/user}","branches_url":"https://api.github.com/repos/thanhfnx/ShareMe/branches{/branch}","tags_url":"https://api.github.com/repos/thanhfnx/ShareMe/tags","blobs_url":"https://api.github.com/repos/thanhfnx/ShareMe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thanhfnx/ShareMe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thanhfnx/ShareMe/git/refs{/sha}","trees_url":"https://api.github.com/repos/thanhfnx/ShareMe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thanhfnx/ShareMe/statuses/{sha}","languages_url":"https://api.github.com/repos/thanhfnx/ShareMe/languages","stargazers_url":"https://api.github.com/repos/thanhfnx/ShareMe/stargazers","contributors_url":"https://api.github.com/repos/thanhfnx/ShareMe/contributors","subscribers_url":"https://api.github.com/repos/thanhfnx/ShareMe/subscribers","subscription_url":"https://api.github.com/repos/thanhfnx/ShareMe/subscription","commits_url":"https://api.github.com/repos/thanhfnx/ShareMe/commits{/sha}","git_commits_url":"https://api.github.com/repos/thanhfnx/ShareMe/git/commits{/sha}","comments_url":"https://api.github.com/repos/thanhfnx/ShareMe/comments{/number}","issue_comment_url":"https://api.github.com/repos/thanhfnx/ShareMe/issues/comments{/number}","contents_url":"https://api.github.com/repos/thanhfnx/ShareMe/contents/{+path}","compare_url":"https://api.github.com/repos/thanhfnx/ShareMe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thanhfnx/ShareMe/merges","archive_url":"https://api.github.com/repos/thanhfnx/ShareMe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thanhfnx/ShareMe/downloads","issues_url":"https://api.github.com/repos/thanhfnx/ShareMe/issues{/number}","pulls_url":"https://api.github.com/repos/thanhfnx/ShareMe/pulls{/number}","milestones_url":"https://api.github.com/repos/thanhfnx/ShareMe/milestones{/number}","notifications_url":"https://api.github.com/repos/thanhfnx/ShareMe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thanhfnx/ShareMe/labels{/name}","releases_url":"https://api.github.com/repos/thanhfnx/ShareMe/releases{/id}","deployments_url":"https://api.github.com/repos/thanhfnx/ShareMe/deployments","created_at":"2016-08-17T14:10:11Z","updated_at":"2016-08-17T11:28:41Z","pushed_at":"2016-10-31T06:02:40Z","git_url":"git://github.com/thanhfnx/ShareMe.git","ssh_url":"git@github.com:thanhfnx/ShareMe.git","clone_url":"https://github.com/thanhfnx/ShareMe.git","svn_url":"https://github.com/thanhfnx/ShareMe","homepage":null,"size":770,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"framgia:develop","ref":"develop","sha":"5872ea314eb2a30c82162bfa0b54b9e791809bd9","user":{"login":"framgia","id":2322183,"avatar_url":"https://avatars.githubusercontent.com/u/2322183?v=3","gravatar_id":"","url":"https://api.github.com/users/framgia","html_url":"https://github.com/framgia","followers_url":"https://api.github.com/users/framgia/followers","following_url":"https://api.github.com/users/framgia/following{/other_user}","gists_url":"https://api.github.com/users/framgia/gists{/gist_id}","starred_url":"https://api.github.com/users/framgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/framgia/subscriptions","organizations_url":"https://api.github.com/users/framgia/orgs","repos_url":"https://api.github.com/users/framgia/repos","events_url":"https://api.github.com/users/framgia/events{/privacy}","received_events_url":"https://api.github.com/users/framgia/received_events","type":"Organization","site_admin":false},"repo":{"id":65902177,"name":"ShareMe","full_name":"framgia/ShareMe","owner":{"login":"framgia","id":2322183,"avatar_url":"https://avatars.githubusercontent.com/u/2322183?v=3","gravatar_id":"","url":"https://api.github.com/users/framgia","html_url":"https://github.com/framgia","followers_url":"https://api.github.com/users/framgia/followers","following_url":"https://api.github.com/users/framgia/following{/other_user}","gists_url":"https://api.github.com/users/framgia/gists{/gist_id}","starred_url":"https://api.github.com/users/framgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/framgia/subscriptions","organizations_url":"https://api.github.com/users/framgia/orgs","repos_url":"https://api.github.com/users/framgia/repos","events_url":"https://api.github.com/users/framgia/events{/privacy}","received_events_url":"https://api.github.com/users/framgia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/framgia/ShareMe","description":"Share Me (training)","fork":false,"url":"https://api.github.com/repos/framgia/ShareMe","forks_url":"https://api.github.com/repos/framgia/ShareMe/forks","keys_url":"https://api.github.com/repos/framgia/ShareMe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/framgia/ShareMe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/framgia/ShareMe/teams","hooks_url":"https://api.github.com/repos/framgia/ShareMe/hooks","issue_events_url":"https://api.github.com/repos/framgia/ShareMe/issues/events{/number}","events_url":"https://api.github.com/repos/framgia/ShareMe/events","assignees_url":"https://api.github.com/repos/framgia/ShareMe/assignees{/user}","branches_url":"https://api.github.com/repos/framgia/ShareMe/branches{/branch}","tags_url":"https://api.github.com/repos/framgia/ShareMe/tags","blobs_url":"https://api.github.com/repos/framgia/ShareMe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/framgia/ShareMe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/framgia/ShareMe/git/refs{/sha}","trees_url":"https://api.github.com/repos/framgia/ShareMe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/framgia/ShareMe/statuses/{sha}","languages_url":"https://api.github.com/repos/framgia/ShareMe/languages","stargazers_url":"https://api.github.com/repos/framgia/ShareMe/stargazers","contributors_url":"https://api.github.com/repos/framgia/ShareMe/contributors","subscribers_url":"https://api.github.com/repos/framgia/ShareMe/subscribers","subscription_url":"https://api.github.com/repos/framgia/ShareMe/subscription","commits_url":"https://api.github.com/repos/framgia/ShareMe/commits{/sha}","git_commits_url":"https://api.github.com/repos/framgia/ShareMe/git/commits{/sha}","comments_url":"https://api.github.com/repos/framgia/ShareMe/comments{/number}","issue_comment_url":"https://api.github.com/repos/framgia/ShareMe/issues/comments{/number}","contents_url":"https://api.github.com/repos/framgia/ShareMe/contents/{+path}","compare_url":"https://api.github.com/repos/framgia/ShareMe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/framgia/ShareMe/merges","archive_url":"https://api.github.com/repos/framgia/ShareMe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/framgia/ShareMe/downloads","issues_url":"https://api.github.com/repos/framgia/ShareMe/issues{/number}","pulls_url":"https://api.github.com/repos/framgia/ShareMe/pulls{/number}","milestones_url":"https://api.github.com/repos/framgia/ShareMe/milestones{/number}","notifications_url":"https://api.github.com/repos/framgia/ShareMe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/framgia/ShareMe/labels{/name}","releases_url":"https://api.github.com/repos/framgia/ShareMe/releases{/id}","deployments_url":"https://api.github.com/repos/framgia/ShareMe/deployments","created_at":"2016-08-17T11:28:41Z","updated_at":"2016-08-17T11:28:41Z","pushed_at":"2016-10-31T06:02:40Z","git_url":"git://github.com/framgia/ShareMe.git","ssh_url":"git@github.com:framgia/ShareMe.git","clone_url":"https://github.com/framgia/ShareMe.git","svn_url":"https://github.com/framgia/ShareMe","homepage":null,"size":773,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/framgia/ShareMe/pulls/36"},"html":{"href":"https://github.com/framgia/ShareMe/pull/36"},"issue":{"href":"https://api.github.com/repos/framgia/ShareMe/issues/36"},"comments":{"href":"https://api.github.com/repos/framgia/ShareMe/issues/36/comments"},"review_comments":{"href":"https://api.github.com/repos/framgia/ShareMe/pulls/36/comments"},"review_comment":{"href":"https://api.github.com/repos/framgia/ShareMe/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/framgia/ShareMe/pulls/36/commits"},"statuses":{"href":"https://api.github.com/repos/framgia/ShareMe/statuses/b1e1852af20649e8d935f596f42aed063f182100"}}}}
{"actor":{"display_login":"quocnb"}}