-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0416976
commit 827f298
Showing
16 changed files
with
195 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from "react" | ||
import FilterScreen from "../screens/FilterScreen" | ||
import NetworkScreen from "../screens/post/NetworkScreen" | ||
import ROUTES from "./Routes" | ||
import Stack from './Stack' | ||
|
||
const FilterStack:React.FC<any> = () => { | ||
return ( | ||
<Stack.Navigator screenOptions={{ headerShown: false }}> | ||
<Stack.Screen name={ROUTES.Filter} component={FilterScreen} /> | ||
</Stack.Navigator> | ||
) | ||
} | ||
|
||
export default FilterStack |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import { Formik } from 'formik' | ||
import { Button, Input, Text } from 'galio-framework' | ||
import React, { useEffect, useState } from 'react' | ||
import { StyleSheet, TouchableOpacity, View } from 'react-native' | ||
import Icon from 'react-native-vector-icons/AntDesign' | ||
import colors from '../themes/colors' | ||
import i18n from '../assets/languages/i18n' | ||
import { Picker } from '@react-native-picker/picker'; | ||
import { RootState } from '../store' | ||
import { useSelector } from 'react-redux' | ||
import { LocationService } from '../services/locationService' | ||
import { useDispatch } from 'react-redux' | ||
import { setLocationTypes } from '../store/locations' | ||
import { LocationType } from '../types/LocationTypeModel' | ||
import { CityService } from '../services/cityService' | ||
import { City } from '../types/CityModel' | ||
import { setCities } from '../store/cities' | ||
const FilterScreen: React.FC<any> = ({ navigation }) => { | ||
const dispatch = useDispatch() | ||
const { locationTypes } = useSelector((state: RootState) => state.locations) | ||
const { cities } = useSelector((state: RootState) => state.cities) | ||
|
||
const [selectedCity, setSelectedCity] = useState<string>() | ||
const [selectedType, setSelectedType] = useState<string>() | ||
|
||
useEffect(() => { | ||
if (!locationTypes || locationTypes.length == 0) { | ||
new LocationService().getAllTypes().then(res => { | ||
const types = res.data.data as LocationType[] | ||
dispatch(setLocationTypes(types)) | ||
}) | ||
} | ||
if(!cities || cities.length == 0){ | ||
new CityService().getAll().then(res => { | ||
const _cities = res.data.data as City[] | ||
dispatch(setCities(_cities)) | ||
}) | ||
} | ||
}, []) | ||
|
||
return ( | ||
<View style={styles.root}> | ||
<View> | ||
<View style={styles.top}> | ||
<TouchableOpacity activeOpacity={0.5} style={{ width: 50 }} onPress={() => navigation.goBack()}> | ||
<Icon name="arrowleft" size={30} color="black" /> | ||
</TouchableOpacity> | ||
<Text bold h6>Filtrele</Text> | ||
<View style={{ width: 50 }} /> | ||
</View> | ||
</View> | ||
<View style={{ paddingVertical: 20 }}> | ||
<View style={styles.input}> | ||
<Input | ||
borderless | ||
placeholder={i18n.t("search")} | ||
placeholderTextColor={colors.MUTED} | ||
/> | ||
</View> | ||
<View style={styles.input}> | ||
<Text bold>Seyehat Türünü Seçiniz</Text> | ||
<Picker | ||
style={styles.select} | ||
selectedValue={selectedType} | ||
onValueChange={(itemValue, itemIndex) => | ||
setSelectedType(itemValue) | ||
}> | ||
{locationTypes.map((type, index) => ( | ||
<Picker.Item label={type.name} value={type._id} /> | ||
))} | ||
</Picker> | ||
</View> | ||
<View style={styles.input}> | ||
<Text bold>Şehir Seçiniz</Text> | ||
<Picker | ||
style={styles.select} | ||
selectedValue={selectedCity} | ||
onValueChange={(itemValue, itemIndex) => | ||
setSelectedCity(itemValue) | ||
}> | ||
{cities.map((city, index) => ( | ||
<Picker.Item label={city.cityName} value={city._id} /> | ||
))} | ||
</Picker> | ||
</View> | ||
|
||
<Button color='#2E1BA5' style={styles.button}> | ||
{i18n.t("filter") + ""} | ||
</Button> | ||
</View> | ||
</View> | ||
) | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
root: { | ||
paddingTop: 20, | ||
paddingBottom: 15, | ||
paddingHorizontal: 20, | ||
}, | ||
top: { | ||
flexDirection: "row", | ||
alignItems: "center", | ||
justifyContent: "space-between", | ||
}, | ||
select: { | ||
backgroundColor: "#fff", | ||
borderRadius: 50, | ||
}, | ||
input: { | ||
marginBottom: 20, | ||
}, | ||
button: { | ||
width: "100%", | ||
borderRadius: 10, | ||
marginTop: 20, | ||
marginBottom: 20, | ||
} | ||
}) | ||
|
||
export default FilterScreen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { AxiosResponse } from "axios"; | ||
import api from "./api"; | ||
|
||
const endpoint = "cities/" | ||
|
||
export class CityService { | ||
public async getAll(): Promise<AxiosResponse<any, any>> { | ||
return api().get(endpoint); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'; | ||
import { City } from '../types/CityModel'; | ||
|
||
const citySlice = createSlice({ | ||
name: 'cities', | ||
initialState: { | ||
cities: [] as City[], | ||
}, | ||
reducers: { | ||
setCities: (state, action: PayloadAction<City[]>) => { | ||
state.cities = action.payload; | ||
} | ||
}, | ||
}); | ||
|
||
export const {setCities} = citySlice.actions; | ||
|
||
export default citySlice.reducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters