CustomActionSheet.swift 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // CustomActionSheet.swift
  3. // SheeeeeeeeetExample
  4. //
  5. // Created by Daniel Saidi on 2018-10-08.
  6. // Copyright © 2018 Daniel Saidi. All rights reserved.
  7. //
  8. import UIKit
  9. import Sheeeeeeeeet
  10. class CustomActionSheet: ActionSheet {
  11. init(options: [FoodOption], buttonTapAction: @escaping (UIButton) -> ()) {
  12. let items = CustomActionSheet.items(for: options, buttonTapAction: buttonTapAction)
  13. super.init(items: items) { _, _ in }
  14. }
  15. required init?(coder aDecoder: NSCoder) {
  16. super.init(coder: aDecoder)
  17. }
  18. }
  19. // MARK: - Private Functions
  20. private extension CustomActionSheet {
  21. static func items(for options: [FoodOption], buttonTapAction: @escaping (UIButton) -> ()) -> [ActionSheetItem] {
  22. let customType = MyCustomViewCell.self
  23. let customItem = ActionSheetCustomItem(cellType: customType) { cell in
  24. cell.buttonTapAction = buttonTapAction
  25. }
  26. return [
  27. ActionSheetTitle(title: "Tap a button"),
  28. customItem,
  29. cancelButton
  30. ]
  31. }
  32. }