【水滴石穿】bstmy-blend-app
这个项目是一个简单的底部导航切换页面
项目的地址为:https://github.com/Bstmy/bstmy-blend-app
先看效果

点击首页是首页面,点击个人中心是个人中心页面
先看代码
//index.js
//引用的是根app.js
import {AppRegistry} from 'react-native';
import App from './app/App';
import {name as appName} from './app.json';
AppRegistry.registerComponent(appName, () => App);
//app/App.js
//这个里面不仅有防止闪屏的,还有倒计时为3的启动页,还有定义了首页
import React, { Component } from 'react';
//闪屏
import SplashScreen from 'react-native-splash-screen';
//导航
import {createAppContainer, createStackNavigator} from 'react-navigation';
//显示首页
import Home from "./Home";
//这个是很好看的启动页很美腻
import GuideView from "./guide/GuideView";
const RootStack = createStackNavigator(
{
homes: Home,
guideView: GuideView
},
{
initialRouteName: 'guideView' ,
defaultNavigationOptions: {
headerStyle: {
backgroundColor: '#f4511e',
height:0,
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
},
},
}
);
const AppContainer = createAppContainer(RootStack);
//定义首页
//渲染AppConta
export default class App extends Component {
constructor(props) {
super(props);
SplashScreen.hide(); // 关闭启动屏幕
}
render() {
return (
<AppContainer />
);
}
}
//app/guide/GuideView.js
//配置的启动页
import React, {Component} from 'react';
import {
Image,
StyleSheet,
View,
Text
} from 'react-native';
import Swiper from 'react-native-swiper';
import AutoSize from '../utils/AutoSize';
class GuideView extends Component {
constructor() {
super();
this.state = { invertedTime: 5 };
}
componentDidMount() {
this.timer1=setInterval(() => {
this.setState(previousState => {
return {invertedTime: (previousState.invertedTime-1)};
})
console.log("启动倒计时"+this.state.invertedTime );
if(this.state.invertedTime == 0){
this.openHomePage();
clearInterval(this.timer1)
}
} ,1000);
}
openHomePage(){
this.props.navigation.navigate('homes');
}
//卸载计时器
componentWillUnmount() {
this.timer1 && clearInterval(this.timer1);
}
render() {
return (
<View style={styles.container}>
<Text style={styles.next} onPress={this.openHomePage.bind(this)}>{this.state.invertedTime}</Text>
<Swiper style={styles.wrapper}
showsButtons={false} //为false时不显示控制按钮
paginationStyle={{ //小圆点位置
bottom: 30
}}
loop={true} //如果设置为false,那么滑动到最后一张时,再次滑动将不会滑到第一张图片。
autoplay={true} //自动轮播
autoplayTimeout={3} //每隔3秒切换
>
<Image style={styles.image} source={require('../img/guide/geoude2.jpg')}/>
<Image style={styles.image} source={require('../img/guide/geoude3.jpg')}/>
<Image style={styles.image} source={require('../img/guide/geoude1.jpg')}/>
</Swiper>
</View>
);
}
};
let styles = StyleSheet.create({
container: {
flex: 1,//必写
flexDirection: 'column',
},
image: {
width:AutoSize.size.width,//等于width:width
height:AutoSize.size.height,
},
next:{
width: 30,
height: 30,
borderRadius:15,
fontSize:15,
textAlign:"center",
textAlignVertical: 'center',
backgroundColor: "#D4237A",
zIndex:1,
position: 'absolute',
color:"#fff",
right: 20,
top: 20,
}
});
export default GuideView;
//app/utils/AutoSize.js
//这个里面进行的就是屏幕适配
import React from 'react';
import Dimensions from 'Dimensions';
const AutoSize = {
size: {
width: Dimensions.get('window').width,
height: Dimensions.get('window').height
},
};
export default AutoSize;
//app/route/RootStack.js
//定义的是首页
import { createStackNavigator } from 'react-navigation';
import Home from '../Home'
import GuideView from '../guide/GuideView'
export const RootStack = createStackNavigator(
{
home: Home,
guideView: GuideView,
},
{
initialRouteName: 'guideView',
defaultNavigationOptions: {
headerStyle: {
backgroundColor: '#f4511e',
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
},
},
}
);
//和index页面类似,不过具体怎么控制的?
//app/pages/User.js
import React, { Component } from 'react';
import {
View,
Text
} from 'react-native';
class User extends Component {
render() {
return (
<View>
<Text>
我是用户
</Text>
</View>
);
}
}
export default User;
上面有一点点的不理解
不知道是什么控制的切换的页面的,因为那个是同时引用的
不过这个项目我喜欢~~哭唧唧,在这个水平这里~~
【水滴石穿】bstmy-blend-app的更多相关文章
- 用 Blend 给Windows Phone 应用创建 示例数据
前言 创建 示例数据(Sample Data) 是提高程序开发效率的一个很有效方法,有了它,我们调UI的时候就不必每次都运行应用,然后在手机上观看页面效果了,配合 “AlignmentGrid.pn ...
- Win10/UWP 让你的App使用上扫描仪
UWP的扫描仪功能现在被微软划分到了[Windows Desktop Extensions for the UWP]中,如果要使用扫描仪扫描图片到自己的App中,首先我们要添加[Windows Des ...
- Blend 2015 教程 (二) 样式
前一篇讲述了如何在新Blend中完成一个简单的带数据绑定的界面小例子,本篇将讲述一下,把View层和Style层分开,并搭建Style层框架的方法,并进行细节样式修改. 1. 在解决方案资源管理器面板 ...
- Blend 2015 教程 (四)控件模板
前一篇讲述了修改ListBox样式的方法,本篇将修改性别显示区域的样式. 1. 选择ListBox控件,编辑ItemTemplate的当前项,选择CheckBox控件,在美工板导航栏中点击CheckB ...
- 使用MVVM-Sidekick开发Universal App(二)
上一篇文章已经建立了基本的实体类,并且搞定了多语言的问题,以后在app里用字符串的时候就可以从资源文件中取了.现在继续进行. 一.添加一个页面 CurrencyExchanger首页是一个货币兑换的列 ...
- 不可或缺 Windows Native (25) - C++: windows app native, android app native, ios app native
[源码下载] 不可或缺 Windows Native (25) - C++: windows app native, android app native, ios app native 作者:web ...
- 尝试HTML + JavaScript 编写Windows App
一直以来博文中使用最多的就是C# + XAML.进入Windows App时代,又多了一对 Javascript + HTML组合,这对于Web开发的程序员来说再熟悉不过了.其实小编也做过几年的Web ...
- 重新想象 Windows 8 Store Apps (70) - 其它: 文件压缩和解压缩, 与 Windows 商店相关的操作, app 与 web, 几个 Core 的应用, 页面的生命周期和程序的生命周期
[源码下载] 重新想象 Windows 8 Store Apps (70) - 其它: 文件压缩和解压缩, 与 Windows 商店相关的操作, app 与 web, 几个 Core 的应用, 页面的 ...
- 给 Xamarin.Form For Windows Phone APP 加个漂亮的 "头"
Windows Phone 是那个1%, 我也是那个1%, 不喜勿喷.WP 向来给 android / ios 的粉们一个最直观的印象: 丑.其实"丑"这个东西会一直下去,而且是个 ...
- iOS视频直播初窥:高仿<喵播APP>
视频直播初窥 视频直播,可以分为 采集,前处理,编码,传输, 服务器处理,解码,渲染 采集: iOS系统因为软硬件种类不多, 硬件适配性比较好, 所以比较简单. 而Android端市面上机型众多, 要 ...
随机推荐
- windows下和linux下运行jar
需要在windows下运行jar,首先需要我们打包出来可执行jar idea打包可执行jar可以参考我的另一篇博客[https://mp.csdn.net/postedit/88653200] 一.w ...
- [code]图像亮度调整enhancement
//draft 2013.9 //F=X2/u; ////远处细节被淹没. 亮的地方增亮明显,暗的地方更暗. 不可取. // CvScalar rgb; // rgb=cvAvg(src); //fo ...
- gulp入门之常见处理方式(三)
整合 streams 来处理错误 默认情况下,在 stream 中发生一个错误的话,它会被直接抛出,除非已经有一个时间监听器监听着 error时间. 这在处理一个比较长的管道操作的时候会显得比较棘手. ...
- 应读的paper
1.Faster R-CNN:https://arxiv.org/abs/1506.01497(已读) 2.FPN(Feature Pyramid Networks for Object Detect ...
- TZOJ 1503 Incredible Cows(折半搜索+二分)
描述 Farmer John is well known for his great cows. Recently, the cows have decided to participate in t ...
- spotbus gradle-qulity-plugiin 多项目bug检查
https://spotbugs.readthedocs.io/en/latest/bugDescriptions.html https://xvik.github.io/gradle-quality ...
- Docx 生成word文档二
/// <summary> /// 生产word 文档 /// </summary> public class GenerateWord { /// <summary&g ...
- [转]json对象详解
json(javascript object notation)全称是javascript对象表示法,它是一种数据交换的文本格式,而不是一种编程语言,用于读取结构化数据.2001年由Douglas C ...
- WWDC 上讲到的 Objective C / LLVM 改进
https://developer.apple.com/wwdc/videos/ Advances in Objective-C What's New in the LLVM Compiler 下面是 ...
- MVVM 一种新型架构框架
MVVM是Model-View-ViewModel的简写.微软的WPF带来了新的技术体验,如Silverlight.音频.视频.3D.动画……,这导致了软件UI层更加细节化.可定制化.同时,在技术层面 ...