React Native商城项目实战11 - 个人中心头部内容
1.创建MineHeaderView.js
- /**
- * 个人中心头部内容
- */
- import React, { Component } from 'react';
- import {
- AppRegistry,
- StyleSheet,
- Text,
- View,
- Image,
- TouchableOpacity
- } from 'react-native';
- // 导入系统类
- var Dimensions = require('Dimensions');
- var screenW = Dimensions.get('window').width;
- // ES5
- var HeaderView = React.createClass({
- render() {
- return (
- <View style={styles.container}>
- {this.renderTopView()}
- {this.renderBottomView()}
- </View>
- );
- },
- renderTopView(){
- return(
- <View style={styles.topViewStyle}>
- <Image source={{uri:'see'}} style={styles.leftIconStyle} />
- <View style={styles.conterViewStyle}>
- <Text style={{fontSize:18,color:'white',fontWeight:'bold'}}>京东电商</Text>
- <Image source={{uri:'avatar_vip'}} style={{width:17,height:17}} />
- </View>
- <Image source={{uri:'icon_cell_rightArrow'}} style={{width:8,height:13,marginRight:8}} />
- </View>
- )
- },
- renderBottomView(){
- return(
- <View style={styles.bottomViewStyle}>
- {this.renderBottomItem()}
- </View>
- )
- },
- renderBottomItem(){
- // 组件数组
- var items = [];
- // 数据
- var dataArr = [{'number':'100', 'title':'购物券'},{'number':'12', 'title':'评价'},{'number':'50', 'title':'收藏'}];
- // 遍历创建组件转入数组
- for (var i=0;i<dataArr.length;i++){
- var data = dataArr[i];
- items.push(
- <TouchableOpacity key={i}>
- <View style={styles.bottomInnerViewStyle}>
- <Text style={{color:'white'}}>{data.number}</Text>
- <Text style={{color:'white'}}>{data.title}</Text>
- </View>
- </TouchableOpacity>
- );
- }
- return items;
- },
- });
- const styles = StyleSheet.create({
- container: {
- height:200,
- backgroundColor:'rgb(255,96,0)'
- },
- topViewStyle:{
- flexDirection:'row',
- marginTop:80,
- alignItems:'center',
- justifyContent:'space-around'
- },
- leftIconStyle:{
- width:70,
- height:70,
- borderRadius:35,
- borderWidth:3,
- borderColor:'rgba(0,0,0,0.2)',
- },
- conterViewStyle:{
- flexDirection:'row',
- width:screenW * 0.6,
- },
- bottomViewStyle:{
- flexDirection:'row',
- position:'absolute',
- bottom:0,
- },
- bottomInnerViewStyle:{
- width:(screenW/3)+1,
- height:40,
- backgroundColor:'rgba(255,255,255,0.4)',
- justifyContent:'center',
- alignItems:'center',
- borderRightWidth:1,
- borderRightColor:'white'
- }
- });
- // 输出
- module.exports = HeaderView;
2.Mine.js使用这个组件
- /**
- * 我的
- */
- import React, { Component } from 'react';
- import {
- AppRegistry,
- StyleSheet,
- Text,
- View,
- ScrollView
- } from 'react-native';
- /*======导入外部组件类======*/
- var MyCell = require('./CommonMyCell');
- var MiddleView = require('./MineMiddleView');
- var HeaderView = require('./MineHeaderView');
- // ES5
- var Mine = React.createClass({
- render() {
- return (
- <ScrollView style={styles.scrollViewStyle}>
- <HeaderView />
- <View style={{marginTop:20}}>
- <MyCell
- leftIconName="collect"
- leftTitle="我的订单"
- rightTitle="查看全部订单"
- />
- <MiddleView />
- </View>
- <View style={{marginTop:20}}>
- <MyCell
- leftIconName="draft"
- leftTitle="钱包"
- rightTitle="账号余额:¥100.88"
- />
- </View>
- <View style={{marginTop:20}}>
- <MyCell
- leftIconName="voucher"
- leftTitle="抵用券"
- rightTitle="10张"
- />
- </View>
- <View style={{marginTop:20}}>
- <MyCell
- leftIconName="mall"
- leftTitle="积分商城"
- rightTitle=""
- />
- </View>
- <View style={{marginTop:20}}>
- <MyCell
- leftIconName="recommend"
- leftTitle="今日推荐"
- rightTitle=""
- />
- </View>
- </ScrollView>
- );
- }
- });
- const styles = StyleSheet.create({
- scrollViewStyle:{
- }
- });
- // 输出
- module.exports = Mine;
3.效果图
React Native商城项目实战11 - 个人中心头部内容的更多相关文章
- React Native商城项目实战10 - 个人中心中间内容设置
1.新建一个MineMiddleView.js,专门用于构建中间的内容 /** * 个人中心中间内容设置 */ import React, { Component } from 'react'; im ...
- React Native商城项目实战09 - 个人中心自定义cell
1.新建组件CommonMyCell.js /** * 个人中心自定义cell */ import React, { Component } from 'react'; import { AppReg ...
- React Native商城项目实战12 - 首页头部内容
1.HomeTopView为首页头部内容,HomeTopListView为HomeTopView子视图. 2.HomeTopView.js /** * 首页头部内容 */ import React, ...
- React Native商城项目实战04 - 封装TabNavigator.Item的创建
1.Main.js /** * 主页面 */ import React, { Component } from 'react'; import { StyleSheet, Text, View, Im ...
- React Native商城项目实战02 - 主要框架部分(tabBar)
1.安装插件,cd到项目根目录下执行: $ npm i react-native-tab-navigator --save 2.主框架文件Main.js /** * 主页面 */ import Rea ...
- React Native商城项目实战01 - 初始化设置
1.创建项目 $ react-native init BuyDemo 2.导入图片资源 安卓:把文件夹放到/android/app/src/main/res/目录下,如图: iOS: Xcode打开工 ...
- React Native商城项目实战07 - 设置“More”界面导航条
1.More/More.js /** * 更多 */ import React, { Component } from 'react'; import { AppRegistry, StyleShee ...
- React Native商城项目实战05 - 设置首页的导航条
1.Home.js /** * 首页 */ import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Te ...
- React Native商城项目实战06 - 设置安卓中的启动页
1.Main 目录下新建LaunchImage.js: /** * 启动页 */ import React, { Component } from 'react'; import { AppRegis ...
随机推荐
- centos7使用kubeadm搭建kubernetes集群
一.本地实验环境准备 服务器虚拟机准备 IP CPU 内存 hostname 192.168.222.129 >=2c >=2G master 192.168.222.130 >=2 ...
- [LeetCode] 211. 添加与搜索单词 - 数据结构设计
题目链接:https://leetcode-cn.com/problems/add-and-search-word-data-structure-design/ 题目描述: 设计一个支持以下两种操作的 ...
- linux-导入python自定义模块的使用方法
#!/usr/bin/python # -*- coding:utf -8 -*- import os import sys sys.path.append("/h/s/compare_f& ...
- redis 教程(一)-基础知识
redis 简介 redis 是高性能的 key-value 数据库,读的速度是110000次/s,写的速度是81000次/s ,它以内存作为主存储 具有以下优点: 1. 支持数据的持久化,将内存中的 ...
- HNUST-1681 机器人走格子(找规律)
1681: 机器人走格子 时间限制: 1 Sec 内存限制: 128 MB提交: 244 解决: 58[提交][状态][讨论版] 题目描述 一个长X宽Y的棋盘,有XY个格子.将机器人放在某个格子中 ...
- RabbitMQ几种队列模式
- 剑指offer-旋转数组的最小数字-数组-python
题目描述 把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转.输入一个非递减排序的数组的一个旋转,输出旋转数组的最小元素.例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转 ...
- xss过滤与单例模式(对象的实例永远用一个)
kindeditor里面可以加入script代码,使用re可以过滤掉python有个专门的模块可以处理这种情况,beautifulsoup4 调用代码: content = XSSFilter().p ...
- C Makefile初学基础
# this is make file hello.out: max.o min.o hello.c gcc max.o min.o hello.c -o hello.out max.o:max.c ...
- 008-流程控制 case 语句
流程控制 case 语句 与if...elif...else 语句一样都是多分支条件语句,不过if语句可以判断多种条件关系,case只能判断一种条件关系 [root@zabbix lianxi]# . ...