Ferrite-backup/Ferrite/ViewModels/ToastViewModel.swift
kingbri 0c0b0a252a Sources: Add source updating and source list edits
Sources can now be updated based on the repo ID. To preserve repo IDs
across single URL links, the source lists can be edited and the ID
is transferred over.

Signed-off-by: kingbri <bdashore3@gmail.com>
2022-08-05 22:31:15 -04:00

40 lines
812 B
Swift

//
// ToastViewModel.swift
// Ferrite
//
// Created by Brian Dashore on 7/19/22.
//
import SwiftUI
@MainActor
class ToastViewModel: ObservableObject {
enum ToastType: Identifiable {
var id: Int {
hashValue
}
case info
case error
}
// Toast variables
@Published var toastDescription: String? = nil {
didSet {
Task {
try? await Task.sleep(seconds: 0.1)
showToast = true
try await Task.sleep(seconds: 5)
showToast = false
toastType = .error
}
}
}
@Published var showToast: Bool = false
// Default the toast type to error since the majority of toasts are errors
@Published var toastType: ToastType = .error
}