2022-11-29 10:46:02 +00:00
|
|
|
import Foundation
|
|
|
|
import SwiftUI
|
2022-12-17 12:37:46 +00:00
|
|
|
import Models
|
2022-11-29 10:46:02 +00:00
|
|
|
|
|
|
|
public enum RouteurDestinations: Hashable {
|
|
|
|
case accountDetail(id: String)
|
2022-12-17 12:37:46 +00:00
|
|
|
case accountDetailWithAccount(account: Account)
|
2022-11-29 10:46:02 +00:00
|
|
|
case statusDetail(id: String)
|
|
|
|
}
|
|
|
|
|
|
|
|
public class RouterPath: ObservableObject {
|
|
|
|
@Published public var path: [RouteurDestinations] = []
|
|
|
|
|
|
|
|
public init() {}
|
|
|
|
|
|
|
|
public func navigate(to: RouteurDestinations) {
|
|
|
|
path.append(to)
|
|
|
|
}
|
2022-12-19 14:51:25 +00:00
|
|
|
|
|
|
|
public func handleStatus(status: AnyStatus, url: URL) -> OpenURLAction.Result {
|
|
|
|
if let mention = status.mentions.first(where: { $0.url == url }) {
|
|
|
|
navigate(to: .accountDetail(id: mention.id))
|
|
|
|
return .handled
|
|
|
|
}
|
|
|
|
return .systemAction
|
|
|
|
}
|
2022-11-29 10:46:02 +00:00
|
|
|
}
|