From 2f1b3f16b6fce4b5c3949c00ff44ecb0e3f32ac4 Mon Sep 17 00:00:00 2001 From: "adnan.naeem@blueeast.com" Date: Mon, 5 Aug 2019 12:19:56 +0500 Subject: [PATCH 01/23] fix(fixed issues of picker): fixed picker --- package.json | 1 + src/components/Picker/Picker.tsx | 154 + src/components/Picker/index.tsx | 1 + src/components/Picker/picker.stories.tsx | 24 + src/components/index.ts | 1 + src/{index.ts => index.tsx} | 9 + tsconfig.json | 22 +- yarn.lock | 4247 ++++++++++++++++------ 8 files changed, 3292 insertions(+), 1167 deletions(-) create mode 100644 src/components/Picker/Picker.tsx create mode 100644 src/components/Picker/index.tsx create mode 100644 src/components/Picker/picker.stories.tsx rename src/{index.ts => index.tsx} (87%) diff --git a/package.json b/package.json index 10a12942..0dba5544 100644 --- a/package.json +++ b/package.json @@ -121,6 +121,7 @@ "codacy-coverage": "^3.4.0", "codecov": "^3.2.0", "commitizen": "^3.0.7", + "core-js": "^3.1.4", "cz-conventional-changelog": "^2.1.0", "enzyme": "^3.9.0", "enzyme-adapter-react-16": "^1.10.0", diff --git a/src/components/Picker/Picker.tsx b/src/components/Picker/Picker.tsx new file mode 100644 index 00000000..b7915f72 --- /dev/null +++ b/src/components/Picker/Picker.tsx @@ -0,0 +1,154 @@ +import { Text,Button, Modal, Picker, StyleSheet, TouchableOpacity, View } from 'react-native'; +import React, { Component } from 'react'; + +import PropTypes from 'prop-types'; + +const propTypes = { + mode: PropTypes.string, + selectedValue: PropTypes.string, + selectedValueIndex: PropTypes.string, + onValueChange: PropTypes.func, + data: PropTypes.array, + style: PropTypes.object, + textStyle: PropTypes.object, + pickerItemStyle: PropTypes.object, + collapseViewStyle: PropTypes.object, +} + +// const defaultProps = { +// data: any, +// mode: 'collapse', + +// }; + +export interface IOSPickerProps { + data: [], + // selectedValueIndex?: number, + selectedValue?: any, + style?: object, + textStyle?: object + onValueChange?: any +} + +export interface IOSPickerState { + data?: [], + selectedValueIndex?: number + textStyle?: string + modalVisible?: boolean + selectedValue: any + selected?: number + +} +class PickerComponent extends Component { + constructor(props: any) { + super(props); + // let selected = 0; + // if (this.props.data !== null) { + // selected = this.props.data[this.props.selectedValueIndex || 0]; + // } else { + // selected = this.props.selectedValue; + // } + this.state = { + modalVisible: false, + selectedValue: 'SanPyaeLin', + selected: 0, + }; + } + + componentWillReceiveProps(nextProps: IOSPickerProps) { + if (this.props.data == null && nextProps.selectedValue!= this.state.selectedValue) { + this.setState({ + selectedValue: nextProps.selectedValue, + }); + } + } + + pressItem = () => { + this.setState({ modalVisible: true }); + } + + valueChange = (data: any, index: any) => { + this.setState({ modalVisible: false, selectedValue: data, selected: data }); + this.props.onValueChange(data, index); + } + + + + renderModalPicker() { + // const { style, textStyle } = this.props; + return ( + + + {/* + {this.state.selectedValue} + */} + + + ) + } + handler = () => { + // const { style, textStyle } = this.props; + this.setState({ modalVisible: true }); + } + + render = () => { + const { children, data } = this.props; + return ( + <> +