{"action":"created","comment":{"url":"https://api.github.com/repos/gringoireDM/MERLin/pulls/comments/218058008","pull_request_review_id":155910168,"id":218058008,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxODA1ODAwOA==","diff_hunk":"@@ -0,0 +1,70 @@\n+//\n+//  ThemeConfiguration.swift\n+//  MERLin\n+//\n+//  Created by Giuseppe Lanza on 14/09/18.\n+//  Copyright © 2018 Giuseppe Lanza. All rights reserved.\n+//\n+\n+import Foundation\n+\n+private var staticThemeHandle: UInt8 = 0\n+private var themeHandle: UInt8 = 0\n+public extension UIWindow {\n+    public static var defaultTheme: ThemeProtocol {\n+        get {\n+            return objc_getAssociatedObject(self, &staticThemeHandle) as! ThemeProtocol\n+        } set {\n+            objc_setAssociatedObject(self, &staticThemeHandle, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)\n+            UIApplication.shared.windows.forEach { window in\n+                guard window.theme === newValue else { return }\n+                window.applyTheme(newValue)\n+            }\n+        }\n+    }\n+    \n+    public var theme: ThemeProtocol {\n+        get {\n+            return objc_getAssociatedObject(self, &themeHandle) as? ThemeProtocol ?? UIWindow.defaultTheme\n+        } set {\n+            objc_setAssociatedObject(self, &themeHandle, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)\n+            applyTheme(theme)\n+        }\n+    }\n+    \n+    func applyTheme(_ theme: ThemeProtocol) {\n+        theme.applyAppearance()\n+        for view in subviews {\n+            view.removeFromSuperview()\n+            addSubview(view)\n+        }\n+        \n+        guard let root = rootViewController else { return }\n+        UIWindow.traverseViewControllerStackApplyingTheme(from: root)\n+    }\n+\n+    static func traverseViewControllerStackApplyingTheme(from root: UIViewController) {\n+        //Standard bredth first traversal. View stack is a tree, therefore\n+        //no visited set is needed.\n+        var queue = [root]\n+        while let controller = queue.first {\n+            queue.removeFirst()\n+            (controller as? Themed)?.applyTheme()\n+            queue += controller.children\n+            if let presented = controller.presentedViewController {\n+                queue += [presented]\n+            }\n+        }\n+    }\n+}\n+\n+@objc public extension UIWindow {\n+    @objc public func applyDefaultTheme(overrideLocal: Bool) {\n+        guard overrideLocal || theme === UIWindow.defaultTheme else { return }\n+        applyTheme(UIWindow.defaultTheme)\n+    }\n+}\n+\n+public protocol Themed: UITraitEnvironment {","path":"MERLin/MERLin/Theming/UIWindow+Theme.swift","position":68,"original_position":68,"commit_id":"06980f9f99d65b5eb040fb04d866b153a928a31f","original_commit_id":"06980f9f99d65b5eb040fb04d866b153a928a31f","user":{"login":"gringoireDM","id":5121938,"node_id":"MDQ6VXNlcjUxMjE5Mzg=","avatar_url":"https://avatars3.githubusercontent.com/u/5121938?v=4","gravatar_id":"","url":"https://api.github.com/users/gringoireDM","html_url":"https://github.com/gringoireDM","followers_url":"https://api.github.com/users/gringoireDM/followers","following_url":"https://api.github.com/users/gringoireDM/following{/other_user}","gists_url":"https://api.github.com/users/gringoireDM/gists{/gist_id}","starred_url":"https://api.github.com/users/gringoireDM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gringoireDM/subscriptions","organizations_url":"https://api.github.com/users/gringoireDM/orgs","repos_url":"https://api.github.com/users/gringoireDM/repos","events_url":"https://api.github.com/users/gringoireDM/events{/privacy}","received_events_url":"https://api.github.com/users/gringoireDM/received_events","type":"User","site_admin":false},"body":"To be sure it's a UIViewController.","created_at":"2018-09-17T12:59:40Z","updated_at":"2018-09-17T12:59:41Z","html_url":"https://github.com/gringoireDM/MERLin/pull/3#discussion_r218058008","pull_request_url":"https://api.github.com/repos/gringoireDM/MERLin/pulls/3","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/gringoireDM/MERLin/pulls/comments/218058008"},"html":{"href":"https://github.com/gringoireDM/MERLin/pull/3#discussion_r218058008"},"pull_request":{"href":"https://api.github.com/repos/gringoireDM/MERLin/pulls/3"}},"in_reply_to_id":218032920},"pull_request":{"url":"https://api.github.com/repos/gringoireDM/MERLin/pulls/3","id":215830181,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE1ODMwMTgx","html_url":"https://github.com/gringoireDM/MERLin/pull/3","diff_url":"https://github.com/gringoireDM/MERLin/pull/3.diff","patch_url":"https://github.com/gringoireDM/MERLin/pull/3.patch","issue_url":"https://api.github.com/repos/gringoireDM/MERLin/issues/3","number":3,"state":"open","locked":false,"title":"Theme propagation","user":{"login":"gringoireDM","id":5121938,"node_id":"MDQ6VXNlcjUxMjE5Mzg=","avatar_url":"https://avatars3.githubusercontent.com/u/5121938?v=4","gravatar_id":"","url":"https://api.github.com/users/gringoireDM","html_url":"https://github.com/gringoireDM","followers_url":"https://api.github.com/users/gringoireDM/followers","following_url":"https://api.github.com/users/gringoireDM/following{/other_user}","gists_url":"https://api.github.com/users/gringoireDM/gists{/gist_id}","starred_url":"https://api.github.com/users/gringoireDM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gringoireDM/subscriptions","organizations_url":"https://api.github.com/users/gringoireDM/orgs","repos_url":"https://api.github.com/users/gringoireDM/repos","events_url":"https://api.github.com/users/gringoireDM/events{/privacy}","received_events_url":"https://api.github.com/users/gringoireDM/received_events","type":"User","site_admin":false},"body":"This is a first look the the new theme system.\r\n\r\n`ResettableAppearence` is introduced in this PR. This class should be use instead of `UIAppearance` in order to have reset behaviour. It solves the problem that UIAppearance changes cannot be reset for new components. Unfortunately at this point the problem of existing components is still existing, hence, if the new theme does not override the appearance properties set in the previous theme, these will stay until the new component is recreated.\r\n\r\nThe ThemeContainer was removed and the defaultTheme is now moved in a UIWindow extension. \r\n\r\nApparently Theme is now completely detached from the concept of Module, and in the future it might become a pod itself as it's independent from MERLin.\r\n\r\nThe sample project has a working example of theme switching.","created_at":"2018-09-16T15:47:52Z","updated_at":"2018-09-17T12:59:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2ec1a4201cc5fd9b59a732f5d2fbf251e5545533","assignee":{"login":"gringoireDM","id":5121938,"node_id":"MDQ6VXNlcjUxMjE5Mzg=","avatar_url":"https://avatars3.githubusercontent.com/u/5121938?v=4","gravatar_id":"","url":"https://api.github.com/users/gringoireDM","html_url":"https://github.com/gringoireDM","followers_url":"https://api.github.com/users/gringoireDM/followers","following_url":"https://api.github.com/users/gringoireDM/following{/other_user}","gists_url":"https://api.github.com/users/gringoireDM/gists{/gist_id}","starred_url":"https://api.github.com/users/gringoireDM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gringoireDM/subscriptions","organizations_url":"https://api.github.com/users/gringoireDM/orgs","repos_url":"https://api.github.com/users/gringoireDM/repos","events_url":"https://api.github.com/users/gringoireDM/events{/privacy}","received_events_url":"https://api.github.com/users/gringoireDM/received_events","type":"User","site_admin":false},"assignees":[{"login":"gringoireDM","id":5121938,"node_id":"MDQ6VXNlcjUxMjE5Mzg=","avatar_url":"https://avatars3.githubusercontent.com/u/5121938?v=4","gravatar_id":"","url":"https://api.github.com/users/gringoireDM","html_url":"https://github.com/gringoireDM","followers_url":"https://api.github.com/users/gringoireDM/followers","following_url":"https://api.github.com/users/gringoireDM/following{/other_user}","gists_url":"https://api.github.com/users/gringoireDM/gists{/gist_id}","starred_url":"https://api.github.com/users/gringoireDM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gringoireDM/subscriptions","organizations_url":"https://api.github.com/users/gringoireDM/orgs","repos_url":"https://api.github.com/users/gringoireDM/repos","events_url":"https://api.github.com/users/gringoireDM/events{/privacy}","received_events_url":"https://api.github.com/users/gringoireDM/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/gringoireDM/MERLin/pulls/3/commits","review_comments_url":"https://api.github.com/repos/gringoireDM/MERLin/pulls/3/comments","review_comment_url":"https://api.github.com/repos/gringoireDM/MERLin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gringoireDM/MERLin/issues/3/comments","statuses_url":"https://api.github.com/repos/gringoireDM/MERLin/statuses/06980f9f99d65b5eb040fb04d866b153a928a31f","head":{"label":"gringoireDM:theme_propagation","ref":"theme_propagation","sha":"06980f9f99d65b5eb040fb04d866b153a928a31f","user":{"login":"gringoireDM","id":5121938,"node_id":"MDQ6VXNlcjUxMjE5Mzg=","avatar_url":"https://avatars3.githubusercontent.com/u/5121938?v=4","gravatar_id":"","url":"https://api.github.com/users/gringoireDM","html_url":"https://github.com/gringoireDM","followers_url":"https://api.github.com/users/gringoireDM/followers","following_url":"https://api.github.com/users/gringoireDM/following{/other_user}","gists_url":"https://api.github.com/users/gringoireDM/gists{/gist_id}","starred_url":"https://api.github.com/users/gringoireDM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gringoireDM/subscriptions","organizations_url":"https://api.github.com/users/gringoireDM/orgs","repos_url":"https://api.github.com/users/gringoireDM/repos","events_url":"https://api.github.com/users/gringoireDM/events{/privacy}","received_events_url":"https://api.github.com/users/gringoireDM/received_events","type":"User","site_admin":false},"repo":{"id":145958938,"node_id":"MDEwOlJlcG9zaXRvcnkxNDU5NTg5Mzg=","name":"MERLin","full_name":"gringoireDM/MERLin","private":false,"owner":{"login":"gringoireDM","id":5121938,"node_id":"MDQ6VXNlcjUxMjE5Mzg=","avatar_url":"https://avatars3.githubusercontent.com/u/5121938?v=4","gravatar_id":"","url":"https://api.github.com/users/gringoireDM","html_url":"https://github.com/gringoireDM","followers_url":"https://api.github.com/users/gringoireDM/followers","following_url":"https://api.github.com/users/gringoireDM/following{/other_user}","gists_url":"https://api.github.com/users/gringoireDM/gists{/gist_id}","starred_url":"https://api.github.com/users/gringoireDM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gringoireDM/subscriptions","organizations_url":"https://api.github.com/users/gringoireDM/orgs","repos_url":"https://api.github.com/users/gringoireDM/repos","events_url":"https://api.github.com/users/gringoireDM/events{/privacy}","received_events_url":"https://api.github.com/users/gringoireDM/received_events","type":"User","site_admin":false},"html_url":"https://github.com/gringoireDM/MERLin","description":"A framework to build an event based, reactive architecture for swift iOS projects","fork":false,"url":"https://api.github.com/repos/gringoireDM/MERLin","forks_url":"https://api.github.com/repos/gringoireDM/MERLin/forks","keys_url":"https://api.github.com/repos/gringoireDM/MERLin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gringoireDM/MERLin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gringoireDM/MERLin/teams","hooks_url":"https://api.github.com/repos/gringoireDM/MERLin/hooks","issue_events_url":"https://api.github.com/repos/gringoireDM/MERLin/issues/events{/number}","events_url":"https://api.github.com/repos/gringoireDM/MERLin/events","assignees_url":"https://api.github.com/repos/gringoireDM/MERLin/assignees{/user}","branches_url":"https://api.github.com/repos/gringoireDM/MERLin/branches{/branch}","tags_url":"https://api.github.com/repos/gringoireDM/MERLin/tags","blobs_url":"https://api.github.com/repos/gringoireDM/MERLin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gringoireDM/MERLin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gringoireDM/MERLin/git/refs{/sha}","trees_url":"https://api.github.com/repos/gringoireDM/MERLin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gringoireDM/MERLin/statuses/{sha}","languages_url":"https://api.github.com/repos/gringoireDM/MERLin/languages","stargazers_url":"https://api.github.com/repos/gringoireDM/MERLin/stargazers","contributors_url":"https://api.github.com/repos/gringoireDM/MERLin/contributors","subscribers_url":"https://api.github.com/repos/gringoireDM/MERLin/subscribers","subscription_url":"https://api.github.com/repos/gringoireDM/MERLin/subscription","commits_url":"https://api.github.com/repos/gringoireDM/MERLin/commits{/sha}","git_commits_url":"https://api.github.com/repos/gringoireDM/MERLin/git/commits{/sha}","comments_url":"https://api.github.com/repos/gringoireDM/MERLin/comments{/number}","issue_comment_url":"https://api.github.com/repos/gringoireDM/MERLin/issues/comments{/number}","contents_url":"https://api.github.com/repos/gringoireDM/MERLin/contents/{+path}","compare_url":"https://api.github.com/repos/gringoireDM/MERLin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gringoireDM/MERLin/merges","archive_url":"https://api.github.com/repos/gringoireDM/MERLin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gringoireDM/MERLin/downloads","issues_url":"https://api.github.com/repos/gringoireDM/MERLin/issues{/number}","pulls_url":"https://api.github.com/repos/gringoireDM/MERLin/pulls{/number}","milestones_url":"https://api.github.com/repos/gringoireDM/MERLin/milestones{/number}","notifications_url":"https://api.github.com/repos/gringoireDM/MERLin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gringoireDM/MERLin/labels{/name}","releases_url":"https://api.github.com/repos/gringoireDM/MERLin/releases{/id}","deployments_url":"https://api.github.com/repos/gringoireDM/MERLin/deployments","created_at":"2018-08-24T07:37:01Z","updated_at":"2018-09-15T00:03:20Z","pushed_at":"2018-09-16T15:47:53Z","git_url":"git://github.com/gringoireDM/MERLin.git","ssh_url":"git@github.com:gringoireDM/MERLin.git","clone_url":"https://github.com/gringoireDM/MERLin.git","svn_url":"https://github.com/gringoireDM/MERLin","homepage":"","size":1776,"stargazers_count":7,"watchers_count":7,"language":"Swift","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1,"open_issues":1,"watchers":7,"default_branch":"master"}},"base":{"label":"gringoireDM:master","ref":"master","sha":"e74e2f44a8a8b59f5adae842bd820d544f90674e","user":{"login":"gringoireDM","id":5121938,"node_id":"MDQ6VXNlcjUxMjE5Mzg=","avatar_url":"https://avatars3.githubusercontent.com/u/5121938?v=4","gravatar_id":"","url":"https://api.github.com/users/gringoireDM","html_url":"https://github.com/gringoireDM","followers_url":"https://api.github.com/users/gringoireDM/followers","following_url":"https://api.github.com/users/gringoireDM/following{/other_user}","gists_url":"https://api.github.com/users/gringoireDM/gists{/gist_id}","starred_url":"https://api.github.com/users/gringoireDM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gringoireDM/subscriptions","organizations_url":"https://api.github.com/users/gringoireDM/orgs","repos_url":"https://api.github.com/users/gringoireDM/repos","events_url":"https://api.github.com/users/gringoireDM/events{/privacy}","received_events_url":"https://api.github.com/users/gringoireDM/received_events","type":"User","site_admin":false},"repo":{"id":145958938,"node_id":"MDEwOlJlcG9zaXRvcnkxNDU5NTg5Mzg=","name":"MERLin","full_name":"gringoireDM/MERLin","private":false,"owner":{"login":"gringoireDM","id":5121938,"node_id":"MDQ6VXNlcjUxMjE5Mzg=","avatar_url":"https://avatars3.githubusercontent.com/u/5121938?v=4","gravatar_id":"","url":"https://api.github.com/users/gringoireDM","html_url":"https://github.com/gringoireDM","followers_url":"https://api.github.com/users/gringoireDM/followers","following_url":"https://api.github.com/users/gringoireDM/following{/other_user}","gists_url":"https://api.github.com/users/gringoireDM/gists{/gist_id}","starred_url":"https://api.github.com/users/gringoireDM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gringoireDM/subscriptions","organizations_url":"https://api.github.com/users/gringoireDM/orgs","repos_url":"https://api.github.com/users/gringoireDM/repos","events_url":"https://api.github.com/users/gringoireDM/events{/privacy}","received_events_url":"https://api.github.com/users/gringoireDM/received_events","type":"User","site_admin":false},"html_url":"https://github.com/gringoireDM/MERLin","description":"A framework to build an event based, reactive architecture for swift iOS projects","fork":false,"url":"https://api.github.com/repos/gringoireDM/MERLin","forks_url":"https://api.github.com/repos/gringoireDM/MERLin/forks","keys_url":"https://api.github.com/repos/gringoireDM/MERLin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gringoireDM/MERLin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gringoireDM/MERLin/teams","hooks_url":"https://api.github.com/repos/gringoireDM/MERLin/hooks","issue_events_url":"https://api.github.com/repos/gringoireDM/MERLin/issues/events{/number}","events_url":"https://api.github.com/repos/gringoireDM/MERLin/events","assignees_url":"https://api.github.com/repos/gringoireDM/MERLin/assignees{/user}","branches_url":"https://api.github.com/repos/gringoireDM/MERLin/branches{/branch}","tags_url":"https://api.github.com/repos/gringoireDM/MERLin/tags","blobs_url":"https://api.github.com/repos/gringoireDM/MERLin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gringoireDM/MERLin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gringoireDM/MERLin/git/refs{/sha}","trees_url":"https://api.github.com/repos/gringoireDM/MERLin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gringoireDM/MERLin/statuses/{sha}","languages_url":"https://api.github.com/repos/gringoireDM/MERLin/languages","stargazers_url":"https://api.github.com/repos/gringoireDM/MERLin/stargazers","contributors_url":"https://api.github.com/repos/gringoireDM/MERLin/contributors","subscribers_url":"https://api.github.com/repos/gringoireDM/MERLin/subscribers","subscription_url":"https://api.github.com/repos/gringoireDM/MERLin/subscription","commits_url":"https://api.github.com/repos/gringoireDM/MERLin/commits{/sha}","git_commits_url":"https://api.github.com/repos/gringoireDM/MERLin/git/commits{/sha}","comments_url":"https://api.github.com/repos/gringoireDM/MERLin/comments{/number}","issue_comment_url":"https://api.github.com/repos/gringoireDM/MERLin/issues/comments{/number}","contents_url":"https://api.github.com/repos/gringoireDM/MERLin/contents/{+path}","compare_url":"https://api.github.com/repos/gringoireDM/MERLin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gringoireDM/MERLin/merges","archive_url":"https://api.github.com/repos/gringoireDM/MERLin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gringoireDM/MERLin/downloads","issues_url":"https://api.github.com/repos/gringoireDM/MERLin/issues{/number}","pulls_url":"https://api.github.com/repos/gringoireDM/MERLin/pulls{/number}","milestones_url":"https://api.github.com/repos/gringoireDM/MERLin/milestones{/number}","notifications_url":"https://api.github.com/repos/gringoireDM/MERLin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gringoireDM/MERLin/labels{/name}","releases_url":"https://api.github.com/repos/gringoireDM/MERLin/releases{/id}","deployments_url":"https://api.github.com/repos/gringoireDM/MERLin/deployments","created_at":"2018-08-24T07:37:01Z","updated_at":"2018-09-15T00:03:20Z","pushed_at":"2018-09-16T15:47:53Z","git_url":"git://github.com/gringoireDM/MERLin.git","ssh_url":"git@github.com:gringoireDM/MERLin.git","clone_url":"https://github.com/gringoireDM/MERLin.git","svn_url":"https://github.com/gringoireDM/MERLin","homepage":"","size":1776,"stargazers_count":7,"watchers_count":7,"language":"Swift","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1,"open_issues":1,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gringoireDM/MERLin/pulls/3"},"html":{"href":"https://github.com/gringoireDM/MERLin/pull/3"},"issue":{"href":"https://api.github.com/repos/gringoireDM/MERLin/issues/3"},"comments":{"href":"https://api.github.com/repos/gringoireDM/MERLin/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/gringoireDM/MERLin/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/gringoireDM/MERLin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gringoireDM/MERLin/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/gringoireDM/MERLin/statuses/06980f9f99d65b5eb040fb04d866b153a928a31f"}},"author_association":"OWNER"}}
{"actor":{"display_login":"gringoireDM"}}