Commit 5960b01e authored by Halvor Horge's avatar Halvor Horge

#9 Added filtering to sidemenu

parent 1249ec41
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
"devToolsPort": 19002, "devToolsPort": 19002,
"expoServerPort": 19000, "expoServerPort": 19000,
"packagerPort": 19001, "packagerPort": 19001,
"packagerPid": 11656, "packagerPid": 17356,
"expoServerNgrokUrl": "https://3u-kzx.hhorge.p4.exp.direct", "expoServerNgrokUrl": "https://3u-kzx.hhorge.p4.exp.direct",
"packagerNgrokUrl": "https://packager.3u-kzx.hhorge.p4.exp.direct", "packagerNgrokUrl": "https://packager.3u-kzx.hhorge.p4.exp.direct",
"ngrokPid": 19796 "ngrokPid": 15624
} }
import React from 'react'; import React from "react";
import { View } from 'react-native'; import { View } from "react-native";
import RadioForm, {RadioButton, RadioButtonInput, RadioButtonLabel} from 'react-native-simple-radio-button'; import RadioForm, {
RadioButton,
RadioButtonInput,
RadioButtonLabel
} from "react-native-simple-radio-button";
import { useDispatch } from "react-redux"; import { useDispatch } from "react-redux";
import { filter } from "../actions"; import { filter } from "../actions";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import { toggleSideMenu } from "../actions"; import { toggleSideMenu } from "../actions";
const genres = [ const genres = [
{label: "All", value: ""}, { label: "All", value: "" },
{label: "Akevitt", value: "Akevitt"}, { label: "Akevitt", value: "Akevitt" },
{label: "Bitter", value: "Bitter"}, { label: "Bitter", value: "Bitter" },
{label: "Druebrennevin", value: "Druebrennevin"}, { label: "Druebrennevin", value: "Druebrennevin" },
{label: "Gin", value: "Gin"}, { label: "Gin", value: "Gin" },
{label: "Hvitvin", value: "Hvitvin"}, { label: "Hvitvin", value: "Hvitvin" },
{label: "Likør", value: "Likør"}, { label: "Likør", value: "Likør" },
{label: "Portvin", value: "Portvin"}, { label: "Portvin", value: "Portvin" },
{label: "Rødvin", value: "Rødvin"}, { label: "Rødvin", value: "Rødvin" },
{label: "Vodka", value: "Vodka"}, { label: "Vodka", value: "Vodka" },
{label: "Whisky", value: "Whisky"}, { label: "Whisky", value: "Whisky" }
] ];
const Filtering = () => { const Filtering = () => {
const stateType = useSelector(state => state.filter);
const dispatch = useDispatch();
const stateType = useSelector(state => state.filter); function updateFilter(e) {
const dispatch = useDispatch(); dispatch(filter(e));
}
function updateFilter(e) {
dispatch(filter(e));
}
function onButtonPress(v){ function onButtonPress(v) {
updateFilter(v) updateFilter(v);
dispatch(toggleSideMenu()) dispatch(toggleSideMenu());
} }
return( return (
<View> <View>
<RadioForm <RadioForm radio_props={genres} onPress={value => onButtonPress(value)} />
radio_props={genres} </View>
onPress={(value) => onButtonPress(value)} );
/> };
</View>
)
}
export default Filtering; export default Filtering;
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment