Skip to content

Commit

Permalink
Revert voice over reordering and release as bug fix (#380)
Browse files Browse the repository at this point in the history
* Revert "Merge pull request #376 from kyleve/alex/reorder"

This reverts commit 147437f, reversing
changes made to d203694.

# Conflicts:
#	Podfile.lock

* Bumping versions to 3.2.1
  • Loading branch information
kylebshr authored Mar 25, 2022
1 parent a24e7e6 commit 87ea7df
Show file tree
Hide file tree
Showing 16 changed files with 14 additions and 317 deletions.
29 changes: 0 additions & 29 deletions BlueprintUILists/Sources/ListReorderGesture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -108,7 +97,6 @@ public struct ListReorderGesture : Element
}
}
}

}


Expand Down Expand Up @@ -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
}
}
}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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?
Expand Down
1 change: 0 additions & 1 deletion ListableUI.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
12 changes: 0 additions & 12 deletions ListableUI/Resources/en.lproj/Localizable.strings

This file was deleted.

28 changes: 0 additions & 28 deletions ListableUI/Sources/Bundle+ListableUI.swift

This file was deleted.

45 changes: 0 additions & 45 deletions ListableUI/Sources/Internal/ItemCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ final class ItemCell<Content:ItemContent> : UICollectionViewCell, AnyItemCell
return layoutAttributes
}

override func prepareForReuse() {
super.prepareForReuse()
_accessibilityLabel = nil
}

// MARK: UIView

override func sizeThatFits(_ size: CGSize) -> CGSize {
Expand Down Expand Up @@ -141,23 +136,6 @@ final class ItemCell<Content:ItemContent> : 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
}
}
}


Expand All @@ -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()
}
}
}
}
55 changes: 0 additions & 55 deletions ListableUI/Sources/ListView/ListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 0 additions & 43 deletions ListableUI/Sources/ListableLocalizedStrings.swift

This file was deleted.

18 changes: 0 additions & 18 deletions ListableUI/Sources/ReorderingActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

}


Expand All @@ -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
}
2 changes: 0 additions & 2 deletions ListableUI/Tests/Fixtures/PresentationState+Fixtures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
12 changes: 6 additions & 6 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading

0 comments on commit 87ea7df

Please sign in to comment.