【水滴石穿】ReactNativeMobxFrame
项目地址如下:https://github.com/FTD-ZF/ReactNativeMobxFrame
应该可以说的是,项目也只是一个花架子,不过底部的tab稍微改变了
我们一起来看代码
//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);
先来看看App.js
很惊讶,其实是有处理数据的用到了mobx
App.js中引用了下部的切换,这个 布局还是挺好玩的
//src/navigation.js
import React, { Component } from 'react';
import { Platform, StyleSheet, Text, View, Easing, Animated } from 'react-native';
import {// TabNavigator,StackNavigator,createStackNavigator,createBottomTabNavigator,createAppContainer,getActiveChildNavigationOptions,// createMaterialTopTabNavigator,
} from 'react-navigation';
import { headerOptions, RouteConfigs, } from './commons/components/navConfig';import { HomeTab, MineTab, DetailsView, CenterView } from './root';
import { AppColors, AppStyles } from './commons/styles/index';
import CustomTabComponent from './commons/components/Tab';
const TabBarText = {home: '首页',centertext: '新增',persnalName: "我的",
}const TabNavigator = createBottomTabNavigator({Home: {screen: HomeTab,navigationOptions: props => {return RouteConfigs({imgSource: require('../src/assets/imgs/homeSelect.png'),label: TabBarText.home,props,})},},Center: {screen: CenterView,navigationOptions: props => {return RouteConfigs({imgSource: require('../src/assets/imgs/homeSelect.png'),label: TabBarText.centertext,props,})},},Mine: {screen: MineTab,navigationOptions: props => {return RouteConfigs({imgSource: require('../src/assets/imgs/homeSelect.png'),label: TabBarText.persnalName,props,})},},},{tabBarComponent: props => <CustomTabComponent {...props} />,tabBarOptions: {showIcon: true,activeTintColor: AppColors.themecolor,inactiveTintColor: '#979797',labelStyle: {fontSize: 12 // 文字大小}}});//此处为每个tab页面可进行设置标题栏相关内容
TabNavigator.navigationOptions = ({ navigation, screenProps }) => {const childOptions = getActiveChildNavigationOptions(navigation, screenProps)return {headerTitle: childOptions.headerTitle,headerLeft: childOptions.headerLeft,headerRight: childOptions.headerRight,headerStyle: AppStyles.NavTopStyle,headerTitleStyle: AppStyles.NavTopTitleStyle,header: childOptions.header,}
}const stackNavigators = createStackNavigator({Root: {screen: TabNavigator,},DetailsView: {screen: DetailsView,navigationOptions: props => {return headerOptions({...props,...{back: true,},})},}},{// // defaultNavigationOptions: ({ navigation }) => {// // return {// // ...defaultHeaderOpts,// // gesturesEnabled: true,// // headerBackTitle: '',// // // headerTitle: '',// // headerBackImage: HeaderBackImage// // };// // },initialRouteName: 'Root',mode: 'card',headerMode: "screen",transitionConfig: () => ({transitionSpec: {duration: 300,easing: Easing.out(Easing.poly(4)),timing: Animated.timing,},screenInterpolator: sceneProps => {const { layout, position, scene } = sceneProps;const { index } = scene;const Width = layout.initWidth;//沿X轴平移const translateX = position.interpolate({inputRange: [index - 1, index, index + 1],outputRange: [Width, 0, -(Width - 10)],});//透明度const opacity = position.interpolate({inputRange: [index - 1, index - 0.99, index],outputRange: [0, 1, 1],});return { opacity, transform: [{ translateX }] };}})}
);const AppContainer = createAppContainer(stackNavigators);export default AppContainer;
//src/pages/details.js
/*** Sample React Native App* https://github.com/facebook/react-native* @flow*/import React, { Component } from 'react';
import {Platform,StyleSheet,Text,View,Image,TouchableOpacity
} from 'react-native';
import { AppColors } from '../commons/styles';export default class Index extends Component {static navigationOptions = ({ navigation }) => {return {headerTitle: navigation.state.params.headername,// headerRight: (<Text>www</Text>),// headerLeft: <Text>返回</Text>}}// 构造constructor(props) {super(props);// 初始状态this.state = {};}componentWillMount() {}_goBack() {this.props.navigation.state.params.callback('你好!!!');this.props.navigation.goBack();}render() {return (<View style={styles.container}><TouchableOpacitystyle={{backgroundColor: AppColors.themecolor,margin: 20,padding: 10,}} onPress={() => this._goBack()}><Text style={{ color: 'white', textAlign: 'center' }}>点击返回通知刷新</Text></TouchableOpacity></View>);}}const styles = StyleSheet.create({container: {flex: 1,justifyContent: 'center',alignItems: 'center',backgroundColor: '#F5FCFF',},welcome: {fontSize: 20,textAlign: 'center',margin: 10,},instructions: {textAlign: 'center',color: '#333333',marginBottom: 5,},
});
//src/pages/home/index.js
/*** Sample React Native App* https://github.com/facebook/react-native* @flow*/import React, { Component } from 'react';
import {Platform,StyleSheet,Text,View,Image,SafeAreaView,TextInput,TouchableOpacity,BackHandler
} from 'react-native';import { AppStyles, AppColors } from '../../commons/styles';
import { Toast } from 'teaset';
// import testStore from '../../mobx/testStore';
import { observer, inject } from "mobx-react";@inject('rootStore')
@observer
export default class Index extends Component {static navigationOptions = ({ navigation }) => ({headerTitle: '首页',headerLeft: (<TouchableOpacity onPress={() => { navigation.state.params.showToast() }}><Text>左边点击</Text></TouchableOpacity>),headerRight: (<View />)});// 构造constructor(props) {super(props);this.testStore = this.props.rootStore.testStore;// 初始状态this.state = {content: '',};}componentWillMount() {this.props.navigation.setParams({showToast: () => this._showToast(),torefresh: (str) => this._toRefresh(str),});}componentDidMount() {this.testStore.getListData();}_showToast() {Toast.message('看下效果');}_todetails() {this.props.navigation.navigate('DetailsView', {headername: '详情',callback: (str) => this.props.navigation.state.params.torefresh(str),});}_toRefresh(str) {this.setState({content: str,});}render() {return (<View style={styles.container}><TouchableOpacitystyle={{backgroundColor: AppColors.themecolor,margin: 20,padding: 10,}} onPress={() => this._todetails()}><Text style={{ color: 'white', textAlign: 'center' }}>点击进入详情</Text></TouchableOpacity><Text style={{ marginTop: 5 }}>详情通知来了:{this.state.content}</Text><Text style={{ marginTop: 15 }}>{this.testStore.listdata}</Text></View>);}}const styles = StyleSheet.create({container: {flex: 1,// justifyContent: 'center',// alignItems: 'center',padding: 5,backgroundColor: AppColors.dark9,},welcome: {fontSize: 20,textAlign: 'center',margin: 10,},instructions: {textAlign: 'center',color: '#333333',marginBottom: 5,},
});
//src/pages/center/index.js
/*** Sample React Native App* https://github.com/facebook/react-native* @flow*/import React, { Component } from 'react';
import {Platform,StyleSheet,Text,View,BackHandler,
} from 'react-native';
import { Toast } from 'teaset';export default class Index extends Component {static navigationOptions = ({ navigation }) => ({headerTitle: "中心",// header:null})// 构造constructor(props) {super(props);this.state = {};}componentWillMount() {}componentDidMount() {}render() {return (<View style={styles.container}><Text>中间</Text></View>);}}const styles = StyleSheet.create({container: {flex: 1,justifyContent: 'center',alignItems: 'center',backgroundColor: '#F5FCFF',},});
时时当勉励,好好加油~
转载于:https://www.cnblogs.com/smart-girl/p/10912091.html
【水滴石穿】ReactNativeMobxFrame相关推荐
- 做人晶莹剔透,做事水滴石穿
看了余世维的讲座,在最后的闭幕中,出现了这样的文字:做人晶莹剔透,做事水滴石穿.晶莹剔透意味着诚信光明,水滴石穿意味着用心坚持.让我心一惊,真是说得太对了.我要用他来鼓舞激励自己. 现在很多人都很虚伪 ...
- Redis 水滴石穿之(六)哨兵
Redis-水滴石穿之(六)哨兵 目录 Redis-水滴石穿之(六)哨兵 一.概述 二.哨兵应用 2.1.主从及哨兵配置 2.2.依次启动主.从.哨兵 2.3.主从节点验证 2.4.故障迁移演示 2. ...
- 水滴石穿、坚持不懈,必能有所精进
在跟随这门课程学习的过程中,我增长了很多大数据相关的知识,对于大数据技术和相关开源组件,也有了更深的了解.今天正好可以借着这个机会,来记录下自己的一点心得体会,也跟你分享一下我的学习思路,咱们一起聊一 ...
- 2.4 找准位置,水滴石穿
考试时的方法多数不是"灵机一动"现场创造出来的,而是平时刻苦训练中积累出来的. 俗话说得好,"水滴石穿",但"水滴未必石穿" ...
- Redis 水滴石穿之(四)持久化
Redis 水滴石穿之(四)持久化 目录 Redis 水滴石穿之(四)持久化 一.概述 二.RDB 1.RDB快照触发时机 1.1 手动触发 (save & bgsave) 1.2 自动触发 ...
- 不会-Redis 水滴石穿之(七)集群
Redis 水滴石穿之(七)集群 目录 Redis 水滴石穿之(七)集群 一.概述 二.集群搭建 2.1.手动搭建集群 1.修改配置文件 2.启动节点 3.节点握手 4.分配槽 5.指定主从关系 2. ...
- 期货开户水滴石穿知行合一
上千年来,人生价值一直都在改变,唯一没有改变的就是价值本身的规律.如果从另一个角度去观察,或许会有另外一番心境,有句老话叫做后生可畏,也许后生并不可畏,真正让人可畏可敬的或许是代表一个时代的思想和精神 ...
- 2022-1-14持之以恒,水滴石穿
1.读到曾文正公修身之难皆因无恒,刚过30的我深有体会,回想往事从幼时读书学习开始总是3分钟热度,学习总浮于表面,老师布置的作业草草了事,出社会参加工作后书倒是买了一大堆,每本书总是翻完几页又想去读其 ...
- 水滴石穿oracle之脚本安装
水滴石穿oracle之脚本安装 上一篇文章带领大家在redhat5.5上一步一步安装了oracle10g,并且详细讲解了每一步操作,图文并茂相信可以帮到一些有需要朋友! 成功动手搭建过一次的朋友们有没 ...
最新文章
- 【python进阶】_文件和目录操作
- python实现文件下载的方法总结
- server之后安装ssms失败 安装sql_关于SQL安装失败的解决方法
- 高可用高性能分布式文件系统FastDFS实践Java程序
- 深度学习:优化器工厂,各种优化器介绍,numpy实现深度学习(一)
- 逆向工程核心原理学习笔记(七):总结
- mysql 回表 覆盖索引_mysql 14 覆盖索引+回表
- python夹角余弦雷达图_P19 从三角形夹角计算看math模块
- 网页在兼容模式和急速模式下前者报错、后者正常的原因查找
- 一文读懂架构师都不知道的isinstance检查机制
- 给 WordPress 博客添加 Tabs 标签切换功能
- 同一计算机打印机无法连接,共享打印机无法连接怎么办 共享打印机无法连接解决方法【图文教程】...
- php赞空间,最新QQ空间免费代码大全(赞)
- 随机森林 OOB理解
- mac sierra mysql_Mac High Sierra一步搞定Mysql安装
- 【Angular】使用高德地图比例尺心得总结
- 一些 差分线的 线距 和 线宽
- 基于多种分隔符进行字符串的分割
- 配置CLion clang-format保存时自动格式化
- 概率统计·参数估计【矩估计、极大似然估计、无偏性、有效性、相合性】
热门文章
- English Learning - L2-7 英音地道语音语调 爆破音 [p] [b] [t] [d] [k] [g] 2023.03.13 周一
- SQL数据恢复总结 - sql server 2012数据库基础-数据恢复-实验报告
- 城市对照表---爬全国天气近10年天气用
- SMT和SMD的区别
- 如何避免碎片化知识的危害
- SMT集成电路板MES系统解决方案
- Android---使用-ContentProvider-无侵入获取-Context,flutter安装配置
- Java计算各种图形的周长、面积利用接口,多态等知识实现
- 在你自学计算机的路上,哪些书籍对你的帮助最大?
- 迷你计算机工作站,掌上的迷你工作站,便携笔记本电脑神奇小本MAG1评测