| 76 | * @since 4.2.0 |
| 77 | */ |
| 78 | export const Stack = <Msg, A, R = never, T = never>( |
| 79 | h: Native.H<Msg>, |
| 80 | options: StackOptions<A, R, T> |
| 81 | ): Native.ViewElement<Msg, R | T, Native.ViewEvents, "view"> => { |
| 82 | const { entries, transition } = options |
| 83 | const screen = options.screen as Draw |
| 84 | if (transition !== undefined) { |
| 85 | return transition.draw(h, entries, screen) as any |
| 86 | } |
| 87 | const top = entries.length - 1 |
| 88 | return h.view.style({ flex: 1 }).children( |
| 89 | entries.map((entry, index) => |
| 90 | Screen(h, { |
| 91 | key: String(entry.id), |
| 92 | props: { |
| 93 | entry, |
| 94 | index, |
| 95 | covered: index < top, |
| 96 | fade: true, |
| 97 | depth: 1, |
| 98 | draw: screen |
| 99 | } |
| 100 | }) |
| 101 | ) |
| 102 | ) as any |
| 103 | } |