Skip to content

Commit ca5287d

Browse files
committed
Feedback Cycle 2: Linter/Formatter
1 parent 8b897e8 commit ca5287d

File tree

13 files changed

+274
-205
lines changed

13 files changed

+274
-205
lines changed

.swiftformat

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--exclude **/Pods
2+
--exclude **/DerivedData
3+
--exclude **/Build
4+
5+
# Thiese rules clashes with SwiftLint.
6+
--disable wrapMultilineStatementBraces
7+
--disable trailingCommas
8+
9+
# Wrapping
10+
--maxwidth 120

.swiftlint.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
reporter: "xcode"
2+
3+
disabled_rules:
4+
- force_cast
5+
- identifier_name

Features/StatusBarController.swift

+55-51
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
//
77

88
import Cocoa
9-
import SwiftUI
109
import ServiceManagement
10+
import SwiftUI
1111

1212
class StatusBarController: ObservableObject {
1313
static let shared = StatusBarController()
1414
private var statusItem: NSStatusItem?
1515
private let windowManager = WindowManager.shared
16-
16+
1717
private init() {
1818
DispatchQueue.main.async {
1919
self.statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength)
@@ -22,126 +22,130 @@ class StatusBarController: ObservableObject {
2222
self.setupLoginItem()
2323
}
2424
}
25-
25+
2626
private func setupLoginItem() {
2727
if let bundleIdentifier = Bundle.main.bundleIdentifier {
2828
if !SMLoginItemSetEnabled(bundleIdentifier as CFString, true) {
2929
print("Login item eklenemedi")
3030
}
3131
}
3232
}
33-
33+
3434
private func setupUI() {
3535
if let button = statusItem?.button {
3636
button.image = NSImage(systemSymbolName: "rectangle.split.3x1", accessibilityDescription: nil)
3737
}
3838
}
39-
39+
4040
private func setupMenus() {
4141
let menu = NSMenu()
42-
42+
4343
// 2/3 Split Menu Items
4444
let leftTwoThirdsItem = NSMenuItem(title: "Left 2/3", action: #selector(leftTwoThirds), keyEquivalent: "")
4545
leftTwoThirdsItem.target = self
4646
menu.addItem(leftTwoThirdsItem)
47-
47+
4848
let rightTwoThirdsItem = NSMenuItem(title: "Right 2/3", action: #selector(rightTwoThirds), keyEquivalent: "")
4949
rightTwoThirdsItem.target = self
5050
menu.addItem(rightTwoThirdsItem)
51-
51+
5252
menu.addItem(NSMenuItem.separator())
53-
53+
5454
// 1/3 Split Menu Items
5555
let leftThirdItem = NSMenuItem(title: "Left 1/3", action: #selector(leftThird), keyEquivalent: "")
5656
leftThirdItem.target = self
5757
menu.addItem(leftThirdItem)
58-
58+
5959
let centerThirdItem = NSMenuItem(title: "Center 1/3", action: #selector(centerThird), keyEquivalent: "")
6060
centerThirdItem.target = self
6161
menu.addItem(centerThirdItem)
62-
62+
6363
let rightThirdItem = NSMenuItem(title: "Right 1/3", action: #selector(rightThird), keyEquivalent: "")
6464
rightThirdItem.target = self
6565
menu.addItem(rightThirdItem)
66-
66+
6767
menu.addItem(NSMenuItem.separator())
68-
68+
6969
// Half Split Menu Items
7070
let leftHalfItem = NSMenuItem(title: "Left Half", action: #selector(leftHalf), keyEquivalent: "")
7171
leftHalfItem.target = self
7272
menu.addItem(leftHalfItem)
73-
73+
7474
let rightHalfItem = NSMenuItem(title: "Right Half", action: #selector(rightHalf), keyEquivalent: "")
7575
rightHalfItem.target = self
7676
menu.addItem(rightHalfItem)
77-
77+
7878
menu.addItem(NSMenuItem.separator())
79-
79+
8080
// Corner Controls
8181
let cornersSubmenu = NSMenu()
82-
82+
8383
let topLeftItem = NSMenuItem(title: "Top Left", action: #selector(topLeft), keyEquivalent: "")
8484
topLeftItem.target = self
8585
cornersSubmenu.addItem(topLeftItem)
86-
86+
8787
let topRightItem = NSMenuItem(title: "Top Right", action: #selector(topRight), keyEquivalent: "")
8888
topRightItem.target = self
8989
cornersSubmenu.addItem(topRightItem)
90-
90+
9191
let bottomLeftItem = NSMenuItem(title: "Bottom Left", action: #selector(bottomLeft), keyEquivalent: "")
9292
bottomLeftItem.target = self
9393
cornersSubmenu.addItem(bottomLeftItem)
94-
94+
9595
let bottomRightItem = NSMenuItem(title: "Bottom Right", action: #selector(bottomRight), keyEquivalent: "")
9696
bottomRightItem.target = self
9797
cornersSubmenu.addItem(bottomRightItem)
98-
98+
9999
let cornersItem = NSMenuItem(title: "Corners", action: nil, keyEquivalent: "")
100100
cornersItem.submenu = cornersSubmenu
101101
menu.addItem(cornersItem)
102-
102+
103103
// Vertical Split
104104
let verticalSubmenu = NSMenu()
105-
105+
106106
let topHalfItem = NSMenuItem(title: "Top Half", action: #selector(topHalf), keyEquivalent: "")
107107
topHalfItem.target = self
108108
verticalSubmenu.addItem(topHalfItem)
109-
109+
110110
let bottomHalfItem = NSMenuItem(title: "Bottom Half", action: #selector(bottomHalf), keyEquivalent: "")
111111
bottomHalfItem.target = self
112112
verticalSubmenu.addItem(bottomHalfItem)
113-
113+
114114
let verticalItem = NSMenuItem(title: "Vertical Split", action: nil, keyEquivalent: "")
115115
verticalItem.submenu = verticalSubmenu
116116
menu.addItem(verticalItem)
117-
117+
118118
menu.addItem(NSMenuItem.separator())
119-
119+
120120
// Other Controls
121121
let centerItem = NSMenuItem(title: "Center", action: #selector(center), keyEquivalent: "")
122122
centerItem.target = self
123123
menu.addItem(centerItem)
124-
124+
125125
let fullScreenItem = NSMenuItem(title: "Full Screen", action: #selector(fullScreen), keyEquivalent: "")
126126
fullScreenItem.target = self
127127
menu.addItem(fullScreenItem)
128-
128+
129129
menu.addItem(NSMenuItem.separator())
130-
130+
131131
// Launch at Login option
132-
let launchAtLoginItem = NSMenuItem(title: "Launch at Login", action: #selector(toggleLaunchAtLogin), keyEquivalent: "")
132+
let launchAtLoginItem = NSMenuItem(
133+
title: "Launch at Login",
134+
action: #selector(toggleLaunchAtLogin),
135+
keyEquivalent: ""
136+
)
133137
launchAtLoginItem.target = self
134138
launchAtLoginItem.state = isLoginItemEnabled() ? .on : .off
135139
menu.addItem(launchAtLoginItem)
136-
140+
137141
menu.addItem(NSMenuItem.separator())
138-
142+
139143
let quitItem = NSMenuItem(title: "Quit", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "q")
140144
menu.addItem(quitItem)
141-
145+
142146
statusItem?.menu = menu
143147
}
144-
148+
145149
private func isLoginItemEnabled() -> Bool {
146150
if let bundleIdentifier = Bundle.main.bundleIdentifier {
147151
for app in NSWorkspace.shared.runningApplications {
@@ -152,7 +156,7 @@ class StatusBarController: ObservableObject {
152156
}
153157
return false
154158
}
155-
159+
156160
@objc private func toggleLaunchAtLogin() {
157161
if let bundleIdentifier = Bundle.main.bundleIdentifier {
158162
let currentState = isLoginItemEnabled()
@@ -162,97 +166,97 @@ class StatusBarController: ObservableObject {
162166
}
163167
}
164168
}
165-
169+
166170
// 2/3 Split Actions
167171
@objc private func leftTwoThirds() {
168172
DispatchQueue.main.async {
169173
self.windowManager.divideScreenIntoTwoThirds(position: .left)
170174
}
171175
}
172-
176+
173177
@objc private func rightTwoThirds() {
174178
DispatchQueue.main.async {
175179
self.windowManager.divideScreenIntoTwoThirds(position: .right)
176180
}
177181
}
178-
182+
179183
// 1/3 Split Actions
180184
@objc private func leftThird() {
181185
DispatchQueue.main.async {
182186
self.windowManager.resize(.third(.left))
183187
}
184188
}
185-
189+
186190
@objc private func centerThird() {
187191
DispatchQueue.main.async {
188192
self.windowManager.resize(.third(.center))
189193
}
190194
}
191-
195+
192196
@objc private func rightThird() {
193197
DispatchQueue.main.async {
194198
self.windowManager.resize(.third(.right))
195199
}
196200
}
197-
201+
198202
// Half Split Actions
199203
@objc private func leftHalf() {
200204
DispatchQueue.main.async {
201205
self.windowManager.resize(.half(.left))
202206
}
203207
}
204-
208+
205209
@objc private func rightHalf() {
206210
DispatchQueue.main.async {
207211
self.windowManager.resize(.half(.right))
208212
}
209213
}
210-
214+
211215
// Corner Actions
212216
@objc private func topLeft() {
213217
DispatchQueue.main.async {
214218
self.windowManager.resize(.corner(.topLeft))
215219
}
216220
}
217-
221+
218222
@objc private func topRight() {
219223
DispatchQueue.main.async {
220224
self.windowManager.resize(.corner(.topRight))
221225
}
222226
}
223-
227+
224228
@objc private func bottomLeft() {
225229
DispatchQueue.main.async {
226230
self.windowManager.resize(.corner(.bottomLeft))
227231
}
228232
}
229-
233+
230234
@objc private func bottomRight() {
231235
DispatchQueue.main.async {
232236
self.windowManager.resize(.corner(.bottomRight))
233237
}
234238
}
235-
239+
236240
// Vertical Split Actions
237241
@objc private func topHalf() {
238242
DispatchQueue.main.async {
239243
self.windowManager.resize(.vertical(.top))
240244
}
241245
}
242-
246+
243247
@objc private func bottomHalf() {
244248
DispatchQueue.main.async {
245249
self.windowManager.resize(.vertical(.bottom))
246250
}
247251
}
248-
252+
249253
// Other Actions
250254
@objc private func center() {
251255
DispatchQueue.main.async {
252256
self.windowManager.resize(.generic(.center))
253257
}
254258
}
255-
259+
256260
@objc private func fullScreen() {
257261
DispatchQueue.main.async {
258262
self.windowManager.resize(.generic(.fullScreen))

Features/StatusBarView.swift

+12-12
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import SwiftUI
99

1010
struct StatusBarView: View {
1111
let windowManager = WindowManager.shared
12-
12+
1313
var body: some View {
1414
VStack(spacing: 8) {
1515
Group {
@@ -25,9 +25,9 @@ struct StatusBarView: View {
2525
Label("Right 1/3", systemImage: "rectangle.righthalf.filled")
2626
}
2727
}
28-
28+
2929
Divider()
30-
30+
3131
// Options for half split
3232
HStack {
3333
Button(action: { windowManager.resize(.half(.left)) }) {
@@ -37,9 +37,9 @@ struct StatusBarView: View {
3737
Label("Right Half", systemImage: "rectangle.righthalf.filled")
3838
}
3939
}
40-
40+
4141
Divider()
42-
42+
4343
// Corner options
4444
Grid {
4545
GridRow {
@@ -54,14 +54,14 @@ struct StatusBarView: View {
5454
Button(action: { windowManager.resize(.corner(.bottomLeft)) }) {
5555
Label("Bottom Left", systemImage: "arrow.down.left.square")
5656
}
57-
Button(action: {windowManager.resize(.corner(.bottomRight)) }) {
57+
Button(action: { windowManager.resize(.corner(.bottomRight)) }) {
5858
Label("Bottom Right", systemImage: "arrow.down.right.square")
5959
}
6060
}
6161
}
62-
62+
6363
Divider()
64-
64+
6565
// Other options
6666
HStack {
6767
Button(action: { windowManager.resize(.vertical(.top)) }) {
@@ -71,19 +71,19 @@ struct StatusBarView: View {
7171
Label("Bottom Half", systemImage: "rectangle.bottomhalf.filled")
7272
}
7373
}
74-
74+
7575
Button(action: { windowManager.resize(.generic(.fullScreen)) }) {
7676
Label("Full Screen", systemImage: "rectangle.fill")
7777
}
78-
78+
7979
Button(action: { windowManager.resize(.generic(.center)) }) {
8080
Label("Center", systemImage: "rectangle.center.filled")
8181
}
8282
}
8383
.buttonStyle(.bordered)
84-
84+
8585
Divider()
86-
86+
8787
Button("Exit") {
8888
NSApplication.shared.terminate(nil)
8989
}

0 commit comments

Comments
 (0)