From fd9edcf9446c5afec79efac27093615977121354 Mon Sep 17 00:00:00 2001 From: Oseias Muller Paulino Date: Mon, 10 Aug 2020 22:40:41 -0300 Subject: [PATCH 1/6] prop RoundCheckBox --- src/index.js | 155 ++++++++++++++++++++++++--------------------------- 1 file changed, 73 insertions(+), 82 deletions(-) diff --git a/src/index.js b/src/index.js index 52d42f1..ca901ad 100644 --- a/src/index.js +++ b/src/index.js @@ -1,16 +1,16 @@ -import React, { memo, useState, useEffect } from 'react'; +import React, { memo, useState, useEffect } from "react"; import { View, Text, Image, TouchableWithoutFeedback, ActivityIndicator, -} from 'react-native'; -import PropTypes from 'prop-types'; +} from "react-native"; +import PropTypes from "prop-types"; -import styles from './styles'; +import styles from "./styles"; -import iconDropdown from './images/icon-dropdown.png'; +import iconDropdown from "./images/icon-dropdown.png"; const AppSelect = ({ items, @@ -26,6 +26,7 @@ const AppSelect = ({ placeholderContainerStyle, placeholderStyle, textOptionStyle, + roundCheckbox, loadingStyle, iconStyle, iconDropdownComponent, @@ -38,15 +39,17 @@ const AppSelect = ({ setOptionSelected(defaultValue); }, [defaultValue]); - const objSelected = items.find((item) => ( - item[valueKey] ? item[valueKey].toString() === optionSelected.toString() : null - )); + const objSelected = items.find((item) => + item[valueKey] + ? item[valueKey].toString() === optionSelected.toString() + : null + ); const onSelectOption = (item) => () => { onChange(item[valueKey]); setOptionSelected(item[valueKey]); - if (theme === 'dropdown') { + if (theme === "dropdown") { setShowOptionsBox(false); } }; @@ -59,54 +62,55 @@ const AppSelect = ({ const IconDropdownComponent = (() => iconDropdownComponent)(); - const optionsList = loading - ? ( - - ) - : ( - items.map((item) => { - const isSelected = item[valueKey] - && (item[valueKey].toString() === optionSelected.toString()); - - return ( - - - - {isSelected && ( - - )} - - - + ) : ( + items.map((item) => { + const isSelected = + item[valueKey] && + item[valueKey].toString() === optionSelected.toString(); + + return ( + + + + {isSelected && ( + + )} + + + - {item[labelKey]} - - - - ); - }) - ); + > + {item[labelKey]} + + + + ); + }) + ); - if (theme === 'dropdown') { + if (theme === "dropdown") { comp = ( <> @@ -116,47 +120,32 @@ const AppSelect = ({ - { - iconDropdownComponent ? ( - - ) : ( - - ) - } + {iconDropdownComponent ? ( + + ) : ( + + )} - { - showOptionsBox && ( - - {optionsList} - - ) - } + {showOptionsBox && {optionsList}} ); } else { comp = optionsList; } - return ( - - {comp} - - ); + return {comp}; }; AppSelect.propTypes = { items: PropTypes.instanceOf(Array), - theme: PropTypes.oneOf(['simple', 'dropdown']), + theme: PropTypes.oneOf(["simple", "dropdown"]), valueKey: PropTypes.string, labelKey: PropTypes.string, placeholder: PropTypes.string, - defaultValue: PropTypes.oneOfType([ - PropTypes.string, - PropTypes.number, - ]), + defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), loading: PropTypes.bool, disabled: PropTypes.bool, containerStyle: PropTypes.instanceOf(Object), @@ -164,6 +153,7 @@ AppSelect.propTypes = { placeholderContainerStyle: PropTypes.instanceOf(Object), placeholderStyle: PropTypes.instanceOf(Object), textOptionStyle: PropTypes.instanceOf(Object), + roundCheckbox: PropTypes.instanceOf(Object), loadingStyle: PropTypes.instanceOf(Object), iconStyle: PropTypes.instanceOf(Object), iconDropdownComponent: PropTypes.func, @@ -172,11 +162,11 @@ AppSelect.propTypes = { AppSelect.defaultProps = { items: [], - theme: 'simple', - valueKey: 'value', - labelKey: 'label', - placeholder: '', - defaultValue: '', + theme: "simple", + valueKey: "value", + labelKey: "label", + placeholder: "", + defaultValue: "", loading: false, disabled: false, containerStyle: null, @@ -186,8 +176,9 @@ AppSelect.defaultProps = { textOptionStyle: null, loadingStyle: null, iconStyle: null, + roundCheckbox: null, iconDropdownComponent: null, - onChange: () => { }, + onChange: () => {}, }; export default memo(AppSelect); From baf0e517e87e73b5f63de2b55f32a7b92c6de6b3 Mon Sep 17 00:00:00 2001 From: Oseias Muller Paulino Date: Mon, 10 Aug 2020 22:49:38 -0300 Subject: [PATCH 2/6] RoundCheckBoxActive prop --- src/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index ca901ad..509ab04 100644 --- a/src/index.js +++ b/src/index.js @@ -27,6 +27,7 @@ const AppSelect = ({ placeholderStyle, textOptionStyle, roundCheckbox, + roundCheckboxActive, loadingStyle, iconStyle, iconDropdownComponent, @@ -81,7 +82,7 @@ const AppSelect = ({ style={[ styles.roundCheckbox, roundCheckbox, - isSelected && styles.roundCheckboxActive, + isSelected && styles.roundCheckboxActive && roundCheckboxActive, disabled && styles.roundCheckboxDisabled, ]} > @@ -154,6 +155,7 @@ AppSelect.propTypes = { placeholderStyle: PropTypes.instanceOf(Object), textOptionStyle: PropTypes.instanceOf(Object), roundCheckbox: PropTypes.instanceOf(Object), + roundCheckboxActive: propTypes.instanceOf(Object), loadingStyle: PropTypes.instanceOf(Object), iconStyle: PropTypes.instanceOf(Object), iconDropdownComponent: PropTypes.func, @@ -177,6 +179,7 @@ AppSelect.defaultProps = { loadingStyle: null, iconStyle: null, roundCheckbox: null, + roundCheckboxActive: null, iconDropdownComponent: null, onChange: () => {}, }; From b77db97068ef9a5050f5de6b0503b51c21f0d7ed Mon Sep 17 00:00:00 2001 From: Oseias Muller Paulino Date: Mon, 10 Aug 2020 22:52:53 -0300 Subject: [PATCH 3/6] Ajuste --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 509ab04..c3a5a40 100644 --- a/src/index.js +++ b/src/index.js @@ -155,7 +155,7 @@ AppSelect.propTypes = { placeholderStyle: PropTypes.instanceOf(Object), textOptionStyle: PropTypes.instanceOf(Object), roundCheckbox: PropTypes.instanceOf(Object), - roundCheckboxActive: propTypes.instanceOf(Object), + roundCheckboxActive: PropTypes.instanceOf(Object), loadingStyle: PropTypes.instanceOf(Object), iconStyle: PropTypes.instanceOf(Object), iconDropdownComponent: PropTypes.func, From eaadbe335bf7ea923a4c381159fe9d35aaff8263 Mon Sep 17 00:00:00 2001 From: Oseias Muller Paulino Date: Mon, 10 Aug 2020 23:07:08 -0300 Subject: [PATCH 4/6] roundCheckboxCore prop --- src/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index c3a5a40..0c39906 100644 --- a/src/index.js +++ b/src/index.js @@ -82,7 +82,7 @@ const AppSelect = ({ style={[ styles.roundCheckbox, roundCheckbox, - isSelected && styles.roundCheckboxActive && roundCheckboxActive, + isSelected && styles.roundCheckboxActive && roundCheckbox, disabled && styles.roundCheckboxDisabled, ]} > @@ -90,6 +90,7 @@ const AppSelect = ({ @@ -155,7 +156,7 @@ AppSelect.propTypes = { placeholderStyle: PropTypes.instanceOf(Object), textOptionStyle: PropTypes.instanceOf(Object), roundCheckbox: PropTypes.instanceOf(Object), - roundCheckboxActive: PropTypes.instanceOf(Object), + roundCheckboxCore: PropTypes.instanceOf(Object), loadingStyle: PropTypes.instanceOf(Object), iconStyle: PropTypes.instanceOf(Object), iconDropdownComponent: PropTypes.func, @@ -179,7 +180,7 @@ AppSelect.defaultProps = { loadingStyle: null, iconStyle: null, roundCheckbox: null, - roundCheckboxActive: null, + roundCheckboxCore: null, iconDropdownComponent: null, onChange: () => {}, }; From 4334a928a85b0e038463f72bfbc98b1f14ef0389 Mon Sep 17 00:00:00 2001 From: Oseias Muller Paulino Date: Mon, 10 Aug 2020 23:09:19 -0300 Subject: [PATCH 5/6] roundCheckboxCore prop --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 0c39906..ee53c3e 100644 --- a/src/index.js +++ b/src/index.js @@ -90,7 +90,7 @@ const AppSelect = ({ From 1037aa69303107f18b8ffe7de030525f9279cd1b Mon Sep 17 00:00:00 2001 From: Oseias Muller Paulino Date: Mon, 10 Aug 2020 23:11:51 -0300 Subject: [PATCH 6/6] roundCheckboxCore prop --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index ee53c3e..7814c5b 100644 --- a/src/index.js +++ b/src/index.js @@ -27,7 +27,7 @@ const AppSelect = ({ placeholderStyle, textOptionStyle, roundCheckbox, - roundCheckboxActive, + roundCheckboxCore, loadingStyle, iconStyle, iconDropdownComponent,