React-Native學習之制作RN版的微博app(一)

前面我們學習了react-native-router-flux硫眯,接下來我們將使用其搭建微博主界面

react_native_router_flux_使用詳解一.php

react_native_router_flux_使用詳解二.php

react_native_router_flux_使用詳解三.php

第一步先來個簡單的主頁面切換

先上效果圖:

源碼已上傳碼云:https://git.oschina.net/osczaizai/RNWeiBo

根據(jù)前面的學習考杉,我們在本項目中通過npm將react-native-router-flux安裝到RNWeibo中褥傍,

npm i react-native-router-flux --save

* Sample React Native App

* https://github.com/facebook/react-native

* @flow

*/

'use strict';

import React, {Component} from 'react';

import {

AppRegistry,

StyleSheet,

PixelRatio,

Dimensions,

Image,

Text,

View,

Platform

} from 'react-native';

import {

Scene,

Reducer,

Router,

Modal,

Actions,

ActionConst

}from'react-native-router-flux';

import HomeView from './pages/home';

import PublishView from './pages/publish';

import ProfileView from './pages/profile';

import MessageView from './pages/message';

import DiscroverView from './pages/discrover';

import TabIcon from './components/TabIcon';

import Error from './components/Error';

const px = 1 / PixelRatio.get();

const screentWidth = Dimensions.get('window').width;

const screentHeight = Dimensions.get('window').height;

var statusBarHeight = Platform.OS == 'android' ? 25 : 0;

var postButtonWidth = 40;

var postButtonHeight = 40;

var tabbarHeight = 60;

/**

* 包裝reducer構(gòu)造函數(shù)返回一個閉包

* @param params

* @returns {function(*=, *=)}

*/

const reducerCreate = (params) => {

const defaultReducer = new Reducer(params);

return (state, action) => {

console.log('ACTION:', action);

return defaultReducer(state, action);

}

};

/**

* 定義基本的樣式

* @param props

* @param computedProps

* @returns {{flex: number, backgroundColor: string, shadowColor: null, shadowOffset: null, shadowOpacity: null, shadowRadius: null}}

*/

const getSceneStyle = (props, computedProps) => {

const style = {

flex: 1,

backgroundColor: '#fff',

shadowColor: null,

shadowOffset: null,

shadowOpacity: null,

shadowRadius: null,

};

if (computedProps.isActive) {

console.log(computedProps)

style.marginTop = computedProps.hideNavBar ? 0 : 64;

style.marginBottom = computedProps.hideTabBar ? 0 : 50;

}

return style;

};

export default class RootView extends Component {

// 構(gòu)造

constructor(props) {

super(props);

// 初始狀態(tài)

this.state = {

selectedTab: 'home',

};

}

render() {

return (

component={Modal}>

key="main"

tabs={true}

hideNavBar={false}

tabBarStyle={styles.tabBarStyle}>

key="home"

title="Home title"

hideNavBar={false}

tabTitle="微博"

component={HomeView}

initial={true}

icon={TabIcon}

/>

key="message"

hideNavBar={false}

tabTitle="信息"

title="Message title"

component={MessageView}

icon={TabIcon}

/>

key="tabbarpublish"

tabTitle="發(fā)布"

title=" title"

component={PublishView}

icon={TabIcon}

/>

key="discrover"

tabTitle="發(fā)現(xiàn)"

hideNavBar={false}

title="Discrover title"

component={DiscroverView}

icon={TabIcon}

/>

key="profile"

title="Profile title"

tabTitle="我的"

hideNavBar={false}

component={ProfileView}

icon={TabIcon}

/>

);

}

}

const styles = StyleSheet.create({

container: {

flex: 1,

},

tab_image: {

height: 28,

width: 28,

},

tabBarStyle: {

borderTopWidth: 0.5,

borderColor: '#b7b7b7',

backgroundColor: 'white',

opacity: 1

},

post: {

width: postButtonWidth,

height: postButtonHeight,

backgroundColor: 'red',

top: screentHeight - tabbarHeight - statusBarHeight + ((tabbarHeight - postButtonHeight) / 2),

left: (screentWidth - postButtonWidth) / 2,

position: 'absolute',

},

instructions: {

textAlign: 'center',

color: '#333333',

marginBottom: 5

}

});

后面將繼續(xù)學習RN技術(shù)孕惜,歡迎一起探討學習

React_Native學習之制作RN版的微博app二.php

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末填大,一起剝皮案震驚了整個濱河市脊凰,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌箭券,老刑警劉巖偏塞,帶你破解...
    沈念sama閱讀 219,039評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異邦鲫,居然都是意外死亡,警方通過查閱死者的電腦和手機神汹,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,426評論 3 395
  • 文/潘曉璐 我一進店門庆捺,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人屁魏,你說我怎么就攤上這事滔以。” “怎么了氓拼?”我有些...
    開封第一講書人閱讀 165,417評論 0 356
  • 文/不壞的土叔 我叫張陵你画,是天一觀的道長抵碟。 經(jīng)常有香客問我,道長坏匪,這世上最難降的妖魔是什么拟逮? 我笑而不...
    開封第一講書人閱讀 58,868評論 1 295
  • 正文 為了忘掉前任,我火速辦了婚禮适滓,結(jié)果婚禮上敦迄,老公的妹妹穿的比我還像新娘。我一直安慰自己凭迹,他們只是感情好罚屋,可當我...
    茶點故事閱讀 67,892評論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著嗅绸,像睡著了一般脾猛。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上鱼鸠,一...
    開封第一講書人閱讀 51,692評論 1 305
  • 那天猛拴,我揣著相機與錄音,去河邊找鬼瞧柔。 笑死漆弄,一個胖子當著我的面吹牛,可吹牛的內(nèi)容都是我干的造锅。 我是一名探鬼主播撼唾,決...
    沈念sama閱讀 40,416評論 3 419
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼哥蔚!你這毒婦竟也來了倒谷?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,326評論 0 276
  • 序言:老撾萬榮一對情侶失蹤糙箍,失蹤者是張志新(化名)和其女友劉穎渤愁,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體深夯,經(jīng)...
    沈念sama閱讀 45,782評論 1 316
  • 正文 獨居荒郊野嶺守林人離奇死亡抖格,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,957評論 3 337
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了咕晋。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片雹拄。...
    茶點故事閱讀 40,102評論 1 350
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖掌呜,靈堂內(nèi)的尸體忽然破棺而出滓玖,到底是詐尸還是另有隱情,我是刑警寧澤质蕉,帶...
    沈念sama閱讀 35,790評論 5 346
  • 正文 年R本政府宣布势篡,位于F島的核電站翩肌,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏禁悠。R本人自食惡果不足惜念祭,卻給世界環(huán)境...
    茶點故事閱讀 41,442評論 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望绷蹲。 院中可真熱鬧棒卷,春花似錦、人聲如沸祝钢。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,996評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽拦英。三九已至蜒什,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間疤估,已是汗流浹背灾常。 一陣腳步聲響...
    開封第一講書人閱讀 33,113評論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留铃拇,地道東北人钞瀑。 一個月前我還...
    沈念sama閱讀 48,332評論 3 373
  • 正文 我出身青樓,卻偏偏與公主長得像慷荔,于是被迫代替她去往敵國和親雕什。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 45,044評論 2 355

推薦閱讀更多精彩內(nèi)容