Skip to content

Commit

Permalink
style(tcr): flow error
Browse files Browse the repository at this point in the history
  • Loading branch information
Manjiz committed Jun 1, 2018
1 parent fa12fbe commit d275231
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 163 deletions.
4 changes: 4 additions & 0 deletions packages/taro-components-rn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ cp -rf src AwesomeProjectDir/src/tcr
- [ ] camera
- 其他
- [ ] tabbar

## D~

[flow type annotation for children react elements](https://stackoverflow.com/a/42887802)
8 changes: 4 additions & 4 deletions packages/taro-components-rn/src/components/Button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @flow
*/

import React, { Component } from 'react'
import * as React from 'react'
import {
TouchableOpacity,
Text,
Expand All @@ -46,8 +46,8 @@ import styles from './styles'
type Props = {
style?: StyleSheet.Styles,
children?: React.Node,
size?: 'default' | 'mini',
type?: 'primary' | 'default' | 'warn',
size: 'default' | 'mini',
type: 'primary' | 'default' | 'warn',
plain?: boolean,
disabled?: boolean,
loading?: boolean,
Expand All @@ -57,7 +57,7 @@ type State = {
valve: Animated.Value
}

class _Button extends Component<Props, State> {
class _Button extends React.Component<Props, State> {
props: Props

static defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @flow
*/

import React, { Component } from 'react'
import * as React from 'react'
import {
View,
StyleSheet
Expand All @@ -18,18 +18,19 @@ type Props = {
onChange?: Function
}

class _CheckboxGroup extends Component<Props> {
class _CheckboxGroup extends React.Component<Props> {
props: Props

values: Array<{ value: any, checked: boolean }> = []
// checkboxs: React.Node = []

toggleChange = (e, index) => {
toggleChange = (e: { value: string, checked: boolean }, index: number) => {
const { onChange } = this.props
this.values[index] = {
value: e.value,
checked: e.checked
}
this.props.onChange({
onChange && onChange({
detail: {
value: this.values.filter((item) => item && item.checked).map((item) => item.value)
}
Expand Down
11 changes: 5 additions & 6 deletions packages/taro-components-rn/src/components/Checkbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @flow
*/

import React, { Component } from 'react'
import * as React from 'react'
import {
View,
TouchableWithoutFeedback,
Expand All @@ -21,22 +21,21 @@ import styles from './styles'
type Props = {
style?: StyleSheet.Styles,
onChange?: Function,
value?: string,
value: string,
disabled?: boolean,
checked?: boolean,
color?: string
// @todo
color?: string | number
}
type State = {
checked: boolean
}

class _Checkbox extends Component<Props, State> {
class _Checkbox extends React.Component<Props, State> {
props: Props

static defaultProps = {
value: '',
disabled: false,
checked: false
}

state: State = {
Expand Down
8 changes: 4 additions & 4 deletions packages/taro-components-rn/src/components/Icon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @flow
*/

import React, { Component } from 'react'
import * as React from 'react'
import {
View,
ART,
Expand All @@ -37,11 +37,11 @@ const iconTypeMap: Object = {
type Props = {
style?: StyleSheet.Styles,
type: 'success' | 'success_no_circle' | 'info' | 'warn' | 'waiting' | 'cancel' | 'download' | 'search' | 'clear',
size?: number,
color?: string | number,
size: number,
color: string | number,
}

class _Icon extends Component<Props> {
class _Icon extends React.Component<Props> {
props: Props

static defaultProps = {
Expand Down
7 changes: 4 additions & 3 deletions packages/taro-components-rn/src/components/Image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
* @flow
*/

import React, { Component } from 'react'
import * as React from 'react'
import {
Image,
StyleSheet,
} from 'react-native'
import Clickable from '../_Clickable'

Expand All @@ -30,12 +31,12 @@ const resizeModeMap: Object = {
type Props = {
style?: StyleSheet.Styles,
src?: string,
mode?: 'scaleToFill' | 'aspectFit' | 'aspectFill' | 'widthFix' | 'top' | 'bottom' | 'center' | 'left' | 'right' | 'top left' | 'top right' | 'bottom left' | 'bottom right',
mode: 'scaleToFill' | 'aspectFit' | 'aspectFill' | 'widthFix' | 'top' | 'bottom' | 'center' | 'left' | 'right' | 'top left' | 'top right' | 'bottom left' | 'bottom right',
binderror?: Function,
bindload?: Function,
}

class _Image extends Component<Props> {
class _Image extends React.Component<Props> {
props: Props

static defaultProps = {
Expand Down

This file was deleted.

This file was deleted.

17 changes: 9 additions & 8 deletions packages/taro-components-rn/src/components/Progress/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,31 @@
* @flow
*/

import React, { Component } from 'react'
import * as React from 'react'
import {
View,
Text,
Animated,
Easing,
StyleSheet,
} from 'react-native'
import styles from './styles'

type Props = {
style?: StyleSheet.Styles,
percent?: number,
percent: number,
showInfo?: boolean,
strokeWidth?: number,
activeColor?: string,
backgroundColor?: string,
strokeWidth: number,
activeColor: string,
backgroundColor: string,
active?: boolean,
activeMode?: 'backwards' | 'forwards',
activeMode: 'backwards' | 'forwards',
}
type State = {
valve: Animated.Value
}

class _Progress extends Component<Props, State> {
class _Progress extends React.Component<Props, State> {
props: Props
state: State = {
valve: new Animated.Value(0)
Expand All @@ -61,7 +62,7 @@ class _Progress extends Component<Props, State> {
activeMode: 'backwards',
}

animate = (nextPercent = 0, nowPercent = 0) => {
animate = (nextPercent: number = 0, nowPercent: number = 0) => {
const { active, activeMode } = this.props
const toValve = nextPercent / 100

Expand Down
11 changes: 0 additions & 11 deletions packages/taro-components-rn/src/components/Swiper/DataSource.js

This file was deleted.

22 changes: 11 additions & 11 deletions packages/taro-components-rn/src/components/Swiper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,31 @@
* @flow
*/

import React, { Component } from 'react'
import * as React from 'react'
import {
Text,
View,
// Text,
// View,
StyleSheet,
} from 'react-native'
import Swiper from 'react-native-swiper'
import styles from './styles'
// import styles from './styles'

type Props = {
children?: React.Node,
style?: StyleSheet.Styles,
indicatorDots?: boolean,
indicatorColor?: string,
indicatorActiveColor?: string,
indicatorColor: string | number,
indicatorActiveColor: string | number,
autoplay?: boolean,
current?: number,
interval?: number,
current: number,
interval: number,
circular?: boolean,
vertical?: boolean,
onChange?: Function,
onAnimationFinish?: Function,
}

class _Swiper extends Component<Props> {
class _Swiper extends React.Component<Props> {
props: Props

static defaultProps = {
Expand All @@ -53,15 +53,15 @@ class _Swiper extends Component<Props> {
interval: 5000,
}

onIndexChanged = (index) => {
onIndexChanged = (index: number) => {
const { onChange } = this.props
onChange && onChange({ detail: { current: index } })
}

/**
* e, state, context(ref to swiper's this)
*/
onMomentumScrollEnd = (e, state) => {
onMomentumScrollEnd = (e: any, state: { index: number }) => {
const { onAnimationFinish } = this.props
onAnimationFinish && onAnimationFinish({ detail: { current: state.index } })
}
Expand Down
Loading

0 comments on commit d275231

Please sign in to comment.