-
Notifications
You must be signed in to change notification settings - Fork 1
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
AYAN
committed
Nov 23, 2020
1 parent
70697ef
commit 4f5df4f
Showing
13 changed files
with
136 additions
and
15 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
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
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
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
67 changes: 67 additions & 0 deletions
67
src/components/react-native-messenger/KeyboardSpacer/KeyboardSpacer.js
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,67 @@ | ||
/* Used to manage keyboard spacing | ||
* NOTE: takes variance as optional prop to vary keyboard height if wanted. | ||
* View expands based on keyboard height. | ||
*/ | ||
import React, { Component } from 'react'; | ||
import { Keyboard, Animated } from 'react-native'; | ||
import PropTypes from 'prop-types'; | ||
import styles from './styles'; | ||
|
||
export default class KeyboardSpacer extends Component { | ||
constructor(props, context) { | ||
super(props, context); | ||
this.state = { | ||
keyboardHeight: 0 | ||
}; | ||
this.imageHeight = new Animated.Value(0); | ||
} | ||
|
||
componentDidMount() { | ||
this.keyboardDidShowListener = Keyboard.addListener( | ||
'keyboardWillShow', | ||
this.keyboardWillShow | ||
); | ||
this.keyboardDidHideListener = Keyboard.addListener( | ||
'keyboardWillHide', | ||
this.keyboardWillHide | ||
); | ||
} | ||
|
||
componentWillUnmount() { | ||
this.keyboardDidShowListener.remove(); | ||
this.keyboardDidHideListener.remove(); | ||
} | ||
|
||
keyboardWillShow = e => { | ||
Animated.timing(this.imageHeight, { | ||
duration: 240, | ||
toValue: e.endCoordinates.height | ||
}).start(); | ||
}; | ||
|
||
keyboardWillHide = () => { | ||
Animated.timing(this.imageHeight, { | ||
duration: 240, | ||
toValue: 0 | ||
}).start(); | ||
}; | ||
|
||
render() { | ||
return ( | ||
<Animated.View | ||
style={[ | ||
styles.wrapper, | ||
{ width: this.imageHeight, height: this.imageHeight } | ||
]} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
KeyboardSpacer.propTypes = { | ||
variance: PropTypes.number | ||
}; | ||
|
||
KeyboardSpacer.defaultProps = { | ||
variance: 0 | ||
}; |
2 changes: 2 additions & 0 deletions
2
src/components/react-native-messenger/KeyboardSpacer/index.js
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,2 @@ | ||
import KeyboardSpacer from './KeyboardSpacer'; | ||
export default KeyboardSpacer; |
7 changes: 7 additions & 0 deletions
7
src/components/react-native-messenger/KeyboardSpacer/styles.js
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,7 @@ | ||
import { StyleSheet } from 'react-native'; | ||
|
||
const styles = StyleSheet.create({ | ||
wrapper: {} | ||
}); | ||
|
||
export default styles; |
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
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
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,13 @@ | ||
/* | ||
* Will dynamically create reducers | ||
* enforcing a unique way to describe reducers | ||
*/ | ||
export default function createReducer(initialState, handlers) { | ||
return function reducer(state = initialState, action) { | ||
if (handlers.hasOwnProperty(action.type)) { | ||
return handlers[action.type](state, action); | ||
} else { | ||
return state; | ||
} | ||
}; | ||
} |
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,19 @@ | ||
import { Dimensions, Platform } from 'react-native'; | ||
|
||
export function isIphoneX() { | ||
let dimen = Dimensions.get('window'); | ||
return ( | ||
Platform.OS === 'ios' && | ||
!Platform.isPad && | ||
!Platform.isTVOS && | ||
(dimen.height === 812 || dimen.width === 812) | ||
); | ||
} | ||
|
||
export function ifIphoneX(iphoneXStyle, regularStyle) { | ||
if (isIphoneX()) { | ||
return iphoneXStyle; | ||
} else { | ||
return regularStyle; | ||
} | ||
} |
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
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