forked from nathvarun/React-Native-Layout-Tutorial-Series
-
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.
15. Udemy Searchbar Animation Project Files Added
- Loading branch information
Showing
5 changed files
with
119 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,74 @@ | ||
import React, { Component } from "react"; | ||
import { | ||
View, | ||
Text, | ||
StyleSheet, | ||
TextInput, | ||
FlatList, | ||
Keyboard | ||
} from "react-native"; | ||
|
||
import * as Animatable from 'react-native-animatable' | ||
|
||
const listItems = ['Development', 'Business', 'IT & Software', 'Office Productivity', 'Personal Development', 'Design', 'Marketing', 'LifeStyle', 'Photography', 'Health & Fitness', 'Teacher Training', 'Music'] | ||
|
||
|
||
import Icon from 'react-native-vector-icons/Ionicons' | ||
class App extends Component { | ||
|
||
state = { | ||
searchBarFocused: false | ||
} | ||
|
||
componentDidMount() { | ||
this.keyboardDidShow = Keyboard.addListener('keyboardDidShow', this.keyboardDidShow) | ||
this.keyboardWillShow = Keyboard.addListener('keyboardWillShow', this.keyboardWillShow) | ||
this.keyboardWillHide = Keyboard.addListener('keyboardWillHide', this.keyboardWillHide) | ||
|
||
|
||
} | ||
|
||
keyboardDidShow = () => { | ||
this.setState({ searchBarFocused: true }) | ||
} | ||
|
||
keyboardWillShow = () => { | ||
this.setState({ searchBarFocused: true }) | ||
} | ||
|
||
keyboardWillHide = () => { | ||
this.setState({ searchBarFocused: false }) | ||
} | ||
render() { | ||
return ( | ||
<View style={{ flex: 1 }}> | ||
<View style={{ height: 80, backgroundColor: '#c45653', justifyContent: 'center', paddingHorizontal: 5 }}> | ||
|
||
<Animatable.View animation="slideInRight" duration={500} style={{ height: 50, backgroundColor: 'white', flexDirection: 'row', padding: 5, alignItems: 'center' }}> | ||
<Animatable.View animation={this.state.searchBarFocused ? "fadeInLeft" : "fadeInRight"} duration={400}> | ||
<Icon name={this.state.searchBarFocused ? "md-arrow-back" : "ios-search"} style={{ fontSize: 24 }} /> | ||
</Animatable.View> | ||
<TextInput placeholder="Search" style={{ fontSize: 24, marginLeft: 15, flex: 1 }} /> | ||
</Animatable.View> | ||
|
||
</View> | ||
|
||
<FlatList | ||
style={{ backgroundColor: this.state.searchBarFocused ? 'rgba(0,0,0,0.3)' : 'white' }} | ||
data={listItems} | ||
renderItem={({ item }) => <Text style={{ padding: 20, fontSize: 20 }}>{item}</Text>} | ||
keyExtractor={(item, index) => index.toString()} | ||
/> | ||
</View> | ||
); | ||
} | ||
} | ||
export default App; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
alignItems: 'center', | ||
justifyContent: 'center' | ||
} | ||
}); |
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,27 @@ | ||
{ | ||
"expo": { | ||
"name": "udemy-ui", | ||
"description": "This project is really great.", | ||
"slug": "udemy-ui", | ||
"privacy": "public", | ||
"sdkVersion": "30.0.0", | ||
"platforms": ["ios", "android"], | ||
"version": "1.0.0", | ||
"orientation": "portrait", | ||
"icon": "./assets/icon.png", | ||
"splash": { | ||
"image": "./assets/splash.png", | ||
"resizeMode": "contain", | ||
"backgroundColor": "#ffffff" | ||
}, | ||
"updates": { | ||
"fallbackToCacheTimeout": 0 | ||
}, | ||
"assetBundlePatterns": [ | ||
"**/*" | ||
], | ||
"ios": { | ||
"supportsTablet": true | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,18 @@ | ||
{ | ||
"name": "empty-project-template", | ||
"main": "node_modules/expo/AppEntry.js", | ||
"private": true, | ||
"scripts": { | ||
"start": "expo start", | ||
"android": "expo start --android", | ||
"ios": "expo start --ios", | ||
"eject": "expo eject" | ||
}, | ||
"dependencies": { | ||
"expo": "^30.0.1", | ||
"react": "16.3.1", | ||
"react-native": "https://github.com/expo/react-native/archive/sdk-30.0.0.tar.gz", | ||
"react-native-animatable": "^1.3.0", | ||
"react-native-vector-icons": "^6.0.2" | ||
} | ||
} |