Provide a mechanism to pop the current card or dismiss the manager
I have a couple of Bulletin Board pages that can be used either standalone, or be pushed from another page. When they are used as standalone pages, the action buttons must trigger dismissBulletin() and when they are pushed from another page, the action buttons may trigger either popItem() or dismissBulletin()
Unfortunately, BLTNItemManager declares many of its internal variables as fileprivate so I can't access itemStack, currentItem, or rootItem (and can't get at them via extension).
I can think of a couple of ways to skin this beast:
- remove fileprivate from rootItem or itemsStack
- add
manager?.isRootItem()which returns (currentItem == rootItem) - add
manager?.positionInStack()which returns itemsStack.index(of: currentItem), requires implementing Equatable for BLTNItem - add
manager?.popOrDismissBulletin(animated:)
I'd be happy to submit a PR if you have a preferred mechanism.
#165 resolves this issue with a particular design pattern. When a page pushes another page, it can optionally pass a reference to itself, indicating that it is the "root" (though it may not actually be the actual root Page of the Page stack).
When pushing a single page, a simple boolean variable could be used to accomplish the same task (if shouldPop, pop, else dismissBulletin). But, such a solution does not suffice if multiple pages are pushed (1 -> 2 -> 3 -> 4) and the flow should return from page 4 to page 2.