-
-
Notifications
You must be signed in to change notification settings - Fork 848
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
103 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import Combine | ||
import Foundation | ||
import SwiftUI | ||
|
||
final class SettingsChecker: ObservableObject { | ||
static let shared = SettingsChecker() | ||
|
||
@ObservedObject private var settings = LibKrbn.Settings.shared | ||
@Published var keyboardTypeEmpty = false | ||
private var subscribers: Set<AnyCancellable> = [] | ||
|
||
public func start() { | ||
settings.$virtualHIDKeyboardKeyboardTypeV2.sink { [weak self] newValue in | ||
self?.checkVirtualHIDKeyboardKeyboardTypeV2(newValue) | ||
}.store(in: &subscribers) | ||
} | ||
|
||
private func checkVirtualHIDKeyboardKeyboardTypeV2(_ virtualHIDKeyboardKeyboardTypeV2: String) { | ||
keyboardTypeEmpty = (virtualHIDKeyboardKeyboardTypeV2 == "") | ||
updateShowSettingsAlert() | ||
} | ||
|
||
private func updateShowSettingsAlert() { | ||
if keyboardTypeEmpty { | ||
ContentViewStates.shared.showSettingsAlert = true | ||
} else { | ||
ContentViewStates.shared.showSettingsAlert = false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/apps/SettingsWindow/src/View/KeyboardTypeSelector.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import SwiftUI | ||
|
||
struct KeyboardTypeSelectorView: View { | ||
@ObservedObject private var settings = LibKrbn.Settings.shared | ||
@ObservedObject private var grabberClient = LibKrbn.GrabberClient.shared | ||
|
||
var body: some View { | ||
Picker( | ||
selection: $settings.virtualHIDKeyboardKeyboardTypeV2, label: Text("Keyboard type:") | ||
) { | ||
Text("ANSI (North America, most of Asia and others)").tag("ansi") | ||
Text("ISO (Europe, Latin America, Middle-East and others)").tag("iso") | ||
Text("JIS (Japanese)").tag("jis") | ||
} | ||
.pickerStyle(RadioGroupPickerStyle()) | ||
.disabled(!grabberClient.connected) | ||
} | ||
} | ||
|
||
struct KeyboardTypeSelectorView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
KeyboardTypeSelectorView() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import SwiftUI | ||
|
||
struct SettingsAlertView: View { | ||
@ObservedObject private var settingsChecker = SettingsChecker.shared | ||
@FocusState var focus: Bool | ||
|
||
var body: some View { | ||
ZStack(alignment: .topLeading) { | ||
VStack(alignment: .leading, spacing: 6.0) { | ||
if settingsChecker.keyboardTypeEmpty { | ||
VStack(alignment: .leading, spacing: 20.0) { | ||
Label( | ||
"Please select the keyboard type", | ||
systemImage: "gearshape" | ||
) | ||
.font(.system(size: 24)) | ||
|
||
KeyboardTypeSelectorView() | ||
} | ||
} | ||
} | ||
.padding() | ||
.frame(width: 850) | ||
|
||
SheetCloseButton { | ||
ContentViewStates.shared.showSettingsAlert = false | ||
} | ||
} | ||
.onAppear { | ||
focus = true | ||
} | ||
} | ||
} | ||
|
||
struct SettingsAlertView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
Group { | ||
SettingsAlertView() | ||
.previewLayout(.sizeThatFits) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters