BulletinBoard icon indicating copy to clipboard operation
BulletinBoard copied to clipboard

Dynamic Page Item

Open timroesner opened this issue 6 years ago • 2 comments

I have the issue that I would like to present a dynamic Page Item, meaning title and description will be supplied at runtime. If I understand correctly from the other issues, the manager has to be created as an instance variable. This limits my abilities as I cannot reassign the rootItem or the title of the Page Item once they have been created.

So I'm not sure if this is a feature request or maybe there is a way to supply those things later. Would appreciate some guidance.

timroesner avatar Oct 05 '18 07:10 timroesner

I'm interested also in such a functionality. @timroesner did you find some workaround?

azlekov avatar Nov 01 '18 12:11 azlekov

Firstly add this into your class somewhere

lazy var bulletinManager: BLTNItemManager = {
    let rootItem: BLTNPageItem = BLTNPageItem(title: "")
    return BLTNItemManager(rootItem: rootItem)
}()

Create your func where you redefine the root item

func showDynamicBulletin(dynamicTitle: String, dynamicDescription: String) {

      let page = BLTNPageItem(title: dynamicTitle)
      page.description = dynamicDescription

      page.actionButtonTitle = "Done"
      page.actionHandler = { (item: BLTNActionItem) in
        
      }
      page.alternativeButtonTitle = "Skip"
      page.alternativeHandler = { (item: BLTNActionItem) in
        
      }

      self.bulletinManager = BLTNItemManager(rootItem: page)
      self.bulletinManager.backgroundViewStyle = .dimmed
      self.bulletinManager.showBulletin(above: self)
}

After this, if you need to push a board you use the normal function with a new BLTNPageItem:

self.bulletinManager.push(item: bltnPushPage)

Usage

let runtimeTitle = "I'm dynamic"
let runtimeDesc = "This is a description"

showDynamicBulletin(dynamicTitle: runtimeTitle, dynamicDescription: runtimeDesc)

adougies avatar Apr 14 '19 14:04 adougies