Browse Source

update library

Marino Faggiana 6 years ago
parent
commit
346be4f7e3

+ 0 - 35
Carthage/Checkouts/Sheeeeeeeeet/SheeeeeeeeetExample/ActionSheets/ActionSheet+Items.swift

@@ -1,35 +0,0 @@
-//
-//  ActionSheet+Items.swift
-//  SheeeeeeeeetExample
-//
-//  Created by Jonas Ullström on 2018-03-16.
-//  Copyright © 2018 Jonas Ullström. All rights reserved.
-//
-
-/*
- 
- These extensions provides action sheets with functions that
- are shared by all example action sheets.
- 
- */
-
-import Sheeeeeeeeet
-
-extension ActionSheet {
-    
-    static var cancelButton: ActionSheetCancelButton {
-        return ActionSheetCancelButton(title: "Cancel")
-    }
-    
-    static var okButton: ActionSheetOkButton {
-        return ActionSheetOkButton(title: "OK")
-    }
-    
-    static var standardTitle: String {
-        return "What do you want to eat?"
-    }
-    
-    static func titleItem(title: String) -> ActionSheetTitle {
-        return ActionSheetTitle(title: title)
-    }
-}

+ 0 - 81
Carthage/Checkouts/Sheeeeeeeeet/SheeeeeeeeetExample/ActionSheets/CollectionActionSheet.swift

@@ -1,81 +0,0 @@
-//
-//  CollectionActionSheet.swift
-//  SheeeeeeeeetExample
-//
-//  Created by Jonas Ullström on 2018-03-16.
-//  Copyright © 2018 Jonas Ullström. All rights reserved.
-//
-
-/*
- 
- This action sheet calls `setupItemsAndButtons` after it has
- been initialized, since taps in the collection view have to
- reload the action sheet to update selection display.
- 
- */
-
-import Sheeeeeeeeet
-
-class CollectionActionSheet: ActionSheet {
-    
-    init(options: [FoodOption], action: @escaping ([MyCollectionViewCell.Item]) -> ()) {
-        let collectionItems = CollectionActionSheet.collectionItems
-        super.init(items: []) { _, item in
-            guard item.isOkButton else { return }
-            action(collectionItems.filter { $0.isSelected })
-        }
-        let items = self.items(for: options, collectionItems: collectionItems)
-        setup(items: items)
-    }
-    
-    required init?(coder aDecoder: NSCoder) {
-        super.init(coder: aDecoder)
-    }
-}
-
-private extension CollectionActionSheet {
-    
-    static var collectionItems: [MyCollectionViewCell.Item] {
-        var items: [MyCollectionViewCell.Item] = []
-        for i in 0...20 {
-            items.append(MyCollectionViewCell.Item(title: "\(i)", subtitle: "\(i)"))
-        }
-        return items
-    }
-    
-    func items(for options: [FoodOption], collectionItems: [MyCollectionViewCell.Item]) -> [ActionSheetItem] {
-        let title = ActionSheetSectionTitle(title: ActionSheet.standardTitle, subtitle: selectionSubtitle(for: collectionItems))
-        
-        let setupAction = { (cell: MyCollectionViewCell, index: Int) in
-            let item = collectionItems[index]
-            cell.configureWith(item: item)
-        }
-        
-        let selectionAction = { [weak self] (cell: MyCollectionViewCell, index: Int) in
-            let item = collectionItems[index]
-            item.isSelected = !item.isSelected
-            title.subtitle = self?.selectionSubtitle(for: collectionItems)
-            cell.configureWith(item: item)
-            self?.reloadData()
-        }
-        
-        let collectionItem = ActionSheetCollectionItem(
-            itemCellType: MyCollectionViewCell.self,
-            itemCount: collectionItems.count,
-            setupAction: setupAction,
-            selectionAction: selectionAction
-        )
-        
-        return [
-            ActionSheetSectionMargin(),
-            title,
-            ActionSheetSectionMargin(),
-            collectionItem,
-            ActionSheet.okButton,
-            ActionSheet.cancelButton]
-    }
-    
-    func selectionSubtitle(for collectionItems: [MyCollectionViewCell.Item]) -> String {
-        return "Selected items: \(collectionItems.filter { $0.isSelected }.count)"
-    }
-}

+ 0 - 41
Carthage/Checkouts/Sheeeeeeeeet/SheeeeeeeeetExample/ActionSheets/CustomActionSheet.swift

@@ -1,41 +0,0 @@
-//
-//  CustomActionSheet.swift
-//  SheeeeeeeeetExample
-//
-//  Created by Daniel Saidi on 2018-10-08.
-//  Copyright © 2018 Daniel Saidi. All rights reserved.
-//
-
-import UIKit
-import Sheeeeeeeeet
-
-class CustomActionSheet: ActionSheet {
-    
-    init(options: [FoodOption], buttonTapAction: @escaping (UIButton) -> ()) {
-        let items = CustomActionSheet.items(for: options, buttonTapAction: buttonTapAction)
-        super.init(items: items) { _, _ in }
-    }
-    
-    required init?(coder aDecoder: NSCoder) {
-        super.init(coder: aDecoder)
-    }
-}
-
-
-// MARK: - Private Functions
-
-private extension CustomActionSheet {
-    
-    static func items(for options: [FoodOption], buttonTapAction: @escaping (UIButton) -> ()) -> [ActionSheetItem] {
-        let customType = MyCustomViewCell.self
-        let customItem = ActionSheetCustomItem(cellType: customType) { cell in
-            cell.buttonTapAction = buttonTapAction
-        }
-        
-        return [
-            ActionSheetTitle(title: "Tap a button"),
-            customItem,
-            cancelButton
-        ]
-    }
-}

+ 0 - 46
Carthage/Checkouts/Sheeeeeeeeet/SheeeeeeeeetExample/ActionSheets/DestructiveActionSheet.swift

@@ -1,46 +0,0 @@
-//
-//  DestructiveActionSheet.swift
-//  SheeeeeeeeetExample
-//
-//  Created by Jonas Ullström on 2018-03-16.
-//  Copyright © 2018 Jonas Ullström. All rights reserved.
-//
-
-/*
- 
- These extensions provides action sheets with functions that
- are shared by all example action sheets.
- 
- */
-
-import Sheeeeeeeeet
-
-class DestructiveActionSheet: ActionSheet {
-    
-    init(options: [FoodOption], action: @escaping ([ActionSheetItem]) -> ()) {
-        let items = DestructiveActionSheet.items(for: options)
-        super.init(items: items) { sheet, item in
-            guard item.isOkButton else { return }
-            let items = sheet.items.compactMap { $0 as? ActionSheetSelectItem }
-            action(items.filter { $0.isSelected })
-        }
-    }
-    
-    required init?(coder aDecoder: NSCoder) {
-        super.init(coder: aDecoder)
-    }
-}
-
-private extension DestructiveActionSheet {
-    
-    static func items(for options: [FoodOption]) -> [ActionSheetItem] {
-        let titleItem = ActionSheetTitle(title: "Remove Payment Options")
-        let image = UIImage(named: "ic_credit_card")
-        let visaTitle = "Visa **** **** **** 4321"
-        let visa = ActionSheetMultiSelectItem(title: visaTitle, isSelected: false, value: "visa", image: image)
-        let masterTitle = "MasterCard **** **** **** 9876"
-        let master = ActionSheetMultiSelectItem(title: masterTitle, isSelected: false, value: "master", image: image)
-        let removeButton = ActionSheetDangerButton(title: "Remove")
-        return [titleItem, visa, master, cancelButton, removeButton]
-    }
-}

+ 0 - 37
Carthage/Checkouts/Sheeeeeeeeet/SheeeeeeeeetExample/ActionSheets/HeaderActionSheet.swift

@@ -1,37 +0,0 @@
-//
-//  HeaderActionSheet.swift
-//  SheeeeeeeeetExample
-//
-//  Created by Jonas Ullström on 2018-03-16.
-//  Copyright © 2018 Jonas Ullström. All rights reserved.
-//
-
-import Sheeeeeeeeet
-
-class HeaderActionSheet: ActionSheet {
-    
-    init(options: [FoodOption], action: @escaping ([ActionSheetItem]) -> ()) {
-        let items = HeaderActionSheet.items(for: options)
-        super.init(items: items) { _, item in
-            if item.value == nil { return }
-            action([item])
-        }
-        let image = UIImage(named: "title-image")
-        headerView = UIImageView(image: image)
-        headerView?.frame.size.height = 150
-    }
-    
-    required init?(coder aDecoder: NSCoder) {
-        super.init(coder: aDecoder)
-    }
-}
-
-private extension HeaderActionSheet {
-    
-    static func items(for options: [FoodOption]) -> [ActionSheetItem] {
-        var items = options.map { $0.item() }
-        items.insert(titleItem(title: standardTitle), at: 0)
-        items.append(cancelButton)
-        return items
-    }
-}

+ 0 - 34
Carthage/Checkouts/Sheeeeeeeeet/SheeeeeeeeetExample/ActionSheets/LinkActionSheet.swift

@@ -1,34 +0,0 @@
-//
-//  LinkActionSheet.swift
-//  SheeeeeeeeetExample
-//
-//  Created by Jonas Ullström on 2018-03-16.
-//  Copyright © 2018 Jonas Ullström. All rights reserved.
-//
-
-import Sheeeeeeeeet
-
-class LinkActionSheet: ActionSheet {
-    
-    init(options: [FoodOption], action: @escaping ([ActionSheetItem]) -> ()) {
-        let items = LinkActionSheet.items(for: options)
-        super.init(items: items) { _, item in
-            if item.value == nil { return }
-            action([item])
-        }
-    }
-    
-    required init?(coder aDecoder: NSCoder) {
-        super.init(coder: aDecoder)
-    }
-}
-
-private extension LinkActionSheet {
-    
-    static func items(for options: [FoodOption]) -> [ActionSheetItem] {
-        var items = options.map { $0.linkItem() }
-        items.insert(titleItem(title: standardTitle), at: 0)
-        items.append(cancelButton)
-        return items
-    }
-}

+ 0 - 50
Carthage/Checkouts/Sheeeeeeeeet/SheeeeeeeeetExample/ActionSheets/MultiSelectActionSheet.swift

@@ -1,50 +0,0 @@
-//
-//  MultiSelectActionSheet.swift
-//  SheeeeeeeeetExample
-//
-//  Created by Jonas Ullström on 2018-03-16.
-//  Copyright © 2018 Jonas Ullström. All rights reserved.
-//
-
-import Sheeeeeeeeet
-
-class MultiSelectActionSheet: ActionSheet {
-    
-    init(options: [FoodOption], preselected: [FoodOption], action: @escaping ([ActionSheetItem]) -> ()) {
-        let items = MultiSelectActionSheet.items(for: options, preselected: preselected)
-        super.init(items: items) { sheet, item in
-            guard item.isOkButton else { return }
-            let selectItems = sheet.items.compactMap { $0 as? ActionSheetSelectItem }
-            let selectedItems = selectItems.filter { $0.isSelected }
-            action(selectedItems)
-        }
-    }
-    
-    required init?(coder aDecoder: NSCoder) {
-        super.init(coder: aDecoder)
-    }
-}
-
-private extension MultiSelectActionSheet {
-    
-    static func items(for options: [FoodOption], preselected: [FoodOption]) -> [ActionSheetItem] {
-        var items = [ActionSheetItem]()
-        items.append(titleItem(title: standardTitle))
-        items.append(contentsOf: itemsGroup(for: options, preselected: .fast, group: "Appetizer"))
-        items.append(ActionSheetSectionMargin())
-        items.append(contentsOf: itemsGroup(for: options, preselected: .homeMade, group: "Main Dish"))
-        items.append(okButton)
-        items.append(cancelButton)
-        return items
-    }
-    
-    static func itemsGroup(for options: [FoodOption], preselected: FoodOption?, group: String) -> [ActionSheetItem] {
-        var items = [ActionSheetItem]()
-        let options = options.filter { $0 != .none && $0 != .fancy }
-        let foodItems = options.map { $0.multiSelectItem(isSelected: $0 == preselected, group: group) }
-        let toggler = ActionSheetMultiSelectToggleItem(title: group, state: .selectAll, group: group, selectAllTitle: "Select all", deselectAllTitle: "Deselect all")
-        items.append(toggler)
-        items.append(contentsOf: foodItems)
-        return items
-    }
-}

+ 0 - 41
Carthage/Checkouts/Sheeeeeeeeet/SheeeeeeeeetExample/ActionSheets/SectionActionSheet.swift

@@ -1,41 +0,0 @@
-//
-//  SectionActionSheet.swift
-//  SheeeeeeeeetExample
-//
-//  Created by Jonas Ullström on 2018-03-16.
-//  Copyright © 2018 Jonas Ullström. All rights reserved.
-//
-
-import Sheeeeeeeeet
-
-class SectionActionSheet: ActionSheet {
-    
-    init(options: [FoodOption], action: @escaping ([ActionSheetItem]) -> ()) {
-        let items = SectionActionSheet.items(for: options)
-        super.init(items: items) { _, item in
-            if item.value == nil { return }
-            action([item])
-        }
-    }
-    
-    required init?(coder aDecoder: NSCoder) {
-        super.init(coder: aDecoder)
-    }
-}
-
-private extension SectionActionSheet {
-    
-    static func items(for options: [FoodOption]) -> [ActionSheetItem] {
-        var items = [ActionSheetItem]()
-        items.append(titleItem(title: standardTitle))
-        items.append(ActionSheetSectionTitle(title: "Cheap"))
-        let cheap = options.filter { $0.isCheap }.map { $0.item() }
-        cheap.forEach { items.append($0) }
-        items.append(ActionSheetSectionMargin())
-        items.append(ActionSheetSectionTitle(title: "Expensive"))
-        let expensive = options.filter { !$0.isCheap }.map { $0.item() }
-        expensive.forEach { items.append($0) }
-        items.append(cancelButton)
-        return items
-    }
-}

+ 0 - 49
Carthage/Checkouts/Sheeeeeeeeet/SheeeeeeeeetExample/ActionSheets/SingleSelectActionSheet.swift

@@ -1,49 +0,0 @@
-//
-//  MultiSelectActionSheet.swift
-//  SheeeeeeeeetExample
-//
-//  Created by Jonas Ullström on 2018-03-16.
-//  Copyright © 2018 Jonas Ullström. All rights reserved.
-//
-
-import Sheeeeeeeeet
-
-class SingleSelectActionSheet: ActionSheet {
-    
-    init(options: [FoodOption], preselected: [FoodOption], action: @escaping ([ActionSheetItem]) -> ()) {
-        let items = SingleSelectActionSheet.items(for: options, preselected: preselected)
-        super.init(items: items) { sheet, item in
-            guard item.isOkButton else { return }
-            let selectItems = sheet.items.compactMap { $0 as? ActionSheetSelectItem }
-            let selectedItems = selectItems.filter { $0.isSelected }
-            action(selectedItems)
-        }
-    }
-    
-    required init?(coder aDecoder: NSCoder) {
-        super.init(coder: aDecoder)
-    }
-}
-
-private extension SingleSelectActionSheet {
-    
-    static func items(for options: [FoodOption], preselected: [FoodOption]) -> [ActionSheetItem] {
-        var items = [ActionSheetItem]()
-        items.append(titleItem(title: standardTitle))
-        items.append(contentsOf: itemsGroup(for: options, preselected: .fast, group: "Appetizer"))
-        items.append(ActionSheetSectionMargin())
-        items.append(contentsOf: itemsGroup(for: options, preselected: .homeMade, group: "Main Dish"))
-        items.append(okButton)
-        items.append(cancelButton)
-        return items
-    }
-    
-    static func itemsGroup(for options: [FoodOption], preselected: FoodOption?, group: String) -> [ActionSheetItem] {
-        var items = [ActionSheetItem]()
-        let options = options.filter { $0 != .none && $0 != .fancy }
-        let foodItems = options.map { $0.singleSelectItem(isSelected: $0 == preselected, group: group) }
-        items.append(ActionSheetSectionTitle(title: group))
-        items.append(contentsOf: foodItems)
-        return items
-    }
-}

+ 0 - 34
Carthage/Checkouts/Sheeeeeeeeet/SheeeeeeeeetExample/ActionSheets/StandardActionSheet.swift

@@ -1,34 +0,0 @@
-//
-//  StandardActionSheet.swift
-//  SheeeeeeeeetExample
-//
-//  Created by Jonas Ullström on 2018-03-16.
-//  Copyright © 2018 Jonas Ullström. All rights reserved.
-//
-
-import Sheeeeeeeeet
-
-class StandardActionSheet: ActionSheet {
-    
-    init(options: [FoodOption], action: @escaping ([ActionSheetItem]) -> ()) {
-        let items = StandardActionSheet.items(for: options)
-        super.init(items: items) { _, item in
-            if item.value == nil { return }
-            action([item])
-        }
-    }
-    
-    required init?(coder aDecoder: NSCoder) {
-        super.init(coder: aDecoder)
-    }
-}
-
-private extension StandardActionSheet {
-    
-    static func items(for options: [FoodOption]) -> [ActionSheetItem] {
-        var items = options.map { $0.item() }
-        items.insert(titleItem(title: standardTitle), at: 0)
-        items.append(cancelButton)
-        return items
-    }
-}