diff --git a/DockPhobia.xcodeproj/project.pbxproj b/DockPhobia.xcodeproj/project.pbxproj index f0de0a8..6b4e102 100644 --- a/DockPhobia.xcodeproj/project.pbxproj +++ b/DockPhobia.xcodeproj/project.pbxproj @@ -12,6 +12,7 @@ A966B4F52DE0842500C721A5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A966B4EF2DE0842400C721A5 /* Assets.xcassets */; }; A966B4F82DE0852900C721A5 /* MouseTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = A966B4F72DE0852900C721A5 /* MouseTracker.swift */; }; A98C20C62DE614180008D61C /* DPSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = A98C20C52DE614180008D61C /* DPSettings.swift */; }; + A9C9AF812DE7776A0039D7A5 /* DockSide.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C9AF802DE777530039D7A5 /* DockSide.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -23,6 +24,7 @@ A966B4F72DE0852900C721A5 /* MouseTracker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MouseTracker.swift; sourceTree = ""; }; A97798072DE485F200B6CB13 /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; A98C20C52DE614180008D61C /* DPSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DPSettings.swift; sourceTree = ""; }; + A9C9AF802DE777530039D7A5 /* DockSide.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DockSide.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -75,6 +77,7 @@ A966B4EE2DE0842400C721A5 /* AppDelegate.swift */, A966B4F72DE0852900C721A5 /* MouseTracker.swift */, A98C20C52DE614180008D61C /* DPSettings.swift */, + A9C9AF802DE777530039D7A5 /* DockSide.swift */, A94BEC102DE23ECE00D4811D /* Views */, A94BEC0A2DE21F8100D4811D /* Resources */, A966B4F02DE0842400C721A5 /* DockPhobia.entitlements */, @@ -158,6 +161,7 @@ A98C20C62DE614180008D61C /* DPSettings.swift in Sources */, A966B4F82DE0852900C721A5 /* MouseTracker.swift in Sources */, A966B4F42DE0842500C721A5 /* AppDelegate.swift in Sources */, + A9C9AF812DE7776A0039D7A5 /* DockSide.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/DockPhobia/DockSide.swift b/DockPhobia/DockSide.swift new file mode 100644 index 0000000..b022453 --- /dev/null +++ b/DockPhobia/DockSide.swift @@ -0,0 +1,59 @@ +// +// DockSide.swift +// DockPhobia +// +// Created by neon443 on 28/05/2025. +// + +import Foundation + +enum DockSide: Int, RawRepresentable { + case left + case bottom + case right + + public typealias RawValue = String + + public var rawValue: RawValue { + switch self { + case .left: + return "left" + case .right: + return "right" + case .bottom: + return "bottom" + } + } + + /// Random Dock Side + /// - will return a random Dock Side when calling DockSide() + public init() { + self = DockSide(rawValue: Int.random(in: 1...3))! + } + + public init?(rawValue: String) { + switch rawValue { + case "left": + self = .left + case "right": + self = .right + case "bottom": + self = .bottom + default: + return nil + } + } + + public init?(rawValue: Int) { + switch rawValue { + case 1: + self = .left + case 2: + self = .bottom + case 3: + self = .right + default: + return nil + } + } +} diff --git a/DockPhobia/MouseTracker.swift b/DockPhobia/MouseTracker.swift index a3151b3..16efba5 100644 --- a/DockPhobia/MouseTracker.swift +++ b/DockPhobia/MouseTracker.swift @@ -15,66 +15,11 @@ struct Screen { var height: CGFloat } -enum DockSide: Int, RawRepresentable { - case left - case bottom - case right - - public typealias RawValue = String - - public var rawValue: RawValue { - switch self { - case .left: - return "left" - case .right: - return "right" - case .bottom: - return "bottom" - } - } - - /// Random Dock Side - /// - will return a random Dock Side when calling DockSide() - public init() { - self = DockSide(rawValue: Int.random(in: 1...3))! - } - - public init?(rawValue: String) { - switch rawValue { - case "left": - self = .left - case "right": - self = .right - case "bottom": - self = .bottom - default: - return nil - } - } - - public init?(rawValue: Int) { - switch rawValue { - case 1: - self = .left - case 2: - self = .bottom - case 3: - self = .right - default: - return nil - } - } -} - class MouseTracker { var screen: Screen - var monitor: Any? - var running: Bool = false - var currentDockSide: DockSide - var dockHeight: CGFloat = 0 var settings: DPSettingsModel