Skip to content

Commit

Permalink
InfoBarCoordinator as ResponseRouterCoordinator
Browse files Browse the repository at this point in the history
  • Loading branch information
lvalenta committed Sep 16, 2024
1 parent 579d154 commit 4e6798e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
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

0 comments on commit 4e6798e

Please sign in to comment.