Skip to content

Commit

Permalink
Merge UI1 and UI2
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Jul 21, 2024
1 parent 8225f9a commit 64c737e
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 190 deletions.
26 changes: 6 additions & 20 deletions src/apps/SettingsWindow/src/View/ContentMainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ enum NavigationTag: String {
case devices
case virtualKeyboard
case profiles
case ui1
case ui2
case ui
case update
case misc
case uninstall
Expand Down Expand Up @@ -142,25 +141,14 @@ struct ContentMainView: View {

Button(
action: {
contentViewStates.navigationSelection = .ui1
contentViewStates.navigationSelection = .ui
},
label: {
SidebarLabelView(text: "UI #1", systemImage: "switch.2", padding: 2.0)
SidebarLabelView(text: "UI", systemImage: "switch.2", padding: 2.0)
}
)
.sidebarButtonStyle(
selected: contentViewStates.navigationSelection == .ui1)

Button(
action: {
contentViewStates.navigationSelection = .ui2
},
label: {
SidebarLabelView(text: "UI #2", systemImage: "switch.2", padding: 2.0)
}
)
.sidebarButtonStyle(
selected: contentViewStates.navigationSelection == .ui2)
selected: contentViewStates.navigationSelection == .ui)
}

Divider()
Expand Down Expand Up @@ -273,10 +261,8 @@ struct ContentMainView: View {
VirtualKeyboardView()
case .profiles:
ProfilesView()
case .ui1:
UI1View()
case .ui2:
UI2View()
case .ui:
UIView()
case .update:
UpdateView()
case .misc:
Expand Down
98 changes: 0 additions & 98 deletions src/apps/SettingsWindow/src/View/UI1View.swift

This file was deleted.

72 changes: 0 additions & 72 deletions src/apps/SettingsWindow/src/View/UI2View.swift

This file was deleted.

153 changes: 153 additions & 0 deletions src/apps/SettingsWindow/src/View/UIView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
import SwiftUI

struct UIView: View {
@ObservedObject private var settings = LibKrbn.Settings.shared
@ObservedObject private var appIcons = AppIcons.shared

var body: some View {
ScrollView {
VStack(alignment: .leading, spacing: 24.0) {
GroupBox(label: Text("Menu bar")) {
VStack(alignment: .leading, spacing: 12.0) {
HStack {
Toggle(isOn: $settings.showIconInMenuBar) {
Text("Show icon in menu bar (Default: on)")
}
.switchToggleStyle()

Spacer()
}

HStack {
Toggle(isOn: $settings.showProfileNameInMenuBar) {
Text("Show profile name in menu bar (Default: off)")
}
.switchToggleStyle()

Spacer()
}

HStack {
Toggle(isOn: $settings.askForConfirmationBeforeQuitting) {
Text("Ask for confirmation when quitting (Default: on)")
}
.switchToggleStyle()

Spacer()
}

}
.padding(6.0)
}

GroupBox(label: Text("Karabiner Notification Window")) {
VStack(alignment: .leading, spacing: 12.0) {
HStack {
Toggle(isOn: $settings.enableNotificationWindow) {
Text("Enable Karabiner Notification Window (Default: on)")
}
.switchToggleStyle()

Spacer()
}

HStack {
Toggle(isOn: $settings.virtualHIDKeyboardIndicateStickyModifierKeysState) {
Text("Indicate sticky modifier keys state (Default: on)")
}
.switchToggleStyle()

Spacer()
}

VStack(alignment: .leading, spacing: 12.0) {
Label(
"What is the Karabiner Notification Window?",
systemImage: "lightbulb"
)
VStack(alignment: .leading, spacing: 0.0) {
Text(
"Karabiner Notification Window is a window that displays messages, located at the bottom right of the screen. "
)
Text(
"It is used for temporary alerts, displaying the status of sticky modifiers, and showing messages for some complex modifications."
)
}

Image(decorative: "notification-window")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(height: 150)

}
.padding()
.foregroundColor(Color.warningForeground)
.background(Color.warningBackground)
}
.padding(6.0)
}

GroupBox(label: Text("App icon")) {
VStack(alignment: .leading, spacing: 12.0) {
VStack {
Label(
"It takes a few seconds for changes to the application icon to take effect.\nAnd to update the Dock icon, you need to close and reopen the application.",
systemImage: "lightbulb"
)
.padding()
.foregroundColor(Color.warningForeground)
.background(Color.warningBackground)
}

Picker(selection: $appIcons.selectedAppIconNumber, label: Text("")) {
ForEach($appIcons.icons) { $appIcon in
HStack {
if let image = appIcon.karabinerElementsThumbnailImage {
Image(nsImage: image)
.resizable()
.frame(width: 64.0, height: 64.0)
}

if let image = appIcon.eventViewerThumbnailImage {
Image(nsImage: image)
.resizable()
.frame(width: 64.0, height: 64.0)
}

if let image = appIcon.multitouchExtensionThumbnailImage {
Image(nsImage: image)
.resizable()
.frame(width: 64.0, height: 64.0)
}

Spacer()
}
.padding(.vertical, 5.0)
.overlay(
RoundedRectangle(cornerRadius: 8)
.stroke(
Color(NSColor.selectedControlColor),
lineWidth: appIcons.selectedAppIconNumber == appIcon.id ? 3 : 0
)
)

.tag(appIcon.id)
}
}.pickerStyle(RadioGroupPickerStyle())

Divider()
}
.padding(6.0)
.background(Color(NSColor.textBackgroundColor))
}
}
}
.padding()
}
}

struct UIView_Previews: PreviewProvider {
static var previews: some View {
UIView()
}
}

0 comments on commit 64c737e

Please sign in to comment.