mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
create helper function on Snackbar to show it
This commit is contained in:
parent
629c378244
commit
ce5123e2d7
4 changed files with 18 additions and 9 deletions
9
apple/OmnivoreKit/Sources/App/SnackbarExtension.swift
Normal file
9
apple/OmnivoreKit/Sources/App/SnackbarExtension.swift
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import Foundation
|
||||
import Services
|
||||
import Views
|
||||
|
||||
extension Snackbar {
|
||||
static func show(message: String) {
|
||||
NSNotification.operationSuccess(message: message)
|
||||
}
|
||||
}
|
||||
|
|
@ -113,7 +113,7 @@ final class HomeFeedViewModel: ObservableObject {
|
|||
receiveValue: { [weak self] _ in
|
||||
self?.isLoading = false
|
||||
stopNetworkActivityIndicator()
|
||||
NSNotification.operationSuccess(message: archived ? "Link archived" : "Link moved to Inbox")
|
||||
Snackbar.show(message: archived ? "Link archived" : "Link moved to Inbox")
|
||||
}
|
||||
)
|
||||
.store(in: &subscriptions)
|
||||
|
|
@ -130,16 +130,15 @@ final class HomeFeedViewModel: ObservableObject {
|
|||
dataService.removeLinkPublisher(itemID: linkId)
|
||||
.sink(
|
||||
receiveCompletion: { [weak self] completion in
|
||||
guard case let .failure(error) = completion else { return }
|
||||
guard case .failure = completion else { return }
|
||||
self?.isLoading = false
|
||||
stopNetworkActivityIndicator()
|
||||
print(error)
|
||||
NSNotification.operationFailed(message: "Failed to remove link")
|
||||
Snackbar.show(message: "Failed to remove link")
|
||||
},
|
||||
receiveValue: { [weak self] _ in
|
||||
self?.isLoading = false
|
||||
stopNetworkActivityIndicator()
|
||||
NSNotification.operationSuccess(message: "Link removed")
|
||||
Snackbar.show(message: "Link removed")
|
||||
}
|
||||
)
|
||||
.store(in: &subscriptions)
|
||||
|
|
@ -169,7 +168,7 @@ final class HomeFeedViewModel: ObservableObject {
|
|||
self?.isLoading = false
|
||||
stopNetworkActivityIndicator()
|
||||
if let message = successMessage {
|
||||
NSNotification.operationSuccess(message: message)
|
||||
Snackbar.show(message: message)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import Combine
|
|||
import Models
|
||||
import Services
|
||||
import SwiftUI
|
||||
import Views
|
||||
|
||||
final class NewsletterEmailsViewModel: ObservableObject {
|
||||
private var hasLoadedInitialEmails = false
|
||||
|
|
@ -94,7 +95,7 @@ struct NewsletterEmailsView: View {
|
|||
pasteBoard.writeObjects([newsletterEmail.email as NSString])
|
||||
#endif
|
||||
|
||||
NSNotification.operationSuccess(message: "Email copied")
|
||||
Snackbar.show(message: "Email copied")
|
||||
},
|
||||
label: { Text(newsletterEmail.email) }
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import SwiftUI
|
||||
|
||||
struct Snackbar: View {
|
||||
public struct Snackbar: View {
|
||||
@Binding var isShowing: Bool
|
||||
private let presenting: AnyView
|
||||
private let text: Text
|
||||
|
|
@ -27,7 +27,7 @@ struct Snackbar: View {
|
|||
self.action = action
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
public var body: some View {
|
||||
GeometryReader { geometry in
|
||||
ZStack(alignment: .center) {
|
||||
self.presenting
|
||||
|
|
|
|||
Loading…
Reference in a new issue