Skip to content

Commit

Permalink
Merge pull request #62 from hyperoslo/fix/reload
Browse files Browse the repository at this point in the history
Make Cart methods public
  • Loading branch information
onmyway133 authored Oct 23, 2017
2 parents fd268c3 + 739a1e4 commit e106a72
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Sources/Images/Cart.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import UIKit
import Photos

protocol CartDelegate: class {
public protocol CartDelegate: class {
func cart(_ cart: Cart, didAdd image: Image, newlyTaken: Bool)
func cart(_ cart: Cart, didRemove image: Image)
func cartDidReload(_ cart: Cart)
}

/// Cart holds selected images and videos information
public class Cart {

public var images: [Image] = []
Expand All @@ -21,13 +22,13 @@ public class Cart {

// MARK: - Delegate

func add(delegate: CartDelegate) {
public func add(delegate: CartDelegate) {
delegates.add(delegate)
}

// MARK: - Logic

func add(_ image: Image, newlyTaken: Bool = false) {
public func add(_ image: Image, newlyTaken: Bool = false) {
guard !images.contains(image) else { return }

images.append(image)
Expand All @@ -37,7 +38,7 @@ public class Cart {
}
}

func remove(_ image: Image) {
public func remove(_ image: Image) {
guard let index = images.index(of: image) else { return }

images.remove(at: index)
Expand All @@ -47,7 +48,7 @@ public class Cart {
}
}

func reload(_ images: [Image]) {
public func reload(_ images: [Image]) {
self.images = images

for case let delegate as CartDelegate in delegates.allObjects {
Expand All @@ -57,7 +58,7 @@ public class Cart {

// MARK: - Reset

func reset() {
public func reset() {
video = nil
images.removeAll()
delegates.removeAllObjects()
Expand Down

0 comments on commit e106a72

Please sign in to comment.