Skip to content

Commit

Permalink
PickerComponent add itemStyle and indicatorStyle (#12335)
Browse files Browse the repository at this point in the history
* PickerComponent add itemStyle and indicatorStyle

* Update Picker.d.ts
  • Loading branch information
Aliom252181 authored Aug 22, 2022
1 parent feee482 commit 536b0ce
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,16 @@ export default class MultiSelector extends React.Component<MultiSelectorProps, M
}

render(): JSX.Element {
const { children, disabled } = this.props
const { children, disabled, itemStyle, indicatorStyle } = this.props
const { cols, range, value } = this.state

return (
<AntPicker
data={range}
value={value}
cols={cols}
itemStyle={itemStyle}
indicatorStyle={indicatorStyle}
onChange={this.onChange}
onPickerChange={this.onPickerChange}
onOk={this.onOk}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export default class Selector extends React.Component<SelectorProps, SelectorSta
const {
children,
disabled,
itemStyle,
indicatorStyle,
} = this.props
const {
range,
Expand All @@ -97,6 +99,8 @@ export default class Selector extends React.Component<SelectorProps, SelectorSta
data={range}
value={[selected && selected.value]}
cols={1}
itemStyle={itemStyle}
indicatorStyle={indicatorStyle}
onChange={this.onChange}
onPickerChange={this.onPickerChange}
onOk={this.onOk}
Expand Down
25 changes: 25 additions & 0 deletions packages/taro-components/types/Picker.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ComponentType } from 'react'
import { StyleProp, TextStyle, ViewStyle } from 'react-native'
import { StandardProps, CommonEventFunction, FormItemProps } from './common'

/** 选择器通用参数 */
Expand Down Expand Up @@ -59,6 +60,18 @@ interface PickerSelectorProps extends PickerStandardProps {
* @default 0
*/
value?: number
/**
* mode为 selector 或 multiSelector 时 itemStyle 有效
* @supported rn
* @default {}
*/
itemStyle?: StyleProp<TextStyle>
/**
* mode为 selector 或 multiSelector 时 indicatorStyle 有效
* @supported rn
* @default {}
*/
indicatorStyle?: StyleProp<ViewStyle>
/**
* value 改变时触发 change 事件,event.detail = {value}
* @supported weapp, h5, rn
Expand Down Expand Up @@ -94,6 +107,18 @@ interface PickerMultiSelectorProps extends PickerStandardProps {
* @default []
*/
value: number[] | string[] | Record<string, any>[]
/**
* mode为 selector 或 multiSelector 时 itemStyle 有效
* @supported rn
* @default {}
*/
itemStyle?: StyleProp<TextStyle>
/**
* mode为 selector 或 multiSelector 时 indicatorStyle 有效
* @supported rn
* @default {}
*/
indicatorStyle?: StyleProp<ViewStyle>
/**
* 当 value 改变时触发 change 事件,event.detail = {value}
* @supported weapp, h5, rn
Expand Down

0 comments on commit 536b0ce

Please sign in to comment.