MainViewModel.swift 976 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import Combine
  2. import Foundation
  3. @MainActor
  4. final class MainViewModel: ObservableObject {
  5. @Published var selectedDestination: NavigationDestination = .grammarChecker
  6. @Published var isShowingPaywall = false
  7. @Published var isShowingSettings = false
  8. @Published var pendingHistoryEntry: HistoryEntry?
  9. func showPaywall() {
  10. isShowingPaywall = true
  11. }
  12. func hidePaywall() {
  13. isShowingPaywall = false
  14. }
  15. func selectDestination(_ destination: NavigationDestination) {
  16. selectedDestination = destination
  17. hideSettings()
  18. }
  19. func showSettings() {
  20. isShowingSettings = true
  21. }
  22. func hideSettings() {
  23. isShowingSettings = false
  24. }
  25. func openHistoryEntry(_ entry: HistoryEntry) {
  26. pendingHistoryEntry = entry
  27. selectedDestination = entry.tool.navigationDestination
  28. hideSettings()
  29. }
  30. func clearPendingHistoryEntry() {
  31. pendingHistoryEntry = nil
  32. }
  33. }