Skip to content

Commit 0b6ab25

Browse files
Himanshu SatijaHimanshu Satija
authored andcommitted
fix input group
1 parent 799c221 commit 0b6ab25

4 files changed

Lines changed: 17 additions & 63 deletions

File tree

Components/Widgets/Button.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ export default class Button extends NativeBaseComponent {
9797

9898
else if(Array.isArray(this.props.children)) {
9999
console.log(this.props.children[0].type, this.props.children[1].type);
100-
if(this.props.children[0] && this.props.children[0].type == undefined || typeof this.props.children == "string")
100+
if(this.props.children[0] && (typeof this.props.children[0] == "string" || this.props.children[0].type == undefined))
101101
return <TouchableOpacity {...this.prepareRootProps()} >
102102
<Text style={this.getTextStyle()}>{this.props.children[0]}</Text>
103103
<View>
104104
{this.props.children[1]}
105105
</View>
106106
</TouchableOpacity>
107107

108-
else if(this.props.children[1] && this.props.children[1].type == undefined || typeof this.props.children == "string")
108+
else if(this.props.children[1] && (typeof this.props.children[1] == "string" || this.props.children[1].type == undefined))
109109
return <TouchableOpacity {...this.prepareRootProps()} >
110110
<View>
111111
{this.props.children[0]}

Components/Widgets/Input.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
'use strict';
33

44
import React, {Component, Text, View, TextInput } from 'react-native';
5+
import NativeBaseComponent from '../Base/NativeBaseComponent';
56
import {brandPrimary as primary} from '../Styles/variable';
67
import Icon from 'react-native-vector-icons/Ionicons';
78
import bootstrap from '../Styles/bootstrap';
89
import computeProps from '../../Utils/computeProps';
910

10-
export default class Input extends Component {
11+
export default class Input extends NativeBaseComponent {
1112

1213
getInitialStyle() {
1314
return {
@@ -34,7 +35,9 @@ export default class Input extends Component {
3435
render() {
3536

3637
return (
38+
<View>
3739
<TextInput {...this.prepareRootProps()} />
40+
</View>
3841
);
3942
}
4043

Components/Widgets/InputGroup.js

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ import Icon from 'react-native-vector-icons/Ionicons';
77
import _ from 'lodash';
88
import computeProps from '../../Utils/computeProps';
99
import Input from './Input';
10-
import InputLabel from './InputLabel';
1110

1211

13-
export default class IconInput extends NativeBaseComponent {
12+
export default class InputGroup extends NativeBaseComponent {
1413

1514
getInitialStyle() {
1615
return {
1716
textInput: {
1817
height: 40,
1918
backgroundColor: 'transparent',
19+
width: 20
2020
},
2121
outerBorder: {
2222
position:'relative',
@@ -68,29 +68,21 @@ export default class IconInput extends NativeBaseComponent {
6868
(this.props.children.type == Icon) ? this.getTheme().inputPaddingLeftIcon : this.getTheme().inputPaddingLeft
6969
}
7070

71+
var defaultStyle = (this.props.borderType === 'regular') ? this.getInitialStyle().bordered : (this.props.borderType === 'rounded') ? this.getInitialStyle().rounded : this.getInitialStyle().underline;
72+
73+
type = _.merge(type, defaultStyle);
7174

72-
var addedProps = _.merge(this.getInitialStyle().textInput,type);
75+
var addedProps = _.merge(this.getInitialStyle().textInput, type);
7376

7477
var defaultProps = {
7578
style: addedProps
7679
}
7780

78-
console.log("input style", computeProps(this.props, defaultProps));
81+
console.log("input group style", computeProps(this.props, defaultProps));
7982

8083
return computeProps(this.props, defaultProps);
8184

8285
}
83-
renderLabel() {
84-
if(!Array.isArray(this.props.children) && this.props.children.type == InputLabel)
85-
return this.props.children;
86-
87-
else
88-
return _.find(this.props.children, function(item) {
89-
if(item && item.type == InputLabel) {
90-
return true;
91-
}
92-
});
93-
}
9486

9587
renderIcon() {
9688
if(!Array.isArray(this.props.children) && this.props.children.type == Icon)
@@ -105,7 +97,7 @@ export default class IconInput extends NativeBaseComponent {
10597
}
10698

10799
renderInput() {
108-
if(!Array.isArray(this.props.children) && this.props.children.type == Input) {
100+
if(!Array.isArray(this.props.children) && this.props.children.type == undefined) {
109101
console.log(11111);
110102
var inputProps = {};
111103

@@ -117,7 +109,7 @@ export default class IconInput extends NativeBaseComponent {
117109
else {
118110
console.log(2222);
119111
var inp = _.find(this.props.children, function(item) {
120-
if(item && item.type == Input) {
112+
if(item && item.type == undefined) {
121113
return true;
122114
}
123115
});
@@ -136,10 +128,9 @@ export default class IconInput extends NativeBaseComponent {
136128

137129
render() {
138130
return (
139-
<View {...this.prepareRootProps()} style={[(this.props.borderType === 'regular') ? this.getInitialStyle().bordered : (this.props.borderType === 'rounded') ? this.getInitialStyle().rounded : this.getInitialStyle().underline]} >
131+
<View {...this.prepareRootProps()} >
140132

141-
{this.renderIcon()}
142-
{this.renderLabel()}
133+
<Text>{this.renderIcon()}</Text>
143134
{this.renderInput()}
144135
</View>
145136
);

Components/Widgets/InputLabel.js

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)