说个题外话,早上打开电脑的时候,电脑变成彩色的了,锅是我曾经安装的一个chrome扩展,没有经过我的同意开启了

(也许是昨天迷迷糊糊开启了)

上午运行项目都不成功,还以为被黑客攻击了~~~然后下午就排除问题啊,不能一直彩色界面啊~~~

就一个一个禁掉chrome插件

言归正传,时间如流水,快快珍惜。

接下来这个demo也是很基础的,重点是看看数据处理还有有没有下拉加载更多,页面返回是有点问题的

上开源的程序员的源码:https://github.com/githubze/react-native-aze

页面效果如下







还是不够有些基础啊,分析代码

//taskapp1/index.js
//引用入口是在app.js
/**
* @format
*/ import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json'; AppRegistry.registerComponent(appName, () => App);
//定义可切换下部,和引用组件
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/ import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View,Image} from 'react-native';
import {DrawerNavigator,TabNavigator,StackNavigator} from 'react-navigation';
import {
createDrawerNavigator,
createStackNavigator,
createBottomTabNavigator,
createAppContainer,
} from 'react-navigation';
import HomeScreen from './Component/HomePage/Home';
import DetailScreen from './Component/HomePage/DetailScreen';
import Mine from './Component/MinePage/Mine'; export const Stack = createStackNavigator(
{
Home: { screen: HomeScreen },
Details: { screen: DetailScreen },
},
{
headerMode:'screen',
navigationOptions: ({
navigation
}) => ({
tabBarVisible: navigation.state.index > 0 ? false : true,
}),
headerBackTitleVisible:false,
//headerBackImage:<Image source={require('./Component/HomePage/back.png')}/>,
},
); export const Stack1 = createStackNavigator(
{
Home: { screen: Mine },
},
{
headerMode:'screen',
navigationOptions: ({
navigation
}) => ({
tabBarVisible: navigation.state.index > 0 ? false : true, }),
headerBackTitleVisible:false,
},
); export const Tabs = createBottomTabNavigator(
{
TabA: {
screen: Stack,
navigationOptions: {
tabBarLabel: '任务',
tabBarIcon: ({tintColor, focused}) => {
if(focused){
return <Image source={require('./Images/HomeImage1.png')} style={styles.imageStyle} />;
} else {
return <Image source={ require('./Images/HomeImage0.png')} style={styles.imageStyle}/>;
}
},
},
},
TabB: {
screen: Stack1,
navigationOptions: {
tabBarLabel: '我的',
tabBarIcon: ({tintColor, focused}) => {
if(focused){
return <Image source={require('./Images/MineImage1.png')} style={styles.imageStyle} />;
} else {
return <Image source={ require('./Images/MineImage0.png')} style={styles.imageStyle}/>;
}
}, //headerBackImage:navigation.state.index > 0? <Image source={require('./Images/back.png')} style={styles.imageStyle} />:null,
},
}
},
{
order: ['TabA', 'TabB'],
tabBarOptions:{
labelStyle: {
fontSize: 11,
bottom:4
},
style: {
backgroundColor: 'white',
},
activeTintColor:'#EA7B00',
inactiveTintColor:'#D1D1D1',
showIcon:true, }, }, ) export const RootStack = createAppContainer(
createDrawerNavigator({
// Stack: { screen: Stack },
Tabs: { screen: Tabs },
})
); type Props = {};
export default class App extends Component<Props> {
render() {
return <RootStack />;
}
} const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5F5F5',
},
imageStyle:{
width:20,
height:20,
}, });

关于首页是写死的数据没有与后端交互

//home
//taskapp1/Component/HomePage/Home.js
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View,Button,ListView,FlatList,Image,TouchableOpacity} from 'react-native'; class HomeScreen extends React.Component {
static navigationOptions = {
title: '任务',
}; state = {selected: (new Map(): Map<string, boolean>)};
_keyExtractor = (item, index) => index; refreshing(){
let timer = setTimeout(()=>{
clearTimeout(timer)
// alert('刷新成功') },15000)
} itemClick(item, index) {
//alert('点击了第' + index + '项,name为:' + item.title); this.props.navigation.navigate('Details',{
userName:'Tory',
userInfo:'Hello'
})
} render() {
let movies = [
{title: '微信分享 帮忙助力领跑汽车优惠 第一行',ProgressText:'33%',DetailText:'4.4',ImageName:'https://gsnapshot.alicdn.com/imgextra/i3/575127927/TB2n8OJIk9WBuNjSspeXXaz5VXa_!!575127927.jpg_430x430.jpg?time=1539689523000'},
{title: '微信分享 帮忙助力领跑汽车优惠 第二行',ProgressText:'33%',DetailText:'4.4',ImageName:'https://gsnapshot.alicdn.com/imgextra/i3/575127927/TB2n8OJIk9WBuNjSspeXXaz5VXa_!!575127927.jpg_430x430.jpg?time=1539689523000'},
{title: '微信分享 帮忙助力领跑汽车优惠 第三行',ProgressText:'33%',DetailText:'4.4',ImageName:'https://gsnapshot.alicdn.com/imgextra/i3/575127927/TB2n8OJIk9WBuNjSspeXXaz5VXa_!!575127927.jpg_430x430.jpg?time=1539689523000'},
{title: '微信分享 帮忙助力领跑汽车优惠 第四行',ProgressText:'33%',DetailText:'4.4',ImageName:'https://gsnapshot.alicdn.com/imgextra/i3/575127927/TB2n8OJIk9WBuNjSspeXXaz5VXa_!!575127927.jpg_430x430.jpg?time=1539689523000'},
{title: '微信分享 帮忙助力领跑汽车优惠 第五行',ProgressText:'33%',DetailText:'4.4',ImageName:'https://gsnapshot.alicdn.com/imgextra/i3/575127927/TB2n8OJIk9WBuNjSspeXXaz5VXa_!!575127927.jpg_430x430.jpg?time=1539689523000'},
{title: '微信分享 帮忙助力领跑汽车优惠 第六行',ProgressText:'33%',DetailText:'4.4',ImageName:'https://gsnapshot.alicdn.com/imgextra/i3/575127927/TB2n8OJIk9WBuNjSspeXXaz5VXa_!!575127927.jpg_430x430.jpg?time=1539689523000'},
{title: '微信分享 帮忙助力领跑汽车优惠 第七行',ProgressText:'33%',DetailText:'4.4',ImageName:'https://gsnapshot.alicdn.com/imgextra/i3/575127927/TB2n8OJIk9WBuNjSspeXXaz5VXa_!!575127927.jpg_430x430.jpg?time=1539689523000'},
];
return (
<View style={styles.container}>
<FlatList
data = {movies}
showsVerticalScrollIndicator = {false}
keyExtractor={this._keyExtractor}
onRefresh={this.refreshing}
refreshing={false}
renderItem={ ({item}) =>
<TouchableOpacity onPress={this.itemClick.bind(this, item, item.index)}>
<View style={styles.cellView} > <View style={styles.contentStyle}>
<Text style={styles.titleStyle}>{item.title}</Text>
<Text style={styles.progressStyle}>{'完成率:'+item.ProgressText}</Text>
<Text style={styles.detailStyle}>{'好评值:'+item.DetailText}</Text>
</View>
<View style={styles.imageContentStyle}>
<Image
source={{uri: 'https://gsnapshot.alicdn.com/imgextra/i3/575127927/TB2n8OJIk9WBuNjSspeXXaz5VXa_!!575127927.jpg_430x430.jpg?time=1539689523000'}}
style={styles.showImageStyle}
/>
</View> </View>
</TouchableOpacity> }
/> </View>
);
}
} const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F4F4F4',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
showImageStyle: {
width:70,
height:70,
},
cellView: {
flexDirection:'row',
backgroundColor: '#ffffff',
marginBottom: 1,
flex: 1,
},
contentStyle:{
marginTop:16,
marginLeft:20,
width: 230,
},
imageContentStyle:{
marginTop:19,
marginRight:20,
marginBottom:15,
marginLeft: 35,
},
titleStyle: {
color: '#333333',
fontSize: 16,
fontWeight: 'bold',
},
progressStyle: {
color: '#A1A1A1',
height:12,
marginTop: 5,
fontSize: 12,
},
detailStyle: {
color: '#A1A1A1',
height:12,
marginTop: 3,
fontSize: 12,
},
}); export {HomeScreen as default};
//taskapp1/Component/HomePage/DetailScreen.js
//点击进入详情页,注意data在homepage页面用到
import React, {Component} from 'react';
import {Image, Platform, StyleSheet, Text, View} from 'react-native'; class DetailScreen extends Component {
static navigationOptions = {
title: '任务详情',
headerBackImage:<Image source={require('../HomePage/back.png')}/>,
}; render() {
const data=this.props.navigation.state.params;
return (
<View style={styles.container}>
<Text>你好!</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5F5F5',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
export {DetailScreen as default};
//detail页面模仿的homepage页面写法,作者有很强的模仿发散能力啊
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View,Button,ListView,FlatList,Image,TouchableOpacity,Dimensions,StatusBar} from 'react-native'; var {height,width} = Dimensions.get('window');
class Mine extends React.Component {
static navigationOptions = {
title: '我的',
header:null,
}; state = {selected: (new Map(): Map<string, boolean>)};
_keyExtractor = (item, index) => index; itemClick(item, index) {
//alert('点击了第' + index + '项,name为:' + item.title); this.props.navigation.navigate('Details',{
userName:'Tory',
userInfo:'Hello'
}) } header = () => {
return ( <View style={styles.headViewStyle}>
<View style={styles.userViewStyle}>
<Image
source={{uri: 'http://img01.myyzz.com/upload/images/20190429/userlogo/20190429wxxwjv24rgl1.png'}}
style={styles.iconImageStyle}
/>
<Text style={styles.nameStyle}>Geniusn</Text>
</View> </View>
)
}; render() {
let movies = [
{title: '我的互助'},
{title: '分享给好友'},
{title: '版本更新'},
{title: '设置'},
{title: '退出登录'},
];
return (
<View style={styles.container}>
<FlatList
data = {movies}
showsVerticalScrollIndicator = {false}
keyExtractor={this._keyExtractor}
ListHeaderComponent={this.header}
renderItem={ ({item}) =>
<TouchableOpacity onPress={this.itemClick.bind(this, item, item.index)}>
<View style={styles.cellView} >
<Text style={[styles.titleStyle,styles.contentStyle]}>{item.title}</Text>
<Image
source={require('../MinePage/ordershow.png')}
style={styles.showImageStyle}
/> </View>
</TouchableOpacity> }
/> </View>
);
}
} const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F4F4F4',
},
cellView: {
flexDirection:'row',
backgroundColor: '#ffffff',
marginBottom: 1,
flex: 1,
height:50,
width:width,
},
contentStyle:{
marginLeft:20,
marginTop:17,
width: 230,
},
titleStyle: {
color: '#333333',
fontSize: 16,
textAlign:'left',
},
showImageStyle: {
width:15,
height:20,
marginTop:15,
marginLeft: 98,
},
headViewStyle:{
flexDirection:'row',
backgroundColor: '#EA7B00',
height:220,
justifyContent:'center',
},
userViewStyle:{
width:70,
height:100,
marginTop:60,
},
iconImageStyle:{
width:70,
height:70,
borderRadius:35,
resizeMode:'cover',
},
nameStyle:{
color: '#ffffff',
fontSize: 18,
marginTop:10,
},
}); export {Mine as default};

【水滴石穿】react-native-aze的更多相关文章

  1. 基于React Native的58 APP开发实践

    React Native在iOS界早就炒的火热了,随着2015年底Android端推出后,一套代码能运行于双平台上,真正拥有了Hybrid框架的所有优势.再加上Native的优秀性能,让越来越多的公司 ...

  2. React Native 之 Text的使用

    前言 学习本系列内容需要具备一定 HTML 开发基础,没有基础的朋友可以先转至 HTML快速入门(一) 学习 本人接触 React Native 时间并不是特别长,所以对其中的内容和性质了解可能会有所 ...

  3. React Native环境配置之Windows版本搭建

    接近年底了,回想这一年都做了啥,学习了啥,然后突然发现,这一年买了不少书,看是看了,就没有完整看完的.悲催. 然后,最近项目也不是很紧了,所以抽空学习了H5.自学啃书还是很无趣的,虽然Head Fir ...

  4. 史上最全Windows版本搭建安装React Native环境配置

    史上最全Windows版本搭建安装React Native环境配置 配置过React Native 环境的都知道,在Windows React Native环境配置有很多坑要跳,为了帮助新手快速无误的 ...

  5. 【腾讯Bugly干货分享】React Native项目实战总结

    本文来自于腾讯bugly开发者社区,非经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/577e16a7640ad7b4682c64a7 “8小时内拼工作,8小时外拼成长 ...

  6. React Native环境搭建以及几个基础控件的使用

    之前写了几篇博客,但是没有从最基础的开始写,现在想了想感觉不太合适,所以现在把基础的一些东西给补上,也算是我从零开始学习RN的经验吧! 一.环境搭建 首先声明一下,本人现在用的编辑器是SublimeT ...

  7. React Native组件介绍

    1.React Native目前已有的组件 ActivityIndicatorIOS:标准的旋转进度轮; DatePickerIOS:日期选择器: Image:图片控件: ListView:列表控件: ...

  8. React Native图片控件的使用

    首先定义组件 import { AppRegistry, StyleSheet, Text, View, Image,} from 'react-native'; 然后将render返回中的模版增加I ...

  9. react-native学习笔记--史上最详细Windows版本搭建安装React Native环境配置

    参考:http://www.lcode.org/react-native/ React native中文网:http://reactnative.cn/docs/0.23/android-setup. ...

  10. windows 7下React Native环境配置

    React Native 是 Facebook 推出的一个用 Java 语言就能同时编写 ios,android,以及后台的一项技术,它可以做到实时热更新 .FaceBook 也号称这们技术是 “Le ...

随机推荐

  1. JPA、Hibernate、Spring data jpa之间的关系

    什么么是JPA? 全称Java Persistence API,可以通过注解或者XML描述[对象-关系表]之间的映射关系,并将实体对象持久化到数据库中. 为我们提供了: 1)ORM映射元数据:JPA支 ...

  2. 如何做系列(2)- XML转义字符

    < < 小于号 > > 大于号 & & 和 &apos; ' 单引号 " " 双引号 也可以使用<![CDATA[ ]]> ...

  3. CA证书制作

    目录 手动制作CA证书 1.安装 CFSSL 2.初始化cfssl 3.创建用来生成 CA 文件的 JSON 配置文件 4.创建用来生成 CA 证书签名请求(CSR)的 JSON 配置文件 5.生成C ...

  4. webpack处理字体文件

    1. 安装 file-loader npm install file-loader --save-dev 2. 在webpack.config.js中配置 module.exports={ //... ...

  5. Hdu 2376

    题目链接 题意:给出一颗含有n个结点的树,树上每条边都有一个长度,求树上所有路径的平均长度. 考虑树上每条边对所有路径长度和的贡献,对于每条偶 就是边的两个短点u和v,只需要记录以u为根的子树的结点的 ...

  6. Spring注解驱动开发(七)-----servlet3.0、springmvc

    ServletContainerInitializer Shared libraries(共享库) / runtimes pluggability(运行时插件能力) 1.Servlet容器启动会扫描, ...

  7. spring cloud深入学习(九)-----配置中心服务化和高可用

    在前两篇的介绍中,客户端都是直接调用配置中心的server端来获取配置文件信息.这样就存在了一个问题,客户端和服务端的耦合性太高,如果server端要做集群,客户端只能通过原始的方式来路由,serve ...

  8. python简单爬豆瓣电影排名

    爬豆瓣电影 网站分析: 1 打开https://movie.douban.com,选择  [排行榜],然后随便选择一类型,我这里选择科幻    2 一直浏览网页,发现没有下一的标签,是下滑再加载的,可 ...

  9. TZOJ 5963 Increasing Sequences(线性DP)

    描述 Given a string of digits, insert commas to create a sequence of strictly increasing numbers so as ...

  10. 关于Git回退再前进造成本地代码和远程仓库代码不一致的问题

    事情经过:  git push 提交之后(版本2.0), 回退, 然后做了一些修改, 发现有问题,于是脑抽回退git reset --hard HEAD^ (版本1,0), 然后又前进到之前那个版本( ...