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
f33ba25f
Commit
f33ba25f
authored
1 hour ago
by
Juan Manuel Solaro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(feat) add selected state
parent
cb9847af
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
28 additions
and
13 deletions
+28
-13
src/common/components/Selector.js
src/common/components/Selector.js
+28
-13
No files found.
src/common/components/Selector.js
View file @
f33ba25f
...
...
@@ -23,8 +23,8 @@ export default class Selector extends Component {
};
}
show
=
()
=>
{
this
.
setState
({
show
:
true
});
show
=
(
item
)
=>
{
this
.
setState
({
show
:
true
,
selected
:
item
});
}
close
=
()
=>
{
...
...
@@ -32,9 +32,10 @@ export default class Selector extends Component {
}
renderItem
=
({
item
})
=>
{
const
fontColor
=
this
.
isSelected
(
item
)
?
styles
.
selectedColorFont
:
styles
.
fontColor
;
return
(
<
Touchable
onPress
=
{()
=>
this
.
itemSelect
(
item
)}
>
<
Text
style
=
{
[{
color
:
'
white
'
}]
}
>
{
this
.
valueExtractor
(
item
)}
<
/Text
>
<
Touchable
onPress
=
{()
=>
this
.
itemSelect
(
item
)}
style
=
{
CommonStyle
.
margin2x
}
>
<
Text
style
=
{
fontColor
}
>
{
this
.
valueExtractor
(
item
)}
<
/Text
>
<
/Touchable
>
);
};
...
...
@@ -44,8 +45,12 @@ export default class Selector extends Component {
this
.
close
();
}
isSelected
=
(
item
)
=>
{
return
this
.
state
.
selected
===
this
.
keyExtractor
(
item
);
}
setSelected
=
(
item
)
=>
{
this
.
setState
({
selected
:
this
.
value
Extractor
(
item
)});
this
.
setState
({
selected
:
this
.
key
Extractor
(
item
)});
}
valueExtractor
=
(
item
)
=>
{
...
...
@@ -61,15 +66,16 @@ export default class Selector extends Component {
<
View
>
<
Modal
isVisible
=
{
this
.
state
.
show
}
>
<
View
style
=
{[
styles
.
container
]}
>
<
Text
style
=
{[
{
color
:
'
white
'
},
CommonStyle
.
fontXL
]}
>
{
this
.
props
.
title
}
<
/Text
>
<
View
style
=
{[
CommonStyle
.
flexContainer
]}
>
<
Text
style
=
{[
styles
.
fontColor
,
CommonStyle
.
fontXL
,
styles
.
marginBottom
]}
>
{
this
.
props
.
title
}
<
/Text
>
<
View
style
=
{[
CommonStyle
.
flexContainer
,
CommonStyle
.
marginTop3x
,
CommonStyle
.
paddingLeft2x
,
styles
.
marginBottom
]}
>
<
FlatList
data
=
{
this
.
props
.
data
}
renderItem
=
{
this
.
renderItem
}
keyExtractor
=
{
this
.
props
.
keyExtractor
}
extraData
=
{
this
.
state
.
selected
}
/
>
<
/View
>
<
Icon
<
Icon
raised
name
=
"
md-close
"
type
=
'
ionicon
'
...
...
@@ -89,7 +95,7 @@ Selector.propTypes = {
data
:
PropTypes
.
array
.
isRequired
,
valueExtractor
:
PropTypes
.
func
.
isRequired
,
keyExtractor
:
PropTypes
.
func
.
isRequired
,
title
:
PropTypes
.
string
,
title
:
PropTypes
.
string
.
isRequired
,
onItemSelect
:
PropTypes
.
func
.
isRequired
,
}
...
...
@@ -105,9 +111,18 @@ const styles = StyleSheet.create({
right
:
70
,
},
iconContainer
:
{
backgroundColor
:
'
white
'
,
width
:
55
,
height
:
55
,
zIndex
:
1000
,
backgroundColor
:
'
#fff
'
,
width
:
55
,
height
:
55
,
zIndex
:
1000
,
},
fontColor
:
{
color
:
'
#fff
'
},
selectedColorFont
:
{
color
:
'
blue
'
},
marginBottom
:
{
marginBottom
:
30
}
});
\ No newline at end of file
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