<commit_before>var React = require('react-native');
var SelectLessonView = require('./selectLessonView');
var api = require('./../../utils/api');
require('./../../utils/userAgent');
var io =require('socket.io-client/socket.io');
var env = require('./../../utils/environment');
var server = env.server + ':' + env.port;

var {
  View,
  Text,
  StyleSheet,
  Navigator,
  TouchableOpacity,
  ScrollView,
  ListView
} = React;

class StartClassView extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      classes: [{id: 1, name:'Quick Class'}, {id:2, name:'CS 101'}, {id:3, name: 'CS 201'}],
    };
  }

  startQuickClass() {
    // generate modal with randomID
    var randomId = '' + Math.floor(Math.random() * 10) 
      + Math.floor(Math.random() * 10) + Math.floor(Math.random() * 10) + Math.floor(Math.random() * 10);
    // send socket submission to server with id (to join room)
    this.socket = io(server, {jsonp: false});
    this.socket.emit('teacherQuickClass' , {classId: randomId});
    // this.props.navigator.push({
    //   component: RequestFeedbackView,
    //   classId: 'Quick Class',
    //   lessonId: 'Quick Class',
    //   socket: this.state.socket,
    //   sceneConfig: {
    //     ...Navigator.SceneConfigs.FloatFromRight,
    //     gestures: {}
    //   }
    // });
    // on click 'ok'
      // go directly to requestFeedbackView
  }

  selectClass(classId) {
    api.getLessons(classId)
    .then((response) => {
      if(response.status === 500){
        console.error('err getting class data');
      } else if(response.status === 200) {
        var lessons = JSON.parse(response._bodyText);

        this.socket = io(server, {jsonp: false});
        this.socket.emit('teacherConnect' , {classId: classId});
        
        this.props.navigator.push({
          component: SelectLessonView,
          classId: classId,
          lessons: lessons,
          socket: this.socket,
          sceneConfig: {
            ...Navigator.SceneConfigs.FloatFromRight,
            gestures: {}
          }
        });
      }
    })
    .catch((err) => {
      console.error(err);
    });
  }

  renderClasses(classes) {
    return classes.map((cls, index) => {
      return (
        <View style={styles.buttonContainer} key={index}>
          <TouchableOpacity onPress={this.selectClass.bind(this, cls.id)} style={styles.button}>
            <Text style={styles.buttonText}> {cls.name} </Text>
          </TouchableOpacity>
        </View>
      )
    })
  }

  render() {
    return (
      <View style={{flex: 1, backgroundColor: '#ededed'}}> 
        <View style={styles.viewContainer}>
          <View style={styles.titleContainer}>
            <Text style={styles.pageText}> Your classes </Text>
          </View>
          <ScrollView>
            <View style={styles.buttonsContainer}>
              <TouchableOpacity onPress={this.startQuickClass} style={styles.button}>
                <Text style={styles.buttonText}> Start Quick Class </Text>
              </TouchableOpacity>
            </View>
              {this.renderClasses(this.state.classes)}
          </ScrollView>
        </View>
      </View>
    )
  }
}

const styles = StyleSheet.create({
  viewContainer: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  pageText: {
    fontSize: 20
  },
  buttonsContainer: {
    padding: 20
  },
  buttonContainer: {
    margin: 20
  },
  button: {

  },
  buttonText: {
    fontSize: 20
  }
});

module.exports = StartClassView;<commit_msg>Add basic modal when click 'Start Quick Class'<commit_after>var React = require('react-native');
var SelectLessonView = require('./selectLessonView');
var api = require('./../../utils/api');
require('./../../utils/userAgent');
var io =require('socket.io-client/socket.io');
var env = require('./../../utils/environment');
var server = env.server + ':' + env.port;

var {
  View,
  Text,
  StyleSheet,
  Navigator,
  Modal,
  TouchableOpacity,
  TouchableHighlight,
  ScrollView,
  ListView
} = React;

class StartClassView extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      classes: [{id: 1, name:'Quick Class'}, {id:2, name:'CS 101'}, {id:3, name: 'CS 201'}],
      modalVisible: false,
    };
  }

  startQuickClass() {
    // generate modal with randomID
    var randomId = '' + Math.floor(Math.random() * 10) 
      + Math.floor(Math.random() * 10) + Math.floor(Math.random() * 10) + Math.floor(Math.random() * 10);
    this.setState({
      modalVisible: true
    });
    // send socket submission to server with id (to join room)
    this.socket = io(server, {jsonp: false});
    this.socket.emit('teacherQuickClass' , {classId: randomId});
    // this.props.navigator.push({
    //   component: RequestFeedbackView,
    //   classId: 'Quick Class',
    //   lessonId: 'Quick Class',
    //   socket: this.state.socket,
    //   sceneConfig: {
    //     ...Navigator.SceneConfigs.FloatFromRight,
    //     gestures: {}
    //   }
    // });
    // on click 'ok'
      // go directly to requestFeedbackView
  }

  selectClass(classId) {
    api.getLessons(classId)
    .then((response) => {
      if(response.status === 500){
        console.error('err getting class data');
      } else if(response.status === 200) {
        var lessons = JSON.parse(response._bodyText);

        this.socket = io(server, {jsonp: false});
        this.socket.emit('teacherConnect' , {classId: classId});
        
        this.props.navigator.push({
          component: SelectLessonView,
          classId: classId,
          lessons: lessons,
          socket: this.socket,
          sceneConfig: {
            ...Navigator.SceneConfigs.FloatFromRight,
            gestures: {}
          }
        });
      }
    })
    .catch((err) => {
      console.error(err);
    });
  }

  renderClasses(classes) {
    return classes.map((cls, index) => {
      return (
        <View style={styles.buttonContainer} key={index}>
          <TouchableOpacity onPress={this.selectClass.bind(this, cls.id)} style={styles.button}>
            <Text style={styles.buttonText}> {cls.name} </Text>
          </TouchableOpacity>
        </View>
      )
    })
  }

  render() {
    return (
      <View style={{flex: 1, backgroundColor: '#ededed'}}> 
        <View style={styles.viewContainer}>
          <View style={styles.titleContainer}>
            <Text style={styles.pageText}> Your classes </Text>
          </View>
          <ScrollView>
            <View style={styles.buttonsContainer}>
              <TouchableOpacity onPress={this.startQuickClass.bind(this)} style={styles.button}>
                <Text style={styles.buttonText}> Start Quick Class </Text>
              </TouchableOpacity>
            </View>
              {this.renderClasses(this.state.classes)}
          </ScrollView>
        </View>
        <Modal visible={this.state.modalVisible} transparent={true} animated={true} style={styles.modal}>
          <View style={styles.modalBox}>
            <Text> TEXT! </Text>
            <TouchableHighlight>
              <Text> Okay </Text>
            </TouchableHighlight>
          </View>
        </Modal>
      </View>
    )
  }
}

const styles = StyleSheet.create({
  viewContainer: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  pageText: {
    fontSize: 20
  },
  buttonsContainer: {
    padding: 20
  },
  buttonContainer: {
    margin: 20
  },
  button: {

  },
  buttonText: {
    fontSize: 20
  },
  modal: {
    justifyContent: 'center',
    alignItems: 'center'
  },
  modalBox: {
    height: 200,
    width: 100,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: 'white'
  }
});

module.exports = StartClassView;
{'fraction_non_alphanumeric': 0.156644963615473, 'fraction_numerical': 0.009447210519596579, 'mean_word_length': 2.2778242677824267, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 63, 'https://': 0, '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': '7653605', 'n_tokens_mistral': 2466, 'n_tokens_neox': 2381, 'n_words': 480}