Skip to content

Commit fcc8b19

Browse files
committed
rn: Fix coding errors caught by TypeScript
1 parent 1f45e42 commit fcc8b19

10 files changed

Lines changed: 48 additions & 50 deletions

File tree

packages/edge-login-ui-rn/src/components/screens/existingAccout/ChangePasswordScreen.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ class ChangePasswordScreenComponent extends React.Component<Props, State> {
128128
returnKeyType="go"
129129
secureTextEntry
130130
value={this.props.confirmPassword}
131-
isSelected={this.state.focusSecond}
132131
label={s.strings.re_enter_new_password}
133132
onChangeText={(password: string) =>
134133
this.props.validateConfirmPassword(password)

packages/edge-login-ui-rn/src/components/screens/newAccount/NewAccountUsernameScreen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const NewAccountUsernameScreenComponent = ({
7878
label={s.strings.username}
7979
onChangeText={validateUsername}
8080
onSubmitEditing={handleNext}
81-
placeholeder={s.strings.choose_username_input_placeholder}
81+
placeholder={s.strings.choose_username_input_placeholder}
8282
returnKeyType="go"
8383
value={username}
8484
isClearable

packages/edge-login-ui-rn/src/components/screens/newAccount/NewAccountWelcomeScreen.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { sprintf } from 'sprintf-js'
88
import { LOGO_BIG, WELCOME_LOCK, WELCOME_SHIELD_KEY } from '../../../assets'
99
import s from '../../../common/locales/strings.js'
1010
import * as Constants from '../../../constants/index.js'
11-
import * as Styles from '../../../styles/index.js'
1211
import { type Branding } from '../../../types/Branding.js'
1312
import { type Dispatch, type RootState } from '../../../types/ReduxTypes.js'
1413
import { logEvent } from '../../../util/analytics.js'
@@ -145,11 +144,7 @@ const getStyles = cacheStyles((theme: Theme) => ({
145144
},
146145
actions: {
147146
marginTop: theme.rem(4.5)
148-
},
149-
nextButtonUpStyle: Styles.PrimaryButtonUpScaledStyle,
150-
nextButtonUpTextStyle: Styles.PrimaryButtonUpTextScaledStyle,
151-
nextButtonDownTextStyle: Styles.PrimaryButtonUpTextScaledStyle,
152-
nextButtonDownStyle: Styles.PrimaryButtonDownScaledStyle
147+
}
153148
}))
154149

155150
export const NewAccountWelcomeScreen = connect<{}, DispatchProps, OwnProps>(

packages/edge-login-ui-rn/src/components/themed/AccountInfo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const AccountInfoComponent = ({
5252
const spacings = sidesToMargin(mapSides(fixSides(marginRem, 0.5), theme.rem))
5353
const [isExpanded, setIsExpanded] = useState(false)
5454

55-
const animatedRef = useAnimatedRef<View>(null)
55+
const animatedRef = useAnimatedRef<View>()
5656
const expanded = useSharedValue(false)
5757
const rotation = useSharedValue(0)
5858
const height = useSharedValue(0)

packages/edge-login-ui-rn/src/components/themed/BackButton.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
const isIos = Platform.OS === 'ios'
1616

1717
type Props = {
18-
onPress(): void,
18+
onPress?: () => void,
1919
marginRem?: number[] | number,
2020
disabled?: boolean
2121
}

packages/edge-login-ui-rn/src/components/themed/Checkbox.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
22

33
import * as React from 'react'
4-
import { StyleSheet, TouchableWithoutFeedback, View } from 'react-native'
4+
import { type TextStyle, TouchableWithoutFeedback, View } from 'react-native'
55
import { cacheStyles } from 'react-native-patina'
66
import SimpleLineIcons from 'react-native-vector-icons/SimpleLineIcons'
77

@@ -14,14 +14,14 @@ import {
1414
import { EdgeText } from './EdgeText'
1515

1616
type Props = {
17-
textStyle: StyleSheet.Styles,
17+
textStyle: TextStyle,
1818
children: React.Node,
1919
value: boolean,
20-
ellipsizeMode?: string,
20+
ellipsizeMode?: 'head' | 'middle' | 'tail' | 'clip',
2121
numberOfLines?: number,
2222
disabled?: boolean,
2323
marginRem?: number[] | number,
24-
onChange(boolean): void
24+
onChange: (value: boolean) => void
2525
}
2626

2727
const CheckboxComponent = ({

packages/edge-login-ui-rn/src/components/themed/EdgeText.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// copied EdgeText component from 'edge-react-gui'
33

44
import * as React from 'react'
5-
import { type Text as TextProps, StyleSheet, Text } from 'react-native'
5+
import { type TextProps, type TextStyle, Text } from 'react-native'
66
import { cacheStyles } from 'react-native-patina'
77

88
import {
@@ -13,9 +13,9 @@ import {
1313

1414
type OwnProps = {
1515
children: React.Node,
16-
ellipsizeMode?: string,
16+
ellipsizeMode?: 'head' | 'middle' | 'tail' | 'clip',
1717
numberOfLines?: number,
18-
style?: StyleSheet.Styles
18+
style?: TextStyle
1919
}
2020

2121
class EdgeTextComponent extends React.PureComponent<

packages/edge-login-ui-rn/src/components/themed/EdgeTextFieldOutlined.js

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// @flow
22

3-
// $FlowFixMe = forwardRef is not recognize by flow?
4-
import React, { forwardRef, useRef } from 'react'
3+
import * as React from 'react'
54
import {
5+
type TextInputProps,
6+
type TextStyle,
7+
type ViewStyle,
68
Platform,
79
Text,
810
TextInput,
9-
TextInputProps,
1011
TouchableOpacity,
1112
TouchableWithoutFeedback,
1213
View
@@ -16,7 +17,6 @@ import Animated, {
1617
Extrapolate,
1718
interpolate,
1819
interpolateColor,
19-
SharedValue,
2020
useAnimatedStyle,
2121
useSharedValue,
2222
withTiming
@@ -28,6 +28,7 @@ import {
2828
useEffect,
2929
useImperativeHandle,
3030
useMemo,
31+
useRef,
3132
useState
3233
} from '../../util/hooks'
3334
import { fixSides, mapSides, sidesToMargin } from '../../util/sides'
@@ -45,32 +46,23 @@ const ANIMATION_STATES = {
4546
ERROR: 2
4647
}
4748

48-
type InputOutlineProps = {
49+
type InputOutlineProps = TextInputProps & {
4950
label?: string,
5051
error?: string,
5152

5253
marginRem?: number | number[],
5354
isClearable: boolean,
5455
size?: 'big' | 'small',
5556
showSearchIcon?: boolean,
56-
onClear: () => void,
57-
58-
...TextInputProps
59-
}
60-
61-
type InputOutline = {
62-
focus: () => void,
63-
blur: () => void,
64-
isFocused: () => boolean,
65-
clear: () => void
57+
onClear?: () => void
6658
}
6759

6860
type CornerBorderProps = {
6961
theme: Theme,
7062
corner: 'left' | 'right',
7163
cornerHeight: { height: number },
72-
placeholderSize: SharedValue,
73-
colorMap: SharedValue
64+
placeholderSize: Animated.SharedValue<number>,
65+
colorMap: Animated.SharedValue<number>
7466
}
7567

7668
const getColor = (
@@ -128,7 +120,8 @@ const CornerBorder = ({
128120
)
129121
}
130122

131-
const EdgeTextFieldOutlinedComponent = forwardRef(
123+
// $FlowFixMe = forwardRef is not recognize by flow?
124+
const EdgeTextFieldOutlinedComponent = React.forwardRef(
132125
(props: InputOutlineProps, ref) => {
133126
const {
134127
error,
@@ -149,7 +142,7 @@ const EdgeTextFieldOutlinedComponent = forwardRef(
149142
const [containerHeight, setContainerHeight] = useState(0)
150143

151144
// animation
152-
const inputRef: { current: InputOutline } = useRef<TextInput>(null)
145+
const inputRef = useRef<TextInput>(null)
153146
const placeholderMap = useSharedValue(
154147
value ? ANIMATION_STATES.FOCUSED : ANIMATION_STATES.INIT
155148
)
@@ -198,18 +191,18 @@ const EdgeTextFieldOutlinedComponent = forwardRef(
198191
[error]
199192
)
200193

201-
const handleFocus = () => {
194+
const handleFocus = e => {
202195
placeholderMap.value = withTiming(ANIMATION_STATES.FOCUSED)
203196
if (!errorState()) colorMap.value = withTiming(ANIMATION_STATES.FOCUSED)
204197
focus()
205-
if (onFocus) onFocus()
198+
if (onFocus) onFocus(e)
206199
}
207200

208-
const handleBlur = () => {
201+
const handleBlur = e => {
209202
if (!value) placeholderMap.value = withTiming(ANIMATION_STATES.INIT) // blur
210203
if (!errorState()) colorMap.value = withTiming(ANIMATION_STATES.INIT) // inactive
211204
blur()
212-
if (onBlur) onBlur()
205+
if (onBlur) onBlur(e)
213206
}
214207

215208
const handleChangeText = (text: string) => {
@@ -430,11 +423,11 @@ const getSizeStyles = (
430423
const placeholderSizeScale = 0.2
431424
let paddingVertical = theme.rem(PADDING_VERTICAL)
432425
let hintLeftMargin = -theme.rem(0.25)
433-
const inputStyles = [styles.input]
434-
const placeholderTextStyles = [styles.placeholderText]
435-
const placeholderPaddingStyles = [styles.placeholder]
436-
const placeholderSpacerPaddingStyles = [styles.placeholderSpacer]
437-
const inputContainerStyles = [styles.inputContainer]
426+
const inputStyles: TextStyle[] = [styles.input]
427+
const placeholderTextStyles: TextStyle[] = [styles.placeholderText]
428+
const placeholderPaddingStyles: TextStyle[] = [styles.placeholder]
429+
const placeholderSpacerPaddingStyles: ViewStyle[] = [styles.placeholderSpacer]
430+
const inputContainerStyles: ViewStyle[] = [styles.inputContainer]
438431
const prefixStyles = [styles.prefix]
439432
const suffixStyles = [styles.suffix]
440433
if (showSearchIcon) {

packages/edge-login-ui-rn/src/components/themed/IconSignal.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ type IconProps = {
1717
}
1818

1919
type Props = {
20-
enabledIcon: React.Component<IconProps>,
21-
disabledIcon: React.Component<IconProps>,
20+
enabledIcon: React.ComponentType<IconProps>,
21+
disabledIcon: React.ComponentType<IconProps>,
2222
enabled: boolean
2323
}
2424

@@ -34,13 +34,11 @@ const IconSignalComponent = ({
3434
<View style={styles.container}>
3535
<View style={styles.icon}>
3636
<Fade visible={enabled}>
37-
{/* $FlowFixMe */}
3837
<EnabledIcon size={theme.rem(1.1)} color={theme.positiveText} />
3938
</Fade>
4039
</View>
4140
<View style={styles.icon}>
4241
<Fade visible={!enabled}>
43-
{/* $FlowFixMe */}
4442
<DisabledIcon size={theme.rem(1.1)} color={theme.warningText} />
4543
</Fade>
4644
</View>

packages/edge-login-ui-rn/src/types/Theme.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
// @flow
22

3+
type FontWeight =
4+
| 'normal'
5+
| 'bold'
6+
| '100'
7+
| '200'
8+
| '300'
9+
| '400'
10+
| '500'
11+
| '600'
12+
| '700'
13+
| '800'
14+
| '900'
15+
316
export type Theme = {|
417
// The app scaling factor, which is the height of "normal" text:
518
rem(size: number): number,
619

720
pressedOpacity: number,
821
fontFamily: string,
9-
fontWeightBold: string,
22+
fontWeightBold: FontWeight,
1023

1124
// Icons
1225
icon: string,

0 commit comments

Comments
 (0)