@@ -7,41 +7,30 @@ import Ionicons from 'react-native-vector-icons/Ionicons'
7
7
import FiltersScreen from '../discover/FiltersScreen' ;
8
8
import DiscoverScreen from '../DiscoverScreen' ;
9
9
import data from '../discover/languajes.json' ;
10
- import { AppContext } from '../../App' ;
11
10
12
-
13
- export const DiscoverContext = React . createContext ( ) ;
14
11
export const navigationRef = React . createRef ( ) ;
15
12
16
13
export function navigate ( name , params ) {
17
14
navigationRef . current ?. navigate ( name , params ) ;
18
15
}
19
16
20
17
21
-
22
18
export default function DiscoverStackNavigator ( { navigation} ) {
23
19
24
- const [ native , setNative ] = useState ( data [ 0 ] ) ;
25
- const [ learning1 , setLearning1 ] = useState ( data [ 1 ] ) ;
26
- const [ learning2 , setLearning2 ] = useState ( data [ 2 ] ) ;
20
+ const [ native , setNative ] = useState ( '' ) ;
21
+ const [ learning1 , setLearning1 ] = useState ( '' ) ;
22
+ const [ learning2 , setLearning2 ] = useState ( '' ) ;
27
23
const [ minAge , setMinAge ] = useState ( 0 ) ;
28
24
const [ maxAge , setMaxAge ] = useState ( 100 ) ;
29
25
30
- const Stack = createStackNavigator ( ) ;
31
26
32
- function FiltersBtn ( ) {
33
- return (
34
- < TouchableOpacity onPress = { ( ) => navigate ( 'Discover Options' ) } >
35
- < Ionicons name = { 'settings-outline' } size = { 20 } color = { 'white' } style = { styles . configBtn } />
36
- </ TouchableOpacity >
37
- ) ;
38
- }
27
+ const Stack = createStackNavigator ( ) ;
39
28
40
- function ApplyFiltersBtn ( ) {
41
29
42
30
31
+ function ApplyFiltersBtn ( props ) {
43
32
const apply = function ( ) {
44
- navigate ( 'Discover' , { filter : true } )
33
+ navigate ( 'Discover' , { filters : getFilters ( ) } )
45
34
}
46
35
return (
47
36
< TouchableOpacity onPress = { ( ) => apply ( ) } style = { styles . applyFiltersBtn } >
@@ -52,24 +41,24 @@ export default function DiscoverStackNavigator({navigation}) {
52
41
53
42
54
43
const getFilters = function ( ) {
55
- return '?speaks=' + native . Code . toLowerCase ( ) + '&wantsToLearn=' + learning1 . Code . toLowerCase ( ) + ',' + learning2 . Code . toLowerCase ( ) ;
44
+ let nativeFilter = native ?. Code ?. toUpperCase ( ) ;
45
+ let learning1Filter = learning1 ?. Code ?. toUpperCase ( ) ;
46
+ let learning2Filter = learning2 ?. Code ?. toUpperCase ( ) ;
47
+ if ( ! nativeFilter )
48
+ nativeFilter = '' ;
49
+ if ( ! learning1Filter )
50
+ learning1Filter = '' ;
51
+ if ( ! learning2Filter )
52
+ learning2Filter = '' ;
53
+
54
+ //TODO
55
+ //AGEEEEE
56
+
57
+ return '?speaks=' + nativeFilter + '&wantsToLearn=' + learning1Filter + ',' + learning2Filter ;
56
58
}
57
59
58
60
59
61
return (
60
- < DiscoverContext . Provider value = {
61
- {
62
- native :native ,
63
- learning1, learning1,
64
- learning2 :learning2 ,
65
- minAge :minAge ,
66
- maxAge :maxAge ,
67
- filters : getFilters ( ) ,
68
- setNative :setNative ,
69
- setLearning1 :setLearning1 ,
70
- setLearning2 :setLearning2 ,
71
- setMinAge :setMinAge ,
72
- setMaxAge :setMaxAge } } >
73
62
< View style = { styles . container } >
74
63
< NavigationContainer independent initialRouteName = "Discover" ref = { navigationRef } >
75
64
< Stack . Navigator screenOptions = { {
@@ -84,23 +73,42 @@ export default function DiscoverStackNavigator({navigation}) {
84
73
fontWeight : 'bold' ,
85
74
}
86
75
} } >
87
- < Stack . Screen name = "Discover" options = { {
76
+ < Stack . Screen name = "Discover" >
77
+ { props => < DiscoverScreen { ...props } parentNavigation = { navigation }
78
+ native = { native }
79
+ setNative = { setNative }
80
+ learning1 = { learning1 }
81
+ setLearning1 = { setLearning1 }
82
+ learning2 = { learning2 }
83
+ setLearning2 = { setLearning2 }
84
+ minAge = { minAge }
85
+ maxAge = { maxAge }
86
+ setMinAge = { setMinAge }
87
+ setMaxAge = { setMaxAge }
88
+ getFilters = { getFilters } />
89
+ }
90
+ </ Stack . Screen >
91
+ < Stack . Screen name = "Discover Options" options = { {
88
92
headerRight : ( ) => (
89
- < FiltersBtn />
93
+ < ApplyFiltersBtn />
90
94
)
91
95
} } >
92
- { props => < DiscoverScreen { ...props } parentNavigation = { navigation } />
96
+ { props => < FiltersScreen { ...props }
97
+ native = { native }
98
+ setNative = { setNative }
99
+ learning1 = { learning1 }
100
+ setLearning1 = { setLearning1 }
101
+ learning2 = { learning2 }
102
+ setLearning2 = { setLearning2 }
103
+ minAge = { minAge }
104
+ maxAge = { maxAge }
105
+ setMinAge = { setMinAge }
106
+ setMaxAge = { setMaxAge } />
93
107
}
94
108
</ Stack . Screen >
95
- < Stack . Screen name = "Discover Options" component = { FiltersScreen } options = { {
96
- headerRight : ( ) => (
97
- < ApplyFiltersBtn />
98
- )
99
- } } />
100
109
</ Stack . Navigator >
101
110
</ NavigationContainer >
102
111
</ View >
103
- </ DiscoverContext . Provider >
104
112
) ;
105
113
}
106
114
0 commit comments