mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
reimplemented onboarding via hostsManager.shownOnboarding
This commit is contained in:
@@ -26,6 +26,7 @@ class HostsManager: ObservableObject, @unchecked Sendable {
|
||||
|
||||
@Published var history: [History] = []
|
||||
@Published var settings: AppSettings = AppSettings()
|
||||
@Published var shownOnboarding: Bool = false
|
||||
|
||||
var tint: SwiftUI.Color {
|
||||
selectedTheme.ansi[selectedAnsi].suiColor
|
||||
@@ -46,6 +47,12 @@ class HostsManager: ObservableObject, @unchecked Sendable {
|
||||
loadFonts()
|
||||
loadSnippets()
|
||||
loadHistory()
|
||||
// self.shownOnboarding = UserDefaults.standard.bool(forKey: "shownOnboarding")
|
||||
}
|
||||
|
||||
func setOnboarding(to newValue: Bool) {
|
||||
self.shownOnboarding = newValue
|
||||
UserDefaults.standard.set(newValue, forKey: "shownOnboarding")
|
||||
}
|
||||
|
||||
func setAppIcon() {
|
||||
|
||||
@@ -22,18 +22,22 @@ struct ShhShellApp: App {
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
if !NSUbiquitousKeyValueStore.default.bool(forKey: "shownOnboarding") {
|
||||
WelcomeView()
|
||||
} else {
|
||||
ContentView(
|
||||
handler: sshHandler,
|
||||
hostsManager: hostsManager,
|
||||
keyManager: keyManager
|
||||
)
|
||||
.transition(.opacity)
|
||||
.colorScheme(hostsManager.selectedTheme.background.luminance > 0.5 ? .light : .dark)
|
||||
.tint(hostsManager.tint)
|
||||
Group {
|
||||
if !hostsManager.shownOnboarding {
|
||||
WelcomeView(hostsManager: hostsManager)
|
||||
|
||||
} else {
|
||||
ContentView(
|
||||
handler: sshHandler,
|
||||
hostsManager: hostsManager,
|
||||
keyManager: keyManager
|
||||
)
|
||||
.colorScheme(hostsManager.selectedTheme.background.luminance > 0.5 ? .light : .dark)
|
||||
.tint(hostsManager.tint)
|
||||
}
|
||||
}
|
||||
.transition(.opacity)
|
||||
.animation(.default, value: hostsManager.shownOnboarding)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
import SwiftUI
|
||||
|
||||
struct WelcomeView: View {
|
||||
@ObservedObject var hostsManager: HostsManager
|
||||
@State private var spawnDate: Date = .now
|
||||
@Environment(\.dismiss) var dismiss
|
||||
|
||||
var body: some View {
|
||||
TimelineView(.animation) { tl in
|
||||
@@ -74,11 +74,13 @@ struct WelcomeView: View {
|
||||
}
|
||||
if time > 9 {
|
||||
#if swift(>=6.2)
|
||||
Button("Continue") { dismiss() }
|
||||
Button("Continue") {
|
||||
hostsManager.setOnboarding(to: true)
|
||||
}
|
||||
.buttonStyle(.glassProminent)
|
||||
#else
|
||||
Button {
|
||||
dismiss()
|
||||
hostsManager.setOnboarding(to: true)
|
||||
} label: {
|
||||
ZStack {
|
||||
Color.terminalGreen
|
||||
@@ -95,9 +97,6 @@ struct WelcomeView: View {
|
||||
#endif
|
||||
}
|
||||
}
|
||||
.onDisappear {
|
||||
NSUbiquitousKeyValueStore.default.set(true, forKey: "shownOnboarding")
|
||||
}
|
||||
.animation(.spring, value: time)
|
||||
.preferredColorScheme(.dark)
|
||||
}
|
||||
@@ -105,5 +104,5 @@ struct WelcomeView: View {
|
||||
}
|
||||
|
||||
#Preview {
|
||||
WelcomeView()
|
||||
WelcomeView(hostsManager: HostsManager(previews: true))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user