-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
218 lines (187 loc) · 5.93 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/**
* React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
Text,
View,
} from 'react-native';
import { createSwitchNavigator, createDrawerNavigator, createStackNavigator, createMaterialTopTabNavigator, createTabNavigator, DrawerNavigator, DrawerItems } from 'react-navigation';
import { Icon, Avatar } from 'react-native-elements'
import styles from './styles/styles'
import MixScreen from './screens/MixScreen';
import ArchiveScreen from './screens/ArchiveScreen';
import FavoritesScreen from './screens/FavoritesScreen';
import AuthLoadingScreen from './screens/AuthLoadingScreen';
import Playbar from './components/Playbar'
import MixPreview from './components/MixPreview'
import {Provider, connect} from 'react-redux'
import store from './store/index'
import {isTablet} from "./helper/dimentions"
import { YellowBox } from 'react-native';
YellowBox.ignoreWarnings(['Class RCTCxxModule']);
export const ArchiveStack = createMaterialTopTabNavigator({
Mix: {
screen: MixScreen,
navigationOptions: ({navigation}) => ({
headerStyle: {
backgroundColor: '#db892a',
},
headerTintColor : '#393939',
headerBackTitle: 'Back',
headerRight: archiveButton(navigation),
tabBarOnPress: ({ navigation, defaultHandler }) => {
if (navigation.isFocused()) {
navigation.state.params.moveToLatestMix();
} else {
defaultHandler();
}
},
}),
},
Archive: {
screen: ArchiveScreen,
navigationOptions: ({navigation}) => ({
headerStyle: {backgroundColor: '#db892a', color: '#fff'},
headerTintColor: 'white', // arrow color
headerBackTitleStyle: {color: '#fff'},
gesturesEnabled: false,
headerTitle: 'Archive',
headerBackTitle: 'Back',
tabBarOnPress: ({ navigation, defaultHandler }) => {
if (navigation.isFocused()) {
navigation.state.params.scrollToTop();
} else {
defaultHandler();
}
},
}),
},
Favorites: {
screen: FavoritesScreen,
navigationOptions: ({navigation}) => ({
headerStyle: {backgroundColor: '#db892a'},
headerTintColor: 'white', // arrow color
headerBackTitleStyle: {color: '#fff'},
gesturesEnabled: false,
headerTitle: 'Favorites',
tabBarOnPress: ({ navigation, defaultHandler }) => {
if (navigation.isFocused()) {
navigation.state.params.scrollToTop();
} else {
defaultHandler();
}
},
}),
},
}, {
navigationOptions: ({ navigation }) => ({
mode: 'modal',
tabBarOptions : {
labelStyle: {
height: 32,
paddingTop: isTablet() > 768 ? 10 : 0,
marginTop: 0,
fontSize: isTablet() ? 18 : 14
},
allowFontScaling: false,
indicatorStyle: {
backgroundColor: '#fbef00',
},
style: {
height: isTablet() > 768 ? 60 : 42,
paddingTop:4,
backgroundColor: '#3c3c3c'
}
}
})
});
const headerIcon = (navigation) =>
<View style={{width: '100%'}}>
<Avatar
small
rounded
source={require('./images/DC-logo-header.png')}
activeOpacity={1.0}
overlayContainerStyle={{backgroundColor: '#db892a'}}
containerStyle={{backgroundColor: '#db892a',marginTop:2, alignSelf: 'center'}}
/>
</View>
const archiveButton = (navigation) =>
<Text
style={{padding: 5, color: '#fff', fontSize: 18, marginRight: 10}}
onPress={() => {
navigation.navigate('Archive');
}
}>Archive</Text>
const RootNavigator = createStackNavigator({
Main: {
//screen: Drawer,
screen: ArchiveStack,
navigationOptions: {
gesturesEnabled: false,
}
},
},
{
navigationOptions: ({navigation}) => ({
gesturesEnabled: false,
headerTitle: headerIcon(navigation),
headerStyle: {
height: 44,
color: '#3c3c3c',
backgroundColor: '#db892a',
borderBottomColor: '#db892a',
borderBottomWidth: 0
},
}),
headerMode: 'float',
mode: "modal"
});
const mapStateToProps = (state) => {
return {
isPlaying: state.isPlaying.playing,
mixPlaying: state.mixPlaying.mix.mix,
mixPreview: state.mixPreview.mix.mix,
modal: state.mixModal,
favorites: state.userFavorites.favorites,
mixes: state.mixes.mixes,
loading: state.mixes.loading,
error: state.mixes.error
}
};
Root = connect(mapStateToProps, {})(RootNavigator);
FooterPlayer = connect(mapStateToProps)(Playbar);
class AppReady extends Component {
static router = RootNavigator.router;
render() {
return (
<View style={{flex:1}}>
<RootNavigator navigation={this.props.navigation} />
<MixPreview />
<FooterPlayer/>
</View>
);
}
}
const MixLoaderNavigator = createSwitchNavigator(
{
AuthLoading: AuthLoadingScreen,
AppReady: AppReady,
},
{
initialRouteName: 'AuthLoading',
}
);
MixLoader = connect(mapStateToProps, {})(MixLoaderNavigator);
export default class App extends Component {
render() {
return (
<Provider store={store}>
<MixLoader />
</Provider>
);
}
}