Skip to content

Commit f174973

Browse files
committed
done for now
1 parent f7647c2 commit f174973

10 files changed

+34
-24
lines changed

src/useAccessibilityInfo.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useEffect, useState } from 'react'
22
import { AccessibilityInfo } from 'react-native'
33

4+
45
export default () => {
56
const [screenReaderEnabled, updateScreenReaderInfo] = useState(null)
67

@@ -17,9 +18,9 @@ export default () => {
1718

1819
useEffect(() => {
1920
AccessibilityInfo.addEventListener('change', onChange)
20-
21+
2122
return () => AccessibilityInfo.removeEventListener('change', onChange)
2223
}, [])
2324

2425
return screenReaderEnabled
25-
}
26+
}

src/useAppState.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import React, { useEffect, useState } from 'react'
2-
import { AppState } from 'react-native'
2+
import { AppState, AppStateStatus } from 'react-native'
3+
34

45
const currentState = AppState.currentState
56

67
export default () => {
78
const [appState, setAppState] = useState(currentState)
89

9-
function onChange (newState) {
10+
function onChange(newState: AppStateStatus) {
1011
setAppState(newState)
1112
}
1213

@@ -19,4 +20,4 @@ export default () => {
1920
})
2021

2122
return appState
22-
}
23+
}

src/useCameraRoll.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import React, { useState } from 'react'
22
import {
3-
CameraRoll
3+
CameraRoll, GetPhotosParamType, GetPhotosReturnType
44
} from 'react-native'
55

6-
const initialState = {
6+
7+
const initialState: GetPhotosReturnType = {
78
edges: [],
89
page_info: {
910
end_cursor: '',
10-
has_next_page: null,
11+
has_next_page: false,
1112
start_cursor: ''
1213
}
1314
}
1415

15-
const defaultConfig = {
16+
const defaultConfig: GetPhotosParamType = {
1617
first: 20,
1718
groupTypes: 'All'
1819
}
@@ -38,4 +39,4 @@ export default function() {
3839
}
3940

4041
return [photos, getPhotos, saveToCameraRoll]
41-
}
42+
}

src/useClipboard.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import React, { useEffect, useState } from 'react'
22
import { Clipboard } from 'react-native'
33

4+
45
export default () => {
56
const [data, updateClipboardData] = useState('')
67

78
useEffect(() => {
8-
(async () => {
9+
(async () => {
910
const content = await Clipboard.getString()
1011
updateClipboardData(content)
1112
})()

src/useDeviceOrientation.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import React, { useEffect, useState } from 'react';
2-
import { Dimensions } from 'react-native';
2+
import { Dimensions, ScaledSize } from 'react-native';
3+
34

45
const screen = Dimensions.get('screen');
56

67
export default () => {
8+
const isOrientationPortrait = ({ width, height }: { width: number, height: number }) => height >= width;
9+
const isOrientationLandscape = ({ width, height }: { width: number, height: number }) => width >= height;
10+
711
const [orientation, setOrientation] = useState({
812
portrait: isOrientationPortrait(screen),
913
landscape: isOrientationLandscape(screen)
1014
});
1115

12-
isOrientationPortrait = ({ width, height }) => height >= width;
13-
isOrientationLandscape = ({ width, height }) => width >= height;
14-
15-
onChange = ({ screen }) => {
16+
const onChange = ({ screen }: { screen: ScaledSize }) => {
1617
setOrientation({
1718
portrait: isOrientationPortrait(screen),
1819
landscape: isOrientationLandscape(screen)

src/useDimensions.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useEffect, useState } from 'react'
2-
import { Dimensions } from 'react-native'
2+
import { Dimensions, ScaledSize } from 'react-native'
3+
34

45
const window = Dimensions.get('window')
56
const screen = Dimensions.get('screen')
@@ -9,7 +10,7 @@ export default () => {
910
window, screen
1011
})
1112

12-
onChange = ({ window, screen }) => {
13+
const onChange = ({ window, screen }: { window: ScaledSize, screen: ScaledSize }) => {
1314
setDimensions({ window, screen })
1415
}
1516

src/useGeolocation.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useEffect, useState } from 'react'
22

3+
34
const initialState = {
45
timeStamp: null,
56
coords: {
@@ -13,7 +14,7 @@ const initialState = {
1314
}
1415
}
1516

16-
export default (positionOptions = {}) => {
17+
export default (positionOptions = {}) => {
1718
const [position, setPosition] = useState(initialState)
1819

1920
useEffect(() => {
@@ -47,4 +48,4 @@ export default (positionOptions = {}) => {
4748
}
4849

4950
return [position, stopObserving, setRNConfiguration]
50-
};
51+
};

src/useInteractionManager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useEffect, useState } from 'react';
22
import { InteractionManager } from 'react-native';
33

4+
45
export default () => {
56
const [complete, updateInteractionStatus] = useState(false);
67

src/useKeyboard.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import React, { useEffect, useState } from 'react'
22
import { Keyboard } from 'react-native'
33

4+
45
export default () => {
56
const [keyboard, setKeyboard] = useState({})
67

7-
keyboardWillShow = e => {
8+
const keyboardWillShow = e => {
89
setKeyboard({
910
isKeyboardShow: true,
1011
keyboardHeight: e.endCoordinates.height
1112
})
1213
}
1314

14-
keyboardWillHide = e => {
15+
const keyboardWillHide = e => {
1516
setKeyboard({
1617
isKeyboardShow: false,
1718
keyboardHeight: e.endCoordinates.height

src/useNetInfo.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import React, { useEffect, useState } from 'react'
22
import { NetInfo } from 'react-native'
33

4+
45
const inititalState = {
56
type: null, effectiveType: null
67
}
78

89
export default () => {
910
const [netInfo, setNetInfo] = useState(inititalState)
1011

11-
onChange = (newState) => {
12+
const onChange = (newState) => {
1213
setNetInfo(newState)
1314
}
1415

@@ -27,4 +28,4 @@ export default () => {
2728
}, [])
2829

2930
return netInfo
30-
}
31+
}

0 commit comments

Comments
 (0)