From 88b90cb14d6c977be2250bc6cb211f48107fb547 Mon Sep 17 00:00:00 2001 From: hamin Date: Sun, 5 Aug 2018 03:11:49 -0400 Subject: [PATCH] Add ability to toggle editor view --- Twig/Base.lproj/Main.storyboard | 5 +++++ Twig/Controllers/WindowController.swift | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/Twig/Base.lproj/Main.storyboard b/Twig/Base.lproj/Main.storyboard index 4cf9710..5a7a032 100644 --- a/Twig/Base.lproj/Main.storyboard +++ b/Twig/Base.lproj/Main.storyboard @@ -388,6 +388,11 @@ + + + + + diff --git a/Twig/Controllers/WindowController.swift b/Twig/Controllers/WindowController.swift index d52c80b..e996474 100644 --- a/Twig/Controllers/WindowController.swift +++ b/Twig/Controllers/WindowController.swift @@ -92,4 +92,17 @@ class WindowController: NSWindowController, NSWindowDelegate { } } + @IBAction func toggleEditor(sender: NSMenuItem) { + guard let editor = editorSplitViewController?.splitViewItems.first else { return } + + editor.collapseBehavior = .preferResizingSplitViewWithFixedSiblings + editor.animator().isCollapsed = !editor.isCollapsed + + // If the editor is open after toggling, send a notification to re-generate the preview + if !editor.isCollapsed { + NotificationCenter.send(.appearanceChanged) + } + } + + }