Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InfoBarCoordinator as ResponseRouterCoordinator #1

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 3 additions & 21 deletions Sources/FlowPilotInfoBar/InfoBarCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
//

import Foundation
import CleevioRouters
import FlowPilot
import SwiftUI
import CleevioCore

#if canImport(UIKit)
open class InfoBarCoordinator<InfoBarView: View, InfoBarContent>: ResponseRouterCoordinator {
open class InfoBarCoordinator<InfoBarView: View, InfoBarContent>: ResponseRouterCoordinator<Void> {
let frame: CGRect
let content: InfoBarContent
let viewModel: InfoBarViewModel<InfoBarContent>
Expand Down Expand Up @@ -48,30 +48,12 @@ open class InfoBarCoordinator<InfoBarView: View, InfoBarContent>: ResponseRouter
.filter { !$0 }
.delay(for: 0.1, scheduler: DispatchQueue.main)
.sink(receiveValue: { [weak self] _ in
self?.response(with: ())
self?.dismiss()
})
.store(in: cancelBag)

present(viewController, animated: animated)
}

open func startAndWaitForDismiss() async {
start()
var shouldCallContinuation = true

await withCheckedContinuation { continuation in
viewModel.$isMessageShown
.dropFirst()
.filter { !$0 }
.delay(for: 0.1, scheduler: DispatchQueue.main)
.sink(receiveValue: { _ in
if shouldCallContinuation {
shouldCallContinuation = false
continuation.resume()
}
})
.store(in: cancelBag)
}
}
}
#endif
2 changes: 1 addition & 1 deletion Sources/FlowPilotInfoBar/InfoBarWindowRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

import Foundation
import CleevioRouters
import FlowPilot
import CleevioUI

#if canImport(UIKit)
Expand Down