Skip to content

Commit

Permalink
updated types for les type defining
Browse files Browse the repository at this point in the history
  • Loading branch information
adkenyon committed May 14, 2020
1 parent 8481bc9 commit 9d3ba97
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 27 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@testing-library/react-native": "5.0.3",
"@types/jest": "25.2.2",
"@types/react": "16.9.34",
"@types/react-native": "0.62.8",
"@types/react-native": "^0.62.8",
"all-contributors-cli": "6.14.2",
"auto": "9.26.8",
"eslint": "7.0.0",
Expand Down
20 changes: 5 additions & 15 deletions src/useAccessibilityInfo.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import {useEffect, useState} from 'react'
import {AccessibilityInfo, AccessibilityEvent} from 'react-native'

type AccessibilityEventName =
| 'boldTextChanged' // iOS-only Event
| 'grayscaleChanged' // iOS-only Event
| 'invertColorsChanged' // iOS-only Event
| 'reduceMotionChanged'
| 'screenReaderChanged'
| 'reduceTransparencyChanged' // iOS-only Event
import {AccessibilityInfo, AccessibilityChangeEventName} from 'react-native'

type AccessibilityInfoStaticInitializers =
| 'isBoldTextEnabled'
Expand All @@ -18,7 +10,7 @@ type AccessibilityInfoStaticInitializers =
| 'isReduceTransparencyEnabled'

type AccessibilityEventToInfoStaticKeyMap = {
[K in AccessibilityEventName]?: AccessibilityInfoStaticInitializers
[K in AccessibilityChangeEventName]?: AccessibilityInfoStaticInitializers
}

const EVENT_NAME_TO_INITIALIZER: AccessibilityEventToInfoStaticKeyMap = {
Expand All @@ -30,10 +22,8 @@ const EVENT_NAME_TO_INITIALIZER: AccessibilityEventToInfoStaticKeyMap = {
reduceTransparencyChanged: 'isReduceTransparencyEnabled',
}

type AccessibilityInfoChangeEventHandler = (event: AccessibilityEvent) => void

function useAccessibilityStateListener(
eventName: AccessibilityEventName,
eventName: AccessibilityChangeEventName,
): boolean {
const [isEnabled, setIsEnabled] = useState(false)

Expand All @@ -47,13 +37,13 @@ function useAccessibilityStateListener(
AccessibilityInfo[initializerKey]().then(setIsEnabled)
AccessibilityInfo.addEventListener(
eventName,
<AccessibilityInfoChangeEventHandler>setIsEnabled,
setIsEnabled,
)

return () =>
AccessibilityInfo.removeEventListener(
eventName,
<AccessibilityInfoChangeEventHandler>setIsEnabled,
setIsEnabled,
)
}, [eventName])

Expand Down
22 changes: 11 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1614,13 +1614,13 @@

"@types/prop-types@*":
version "15.7.3"
resolved "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7"
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7"
integrity sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==

"@types/react-native@0.62.8":
version "0.62.8"
resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.62.8.tgz#224602561f75b838ed6e3b5ea37093bb84cffd74"
integrity sha512-YEf0tH3xYJpQB12Vvzoy7cqPY3mvbbulTnG3G7ToKOuJuqigAN3K9NNAaxNAAm1zCj+UtObhzcaJtPRwX1z6Fw==
"@types/react-native@^0.62.8":
version "0.62.9"
resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.62.9.tgz#f75d4a8879e68ed3857d6f2f73dc0752a0505362"
integrity sha512-OcoE7SKz1PsvTGJK5fIwJu6kWdDFN+hH1vMI4GVTEBYhV5FAM5vKVUFCaSiEPJScyNyIEWAeQwFvI3a01+Grzg==
dependencies:
"@types/react" "*"

Expand All @@ -1632,9 +1632,9 @@
"@types/react" "*"

"@types/react@*":
version "16.9.25"
resolved "https://registry.npmjs.org/@types/react/-/react-16.9.25.tgz#6ae2159b40138c792058a23c3c04fd3db49e929e"
integrity sha512-Dlj2V72cfYLPNscIG3/SMUOzhzj7GK3bpSrfefwt2YT9GLynvLCCZjbhyF6VsT0q0+aRACRX03TDJGb7cA0cqg==
version "16.9.35"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.35.tgz#a0830d172e8aadd9bd41709ba2281a3124bbd368"
integrity sha512-q0n0SsWcGc8nDqH2GJfWQWUOmZSJhXV64CjVN5SvcNti3TdEaA3AH0D8DwNmMdzjMAC/78tB8nAZIlV8yTz+zQ==
dependencies:
"@types/prop-types" "*"
csstype "^2.2.0"
Expand Down Expand Up @@ -2823,9 +2823,9 @@ cssstyle@^2.2.0:
cssom "~0.3.6"

csstype@^2.2.0:
version "2.6.9"
resolved "https://registry.npmjs.org/csstype/-/csstype-2.6.9.tgz#05141d0cd557a56b8891394c1911c40c8a98d098"
integrity sha512-xz39Sb4+OaTsULgUERcCk+TJj8ylkL4aSVDQiX/ksxbELSqwkgt4d4RD7fovIdgJGSuNYqwZEiVjYY5l0ask+Q==
version "2.6.10"
resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.6.10.tgz#e63af50e66d7c266edb6b32909cfd0aabe03928b"
integrity sha512-D34BqZU4cIlMCY93rZHbrq9pjTAQJ3U8S8rfBqjwHxkGPThWFjzZDQpgMJY0QViLxth6ZKYiwFBo14RdN44U/w==

dashdash@^1.12.0:
version "1.14.1"
Expand Down

0 comments on commit 9d3ba97

Please sign in to comment.