네비게이션 만들기 정보
네비게이션 만들기
본문
http://sir.kr/yc5_theme/513 redshp은 이미 basic용으로 만들고 있어서 macaroon을 사용합니다.
https://github.com/wix/react-native-navigation 를 메인으로 사용합니다.
현재 실험 2.0이지만, 곧 2.0버전이 릴리스 되면, 아마도 react-native메인에서 합칠 것도 같습니다.
먼저 react-native-navigation을 사용하려면 bootstrap을 다운로드 해서 사용합니다.
git clone https://github.com/wix/react-native-navigation-bootstrap.git redshop
아래에서 vi package.json 으로 최신 버전의 react(15.4.1)와 react-native(0.39.2)로 변경
cd redshop
vi package.json
npm install
react-native run-ios
다음과 같은 화면이 나오면 성공입니다.

atom .
에디터로 오픈합니다.
Navigation.registerComponent('react-native-navigation-bootstrap', () => react_native_navigation_bootstrap);
Navigation.startSingleScreenApp({
screen: {
screen: 'react-native-navigation-bootstrap',
title: 'Navigation Bootstrap'
}
});
Navigation.startSingleScreenApp으로 되어 있습니다.
여기에 Drawer를 추가해 볼까요?
screens라는 디렉토리를 만들고
index.js 파일과
import { Navigation } from 'react-native-navigation';
import SideMenu from './SideMenu';
export function registerScreens() {
Navigation.registerComponent('redshop.SideMenu', () => SideMenu);
}
SideMenu.js
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
export default class SideMenuScreen extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started, edit index.ios.js
</Text>
<Text style={styles.instructions}>
Press Cmd+R to reload,{'\n'}
Cmd+D or shake for dev menu
</Text>
</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,
},
});
를 만들고
index.ios.js 파일의 상단 import react-native아래에
import { registerScreens } from './screens';
registerScreens();
startSingleScreenApp안의 screen아래에
drawer: {
left: {
screen: 'redshop.SideMenu'
}
}
Redshop Theme 왼쪽을 클릭해서 옆으로 밀면 아래와 같은 화면이 나옵니다.
!-->!-->!-->!-->!-->!-->!-->!-->
공감
1
1
댓글 0개