<commit_before>import React, { Component } from 'react';
import { View, Image, Text, StyleSheet, ScrollView, TouchableOpacity, Alert } from 'react-native';
import { Actions } from 'react-native-router-flux';
import Icon from 'react-native-vector-icons/FontAwesome';

const theme = {
  accent: '#ffc107',
  bg: '#212121',
  text: 'white',
  font: 'OpenSans',
};

export default class FriendsSnapshot extends Component {

  constructor() {
    super();
    this.state = {
      friends: [],
    };
  }

  componentDidMount() {
    this.setFriends();
  }

  async setFriends() {
    try {
      const _this = this;
      await this.props.Firebase.auth().currentUser;

      const uid = this.props.Firebase.auth().currentUser.uid;
      const ref = this.props.Firebase.database().ref();
      const userFriendsRef = ref.child('userReadable/userFriends').child(uid);
      userFriendsRef.orderByKey().once('value').then((snap) => {
        const friendList = [];
        snap.forEach((snapshot) => {
          friendList.push({ displayName: snapshot.val().displayName, uid: snapshot.val().uid });
        });
        return friendList;
      }).then((value) => {
        if ((value.length > 0)) {
          _this.setState({
            friends: value,
          });
        } else {
          Alert.alert('Please add some friends!');
          _this.setState({
            friends: [],
          });
        }
      });
    } catch (e) {
      console.log(error);
    }
  }

  navFriend() {
    Actions.friends();
  }

  render() {
    const friends = [];
    let i = 0;
    this.state.friends.forEach((element) => {
      friends.push(
        <View key={i} style={{ alignItems: 'center', margin: 10 }}>
          <Image
            style={styles.icon}
            source={{ uri: 'https://static.pexels.com/photos/343717/pexels-photo-343717.jpeg' }}
          />
          <Text style={styles.friendList}> {element.displayName} </Text>
          <Text style={styles.friendList}> 400 pts </Text>
        </View>,
      );
      i += 1;
    });

    return (
      <View style={styles.friendSnap}>
        <TouchableOpacity style={styles.button} onPress={this.navFriend.bind(this)}>
          <Text style={styles.headerText}>
          FRIENDS
        </Text>
        </TouchableOpacity>
        <ScrollView horizontal showsHorizontalScrollIndicator={false}>
          { friends }
        </ScrollView>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  friendSnap: {
    flex: 0,
    backgroundColor: 'black',
    borderColor: '#424242',
    borderBottomWidth: 1,
    borderTopWidth: 1,

  },
  button: {
    flexDirection: 'row',
    justifyContent: 'flex-start',
  },
  friendList: {
    color: theme.text,
    fontSize: 10,
    fontWeight: '600',
    fontFamily: 'OpenSans',
  },<commit_msg>set freinds snapshot to a fixed hieght<commit_after>import React, { Component } from 'react';
import { Dimensions, View, Image, Text, StyleSheet, ScrollView, TouchableOpacity, Alert } from 'react-native';
import { Actions } from 'react-native-router-flux';
import Icon from 'react-native-vector-icons/FontAwesome';

const { height, width } = Dimensions.get('window');

const theme = {
  accent: '#ffc107',
  bg: '#212121',
  text: 'white',
  font: 'OpenSans',
};

export default class FriendsSnapshot extends Component {

  constructor() {
    super();
    this.state = {
      friends: [],
    };
  }

  componentDidMount() {
    this.setFriends();
  }

  async setFriends() {
    try {
      const _this = this;
      await this.props.Firebase.auth().currentUser;

      const uid = this.props.Firebase.auth().currentUser.uid;
      const ref = this.props.Firebase.database().ref();
      const userFriendsRef = ref.child('userReadable/userFriends').child(uid);
      userFriendsRef.orderByKey().once('value').then((snap) => {
        const friendList = [];
        snap.forEach((snapshot) => {
          friendList.push({ displayName: snapshot.val().displayName, uid: snapshot.val().uid });
        });
        return friendList;
      }).then((value) => {
        if ((value.length > 0)) {
          _this.setState({
            friends: value,
          });
        } else {
          Alert.alert('Please add some friends!');
          _this.setState({
            friends: [],
          });
        }
      });
    } catch (e) {
      console.log(error);
    }
  }

  navFriend() {
    Actions.friends();
  }

  render() {
    const friends = [];
    let i = 0;
    this.state.friends.forEach((element) => {
      friends.push(
        <View key={i} style={{ alignItems: 'center', margin: 10 }}>
          <Image
            style={styles.icon}
            source={{ uri: 'https://static.pexels.com/photos/343717/pexels-photo-343717.jpeg' }}
          />
          <Text style={styles.friendList}> {element.displayName} </Text>
          <Text style={styles.friendList}> 400 pts </Text>
        </View>,
      );
      i += 1;
    });

    return (
      <View style={styles.friendSnap}>
        <TouchableOpacity style={styles.button} onPress={this.navFriend.bind(this)}>
          <Text style={styles.headerText}>
          FRIENDS
        </Text>
        </TouchableOpacity>
        <ScrollView horizontal showsHorizontalScrollIndicator={false}>
          { friends }
        </ScrollView>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  friendSnap: {
    flex: 0,
    height: height * 0.20,
    backgroundColor: 'black',
    borderColor: '#424242',
    borderBottomWidth: 1,
    borderTopWidth: 1,

  },
  button: {
    flexDirection: 'row',
    justifyContent: 'flex-start',
  },
  friendList: {
    color: theme.text,
    fontSize: 10,
    fontWeight: '600',
    fontFamily: 'OpenSans',
  },
{'fraction_non_alphanumeric': 0.15428970819500262, 'fraction_numerical': 0.01555128429145553, 'mean_word_length': 2.320185614849188, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 43, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7485007', 'n_tokens_mistral': 1844, 'n_tokens_neox': 1755, 'n_words': 352}