Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Mobile
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
193
Issues
193
List
Boards
Labels
Service Desk
Milestones
Merge Requests
17
Merge Requests
17
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Minds
Minds Mobile
Commits
cb9847af
Commit
cb9847af
authored
6 hours ago
by
Juan Manuel Solaro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add methods and propTypes validation
parent
448e355c
feat/selector-component
1 merge request
!394
WIP: [Sprint/PinkPanther] (feat) Selector Component
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
21 deletions
+64
-21
src/common/components/Selector.js
src/common/components/Selector.js
+64
-21
No files found.
src/common/components/Selector.js
View file @
cb9847af
import
React
,
{
Component
Component
,
}
from
'
react
'
;
import
{
View
,
StyleSheet
}
from
'
react-native
'
;
import
{
View
,
StyleSheet
,
FlatList
}
from
'
react-native
'
;
import
{
Text
,
Icon
}
from
'
react-native-elements
'
;
import
Modal
from
'
react-native-modal
'
;
import
{
CommonStyle
}
from
'
../../styles/Common
'
;
import
Touchable
from
'
./Touchable
'
;
import
PropTypes
from
'
prop-types
'
;
export
default
class
Selector
extends
Component
{
...
...
@@ -15,7 +17,10 @@ export default class Selector extends Component {
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
show
:
false
};
this
.
state
=
{
show
:
false
,
selected
:
''
,
};
}
show
=
()
=>
{
...
...
@@ -26,35 +31,73 @@ export default class Selector extends Component {
this
.
setState
({
show
:
false
});
}
renderItem
=
({
item
})
=>
{
return
(
<
Touchable
onPress
=
{()
=>
this
.
itemSelect
(
item
)}
>
<
Text
style
=
{[{
color
:
'
white
'
}]}
>
{
this
.
valueExtractor
(
item
)}
<
/Text
>
<
/Touchable
>
);
};
itemSelect
=
(
item
)
=>
{
this
.
props
.
onItemSelect
(
item
);
this
.
close
();
}
setSelected
=
(
item
)
=>
{
this
.
setState
({
selected
:
this
.
valueExtractor
(
item
)});
}
valueExtractor
=
(
item
)
=>
{
return
this
.
props
.
valueExtractor
(
item
);
}
keyExtractor
=
(
item
)
=>
{
return
this
.
props
.
keyExtractor
(
item
);
}
render
()
{
const
show
=
this
.
state
.
show
;
return
(
<
Modal
isVisible
=
{
show
}
>
<
View
style
=
{[
styles
.
container
]}
>
<
Text
style
=
{[{
color
:
'
white
'
},
CommonStyle
.
fontXL
]}
>
Selector
Title
<
/Text
>
<
View
style
=
{{
height
:
570
}}
>
<
Text
style
=
{{
color
:
'
white
'
}}
>
List
<
/Text
>
<
View
>
<
Modal
isVisible
=
{
this
.
state
.
show
}
>
<
View
style
=
{[
styles
.
container
]}
>
<
Text
style
=
{[{
color
:
'
white
'
},
CommonStyle
.
fontXL
]}
>
{
this
.
props
.
title
}
<
/Text
>
<
View
style
=
{[
CommonStyle
.
flexContainer
]}
>
<
FlatList
data
=
{
this
.
props
.
data
}
renderItem
=
{
this
.
renderItem
}
keyExtractor
=
{
this
.
props
.
keyExtractor
}
/
>
<
/View
>
<
Icon
raised
name
=
"
md-close
"
type
=
'
ionicon
'
color
=
'
black
'
size
=
{
24
}
containerStyle
=
{
styles
.
iconContainer
}
onPress
=
{
this
.
close
}
/
>
<
/View
>
<
Icon
raised
name
=
"
md-close
"
type
=
'
ionicon
'
color
=
'
black
'
size
=
{
24
}
containerStyle
=
{
styles
.
iconContainer
}
onPress
=
{
this
.
close
}
/
>
<
/View
>
<
/Modal
>
<
/Modal
>
<
/View
>
)
}
}
Selector
.
propTypes
=
{
data
:
PropTypes
.
array
.
isRequired
,
valueExtractor
:
PropTypes
.
func
.
isRequired
,
keyExtractor
:
PropTypes
.
func
.
isRequired
,
title
:
PropTypes
.
string
,
onItemSelect
:
PropTypes
.
func
.
isRequired
,
}
const
styles
=
StyleSheet
.
create
({
container
:
{
backgroundColor
:
'
transparent
'
,
width
:
200
,
height
:
6
50
,
height
:
4
50
,
alignItems
:
'
center
'
,
justifyContent
:
'
center
'
,
position
:
'
absolute
'
,
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment