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