|
@@ -7,7 +7,7 @@ import ActionButton from 'react-native-action-button';
|
|
|
import { Actions, ActionConst } from 'react-native-router-flux';
|
|
import { Actions, ActionConst } from 'react-native-router-flux';
|
|
|
|
|
|
|
|
|
|
|
|
|
-import { claseFetch } from '../actions/';
|
|
|
|
|
|
|
+import { claseFetch, saveClase, deleteClase } from '../actions/';
|
|
|
import Teoria from './Clase/Teoria';
|
|
import Teoria from './Clase/Teoria';
|
|
|
import Comentarios from './Clase/Comentarios';
|
|
import Comentarios from './Clase/Comentarios';
|
|
|
import { Spinner } from '../components/common/';
|
|
import { Spinner } from '../components/common/';
|
|
@@ -17,63 +17,78 @@ import { ConnectionError } from '../components/common';
|
|
|
|
|
|
|
|
|
|
|
|
|
class Clase extends Component {
|
|
class Clase extends Component {
|
|
|
- state = { page: 'Teoria' };
|
|
|
|
|
|
|
+ state = { page: 'Teoria' };
|
|
|
|
|
|
|
|
- componentWillMount() {
|
|
|
|
|
- this.props.claseFetch(this.props);
|
|
|
|
|
|
|
+ componentWillMount() {
|
|
|
|
|
+ this.props.claseFetch(this.props);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- renderView() {
|
|
|
|
|
- if ( this.state.page === 'Teoria' )
|
|
|
|
|
- return <Teoria titulo={titulo} profesor={profesor} texto={texto} style={{flex:1}} />;
|
|
|
|
|
-
|
|
|
|
|
- if ( this.state.page === 'Comentarios' )
|
|
|
|
|
- return <Comentarios style={{flex:1}} comentarios={comentarios} respuestas={respuestas} />;
|
|
|
|
|
-
|
|
|
|
|
- return <Text>{this.state.page}!!!</Text>;
|
|
|
|
|
- }
|
|
|
|
|
- render() {
|
|
|
|
|
- const { clase } = this.props;
|
|
|
|
|
-
|
|
|
|
|
- if (this.props.loading)
|
|
|
|
|
- return <Spinner size="large" />;
|
|
|
|
|
-
|
|
|
|
|
- if (clase.error)
|
|
|
|
|
- return <ConnectionError />;
|
|
|
|
|
-
|
|
|
|
|
- var ScrollableTabView = require('react-native-scrollable-tab-view');
|
|
|
|
|
- const { titulo, profesor, texto, comentarios, respuestas } = this.props.clase;
|
|
|
|
|
-
|
|
|
|
|
- return (
|
|
|
|
|
- <View style={{flex:1}}>
|
|
|
|
|
- <ScrollableTabView style={styles.container, {flex:1}}>
|
|
|
|
|
- <Teoria titulo={titulo} profesor={profesor} texto={texto} style={{flex:1}} tabLabel="Teoria" />
|
|
|
|
|
- <View tabLabel="Videos" />
|
|
|
|
|
- <Comentarios style={{flex:1}} comentarios={comentarios} respuestas={respuestas} tabLabel="Comentarios" />
|
|
|
|
|
- </ScrollableTabView>
|
|
|
|
|
- <MyActionButton onPress={() => true}>
|
|
|
|
|
- <ActionButton.Item buttonColor='#22eeee' title="Comentario">
|
|
|
|
|
- <Icon name="md-create" style={styles.actionButtonIcon} />
|
|
|
|
|
- </ActionButton.Item>
|
|
|
|
|
-
|
|
|
|
|
- <ActionButton.Item onPress={() => {} } buttonColor='#ee22ee' title="Guardar clase">
|
|
|
|
|
- <Icon name={ false ? "ios-star" : "ios-star-outline" } style={styles.actionButtonIcon} />
|
|
|
|
|
- </ActionButton.Item>
|
|
|
|
|
-
|
|
|
|
|
- <ActionButton.Item onPress={() => Actions.Menu()} buttonColor='#eeee22' title="Menu">
|
|
|
|
|
- <Icon name="md-apps" style={styles.actionButtonIcon} />
|
|
|
|
|
- </ActionButton.Item>
|
|
|
|
|
- </MyActionButton>
|
|
|
|
|
- </View>
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ renderView() {
|
|
|
|
|
+ if ( this.state.page === 'Teoria' )
|
|
|
|
|
+ return <Teoria titulo={titulo} profesor={profesor} texto={texto} style={{flex:1}} />;
|
|
|
|
|
+
|
|
|
|
|
+ if ( this.state.page === 'Comentarios' )
|
|
|
|
|
+ return <Comentarios style={{flex:1}} comentarios={comentarios} respuestas={respuestas} />;
|
|
|
|
|
+
|
|
|
|
|
+ return <Text>{this.state.page}!!!</Text>;
|
|
|
|
|
+ }
|
|
|
|
|
+ onSavePress() {
|
|
|
|
|
+ const { local, clase } = this.props;
|
|
|
|
|
+ if ( !local ) {
|
|
|
|
|
+ this.props.saveClase({ clase });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.props.deleteClase({ clase });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ render() {
|
|
|
|
|
+ const { clase, local, loading } = this.props;
|
|
|
|
|
+
|
|
|
|
|
+ if (loading)
|
|
|
|
|
+ return <Spinner size="large" />;
|
|
|
|
|
+
|
|
|
|
|
+ if (clase.error)
|
|
|
|
|
+ return <ConnectionError />;
|
|
|
|
|
+
|
|
|
|
|
+ var ScrollableTabView = require('react-native-scrollable-tab-view');
|
|
|
|
|
+ const { titulo, profesor, texto, comentarios, respuestas } = this.props.clase;
|
|
|
|
|
+
|
|
|
|
|
+ const icon = local ? "ios-star" : "ios-star-outline";
|
|
|
|
|
+ const title = local ? "Borrar clase" : "Guardar clase";
|
|
|
|
|
+
|
|
|
|
|
+ return (
|
|
|
|
|
+ <View style={{flex:1}}>
|
|
|
|
|
+
|
|
|
|
|
+ <ScrollableTabView style={styles.container, {flex:1}}>
|
|
|
|
|
+ <Teoria titulo={titulo} profesor={profesor} texto={texto} style={{flex:1}} tabLabel="Teoria" />
|
|
|
|
|
+ <View tabLabel="Videos" />
|
|
|
|
|
+ <Comentarios style={{flex:1}} comentarios={comentarios} respuestas={respuestas} tabLabel="Comentarios" />
|
|
|
|
|
+ </ScrollableTabView>
|
|
|
|
|
+
|
|
|
|
|
+ <MyActionButton onPress={() => true}>
|
|
|
|
|
+ <ActionButton.Item buttonColor='#22eeee' title="Comentario">
|
|
|
|
|
+ <Icon name="md-create" style={styles.actionButtonIcon} />
|
|
|
|
|
+ </ActionButton.Item>
|
|
|
|
|
+
|
|
|
|
|
+ <ActionButton.Item onPress={this.onSavePress.bind(this)} buttonColor='#ee22ee' title={title}>
|
|
|
|
|
+ <Icon name={ icon } style={styles.actionButtonIcon} />
|
|
|
|
|
+ </ActionButton.Item>
|
|
|
|
|
+
|
|
|
|
|
+ <ActionButton.Item onPress={() => Actions.Menu()} buttonColor='#eeee22' title="Menu">
|
|
|
|
|
+ <Icon name="md-apps" style={styles.actionButtonIcon} />
|
|
|
|
|
+ </ActionButton.Item>
|
|
|
|
|
+ </MyActionButton>
|
|
|
|
|
+
|
|
|
|
|
+ </View>
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const styles = {
|
|
const styles = {
|
|
|
actionButtonIcon: {
|
|
actionButtonIcon: {
|
|
|
- fontSize: 20,
|
|
|
|
|
- height: 22,
|
|
|
|
|
- color: 'white',
|
|
|
|
|
|
|
+ fontSize: 20,
|
|
|
|
|
+ height: 22,
|
|
|
|
|
+ color: 'white',
|
|
|
},
|
|
},
|
|
|
container: {
|
|
container: {
|
|
|
flex: 1,
|
|
flex: 1,
|
|
@@ -84,8 +99,14 @@ const styles = {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const mapStateToProps = state => {
|
|
const mapStateToProps = state => {
|
|
|
- const { curClase, loading } = state.ClasesReducer;
|
|
|
|
|
- return { loading, clase: curClase };
|
|
|
|
|
|
|
+ const { curClase, loading } = state.ClasesReducer;
|
|
|
|
|
+ const localClases = state.LocalStorageReducer.clases;
|
|
|
|
|
+
|
|
|
|
|
+ const local = localClases.filter( c => {
|
|
|
|
|
+ return c._id === curClase._id
|
|
|
|
|
+ }).length > 0;
|
|
|
|
|
+
|
|
|
|
|
+ return { loading, clase: curClase, local };
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-export default connect(mapStateToProps, { claseFetch })(Clase);
|
|
|
|
|
|
|
+export default connect(mapStateToProps, { claseFetch, saveClase, deleteClase })(Clase);
|