mirror of
https://github.com/neon443/DockPhobia.git
synced 2026-03-11 06:49:12 +00:00
refactoring
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
A966B4F52DE0842500C721A5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A966B4EF2DE0842400C721A5 /* Assets.xcassets */; };
|
A966B4F52DE0842500C721A5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A966B4EF2DE0842400C721A5 /* Assets.xcassets */; };
|
||||||
A966B4F82DE0852900C721A5 /* MouseTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = A966B4F72DE0852900C721A5 /* MouseTracker.swift */; };
|
A966B4F82DE0852900C721A5 /* MouseTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = A966B4F72DE0852900C721A5 /* MouseTracker.swift */; };
|
||||||
A98C20C62DE614180008D61C /* DPSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = A98C20C52DE614180008D61C /* DPSettings.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 */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
@@ -23,6 +24,7 @@
|
|||||||
A966B4F72DE0852900C721A5 /* MouseTracker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MouseTracker.swift; sourceTree = "<group>"; };
|
A966B4F72DE0852900C721A5 /* MouseTracker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MouseTracker.swift; sourceTree = "<group>"; };
|
||||||
A97798072DE485F200B6CB13 /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
|
A97798072DE485F200B6CB13 /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
|
||||||
A98C20C52DE614180008D61C /* DPSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DPSettings.swift; sourceTree = "<group>"; };
|
A98C20C52DE614180008D61C /* DPSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DPSettings.swift; sourceTree = "<group>"; };
|
||||||
|
A9C9AF802DE777530039D7A5 /* DockSide.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DockSide.swift; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@@ -75,6 +77,7 @@
|
|||||||
A966B4EE2DE0842400C721A5 /* AppDelegate.swift */,
|
A966B4EE2DE0842400C721A5 /* AppDelegate.swift */,
|
||||||
A966B4F72DE0852900C721A5 /* MouseTracker.swift */,
|
A966B4F72DE0852900C721A5 /* MouseTracker.swift */,
|
||||||
A98C20C52DE614180008D61C /* DPSettings.swift */,
|
A98C20C52DE614180008D61C /* DPSettings.swift */,
|
||||||
|
A9C9AF802DE777530039D7A5 /* DockSide.swift */,
|
||||||
A94BEC102DE23ECE00D4811D /* Views */,
|
A94BEC102DE23ECE00D4811D /* Views */,
|
||||||
A94BEC0A2DE21F8100D4811D /* Resources */,
|
A94BEC0A2DE21F8100D4811D /* Resources */,
|
||||||
A966B4F02DE0842400C721A5 /* DockPhobia.entitlements */,
|
A966B4F02DE0842400C721A5 /* DockPhobia.entitlements */,
|
||||||
@@ -158,6 +161,7 @@
|
|||||||
A98C20C62DE614180008D61C /* DPSettings.swift in Sources */,
|
A98C20C62DE614180008D61C /* DPSettings.swift in Sources */,
|
||||||
A966B4F82DE0852900C721A5 /* MouseTracker.swift in Sources */,
|
A966B4F82DE0852900C721A5 /* MouseTracker.swift in Sources */,
|
||||||
A966B4F42DE0842500C721A5 /* AppDelegate.swift in Sources */,
|
A966B4F42DE0842500C721A5 /* AppDelegate.swift in Sources */,
|
||||||
|
A9C9AF812DE7776A0039D7A5 /* DockSide.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
59
DockPhobia/DockSide.swift
Normal file
59
DockPhobia/DockSide.swift
Normal file
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,66 +15,11 @@ struct Screen {
|
|||||||
var height: CGFloat
|
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 {
|
class MouseTracker {
|
||||||
var screen: Screen
|
var screen: Screen
|
||||||
|
|
||||||
var monitor: Any?
|
var monitor: Any?
|
||||||
|
|
||||||
var running: Bool = false
|
var running: Bool = false
|
||||||
|
|
||||||
var currentDockSide: DockSide
|
var currentDockSide: DockSide
|
||||||
|
|
||||||
var dockHeight: CGFloat = 0
|
var dockHeight: CGFloat = 0
|
||||||
|
|
||||||
var settings: DPSettingsModel
|
var settings: DPSettingsModel
|
||||||
|
|||||||
Reference in New Issue
Block a user