-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue where text entry do not have "text field" or a hint in the …
…description (#186) Fixes the issue where text fields and text views do not have "text field" or a hint in their description --------- Co-authored-by: David Brunow <[email protected]> Co-authored-by: Nick Entin <[email protected]>
- Loading branch information
1 parent
07c283f
commit f039d27
Showing
22 changed files
with
381 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// Copyright 2024 Square Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct SwiftUITextEntry: View { | ||
var body: some View { | ||
VStack { | ||
TextField("SwiftUI Text Field", text: .constant("")) | ||
TextField("SwiftUI Text Field", text: .constant("Value in Text Field")) | ||
if #available(iOS 14.0, *) { | ||
TextEditor(text: .constant("")) | ||
} | ||
} | ||
} | ||
} | ||
|
||
struct SwiftUITextEntry_Previews: PreviewProvider { | ||
static var previews: some View { | ||
SwiftUITextEntry() | ||
.previewLayout(.sizeThatFits) | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
Example/AccessibilitySnapshot/TextFieldViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// | ||
// Copyright 2024 Block Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Paralayout | ||
import UIKit | ||
|
||
final class TextFieldViewController: AccessibilityViewController { | ||
|
||
// MARK: - UIViewController | ||
|
||
override func loadView() { | ||
self.view = View() | ||
} | ||
} | ||
|
||
// MARK: - | ||
|
||
private extension TextFieldViewController { | ||
|
||
final class View: UIView { | ||
|
||
// MARK: - Life Cycle | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
|
||
textFieldWithPlaceholder.placeholder = "Some placeholder text" | ||
|
||
textFieldWithText.text = "Hello from Text Field" | ||
|
||
textInputViews.forEach { | ||
$0.layer.borderWidth = 1.0 | ||
$0.layer.borderColor = UIColor.lightGray.cgColor | ||
addSubview($0) | ||
} | ||
} | ||
|
||
@available(*, unavailable) | ||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
// MARK: - Private Properties | ||
|
||
private let textFieldEmpty: UITextField = .init() | ||
|
||
private let textFieldFirstResponder: UITextField = .init() | ||
|
||
private let textFieldWithPlaceholder: UITextField = .init() | ||
|
||
private let textFieldWithText: UITextField = .init() | ||
|
||
private var textInputViews: [UIView] { | ||
return [ | ||
textFieldEmpty, | ||
textFieldFirstResponder, | ||
textFieldWithPlaceholder, | ||
textFieldWithText, | ||
] | ||
} | ||
|
||
// MARK: - UIView | ||
|
||
override func layoutSubviews() { | ||
textInputViews.forEach { $0.frame.size = CGSize(width: 250, height: 30) } | ||
|
||
let statusBarHeight = window?.windowScene?.statusBarManager?.statusBarFrame.height ?? 0 | ||
|
||
var distributionSpecifiers: [ViewDistributionSpecifying] = [ statusBarHeight.fixed, 1.flexible ] | ||
for subview in textInputViews { | ||
distributionSpecifiers.append(subview) | ||
distributionSpecifiers.append(1.flexible) | ||
} | ||
applyVerticalSubviewDistribution(distributionSpecifiers) | ||
|
||
textFieldFirstResponder.becomeFirstResponder() | ||
} | ||
|
||
} | ||
|
||
} |
89 changes: 89 additions & 0 deletions
89
Example/AccessibilitySnapshot/TextViewViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// | ||
// Copyright 2024 Block Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Paralayout | ||
import UIKit | ||
|
||
final class TextViewViewController: AccessibilityViewController { | ||
|
||
// MARK: - UIViewController | ||
|
||
override func loadView() { | ||
self.view = View() | ||
} | ||
} | ||
|
||
// MARK: - | ||
|
||
private extension TextViewViewController { | ||
|
||
final class View: UIView { | ||
|
||
// MARK: - Life Cycle | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
|
||
textViewWithText.text = "Hello from Text View" | ||
|
||
textInputViews.forEach { | ||
$0.layer.borderWidth = 1.0 | ||
$0.layer.borderColor = UIColor.lightGray.cgColor | ||
addSubview($0) | ||
} | ||
} | ||
|
||
@available(*, unavailable) | ||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
// MARK: - Private Properties | ||
|
||
private let textViewEmpty: UITextView = .init() | ||
|
||
private let textViewFirstResponder: UITextView = .init() | ||
|
||
private let textViewWithText: UITextView = .init() | ||
|
||
private var textInputViews: [UIView] { | ||
return [ | ||
textViewEmpty, | ||
textViewFirstResponder, | ||
textViewWithText, | ||
] | ||
} | ||
|
||
// MARK: - UIView | ||
|
||
override func layoutSubviews() { | ||
textInputViews.forEach { $0.frame.size = CGSize(width: 250, height: 30) } | ||
|
||
let statusBarHeight = window?.windowScene?.statusBarManager?.statusBarFrame.height ?? 0 | ||
|
||
var distributionSpecifiers: [ViewDistributionSpecifying] = [ statusBarHeight.fixed, 1.flexible ] | ||
for subview in textInputViews { | ||
distributionSpecifiers.append(subview) | ||
distributionSpecifiers.append(1.flexible) | ||
} | ||
applyVerticalSubviewDistribution(distributionSpecifiers) | ||
|
||
textViewFirstResponder.becomeFirstResponder() | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+133 KB
...sts/__Snapshots__/SnapshotTestingTests/testSwiftUITextEntry.375x812-13-7-3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+161 KB
...sts/__Snapshots__/SnapshotTestingTests/testSwiftUITextEntry.390x844-14-5-3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+166 KB
...sts/__Snapshots__/SnapshotTestingTests/testSwiftUITextEntry.393x852-16-4-3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+166 KB
...sts/__Snapshots__/SnapshotTestingTests/testSwiftUITextEntry.393x852-17-2-3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+165 KB
...Tests/__Snapshots__/SnapshotTestingTests/testUIKitTextField.375x812-13-7-3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+170 KB
...Tests/__Snapshots__/SnapshotTestingTests/testUIKitTextField.390x844-14-5-3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+172 KB
...Tests/__Snapshots__/SnapshotTestingTests/testUIKitTextField.393x852-16-4-3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+170 KB
...Tests/__Snapshots__/SnapshotTestingTests/testUIKitTextField.393x852-17-2-3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+169 KB
...tTests/__Snapshots__/SnapshotTestingTests/testUIKitTextView.375x812-13-7-3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+175 KB
...tTests/__Snapshots__/SnapshotTestingTests/testUIKitTextView.390x844-14-5-3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+177 KB
...tTests/__Snapshots__/SnapshotTestingTests/testUIKitTextView.393x852-16-4-3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+177 KB
...tTests/__Snapshots__/SnapshotTestingTests/testUIKitTextView.393x852-17-2-3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.