mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-27 01:57:41 +00:00
feat(mac): Fixed minor issues with installation flow
This commit is contained in:
parent
7b531fd4c2
commit
cfea0a4efd
7 changed files with 46 additions and 52 deletions
|
|
@ -21,7 +21,6 @@ struct CompletedInstallView: View {
|
|||
}
|
||||
|
||||
var body: some View {
|
||||
|
||||
VStack {
|
||||
|
||||
Spacer()
|
||||
|
|
@ -43,4 +42,3 @@ struct CompletedInstallView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ struct GrantAccessibiltyPermissionView: View {
|
|||
.padding(7)
|
||||
.background {
|
||||
Capsule()
|
||||
.fill(.quaternary.opacity(0.6))
|
||||
.fill(.quaternary.opacity(0.5))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -68,16 +68,16 @@ struct GrantAccessibiltyPermissionView: View {
|
|||
Spacer()
|
||||
|
||||
HStack {
|
||||
|
||||
Text("Grant accessibility control")
|
||||
.font(.title2)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
Button {
|
||||
if installation.currentTask()?.taskType == .requestAccess {
|
||||
openSettingsButtonPressed = true
|
||||
installation.executeNextInstallationTask()
|
||||
openSettingsButtonPressed = true
|
||||
} else {
|
||||
openAccessibilitySettings()
|
||||
openSettingsButtonPressed = true
|
||||
}
|
||||
} label: {
|
||||
Text("Open Settings")
|
||||
|
|
@ -91,7 +91,6 @@ struct GrantAccessibiltyPermissionView: View {
|
|||
Button {
|
||||
checkingPermission = true
|
||||
installation.executeNextInstallationTask()
|
||||
|
||||
} label: {
|
||||
Text("Continue")
|
||||
.padding(.horizontal, 16)
|
||||
|
|
@ -115,19 +114,3 @@ struct GrantAccessibiltyPermissionView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct GrantAccessibiltyPermissionView_Previews: PreviewProvider {
|
||||
struct PreviewHost: View {
|
||||
@Namespace private var namespace
|
||||
private let installation = InstallationContainer()
|
||||
|
||||
var body: some View {
|
||||
GrantAccessibiltyPermissionView(namespace: namespace, onContinue: {})
|
||||
.environmentObject(installation)
|
||||
}
|
||||
}
|
||||
|
||||
static var previews: some View {
|
||||
PreviewHost()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@
|
|||
|
||||
enum InstallPage: String, CaseIterable {
|
||||
case loading
|
||||
case initial
|
||||
case initialInstall
|
||||
case initialRepair
|
||||
case completed
|
||||
case enableInputMethod
|
||||
case allowSecurityPermission
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ import Foundation
|
|||
|
||||
|
||||
struct NewInstallView: View {
|
||||
|
||||
@EnvironmentObject var installation: InstallationContainer
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
let namespace: Namespace.ID
|
||||
let onContinue: () -> Void
|
||||
|
||||
var versionText: String {
|
||||
if let version = installation.installationState?.keymanVersion {
|
||||
return "Version: \(version) "
|
||||
|
|
|
|||
|
|
@ -12,9 +12,12 @@ import SwiftUI
|
|||
import AppKit
|
||||
internal import UniformTypeIdentifiers
|
||||
|
||||
struct InitialRepairView: View {
|
||||
struct NewRepairView: View {
|
||||
|
||||
@EnvironmentObject var installation: InstallationContainer
|
||||
|
||||
let namespace: Namespace.ID
|
||||
let onContinue: () -> Void
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
|
|
@ -42,22 +45,8 @@ struct InitialRepairView: View {
|
|||
.buttonStyle(.borderedProminent)
|
||||
.tint(.blue)
|
||||
.clipShape(Capsule())
|
||||
NavigationButton(action: .advance)
|
||||
NavigationButton(action: .advance, onContinue: onContinue)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct InitialRepairViewPreview: View {
|
||||
@Namespace private var namespace
|
||||
private let installation = InstallationContainer()
|
||||
|
||||
var body: some View {
|
||||
InitialRepairView(namespace: namespace)
|
||||
.environmentObject(installation)
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
InitialRepairViewPreview()
|
||||
}
|
||||
|
|
@ -16,10 +16,12 @@ struct ParentInstallView: View {
|
|||
func chooseCurrentPage() {
|
||||
if installation.installationPhase.hasTasks {
|
||||
switch installation.currentTask()?.taskType {
|
||||
case .prepareNewInstall: currentPage = .initial
|
||||
case .prepareNewInstall: currentPage = .initialInstall
|
||||
case .prepareNewRepair: currentPage = .initialRepair
|
||||
case .enableInputMethod: currentPage = .enableInputMethod
|
||||
case .requestAccess: currentPage = .allowSecurityPermission
|
||||
case .confirmAccess: print("Access granted")
|
||||
case .confirmAccess: currentPage = .allowSecurityPermission
|
||||
case .confirmRestart: currentPage = .restartComputer
|
||||
case .requestRestart: currentPage = .restartComputer
|
||||
default: currentPage = .completed
|
||||
}
|
||||
|
|
@ -28,21 +30,26 @@ struct ParentInstallView: View {
|
|||
case .evaluatingInstallation: currentPage = .loading
|
||||
case .inputMethodMissing, .inputMethodOutdated: currentPage = .rerunInstaller
|
||||
case .installationComplete:
|
||||
if installation.getHasDisplayedInstallationComplete() {
|
||||
currentPage = .completed
|
||||
currentPage = .completed
|
||||
if !installation.getHasDisplayedInstallationComplete() {
|
||||
installation.setHasDisplayedInstallationComplete()
|
||||
}
|
||||
default: currentPage = .completed
|
||||
default:
|
||||
currentPage = .completed
|
||||
}
|
||||
}
|
||||
print("currentPage is now \(currentPage)")
|
||||
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
switch currentPage {
|
||||
case .loading: ProgressView()
|
||||
case .initial: NewInstallView(namespace: animation,onContinue: {
|
||||
case .initialInstall: NewInstallView(namespace: animation,onContinue: {
|
||||
installation.executeNextInstallationTask()
|
||||
chooseCurrentPage()
|
||||
})
|
||||
case .initialRepair: NewRepairView(namespace: animation,onContinue: {
|
||||
installation.executeNextInstallationTask()
|
||||
chooseCurrentPage()
|
||||
})
|
||||
|
|
@ -54,15 +61,19 @@ struct ParentInstallView: View {
|
|||
}
|
||||
}
|
||||
.onAppear {
|
||||
print("LOL ", installation.installationPhase)
|
||||
print("LOL ", installation.currentTask()?.taskType ?? "no task available")
|
||||
if installation.installationPhase == .evaluatingInstallation {
|
||||
currentPage = .loading
|
||||
Task {
|
||||
while installation.installationPhase == .evaluatingInstallation {
|
||||
try? await Task.sleep(for: .milliseconds(100))
|
||||
try? await Task.sleep(for: .milliseconds(200))
|
||||
}
|
||||
await MainActor.run {
|
||||
withAnimation(.smooth) {
|
||||
chooseCurrentPage()
|
||||
print("LOOL ", installation.installationPhase)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -70,8 +81,6 @@ struct ParentInstallView: View {
|
|||
chooseCurrentPage()
|
||||
}
|
||||
}
|
||||
.onReceive( NotificationCenter.default.publisher(for: .installationRepairStarted)) { notification in
|
||||
}
|
||||
.padding()
|
||||
.frame(minWidth: 600)
|
||||
.frame(minHeight: 400)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,20 @@ import SwiftUI
|
|||
import AppKit
|
||||
internal import UniformTypeIdentifiers
|
||||
|
||||
private func chooseAndOpenKeymanInstaller() {
|
||||
let panel = NSOpenPanel()
|
||||
panel.message = "Open the Keyman .pkg file."
|
||||
panel.allowedContentTypes = [UTType(filenameExtension: "pkg")!]
|
||||
panel.directoryURL = FileManager.default.urls(
|
||||
for: .downloadsDirectory,
|
||||
in: .userDomainMask
|
||||
).first
|
||||
|
||||
if panel.runModal() == .OK, let url = panel.url {
|
||||
NSWorkspace.shared.open(url)
|
||||
}
|
||||
}
|
||||
|
||||
struct RerunInstallerView: View {
|
||||
@EnvironmentObject var installation: InstallationContainer
|
||||
let namespace: Namespace.ID
|
||||
|
|
@ -42,7 +56,7 @@ struct RerunInstallerView: View {
|
|||
.font(.title2)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
Button {
|
||||
installation.executeNextInstallationTask()
|
||||
chooseAndOpenKeymanInstaller()
|
||||
} label: {
|
||||
Text("Open Installer")
|
||||
.padding(.horizontal, 16)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue