Skip to content

Commit

Permalink
Merge pull request #80 from mo5tone/nested_anyhashable_screen
Browse files Browse the repository at this point in the history
fix: handle nested AnyHashable screen
  • Loading branch information
johnpatrickmorgan authored Aug 30, 2024
2 parents 208bb6b + fe76726 commit bdf4148
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Sources/FlowStacks/DestinationBuilderHolder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ class DestinationBuilderHolder: ObservableObject {
}

func build(_ binding: Binding<AnyHashable>) -> AnyView {
let base = binding.wrappedValue.base
var base = binding.wrappedValue.base
var key = Self.identifier(for: type(of: base))
// NOTE: - `wrappedValue` might be nested `AnyHashable` e.g. `AnyHashable<AnyHashable<AnyHashable<MyScreen>>>`.
// And `base as? AnyHashable` will always produce a `AnyHashable` so we need check if key contains 'AnyHashable' to break the looping.
while key == "Swift.AnyHashable", let anyHashable = base as? AnyHashable {
base = anyHashable.base
key = Self.identifier(for: type(of: base))
}
if let identifier = base as? LocalDestinationID {
let key = identifier.rawValue.uuidString
if let builder = builders[key], let output = builder(binding) {
Expand Down

0 comments on commit bdf4148

Please sign in to comment.