Skip to content

Commit

Permalink
Merge pull request #31 from Leanplum/fix-iam-handlers
Browse files Browse the repository at this point in the history
Bind display and priority handlers
  • Loading branch information
nzagorchev authored Jul 28, 2022
2 parents 3adfa51 + a3fff9d commit 1f35538
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Rondo/UI/Messages/ActionManagerModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ enum MessageDisplay: String, CaseIterable {
}

enum MessagePrioritization: String, CaseIterable {
case all = "All"
case firstOnly = "First Only"
case allReversed = "All Reversed"
}
Expand Down Expand Up @@ -185,6 +186,10 @@ class ActionManagerModel {

func prioritizationChoiceChanged(_ prioritization: MessagePrioritization?) {
switch prioritization {
case .all:
ActionManager.shared.prioritizeMessages { contexts, trigger in
return contexts
}
case .firstOnly:
ActionManager.shared.prioritizeMessages { contexts, trigger in
guard let first = contexts.first else {
Expand Down
12 changes: 9 additions & 3 deletions Rondo/UI/Messages/MessagesViewController+ActionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ extension MessagesViewController {
listRow.title = option.rawValue
listRow.tag = option.rawValue
listRow.selectableValue = option
listRow.value = nil
listRow.value = model.displayChoice == option ? option : nil
}
}
section.onSelectSelectableRow = { [weak self] (cell, cellRow) in
self?.model.displayChoice = cellRow.value
}

form +++ section

Expand Down Expand Up @@ -114,12 +117,15 @@ extension MessagesViewController {

let prioritizeOptions = MessagePrioritization.allCases
for option in prioritizeOptions {
prioritySection <<< ListCheckRow<MessagePrioritization>(){ listRow in
prioritySection <<< ListCheckRow<MessagePrioritization>() { listRow in
listRow.title = option.rawValue
listRow.selectableValue = option
listRow.value = nil
listRow.value = model.prioritizationChoice == option ? option : nil
}
}
prioritySection.onSelectSelectableRow = { [weak self] (cell, cellRow) in
self?.model.prioritizationChoice = cellRow.value
}

form +++ prioritySection
}
Expand Down

0 comments on commit 1f35538

Please sign in to comment.