diff --git a/Box42.xcodeproj/project.pbxproj b/Box42.xcodeproj/project.pbxproj index 54be299..337d15f 100644 --- a/Box42.xcodeproj/project.pbxproj +++ b/Box42.xcodeproj/project.pbxproj @@ -38,7 +38,6 @@ DE1F1A1C2A8B50C500A88DD8 /* BoxBaseContainerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE1F1A192A8B50C500A88DD8 /* BoxBaseContainerViewController.swift */; }; DE1F1A1D2A8B50C500A88DD8 /* BoxContentsViewGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE1F1A1A2A8B50C500A88DD8 /* BoxContentsViewGroup.swift */; }; DE1F1A1E2A8B50C500A88DD8 /* BoxButtonViewGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE1F1A1B2A8B50C500A88DD8 /* BoxButtonViewGroup.swift */; }; - DE1F1A262A8B50D500A88DD8 /* BoxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE1F1A232A8B50D500A88DD8 /* BoxViewController.swift */; }; DE1F1A292A8B50E200A88DD8 /* BoxSizeManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE1F1A282A8B50E200A88DD8 /* BoxSizeManager.swift */; }; DE1F1A2E2A8BCC9800A88DD8 /* Storage.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE1F1A2D2A8BCC9800A88DD8 /* Storage.swift */; }; DE1F1A312A8BD68F00A88DD8 /* Double.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE1F1A302A8BD68F00A88DD8 /* Double.swift */; }; @@ -47,13 +46,20 @@ DE24E6382A8FE10400E29F5D /* BoxBaseSplitView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE24E6372A8FE10300E29F5D /* BoxBaseSplitView.swift */; }; DE24E63B2A8FE93900E29F5D /* NSImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE24E63A2A8FE93900E29F5D /* NSImage.swift */; }; DE2AD3292A824EEB00002D51 /* Accessibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE2AD3282A824EEB00002D51 /* Accessibility.swift */; }; + DE3FF3672A978A37009C88EF /* HexValue+NSColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE3FF3662A978A37009C88EF /* HexValue+NSColor.swift */; }; + DE3FF36B2A978A57009C88EF /* WindowButtonViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE3FF3692A978A57009C88EF /* WindowButtonViewController.swift */; }; + DE3FF3742A978AB8009C88EF /* WindowMaximizeButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE3FF3702A978AB8009C88EF /* WindowMaximizeButton.swift */; }; + DE3FF3752A978AB8009C88EF /* WindowViewGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE3FF3712A978AB8009C88EF /* WindowViewGroup.swift */; }; + DE3FF3762A978AB8009C88EF /* WindowCloseButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE3FF3722A978AB8009C88EF /* WindowCloseButton.swift */; }; + DE3FF3772A978AB8009C88EF /* WindowMinimizeButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE3FF3732A978AB8009C88EF /* WindowMinimizeButton.swift */; }; + DE3FF3A32A97D2A6009C88EF /* DisplayURLTextfield.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE3FF3A22A97D2A6009C88EF /* DisplayURLTextfield.swift */; }; DE4407FA2A923E860091937A /* BoxFunctionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE4407F92A923E860091937A /* BoxFunctionViewController.swift */; }; DE4407FE2A923EA90091937A /* PreferenceButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE4407FD2A923EA90091937A /* PreferenceButtonView.swift */; }; DE4408022A923EB60091937A /* PinButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE4408012A923EB60091937A /* PinButtonView.swift */; }; DE4408052A923EC00091937A /* QuitButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE4408042A923EC00091937A /* QuitButtonView.swift */; }; DE4408082A9240300091937A /* BoxFunctionButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE4408072A9240300091937A /* BoxFunctionButtonView.swift */; }; DE44080C2A924B520091937A /* BoxFunctionViewGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE44080B2A924B520091937A /* BoxFunctionViewGroup.swift */; }; - DE4408152A92750D0091937A /* keyDown+BoxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE4408142A92750D0091937A /* keyDown+BoxViewController.swift */; }; + DE4408152A92750D0091937A /* keyDown+BoxBaseContainerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE4408142A92750D0091937A /* keyDown+BoxBaseContainerViewController.swift */; }; DE44081D2A928F760091937A /* TopDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE44081C2A928F760091937A /* TopDivider.swift */; }; DE77BA512A82580400713683 /* MenubarViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE77BA502A82580400713683 /* MenubarViewModel.swift */; }; DE77BA562A82637900713683 /* StateManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE77BA552A82637900713683 /* StateManager.swift */; }; @@ -62,6 +68,7 @@ DE874F542A591F1400FC3B77 /* PreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE874F532A591F1400FC3B77 /* PreferencesView.swift */; }; DE874F572A591F2500FC3B77 /* Icon.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE874F562A591F2500FC3B77 /* Icon.swift */; }; DE874F5F2A5935CC00FC3B77 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE874F5E2A5935CC00FC3B77 /* String.swift */; }; + DE9DA8142A97F20E001C0D3B /* ButtonGroupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE9DA8132A97F20E001C0D3B /* ButtonGroupViewController.swift */; }; DEB862D42A85124500278FCD /* cleanCache.sh in Resources */ = {isa = PBXBuildFile; fileRef = DEB862D32A85124500278FCD /* cleanCache.sh */; }; DEB862D92A852C4500278FCD /* brewInGoinfre.sh in Resources */ = {isa = PBXBuildFile; fileRef = DEB862D82A852C4500278FCD /* brewInGoinfre.sh */; }; DEB862DC2A85347400278FCD /* Scripts.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEB862DB2A85347400278FCD /* Scripts.swift */; }; @@ -100,10 +107,9 @@ DE1F1A112A8B506600A88DD8 /* importMacOSInfo.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = importMacOSInfo.sh; sourceTree = ""; }; DE1F1A122A8B506600A88DD8 /* exportMacOSInfo.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = exportMacOSInfo.sh; sourceTree = ""; }; DE1F1A132A8B506600A88DD8 /* keyMapping.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = keyMapping.sh; sourceTree = ""; }; - DE1F1A192A8B50C500A88DD8 /* BoxBaseContainerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BoxBaseContainerViewController.swift; path = Box/BoxBaseContainerViewController.swift; sourceTree = ""; }; + DE1F1A192A8B50C500A88DD8 /* BoxBaseContainerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BoxBaseContainerViewController.swift; path = Main/BoxBaseContainerViewController.swift; sourceTree = ""; }; DE1F1A1A2A8B50C500A88DD8 /* BoxContentsViewGroup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BoxContentsViewGroup.swift; sourceTree = ""; }; DE1F1A1B2A8B50C500A88DD8 /* BoxButtonViewGroup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BoxButtonViewGroup.swift; sourceTree = ""; }; - DE1F1A232A8B50D500A88DD8 /* BoxViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BoxViewController.swift; path = Main/BoxViewController.swift; sourceTree = ""; }; DE1F1A282A8B50E200A88DD8 /* BoxSizeManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BoxSizeManager.swift; sourceTree = ""; }; DE1F1A2D2A8BCC9800A88DD8 /* Storage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Storage.swift; sourceTree = ""; }; DE1F1A302A8BD68F00A88DD8 /* Double.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Double.swift; sourceTree = ""; }; @@ -112,13 +118,20 @@ DE24E6372A8FE10300E29F5D /* BoxBaseSplitView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoxBaseSplitView.swift; sourceTree = ""; }; DE24E63A2A8FE93900E29F5D /* NSImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSImage.swift; sourceTree = ""; }; DE2AD3282A824EEB00002D51 /* Accessibility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Accessibility.swift; sourceTree = ""; }; + DE3FF3662A978A37009C88EF /* HexValue+NSColor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "HexValue+NSColor.swift"; sourceTree = ""; }; + DE3FF3692A978A57009C88EF /* WindowButtonViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WindowButtonViewController.swift; sourceTree = ""; }; + DE3FF3702A978AB8009C88EF /* WindowMaximizeButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WindowMaximizeButton.swift; sourceTree = ""; }; + DE3FF3712A978AB8009C88EF /* WindowViewGroup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WindowViewGroup.swift; sourceTree = ""; }; + DE3FF3722A978AB8009C88EF /* WindowCloseButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WindowCloseButton.swift; sourceTree = ""; }; + DE3FF3732A978AB8009C88EF /* WindowMinimizeButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WindowMinimizeButton.swift; sourceTree = ""; }; + DE3FF3A22A97D2A6009C88EF /* DisplayURLTextfield.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisplayURLTextfield.swift; sourceTree = ""; }; DE4407F92A923E860091937A /* BoxFunctionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoxFunctionViewController.swift; sourceTree = ""; }; DE4407FD2A923EA90091937A /* PreferenceButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferenceButtonView.swift; sourceTree = ""; }; DE4408012A923EB60091937A /* PinButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PinButtonView.swift; sourceTree = ""; }; DE4408042A923EC00091937A /* QuitButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuitButtonView.swift; sourceTree = ""; }; DE4408072A9240300091937A /* BoxFunctionButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoxFunctionButtonView.swift; sourceTree = ""; }; DE44080B2A924B520091937A /* BoxFunctionViewGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoxFunctionViewGroup.swift; sourceTree = ""; }; - DE4408142A92750D0091937A /* keyDown+BoxViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "keyDown+BoxViewController.swift"; path = "Main/keyDown+BoxViewController.swift"; sourceTree = ""; }; + DE4408142A92750D0091937A /* keyDown+BoxBaseContainerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "keyDown+BoxBaseContainerViewController.swift"; path = "Main/keyDown+BoxBaseContainerViewController.swift"; sourceTree = ""; }; DE44081C2A928F760091937A /* TopDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopDivider.swift; sourceTree = ""; }; DE77BA502A82580400713683 /* MenubarViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenubarViewModel.swift; sourceTree = ""; }; DE77BA552A82637900713683 /* StateManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StateManager.swift; sourceTree = ""; }; @@ -127,6 +140,7 @@ DE874F532A591F1400FC3B77 /* PreferencesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesView.swift; sourceTree = ""; }; DE874F562A591F2500FC3B77 /* Icon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Icon.swift; sourceTree = ""; }; DE874F5E2A5935CC00FC3B77 /* String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = ""; }; + DE9DA8132A97F20E001C0D3B /* ButtonGroupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonGroupViewController.swift; sourceTree = ""; }; DEB862D32A85124500278FCD /* cleanCache.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = cleanCache.sh; sourceTree = ""; }; DEB862D82A852C4500278FCD /* brewInGoinfre.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = brewInGoinfre.sh; sourceTree = ""; }; DEB862DB2A85347400278FCD /* Scripts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Scripts.swift; path = Box42/Scripts/Scripts.swift; sourceTree = SOURCE_ROOT; }; @@ -167,20 +181,19 @@ DE018BB12A5099F900FF0AA3 /* Box42 */ = { isa = PBXGroup; children = ( - DE0A916B2A8E7DC700D1D6F1 /* UI */, - DE1F1A202A8B50CA00A88DD8 /* Main */, + DE77BA542A82636500713683 /* Shared */, DEF749302A85655E00D987C8 /* Extensions */, - DEB862E82A853F6800278FCD /* Window */, + DE018C0E2A509C0C00FF0AA3 /* Menubar */, + DE9DA8122A97F1E2001C0D3B /* ButtonGroup */, + DE1F1A202A8B50CA00A88DD8 /* Main */, DEB862D22A8511D600278FCD /* Scripts */, - DE77BA542A82636500713683 /* Shared */, DE874F512A591EC600FC3B77 /* Preferences */, DE018C0C2A509BDF00FF0AA3 /* Resources */, DE018C062A509B9000FF0AA3 /* System */, DE018C082A509BB500FF0AA3 /* WebView */, + DEB862E82A853F6800278FCD /* WindowButton */, DE0A917D2A8F864300D1D6F1 /* Toolbar */, DE4407F82A923E5B0091937A /* FunctionButton */, - DE1F1A182A8B50BB00A88DD8 /* Box */, - DE018C0E2A509C0C00FF0AA3 /* Menubar */, ); path = Box42; sourceTree = ""; @@ -263,6 +276,7 @@ children = ( DE0A91A62A8FC66600D1D6F1 /* SideBarLeading.swift */, DE0A91822A8F889000D1D6F1 /* GoHomePageViaToolbar().swift */, + DE3FF3A22A97D2A6009C88EF /* DisplayURLTextfield.swift */, DE0A918F2A8F88CA00D1D6F1 /* DisplayURLInToolbar.swift */, DE0A918C2A8F88BC00D1D6F1 /* GoBackInToolbar.swift */, DE0A91892A8F88A900D1D6F1 /* GoForwardInToolbar.swift */, @@ -279,22 +293,27 @@ name = Frameworks; sourceTree = ""; }; - DE1F1A182A8B50BB00A88DD8 /* Box */ = { + DE1F1A202A8B50CA00A88DD8 /* Main */ = { isa = PBXGroup; children = ( + DE0A916B2A8E7DC700D1D6F1 /* UI */, DE4408202A9297EE0091937A /* View */, DE1F1A192A8B50C500A88DD8 /* BoxBaseContainerViewController.swift */, + DE4408142A92750D0091937A /* keyDown+BoxBaseContainerViewController.swift */, + DEB862E92A853F7F00278FCD /* BoxWindowController.swift */, ); - name = Box; + name = Main; sourceTree = ""; }; - DE1F1A202A8B50CA00A88DD8 /* Main */ = { + DE3FF36F2A978A6E009C88EF /* View */ = { isa = PBXGroup; children = ( - DE1F1A232A8B50D500A88DD8 /* BoxViewController.swift */, - DE4408142A92750D0091937A /* keyDown+BoxViewController.swift */, + DE3FF3722A978AB8009C88EF /* WindowCloseButton.swift */, + DE3FF3732A978AB8009C88EF /* WindowMinimizeButton.swift */, + DE3FF3702A978AB8009C88EF /* WindowMaximizeButton.swift */, + DE3FF3712A978AB8009C88EF /* WindowViewGroup.swift */, ); - name = Main; + path = View; sourceTree = ""; }; DE4407F82A923E5B0091937A /* FunctionButton */ = { @@ -322,12 +341,10 @@ DE4408202A9297EE0091937A /* View */ = { isa = PBXGroup; children = ( - DE1F1A1B2A8B50C500A88DD8 /* BoxButtonViewGroup.swift */, DE1F1A1A2A8B50C500A88DD8 /* BoxContentsViewGroup.swift */, DE24E6372A8FE10300E29F5D /* BoxBaseSplitView.swift */, ); - name = View; - path = Box/View; + path = View; sourceTree = ""; }; DE77BA542A82636500713683 /* Shared */ = { @@ -352,6 +369,15 @@ path = Preferences; sourceTree = ""; }; + DE9DA8122A97F1E2001C0D3B /* ButtonGroup */ = { + isa = PBXGroup; + children = ( + DE1F1A1B2A8B50C500A88DD8 /* BoxButtonViewGroup.swift */, + DE9DA8132A97F20E001C0D3B /* ButtonGroupViewController.swift */, + ); + path = ButtonGroup; + sourceTree = ""; + }; DEB862D22A8511D600278FCD /* Scripts */ = { isa = PBXGroup; children = ( @@ -374,17 +400,19 @@ path = sh; sourceTree = ""; }; - DEB862E82A853F6800278FCD /* Window */ = { + DEB862E82A853F6800278FCD /* WindowButton */ = { isa = PBXGroup; children = ( - DEB862E92A853F7F00278FCD /* BoxWindowController.swift */, + DE3FF36F2A978A6E009C88EF /* View */, + DE3FF3692A978A57009C88EF /* WindowButtonViewController.swift */, ); - path = Window; + path = WindowButton; sourceTree = ""; }; DEF749302A85655E00D987C8 /* Extensions */ = { isa = PBXGroup; children = ( + DE3FF3662A978A37009C88EF /* HexValue+NSColor.swift */, DE874F5E2A5935CC00FC3B77 /* String.swift */, DEF749312A85657600D987C8 /* NSScreen.swift */, DE1F1A302A8BD68F00A88DD8 /* Double.swift */, @@ -473,13 +501,16 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + DE3FF3752A978AB8009C88EF /* WindowViewGroup.swift in Sources */, DE0A91A72A8FC66600D1D6F1 /* SideBarLeading.swift in Sources */, DE0A917B2A8F0CA800D1D6F1 /* AppleScripts+ShowMessage.swift in Sources */, - DE1F1A262A8B50D500A88DD8 /* BoxViewController.swift in Sources */, DE018BB82A5099F900FF0AA3 /* Box42.xcdatamodeld in Sources */, DE874F542A591F1400FC3B77 /* PreferencesView.swift in Sources */, DE0A91982A8F977F00D1D6F1 /* ToolbarViewController.swift in Sources */, + DE9DA8142A97F20E001C0D3B /* ButtonGroupViewController.swift in Sources */, DE4408082A9240300091937A /* BoxFunctionButtonView.swift in Sources */, + DE3FF3742A978AB8009C88EF /* WindowMaximizeButton.swift in Sources */, + DE3FF3A32A97D2A6009C88EF /* DisplayURLTextfield.swift in Sources */, DE77BA562A82637900713683 /* StateManager.swift in Sources */, DE1F1A1C2A8B50C500A88DD8 /* BoxBaseContainerViewController.swift in Sources */, DE018BE72A509B1E00FF0AA3 /* WebViewController.swift in Sources */, @@ -501,9 +532,11 @@ DE7A257A2A6D8CA20043225A /* PreferencesViewController.swift in Sources */, DE24E63B2A8FE93900E29F5D /* NSImage.swift in Sources */, DE0A916D2A8E7DD700D1D6F1 /* HoverButton.swift in Sources */, + DE3FF3762A978AB8009C88EF /* WindowCloseButton.swift in Sources */, + DE3FF3772A978AB8009C88EF /* WindowMinimizeButton.swift in Sources */, DE4408022A923EB60091937A /* PinButtonView.swift in Sources */, DE0A91672A8E6CA700D1D6F1 /* WebViewManager.swift in Sources */, - DE4408152A92750D0091937A /* keyDown+BoxViewController.swift in Sources */, + DE4408152A92750D0091937A /* keyDown+BoxBaseContainerViewController.swift in Sources */, DE018BED2A509B2600FF0AA3 /* URLModel.swift in Sources */, DE4408052A923EC00091937A /* QuitButtonView.swift in Sources */, DE0A918A2A8F88A900D1D6F1 /* GoForwardInToolbar.swift in Sources */, @@ -511,6 +544,7 @@ DEB862EB2A853F7F00278FCD /* BoxWindowController.swift in Sources */, DE0A918D2A8F88BC00D1D6F1 /* GoBackInToolbar.swift in Sources */, DE018BDD2A509AEB00FF0AA3 /* EventMonitor.swift in Sources */, + DE3FF3672A978A37009C88EF /* HexValue+NSColor.swift in Sources */, DE1F1A292A8B50E200A88DD8 /* BoxSizeManager.swift in Sources */, DEB862DC2A85347400278FCD /* Scripts.swift in Sources */, DE1F1A1D2A8B50C500A88DD8 /* BoxContentsViewGroup.swift in Sources */, @@ -522,6 +556,7 @@ DE874F572A591F2500FC3B77 /* Icon.swift in Sources */, DE1F1A2E2A8BCC9800A88DD8 /* Storage.swift in Sources */, DE0A91782A8F014F00D1D6F1 /* WebView.swift in Sources */, + DE3FF36B2A978A57009C88EF /* WindowButtonViewController.swift in Sources */, DE1F1A312A8BD68F00A88DD8 /* Double.swift in Sources */, DE0A917F2A8F865400D1D6F1 /* BoxToolbarViewGroup.swift in Sources */, DE018BEA2A509B2100FF0AA3 /* WebViewModel.swift in Sources */, diff --git a/Box42/BoxWindowController.swift b/Box42/BoxWindowController.swift new file mode 100644 index 0000000..3a3babf --- /dev/null +++ b/Box42/BoxWindowController.swift @@ -0,0 +1,41 @@ +// +// BoxWindowController.swift +// Box42 +// +// Created by Chanhee Kim on 8/11/23. +// + +import Cocoa + +class BoxWindowController: NSWindowController, NSWindowDelegate { + override init(window: NSWindow?) { + let contentRect = BoxSizeManager.shared.boxViewSizeNSRect + let styleMask: NSWindow.StyleMask = [.resizable, .titled, .fullSizeContentView, .closable, .miniaturizable] + let windowInstance = NSWindow(contentRect: contentRect, styleMask: styleMask, backing: .buffered, defer: false) + super.init(window: windowInstance) + windowInstance.delegate = self + + windowInstance.title = "Box" + windowInstance.titlebarAppearsTransparent = true + windowInstance.titleVisibility = .hidden + windowInstance.isReleasedWhenClosed = false + windowInstance.isMovableByWindowBackground = true + + let boxViewController = BoxBaseContainerViewController(nibName: nil, bundle: nil) + windowInstance.contentViewController = boxViewController + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} + +extension BoxWindowController { + func windowWillClose(_ notification: Notification) { + StateManager.shared.showWindow = false + } + + func windowWillMiniaturize(_ notification: Notification) { + StateManager.shared.showWindow = false + } +} diff --git a/Box42/Box/View/BoxButtonViewGroup.swift b/Box42/ButtonGroup/BoxButtonViewGroup.swift similarity index 100% rename from Box42/Box/View/BoxButtonViewGroup.swift rename to Box42/ButtonGroup/BoxButtonViewGroup.swift diff --git a/Box42/ButtonGroup/ButtonGroupViewController.swift b/Box42/ButtonGroup/ButtonGroupViewController.swift new file mode 100644 index 0000000..2101feb --- /dev/null +++ b/Box42/ButtonGroup/ButtonGroupViewController.swift @@ -0,0 +1,35 @@ +// +// ButtonGroupViewController.swift +// Box42 +// +// Created by Chanhee Kim on 8/25/23. +// + +import Cocoa + +class ButtonGroupViewController: NSViewController { + override func loadView() { +// let ButtonViewGroup = BoxButtonViewGroup() + let ButtonViewGroup = NSView() + ButtonViewGroup.wantsLayer = true + ButtonViewGroup.layer?.backgroundColor = NSColor.black.cgColor + self.view = ButtonViewGroup + } + + override func viewDidLoad() { + super.viewDidLoad() + } + + func preference() { + print("preference") + } + + func pin() { + print("pin") + } + + func quit() { + print("quit") + NSApplication.shared.terminate(self) + } +} diff --git a/Box42/Extensions/HexValue+NSColor.swift b/Box42/Extensions/HexValue+NSColor.swift new file mode 100644 index 0000000..8360c15 --- /dev/null +++ b/Box42/Extensions/HexValue+NSColor.swift @@ -0,0 +1,30 @@ +// +// NSColor.swift +// Box42 +// +// Created by Chanhee Kim on 8/24/23. +// + +import AppKit + +extension NSColor { + convenience init(hex: String) { + let hex = hex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted) + var int: UInt64 = 0 + + Scanner(string: hex).scanHexInt64(&int) + let a, r, g, b: UInt64 + switch hex.count { + case 3: // RGB (12-bit) + (a, r, g, b) = (255, (int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0xF) * 17) + case 6: // RGB (24-bit) + (a, r, g, b) = (255, int >> 16, int >> 8 & 0xFF, int & 0xFF) + case 8: // ARGB (32-bit) + (a, r, g, b) = (int >> 24, int >> 16 & 0xFF, int >> 8 & 0xFF, int & 0xFF) + default: + (a, r, g, b) = (255, 0, 0, 0) + } + + self.init(red: CGFloat(r) / 255, green: CGFloat(g) / 255, blue: CGFloat(b) / 255, alpha: CGFloat(a) / 255) + } +} diff --git a/Box42/Extensions/NSScreen.swift b/Box42/Extensions/NSScreen.swift index 778e4fd..263a718 100644 --- a/Box42/Extensions/NSScreen.swift +++ b/Box42/Extensions/NSScreen.swift @@ -10,7 +10,13 @@ import Cocoa extension NSScreen { static let screenSize = NSScreen.main?.visibleFrame.size static let screenWidth = screenSize!.width - static let screenHeight = screenSize!.height + static let screenHeight = screenSize!.height - 60 static let halfOfScreen = (x: screenWidth / 2, y: screenHeight / 2) - static let customScreenSize = (x: CGFloat(900), y: screenHeight - 132) + static let contentsScreenSize = CGSize(width: CGFloat(768), height: screenHeight) + static let buttonGroupSize = CGSize(width: CGFloat(200), height: screenHeight) + static let customScreenSize = contentsScreenSize + buttonGroupSize +} + +func +(left: CGSize, right: CGSize) -> CGSize { + return CGSize(width: left.width + right.width, height: left.height) } diff --git a/Box42/FunctionButton/BoxFunctionViewController.swift b/Box42/FunctionButton/BoxFunctionViewController.swift index a2a482e..42e3396 100644 --- a/Box42/FunctionButton/BoxFunctionViewController.swift +++ b/Box42/FunctionButton/BoxFunctionViewController.swift @@ -36,7 +36,14 @@ class BoxFunctionViewController: NSViewController { NSApplication.shared.terminate(self) } + weak var delegate: BoxFunctionViewControllerDelegate? + func box() { print("box") + delegate?.didTapBoxButton() } } + +protocol BoxFunctionViewControllerDelegate: AnyObject { + func didTapBoxButton() +} diff --git a/Box42/FunctionButton/View/BoxFunctionButtonView.swift b/Box42/FunctionButton/View/BoxFunctionButtonView.swift index 01eb568..b0fd5fc 100644 --- a/Box42/FunctionButton/View/BoxFunctionButtonView.swift +++ b/Box42/FunctionButton/View/BoxFunctionButtonView.swift @@ -15,7 +15,9 @@ class BoxFunctionButtonView: NSButton { super.init(frame: .zero) self.image = image - self.bezelStyle = .texturedRounded + self.isBordered = false // 버튼의 테두리를 제거 + self.wantsLayer = true + self.layer?.backgroundColor = NSColor.clear.cgColor self.target = self self.action = #selector(BoxFunction) self.callback = completion diff --git a/Box42/FunctionButton/View/PinButtonView.swift b/Box42/FunctionButton/View/PinButtonView.swift index a91036b..f80e9d3 100644 --- a/Box42/FunctionButton/View/PinButtonView.swift +++ b/Box42/FunctionButton/View/PinButtonView.swift @@ -15,7 +15,9 @@ class PinButtonView: NSButton { super.init(frame: .zero) self.image = image - self.bezelStyle = .texturedRounded + self.isBordered = false // 버튼의 테두리를 제거 + self.wantsLayer = true + self.layer?.backgroundColor = NSColor.clear.cgColor self.target = self self.action = #selector(pin) self.callback = completion diff --git a/Box42/FunctionButton/View/PreferenceButtonView.swift b/Box42/FunctionButton/View/PreferenceButtonView.swift index ffc8102..7c7a324 100644 --- a/Box42/FunctionButton/View/PreferenceButtonView.swift +++ b/Box42/FunctionButton/View/PreferenceButtonView.swift @@ -14,7 +14,9 @@ class PreferenceButtonView: NSButton { init(image: NSImage, completion: @escaping () -> Void) { super.init(frame: .zero) self.image = image - self.bezelStyle = .texturedRounded + self.isBordered = false // 버튼의 테두리를 제거 + self.wantsLayer = true + self.layer?.backgroundColor = NSColor.clear.cgColor self.target = self self.action = #selector(preference) self.callback = completion diff --git a/Box42/FunctionButton/View/QuitButtonView.swift b/Box42/FunctionButton/View/QuitButtonView.swift index aaf9259..eec8ed7 100644 --- a/Box42/FunctionButton/View/QuitButtonView.swift +++ b/Box42/FunctionButton/View/QuitButtonView.swift @@ -15,7 +15,9 @@ class QuitButtonView: NSButton { super.init(frame: .zero) self.image = image - self.bezelStyle = .texturedRounded + self.isBordered = false // 버튼의 테두리를 제거 + self.wantsLayer = true + self.layer?.backgroundColor = NSColor.clear.cgColor self.target = self self.action = #selector(QuitButton) self.callback = completion diff --git a/Box42/Box/BoxBaseContainerViewController.swift b/Box42/Main/BoxBaseContainerViewController.swift similarity index 54% rename from Box42/Box/BoxBaseContainerViewController.swift rename to Box42/Main/BoxBaseContainerViewController.swift index 836ca15..dcb6323 100644 --- a/Box42/Box/BoxBaseContainerViewController.swift +++ b/Box42/Main/BoxBaseContainerViewController.swift @@ -13,24 +13,27 @@ class BoxBaseContainerViewController: NSViewController { var contentGroup: BoxContentsViewGroup = BoxContentsViewGroup() var toolbarGroupVC: ToolbarViewController = ToolbarViewController() var functionGroupVC: BoxFunctionViewController = BoxFunctionViewController() - let windowViewGroup: WindowButtonViewController = WindowButtonViewController() - var buttonGroup: BoxButtonViewGroup! - var leftContainer: MovableContainerView! - + let windowViewGroupVC: WindowButtonViewController = WindowButtonViewController() + var leftContainer: MovableContainerView = MovableContainerView() + var buttonGroupVC: ButtonGroupViewController = ButtonGroupViewController() + weak var menubarVCDelegate: MenubarViewControllerDelegate? // extension + override func loadView() { self.view = NSView() -// self.view.wantsLayer = true -// self.view.layer?.backgroundColor = NSColor.red.cgColor self.view.addSubview(splitView) splitView.delegate = self - buttonGroup = BoxButtonViewGroupInit() - +// buttonGroup = BoxButtonViewGroupInit() leftContainerInit() viewInit() } + override func viewDidLoad() { + self.view.wantsLayer = true + self.view.layer?.backgroundColor = NSColor(hex: "#FF9548").cgColor + } + func BoxButtonViewGroupInit() -> BoxButtonViewGroup { let buttonGroup = BoxButtonViewGroup { sender in @@ -40,56 +43,70 @@ class BoxBaseContainerViewController: NSViewController { return buttonGroup } - func clickBtn(sender: NSButton) { - guard let clickCount = NSApp.currentEvent?.clickCount else { return } - if clickCount == 2 { - WebViewManager.shared.list[sender.title]!.reload() - print("Dobule Click") - } else if clickCount > 2 { - if let currentURL = WebViewManager.shared.hostingWebView?.url { - NSWorkspace.shared.open(currentURL) + func clickBtn(sender: Any?) { + if let button = sender as? NSButton { + guard let clickCount = NSApp.currentEvent?.clickCount else { return } + if clickCount == 2 { + WebViewManager.shared.list[button.title]!.reload() + print("Dobule Click") + } else if clickCount > 2 { + if let currentURL = WebViewManager.shared.hostingWebView?.url { + NSWorkspace.shared.open(currentURL) + } + print("Triple Click") + } else if clickCount < 2 { + contentGroup.removeAllSubviews() + contentGroup.showWebviews(button) + } + } else { + if let str = sender as? String { + if str == "box" { + contentGroup.removeAllSubviews() + print("box inside") + } } - print("Triple Click") - } else if clickCount < 2 { - contentGroup.removeAllSubviews() - contentGroup.showWebviews(sender) } } private func leftContainerInit() { - leftContainer = MovableContainerView() - leftContainer.addSubview(buttonGroup) - leftContainer.addSubview(windowViewGroup.view) + leftContainer.frame.size.width = BoxSizeManager.shared.windowButtonGroupSize.width + leftContainer.frame.size.height = BoxSizeManager.shared.windowButtonGroupSize.height +// leftContainer.addSubview(windowViewGroupVC.view) + leftContainer.addSubview(buttonGroupVC.view) leftContainer.addSubview(toolbarGroupVC.view) leftContainer.addSubview(functionGroupVC.view) + leftContainerAutolayout() - leftContainer.frame.size.width = BoxSizeManager.shared.windowButtonGroupSize.width } private func leftContainerAutolayout() { - windowViewGroup.view.snp.makeConstraints { make in - make.top.equalTo(leftContainer).offset(Constants.UI.GroupAutolayout) - make.right.equalTo(leftContainer).offset(-Constants.UI.GroupAutolayout) - make.left.equalTo(leftContainer) - } +// windowViewGroupVC.view.snp.makeConstraints { make in +// make.top.equalTo(leftContainer) +// make.left.equalTo(leftContainer).offset(3) +// make.width.equalTo(77) +// make.height.equalTo(21) +// } toolbarGroupVC.view.snp.makeConstraints { make in - make.top.equalTo(windowViewGroup.view.snp.bottom).offset(Constants.UI.GroupAutolayout) - make.right.equalTo(leftContainer).offset(-Constants.UI.GroupAutolayout) - make.left.equalTo(leftContainer) - } - - buttonGroup.snp.makeConstraints { make in - make.top.equalTo(toolbarGroupVC.view.snp.bottom).offset(Constants.UI.GroupAutolayout) - make.right.equalTo(leftContainer).offset(-Constants.UI.GroupAutolayout) +// make.top.equalTo(windowViewGroupVC.view.snp.bottom).offset(31) + make.top.equalTo(leftContainer).offset(31) // wVGVC 없으면 + make.right.equalTo(leftContainer) make.left.equalTo(leftContainer) + make.height.equalTo(44 + 14 + 24) } functionGroupVC.view.snp.makeConstraints { make in - make.top.equalTo(buttonGroup.snp.bottom).offset(Constants.UI.GroupAutolayout) - make.right.equalTo(leftContainer).offset(-Constants.UI.GroupAutolayout) +// make.top.equalTo(buttonGroup.snp.bottom).offset(Constants.UI.groupAutolayout) + make.right.equalTo(leftContainer).offset(-Constants.UI.groupAutolayout) make.left.bottom.equalTo(leftContainer) } + + buttonGroupVC.view.snp.makeConstraints { make in + make.top.equalTo(toolbarGroupVC.view.snp.bottom).offset(Constants.UI.groupAutolayout) + make.right.equalTo(leftContainer).offset(-Constants.UI.groupAutolayout) + make.left.equalTo(leftContainer) + make.bottom.equalTo(functionGroupVC.view.snp.top).offset(-Constants.UI.groupAutolayout) + } } func viewInit() { @@ -100,10 +117,10 @@ class BoxBaseContainerViewController: NSViewController { self.view.addSubview(splitView) splitView.snp.makeConstraints { make in - make.top.equalTo(self.view).offset(Constants.UI.GroupAutolayout) - make.left.equalTo(self.view).offset(Constants.UI.GroupAutolayout) - make.right.equalTo(self.view).offset(-Constants.UI.GroupAutolayout) - make.bottom.equalTo(self.view).offset(-Constants.UI.GroupAutolayout) + make.top.equalToSuperview().offset(Constants.UI.groupAutolayout) + make.left.equalToSuperview().offset(Constants.UI.groupAutolayout) + make.right.equalToSuperview().offset(-Constants.UI.groupAutolayout) + make.bottom.equalToSuperview().offset(-Constants.UI.groupAutolayout) } } @@ -140,3 +157,9 @@ extension BoxBaseContainerViewController: NSSplitViewDelegate { contentGroup.frame = NSRect(x: leftWidth + dividerThickness, y: 0, width: contentWidth, height: splitView.bounds.height) } } + +extension BoxBaseContainerViewController: BoxFunctionViewControllerDelegate { + func didTapBoxButton() { + clickBtn(sender: "box") + } +} diff --git a/Box42/Main/BoxViewController.swift b/Box42/Main/BoxViewController.swift deleted file mode 100644 index 551ba31..0000000 --- a/Box42/Main/BoxViewController.swift +++ /dev/null @@ -1,62 +0,0 @@ -// -// BoxViewController.swift -// Box42 -// -// Created by Chan on 2023/03/16. -// - -import AppKit -import WebKit - -class BoxViewController: NSViewController { - var boxView: BoxBaseContainerViewController = BoxBaseContainerViewController() - var gradientLayer: CAGradientLayer! - let preferencesVC = PreferencesViewController() - weak var menubarVCDelegate: MenubarViewControllerDelegate? - - override func loadView() { - self.view = boxView.view - } - - override func viewDidLoad() { - super.viewDidLoad() - - menubarVCDelegate = (NSApplication.shared.delegate as? AppDelegate)?.menubarController - - self.view.wantsLayer = true - setupGradientLayer() - - NotificationCenter.default.addObserver(self, selector: #selector(boundsDidChange), name: NSWindow.didResizeNotification, object: self.view.window) - } - - func setupGradientLayer() { - gradientLayer = CAGradientLayer() - gradientLayer.frame = self.view.bounds - let startingColor = NSColor(red: 1.0, green: 0.804, blue: 0.0, alpha: 0.9).cgColor - let endingColor = NSColor(red: 1.0, green: 0.447, blue: 0.0, alpha: 0.7).cgColor - gradientLayer.colors = [startingColor, endingColor] - - self.view.layer?.addSublayer(gradientLayer) - } - - @objc func boundsDidChange(notification: NSNotification) { - if let window = notification.object as? NSWindow { - gradientLayer.frame = window.contentView!.bounds - } - } - - @objc - func doubleClickBtn(sender: NSButton) { - WebViewManager.shared.list[sender.title]!.reload() - } - - @objc - func pin(_ sender: NSSwitch) { - StateManager.shared.setToggleIsPin() - print(sender.state) - } - - func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { - print(message.name) - } -} diff --git a/Box42/Main/keyDown+BoxViewController.swift b/Box42/Main/keyDown+BoxBaseContainerViewController.swift similarity index 95% rename from Box42/Main/keyDown+BoxViewController.swift rename to Box42/Main/keyDown+BoxBaseContainerViewController.swift index 63b89e2..f16fcfc 100644 --- a/Box42/Main/keyDown+BoxViewController.swift +++ b/Box42/Main/keyDown+BoxBaseContainerViewController.swift @@ -7,7 +7,7 @@ import AppKit -extension BoxViewController { +extension BoxBaseContainerViewController { override func keyDown(with event: NSEvent) { print(event.keyCode) if event.keyCode == 1 { diff --git a/Box42/Menubar/MenubarViewController.swift b/Box42/Menubar/MenubarViewController.swift index 2cb1a3f..2701716 100644 --- a/Box42/Menubar/MenubarViewController.swift +++ b/Box42/Menubar/MenubarViewController.swift @@ -8,7 +8,7 @@ import Foundation import AppKit -class MenubarViewController: NSWorkspace { +class MenubarViewController: NSViewController { var popover = NSPopover() var statusBarVM = StatusBarViewModel() lazy var eventMonitor: EventMonitor = self.setupEventMonitor() @@ -21,7 +21,7 @@ class MenubarViewController: NSWorkspace { func menubarViewControllerStart() { self.menubarStartRunning() self.buttonActionInit() - self.popoverCoentViewInit() + self.popoverContentViewInit() self.startEventMonitoring() } @@ -42,7 +42,7 @@ class MenubarViewController: NSWorkspace { } func buttonInit() { - buttonImageChange("Cat") + buttonImageChange("Fox") statusBarVM.statusButtonAppear() } @@ -55,15 +55,15 @@ class MenubarViewController: NSWorkspace { statusBarVM.statusBar.statusItem.button?.target = self } - func popoverCoentViewInit() { - let boxViewController = BoxViewController(nibName: nil, bundle: nil) + func popoverContentViewInit() { + let boxViewController = BoxBaseContainerViewController(nibName: nil, bundle: nil) popover.contentViewController = boxViewController } func setupEventMonitor() -> EventMonitor { return EventMonitor(mask: [.leftMouseDown, .rightMouseDown, .otherMouseDown]) { [weak self] event in if let strongSelf = self, strongSelf.popover.isShown { - if StateManager.shared.getIsPin() == false && event?.buttonNumber != 2 { + if StateManager.shared.pin == false && event?.buttonNumber != 2 { strongSelf.closePopover(sender: event) } } else if let strongSelf = self, !strongSelf.popover.isShown { @@ -99,8 +99,8 @@ class MenubarViewController: NSWorkspace { extension MenubarViewController: MenubarViewControllerDelegate { func toggleWindow(sender: Any?) { - StateManager.shared.setToggleIsShowWindow() - if StateManager.shared.getIsShowWindow() == false { + StateManager.shared.toggleShowWindow() + if StateManager.shared.showWindow == false { if let window = boxWindowController?.window { if window.isVisible { window.orderOut(sender) @@ -113,19 +113,18 @@ extension MenubarViewController: MenubarViewControllerDelegate { } if let button = statusBarVM.statusBar.statusItem.button, let window = boxWindowController?.window { - if StateManager.shared.getIsShowFirstWindow() == false { + if StateManager.shared.showFirstWindow == false { let buttonFrame = button.window?.convertToScreen(button.frame) ?? NSZeroRect let desiredPosition = NSPoint(x: buttonFrame.origin.x - (BoxSizeManager.shared.size.width / 2) - 10, y: buttonFrame.origin.y - window.frame.height) window.setFrameOrigin(desiredPosition) - StateManager.shared.setToggleIsShowFirstWindow() + StateManager.shared.toggleShowFirstWindow() } window.level = .floating } boxWindowController?.showWindow(sender) } } - } protocol MenubarViewControllerDelegate: AnyObject { diff --git a/Box42/Menubar/MenubarViewModel.swift b/Box42/Menubar/MenubarViewModel.swift index 7a7fb9e..5d23f10 100644 --- a/Box42/Menubar/MenubarViewModel.swift +++ b/Box42/Menubar/MenubarViewModel.swift @@ -31,6 +31,7 @@ class StatusBarViewModel { case "gam": for i in (1...5) {statusBar.frames.append(NSImage(imageLiteralResourceName: "gam_\(i)"))} case "lee": for i in (1...5) {statusBar.frames.append(NSImage(imageLiteralResourceName: "lee_\(i)"))} case "Box": for i in (1...4) {statusBar.frames.append(NSImage(imageLiteralResourceName: "42box_\(i)"))} + case "Fox": for i in (1...4) {statusBar.frames.append(NSImage(imageLiteralResourceName: "fox_page\(i)"))} case "box_oc": for i in (1...2) {statusBar.frames.append(NSImage(imageLiteralResourceName: "42box_oc\(i)"))} default : for i in (1...11) {statusBar.frames.append(NSImage(imageLiteralResourceName: "42flip_0\(i)"))} } diff --git a/Box42/Resources/Assets.xcassets/42pack_icon/fox/Contents.json b/Box42/Resources/Assets.xcassets/42pack_icon/fox/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Box42/Resources/Assets.xcassets/42pack_icon/fox/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page0.imageset/Contents.json b/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page0.imageset/Contents.json new file mode 100644 index 0000000..64bcd2c --- /dev/null +++ b/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page0.imageset/Contents.json @@ -0,0 +1,20 @@ +{ + "images" : [ + { + "idiom" : "mac", + "scale" : "1x" + }, + { + "filename" : "fox0.png", + "idiom" : "mac", + "scale" : "2x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page0.imageset/fox0.png b/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page0.imageset/fox0.png new file mode 100644 index 0000000..0892874 Binary files /dev/null and b/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page0.imageset/fox0.png differ diff --git a/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page1.imageset/Contents.json b/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page1.imageset/Contents.json new file mode 100644 index 0000000..b59bbbf --- /dev/null +++ b/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page1.imageset/Contents.json @@ -0,0 +1,20 @@ +{ + "images" : [ + { + "idiom" : "mac", + "scale" : "1x" + }, + { + "filename" : "fox1.png", + "idiom" : "mac", + "scale" : "2x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page1.imageset/fox1.png b/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page1.imageset/fox1.png new file mode 100644 index 0000000..14ede17 Binary files /dev/null and b/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page1.imageset/fox1.png differ diff --git a/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page2.imageset/Contents.json b/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page2.imageset/Contents.json new file mode 100644 index 0000000..7b2f55b --- /dev/null +++ b/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page2.imageset/Contents.json @@ -0,0 +1,20 @@ +{ + "images" : [ + { + "idiom" : "mac", + "scale" : "1x" + }, + { + "filename" : "fox2.png", + "idiom" : "mac", + "scale" : "2x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page2.imageset/fox2.png b/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page2.imageset/fox2.png new file mode 100644 index 0000000..2120ecd Binary files /dev/null and b/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page2.imageset/fox2.png differ diff --git a/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page3.imageset/Contents.json b/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page3.imageset/Contents.json new file mode 100644 index 0000000..533abef --- /dev/null +++ b/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page3.imageset/Contents.json @@ -0,0 +1,20 @@ +{ + "images" : [ + { + "idiom" : "mac", + "scale" : "1x" + }, + { + "filename" : "fox3.png", + "idiom" : "mac", + "scale" : "2x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page3.imageset/fox3.png b/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page3.imageset/fox3.png new file mode 100644 index 0000000..e15e2be Binary files /dev/null and b/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page3.imageset/fox3.png differ diff --git a/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page4.imageset/Contents.json b/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page4.imageset/Contents.json new file mode 100644 index 0000000..018fb9c --- /dev/null +++ b/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page4.imageset/Contents.json @@ -0,0 +1,20 @@ +{ + "images" : [ + { + "idiom" : "mac", + "scale" : "1x" + }, + { + "filename" : "fox4.png", + "idiom" : "mac", + "scale" : "2x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page4.imageset/fox4.png b/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page4.imageset/fox4.png new file mode 100644 index 0000000..352f185 Binary files /dev/null and b/Box42/Resources/Assets.xcassets/42pack_icon/fox/fox_page4.imageset/fox4.png differ diff --git a/Box42/Resources/Assets.xcassets/Icons/arrow.left.imageset/Contents.json b/Box42/Resources/Assets.xcassets/Icons/_arrow.left.imageset/Contents.json similarity index 100% rename from Box42/Resources/Assets.xcassets/Icons/arrow.left.imageset/Contents.json rename to Box42/Resources/Assets.xcassets/Icons/_arrow.left.imageset/Contents.json diff --git a/Box42/Resources/Assets.xcassets/Icons/arrow.left.imageset/arrow.left@2x.png b/Box42/Resources/Assets.xcassets/Icons/_arrow.left.imageset/arrow.left@2x.png similarity index 100% rename from Box42/Resources/Assets.xcassets/Icons/arrow.left.imageset/arrow.left@2x.png rename to Box42/Resources/Assets.xcassets/Icons/_arrow.left.imageset/arrow.left@2x.png diff --git a/Box42/Resources/Assets.xcassets/uibuttons/Contents.json b/Box42/Resources/Assets.xcassets/uibuttons/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Box42/Resources/Assets.xcassets/uibuttons/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Box42/Resources/Assets.xcassets/uibuttons/arrow-left.imageset/Contents.json b/Box42/Resources/Assets.xcassets/uibuttons/arrow-left.imageset/Contents.json new file mode 100644 index 0000000..aad174b --- /dev/null +++ b/Box42/Resources/Assets.xcassets/uibuttons/arrow-left.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "arrow-left.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Box42/Resources/Assets.xcassets/uibuttons/arrow-left.imageset/arrow-left.png b/Box42/Resources/Assets.xcassets/uibuttons/arrow-left.imageset/arrow-left.png new file mode 100644 index 0000000..8a82ffc Binary files /dev/null and b/Box42/Resources/Assets.xcassets/uibuttons/arrow-left.imageset/arrow-left.png differ diff --git a/Box42/Resources/Assets.xcassets/uibuttons/arrow-right.imageset/Contents.json b/Box42/Resources/Assets.xcassets/uibuttons/arrow-right.imageset/Contents.json new file mode 100644 index 0000000..4941e41 --- /dev/null +++ b/Box42/Resources/Assets.xcassets/uibuttons/arrow-right.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "arrow-right.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Box42/Resources/Assets.xcassets/uibuttons/arrow-right.imageset/arrow-right.png b/Box42/Resources/Assets.xcassets/uibuttons/arrow-right.imageset/arrow-right.png new file mode 100644 index 0000000..73ce0d2 Binary files /dev/null and b/Box42/Resources/Assets.xcassets/uibuttons/arrow-right.imageset/arrow-right.png differ diff --git a/Box42/Resources/Assets.xcassets/uibuttons/circle.imageset/Contents.json b/Box42/Resources/Assets.xcassets/uibuttons/circle.imageset/Contents.json new file mode 100644 index 0000000..0b17967 --- /dev/null +++ b/Box42/Resources/Assets.xcassets/uibuttons/circle.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Ellipse 1.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Box42/Resources/Assets.xcassets/uibuttons/circle.imageset/Ellipse 1.png b/Box42/Resources/Assets.xcassets/uibuttons/circle.imageset/Ellipse 1.png new file mode 100644 index 0000000..f035028 Binary files /dev/null and b/Box42/Resources/Assets.xcassets/uibuttons/circle.imageset/Ellipse 1.png differ diff --git a/Box42/Resources/Assets.xcassets/uibuttons/rotate-right.imageset/Contents.json b/Box42/Resources/Assets.xcassets/uibuttons/rotate-right.imageset/Contents.json new file mode 100644 index 0000000..c2f10ea --- /dev/null +++ b/Box42/Resources/Assets.xcassets/uibuttons/rotate-right.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "rotate-right.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Box42/Resources/Assets.xcassets/uibuttons/rotate-right.imageset/rotate-right.png b/Box42/Resources/Assets.xcassets/uibuttons/rotate-right.imageset/rotate-right.png new file mode 100644 index 0000000..662594e Binary files /dev/null and b/Box42/Resources/Assets.xcassets/uibuttons/rotate-right.imageset/rotate-right.png differ diff --git a/Box42/Resources/Assets.xcassets/uibuttons/toggle-off.imageset/Contents.json b/Box42/Resources/Assets.xcassets/uibuttons/toggle-off.imageset/Contents.json new file mode 100644 index 0000000..c71abfa --- /dev/null +++ b/Box42/Resources/Assets.xcassets/uibuttons/toggle-off.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "toggle-off.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Box42/Resources/Assets.xcassets/uibuttons/toggle-off.imageset/toggle-off.png b/Box42/Resources/Assets.xcassets/uibuttons/toggle-off.imageset/toggle-off.png new file mode 100644 index 0000000..01634fd Binary files /dev/null and b/Box42/Resources/Assets.xcassets/uibuttons/toggle-off.imageset/toggle-off.png differ diff --git a/Box42/Resources/Assets.xcassets/uibuttons/toggle-on.imageset/Contents.json b/Box42/Resources/Assets.xcassets/uibuttons/toggle-on.imageset/Contents.json new file mode 100644 index 0000000..44dd8e0 --- /dev/null +++ b/Box42/Resources/Assets.xcassets/uibuttons/toggle-on.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "toggle-on.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Box42/Resources/Assets.xcassets/uibuttons/toggle-on.imageset/toggle-on.png b/Box42/Resources/Assets.xcassets/uibuttons/toggle-on.imageset/toggle-on.png new file mode 100644 index 0000000..f47e732 Binary files /dev/null and b/Box42/Resources/Assets.xcassets/uibuttons/toggle-on.imageset/toggle-on.png differ diff --git a/Box42/Resources/Box42.entitlements b/Box42/Resources/Box42.entitlements index aa078cb..1b4b0b0 100644 --- a/Box42/Resources/Box42.entitlements +++ b/Box42/Resources/Box42.entitlements @@ -6,7 +6,11 @@ com.apple.security.automation.apple-events - com.apple.security.files.user-selected.read-only + com.apple.security.device.camera + + com.apple.security.files.downloads.read-write + + com.apple.security.files.user-selected.read-write com.apple.security.network.client diff --git a/Box42/Scripts/Scripts.swift b/Box42/Scripts/Scripts.swift index 96323f7..2feac26 100644 --- a/Box42/Scripts/Scripts.swift +++ b/Box42/Scripts/Scripts.swift @@ -8,8 +8,8 @@ import Foundation struct Scripts { - var info: [(name: String, description: String)] = [("cleanCache", "cleaning cache"), ("brewInGoinfre", - "brew download in goinfre")] + var info: [(name: String, description: String)] = [("cleanCache", "cleaning cache"), + ("brewInGoinfre", "brew download in goinfre")] } struct Script { diff --git a/Box42/Shared/BoxSizeManager.swift b/Box42/Shared/BoxSizeManager.swift index acd32f4..1e80c2b 100644 --- a/Box42/Shared/BoxSizeManager.swift +++ b/Box42/Shared/BoxSizeManager.swift @@ -22,13 +22,13 @@ struct BoxSizeManager { init() { halfSize = (NSScreen.halfOfScreen.x, NSScreen.halfOfScreen.y) - size = (NSScreen.customScreenSize.x, NSScreen.customScreenSize.y) - buttonGroupSize = (CGFloat(132), NSScreen.customScreenSize.y) - toolbarGroupSize = (CGFloat(132), CGFloat(100)) + size = (NSScreen.customScreenSize.width, NSScreen.customScreenSize.height) + buttonGroupSize = (NSScreen.buttonGroupSize.width, NSScreen.buttonGroupSize.height) + toolbarGroupSize = (NSScreen.buttonGroupSize.width, CGFloat(100)) viewStack = [NSView()] boxViewSizeNSRect = NSRect(x: 0, y: 0, width: size.width, height: size.height) boxViewSizeNSSize = NSSize(width: size.width, height: size.height) buttonGroupSizeNSRect = NSRect(x: 0, y: 0, width: buttonGroupSize.width, height: buttonGroupSize.height) - windowButtonGroupSize = (CGFloat(200), NSScreen.customScreenSize.y) + windowButtonGroupSize = (NSScreen.buttonGroupSize.width, NSScreen.customScreenSize.height) } } diff --git a/Box42/Shared/Constants.swift b/Box42/Shared/Constants.swift index 322faa9..4484e4a 100644 --- a/Box42/Shared/Constants.swift +++ b/Box42/Shared/Constants.swift @@ -7,11 +7,13 @@ struct Constants { struct url { - static let InitialName = "home" - static let InitialPage = "https://42box.github.io/front-end/" + static let initialName = "home" + static let initialPage = "https://42box.github.io/front-end/" } struct UI { - static let GroupAutolayout = 12 + static let groupAutolayout = 16 + static let topWindow = 64 - 16 + static let leadingWindow = 14 } } diff --git a/Box42/Shared/StateManager.swift b/Box42/Shared/StateManager.swift index e73da57..e62b1e3 100644 --- a/Box42/Shared/StateManager.swift +++ b/Box42/Shared/StateManager.swift @@ -7,62 +7,59 @@ class StateManager { static let shared = StateManager() - - private var isPin: Bool! - private var isShowCPUUsage: Bool! - private var isShowWindow: Bool! - private var isShowFirstWindow: Bool! - private var isAutoStorage: Bool! - private init() { - isPin = false - isShowCPUUsage = false - isShowWindow = false - isShowFirstWindow = false - isAutoStorage = true - } + private var _pin: Bool = false + private var _showCPUUsage: Bool = false + private var _showWindow: Bool = false + private var _showFirstWindow: Bool = false + private var _autoStorage: Bool = true - func getIsPin() -> Bool { - return isPin + var pin: Bool { + get { return _pin } + set { _pin = newValue } } - func setToggleIsPin() { - isPin.toggle() + func togglePin() { + _pin.toggle() } - func getIsShowCPUUsage() -> Bool { - return isShowCPUUsage + var showCPUUsage: Bool { + get { return _showCPUUsage } + set { _showCPUUsage = newValue } } - - func setToggleIsShowCPUUsage() { - isShowCPUUsage.toggle() + + func toggleShowCPUUsage() { + _showCPUUsage.toggle() } - func getIsShowWindow() -> Bool { - return isShowWindow + var showWindow: Bool { + get { return _showWindow } + set { _showWindow = newValue } } - func setToggleIsShowWindow() { - isShowWindow.toggle() + func toggleShowWindow() { + _showWindow.toggle() } - func getIsShowFirstWindow() -> Bool { - return isShowFirstWindow + var showFirstWindow: Bool { + get { return _showFirstWindow } + set { _showFirstWindow = newValue } } - - func setToggleIsShowFirstWindow() { - isShowFirstWindow.toggle() + + func toggleShowFirstWindow() { + _showFirstWindow.toggle() } - func getIsAutoStorage() -> Bool { - return isAutoStorage + var autoStorage: Bool { + get { return _autoStorage } + set { _autoStorage = newValue } } - func setOffIsAutoStorage() { - isAutoStorage = false + func setOffAutoStorage() { + _autoStorage = false } - func setOnIsAutoStorage() { - isAutoStorage = true + func setOnAutoStorage() { + _autoStorage = true } } diff --git a/Box42/System/CPU.swift b/Box42/System/CPU.swift index f7a8dbf..9f70003 100644 --- a/Box42/System/CPU.swift +++ b/Box42/System/CPU.swift @@ -52,7 +52,7 @@ class CPU { cpuTimer = Timer.scheduledTimer(withTimeInterval: 5.0, repeats: true, block: { _ in self.usageCPU() statusBar.interval = 0.02 * (100 - max(0.0, min(99.0, self.usage.value))) / 6 - statusBar.statusItem.button?.title = StateManager.shared.getIsShowCPUUsage() ? self.usage.description : "" + statusBar.statusItem.button?.title = StateManager.shared.showCPUUsage ? self.usage.description : "" }) self.cpuTimer?.fire() return true diff --git a/Box42/System/Storage.swift b/Box42/System/Storage.swift index 4024446..a728ffb 100644 --- a/Box42/System/Storage.swift +++ b/Box42/System/Storage.swift @@ -55,7 +55,7 @@ class Storage { func storageTimerEvent(){ storageTimer?.invalidate() - if StateManager.shared.getIsAutoStorage() == false { + if StateManager.shared.autoStorage == false { return } @@ -72,7 +72,7 @@ class Storage { if usagePercentage < self.config.threshold.rawValue { self.cleanSh() self.count += 1 - if self.count > 2 { + if self.count > 1 { // showMessageWithAppleScript("캐시 문제가 아닙니다. ncdu ~ 를 확인해주세요.", "재시작") { button in // print("timer") // dump(button) @@ -89,8 +89,7 @@ class Storage { // } // } // } - StateManager.shared.setOffIsAutoStorage() - // 여기서도 타이머를 중지시켜야 합니다. + StateManager.shared.setOffAutoStorage() self.storageTimer?.invalidate() } else { print("\(usedUsage.roundedToTwoDecimalPlaces) GB", "Storage used is less than 30%") diff --git a/Box42/Toolbar/View/BoxToolbarViewGroup.swift b/Box42/Toolbar/View/BoxToolbarViewGroup.swift index 3d63053..00628df 100644 --- a/Box42/Toolbar/View/BoxToolbarViewGroup.swift +++ b/Box42/Toolbar/View/BoxToolbarViewGroup.swift @@ -9,12 +9,12 @@ import AppKit import SnapKit class BoxToolbarViewGroup: NSView { - var displayURL = DisplayURLInToolbar() - lazy var sidebarLeading: SideBarLeading = SideBarLeading(image: NSImage(imageLiteralResourceName: "sidebar.leading"), completion: { self.goBack?() }) - lazy var goBackButton: GoBackInToolbar = GoBackInToolbar(image: NSImage(imageLiteralResourceName: "arrow.left"), completion: { self.goFoward?()} ) - lazy var goForwardButton: GoForwardInToolbar = GoForwardInToolbar(image: NSImage(imageLiteralResourceName: "arrow.right"), completion: { self.reloadPage?() }) - lazy var reloadPageButton: ReloadPageViaToolbar = ReloadPageViaToolbar(image: NSImage(imageLiteralResourceName: "arrow.clockwise"), completion: { self.goToHome?() }) - lazy var goHomePageViaButton: GoHomePageViaToolbar = GoHomePageViaToolbar(image: NSImage(imageLiteralResourceName: "figure.skating"), completion: { self.sidebar?() }) + var displayURL: DisplayURLInToolbar = DisplayURLInToolbar() + lazy var sidebarLeading: SideBarLeading = SideBarLeading(image: NSImage(imageLiteralResourceName: "toggle-off"), completion: { [weak self] in self?.sidebar?() }) + lazy var goBackButton: GoBackInToolbar = GoBackInToolbar(image: NSImage(imageLiteralResourceName: "arrow-left"), completion: { [weak self] in self?.goBack?() }) + lazy var goForwardButton: GoForwardInToolbar = GoForwardInToolbar(image: NSImage(imageLiteralResourceName: "arrow-right"), completion: { [weak self] in self?.goFoward?()} ) + lazy var reloadPageButton: ReloadPageViaToolbar = ReloadPageViaToolbar(image: NSImage(imageLiteralResourceName: "rotate-right"), completion: { [weak self] in self?.reloadPage?() }) + lazy var goHomePageViaButton: GoHomePageViaToolbar = GoHomePageViaToolbar(image: NSImage(imageLiteralResourceName: "figure.skating"), completion: { [weak self] in self?.goToHome?() }) var goBack: (() -> Void)? var goFoward: (() -> Void)? @@ -35,50 +35,47 @@ class BoxToolbarViewGroup: NSView { } private func setupViews() { - self.addSubview(displayURL) - self.addSubview(sidebarLeading) self.addSubview(goBackButton) self.addSubview(goForwardButton) self.addSubview(reloadPageButton) - self.addSubview(goHomePageViaButton) + self.addSubview(sidebarLeading) + self.addSubview(displayURL) +// self.addSubview(goHomePageViaButton) } private func setupConstraints() { - displayURL.snp.makeConstraints { make in - make.top.equalToSuperview() - make.left.right.equalToSuperview() - } - - sidebarLeading.snp.makeConstraints { make in - make.top.equalTo(displayURL).offset(10) - make.bottom.equalToSuperview() - make.left.equalToSuperview() - make.width.equalTo(goBackButton) - } - goBackButton.snp.makeConstraints { make in - make.top.bottom.equalTo(sidebarLeading) - make.left.equalTo(sidebarLeading.snp.right).offset(10) - make.width.equalTo(goForwardButton) + make.top.equalToSuperview() + make.left.equalToSuperview().offset(2) + make.width.equalTo(24) + make.height.equalTo(24) } goForwardButton.snp.makeConstraints { make in - make.top.bottom.equalTo(sidebarLeading) - make.left.equalTo(goBackButton.snp.right).offset(10) - make.width.equalTo(reloadPageButton) + make.top.bottom.equalTo(goBackButton) + make.left.equalTo(goBackButton.snp.right).offset(14) + make.width.equalTo(24) + make.height.equalTo(24) } reloadPageButton.snp.makeConstraints { make in - make.top.bottom.equalTo(sidebarLeading) - make.left.equalTo(goForwardButton.snp.right).offset(10) - make.width.equalTo(goHomePageViaButton) + make.top.bottom.equalTo(goBackButton) + make.left.equalTo(goForwardButton.snp.right).offset(14) + make.width.equalTo(24) + make.height.equalTo(24) } - goHomePageViaButton.snp.makeConstraints { make in - make.top.bottom.equalTo(sidebarLeading) - make.left.equalTo(reloadPageButton.snp.right).offset(10) + sidebarLeading.snp.makeConstraints { make in + make.top.equalToSuperview() make.right.equalToSuperview() + make.width.equalTo(24) + make.height.equalTo(24) } + displayURL.snp.makeConstraints { make in + make.top.equalTo(goBackButton.snp.bottom).offset(14) + make.left.right.equalToSuperview() + make.height.equalTo(44) + } } } diff --git a/Box42/Toolbar/View/DisplayURLInToolbar.swift b/Box42/Toolbar/View/DisplayURLInToolbar.swift index d8026dd..59ff65b 100644 --- a/Box42/Toolbar/View/DisplayURLInToolbar.swift +++ b/Box42/Toolbar/View/DisplayURLInToolbar.swift @@ -6,28 +6,94 @@ // import AppKit +import WebKit +import SnapKit -class DisplayURLInToolbar: NSTextField { +class DisplayURLInToolbar: NSView { + var URLTextfield: DisplayURLTextfield = DisplayURLTextfield() + var originalString: String = "" override init(frame frameRect: NSRect) { - super.init(frame: frameRect) + super.init(frame: .zero) + self.wantsLayer = true + self.layer?.backgroundColor = NSColor(hex: "#7FFFFFFF").cgColor + self.layer?.cornerRadius = 13 - self.isEditable = true - self.isBordered = false // 테두리를 제거합니다. - self.backgroundColor = NSColor.clear // 배경색을 투명하게 만듭니다. + WebViewManager.shared.hostingWebView?.navigationDelegate = self - if let url = WebViewManager.shared.hostingWebView?.url { - self.stringValue = url.absoluteString + self.addSubview(URLTextfield) + textfieldInit() + textfieldConstraints() + + updateURL() + } + + func textfieldInit() { + URLTextfield.font = NSFont.systemFont(ofSize: 15) + URLTextfield.maximumNumberOfLines = 1 + URLTextfield.lineBreakMode = .byTruncatingTail + URLTextfield.isEditable = true + URLTextfield.isBordered = false + URLTextfield.backgroundColor = NSColor.clear + URLTextfield.focusRingType = .none + URLTextfield.isAutomaticTextCompletionEnabled = false + URLTextfield.delegate = self + URLTextfield.onTextFieldRestore = { + self.URLTextfield.stringValue = self.originalString } } - + + func textfieldConstraints() { + URLTextfield.snp.makeConstraints { make in + make.centerY.equalToSuperview() + make.leading.equalToSuperview().offset(17) + make.trailing.equalToSuperview().offset(-17) + } + } + required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } +} + +extension DisplayURLInToolbar: NSTextFieldDelegate { + func control(_ control: NSControl, textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool { + if commandSelector == #selector(insertNewline(_:)) { + var urlString = URLTextfield.stringValue + let validateURL = urlString.split(separator: "/").map({String($0)}) + if validateURL.count < 1 { + return false + } else if validateURL[0] != "https:" && validateURL[0] != "http:" { + urlString = "https://" + urlString + } + + if let url = URL(string: urlString) { + DispatchQueue.main.async { + print(url) + WebViewManager.shared.hostingWebView?.load(URLRequest(url: url)) + } + } + return true + } + return false + } +} +extension DisplayURLInToolbar: WKNavigationDelegate { func updateURL() { if let url = WebViewManager.shared.hostingWebView?.url { - self.stringValue = url.absoluteString + originalString = url.absoluteString + let showURLString: [String?] = originalString.split(separator: "/").map{String($0)} + if showURLString.count > 1 { + URLTextfield.stringValue = (showURLString[1] ?? "") + } } } } + +extension DisplayURLInToolbar { + func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { + print("Navigation finished") + updateURL() + } +} diff --git a/Box42/Toolbar/View/DisplayURLTextfield.swift b/Box42/Toolbar/View/DisplayURLTextfield.swift new file mode 100644 index 0000000..ea65859 --- /dev/null +++ b/Box42/Toolbar/View/DisplayURLTextfield.swift @@ -0,0 +1,26 @@ +// +// DisplayURLTextfield.swift +// Box42 +// +// Created by Chanhee Kim on 8/25/23. +// + +import AppKit + +class DisplayURLTextfield: NSTextField { + var onTextFieldRestore: (() -> Void)? + + override func mouseDown(with event: NSEvent) { + onTextFieldRestore?() + super.mouseDown(with: event) + } + + override func keyUp(with event: NSEvent) { + if event.keyCode == 53 { + print("url") + onTextFieldRestore?() + } else { + super.keyUp(with: event) + } + } +} diff --git a/Box42/Toolbar/View/GoBackInToolbar.swift b/Box42/Toolbar/View/GoBackInToolbar.swift index 6bb209f..9e3a8c3 100644 --- a/Box42/Toolbar/View/GoBackInToolbar.swift +++ b/Box42/Toolbar/View/GoBackInToolbar.swift @@ -15,10 +15,14 @@ class GoBackInToolbar: NSButton { super.init(frame: .zero) self.image = image - self.bezelStyle = .texturedRounded + self.isBordered = false // 버튼의 테두리를 제거 + self.wantsLayer = true + self.layer?.backgroundColor = NSColor.clear.cgColor self.target = self self.action = #selector(goBackWebView) self.callback = completion + self.wantsLayer = true + self.layer?.backgroundColor = .clear } required init?(coder: NSCoder) { diff --git a/Box42/Toolbar/View/GoForwardInToolbar.swift b/Box42/Toolbar/View/GoForwardInToolbar.swift index e5f04fb..5556d05 100644 --- a/Box42/Toolbar/View/GoForwardInToolbar.swift +++ b/Box42/Toolbar/View/GoForwardInToolbar.swift @@ -15,10 +15,14 @@ class GoForwardInToolbar: NSButton { super.init(frame: .zero) self.image = image - self.bezelStyle = .texturedRounded + self.isBordered = false // 버튼의 테두리를 제거 + self.wantsLayer = true + self.layer?.backgroundColor = NSColor.clear.cgColor self.target = self self.action = #selector(goForwardWebView) self.callback = completion + self.wantsLayer = true + self.layer?.backgroundColor = .clear } required init?(coder: NSCoder) { diff --git a/Box42/Toolbar/View/GoHomePageViaToolbar().swift b/Box42/Toolbar/View/GoHomePageViaToolbar().swift index 2728ff3..c647cc1 100644 --- a/Box42/Toolbar/View/GoHomePageViaToolbar().swift +++ b/Box42/Toolbar/View/GoHomePageViaToolbar().swift @@ -15,7 +15,9 @@ class GoHomePageViaToolbar: NSButton { super.init(frame: .zero) self.image = image - self.bezelStyle = .texturedRounded + self.isBordered = false // 버튼의 테두리를 제거 + self.wantsLayer = true + self.layer?.backgroundColor = NSColor.clear.cgColor self.target = self self.action = #selector(goToHomePageWebView) self.callback = completion diff --git a/Box42/Toolbar/View/RefreshPageViaToolbar.swift b/Box42/Toolbar/View/RefreshPageViaToolbar.swift index 8be72bc..8c4ef50 100644 --- a/Box42/Toolbar/View/RefreshPageViaToolbar.swift +++ b/Box42/Toolbar/View/RefreshPageViaToolbar.swift @@ -15,7 +15,11 @@ class ReloadPageViaToolbar: NSButton { super.init(frame: .zero) self.image = image - self.bezelStyle = .texturedRounded + self.isBordered = false // 버튼의 테두리를 제거 + self.wantsLayer = true + self.layer?.backgroundColor = NSColor.clear.cgColor + self.wantsLayer = true + self.layer?.backgroundColor = .clear self.target = self self.action = #selector(reloadWebView) self.callback = completion diff --git a/Box42/Toolbar/View/SideBarLeading.swift b/Box42/Toolbar/View/SideBarLeading.swift index 9849a05..24c2f1c 100644 --- a/Box42/Toolbar/View/SideBarLeading.swift +++ b/Box42/Toolbar/View/SideBarLeading.swift @@ -15,10 +15,14 @@ class SideBarLeading: NSButton { super.init(frame: .zero) self.image = image - self.bezelStyle = .texturedRounded + self.isBordered = false // 버튼의 테두리를 제거 + self.wantsLayer = true + self.layer?.backgroundColor = NSColor.clear.cgColor self.target = self self.action = #selector(sideBarLeading) self.callback = completion + self.wantsLayer = true + self.layer?.backgroundColor = .clear } required init?(coder: NSCoder) { diff --git a/Box42/UI/MovableContainerView.swift b/Box42/UI/MovableContainerView.swift index 69c4042..bd8dba6 100644 --- a/Box42/UI/MovableContainerView.swift +++ b/Box42/UI/MovableContainerView.swift @@ -9,7 +9,7 @@ import AppKit class MovableContainerView: NSView { init() { - super.init(frame: NSRect(x: 0, y: 0, width: 300, height: BoxSizeManager.shared.size.height)) + super.init(frame: .zero) } required init?(coder: NSCoder) { diff --git a/Box42/Box/View/BoxBaseSplitView.swift b/Box42/View/BoxBaseSplitView.swift similarity index 100% rename from Box42/Box/View/BoxBaseSplitView.swift rename to Box42/View/BoxBaseSplitView.swift diff --git a/Box42/Box/View/BoxContentsViewGroup.swift b/Box42/View/BoxContentsViewGroup.swift similarity index 97% rename from Box42/Box/View/BoxContentsViewGroup.swift rename to Box42/View/BoxContentsViewGroup.swift index 596a5d1..1eb1ee5 100644 --- a/Box42/Box/View/BoxContentsViewGroup.swift +++ b/Box42/View/BoxContentsViewGroup.swift @@ -69,7 +69,6 @@ class BoxContentsViewGroup: NSView { } currentWebview.viewDidMoveToSuperview() - currentWebview.becomeFirstResponder() } } diff --git a/Box42/WebView/WebView.swift b/Box42/WebView/WebView.swift index 0e909ad..e12930e 100644 --- a/Box42/WebView/WebView.swift +++ b/Box42/WebView/WebView.swift @@ -7,7 +7,7 @@ import WebKit -class WebView: WKWebView, WKScriptMessageHandler, WKUIDelegate, WKNavigationDelegate { +class WebView: WKWebView, WKScriptMessageHandler, WKUIDelegate { func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { print("userContentController") } @@ -25,14 +25,13 @@ class WebView: WKWebView, WKScriptMessageHandler, WKUIDelegate, WKNavigationDele super.init(frame: .zero, configuration: configuration) - contentController.add(self, name: "box") // Moved after super.init + contentController.add(self, name: "box") self.configuration.preferences.javaScriptCanOpenWindowsAutomatically = true self.configuration.preferences.javaScriptEnabled = true self.configuration.preferences.setValue(true, forKey: "allowFileAccessFromFileURLs") self.uiDelegate = self - self.navigationDelegate = self self.becomeFirstResponder() } diff --git a/Box42/WebView/WebViewModel.swift b/Box42/WebView/WebViewModel.swift index 2e091a0..d9af17b 100644 --- a/Box42/WebView/WebViewModel.swift +++ b/Box42/WebView/WebViewModel.swift @@ -17,7 +17,7 @@ class WebViewModel: ObservableObject { private var cancellables = Set() init() { - self.webViewURL = URLModels(info: [URLModel(name: Constants.url.InitialName, url: Constants.url.InitialPage)]) + self.webViewURL = URLModels(info: [URLModel(name: Constants.url.initialName, url: Constants.url.initialPage)]) self.URLdict = URLMapping() $webViewURL.sink { (WVURL) in @@ -43,11 +43,11 @@ class WebViewModel: ObservableObject { } func readURL(_ index: Int) -> URL { - return URL(string: webViewURL.info[index].url) ?? URL(string: Constants.url.InitialPage)! + return URL(string: webViewURL.info[index].url) ?? URL(string: Constants.url.initialPage)! } func safeURL() -> URL { - return URL(string: webViewURL.info.first?.url ?? Constants.url.InitialPage)! + return URL(string: webViewURL.info.first?.url ?? Constants.url.initialPage)! } func requestURL(_ url: URL) -> URLRequest { diff --git a/Box42/Window/BoxWindowController.swift b/Box42/Window/BoxWindowController.swift deleted file mode 100644 index 063dd96..0000000 --- a/Box42/Window/BoxWindowController.swift +++ /dev/null @@ -1,136 +0,0 @@ -// -// BoxWindowController.swift -// Box42 -// -// Created by Chanhee Kim on 8/11/23. -// - -import Cocoa - -class BoxWindowController: NSWindowController, NSToolbarDelegate, NSWindowDelegate { - override init(window: NSWindow?) { - let contentRect = BoxSizeManager.shared.boxViewSizeNSRect - let styleMask: NSWindow.StyleMask = [.resizable, .closable, .miniaturizable, .fullSizeContentView] - let windowInstance = NSWindow(contentRect: contentRect, styleMask: styleMask, backing: .buffered, defer: false) - - windowInstance.titlebarAppearsTransparent = true - windowInstance.titleVisibility = .hidden - windowInstance.title = "Box" - windowInstance.isReleasedWhenClosed = false - windowInstance.isOpaque = false - windowInstance.backgroundColor = .clear - windowInstance.isMovableByWindowBackground = true - - let boxViewController = BoxViewController(nibName: nil, bundle: nil) - windowInstance.contentViewController = boxViewController - - super.init(window: windowInstance) - - windowInstance.delegate = self - -// setupToolbar() - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } -} - -extension BoxWindowController { - func windowShouldClose(_ sender: NSWindow) -> Bool { -// NSApplication.shared.terminate(self) - StateManager.shared.setToggleIsShowWindow() - return true - } -} - -// MARK: - Toolbar -extension BoxWindowController { - func setupToolbar() { - let toolbar = NSToolbar(identifier: "MainToolbar") - toolbar.delegate = self - toolbar.displayMode = .iconOnly - toolbar.sizeMode = .small - self.window?.toolbar = toolbar - } - - func toolbarDefaultItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] { - return [.group] - } - - func toolbarAllowedItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] { - return [.group, .flexibleSpace, .sidebar, .flexibleSpace, .goBack, .flexibleSpace, .goFoward, .flexibleSpace, .reloadPage, .flexibleSpace, .goToHome] - } - - func toolbar(_ toolbar: NSToolbar, itemForItemIdentifier itemIdentifier: NSToolbarItem.Identifier, willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem? { - switch itemIdentifier { - case .group: - let groupItem = NSToolbarItemGroup(itemIdentifier: .group) - - let sidebarItem = NSToolbarItem(itemIdentifier: .sidebar) - sidebarItem.label = "Sidebar" - sidebarItem.image = NSImage(named: NSImage.Name("sidebar.leading")) - sidebarItem.action = #selector(toggleSidebar) - sidebarItem.minSize = NSSize(width: 40, height: 40) - sidebarItem.maxSize = NSSize(width: 40, height: 40) - - let goBack = NSToolbarItem(itemIdentifier: .goBack) - goBack.label = "left" - goBack.image = NSImage(named: NSImage.Name("arrow.left")) // 이미지 설정 - goBack.action = #selector(goBackAction) // 해당 action 설정 - - let goFoward = NSToolbarItem(itemIdentifier: .goFoward) - goFoward.label = "right" - goFoward.image = NSImage(named: NSImage.Name("arrow.right")) - goFoward.action = #selector(goFowardAction) - - let reloadPage = NSToolbarItem(itemIdentifier: .reloadPage) - reloadPage.label = "clockwise" - reloadPage.image = NSImage(named: NSImage.Name("arrow.clockwise")) - reloadPage.action = #selector(reloadPageAction) - - let goToHome = NSToolbarItem(itemIdentifier: .goToHome) - goToHome.label = "skating" - goToHome.image = NSImage(named: NSImage.Name("figure.skating")) - goToHome.action = #selector(goToHomeAction) - - groupItem.subitems = [sidebarItem, goBack, goFoward, reloadPage, goToHome] - - return groupItem - - default: - return nil - } - } - - @objc func toggleSidebar() { - print("sidebar") - } - - @objc func goBackAction() { - WebViewManager.shared.hostingWebView?.goBack() - } - - @objc func goFowardAction() { - WebViewManager.shared.hostingWebView?.goForward() - } - - @objc func reloadPageAction() { - WebViewManager.shared.hostingWebView?.reload() - } - - @objc func goToHomeAction() { - if let item = WebViewManager.shared.hostingWebView?.backForwardList.backList.first { - WebViewManager.shared.hostingWebView?.go(to: item) - } - } -} - -extension NSToolbarItem.Identifier { - static let sidebar = NSToolbarItem.Identifier(rawValue: "SidebarButton") - static let goBack = NSToolbarItem.Identifier(rawValue: "goBackButton") - static let goFoward = NSToolbarItem.Identifier(rawValue: "goFowardButton") - static let reloadPage = NSToolbarItem.Identifier(rawValue: "reloadPageButton") - static let goToHome = NSToolbarItem.Identifier(rawValue: "goToHomeButton") - static let group = NSToolbarItem.Identifier(rawValue: "ItemGroup") -} diff --git a/Box42/Window/View/WindowCloseButton.swift b/Box42/Window/View/WindowCloseButton.swift deleted file mode 100644 index 0e9a747..0000000 --- a/Box42/Window/View/WindowCloseButton.swift +++ /dev/null @@ -1,31 +0,0 @@ -// -// WindowCloseButton.swift -// Box42 -// -// Created by Chanhee Kim on 8/23/23. -// - -import AppKit - -class WindowCloseButton: NSButton { - - private var callback: (() -> Void)? - - init(image: NSImage, completion: @escaping () -> Void) { - super.init(frame: .zero) - - self.title = "X" // 기본적인 X 모양으로 표시. 이미지나 다른 디자인을 원하시면 변경하실 수 있습니다. - self.bezelStyle = .texturedRounded - self.target = self - self.action = #selector(closeAction) - self.callback = completion - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - @objc func closeAction() { - callback?() - } -} diff --git a/Box42/Window/View/WindowMaximizeButton.swift b/Box42/Window/View/WindowMaximizeButton.swift deleted file mode 100644 index dde3691..0000000 --- a/Box42/Window/View/WindowMaximizeButton.swift +++ /dev/null @@ -1,31 +0,0 @@ -// -// WindowMaximizeButton.swift -// Box42 -// -// Created by Chanhee Kim on 8/23/23. -// - -import AppKit - -class WindowMaximizeButton: NSButton { - - private var callback: (() -> Void)? - - init(image: NSImage, completion: @escaping () -> Void) { - super.init(frame: .zero) - - self.title = "□" // 기본적인 □ 모양으로 표시. 변경 가능. - self.bezelStyle = .texturedRounded - self.target = self - self.action = #selector(maximizeAction) - self.callback = completion - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - @objc func maximizeAction() { - callback?() - } -} diff --git a/Box42/Window/View/WindowMinimizeButton.swift b/Box42/Window/View/WindowMinimizeButton.swift deleted file mode 100644 index e940fb5..0000000 --- a/Box42/Window/View/WindowMinimizeButton.swift +++ /dev/null @@ -1,31 +0,0 @@ -// -// WindowMinimizeButton.swift -// Box42 -// -// Created by Chanhee Kim on 8/23/23. -// - -import AppKit - -class WindowMinimizeButton: NSButton { - - private var callback: (() -> Void)? - - init(image: NSImage, completion: @escaping () -> Void) { - super.init(frame: .zero) - - self.title = "_" // 기본적인 _ 모양으로 표시. 변경 가능. - self.bezelStyle = .texturedRounded - self.target = self - self.action = #selector(minimizeAction) - self.callback = completion - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - @objc func minimizeAction() { - callback?() - } -} diff --git a/Box42/WindowButton/View/WindowCloseButton.swift b/Box42/WindowButton/View/WindowCloseButton.swift new file mode 100644 index 0000000..84074b3 --- /dev/null +++ b/Box42/WindowButton/View/WindowCloseButton.swift @@ -0,0 +1,55 @@ +// +// WindowCloseButton.swift +// Box42 +// +// Created by Chanhee Kim on 8/23/23. +// + +import AppKit + +class WindowCloseButton: NSButton { + + private var callback: (() -> Void)? + + init(completion: @escaping () -> Void) { + super.init(frame: NSRect(x: 0, y: 0, width: 21, height: 21)) + + self.title = "" + self.isBordered = false + self.wantsLayer = true + self.layer?.cornerRadius = 21 / 2 + self.layer?.backgroundColor = NSColor.white.cgColor + self.target = self + self.action = #selector(closeAction) + self.callback = completion + + let trackingArea = NSTrackingArea(rect: self.bounds, options: [.mouseEnteredAndExited, .activeAlways], owner: self, userInfo: nil) + self.addTrackingArea(trackingArea) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + @objc func closeAction() { + callback?() + } + + override func mouseEntered(with event: NSEvent) { + super.mouseEntered(with: event) + + NSAnimationContext.runAnimationGroup({ (context) in + context.duration = 2 + self.layer?.backgroundColor = NSColor.red.cgColor + }, completionHandler: nil) + } + + override func mouseExited(with event: NSEvent) { + super.mouseExited(with: event) + + NSAnimationContext.runAnimationGroup({ (context) in + context.duration = 2 + self.layer?.backgroundColor = NSColor.white.cgColor + }, completionHandler: nil) + } +} diff --git a/Box42/WindowButton/View/WindowMaximizeButton.swift b/Box42/WindowButton/View/WindowMaximizeButton.swift new file mode 100644 index 0000000..5934059 --- /dev/null +++ b/Box42/WindowButton/View/WindowMaximizeButton.swift @@ -0,0 +1,55 @@ +// +// WindowMaximizeButton.swift +// Box42 +// +// Created by Chanhee Kim on 8/23/23. +// + +import AppKit + +class WindowMaximizeButton: NSButton { + + private var callback: (() -> Void)? + + init(completion: @escaping () -> Void) { + super.init(frame: NSRect(x: 0, y: 0, width: 21, height: 21)) + + self.title = "" + self.isBordered = false + self.wantsLayer = true + self.layer?.cornerRadius = 21 / 2 + self.layer?.backgroundColor = NSColor.white.cgColor + self.target = self + self.action = #selector(maximizeAction) + self.callback = completion + + let trackingArea = NSTrackingArea(rect: self.bounds, options: [.mouseEnteredAndExited, .activeAlways], owner: self, userInfo: nil) + self.addTrackingArea(trackingArea) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + @objc func maximizeAction() { + callback?() + } + + override func mouseEntered(with event: NSEvent) { + super.mouseEntered(with: event) + + NSAnimationContext.runAnimationGroup({ (context) in + context.duration = 2 + self.layer?.backgroundColor = NSColor.green.cgColor + }, completionHandler: nil) + } + + override func mouseExited(with event: NSEvent) { + super.mouseExited(with: event) + + NSAnimationContext.runAnimationGroup({ (context) in + context.duration = 2 + self.layer?.backgroundColor = NSColor.white.cgColor + }, completionHandler: nil) + } +} diff --git a/Box42/WindowButton/View/WindowMinimizeButton.swift b/Box42/WindowButton/View/WindowMinimizeButton.swift new file mode 100644 index 0000000..c628742 --- /dev/null +++ b/Box42/WindowButton/View/WindowMinimizeButton.swift @@ -0,0 +1,55 @@ +// +// WindowMinimizeButton.swift +// Box42 +// +// Created by Chanhee Kim on 8/23/23. +// + +import AppKit + +class WindowMinimizeButton: NSButton { + + private var callback: (() -> Void)? + + init(completion: @escaping () -> Void) { + super.init(frame: NSRect(x: 0, y: 0, width: 21, height: 21)) + + self.title = "" + self.isBordered = false + self.wantsLayer = true + self.layer?.cornerRadius = 21 / 2 + self.layer?.backgroundColor = NSColor.white.cgColor + self.target = self + self.action = #selector(minimizeAction) + self.callback = completion + + let trackingArea = NSTrackingArea(rect: self.bounds, options: [.mouseEnteredAndExited, .activeAlways], owner: self, userInfo: nil) + self.addTrackingArea(trackingArea) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + @objc func minimizeAction() { + callback?() + } + + override func mouseEntered(with event: NSEvent) { + super.mouseEntered(with: event) + + NSAnimationContext.runAnimationGroup({ (context) in + context.duration = 2 + self.layer?.backgroundColor = NSColor.yellow.cgColor + }, completionHandler: nil) + } + + override func mouseExited(with event: NSEvent) { + super.mouseExited(with: event) + + NSAnimationContext.runAnimationGroup({ (context) in + context.duration = 2 + self.layer?.backgroundColor = NSColor.white.cgColor + }, completionHandler: nil) + } +} diff --git a/Box42/Window/View/WindowViewGroup.swift b/Box42/WindowButton/View/WindowViewGroup.swift similarity index 53% rename from Box42/Window/View/WindowViewGroup.swift rename to Box42/WindowButton/View/WindowViewGroup.swift index f96abec..9891bcc 100644 --- a/Box42/Window/View/WindowViewGroup.swift +++ b/Box42/WindowButton/View/WindowViewGroup.swift @@ -9,9 +9,9 @@ import AppKit import SnapKit class WindowViewGroup: NSView { - lazy var windowClose: WindowCloseButton = WindowCloseButton(image: NSImage(imageLiteralResourceName: "sidebar.leading"), completion: { self.close?() }) - lazy var windowMinimize: WindowMinimizeButton = WindowMinimizeButton(image: NSImage(imageLiteralResourceName: "arrow.left"), completion: { self.minimize?()} ) - lazy var windowMaximize: WindowMaximizeButton = WindowMaximizeButton(image: NSImage(imageLiteralResourceName: "arrow.right"), completion: { self.maximize?() }) + lazy var windowClose = WindowCloseButton(completion: { self.close?() }) + lazy var windowMinimize = WindowMinimizeButton(completion: { self.minimize?() }) + lazy var windowMaximize = WindowMaximizeButton(completion: { self.maximize?() }) var close: (() -> Void)? var minimize: (() -> Void)? @@ -38,19 +38,24 @@ class WindowViewGroup: NSView { private func setupConstraints() { windowClose.snp.makeConstraints { make in - make.top.left.bottom.equalToSuperview() - make.width.equalTo(windowMinimize) + make.top.equalToSuperview() + make.left.equalToSuperview() + make.width.equalTo(21) + make.height.equalTo(21) } windowMinimize.snp.makeConstraints { make in make.top.bottom.equalTo(windowClose) - make.left.equalTo(windowClose.snp.right).offset(10) - make.width.equalTo(windowMaximize) + make.left.equalTo(windowClose.snp.right).offset(7) + make.width.equalTo(21) + make.height.equalTo(21) } windowMaximize.snp.makeConstraints { make in - make.top.right.bottom.equalToSuperview() - make.left.equalTo(windowMinimize.snp.right).offset(10) + make.top.bottom.equalTo(windowClose) + make.left.equalTo(windowMinimize.snp.right).offset(7) + make.width.equalTo(21) + make.height.equalTo(21) } } } diff --git a/Box42/Window/WindowButtonViewController.swift b/Box42/WindowButton/WindowButtonViewController.swift similarity index 73% rename from Box42/Window/WindowButtonViewController.swift rename to Box42/WindowButton/WindowButtonViewController.swift index 511ef8c..10dd411 100644 --- a/Box42/Window/WindowButtonViewController.swift +++ b/Box42/WindowButton/WindowButtonViewController.swift @@ -23,14 +23,16 @@ class WindowButtonViewController: NSViewController { } func windowClose() { - print("close") + StateManager.shared.showWindow = false + self.view.window?.close() } func windowMin() { - print("min") + StateManager.shared.showWindow = false + self.view.window?.miniaturize(nil) } func windowMax() { - print("max") + self.view.window?.toggleFullScreen(nil) } }