{"action":"created","comment":{"url":"https://api.github.com/repos/SoySauceLab/CollectionKit/pulls/comments/137106895","pull_request_review_id":60731920,"id":137106895,"diff_hunk":"@@ -0,0 +1,151 @@\n+//\n+//  ReloadDataViewController.swift\n+//  CollectionKit\n+//\n+//  Created by yansong li on 2017-09-04.\n+//  Copyright © 2017 lkzhao. All rights reserved.\n+//\n+\n+import UIKit\n+import CollectionKit\n+\n+let maxDataCount: Int = 1000\n+\n+class ReloadDataViewController: CollectionViewController {\n+  var data: [Int] = []\n+  var dataSet: Set<Int> = Set()\n+\n+  let addButton: UIButton = {\n+    let button = UIButton()\n+    let addAttributedTitle =\n+        NSAttributedString(string: \"+\",\n+                           attributes: [NSFontAttributeName : UIFont.boldSystemFont(ofSize: 20)])\n+    button.setTitleColor(.black, for: .normal)\n+    button.setAttributedTitle(addAttributedTitle, for: .normal)\n+    button.backgroundColor = UIColor(hue: 0.16, saturation: 0.68, brightness: 0.98, alpha: 1)\n+    return button\n+  }()\n+\n+  let removeButton: UIButton = {\n+    let button = UIButton()\n+    let removeAttributedTitle =\n+      NSAttributedString(string: \"-\",\n+                         attributes: [NSFontAttributeName : UIFont.boldSystemFont(ofSize: 20)])\n+    button.setAttributedTitle(removeAttributedTitle, for: .normal)\n+    button.setTitleColor(.black, for: .normal)\n+    button.backgroundColor = UIColor(hue: 0.20, saturation: 0.68, brightness: 0.98, alpha: 1)\n+    return button\n+  }()\n+\n+  let reloadButton: UIButton = {\n+    let button = UIButton()\n+    button.setTitle(\"Reset\", for: .normal)\n+    button.setTitleColor(.black, for: .normal)\n+    button.backgroundColor = UIColor(hue: 0.22, saturation: 0.68, brightness: 0.98, alpha: 1)\n+    return button\n+  }()\n+\n+  override func viewDidLoad() {\n+    super.viewDidLoad()\n+    view.backgroundColor = .white\n+    addButton.addTarget(self, action: #selector(add), for: .touchUpInside)\n+    view.addSubview(addButton)\n+    removeButton.addTarget(self, action: #selector(remove), for: .touchUpInside)\n+    view.addSubview(removeButton)\n+    reloadButton.addTarget(self, action: #selector(reload), for: .touchUpInside)\n+    view.addSubview(reloadButton)\n+\n+    let dataProvider = ArrayDataProvider(data: data, identifierMapper: { (_, data) in\n+      return \"\\(data)\"\n+    })\n+    let layout = FlowLayout<Int>(insets: UIEdgeInsetsMake(15, 15, 15, 15),\n+                                 lineSpacing: 15,\n+                                 interitemSpacing: 15)\n+    let presenter = ZoomPresenter()\n+    presenter.insertAnimation = .scale\n+    presenter.deleteAnimation = .scale\n+    provider = CollectionProvider(\n+      dataProvider: dataProvider,\n+      viewUpdater: { (view: UILabel, data: Int, index: Int) in\n+        view.backgroundColor = UIColor(hue: CGFloat(data) / CGFloat(maxDataCount),\n+                                       saturation: 0.68,\n+                                       brightness: 0.98,\n+                                       alpha: 1)\n+        view.textColor = .white\n+        view.textAlignment = .center\n+        view.text = \"\\(data)\"\n+      },\n+      layout: layout,\n+      sizeProvider: { _, _, _ in\n+        return CGSize(width: 60, height: 60)","path":"Examples/ReloadDataExample/ReloadDataViewController.swift","position":80,"original_position":80,"commit_id":"cbd36923a5b230a1d8876854255d5ba0bfb8e45b","original_commit_id":"cbd36923a5b230a1d8876854255d5ba0bfb8e45b","user":{"login":"lkzhao","id":3359850,"avatar_url":"https://avatars1.githubusercontent.com/u/3359850?v=4","gravatar_id":"","url":"https://api.github.com/users/lkzhao","html_url":"https://github.com/lkzhao","followers_url":"https://api.github.com/users/lkzhao/followers","following_url":"https://api.github.com/users/lkzhao/following{/other_user}","gists_url":"https://api.github.com/users/lkzhao/gists{/gist_id}","starred_url":"https://api.github.com/users/lkzhao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lkzhao/subscriptions","organizations_url":"https://api.github.com/users/lkzhao/orgs","repos_url":"https://api.github.com/users/lkzhao/repos","events_url":"https://api.github.com/users/lkzhao/events{/privacy}","received_events_url":"https://api.github.com/users/lkzhao/received_events","type":"User","site_admin":false},"body":"Let do some calculation here so they don't leave empty spaces on the right hand side.\r\nA trick that I usually do is to divide the collection size with a preferred width to get a column count. Then use this column count to figure out the cell size.\r\nsizeProvider: { _, _, collectionSize in \r\n  let columns = max(1, Int(collectionSize.width / 60))\r\n  let cellWidth = collectionSize.width / columns\r\n  return CGSize(width: cellWidth height: cellWidth)\r\n}","created_at":"2017-09-05T20:36:13Z","updated_at":"2017-09-05T20:36:13Z","html_url":"https://github.com/SoySauceLab/CollectionKit/pull/24#discussion_r137106895","pull_request_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/pulls/24","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/SoySauceLab/CollectionKit/pulls/comments/137106895"},"html":{"href":"https://github.com/SoySauceLab/CollectionKit/pull/24#discussion_r137106895"},"pull_request":{"href":"https://api.github.com/repos/SoySauceLab/CollectionKit/pulls/24"}}},"pull_request":{"url":"https://api.github.com/repos/SoySauceLab/CollectionKit/pulls/24","id":139234268,"html_url":"https://github.com/SoySauceLab/CollectionKit/pull/24","diff_url":"https://github.com/SoySauceLab/CollectionKit/pull/24.diff","patch_url":"https://github.com/SoySauceLab/CollectionKit/pull/24.patch","issue_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/issues/24","number":24,"state":"open","locked":false,"title":"Add in ReloadDataViewController.","user":{"login":"jindulys","id":1540225,"avatar_url":"https://avatars1.githubusercontent.com/u/1540225?v=4","gravatar_id":"","url":"https://api.github.com/users/jindulys","html_url":"https://github.com/jindulys","followers_url":"https://api.github.com/users/jindulys/followers","following_url":"https://api.github.com/users/jindulys/following{/other_user}","gists_url":"https://api.github.com/users/jindulys/gists{/gist_id}","starred_url":"https://api.github.com/users/jindulys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jindulys/subscriptions","organizations_url":"https://api.github.com/users/jindulys/orgs","repos_url":"https://api.github.com/users/jindulys/repos","events_url":"https://api.github.com/users/jindulys/events{/privacy}","received_events_url":"https://api.github.com/users/jindulys/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-09-05T04:06:28Z","updated_at":"2017-09-05T20:36:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9044307a4429930ad6cd5b7d2678056f8b0056b5","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/pulls/24/commits","review_comments_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/pulls/24/comments","review_comment_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/issues/24/comments","statuses_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/statuses/cbd36923a5b230a1d8876854255d5ba0bfb8e45b","head":{"label":"SoySauceLab:reload","ref":"reload","sha":"cbd36923a5b230a1d8876854255d5ba0bfb8e45b","user":{"login":"SoySauceLab","id":18728991,"avatar_url":"https://avatars3.githubusercontent.com/u/18728991?v=4","gravatar_id":"","url":"https://api.github.com/users/SoySauceLab","html_url":"https://github.com/SoySauceLab","followers_url":"https://api.github.com/users/SoySauceLab/followers","following_url":"https://api.github.com/users/SoySauceLab/following{/other_user}","gists_url":"https://api.github.com/users/SoySauceLab/gists{/gist_id}","starred_url":"https://api.github.com/users/SoySauceLab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SoySauceLab/subscriptions","organizations_url":"https://api.github.com/users/SoySauceLab/orgs","repos_url":"https://api.github.com/users/SoySauceLab/repos","events_url":"https://api.github.com/users/SoySauceLab/events{/privacy}","received_events_url":"https://api.github.com/users/SoySauceLab/received_events","type":"Organization","site_admin":false},"repo":{"id":98057833,"name":"CollectionKit","full_name":"SoySauceLab/CollectionKit","owner":{"login":"SoySauceLab","id":18728991,"avatar_url":"https://avatars3.githubusercontent.com/u/18728991?v=4","gravatar_id":"","url":"https://api.github.com/users/SoySauceLab","html_url":"https://github.com/SoySauceLab","followers_url":"https://api.github.com/users/SoySauceLab/followers","following_url":"https://api.github.com/users/SoySauceLab/following{/other_user}","gists_url":"https://api.github.com/users/SoySauceLab/gists{/gist_id}","starred_url":"https://api.github.com/users/SoySauceLab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SoySauceLab/subscriptions","organizations_url":"https://api.github.com/users/SoySauceLab/orgs","repos_url":"https://api.github.com/users/SoySauceLab/repos","events_url":"https://api.github.com/users/SoySauceLab/events{/privacy}","received_events_url":"https://api.github.com/users/SoySauceLab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SoySauceLab/CollectionKit","description":"A modern Swift framework for building reusable data-driven collection components.","fork":false,"url":"https://api.github.com/repos/SoySauceLab/CollectionKit","forks_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/forks","keys_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/teams","hooks_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/hooks","issue_events_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/issues/events{/number}","events_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/events","assignees_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/assignees{/user}","branches_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/branches{/branch}","tags_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/tags","blobs_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/git/refs{/sha}","trees_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/statuses/{sha}","languages_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/languages","stargazers_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/stargazers","contributors_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/contributors","subscribers_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/subscribers","subscription_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/subscription","commits_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/commits{/sha}","git_commits_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/git/commits{/sha}","comments_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/comments{/number}","issue_comment_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/issues/comments{/number}","contents_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/contents/{+path}","compare_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/merges","archive_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/downloads","issues_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/issues{/number}","pulls_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/pulls{/number}","milestones_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/milestones{/number}","notifications_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/labels{/name}","releases_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/releases{/id}","deployments_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/deployments","created_at":"2017-07-22T21:06:01Z","updated_at":"2017-08-30T02:46:32Z","pushed_at":"2017-09-05T04:06:28Z","git_url":"git://github.com/SoySauceLab/CollectionKit.git","ssh_url":"git@github.com:SoySauceLab/CollectionKit.git","clone_url":"https://github.com/SoySauceLab/CollectionKit.git","svn_url":"https://github.com/SoySauceLab/CollectionKit","homepage":"","size":788,"stargazers_count":10,"watchers_count":10,"language":"Swift","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":2,"forks":4,"open_issues":2,"watchers":10,"default_branch":"master"}},"base":{"label":"SoySauceLab:master","ref":"master","sha":"c65b9f568077041499d9b47227c958f71a306f67","user":{"login":"SoySauceLab","id":18728991,"avatar_url":"https://avatars3.githubusercontent.com/u/18728991?v=4","gravatar_id":"","url":"https://api.github.com/users/SoySauceLab","html_url":"https://github.com/SoySauceLab","followers_url":"https://api.github.com/users/SoySauceLab/followers","following_url":"https://api.github.com/users/SoySauceLab/following{/other_user}","gists_url":"https://api.github.com/users/SoySauceLab/gists{/gist_id}","starred_url":"https://api.github.com/users/SoySauceLab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SoySauceLab/subscriptions","organizations_url":"https://api.github.com/users/SoySauceLab/orgs","repos_url":"https://api.github.com/users/SoySauceLab/repos","events_url":"https://api.github.com/users/SoySauceLab/events{/privacy}","received_events_url":"https://api.github.com/users/SoySauceLab/received_events","type":"Organization","site_admin":false},"repo":{"id":98057833,"name":"CollectionKit","full_name":"SoySauceLab/CollectionKit","owner":{"login":"SoySauceLab","id":18728991,"avatar_url":"https://avatars3.githubusercontent.com/u/18728991?v=4","gravatar_id":"","url":"https://api.github.com/users/SoySauceLab","html_url":"https://github.com/SoySauceLab","followers_url":"https://api.github.com/users/SoySauceLab/followers","following_url":"https://api.github.com/users/SoySauceLab/following{/other_user}","gists_url":"https://api.github.com/users/SoySauceLab/gists{/gist_id}","starred_url":"https://api.github.com/users/SoySauceLab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SoySauceLab/subscriptions","organizations_url":"https://api.github.com/users/SoySauceLab/orgs","repos_url":"https://api.github.com/users/SoySauceLab/repos","events_url":"https://api.github.com/users/SoySauceLab/events{/privacy}","received_events_url":"https://api.github.com/users/SoySauceLab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SoySauceLab/CollectionKit","description":"A modern Swift framework for building reusable data-driven collection components.","fork":false,"url":"https://api.github.com/repos/SoySauceLab/CollectionKit","forks_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/forks","keys_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/teams","hooks_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/hooks","issue_events_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/issues/events{/number}","events_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/events","assignees_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/assignees{/user}","branches_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/branches{/branch}","tags_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/tags","blobs_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/git/refs{/sha}","trees_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/statuses/{sha}","languages_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/languages","stargazers_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/stargazers","contributors_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/contributors","subscribers_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/subscribers","subscription_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/subscription","commits_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/commits{/sha}","git_commits_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/git/commits{/sha}","comments_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/comments{/number}","issue_comment_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/issues/comments{/number}","contents_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/contents/{+path}","compare_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/merges","archive_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/downloads","issues_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/issues{/number}","pulls_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/pulls{/number}","milestones_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/milestones{/number}","notifications_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/labels{/name}","releases_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/releases{/id}","deployments_url":"https://api.github.com/repos/SoySauceLab/CollectionKit/deployments","created_at":"2017-07-22T21:06:01Z","updated_at":"2017-08-30T02:46:32Z","pushed_at":"2017-09-05T04:06:28Z","git_url":"git://github.com/SoySauceLab/CollectionKit.git","ssh_url":"git@github.com:SoySauceLab/CollectionKit.git","clone_url":"https://github.com/SoySauceLab/CollectionKit.git","svn_url":"https://github.com/SoySauceLab/CollectionKit","homepage":"","size":788,"stargazers_count":10,"watchers_count":10,"language":"Swift","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":2,"forks":4,"open_issues":2,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SoySauceLab/CollectionKit/pulls/24"},"html":{"href":"https://github.com/SoySauceLab/CollectionKit/pull/24"},"issue":{"href":"https://api.github.com/repos/SoySauceLab/CollectionKit/issues/24"},"comments":{"href":"https://api.github.com/repos/SoySauceLab/CollectionKit/issues/24/comments"},"review_comments":{"href":"https://api.github.com/repos/SoySauceLab/CollectionKit/pulls/24/comments"},"review_comment":{"href":"https://api.github.com/repos/SoySauceLab/CollectionKit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SoySauceLab/CollectionKit/pulls/24/commits"},"statuses":{"href":"https://api.github.com/repos/SoySauceLab/CollectionKit/statuses/cbd36923a5b230a1d8876854255d5ba0bfb8e45b"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"lkzhao"}}