Skip to content

Commit

Permalink
Fix swiftlint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Nov 4, 2023
1 parent 5d17afa commit 63581c7
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 68 deletions.
6 changes: 3 additions & 3 deletions src/ShowyEdge/swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ public class AppDelegate: NSObject, NSApplicationDelegate {

// ----------------------------------------
let screens = NSScreen.screens
var firstScreenFrame = NSZeroRect
var firstScreenFrame = NSRect.zero
if screens.count > 0 {
firstScreenFrame = screens[0].frame
}

for (i, w) in windows.enumerated() {
var screenFrame = NSZeroRect
var screenFrame = NSRect.zero
if i < screens.count {
screenFrame = screens[i].frame
}

let menuOriginX = screenFrame.origin.x
let menuOriginY = firstScreenFrame.size.height - NSMaxY(screenFrame)
let menuOriginY = firstScreenFrame.size.height - screenFrame.maxY

let isFullScreenSpace = !WorkspaceData.shared.menubarOrigins.contains(
CGPoint(
Expand Down
2 changes: 1 addition & 1 deletion src/ShowyEdge/swift/MenuController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MenuController: NSObject {

let menu = NSMenu(title: "ShowyEdge")

let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as! String
let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") ?? ""
menu.addItem(withTitle: "ShowyEdge \(version)", action: nil, keyEquivalent: "")

menu.addItem(NSMenuItem.separator())
Expand Down
24 changes: 14 additions & 10 deletions src/ShowyEdge/swift/Views/Settings/SettingsActionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@ struct SettingsActionView: View {
GroupBox(label: Text("Action")) {
VStack(alignment: .leading, spacing: 16) {
HStack {
Button(action: {
Relauncher.relaunch()
}) {
Label("Restart ShowyEdge", systemImage: "arrow.clockwise")
}
Button(
action: {
Relauncher.relaunch()
},
label: {
Label("Restart ShowyEdge", systemImage: "arrow.clockwise")
})

Spacer()
}

HStack {
Button(action: {
NSApplication.shared.terminate(self)
}) {
Label("Quit ShowyEdge", systemImage: "xmark.circle.fill")
}
Button(
action: {
NSApplication.shared.terminate(self)
},
label: {
Label("Quit ShowyEdge", systemImage: "xmark.circle.fill")
})

Spacer()
}
Expand Down
30 changes: 18 additions & 12 deletions src/ShowyEdge/swift/Views/Settings/SettingsBasicView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@ struct SettingsBasicView: View {

Spacer()

Button(action: {
userSettings.removeCustomizedLanguageColor(
languageColor.inputSourceID
)
}) {
Label("Delete", systemImage: "xmark")
}
Button(
action: {
userSettings.removeCustomizedLanguageColor(
languageColor.inputSourceID
)
},
label: {
Label("Delete", systemImage: "xmark")
})
}

HStack(spacing: 0) {
Expand Down Expand Up @@ -99,11 +101,15 @@ struct SettingsBasicView: View {
}
}

Button(action: {
userSettings.appendCustomizedLanguageColor(workspaceData.currentInputSourceID)
}) {
Label("Add custom color of \(workspaceData.currentInputSourceID)", systemImage: "plus")
}.disabled(
Button(
action: {
userSettings.appendCustomizedLanguageColor(workspaceData.currentInputSourceID)
},
label: {
Label(
"Add custom color of \(workspaceData.currentInputSourceID)", systemImage: "plus")
}
).disabled(
userSettings.customizedLanguageColor(inputSourceID: workspaceData.currentInputSourceID)
!= nil
)
Expand Down
40 changes: 25 additions & 15 deletions src/ShowyEdge/swift/Views/Settings/SettingsUpdateView.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SwiftUI

struct SettingsUpdateView: View {
let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as! String
let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") ?? ""

var body: some View {
VStack(alignment: .leading, spacing: 25.0) {
Expand All @@ -21,14 +21,18 @@ struct SettingsUpdateView: View {

GroupBox(label: Text("Websites")) {
HStack(spacing: 20.0) {
Button(action: { NSWorkspace.shared.open(URL(string: "https://showyedge.pqrs.org")!) }) {
Label("Open official website", systemImage: "house")
}
Button(action: {
NSWorkspace.shared.open(URL(string: "https://github.com/pqrs-org/ShowyEdge")!)
}) {
Label("Open GitHub (source code)", systemImage: "network")
}
Button(
action: { NSWorkspace.shared.open(URL(string: "https://showyedge.pqrs.org")!) },
label: {
Label("Open official website", systemImage: "house")
})
Button(
action: {
NSWorkspace.shared.open(URL(string: "https://github.com/pqrs-org/ShowyEdge")!)
},
label: {
Label("Open GitHub (source code)", systemImage: "network")
})
Spacer()
}.padding()
}
Expand All @@ -43,9 +47,12 @@ struct SettingsUpdateView: View {
@ObservedObject private var updater = Updater.shared

var body: some View {
Button(action: { updater.checkForUpdatesStableOnly() }) {
Label("Check for updates...", systemImage: "star")
}
Button(
action: { updater.checkForUpdatesStableOnly() },
label: {
Label("Check for updates...", systemImage: "star")
}
)
.disabled(!updater.canCheckForUpdates)
}
}
Expand All @@ -56,9 +63,12 @@ struct SettingsUpdateView: View {
@ObservedObject private var updater = Updater.shared

var body: some View {
Button(action: { updater.checkForUpdatesWithBetaVersion() }) {
Label("Check for beta updates...", systemImage: "star.circle")
}
Button(
action: { updater.checkForUpdatesWithBetaVersion() },
label: {
Label("Check for beta updates...", systemImage: "star.circle")
}
)
.disabled(!updater.canCheckForUpdates)
}
}
Expand Down
67 changes: 40 additions & 27 deletions src/ShowyEdge/swift/Views/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,51 +11,64 @@ enum NavigationTag: String {
struct SettingsView: View {
@State private var selection: NavigationTag = NavigationTag.basic

let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as! String

var body: some View {
VStack {
HStack {
VStack(alignment: .leading, spacing: 0) {
Group {
Button(action: {
selection = .basic
}) {
SidebarLabelView(text: "Basic", systemImage: "gearshape")
}
Button(
action: {
selection = .basic
},
label: {
SidebarLabelView(text: "Basic", systemImage: "gearshape")
}
)
.sidebarButtonStyle(selected: selection == .basic)

Button(action: {
selection = .indicator
}) {
SidebarLabelView(text: "Indicator", systemImage: "wrench")
}
Button(
action: {
selection = .indicator
},
label: {
SidebarLabelView(text: "Indicator", systemImage: "wrench")
}
)
.sidebarButtonStyle(selected: selection == .indicator)

Button(action: {
selection = .customFrame
}) {
SidebarLabelView(text: "Custom Frame", systemImage: "hammer")
}
Button(
action: {
selection = .customFrame
},
label: {
SidebarLabelView(text: "Custom Frame", systemImage: "hammer")
}
)
.sidebarButtonStyle(selected: selection == .customFrame)

Button(action: {
selection = .update
}) {
SidebarLabelView(text: "Update", systemImage: "network")
}
Button(
action: {
selection = .update
},
label: {
SidebarLabelView(text: "Update", systemImage: "network")
}
)
.sidebarButtonStyle(selected: selection == .update)
}

Divider()
.padding(.vertical, 10.0)

Group {
Button(action: {
selection = .action
}) {
SidebarLabelView(text: "Quit, Restart", systemImage: "bolt.circle")
}
Button(
action: {
selection = .action
},
label: {
SidebarLabelView(text: "Quit, Restart", systemImage: "bolt.circle")
}
)
.sidebarButtonStyle(selected: selection == .action)
}

Expand Down

0 comments on commit 63581c7

Please sign in to comment.