-
Notifications
You must be signed in to change notification settings - Fork 734
Feat/new wheel picker integration #1083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 16 commits
a3c353e
3addf5e
18361d4
d0fc5a7
416f7f0
0f64d32
cf182bc
59ea97d
3026c2b
b6ed3db
3f7f1e5
e289672
ba507b1
bc505f7
3c30f46
6d14cd7
35deda4
9f8e50f
01c95ea
25cb8b2
714571f
55528d1
b7894f3
3041c69
5dda43c
ae3eb14
3e7eb77
0303fbe
312da06
1ce4958
139b30b
d44a820
e6deee1
2cb3f07
2c3f0ef
796c3e2
0174030
03e6eb9
0a06813
0759a9d
f8dfd17
b56821c
b045a30
5052368
8832dce
1b6235f
5dca309
e0e4ac2
5cd4107
418c9f7
cce289d
c460bb2
0742539
b45f0db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,56 @@ | ||
/// <reference types="react" /> | ||
import { TextStyle } from 'react-native'; | ||
import { ItemProps } from './Item'; | ||
import {TextStyle} from 'react-native'; | ||
import {ItemProps} from './Item'; | ||
export interface WheelPickerProps { | ||
/** | ||
* Data source for WheelPicker | ||
*/ | ||
items?: ItemProps[]; | ||
/** | ||
* Describe the height of each item in the WheelPicker | ||
*/ | ||
itemHeight?: number; | ||
/** | ||
* Text color for the focused row | ||
*/ | ||
activeTextColor?: string; | ||
/** | ||
* Text color for other, non-focused rows | ||
*/ | ||
inactiveTextColor?: string; | ||
/** | ||
* Row text style | ||
*/ | ||
textStyle?: TextStyle; | ||
/** | ||
* Event, on active row change | ||
*/ | ||
onChange: (index: number, item?: ItemProps) => void; | ||
/** | ||
* Data source for WheelPicker | ||
*/ | ||
items?: ItemProps[]; | ||
/** | ||
* Describe the height of each item in the WheelPicker | ||
* default value: 44 | ||
*/ | ||
itemHeight?: number; | ||
/** | ||
* Describe the number of rows visible | ||
* default value: 5 | ||
*/ | ||
numberOfVisibleRows?: number; | ||
/** | ||
* Text color for the focused row | ||
*/ | ||
activeTextColor?: string; | ||
/** | ||
* Text color for other, non-focused rows | ||
*/ | ||
inactiveTextColor?: string; | ||
/** | ||
* Row text style | ||
*/ | ||
textStyle?: TextStyle; | ||
/** | ||
* Event, on active row change | ||
*/ | ||
onValueChange: (item: string | undefined, index: number) => void; | ||
/** | ||
* Container's ViewStyle, height is computed according to itemHeight * numberOfVisibleRows | ||
*/ | ||
style?: Omit<ViewStyle, 'height'>; | ||
/** | ||
* Support passing items as children props | ||
*/ | ||
children?: JSX.Element | JSX.Element[]; | ||
/** | ||
* WheelPicker initial value, can be ItemProps.value, number as index | ||
*/ | ||
selectedValue?: ItemProps | number; | ||
} | ||
declare const WheelPicker: ({ items, itemHeight, activeTextColor, inactiveTextColor, textStyle, onChange: onChangeEvent }: WheelPickerProps) => JSX.Element; | ||
declare const WheelPicker: ({ | ||
items, | ||
itemHeight, | ||
activeTextColor, | ||
inactiveTextColor, | ||
textStyle, | ||
onChange: onChangeEvent | ||
}: WheelPickerProps) => JSX.Element; | ||
export default WheelPicker; |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -200,10 +200,18 @@ class Dialog extends Component<DialogProps, DialogState> { | |||||
} | ||||||
}; | ||||||
|
||||||
containerType = () => { | ||||||
const {panDirection, renderPannableHeader} = this.props; | ||||||
if (!panDirection || renderPannableHeader) { | ||||||
return View; | ||||||
} | ||||||
return PanListenerView; | ||||||
} | ||||||
|
||||||
renderDialogView = () => { | ||||||
const {children, renderPannableHeader, panDirection = PanningProvider.Directions.DOWN, containerStyle, testID} = this.props; | ||||||
const {children, panDirection = PanningProvider.Directions.DOWN, containerStyle, testID} = this.props; | ||||||
const {dialogVisibility} = this.state; | ||||||
const Container = renderPannableHeader ? View : PanListenerView; | ||||||
const Container = this.containerType(); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
return ( | ||||||
<View testID={testID} style={[this.styles.dialogViewSize]} pointerEvents="box-none"> | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,10 @@ import _ from 'lodash'; | |
import React from 'react'; | ||
import {BaseComponent} from '../../commons'; | ||
import TextField from '../textField'; | ||
import {WheelPicker} from '../../nativeComponents'; | ||
import PickerDialog from './PickerDialog'; | ||
import TouchableOpacity from '../touchableOpacity'; | ||
import {Colors} from '../../style'; | ||
import {WheelPicker} from '../../nativeComponents'; | ||
|
||
class NativePicker extends BaseComponent { | ||
static displayName = 'IGNORE'; | ||
|
@@ -15,6 +15,11 @@ class NativePicker extends BaseComponent { | |
showDialog: false | ||
}; | ||
|
||
NUMBER_OF_ROWS = 5; | ||
ROW_HEIGHT = 44; | ||
MENU_HEIGHT = 44; | ||
PICKER_HEIGHT = this.NUMBER_OF_ROWS * this.ROW_HEIGHT + this.MENU_HEIGHT; | ||
|
||
extractPickerItems(props) { | ||
const {children, useNativePicker} = props; | ||
if (useNativePicker) { | ||
|
@@ -59,9 +64,11 @@ class NativePicker extends BaseComponent { | |
|
||
renderPickerDialog = () => { | ||
const {selectedValue, showDialog} = this.state; | ||
|
||
return ( | ||
<PickerDialog | ||
height={this.PICKER_HEIGHT + this.MENU_HEIGHT} | ||
pickerStyle={{width: '100%'}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure this is required.. |
||
{...this.getThemeProps()} | ||
visible={showDialog} | ||
panDirection={null} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.