Skip to content

Commit

Permalink
Fix contacts
Browse files Browse the repository at this point in the history
  • Loading branch information
ChesterSim committed Jun 28, 2019
1 parent 755cb82 commit e012565
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 25 deletions.
12 changes: 6 additions & 6 deletions ios/RNFirebaseStarter/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@
</dict>
</dict>
<key>NSCameraUsageDescription</key>
<string/>
<string></string>
<key>NSContactsUsageDescription</key>
<string>Chat app that uses user's contacts</string>
<string>Chat app that uses user&apos;s contacts</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string/>
<string></string>
<key>NSMicrophoneUsageDescription</key>
<string/>
<string></string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string/>
<string></string>
<key>NSPhotoLibraryUsageDescription</key>
<string/>
<string></string>
<key>UIAppFonts</key>
<array>
<string>AntDesign.ttf</string>
Expand Down
3 changes: 1 addition & 2 deletions src/components/ContactsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,12 @@ class ContactsList extends React.Component {
if (
snapshot.child(`${phoneNumber}`.replace(/\s/g, "")).exists()
) {
return snapshot.val()[phoneNumber];
return snapshot.val()[phoneNumber.replace(/\s/g, "")];
}
}
return;
})
.filter(x => x);

return {
...prevState,
contacts
Expand Down
1 change: 0 additions & 1 deletion src/components/ImagePickerComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class ImagePickerComponent extends React.Component {
pickImageHandler = () => {
const options = {
title: "Select Profile Picture",
customButtons: [{ name: "fb", title: "Choose Photo from Facebook" }],
storageOptions: {
skipBackup: true,
path: "images"
Expand Down
6 changes: 3 additions & 3 deletions src/screens/Main/EventModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ class EventModal extends Component {
};

handleEditButtonPress = () => {
(this.props.navigation || {}).navigate("CreateEvents", {
groupID: this.props.event.groupID
});
// (this.props.navigation || {}).navigate("CreateEvents", {
// groupID: this.props.event.groupID
// });
};

renderTitle = () => {
Expand Down
6 changes: 4 additions & 2 deletions src/screens/Main/GroupScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
FlatList,
Image,
Dimensions,
Alert
Alert,
StatusBar
} from "react-native";
import firebase from "react-native-firebase";
import _ from "lodash";
Expand Down Expand Up @@ -44,8 +45,8 @@ class GroupScreen extends Component {
};
};


componentDidMount() {
console.log("mounted groupScreen");
this.scrollToTop();
const db = firebase.database();
const uid = firebase.auth().currentUser.uid;
Expand Down Expand Up @@ -160,6 +161,7 @@ class GroupScreen extends Component {
};
return (
<SwipeOut {...swipeSettings}>
<StatusBar barStyle="light-content" />
<TouchableOpacity
style={styles.chatList}
onPress={() =>
Expand Down
15 changes: 12 additions & 3 deletions src/screens/Main/Groups/ChatScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
Platform,
TouchableOpacity,
TouchableWithoutFeedback,
SafeAreaView
SafeAreaView,
StatusBar
} from "react-native";
import { FlatList } from "react-native-gesture-handler";
import {
Expand Down Expand Up @@ -39,7 +40,7 @@ class ChatScreen extends Component {
groupID: this.props.navigation.getParam("group").groupID,
textMessage: "",
dayOfLastMsg: new Date().getDay(),
dateOfLastMsg: new Date().getDate()
dateOfLastMsg: new Date().getDate(),
};
this.convertTime = this.convertTime.bind(this);
this.sendMessage = this.sendMessage.bind(this);
Expand Down Expand Up @@ -107,6 +108,12 @@ class ChatScreen extends Component {
};
};

componentDidMount() {
this.props.navigation.setParams({
groupName: this.props.group.groupName
})
}

componentWillMount() {
const groupID = this.state.groupID;
this.messagesRef.child(`${groupID}`).on("value", snapshot => {
Expand Down Expand Up @@ -317,6 +324,7 @@ class ChatScreen extends Component {
keyboardVerticalOffset={Platform.OS === "ios" ? 87 : -300}
style={{ flex: 1 }}
>
<StatusBar barStyle="light-content" />
<SafeAreaView style={{ flex: 1 }}>
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<FlatList
Expand Down Expand Up @@ -377,7 +385,8 @@ const mapStateToProps = (state, ownProps) => {
return {
uid: state.authReducer.user.uid,
conversation: stateOfGroup.messages || [],
username
username,
group: state.groupsReducer.groups[groupID]
};
};

Expand Down
5 changes: 3 additions & 2 deletions src/screens/Main/Groups/CreateGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ class GroupMembersSelect extends React.Component {
return (
<ContactsList
goBack={() => this.props.navigation.goBack()}
onSubmit={formValues =>
onSubmit={formValues => {
console.log(formValues);
this.props.navigation.navigate("GroupDetails", {
users: formValues,
title: "Create Groups",
type: "create",
})
}
}}
/>
);
}
Expand Down
16 changes: 12 additions & 4 deletions src/screens/Main/Groups/GroupDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
TextInput,
StyleSheet,
TouchableOpacity,
Dimensions
Dimensions,
StatusBar
} from "react-native";
import { connect } from "react-redux";
import { Field, reduxForm } from "redux-form";
Expand All @@ -24,6 +25,7 @@ class GroupDetails extends React.Component {
super(props);
this.state = {
loading: false,
groupName: this.props.navigation.getParam("type") === "create" ? "" : this.props.group.groupName
}
this.handleSubmitCreate = this.handleSubmitCreate.bind(this);
}
Expand All @@ -34,7 +36,8 @@ class GroupDetails extends React.Component {
<View style={{ bottom: 5 }}>
<HeaderTitle title={navigation.getParam("title")} />
</View>
)
),
headerTintColor: "#fff"
};
};

Expand Down Expand Up @@ -79,24 +82,29 @@ class GroupDetails extends React.Component {
<ImagePicker
width={Dimensions.get("window").width}
{...props.input}
value={defaultPicture}
value={this.props.navigation.getParam("type") === "create" ? defaultPicture : { uri: this.props.group.photoURL }}
/>
);
};

renderInput = ({ input, label }) => {
// console.log(input)
return (
<TextInput
{...input}
value={this.state.groupName}
onChangeText={text => this.setState({ groupName: text })}
style={[styles.textInput, { marginTop: 5 }]}
placeholder={label}
defaultValue={this.props.navigation.getParam("type") === "create" ? "" : this.props.group.groupName}
/>
);
};

render() {
return (
<View style={styles.container}>
<StatusBar barStyle="light-content" />
<View style={{ marginTop: "15%" }}>
<Text body grey style={styles.text}>
Enter your group name and group picture!
Expand Down Expand Up @@ -150,7 +158,7 @@ const styles = StyleSheet.create({
const mapStateToProps = (state, ownProps) => {
return {
user: state.authReducer.user,
group: state.groupsReducer.groups[ownProps.navigation.getParam("groupID")]
group: state.groupsReducer.groups[ownProps.navigation.getParam("groupID")] || {}
};
};

Expand Down
10 changes: 8 additions & 2 deletions src/screens/Main/Groups/GroupInformation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
StyleSheet,
TouchableOpacity,
Dimensions,
Alert
Alert,
StatusBar
} from "react-native";
import SwipeOut from "react-native-swipeout";
import GroupPicture from "../../../components/GroupPicture";
Expand All @@ -26,6 +27,7 @@ class GroupInformation extends React.Component {
image: navigation.getParam("image")
});
return {
gesturesEnabled: false,
headerTintColor: "#fff",
headerStyle: {
borderBottomColor: "transparent",
Expand All @@ -50,7 +52,10 @@ class GroupInformation extends React.Component {
headerLeft: (
<TouchableOpacity
onPress={() => {
navigation.goBack();
navigation.navigate("Chat", {
group,
image: { uri: group.photoURL }
});;
}}
style={{ alignSelf: "flex-start", paddingTop: 10, paddingLeft: 10 }}
>
Expand Down Expand Up @@ -235,6 +240,7 @@ class GroupInformation extends React.Component {
render() {
return (
<View style={{ display: "flex", height: "100%" }}>
<StatusBar barStyle="light-content" />
{this.renderFlatList()}
</View>
);
Expand Down

0 comments on commit e012565

Please sign in to comment.