Skip to content

Commit

Permalink
Add Toast controller option to higher level slot controller as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carifio24 committed Nov 2, 2023
1 parent ee00042 commit b5c6a42
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Spellbook/HigherLevelSlotController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ class HigherLevelSlotController: UIViewController {

var spell: Spell?
var textDelegate: TextFieldChooserDelegate<GenericSpellbookAction, Int>?

// TODO: What's a better way to do this?
var toastController: UIViewController? = nil

override func viewDidLoad() {
super.viewDidLoad()

cancelButton.addTarget(self, action: #selector(cancelButtonPressed), for: UIControl.Event.touchUpInside)
//castButton.addTarget(self, action: #selector(castButtonPressed), for: UIControl.Event.touchUpInside)
castButton.addTarget(self, action: #selector(castButtonPressed), for: UIControl.Event.touchUpInside)

guard let spell = self.spell else { return }
guard let profile = store.state.profile else { return }
Expand Down Expand Up @@ -61,7 +64,8 @@ class HigherLevelSlotController: UIViewController {
if let level = valueFrom(ordinal: text) {
store.dispatch(CastSpellAction(level: level))
let message = "\(spell.name) was cast at level \(level)"
Toast.makeToast(message, controller: self.parent ?? self)
let controller = self.toastController ?? (self.parent ?? self)
Toast.makeToast(message, controller: controller)
}
}

Expand Down
1 change: 1 addition & 0 deletions Spellbook/SpellWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ class SpellWindowController: UIViewController {
} else if !spell.higherLevel.isEmpty {
let controller = storyboard.instantiateViewController(withIdentifier: "higherLevelSlotDialog") as! HigherLevelSlotController
controller.spell = spell
controller.toastController = self
let popupHeight = 0.33 * SizeUtils.screenHeight
let popupWidth = 0.75 * SizeUtils.screenWidth
let height = min(popupHeight, CGFloat(135))
Expand Down

0 comments on commit b5c6a42

Please sign in to comment.