Skip to content

Commit

Permalink
Merge pull request #59 from RyoAbe/fix_voiceover
Browse files Browse the repository at this point in the history
Add VoiceOver Support
  • Loading branch information
liu044100 authored Sep 20, 2018
2 parents d8a8812 + e80fdfe commit 43abb2b
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Localizable/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
Localizable.strings
Pods

Created by 阿部 諒 on 2018/08/03.

*/

"PasswordDotViewAccessibilityLabel" = "Passcode Field";
"PasswordDotViewAccessibilityValue" = "%d of %d entered";
10 changes: 10 additions & 0 deletions Localizable/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
Localizable.strings
Pods

Created by 阿部 諒 on 2018/08/03.

*/

"PasswordDotViewAccessibilityLabel" = "パスコード";
"PasswordDotViewAccessibilityValue" = "%d個ちゅう%d個が入力されています";
18 changes: 18 additions & 0 deletions SmileLock-Example/Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions SmileLock-Example/SmileLock-Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
1D7E32E52142604800A5227D /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/LaunchScreen.strings; sourceTree = "<group>"; };
3DA1702F1AC31AA3EDCA5FE7 /* Pods_SmileLock_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SmileLock_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
7C52457304DEFE4405D2D34B /* Pods-SmileLock-Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SmileLock-Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SmileLock-Example/Pods-SmileLock-Example.debug.xcconfig"; sourceTree = "<group>"; };
B7A42F861CD2588B00FEB7B0 /* BlurPasswordLoginViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlurPasswordLoginViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -395,6 +396,7 @@
isa = PBXVariantGroup;
children = (
B7E3A1B71CCC6449005F680E /* Base */,
1D7E32E52142604800A5227D /* ja */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
Expand All @@ -406,6 +408,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -454,6 +457,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

4 changes: 4 additions & 0 deletions SmileLock/Classes/PasswordDotView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ open class PasswordDotView: UIView {
@IBInspectable
open var inputDotCount = 0 {
didSet {
let format = Bundle(for: type(of: self)).localizedString(forKey: "PasswordDotViewAccessibilityValue", value: nil, table: nil)
accessibilityValue = String(format: format, totalDotCount, inputDotCount)
setNeedsDisplay()
}
}
Expand Down Expand Up @@ -69,6 +71,8 @@ open class PasswordDotView: UIView {
open override func awakeFromNib() {
super.awakeFromNib()
backgroundColor = UIColor.clear
isAccessibilityElement = true
accessibilityLabel = Bundle(for: type(of: self)).localizedString(forKey: "PasswordDotViewAccessibilityLabel", value: nil, table: nil)
}
open override func layoutSubviews() {
super.layoutSubviews()
Expand Down
2 changes: 2 additions & 0 deletions SmileLock/Classes/PasswordInputView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,14 @@ private extension PasswordInputView {
//configure label
NSLayoutConstraint.addEqualConstraintsFromSubView(label, toSuperView: self)
label.textAlignment = .center
label.isAccessibilityElement = false

//configure button
NSLayoutConstraint.addEqualConstraintsFromSubView(button, toSuperView: self)
button.isExclusiveTouch = true
button.addTarget(self, action: #selector(PasswordInputView.touchDown), for: [.touchDown])
button.addTarget(self, action: #selector(PasswordInputView.touchUp), for: [.touchUpInside, .touchDragOutside, .touchCancel, .touchDragExit])
button.accessibilityValue = numberString
}

//MARK: Animation
Expand Down

0 comments on commit 43abb2b

Please sign in to comment.