{"action":"created","comment":{"url":"https://api.github.com/repos/xi-editor/xi-mac/pulls/comments/223221622","pull_request_review_id":162298214,"id":223221622,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMzIyMTYyMg==","diff_hunk":"@@ -50,6 +50,8 @@ class EditViewController: NSViewController, EditViewDataSource, FindDelegate, Sc\n \n     @IBOutlet weak var editViewHeight: NSLayoutConstraint!\n     @IBOutlet weak var editViewWidth: NSLayoutConstraint!\n+    \n+    let appDelegate = NSApp.delegate as! AppDelegate","path":"XiEditor/EditViewController.swift","position":5,"original_position":5,"commit_id":"c42512ef3c347084a286a9b6faf230aa8dc3eb88","original_commit_id":"c42512ef3c347084a286a9b6faf230aa8dc3eb88","user":{"login":"ollieatkinson","id":1382565,"node_id":"MDQ6VXNlcjEzODI1NjU=","avatar_url":"https://avatars3.githubusercontent.com/u/1382565?v=4","gravatar_id":"","url":"https://api.github.com/users/ollieatkinson","html_url":"https://github.com/ollieatkinson","followers_url":"https://api.github.com/users/ollieatkinson/followers","following_url":"https://api.github.com/users/ollieatkinson/following{/other_user}","gists_url":"https://api.github.com/users/ollieatkinson/gists{/gist_id}","starred_url":"https://api.github.com/users/ollieatkinson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ollieatkinson/subscriptions","organizations_url":"https://api.github.com/users/ollieatkinson/orgs","repos_url":"https://api.github.com/users/ollieatkinson/repos","events_url":"https://api.github.com/users/ollieatkinson/events{/privacy}","received_events_url":"https://api.github.com/users/ollieatkinson/received_events","type":"User","site_admin":false},"body":"It's generally not good practice to reference the AppDelegate inside of your view controllers (directly).\r\n\r\nHow about using a protocol?\r\n\r\ne.g.\r\n\r\n```swift\r\nprotocol ThemeChangeDelegate {\r\n    func themeChanged(name: String, theme: Theme)\r\n}\r\n\r\n\r\n...\r\n\r\nextension AppDelegate: ThemeChangeDelegate { }\r\n\r\n...\r\n\r\nweak var themeChangeDelegate: ThemeChangeDelegate? = NSApp.delegate as? ThemeChangeDelegate\r\n\r\n```\r\n\r\nIt will make it much easier to write a unit test and decouples the editor view.","created_at":"2018-10-07T17:37:00Z","updated_at":"2018-10-07T17:37:00Z","html_url":"https://github.com/xi-editor/xi-mac/pull/287#discussion_r223221622","pull_request_url":"https://api.github.com/repos/xi-editor/xi-mac/pulls/287","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/xi-editor/xi-mac/pulls/comments/223221622"},"html":{"href":"https://github.com/xi-editor/xi-mac/pull/287#discussion_r223221622"},"pull_request":{"href":"https://api.github.com/repos/xi-editor/xi-mac/pulls/287"}},"in_reply_to_id":222234250},"pull_request":{"url":"https://api.github.com/repos/xi-editor/xi-mac/pulls/287","id":219961869,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE5OTYxODY5","html_url":"https://github.com/xi-editor/xi-mac/pull/287","diff_url":"https://github.com/xi-editor/xi-mac/pull/287.diff","patch_url":"https://github.com/xi-editor/xi-mac/pull/287.patch","issue_url":"https://api.github.com/repos/xi-editor/xi-mac/issues/287","number":287,"state":"open","locked":false,"title":"[WIP] Add macOS 10.14 Dark Mode support","user":{"login":"habovh","id":4186230,"node_id":"MDQ6VXNlcjQxODYyMzA=","avatar_url":"https://avatars3.githubusercontent.com/u/4186230?v=4","gravatar_id":"","url":"https://api.github.com/users/habovh","html_url":"https://github.com/habovh","followers_url":"https://api.github.com/users/habovh/followers","following_url":"https://api.github.com/users/habovh/following{/other_user}","gists_url":"https://api.github.com/users/habovh/gists{/gist_id}","starred_url":"https://api.github.com/users/habovh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/habovh/subscriptions","organizations_url":"https://api.github.com/users/habovh/orgs","repos_url":"https://api.github.com/users/habovh/repos","events_url":"https://api.github.com/users/habovh/events{/privacy}","received_events_url":"https://api.github.com/users/habovh/received_events","type":"User","site_admin":false},"body":"# WIP\r\n\r\n<img width=\"730\" alt=\"capture d ecran 2018-10-03 a 00 09 52\" src=\"https://user-images.githubusercontent.com/4186230/46380099-5b624000-c6a1-11e8-8b7d-0bb56a0512cd.png\">\r\n\r\nAs suggested in #276 by @jansol and @nangtrongvuon, I'm creating a PR so we can push the discussion further. Bear in mind this is my first contribution to a Swift project. 🙈\r\n\r\nThis is a work in progress, and should probably not be merged as-is.\r\n\r\n## Set theme flow\r\n\r\nThe Theme changes originally follow this flow during the app lifecycle:\r\n- Select theme\r\n  - App initialization\r\n    - Get theme list from `core`\r\n    - Get current theme from preferences\r\n  - Manual theme setting\r\n     - Get theme name from menu item\r\n- Apply theme\r\n  - Send a *set theme* message to `core`\r\n  - `core` responds to `mac` with a JSON-like theme object\r\n  - The provided theme object is parsed by `mac` and sets the menu item as *active*\r\n\r\n### Working stuff\r\n\r\nWhat works in the current PR, is selecting the `macOS` theme after app initialization. Doing so will inhibit the *set theme* message usually sent to `core`, and update the UI with a `Theme` object directly.\r\n\r\n### Not working stuff\r\n\r\nI found that setting the theme this way does not work for some keys (they are explicitly listed in comments in the code).\r\nOpening the app when `macOS` theme is selected results in an error from `core`, because of the *set theme* message sent on startup with a theme name that does not exist in `core`. We could inhibit this as well.\r\n`core` seems to still have a word to say in what's displayed on the screen somehow, and the previously selected theme will apply to the editor text color.\r\n\r\n## Thoughts\r\n\r\nAs you can see, this PR is pretty hacky, so we may want to come up with a better solution. But I feel this is definitely doable.\r\n\r\nI feel the best solution (for a working v1) would be to have a dedicated theme menu entry that is treated like a special case that sends a *set theme* message to core with an existing theme (e.g. `base16-ocean.light`) based on the current selected system color scheme, so the editor can use the text color from core, and then set the rest of the app UI with a Theme object using semantic `NSColors`.\r\n\r\nIf any of you guys have insights or general tips regarding Swift development please feel free to share your feedback and contribute!\r\n\r\n😃","created_at":"2018-10-03T09:00:43Z","updated_at":"2018-10-07T17:37:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"86344902db139b6f81ad077f39ccc068d632ef86","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/xi-editor/xi-mac/pulls/287/commits","review_comments_url":"https://api.github.com/repos/xi-editor/xi-mac/pulls/287/comments","review_comment_url":"https://api.github.com/repos/xi-editor/xi-mac/pulls/comments{/number}","comments_url":"https://api.github.com/repos/xi-editor/xi-mac/issues/287/comments","statuses_url":"https://api.github.com/repos/xi-editor/xi-mac/statuses/c42512ef3c347084a286a9b6faf230aa8dc3eb88","head":{"label":"habovh:feature/dark-mode","ref":"feature/dark-mode","sha":"c42512ef3c347084a286a9b6faf230aa8dc3eb88","user":{"login":"habovh","id":4186230,"node_id":"MDQ6VXNlcjQxODYyMzA=","avatar_url":"https://avatars3.githubusercontent.com/u/4186230?v=4","gravatar_id":"","url":"https://api.github.com/users/habovh","html_url":"https://github.com/habovh","followers_url":"https://api.github.com/users/habovh/followers","following_url":"https://api.github.com/users/habovh/following{/other_user}","gists_url":"https://api.github.com/users/habovh/gists{/gist_id}","starred_url":"https://api.github.com/users/habovh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/habovh/subscriptions","organizations_url":"https://api.github.com/users/habovh/orgs","repos_url":"https://api.github.com/users/habovh/repos","events_url":"https://api.github.com/users/habovh/events{/privacy}","received_events_url":"https://api.github.com/users/habovh/received_events","type":"User","site_admin":false},"repo":{"id":151379697,"node_id":"MDEwOlJlcG9zaXRvcnkxNTEzNzk2OTc=","name":"xi-mac","full_name":"habovh/xi-mac","private":false,"owner":{"login":"habovh","id":4186230,"node_id":"MDQ6VXNlcjQxODYyMzA=","avatar_url":"https://avatars3.githubusercontent.com/u/4186230?v=4","gravatar_id":"","url":"https://api.github.com/users/habovh","html_url":"https://github.com/habovh","followers_url":"https://api.github.com/users/habovh/followers","following_url":"https://api.github.com/users/habovh/following{/other_user}","gists_url":"https://api.github.com/users/habovh/gists{/gist_id}","starred_url":"https://api.github.com/users/habovh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/habovh/subscriptions","organizations_url":"https://api.github.com/users/habovh/orgs","repos_url":"https://api.github.com/users/habovh/repos","events_url":"https://api.github.com/users/habovh/events{/privacy}","received_events_url":"https://api.github.com/users/habovh/received_events","type":"User","site_admin":false},"html_url":"https://github.com/habovh/xi-mac","description":"The xi-editor mac frontend.","fork":true,"url":"https://api.github.com/repos/habovh/xi-mac","forks_url":"https://api.github.com/repos/habovh/xi-mac/forks","keys_url":"https://api.github.com/repos/habovh/xi-mac/keys{/key_id}","collaborators_url":"https://api.github.com/repos/habovh/xi-mac/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/habovh/xi-mac/teams","hooks_url":"https://api.github.com/repos/habovh/xi-mac/hooks","issue_events_url":"https://api.github.com/repos/habovh/xi-mac/issues/events{/number}","events_url":"https://api.github.com/repos/habovh/xi-mac/events","assignees_url":"https://api.github.com/repos/habovh/xi-mac/assignees{/user}","branches_url":"https://api.github.com/repos/habovh/xi-mac/branches{/branch}","tags_url":"https://api.github.com/repos/habovh/xi-mac/tags","blobs_url":"https://api.github.com/repos/habovh/xi-mac/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/habovh/xi-mac/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/habovh/xi-mac/git/refs{/sha}","trees_url":"https://api.github.com/repos/habovh/xi-mac/git/trees{/sha}","statuses_url":"https://api.github.com/repos/habovh/xi-mac/statuses/{sha}","languages_url":"https://api.github.com/repos/habovh/xi-mac/languages","stargazers_url":"https://api.github.com/repos/habovh/xi-mac/stargazers","contributors_url":"https://api.github.com/repos/habovh/xi-mac/contributors","subscribers_url":"https://api.github.com/repos/habovh/xi-mac/subscribers","subscription_url":"https://api.github.com/repos/habovh/xi-mac/subscription","commits_url":"https://api.github.com/repos/habovh/xi-mac/commits{/sha}","git_commits_url":"https://api.github.com/repos/habovh/xi-mac/git/commits{/sha}","comments_url":"https://api.github.com/repos/habovh/xi-mac/comments{/number}","issue_comment_url":"https://api.github.com/repos/habovh/xi-mac/issues/comments{/number}","contents_url":"https://api.github.com/repos/habovh/xi-mac/contents/{+path}","compare_url":"https://api.github.com/repos/habovh/xi-mac/compare/{base}...{head}","merges_url":"https://api.github.com/repos/habovh/xi-mac/merges","archive_url":"https://api.github.com/repos/habovh/xi-mac/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/habovh/xi-mac/downloads","issues_url":"https://api.github.com/repos/habovh/xi-mac/issues{/number}","pulls_url":"https://api.github.com/repos/habovh/xi-mac/pulls{/number}","milestones_url":"https://api.github.com/repos/habovh/xi-mac/milestones{/number}","notifications_url":"https://api.github.com/repos/habovh/xi-mac/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/habovh/xi-mac/labels{/name}","releases_url":"https://api.github.com/repos/habovh/xi-mac/releases{/id}","deployments_url":"https://api.github.com/repos/habovh/xi-mac/deployments","created_at":"2018-10-03T08:01:37Z","updated_at":"2018-10-03T08:01:39Z","pushed_at":"2018-10-03T08:33:12Z","git_url":"git://github.com/habovh/xi-mac.git","ssh_url":"git@github.com:habovh/xi-mac.git","clone_url":"https://github.com/habovh/xi-mac.git","svn_url":"https://github.com/habovh/xi-mac","homepage":"","size":2070,"stargazers_count":0,"watchers_count":0,"language":"Swift","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"xi-editor:master","ref":"master","sha":"d896aeff4e712a4e45311c67f3517dcc04fa014b","user":{"login":"xi-editor","id":43351123,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQzMzUxMTIz","avatar_url":"https://avatars3.githubusercontent.com/u/43351123?v=4","gravatar_id":"","url":"https://api.github.com/users/xi-editor","html_url":"https://github.com/xi-editor","followers_url":"https://api.github.com/users/xi-editor/followers","following_url":"https://api.github.com/users/xi-editor/following{/other_user}","gists_url":"https://api.github.com/users/xi-editor/gists{/gist_id}","starred_url":"https://api.github.com/users/xi-editor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xi-editor/subscriptions","organizations_url":"https://api.github.com/users/xi-editor/orgs","repos_url":"https://api.github.com/users/xi-editor/repos","events_url":"https://api.github.com/users/xi-editor/events{/privacy}","received_events_url":"https://api.github.com/users/xi-editor/received_events","type":"Organization","site_admin":false},"repo":{"id":78881023,"node_id":"MDEwOlJlcG9zaXRvcnk3ODg4MTAyMw==","name":"xi-mac","full_name":"xi-editor/xi-mac","private":false,"owner":{"login":"xi-editor","id":43351123,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQzMzUxMTIz","avatar_url":"https://avatars3.githubusercontent.com/u/43351123?v=4","gravatar_id":"","url":"https://api.github.com/users/xi-editor","html_url":"https://github.com/xi-editor","followers_url":"https://api.github.com/users/xi-editor/followers","following_url":"https://api.github.com/users/xi-editor/following{/other_user}","gists_url":"https://api.github.com/users/xi-editor/gists{/gist_id}","starred_url":"https://api.github.com/users/xi-editor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xi-editor/subscriptions","organizations_url":"https://api.github.com/users/xi-editor/orgs","repos_url":"https://api.github.com/users/xi-editor/repos","events_url":"https://api.github.com/users/xi-editor/events{/privacy}","received_events_url":"https://api.github.com/users/xi-editor/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/xi-editor/xi-mac","description":"The xi-editor mac frontend.","fork":false,"url":"https://api.github.com/repos/xi-editor/xi-mac","forks_url":"https://api.github.com/repos/xi-editor/xi-mac/forks","keys_url":"https://api.github.com/repos/xi-editor/xi-mac/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xi-editor/xi-mac/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xi-editor/xi-mac/teams","hooks_url":"https://api.github.com/repos/xi-editor/xi-mac/hooks","issue_events_url":"https://api.github.com/repos/xi-editor/xi-mac/issues/events{/number}","events_url":"https://api.github.com/repos/xi-editor/xi-mac/events","assignees_url":"https://api.github.com/repos/xi-editor/xi-mac/assignees{/user}","branches_url":"https://api.github.com/repos/xi-editor/xi-mac/branches{/branch}","tags_url":"https://api.github.com/repos/xi-editor/xi-mac/tags","blobs_url":"https://api.github.com/repos/xi-editor/xi-mac/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xi-editor/xi-mac/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xi-editor/xi-mac/git/refs{/sha}","trees_url":"https://api.github.com/repos/xi-editor/xi-mac/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xi-editor/xi-mac/statuses/{sha}","languages_url":"https://api.github.com/repos/xi-editor/xi-mac/languages","stargazers_url":"https://api.github.com/repos/xi-editor/xi-mac/stargazers","contributors_url":"https://api.github.com/repos/xi-editor/xi-mac/contributors","subscribers_url":"https://api.github.com/repos/xi-editor/xi-mac/subscribers","subscription_url":"https://api.github.com/repos/xi-editor/xi-mac/subscription","commits_url":"https://api.github.com/repos/xi-editor/xi-mac/commits{/sha}","git_commits_url":"https://api.github.com/repos/xi-editor/xi-mac/git/commits{/sha}","comments_url":"https://api.github.com/repos/xi-editor/xi-mac/comments{/number}","issue_comment_url":"https://api.github.com/repos/xi-editor/xi-mac/issues/comments{/number}","contents_url":"https://api.github.com/repos/xi-editor/xi-mac/contents/{+path}","compare_url":"https://api.github.com/repos/xi-editor/xi-mac/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xi-editor/xi-mac/merges","archive_url":"https://api.github.com/repos/xi-editor/xi-mac/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xi-editor/xi-mac/downloads","issues_url":"https://api.github.com/repos/xi-editor/xi-mac/issues{/number}","pulls_url":"https://api.github.com/repos/xi-editor/xi-mac/pulls{/number}","milestones_url":"https://api.github.com/repos/xi-editor/xi-mac/milestones{/number}","notifications_url":"https://api.github.com/repos/xi-editor/xi-mac/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xi-editor/xi-mac/labels{/name}","releases_url":"https://api.github.com/repos/xi-editor/xi-mac/releases{/id}","deployments_url":"https://api.github.com/repos/xi-editor/xi-mac/deployments","created_at":"2017-01-13T19:46:46Z","updated_at":"2018-10-07T15:40:05Z","pushed_at":"2018-10-07T15:51:26Z","git_url":"git://github.com/xi-editor/xi-mac.git","ssh_url":"git@github.com:xi-editor/xi-mac.git","clone_url":"https://github.com/xi-editor/xi-mac.git","svn_url":"https://github.com/xi-editor/xi-mac","homepage":"","size":4028,"stargazers_count":2143,"watchers_count":2143,"language":"Swift","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":97,"mirror_url":null,"archived":false,"open_issues_count":50,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":97,"open_issues":50,"watchers":2143,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/xi-editor/xi-mac/pulls/287"},"html":{"href":"https://github.com/xi-editor/xi-mac/pull/287"},"issue":{"href":"https://api.github.com/repos/xi-editor/xi-mac/issues/287"},"comments":{"href":"https://api.github.com/repos/xi-editor/xi-mac/issues/287/comments"},"review_comments":{"href":"https://api.github.com/repos/xi-editor/xi-mac/pulls/287/comments"},"review_comment":{"href":"https://api.github.com/repos/xi-editor/xi-mac/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/xi-editor/xi-mac/pulls/287/commits"},"statuses":{"href":"https://api.github.com/repos/xi-editor/xi-mac/statuses/c42512ef3c347084a286a9b6faf230aa8dc3eb88"}},"author_association":"NONE"}}
{"actor":{"display_login":"ollieatkinson"}}