Skip to content

Commit

Permalink
some fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
AYAN committed Nov 23, 2020
1 parent 70697ef commit 4f5df4f
Show file tree
Hide file tree
Showing 13 changed files with 136 additions and 15 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"expo-status-bar": "~1.0.2",
"expo-updates": "~0.3.2",
"moment": "^2.29.1",
"prop-types": "^15.7.2",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-native": "~0.63.3",
Expand Down
7 changes: 5 additions & 2 deletions src/components/GroupsList/GroupsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ const data = [
];

export default class GroupsList extends Component {
renderItem = ({ item }) => {
return <GroupsItem item={item} />;


renderItem = ({ item}) => {
return <GroupsItem item={item}/>;
};


render() {
return (
<FlatList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from 'react';
import { View, TextInput, Keyboard, Platform } from 'react-native';
import { TouchableRipple } from 'react-native-paper';
import Icon from 'react-native-vector-icons/MaterialIcons';
import AppStyles from 'src/config/styles';
import AppStyles from '../../../config/styles';
import styles from './styles';

export default class InputModule extends Component {
Expand Down
6 changes: 3 additions & 3 deletions src/components/react-native-messenger/InputModule/styles.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { StyleSheet } from 'react-native';
import Metrics from 'src/config/metrics';
import AppStyles from 'src/config/styles';
import { isIphoneX } from 'src/lib/isIphoneX';
import Metrics from '../../../config/metrics';
import AppStyles from '../../../config/styles';
import { isIphoneX } from '../../../lib/isIphoneX';

const styles = StyleSheet.create({
container: {
Expand Down
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 src/components/react-native-messenger/KeyboardSpacer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import KeyboardSpacer from './KeyboardSpacer';
export default KeyboardSpacer;
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;
4 changes: 2 additions & 2 deletions src/components/react-native-messenger/Toolbar/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ class Toolbar extends Component {
subtitle={'Active 32 minutes ago'}
/>

<Appbar.Action icon="call" onPress={() => {}} />
{/* <Appbar.Action icon="call" onPress={() => {}} />
<Appbar.Action icon="videocam" onPress={() => {}} />
<Appbar.Action icon="error-outline" onPress={() => {}} />
<Appbar.Action icon="error-outline" onPress={() => {}} /> */}
</Appbar.Header>
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/react-native-messenger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
TouchableWithoutFeedback,
Keyboard
} from 'react-native';
import Toolbar from './Toolbar';
// import Toolbar from './Toolbar';
import InputModule from './InputModule';
import KeyboardSpacer from '../KeyboardSpacer';
import KeyboardSpacer from './KeyboardSpacer';

export default class Messenger extends Component {
onBackPress = () => {
Expand All @@ -21,7 +21,7 @@ export default class Messenger extends Component {
render() {
return (
<View style={{ flex: 1 }}>
<Toolbar onBackPress={this.onBackPress} />
{/* <Toolbar onBackPress={this.onBackPress} /> */}
<TouchableWithoutFeedback onPress={this.dismissKeyboard}>
<View style={{ flex: 1 }} />
</TouchableWithoutFeedback>
Expand Down
13 changes: 13 additions & 0 deletions src/lib/createReducer.js
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;
}
};
}
19 changes: 19 additions & 0 deletions src/lib/isIphoneX.js
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;
}
}
3 changes: 2 additions & 1 deletion src/screens/ChatScreen/ChatScreen.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, { Component } from 'react';
import { View } from 'react-native';
import Messenger from 'src/components/react-native-messenger';
import Messenger from '../../components/react-native-messenger';

export default class ChatScreen extends Component {
onBackPress = () => {
this.props.navigation.goBack();
};

render() {
return (
<View style={{ flex: 1 }}>
Expand Down
14 changes: 11 additions & 3 deletions src/screens/GroupScreen/GroupScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@ import { View } from 'react-native';

import GroupsList from '../../components/GroupsList';
import styles from './styles';
import FormButton from '../../components/FormButton';

export default function GroupScreen({ navigation }) {



export default class GroupsScreen extends Component {
render() {
return (
<View style={styles.container}>
<GroupsList />
<FormButton
buttonTitle="Chat with Friends"
onPress={() => navigation.navigate('Chat')}
/>

</View>
);
}

}

0 comments on commit 4f5df4f

Please sign in to comment.