테스트 사이트 - 개발 중인 베타 버전입니다

네비게이션 만들기

· 8년 전 · 2796

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을 다운로드 해서 사용합니다.

 

[code]

git clone https://github.com/wix/react-native-navigation-bootstrap.git redshop

[/code]

 

아래에서 vi package.json 으로 최신 버전의 react(15.4.1)와 react-native(0.39.2)로 변경

 

[code]

cd redshop

vi package.json

npm install

react-native run-ios

[/code]

 

다음과 같은 화면이 나오면 성공입니다.

 


[code]

atom .

[/code]

에디터로 오픈합니다.

 

[code]

Navigation.registerComponent('react-native-navigation-bootstrap', () => react_native_navigation_bootstrap);

Navigation.startSingleScreenApp({

  screen: {

    screen: 'react-native-navigation-bootstrap',

    title: 'Navigation Bootstrap'

  }

});

[/code]

 

Navigation.startSingleScreenApp으로 되어 있습니다.

 

여기에 Drawer를 추가해 볼까요?

 

screens라는 디렉토리를 만들고

index.js 파일과

[code]

import { Navigation } from 'react-native-navigation';

 

import SideMenu from './SideMenu';

 

export function registerScreens() {

  Navigation.registerComponent('redshop.SideMenu', () => SideMenu);

}

[/code]

SideMenu.js

[code]

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,
  },
});

[/code]

를 만들고

 

index.ios.js 파일의 상단 import react-native아래에 

[code]

import { registerScreens } from './screens';

registerScreens();

[/code]

 

startSingleScreenApp안의 screen아래에

[code]

drawer: {

left: {

screen: 'redshop.SideMenu'

}

}

[/code]

 

Redshop Theme 왼쪽을 클릭해서 옆으로 밀면 아래와 같은 화면이 나옵니다.


 

 

 

 

 

 

 

 

 

 

 

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

게시판 목록

앱개발

글쓰기
🐛 버그신고