Skip to content

Instantly share code, notes, and snippets.

@irisAsh
Created September 23, 2017 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save irisAsh/bc9255ad906a90e6847ec034f9598f96 to your computer and use it in GitHub Desktop.
Save irisAsh/bc9255ad906a90e6847ec034f9598f96 to your computer and use it in GitHub Desktop.
React Native Elementsの使い方(No.2)
import React, { Component } from 'react'
import {
ScrollView,
View,
} from 'react-native'
import { List, ListItem } from 'react-native-elements'
import { networkData, generalData } from './config/menuData'
export default class MenuList extends Component {
constructor(props) {
super(props)
}
render() {
return (
<View style={{flex: 1}}>
<ScrollView
automaticallyAdjustContentInsets={false}
>
{this.renderMenuItems(generalData)}
{this.renderMenuItems(networkData)}
</ScrollView>
</View>
)
}
renderMenuItems = (menuData) => {
return (
<List>
{
menuData.map((item, i) => (
<ListItem
{...item}
key={i}
onPress={!!item.navigateScreen ? () => this.props.navigation.navigate(item.navigateScreen) : null}
/>
))
}
</List>
)
}
}
export const networkData = [
{
title: '機内モード',
hideChevron: true,
leftIcon: {
name: 'airplanemode-active',
},
},
{
title: 'Wi-Fi',
hideChevron: true,
leftIcon: {
name: 'wifi-tethering',
color: '#7EDDFF',
},
},
{
title: 'Bluetooth',
hideChevron: true,
leftIcon: {
name: 'ios-bluetooth',
color: '#3A57FF',
type: 'ionicon',
},
},
{
title: 'データ通信',
hideChevron: true,
leftIcon: {
name: 'access-point',
color: 'white',
type: 'material-community',
style: {
backgroundColor: '#1CEC26',
},
},
},
]
export const generalData = [
{
title: '通知',
leftIcon: {
name: 'bell-ring',
type: 'material-community',
color: '#FF4290',
},
navigateScreen: 'NoticeMenu',
},
{
title: '画面表示と明るさ',
leftIcon: {
name: 'tablet-ipad',
color: 'white',
type: 'material-community',
style: {
padding: 2,
backgroundColor: 'blue',
},
},
navigateScreen: 'DisplayMenu',
},
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment