diff --git a/src/components/SearchInput.jsx b/src/components/SearchInput.jsx
index 447a9fd..a2bb252 100644
--- a/src/components/SearchInput.jsx
+++ b/src/components/SearchInput.jsx
@@ -3,68 +3,161 @@ import PropTypes from 'prop-types'
import {
ViewPropTypes,
StyleSheet,
- Text,
+ Animated,
View,
TouchableOpacity,
+ Easing,
} from 'react-native'
-import TextInput from './TextInput'
+import TextInput from "./TextInput";
// Theme
import theme from '../theme'
const { colors } = theme
+const SEARCH_SHRINK_WIDTH = 375 - 65;
+
const styles = StyleSheet.create({
searchContainer: {
flexDirection: 'row',
alignItems: 'center',
- flexWrap: 'wrap',
+ justifyContent: 'center',
+
+ },
+ searchInputContainer: {
+ backgroundColor: colors.main.lightGrey.rgb,
+ flex: 1,
+ flexDirection: 'row',
+ alignItems: 'center',
justifyContent: 'center',
borderRadius: 8,
- marginVertical: 16,
- marginHorizontal: 16,
- height: 36,
},
search: {
- flex: 1,
- paddingLeft: 8,
backgroundColor: colors.main.lightGrey.rgb,
- fontWeight: '400',
+ flex: 1,
+ flexDirection: 'row',
+ alignItems: 'center',
+ justifyContent: 'center',
+ borderRadius: 8,
+ },
+ searchIcon: {
+ marginRight: 4,
+ height: 24,
+ width: 24,
+ },
+ cancelSearch: {
+ flex: 1,
+ position: "absolute",
+ marginHorizontal: 16,
+ textAlign: "center",
+ justifyContent: "center",
+ alignSelf: "center"
+ },
+ cancelSearchText: {
+ flex: 1,
+ backgroundColor: colors.main.white.rgb,
+ color: colors.main.accentBlue.rgb,
+ marginLeft: 16,
+ fontFamily: "Inter",
fontSize: 15,
lineHeight: '140%',
- marginVertical: 10,
+ textAlign: "center",
+ },
+ closeIcon: {
+ height: 16,
+ width: 16,
+ marginRight: 30
},
})
class SearchInput extends TextInput {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ inputLength: new Animated.Value(410),
+ cancelPosition: new Animated.Value(0),
+ opacity: new Animated.Value(0),
+ searchBarFocused: false,
+ };
+ }
+
+ onFocus = () => {
+ Animated.parallel([
+ Animated.timing(this.state.inputLength, {
+ toValue: SEARCH_SHRINK_WIDTH,
+ duration: 350,
+ easing: Easing.quad,
+ }),
+ Animated.timing(this.state.cancelPosition, {
+ toValue: 16,
+ duration: 350
+ }),
+ Animated.timing(this.state.opacity, {
+ toValue: 1,
+ duration: 350
+ })
+ ]).start();
+ }
+
+ onBlur = () => {
+ Animated.parallel([
+ Animated.timing(this.state.inputLength, {
+ toValue: 410,
+ duration: 350,
+ easing: Easing.quad
+ }),
+ Animated.timing(this.state.cancelPosition, {
+ toValue: 0,
+ duration: 350
+ }),
+ Animated.timing(this.state.opacity, {
+ toValue: 0,
+ duration: 350
+ })
+ ]).start();
+
+ };
+
render() {
- const { text } = this.props
+ const { text, } = this.props
return (
-
-
-
- console.log('Pressed')}
- >
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+ Cancel
+
+
)
}
}
SearchInput.propTypes = {
- text: PropTypes.string,
+ text: PropTypes.string
}
export default SearchInput
diff --git a/src/components/TextInput.jsx b/src/components/TextInput.jsx
index 4ef57d8..d8d0a8a 100644
--- a/src/components/TextInput.jsx
+++ b/src/components/TextInput.jsx
@@ -17,35 +17,49 @@ const { colors } = theme
const styles = StyleSheet.create({
label: {
- fontSize: 14,
+ position: 'relative',
+ alignItems: 'center',
+ display: 'flex',
fontFamily: 'Inter UI',
- paddingBottom: 8,
+ fontSize: 15,
+ fontStyle: 'normal',
+ fontWeight: 'normal',
+ width: 343,
+ top: 12,
+ height: 26,
+
},
inputContainer: {
- paddingTop: 8,
- padding: 16,
+ flex: 1,
justifyContent: 'center',
+ alignItems: 'center',
+ },
+ inputTouch: {
+ alignItems: 'center',
+ flexDirection: 'column',
backgroundColor: colors.main.white.rgb,
- marginVertical: 16,
- marginHorizontal: 16,
- borderRadius: 8,
},
input: {
- padding: 0,
+ position: 'relative',
backgroundColor: colors.main.lightGrey.rgb,
+ borderRadius: 8,
+ marginHorizontal: 16,
+ marginVertical: 16,
minHeight: 52,
overflowY: 'auto',
width: 343,
+ height: 52,
},
// error: {
// color: colors.main.red.rgb,
// },
text: {
- fontWeight: 'normal',
- fontStyle: 'normal',
- fontSize: 15,
fontFamily: 'Inter UI',
+ fontSize: 15,
+ fontStyle: 'normal',
+ fontWeight: 'normal',
lineHeight: 22,
+ padding: 16,
},
})
@@ -58,51 +72,76 @@ class TextInput extends React.Component {
}
render() {
- const { label, error, text, multiLine, autoFocus } = this.props
+ const { container, autoFocus, error, labeltext, labelishidden, text, textarea } = this.props
- return (
-
-
-
- {label}
-
+ function renderLabel() {
+ if(labelishidden == true) {
+ return null;
+ } else {
+ return {labeltext}
+ }
+ }
+ if(textarea == true) {
+ return (
+
console.log('Pressed')}
- >
+ style={[styles.inputTouch]}>
+ {renderLabel()}
{
- if(this.state.height <= 160) {
+ if(this.state.height <= 202) {
this.setState({height: event.nativeEvent.contentSize.height})
}
}}
- placeholderTextColor={'gray'}
- multiline={multiLine}
- style={[styles.input, styles.text, {minHeight: Math.max(52, this.state.height)}]}
- autoFocus={autoFocus}
autoCapitalize={'none'}
+ autoFocus={autoFocus}
+ multiline={true}
+ placeholderTextColor={'gray'}
+ style={[styles.input, styles.text, {minHeight: Math.max(95, this.state.height)}]}
value={text}
/>
-
-
-
- )
+
+
+
+ )
+ } else {
+ return (
+
+
+ {renderLabel()}
+
+
+
+
+ )
+ }
}
}
TextInput.propTypes = {
- label: PropTypes.string,
- error: PropTypes.bool,
- text: PropTypes.string,
- maxNumOfLines: PropTypes.number,
- multiLine: PropTypes.bool,
autoFocus: PropTypes.bool,
+ error: PropTypes.bool,
+ labeltext: PropTypes.string,
+ labelishidden: PropTypes.bool,
+ maxNumOfLines: PropTypes.number,
+ text: PropTypes.string,
}
TextInput.defaultTypes = {
- multiLine: false,
- autoFocus: true,
+ autoFocus: false,
+ labelishidden: false,
}
export default TextInput
diff --git a/src/stories/index.js b/src/stories/index.js
index cfe0722..9d5d8ba 100644
--- a/src/stories/index.js
+++ b/src/stories/index.js
@@ -7,7 +7,7 @@ import 'typeface-roboto'
// Components
import Button from '../components/Button'
-import TextInput from '../components/TextInput'
+import TextInput from "../components/TextInput"
import SearchInput from '../components/SearchInput'
// Style Guide
@@ -37,30 +37,23 @@ storiesOf('Theming', module)
storiesOf('TextInput', module)
.add('Text Input', () => (
-
-
-
+
))
.add('Text Area', () => (
-
-
))
.add('Search Input', () => (
-
))