From 30ba264ae838ae5542adcc12b22488f14ec8d471 Mon Sep 17 00:00:00 2001 From: Omar Altayyan Date: Tue, 20 Nov 2018 17:12:46 +0200 Subject: [PATCH] Allow smoother Single image selection when a single image selection mode is selected (by setting imageLimit to 1) the controller doesn't select the image until the user manually deselects the previous one, this modification automatically removes the last picked image to allow for the new image to be selected in single image selection mode. --- Sources/Images/ImagesController.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sources/Images/ImagesController.swift b/Sources/Images/ImagesController.swift index c70a3160..48aec408 100644 --- a/Sources/Images/ImagesController.swift +++ b/Sources/Images/ImagesController.swift @@ -224,6 +224,13 @@ extension ImagesController: UICollectionViewDataSource, UICollectionViewDelegate if cart.images.contains(item) { cart.remove(item) } else { + // In single image selection mode, remove selected image when + // another image is clicked + if Config.Camera.imageLimit == 1 && cart.images.count == 1 + { + cart.remove(cart.images[0]) + } + if Config.Camera.imageLimit == 0 || Config.Camera.imageLimit > cart.images.count{ cart.add(item) }