Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IT2810 H20
Team Ad Hoc
4-t-h
Commits
d90d4f77
Commit
d90d4f77
authored
Nov 13, 2020
by
Thor-Herman
Browse files
Create FilterList
#7
parent
2d6ef07c
Changes
1
Hide whitespace changes
Inline
Side-by-side
prosjekt-4/components/FilterList.tsx
0 → 100644
View file @
d90d4f77
import
_
from
"
lodash
"
;
import
{
List
,
ListItem
,
CheckBox
,
Body
,
Item
}
from
"
native-base
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
Text
}
from
"
react-native
"
;
import
{
useDispatch
,
useSelector
}
from
"
react-redux
"
;
import
{
changeFilters
}
from
"
../actions
"
;
import
{
RootState
}
from
"
../reducers
"
;
import
{
FilterState
,
Genres
}
from
"
../types/filter
"
;
const
genres
:
Array
<
Genres
>
=
[
"
Action
"
,
"
Comedy
"
,
"
Musical
"
,
"
Romance
"
,
"
Drama
"
,
"
Horror
"
,
];
const
FilterList
=
()
=>
{
const
checkedGenres
:
Record
<
Genres
,
boolean
>
=
useSelector
((
state
:
RootState
)
=>
state
.
filtering
.
filter
.
genres
);
const
dispatch
=
useDispatch
()
const
onPress
=
(
genre
:
Genres
)
=>
{
const
checked
=
checkedGenres
[
genre
];
dispatch
(
changeFilters
({...
checkedGenres
,
[
genre
]:
!
checked
,
to
:
""
,
from
:
""
}));
};
const
filterItems
=
genres
.
map
((
genre
)
=>
(
<
ListItem
onPress
=
{
()
=>
onPress
(
genre
)
}
key
=
{
genre
}
>
<
CheckBox
checked
=
{
checkedGenres
[
genre
]
}
/>
<
Body
>
<
Text
>
{
genre
}
</
Text
>
</
Body
>
</
ListItem
>
));
return
(
<>
<
Text
>
Genres:
</
Text
>
<
List
>
{
filterItems
}
</
List
>
</>
);
};
export
default
FilterList
;
Thor-Herman Van Eggelen
@theggele
mentioned in commit
b6223b73
·
Nov 13, 2020
mentioned in commit
b6223b73
mentioned in commit b6223b73e0413e03a52be165ce7379a58ca587c7
Toggle commit list
Write
Preview
Supports
Markdown
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