-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathApp.js
102 lines (90 loc) · 3.07 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
import React, {useState, useEffect} from 'react';
import SectionListDemo from './components/SettingsPage';
import FlatListDemo from './components/HomePage';
import WebViewDemo from './components/WebViewDemo';
import {NavigationContainer} from '@react-navigation/native';
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
import {createStackNavigator} from '@react-navigation/stack';
import {StyleSheet} from 'react-native';
import Ionicons from 'react-native-vector-icons/Ionicons';
import codePush from 'react-native-code-push';
import {getData, storeData} from './utils/DataStorage';
import RSSSource from './data/RSSSource.json';
const Tab = createBottomTabNavigator();
const App = () => {
// Apple Developer RSS: https://developer.apple.com/news/rss/news.rss
// App Center Dev Blog RSS: https://devblogs.microsoft.com/appcenter/feed/
// Xamarin Dev Blog RSS: https://devblogs.microsoft.com/xamarin/feed/
const [source, setSource] = useState({
title: RSSSource.title,
data: RSSSource.data,
});
useEffect(() => {
getData('@rss_source').then((value) => {
setSource({
title: value.title,
data: value.data,
});
console.log(value);
});
}, []);
const FlatListDemoStack = () => {
const FLStack = createStackNavigator();
return (
<FLStack.Navigator style={styles.navigator} initialRouteName="Home">
<FLStack.Screen name="Home">
{(props) => <FlatListDemo {...props} source={source} />}
</FLStack.Screen>
<FLStack.Screen name="Details" component={WebViewDemo} />
</FLStack.Navigator>
);
};
const SectionListDemoStack = () => {
const SLStack = createStackNavigator();
return (
<SLStack.Navigator style={styles.navigator}>
<SLStack.Screen name="Settings">
{(props) => (
<SectionListDemo
{...props}
source={source}
/>
)}
</SLStack.Screen>
</SLStack.Navigator>
);
};
return (
<NavigationContainer>
<Tab.Navigator
screenOptions={({route}) => ({
tabBarIcon: ({focused, color, size}) => {
let iconName;
if (route.name === 'Home') {
iconName = focused ? 'home' : 'home-outline';
} else if (route.name === 'Settings') {
iconName = focused ? 'settings' : 'settings-outline';
}
// You can return any component that you like here!
return <Ionicons name={iconName} size={size} color={color} />;
},
})}
tabBarOptions={{
activeTintColor: 'tomato',
inactiveTintColor: 'gray',
}}>
<Tab.Screen name="Home" component={FlatListDemoStack} />
<Tab.Screen name="Settings" component={SectionListDemoStack} />
</Tab.Navigator>
</NavigationContainer>
);
};
const styles = StyleSheet.create({
navigator: {
// flex: 1,
// marginTop: StatusBar.currentHeight || 0,
// paddingTop: StatusBar.currentHeight || 0,
backgroundColor: '#faedcd',
},
});
export default codePush(App);