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

아래 레이아웃 1,2,3의 풀 코드

· 8년 전 · 890
아래에 올린 아이콘을 이용해서 만들어 본 최종 코드입니다. 아이폰 시뮬레이터에서는 안나와서 위의 링크에 아래 코드를 Copy & Paste를 해서 본 것입니다.




import React, { Component } from 'react';
import { Text, View, Image, StyleSheet, AppRegistry } from 'react-native';

class NavBar extends Component {
  render() {
    return (
      <View style={styles.navbar}>
        <Text style={styles.textColor}>더보기</Text>
      </View>
    )
  }
}
class UserComment extends Component {
  render () {
    return (
      <View style={{flex:1, flexDirection: 'row', margin: 3, backgroundColor: 'aqua', justifyContent: 'space-between', }}>
        <View style={{flex:1,  margin: 2, minWidth: 20,justifyContent: 'center', alignItems: 'center'}}>
          <Image source={{uri: this.props.imagesrc}} />
        </View>
        <View style={{flex:2, justifyContent: 'center',  margin: 3}}>
          <Text style={{paddingLeft: 5}}>{this.props.name}</Text>
        </View>
      </View>
    )
  }
}
class User extends Component {
  render() {
    return (
      <View style={styles.user}>
        <View style={{flex:2, flexDirection: 'row', margin: 3, backgroundColor: 'antiquewhite', justifyContent: 'space-around'}}>
          <View style={{flex:1, margin: 3, backgroundColor: 'aqua'}}>
            <View style={{flex:1,  margin: 2, minWidth: 60, justifyContent: 'center', alignItems: 'center', borderWidth: 1, borderRadius: 50, backgroundColor: 'white'}}>
            </View>
          </View>
          <View style={{flex:3, flexDirection: 'column', margin: 3, backgroundColor: 'aqua', justifyContent: 'flex-start'}}>
            <Text style={{ fontSize: 20, fontWeight: 'bold'}}>은애악</Text>
            <Text>강철 / g6lingp</Text>
            <Text>서울대 16학번</Text>
          </View>
        </View>
        <View style={{ flex:1, flexDirection: 'row', margin: 3, backgroundColor: 'bisque', justifyContent: 'space-around'}}>
          <UserComment imagesrc='http://sir.kr/data/editor/1611/bf64a50a11d0abb95b1fb8b21011b802_1479950536_4407.png' name='내가 쓴 글'/>
          <UserComment imagesrc='http://sir.kr/data/editor/1611/bf64a50a11d0abb95b1fb8b21011b802_1479950742_1528.png' name='댓글 단 글'/>
          <UserComment imagesrc='http://sir.kr/data/editor/1611/bf64a50a11d0abb95b1fb8b21011b802_1479950793_3841.png' name='스크랩'/>
        </View>
      </View>
    )
  }
}
class Button extends Component {
  render () {
    return (
      <View style={{flex: 1, flexDirection: 'column', borderWidth: 0.5}}>
        <View style={{flex:2,  margin: 2, minWidth: 20, justifyContent: 'center', alignItems: 'center'}}>
          <Image source={{uri: this.props.imagesrc}} />
        </View>
        <View style ={{flex:1, justifyContent: 'center', alignItems: 'center'}}>
          <Text>{this.props.name}</Text>
        </View>
      </View>
    )
  }
}
class ButtonGroup extends Component {
  render() {
    return (
      <View style={styles.buttongroup}>
        <View style={{flex:1, flexDirection: 'row', justifyContent: 'space-between'}}>
          <Button imagesrc='http://sir.kr/data/editor/1611/bf64a50a11d0abb95b1fb8b21011b802_1479950159_8211.png' name='강의평가'/>
          <Button imagesrc='http://sir.kr/data/editor/1611/bf64a50a11d0abb95b1fb8b21011b802_1479950181_0548.png' name='학점계산기'/>
        </View>
        <View style={{flex:1, flexDirection: 'row', justifyContent: 'space-between'}}>
          <Button imagesrc='http://sir.kr/data/editor/1611/bf64a50a11d0abb95b1fb8b21011b802_1479950160_3432.png' name='공지사항'/>
        </View>
      </View>
    )
  }
}
class Ads extends Component {
  render() {
    return (
      <View style={styles.ads}>
      </View>
    )
  }
}
class Taps extends Component {
  render() {
    return (
      <View style={styles.taps}>
      </View>
    )
  }
}

class gitbookTest extends Component {
  render() {
    return (
      <View style={styles.container}>
        <NavBar />
        <User />
        <ButtonGroup />
        <Ads />
        <Taps />

      </View>
    );
  }
}


const styles = StyleSheet.create({
  container: {
    flex: 1,
    flexDirection: 'column',
    justifyContent: 'space-between'
  },
  navbar: {
    height: 50,
    marginTop: 20,
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: 'orangered',
  },
  textColor: {
    color: 'white',
    fontSize: 20
  },
  user: {
    flex: 2,
    backgroundColor: 'darkturquoise'
  },
  buttongroup: {
    marginTop: 10,
    flex: 3,
    backgroundColor: 'lightgreen',
  },
  ads: {
    flex: 1,
    backgroundColor: 'lightblue',
  },
  taps: {
    flex: 1,
    backgroundColor: 'mediumpurple',
    flexDirection: 'row'
  }

});
AppRegistry.registerComponent('awesome', () => gitbookTest);

 

댓글 작성

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

로그인하기

게시글 목록

번호 제목
1327
1326
1325
1324
1323
1321
1320
1319
1316
1315
1314
1313
1312
1311
1310
1309
1308
1305
1304
1303
1302
1301
1300
1295
1294
1293
1287
1285
1283
1279