forked from GeekyAnts/NativeBase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Himanshu Satija
authored and
Himanshu Satija
committed
Apr 25, 2016
1 parent
b06d6d9
commit 9f9d1ff
Showing
4 changed files
with
226 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* @flow */ | ||
'use strict'; | ||
|
||
import React from 'react-native'; | ||
import NativeBaseComponent from '../Base/NativeBaseComponent'; | ||
import _ from 'lodash'; | ||
import computeProps from '../../Utils/computeProps'; | ||
import Icon from 'react-native-vector-icons/Ionicons'; | ||
|
||
export default class IconNB extends NativeBaseComponent { | ||
|
||
getInitialStyle() { | ||
return { | ||
icon: { | ||
fontSize: 27, | ||
color: 'white' | ||
} | ||
} | ||
} | ||
prepareRootProps() { | ||
var defaultProps = { | ||
style: this.getInitialStyle().icon | ||
}; | ||
|
||
console.log(computeProps(this.props, defaultProps)); | ||
|
||
return computeProps(this.props, defaultProps); | ||
|
||
} | ||
|
||
render() { | ||
return( | ||
<Icon {...this.prepareRootProps()}/> | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* @flow */ | ||
'use strict'; | ||
|
||
import React, {View, Text} from 'react-native'; | ||
import Title from './Title'; | ||
import NativeBaseComponent from '../Base/NativeBaseComponent'; | ||
import _ from 'lodash'; | ||
import computeProps from '../../Utils/computeProps'; | ||
|
||
export default class ListNB extends NativeBaseComponent { | ||
|
||
getInitialStyle() { | ||
return { | ||
list: { | ||
|
||
}, | ||
insetList: { | ||
borderWidth: 1, | ||
borderRadius: 8 | ||
} | ||
} | ||
} | ||
|
||
prepareRootProps() { | ||
|
||
var defaultProps = { | ||
style: this.props.inset ? this.getInitialStyle().insetList : this.getInitialStyle().list | ||
}; | ||
|
||
return computeProps(this.props, defaultProps); | ||
|
||
} | ||
|
||
render() { | ||
return( | ||
<View {...this.prepareRootProps()} > | ||
{this.props.children} | ||
</View> | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* @flow */ | ||
'use strict'; | ||
|
||
import React from 'react-native'; | ||
import NativeBaseComponent from '../Base/NativeBaseComponent'; | ||
import _ from 'lodash'; | ||
import computeProps from '../../Utils/computeProps'; | ||
import Icon from './Icon'; | ||
import Text from './Text'; | ||
import View from './View'; | ||
import Button from './Button'; | ||
|
||
export default class ListItemNB extends NativeBaseComponent { | ||
|
||
getInitialStyle() { | ||
return { | ||
listItem: { | ||
borderBottomWidth: 1, | ||
padding: 7 | ||
}, | ||
listItemDivider: { | ||
borderBottomWidth: 1, | ||
padding: 7, | ||
backgroundColor: '#ddd' | ||
}, | ||
itemText: { | ||
fontSize: 25 | ||
}, | ||
itemIcon: { | ||
fontSize: 25, | ||
color: 'black' | ||
}, | ||
itemButton: { | ||
width: 50 | ||
}, | ||
itemNote: { | ||
fontSize: 15, | ||
color: '#999' | ||
} | ||
} | ||
} | ||
|
||
getChildStyle(child) { | ||
var mergedStyle = {}; | ||
if(child.type == Icon) { | ||
return _.merge(mergedStyle, this.getInitialStyle().itemIcon, child.props.style); | ||
} | ||
|
||
else if(child.type == Text) { | ||
if(child.props.note) | ||
return _.merge(mergedStyle, this.getInitialStyle().itemNote, child.props.style); | ||
else | ||
return _.merge(mergedStyle, this.getInitialStyle().itemText, child.props.style); | ||
} | ||
|
||
else if(child.type == Button) { | ||
return _.merge(mergedStyle, this.getInitialStyle().itemButton, child.props.style); | ||
} | ||
|
||
else | ||
return child.props.style; | ||
} | ||
|
||
prepareRootProps() { | ||
if(this.props.itemDivider) | ||
var defaultProps = { | ||
style: this.getInitialStyle().listItemDivider | ||
}; | ||
else | ||
var defaultProps = { | ||
style: this.getInitialStyle().listItem | ||
}; | ||
|
||
console.log(computeProps(this.props, defaultProps)); | ||
|
||
return computeProps(this.props, defaultProps); | ||
|
||
} | ||
|
||
renderChildren() { | ||
var newChildren = React.Children.map(this.props.children, (child) => { | ||
return React.cloneElement(child, {style: this.getChildStyle(child)}) | ||
}); | ||
|
||
console.log(newChildren); | ||
|
||
return newChildren; | ||
} | ||
|
||
render() { | ||
return( | ||
<View {...this.prepareRootProps()} > | ||
{this.renderChildren()} | ||
</View> | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* @flow */ | ||
'use strict'; | ||
|
||
import React, {Image, View} from 'react-native'; | ||
import NativeBaseComponent from '../Base/NativeBaseComponent'; | ||
import _ from 'lodash'; | ||
import computeProps from '../../Utils/computeProps'; | ||
|
||
export default class ThumbnailNB extends NativeBaseComponent { | ||
|
||
getInitialStyle() { | ||
return { | ||
thumbnail: { | ||
borderRadius: 15, | ||
width: 30, | ||
height: 30 | ||
} | ||
} | ||
} | ||
prepareRootProps() { | ||
var thumbnailStyle = {}; | ||
if(this.props.circular) { | ||
thumbnailStyle.width = this.props.size; | ||
thumbnailStyle.height = this.props.size; | ||
thumbnailStyle.borderRadius = this.props.size/2; | ||
} | ||
else if(this.props.square) { | ||
thumbnailStyle.width = this.props.size; | ||
thumbnailStyle.height = this.props.size; | ||
thumbnailStyle.borderRadius = 0; | ||
} | ||
|
||
var defaultProps = { | ||
style: _.merge(this.getInitialStyle().thumbnail, thumbnailStyle) | ||
}; | ||
|
||
console.log(computeProps(this.props, defaultProps)); | ||
|
||
return computeProps(this.props, defaultProps); | ||
|
||
} | ||
|
||
render() { | ||
return( | ||
<Image {...this.prepareRootProps()}/> | ||
); | ||
} | ||
|
||
} |