├── .babelrc ├── .flowconfig ├── .gitignore ├── .idea ├── dictionaries │ └── panyz.xml ├── inspectionProfiles │ └── Project_Default.xml └── vcs.xml ├── .watchmanconfig ├── App.js ├── App.test.js ├── LICENSE ├── README.md ├── app.json ├── package.json └── src ├── common ├── GankTabNav.js └── TabNavigator.js ├── components ├── GankListItemComponent.js ├── HomeSectionListItem.js └── InputComponent.js ├── images ├── avatar.jpg ├── blog.png ├── four_normal.png ├── four_selected.png ├── github.png ├── home_normal.png ├── home_selected.png ├── logo.png ├── three_normal.png ├── three_selected.png ├── two_normal.png └── two_selected.png └── pages ├── AndroidTabPage.js ├── BlogPage.js ├── FrontEndTabPage.js ├── GankPage.js ├── LoginPage.js ├── MainPage.js ├── PersonalInfoPage.js ├── ThirdScreen.js ├── WebPage.js └── iOSTabPage.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["babel-preset-expo"], 3 | "env": { 4 | "development": { 5 | "plugins": ["transform-react-jsx-source"] 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore unexpected extra "@providesModule" 9 | .*/node_modules/.*/node_modules/fbjs/.* 10 | 11 | ; Ignore duplicate module providers 12 | ; For RN Apps installed via npm, "Libraries" folder is inside 13 | ; "node_modules/react-native" but in the source repo it is in the root 14 | .*/Libraries/react-native/React.js 15 | .*/Libraries/react-native/ReactNative.js 16 | 17 | ; Additional create-react-native-app ignores 18 | 19 | ; Ignore duplicate module providers 20 | .*/node_modules/fbemitter/lib/* 21 | 22 | ; Ignore misbehaving dev-dependencies 23 | .*/node_modules/xdl/build/* 24 | .*/node_modules/reqwest/tests/* 25 | 26 | ; Ignore missing expo-sdk dependencies (temporarily) 27 | ; https://github.com/exponent/exponent-sdk/issues/36 28 | .*/node_modules/expo/src/* 29 | 30 | ; Ignore react-native-fbads dependency of the expo sdk 31 | .*/node_modules/react-native-fbads/* 32 | 33 | [include] 34 | 35 | [libs] 36 | node_modules/react-native/Libraries/react-native/react-native-interface.js 37 | node_modules/react-native/flow 38 | flow/ 39 | 40 | [options] 41 | module.system=haste 42 | 43 | emoji=true 44 | 45 | experimental.strict_type_args=true 46 | 47 | munge_underscores=true 48 | 49 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' 50 | 51 | suppress_type=$FlowIssue 52 | suppress_type=$FlowFixMe 53 | suppress_type=$FixMe 54 | 55 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-2]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 56 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-2]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ 57 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy 58 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError 59 | 60 | unsafe.enable_getters_and_setters=true 61 | 62 | [version] 63 | ^0.42.0 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .expo/ 3 | npm-debug.* 4 | -------------------------------------------------------------------------------- /.idea/dictionaries/panyz.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | gank 5 | github 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import LoginPage from './src/pages/LoginPage'; 3 | 4 | export default class App extends React.Component { 5 | render() { 6 | return ( 7 | 8 | ); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import App from './App'; 3 | 4 | import renderer from 'react-test-renderer'; 5 | 6 | it('renders without crashing', () => { 7 | const rendered = renderer.create().toJSON(); 8 | expect(rendered).toBeTruthy(); 9 | }); 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 panyz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GankAndPanyz 2 | > 这是一个完全由React Native开发的App,里面的数据内容来自gank.io(干货集中营)和记录在自己GitHub上的一些博客笔记。(目前尚未适配iOS端) 3 | 4 | 使用创建应用的脚手架工具为**create-react-native-app**,具体的使用教程可以参考这篇教程[《React Native高效开发》之create-react-native-app](https://juejin.im/post/58d8ef5f44d9040069444989) 5 | 6 | 数据来源:干货集中营提供的API(在这里表示万分感谢!)和我在GitHub Issues上记录的博客笔记等。 7 | 8 | 第三方库:导航栏React-Navigation,我也做了一些总结在这篇笔记博客上[关于React Navigation的一些使用技巧](https://github.com/panyz/Blogs/issues/15) 9 | 10 | 总结:我是搞Android开发,就想接触了解下React Native这项新技术,所以就直接写了一个app来练练手,当然在开发的过程中还是踩过一些坑,不过大多都能Google下就能就能解决。这个app写起代码来算比较简单,而且大多数都是用了官方提供的组件去做的,所以用这个项目作为React Native入门感觉还是挺OK的了。不过最好还是要熟悉Javascript的语法用法再来入门React Native,要不然在开发过程中效率会很慢的。 11 | 12 | 最后来看看app的整体截图: 13 | 14 | ![登录界面](http://upload-images.jianshu.io/upload_images/2355123-3c888af06e5bb278.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 15 | 16 | ![首页1](http://upload-images.jianshu.io/upload_images/2355123-7b9b8c5d35674010.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 17 | 18 | ![首页1](http://upload-images.jianshu.io/upload_images/2355123-c44638b160aec5dc.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 19 | 20 | ![干货分类](http://upload-images.jianshu.io/upload_images/2355123-6a7865f4d0bddb56.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 21 | 22 | ![我的博客](http://upload-images.jianshu.io/upload_images/2355123-23475f50bf2f68e2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 23 | 24 | ![项目介绍](http://upload-images.jianshu.io/upload_images/2355123-b3c713b117d653be.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 25 | 26 | ![详细页面](http://upload-images.jianshu.io/upload_images/2355123-bc5e9e35b6dfacf2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 27 | 28 | ![iOS Android](http://upload-images.jianshu.io/upload_images/2355123-dce5a165c532f3bb.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 29 | 30 | 31 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "expo": { 3 | "sdkVersion": "17.0.0" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "GankAndPanyz", 3 | "version": "0.1.0", 4 | "private": true, 5 | "devDependencies": { 6 | "react-native-scripts": "0.0.30", 7 | "jest-expo": "~1.0.1", 8 | "react-test-renderer": "16.0.0-alpha.6" 9 | }, 10 | "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js", 11 | "scripts": { 12 | "start": "react-native-scripts start", 13 | "eject": "react-native-scripts eject", 14 | "android": "react-native-scripts android", 15 | "ios": "react-native-scripts ios", 16 | "test": "node node_modules/jest/bin/jest.js --watch" 17 | }, 18 | "jest": { 19 | "preset": "jest-expo" 20 | }, 21 | "dependencies": { 22 | "expo": "^17.0.0", 23 | "react": "16.0.0-alpha.6", 24 | "react-native": "^0.44.0", 25 | "react-navigation": "^1.0.0-beta.11" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/common/GankTabNav.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {TabNavigator} from 'react-navigation'; 3 | 4 | import AndroidTabPage from '../pages/AndroidTabPage'; 5 | import iOSTabPage from '../pages/iOSTabPage'; 6 | import FrontEndTabPage from '../pages/FrontEndTabPage'; 7 | 8 | const GankTab = TabNavigator({ 9 | Android: {screen:AndroidTabPage,navigationOptions:{ 10 | tabBarLabel:'Android' 11 | }}, 12 | iOS:{screen:iOSTabPage, navigationOptions:{ 13 | tabBarLabel:'iOS' 14 | }}, 15 | frontEnd:{screen:FrontEndTabPage,navigationOptions:{ 16 | tabBarLabel:'前端' 17 | }} 18 | }); 19 | 20 | GankTab.navigationOptions = { 21 | headerTitle:'干货' 22 | }; 23 | 24 | export default GankTab; -------------------------------------------------------------------------------- /src/common/TabNavigator.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {StyleSheet, Image} from 'react-native'; 3 | import {TabNavigator} from 'react-navigation'; 4 | 5 | import HomePage from '../pages/MainPage' 6 | import MessagePage from '../pages/GankPage'; 7 | import BlogPage from '../pages/BlogPage'; 8 | import PersonalInfoPage from '../pages/PersonalInfoPage'; 9 | import GankPage from './GankTabNav'; 10 | 11 | const Navigator = TabNavigator({ 12 | One: { 13 | screen: HomePage, navigationOptions: { 14 | tabBarIcon: (({focused}) => focused ? 15 | : 16 | 17 | ), 18 | } 19 | }, 20 | Two: { 21 | screen: GankPage, navigationOptions: { 22 | tabBarIcon: (({focused}) => focused ? 23 | : 24 | 25 | ), 26 | } 27 | }, 28 | Three: { 29 | screen: BlogPage, navigationOptions: { 30 | tabBarIcon: (({focused}) => focused ? 31 | : 32 | 33 | ), 34 | } 35 | }, 36 | Four: { 37 | screen: PersonalInfoPage, navigationOptions: { 38 | tabBarIcon: (({focused}) => focused ? 39 | : 40 | 41 | ), 42 | } 43 | } 44 | }, { 45 | tabBarPosition: 'bottom', 46 | swipeEnabled: false, 47 | animationEnabled: false, 48 | backBehavior: 'none', 49 | tabBarOptions: { 50 | indicatorStyle: {height: 0}, 51 | showIcon: true, 52 | showLabel: false, 53 | style: {backgroundColor: 'white'} 54 | } 55 | }); 56 | 57 | const styles = StyleSheet.create({ 58 | pageIcon: { 59 | height: 24, 60 | width: 24, 61 | resizeMode: 'contain' 62 | } 63 | }); 64 | 65 | export default Navigator -------------------------------------------------------------------------------- /src/components/GankListItemComponent.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | import {StyleSheet, View, Text, Image, Dimensions} from 'react-native'; 3 | 4 | const windowSize = Dimensions.get('window'); 5 | 6 | export default class GankListItemComponent extends Component { 7 | 8 | setNativeProps(nativeProps) { 9 | this._root.setNativeProps(nativeProps); 10 | } 11 | 12 | render() { 13 | return ( 14 | 15 | this._root = component}/> 16 | 17 | {this.props.author} 18 | 19 | {this.props.title} 20 | 21 | 22 | 23 | ) 24 | } 25 | } 26 | 27 | const styles = StyleSheet.create({ 28 | container: { 29 | display: 'flex', 30 | marginVertical: 5, 31 | height: 2 / 9 * windowSize.height, 32 | flexDirection: 'row', 33 | backgroundColor: '#fff' 34 | }, 35 | imageStyle: { 36 | width: 1 / 3 * windowSize.width, 37 | height: 2 / 9 * windowSize.height 38 | }, 39 | textStyle:{ 40 | marginVertical:10, 41 | marginHorizontal:10, 42 | color:"#9c9c9c" 43 | } 44 | }); -------------------------------------------------------------------------------- /src/components/HomeSectionListItem.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | import {StyleSheet, View, Image, Text, Dimensions, } from 'react-native'; 3 | 4 | const windowSize = Dimensions.get('window'); 5 | 6 | export default class HomeSectionListItem extends Component { 7 | 8 | setNativeProps(nativeProps) { 9 | this._root.setNativeProps(nativeProps); 10 | } 11 | 12 | render() { 13 | return ( 14 | 15 | this._root = component}/> 16 | {this.props.author} 17 | {this.props.title} 18 | 19 | ); 20 | } 21 | } 22 | 23 | const styles = StyleSheet.create({ 24 | container: { 25 | backgroundColor: 'white', 26 | height: 1 / 3 * windowSize.height, 27 | marginHorizontal: 15, 28 | marginVertical: 5, 29 | borderRadius: 10, 30 | }, 31 | imageStyle: { 32 | borderTopRightRadius: 10, 33 | borderTopLeftRadius: 10, 34 | height: 2 / 9 * windowSize.height 35 | }, 36 | textStyle: { 37 | marginLeft: 10, 38 | color: '#51c4fe', 39 | } 40 | }); -------------------------------------------------------------------------------- /src/components/InputComponent.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {StyleSheet, TextInput, View, } from 'react-native' 3 | 4 | export default class InputComponent extends React.Component { 5 | static defaultProps = { 6 | isPwd: false, 7 | text: '', 8 | }; 9 | 10 | render() { 11 | return ( 12 | 13 | 15 | 16 | ); 17 | } 18 | } 19 | 20 | const styles = StyleSheet.create({ 21 | container: { 22 | marginTop: 20, 23 | display: 'flex', 24 | flexDirection: 'row', 25 | }, 26 | input: { 27 | width: 250, 28 | height: 35, 29 | paddingLeft: 10, 30 | backgroundColor: '#EDEDED', 31 | borderWidth: 0, 32 | borderRadius: 5, 33 | borderStyle: "solid", 34 | }, 35 | text: { 36 | textAlign: 'center', 37 | alignSelf: 'center' 38 | 39 | } 40 | }); -------------------------------------------------------------------------------- /src/images/avatar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/panyz/GankAndPanyz/ddef7ea5db39e7ffc811ef134eaf572150cc977e/src/images/avatar.jpg -------------------------------------------------------------------------------- /src/images/blog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/panyz/GankAndPanyz/ddef7ea5db39e7ffc811ef134eaf572150cc977e/src/images/blog.png -------------------------------------------------------------------------------- /src/images/four_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/panyz/GankAndPanyz/ddef7ea5db39e7ffc811ef134eaf572150cc977e/src/images/four_normal.png -------------------------------------------------------------------------------- /src/images/four_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/panyz/GankAndPanyz/ddef7ea5db39e7ffc811ef134eaf572150cc977e/src/images/four_selected.png -------------------------------------------------------------------------------- /src/images/github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/panyz/GankAndPanyz/ddef7ea5db39e7ffc811ef134eaf572150cc977e/src/images/github.png -------------------------------------------------------------------------------- /src/images/home_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/panyz/GankAndPanyz/ddef7ea5db39e7ffc811ef134eaf572150cc977e/src/images/home_normal.png -------------------------------------------------------------------------------- /src/images/home_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/panyz/GankAndPanyz/ddef7ea5db39e7ffc811ef134eaf572150cc977e/src/images/home_selected.png -------------------------------------------------------------------------------- /src/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/panyz/GankAndPanyz/ddef7ea5db39e7ffc811ef134eaf572150cc977e/src/images/logo.png -------------------------------------------------------------------------------- /src/images/three_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/panyz/GankAndPanyz/ddef7ea5db39e7ffc811ef134eaf572150cc977e/src/images/three_normal.png -------------------------------------------------------------------------------- /src/images/three_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/panyz/GankAndPanyz/ddef7ea5db39e7ffc811ef134eaf572150cc977e/src/images/three_selected.png -------------------------------------------------------------------------------- /src/images/two_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/panyz/GankAndPanyz/ddef7ea5db39e7ffc811ef134eaf572150cc977e/src/images/two_normal.png -------------------------------------------------------------------------------- /src/images/two_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/panyz/GankAndPanyz/ddef7ea5db39e7ffc811ef134eaf572150cc977e/src/images/two_selected.png -------------------------------------------------------------------------------- /src/pages/AndroidTabPage.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | import {StyleSheet, View, FlatList, ActivityIndicator,TouchableHighlight} from 'react-native'; 3 | 4 | import GankListItem from '../components/GankListItemComponent'; 5 | 6 | const defaultImage = 'https://facebook.github.io/react/img/logo_og.png'; 7 | 8 | export default class AndroidTabPage extends Component { 9 | 10 | constructor(props) { 11 | super(props); 12 | this.state = { 13 | results: [], 14 | showLoadView: true, 15 | refreshing: true, 16 | }; 17 | this._loadAndroidData(); 18 | } 19 | 20 | _loadAndroidData = () => { 21 | fetch('http://gank.io/api/random/data/Android/15') 22 | .then((res) => res.json()) 23 | .then((responseJson) => { 24 | this.setState({ 25 | results: responseJson.results, 26 | showLoadView: false, 27 | refreshing: false 28 | }) 29 | }) 30 | .catch((error) => { 31 | console.warn(error); 32 | }) 33 | }; 34 | 35 | _extraUniqueKey = (item, index) => { 36 | return "index" + index + item; 37 | }; 38 | 39 | _renderListItem = ({item}) => { 40 | return ( 41 | this.props.navigation.navigate('Web', { 42 | url: item.url, 43 | title: item.desc 44 | })}> 45 | 49 | 50 | ) 51 | }; 52 | 53 | 54 | render() { 55 | return ( 56 | 57 | {this.state.showLoadView ? 58 | : 59 | 60 | 67 | 68 | } 69 | 70 | ); 71 | } 72 | } 73 | 74 | const styles = StyleSheet.create({ 75 | container: { 76 | flex: 1, 77 | }, 78 | loadingStyle: { 79 | flex: 1, 80 | justifyContent: 'center', 81 | alignItems: 'center' 82 | } 83 | }); -------------------------------------------------------------------------------- /src/pages/BlogPage.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | import {StyleSheet, View, Text,FlatList,TouchableHighlight} from 'react-native'; 3 | 4 | export default class BlogPage extends Component{ 5 | static navigationOptions = { 6 | headerTitle: "博客", 7 | }; 8 | 9 | constructor(props){ 10 | super(props); 11 | this.state = { 12 | results:[], 13 | }; 14 | this._loadData(); 15 | } 16 | 17 | _loadData = () => { 18 | fetch('https://api.github.com/repos/panyz/Blogs/issues') 19 | .then((res) => res.json()) 20 | .then((responseJson) => { 21 | this.setState({ 22 | results:responseJson, 23 | }); 24 | }) 25 | .catch((error) => { 26 | console.warn(error); 27 | }) 28 | }; 29 | 30 | _renderListItem = ({item}) => { 31 | return( 32 | 33 | this.props.navigation.navigate('Web',{ 34 | url:item.html_url, 35 | title:item.title, 36 | })}> 37 | {item.title} 38 | 39 | 40 | ) 41 | }; 42 | 43 | _extraUniqueKey = (item, index) => { 44 | return "index" + index + item; 45 | }; 46 | 47 | render(){ 48 | return( 49 | 50 | 55 | 56 | ) 57 | } 58 | } 59 | 60 | const styles = StyleSheet.create({ 61 | container:{ 62 | flex:1, 63 | justifyContent:'center', 64 | alignItems:'center' 65 | }, 66 | textStyle : { 67 | paddingHorizontal:5, 68 | paddingVertical:5, 69 | }, 70 | cardStyle:{ 71 | marginHorizontal:10, 72 | marginVertical:5, 73 | height:50, 74 | backgroundColor:'#fff', 75 | borderRadius:10, 76 | 77 | } 78 | }); -------------------------------------------------------------------------------- /src/pages/FrontEndTabPage.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | import {StyleSheet, View, FlatList, ActivityIndicator,TouchableHighlight} from 'react-native'; 3 | 4 | import GankListItem from '../components/GankListItemComponent'; 5 | const defaultImage = 'https://facebook.github.io/react/img/logo_og.png'; 6 | 7 | export default class FrontEndTabPage extends Component { 8 | 9 | constructor(props) { 10 | super(props); 11 | this.state = { 12 | results: [], 13 | showLoadView: true, 14 | refreshing: true, 15 | }; 16 | this._loadAndroidData(); 17 | } 18 | 19 | _loadAndroidData = () => { 20 | fetch('http://gank.io/api/random/data/前端/15') 21 | .then((res) => res.json()) 22 | .then((responseJson) => { 23 | this.setState({ 24 | results: responseJson.results, 25 | showLoadView: false, 26 | refreshing: false 27 | }) 28 | }) 29 | .catch((error) => { 30 | console.warn(error); 31 | }) 32 | }; 33 | 34 | _extraUniqueKey = (item, index) => { 35 | return "index" + index + item; 36 | }; 37 | 38 | _renderListItem = ({item}) => { 39 | return ( 40 | this.props.navigation.navigate('Web', { 41 | url: item.url, 42 | title: item.desc 43 | })}> 44 | 48 | 49 | ) 50 | }; 51 | 52 | render() { 53 | return ( 54 | 55 | {this.state.showLoadView ? 56 | : 57 | 58 | 65 | 66 | } 67 | 68 | ) 69 | } 70 | } 71 | 72 | const styles = StyleSheet.create({ 73 | container: { 74 | flex: 1, 75 | justifyContent: 'center', 76 | alignItems: 'center' 77 | }, 78 | loadingStyle: { 79 | flex: 1, 80 | justifyContent: 'center', 81 | alignItems: 'center' 82 | } 83 | }); -------------------------------------------------------------------------------- /src/pages/GankPage.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | import {StyleSheet, View, Text,} from 'react-native'; 3 | import GankTab from '../common/GankTabNav'; 4 | 5 | export default class GankPage extends Component { 6 | static navigationOptions = { 7 | headerTitle: "干货", 8 | }; 9 | 10 | render() { 11 | return ( 12 | 13 | 此功能正在开发中... 14 | 15 | ) 16 | } 17 | } 18 | 19 | const styles = StyleSheet.create({ 20 | container: { 21 | flex: 1, 22 | justifyContent: 'center', 23 | alignItems: 'center' 24 | }, 25 | }); -------------------------------------------------------------------------------- /src/pages/LoginPage.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | import {StyleSheet, Image, View, Button, Text, ScrollView, KeyboardAvoidingView,} from 'react-native'; 3 | import {StackNavigator, NavigationActions} from 'react-navigation'; 4 | import Navigator from '../common/TabNavigator'; 5 | 6 | import Input from '../components/InputComponent'; 7 | import HomePage from './MainPage'; 8 | import ThirdScreen from './ThirdScreen'; 9 | import BlogPage from './BlogPage'; 10 | import PersonalInfoPage from './PersonalInfoPage'; 11 | import WebPage from './WebPage'; 12 | import GankPage from '../common/GankTabNav'; 13 | 14 | 15 | class LoginPage extends Component { 16 | 17 | static navigationOptions = { 18 | headerTitle: "登录", 19 | }; 20 | 21 | _toMain = () => { 22 | const resetActions = NavigationActions.reset({ 23 | index: 0, 24 | actions: [NavigationActions.navigate({routeName: 'Main'})] 25 | }); 26 | this.props.navigation.dispatch(resetActions); 27 | }; 28 | 29 | render() { 30 | return ( 31 | 32 | 33 | 34 | 35 | 36 | 37 | 干货集中营 x 博客 38 | 39 | 40 | 41 |