diff --git a/BlueprintUILists/Sources/ListReorderGesture.swift b/BlueprintUILists/Sources/ListReorderGesture.swift index cbb357cf4..bfa950d3f 100644 --- a/BlueprintUILists/Sources/ListReorderGesture.swift +++ b/BlueprintUILists/Sources/ListReorderGesture.swift @@ -54,10 +54,6 @@ public struct ListReorderGesture : Element let actions : ReorderingActions - /// The acccessibility Label of the item that will be reordered. - /// This will be set as the gesture's accessibilityValue to provide a richer VoiceOver utterance. - public var reorderItemAccessibilityLabel : String? = nil - /// Creates a new re-order gesture which wraps the provided element. /// /// This element on its own has no visual appearance. Thus, you should @@ -93,13 +89,6 @@ public struct ListReorderGesture : Element } config.apply { view in - view.isAccessibilityElement = true - view.accessibilityLabel = ListableLocalizedStrings.ReorderGesture.accessibilityLabel - view.accessibilityValue = reorderItemAccessibilityLabel - view.accessibilityHint = ListableLocalizedStrings.ReorderGesture.accessibilityHint - view.accessibilityTraits.formUnion(.button) - view.accessibilityCustomActions = accessibilityActions() - view.recognizer.isEnabled = self.isEnabled view.recognizer.apply(actions: self.actions) @@ -108,7 +97,6 @@ public struct ListReorderGesture : Element } } } - } @@ -150,20 +138,3 @@ fileprivate extension ListReorderGesture } } } - - -fileprivate extension ListReorderGesture { - func accessibilityActions() -> [UIAccessibilityCustomAction]? { - if #available(iOS 13.0, *) { - let up = UIAccessibilityCustomAction(name: ListableLocalizedStrings.ReorderGesture.accessibilityMoveUp) { _ in - return self.actions.accessibilityMove(direction: .up) - } - let down = UIAccessibilityCustomAction(name: ListableLocalizedStrings.ReorderGesture.accessibilityMoveDown) { _ in - return self.actions.accessibilityMove(direction: .down) - } - return [up, down] - } else { - return nil - } - } -} diff --git a/CHANGELOG.md b/CHANGELOG.md index 799fdf3b3..ce682015b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,11 @@ # Past Releases +# [3.2.1] - 2022-03-25 + +### Removed +- Removed item reordering with VoiceOver as it caused issues with KIF tests. + # [3.2.0] - 2022-03-21 ### Fixed diff --git a/Demo/Sources/Demos/Demo Screens/CollectionViewAppearance.swift b/Demo/Sources/Demos/Demo Screens/CollectionViewAppearance.swift index bd7cbb00b..21d006b6a 100644 --- a/Demo/Sources/Demos/Demo Screens/CollectionViewAppearance.swift +++ b/Demo/Sources/Demos/Demo Screens/CollectionViewAppearance.swift @@ -142,7 +142,7 @@ struct DemoItem : BlueprintItemContent, Equatable, LocalizedCollatableItemConten func element(with info : ApplyItemContentInfo) -> Element { - let row = Row { row in + Row { row in row.verticalAlignment = .center row.add(child: Label(text: self.text) { @@ -163,12 +163,7 @@ struct DemoItem : BlueprintItemContent, Equatable, LocalizedCollatableItemConten } } .inset(horizontal: 15.0, vertical: 13.0) - - if !info.isReorderable { - // Only wrap the row in an accessibility element if we arent showing the reorder gesture. - return AccessibilityElement(label: self.text, value: nil, traits: [.button], wrapping: row) - } - return row + .accessibilityElement(label: self.text, value: nil, traits: [.button]) } func backgroundElement(with info: ApplyItemContentInfo) -> Element? diff --git a/ListableUI.podspec b/ListableUI.podspec index 8e2320bd4..a58412375 100644 --- a/ListableUI.podspec +++ b/ListableUI.podspec @@ -14,7 +14,6 @@ Pod::Spec.new do |s| s.swift_versions = ['5.4'] s.source_files = 'ListableUI/Sources/**/*.{swift,h,m}' - s.resource_bundle = { 'ListableUIResources' => 'ListableUI/Resources/**/*' } s.weak_framework = 'SwiftUI' diff --git a/ListableUI/Resources/en.lproj/Localizable.strings b/ListableUI/Resources/en.lproj/Localizable.strings deleted file mode 100644 index 9027793fc..000000000 --- a/ListableUI/Resources/en.lproj/Localizable.strings +++ /dev/null @@ -1,12 +0,0 @@ -/* title for an accessibility action that will move a selected cell down one position in the list. */ -"reorder.AccessibilityAction.MoveDown" = "Move down"; - -/* title for an accessibility action that will move a selected cell up one position in the list. */ -"reorder.AccessibilityAction.MoveUp" = "Move up"; - -/* Accessibility hint for the reorder control in an item */ -"reorder.AccessibilityHint" = "Double tap and hold, wait for the sound, then drag to rearrange."; - -/* Accessibility label for the reorder control on an item */ -"reorder.AccessibilityLabel" = "Reorder"; - diff --git a/ListableUI/Sources/Bundle+ListableUI.swift b/ListableUI/Sources/Bundle+ListableUI.swift deleted file mode 100644 index 23e91444f..000000000 --- a/ListableUI/Sources/Bundle+ListableUI.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// Bundle+ListableUI.swift -// ListableUI -// -// Created by Alex Odawa on 01/03/2022. -// - -import Foundation - -private final class MarkerClass {} - -extension Bundle { - /// The resource bundle - static let listableUIResources: Bundle = { - #if SWIFT_PACKAGE - return .module - #else - let listableUIResources: Bundle = Bundle(for: MarkerClass.self) - - guard let resourcePath = listableUIResources.path(forResource: "ListableUIResources", ofType: "bundle"), - let bundle = Bundle(path: resourcePath) - else { - fatalError("Could not load bundle ListableUIResources") - } - return bundle - #endif - }() -} diff --git a/ListableUI/Sources/Internal/ItemCell.swift b/ListableUI/Sources/Internal/ItemCell.swift index 4129a90c3..24c43181e 100644 --- a/ListableUI/Sources/Internal/ItemCell.swift +++ b/ListableUI/Sources/Internal/ItemCell.swift @@ -90,11 +90,6 @@ final class ItemCell : UICollectionViewCell, AnyItemCell return layoutAttributes } - override func prepareForReuse() { - super.prepareForReuse() - _accessibilityLabel = nil - } - // MARK: UIView override func sizeThatFits(_ size: CGSize) -> CGSize { @@ -141,23 +136,6 @@ final class ItemCell : UICollectionViewCell, AnyItemCell liveCells.add(self) } - - - // MARK: AccessibilityLabel - - // When reordering cells the UICollectionView expects all cells to have a valid accessibility label, even when acting as an accessibility container with `isAccessibilityElement == false`. This is used to announce the destination of the reodering operaton in relation to the other cells, e.g. "Before foo" or "after bar". - private var _accessibilityLabel: String? - override var accessibilityLabel: String? { - set { - _accessibilityLabel = newValue - } - get { - guard let accessibilityLabel = _accessibilityLabel else { - return contentView.firstAccessibleChild()?.accessibilityLabel - } - return accessibilityLabel - } - } } @@ -183,26 +161,3 @@ final class LiveCells { weak var cell : AnyItemCell? } } - - -extension UIView { - - fileprivate func firstAccessibleChild() -> NSObject? { - guard !isAccessibilityElement else { - return self - } - return recursiveAccessibleSubviews().first as? NSObject - } - - fileprivate func recursiveAccessibleSubviews() -> [Any] { - subviews.flatMap { subview -> [Any] in - if let accessibilityElements = subview.accessibilityElements { - return accessibilityElements - } else if subview.isAccessibilityElement { - return [subview] - } else { - return subview.recursiveAccessibleSubviews() - } - } - } -} diff --git a/ListableUI/Sources/ListView/ListView.swift b/ListableUI/Sources/ListView/ListView.swift index ce732d21f..a04d6d7e6 100644 --- a/ListableUI/Sources/ListView/ListView.swift +++ b/ListableUI/Sources/ListView/ListView.swift @@ -1333,61 +1333,6 @@ extension ListView : ReorderingActionsDelegate } } - func accessibilityMove(item: AnyPresentationItemState, direction: ReorderingActions.AccessibilityMoveDirection) -> Bool { - guard let indexPath = self.storage.presentationState.indexPath(for: item), - self.dataSource.collectionView(self.collectionView, canMoveItemAt: indexPath) else { - return false - } - - let destinationPath : IndexPath - switch direction { - case .up: - // Moving an item up means decrementing the index. - if indexPath.row == 0 { - // First item in section, we should go to the previous section - if indexPath.section > 0 { - let newSection = indexPath.section - 1 - let rowInNewSection = self.storage.allContent.sections[indexPath.section - 1].count - destinationPath = IndexPath(row: rowInNewSection, section:newSection ) - } - else { - // Unable to move up, we are item 0,0. - return false - } - } else { - destinationPath = IndexPath(row: indexPath.row - 1, section: indexPath.section) - } - - case .down: - // Moving an item down means incrementing the index. - if indexPath.row == storage.allContent.sections[indexPath.section].count - 1 { - // we are the last item our section, lets see if there's another section we can move down to - if storage.allContent.sections.count - 1 > indexPath.section { - destinationPath = IndexPath(row: 0, section: indexPath.section + 1) - } else { - // Unable to move down, we are the last item in the last section. - return false - } - } else { - destinationPath = IndexPath(row: indexPath.row + 1, section: indexPath.section) - } - } - - let targetPath = self.delegate.collectionView(self.collectionView, targetIndexPathForMoveFromItemAt: indexPath, toProposedIndexPath: destinationPath) - - /* We are responding to a user event, but won't be using the `InteractiveMovement` API the collection view provides as we are being called from an accessibility action rather than a gesture regognizer. This means we'll have to call out to the dataSource directly. - - NOTE: It's Important that we call `dataSource.collectionView(_ :, moveItemAt:, to:)` to perform the move in the data source before calling `collectionView.moveItem(at:, to:)` to update the collection view itself. - */ - - item.beginReorder(from: indexPath, with: self.environment) - self.dataSource.collectionView(self.collectionView, moveItemAt: indexPath, to: targetPath) - self.collectionView.moveItem(at: indexPath, to: targetPath) - item.endReorder(with: environment, result: .finished) - - return true - } - func cancelAllInProgressReorders() { self.storage.presentationState.forEachItem { _, item in diff --git a/ListableUI/Sources/ListableLocalizedStrings.swift b/ListableUI/Sources/ListableLocalizedStrings.swift deleted file mode 100644 index dc1e67f19..000000000 --- a/ListableUI/Sources/ListableLocalizedStrings.swift +++ /dev/null @@ -1,43 +0,0 @@ -// -// LocalizedStrings.swift -// BlueprintUILists -// -// Created by Alex Odawa on 22/02/2022. -// - -import Foundation - - -public struct ListableLocalizedStrings { - - public struct ReorderGesture{ - - - public static let accessibilityLabel = NSLocalizedString("reorder.AccessibilityLabel", - tableName: nil, - bundle: .listableUIResources, - value: "Reorder", - comment: "Accessibility label for the reorder control on an item") - - public static let accessibilityHint = NSLocalizedString("reorder.AccessibilityHint", - tableName: nil, - bundle: .listableUIResources, - value: "Double tap and hold, wait for the sound, then drag to rearrange.", - comment: "Accessibility hint for the reorder control in an item") - - - public static let accessibilityMoveUp = NSLocalizedString("reorder.AccessibilityAction.MoveUp", - tableName: nil, - bundle: .listableUIResources, - value: "Move up", - comment:"title for an accessibility action that will move a selected cell up one position in the list.") - - public static let accessibilityMoveDown = NSLocalizedString("reorder.AccessibilityAction.MoveDown", - tableName: nil, - bundle: .listableUIResources, - value:"Move down", - comment:"title for an accessibility action that will move a selected cell down one position in the list.") - } - -} - diff --git a/ListableUI/Sources/ReorderingActions.swift b/ListableUI/Sources/ReorderingActions.swift index 9e0a93d58..069a7718a 100644 --- a/ListableUI/Sources/ReorderingActions.swift +++ b/ListableUI/Sources/ReorderingActions.swift @@ -68,14 +68,6 @@ public final class ReorderingActions self.delegate?.endReorder(for: item, with: result) } - - public func accessibilityMove(direction: AccessibilityMoveDirection) -> Bool { - guard let item = self.item, let delegate = self.delegate else { - return false - } - return delegate.accessibilityMove(item: item, direction: direction) - } - } @@ -87,20 +79,10 @@ extension ReorderingActions { } } -extension ReorderingActions { - /// Used with the accessibilityMove(item: direction:) delegate method to indicate the direction a selected item should be moved in the collection view. - public enum AccessibilityMoveDirection { - case up - case down - } -} protocol ReorderingActionsDelegate : AnyObject { func beginReorder(for item : AnyPresentationItemState) -> Bool func updateReorderTargetPosition(with recognizer : ItemReordering.GestureRecognizer, for item : AnyPresentationItemState) func endReorder(for item : AnyPresentationItemState, with result : ReorderingActions.Result) - - // In addition to reordering cells with the standard drag gesture we offer an AccessibilityCustomAction to move a selected cell up or down by a single index path position. This provides an affordance for those who struggle to precisely drag cells about the screen. - func accessibilityMove(item: AnyPresentationItemState, direction: ReorderingActions.AccessibilityMoveDirection) -> Bool } diff --git a/ListableUI/Tests/Fixtures/PresentationState+Fixtures.swift b/ListableUI/Tests/Fixtures/PresentationState+Fixtures.swift index 06d4afef1..058b00a1a 100644 --- a/ListableUI/Tests/Fixtures/PresentationState+Fixtures.swift +++ b/ListableUI/Tests/Fixtures/PresentationState+Fixtures.swift @@ -88,6 +88,4 @@ final class ReorderingActionsDelegateMock : ReorderingActionsDelegate ) {} func endReorder(for item: AnyPresentationItemState, with result: ReorderingActions.Result) {} - - func accessibilityMove(item: AnyPresentationItemState, direction: ReorderingActions.AccessibilityMoveDirection) -> Bool { true } } diff --git a/Podfile.lock b/Podfile.lock index 8d2ccc744..4584076a3 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -2,15 +2,15 @@ PODS: - BlueprintUI (0.37.0) - BlueprintUICommonControls (0.37.0): - BlueprintUI (= 0.37.0) - - BlueprintUILists (3.2.0): + - BlueprintUILists (3.2.1): - BlueprintUI - ListableUI - - BlueprintUILists/Tests (3.2.0): + - BlueprintUILists/Tests (3.2.1): - BlueprintUI - ListableUI - EnglishDictionary (1.0.0.LOCAL) - - ListableUI (3.2.0) - - ListableUI/Tests (3.2.0): + - ListableUI (3.2.1) + - ListableUI/Tests (3.2.1): - EnglishDictionary - Snapshot - Snapshot (1.0.0.LOCAL) @@ -45,9 +45,9 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: BlueprintUI: 6b7661b6ad54fb15cb3cd670d0917aa6d1a3d508 BlueprintUICommonControls: 714c3b2068ff74c59a5965f462f2c9c2a4c018e1 - BlueprintUILists: ad39019aadba3f0ef308c6cbc6f65334f1dc1f4d + BlueprintUILists: c47cf982adbe6732331a0c3ea1473c2255ac5555 EnglishDictionary: f03968b9382ddc5c8dd63535efbf783c6cd45f1c - ListableUI: acc5402fffe43dd6a2330fb0964a4579acac91eb + ListableUI: b084439b3774468a30b95d3dabf75550757e82e0 Snapshot: cda3414db426919d09f775434b36289c8e864183 PODFILE CHECKSUM: 505f47e09640e9b7eadef9a138cfeed056359f76 diff --git a/RELEASING.md b/RELEASING.md index a9136b1ee..6b2226e6d 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -15,8 +15,6 @@ 1. Create a branch off `main` to update the version numbers and `Podfile.lock`. An example name would be `your-username/release-0.1.0`. -1. Update localized strings. Find the sha of the latest commit with `git log`, then run `./Scripts/install_localized_strings.sh [sha]` to download the latest translations. - 1. Update the library version in `version.rb` if it has not already been updated (it should match the version number that you are about to release). 1. Update `CHANGELOG.md` (in the root of the repo), moving current changes under `Main` to a new section under `Past Releases` for the version you are releasing. diff --git a/Scripts/extract_english_strings.sh b/Scripts/extract_english_strings.sh deleted file mode 100755 index 922b04cf7..000000000 --- a/Scripts/extract_english_strings.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -# Generate a Localizable.strings file from the ListableLocalizedStrings.swift file in ListableUI -# Usage: extract_english_strings - -set -euo pipefail - -# We want this to be runnable from Xcode or the root of the repo, -# so we cd to the script dir is and use paths relative to that. -cd "$(dirname "${BASH_SOURCE[0]}")" - -genstrings -o ../ListableUI/Resources/en.lproj \ -../ListableUI/Sources/ListableLocalizedStrings.swift \ - -# genstrings encodes its file in UTF-16, but UTF-8 is also supported and will show in diffs, -# so we'll convert the file to UTF-8 -iconv -f UTF-16 -t UTF-8 ../ListableUI/Resources/en.lproj/Localizable.strings > temp && mv temp ../ListableUI/Resources/en.lproj/Localizable.strings diff --git a/Scripts/install_localized_strings.sh b/Scripts/install_localized_strings.sh deleted file mode 100755 index 155411437..000000000 --- a/Scripts/install_localized_strings.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env bash - -# Usage: install-localized-strings [--allowpartials] [SHA] -# -# --allowpartials - (Optional) Allow incomplete translations and download all available languages. -# SHA = (Optional) The SHA to download strings for. Uses HEAD if none is specified. - -set -euo pipefail - -SHA=$1 -PROJECT_NAME="listable" - -if [ ! -e "${PWD}/ListableUI" ]; then - echo "ERROR: This script must be run from the root of the Listable repo!" - exit 1 -fi - -URL_ARGUMENTS="?encoding=utf-8" -if [ "$1" == "--allowpartials" ]; then - URL_ARGUMENTS="${URL_ARGUMENTS}&partial=true" - SHA=$2 -fi - -if [ "$SHA" == "" ]; then - SHA=`git rev-parse HEAD` - echo "SHA not specified, using current HEAD: $SHA" -fi - -STRINGS_PATH=./localized_strings_$SHA.tgz - -echo -e "Downloading translations for project '${PROJECT_NAME}' at commit '${SHA}'\n" - -# Attempt to download Strings manifest tar. Exit on non-200 -URL_STRINGS=https://shuttle.squareup.com/projects/${PROJECT_NAME}/commits/${SHA}/manifest.ios$URL_ARGUMENTS -STATUSCODE_STRINGS=$(curl --output $STRINGS_PATH --write-out "%{http_code}" $URL_STRINGS) -if [[ $STATUSCODE_STRINGS -ne 200 ]]; then - echo -e "\nDownloading Strings manifest failed!\n" - echo " - URL: $URL_STRINGS" - echo " - Status code: $STATUSCODE_STRINGS" - echo -e "\nCheck translation is completed: https://shuttle.squareup.com/projects/${PROJECT_NAME}/commits/${SHA}" - - # Leaving git in a clean state on error - rm $STRINGS_PATH - exit 1 -fi - -# Expand the downloaded strings -tar xvzf $STRINGS_PATH - -# Remove the tar file -rm $STRINGS_PATH diff --git a/version.rb b/version.rb index d14512f34..5b7421105 100644 --- a/version.rb +++ b/version.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -LISTABLE_VERSION ||= '3.2.0' +LISTABLE_VERSION ||= '3.2.1'