Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //import liraries
- import React, { Component } from 'react';
- import { View, Text, TextInput, StyleSheet, ScrollView, Container, TouchableOpacity, Dimensions, StatusBar, Alert, ActivityIndicator, Image, ImageBackground, AsyncStorage, BackHandler } from 'react-native';
- import Icon from 'react-native-vector-icons/FontAwesome';
- import Slideshow from 'react-native-slideshow';
- import InternetOffline from '../../Components/InternetOffline';
- import NetInfo from "@react-native-community/netinfo";
- import Accounting from '../../Components/Accounting';
- import PropTypes from 'prop-types';
- import { USER_INFO } from '../../Config/UserServices';
- // import Dialog, {
- // DialogTitle,
- // DialogContent,
- // DialogFooter,
- // DialogButto
- // SlideAnimation,
- // ScaleAnimation,
- // } from 'react-native-popup-dialog';
- // const { height, width, scale } = Dimensions.get('window')
- const width = Dimensions.get('window').width;
- const height = Dimensions.get('window').height;
- const GLOBAL = require('../../Config/Services');
- // create a component
- class Home extends Component {
- constructor() {
- super();
- this.state = {
- isConnected: false,
- animating: true,
- position: 1,
- interval: null,
- dataSource: [
- {
- title: 'Title 1',
- caption: 'Caption 1',
- url: 'http://placeimg.com/640/480/any',
- }, {
- title: 'Title 2',
- caption: 'Caption 2',
- url: 'http://placeimg.com/640/480/any',
- }, {
- title: 'Title 3',
- caption: 'Caption 3',
- url: 'http://placeimg.com/640/480/any',
- },
- ],
- dataBuku: [{
- id: 0,
- judul: 'Judul Buku 1',
- namapengarang: 'Arief Advani',
- harga: 'Rp. 5000',
- image: require('../../Assets/image/icons/buk1.png'),
- star: 4
- },
- {
- id: 1,
- judul: 'Judul Buku 2',
- namapengarang: 'Arief Advani',
- harga: 'Rp. 5000',
- image: require('../../Assets/image/icons/buk2.png'),
- star: 4
- },
- {
- id: 2,
- judul: 'Judul Buku 3',
- namapengarang: 'Arief Advani',
- harga: 'Rp. 5000',
- image: require('../../Assets/image/icons/buk3.png'),
- star: 4
- },
- {
- id: 3,
- judul: 'Judul Buku 4',
- namapengarang: 'Arief Advani',
- harga: 'Rp. 5000',
- image: require('../../Assets/image/icons/buk4.png'),
- star: 4
- }],
- tempWallet: 0,
- tempName: '',
- tempImage: '',
- screenWidth: width,
- screenHeight: height,
- orientation: this._getOrientation(width, height)
- }
- this.handleBackButtonClick = this.handleBackButtonClick.bind(this);
- }
- _getOrientation(width, height) {
- return width < height ? 'Potrait' : 'Landscape'
- }
- _updateLayout(event) {
- const { width, height } = event.nativeEvent.layout
- let orientation = this._getOrientation(width, height)
- this.setState({
- screenWidth: width,
- screenHeight: height,
- orientation: this._getOrientation(width, height)
- })
- }
- componentWillMount() {
- this.setState({
- interval: setInterval(() => {
- this.setState({
- position: this.state.position === this.state.dataSource.length ? 0 : this.state.position + 1
- });
- }, 2000)
- });
- BackHandler.addEventListener('hardwareBackPress', this.handleBackButtonClick);
- }
- componentDidMount() {
- NetInfo.isConnected.addEventListener('connectionChange', this.handleConnectivityChange);
- this.getId();
- }
- componentWillUnmount() {
- clearInterval(this.state.interval);
- BackHandler.removeEventListener('hardwareBackPress', this.handleBackButtonClick);
- NetInfo.isConnected.removeEventListener('connectionChange', this.handleConnectivityChange);
- }
- clickBack(){
- this.props.navigation.navigate('AppAuthentication');
- };
- handleBackButtonClick() {
- // this.props.navigation.goBack(null);
- Alert.alert('My Character', 'Apakah Anda Ingin Keluar ?', [
- { text: 'NO', onPress: () => console.warn('NO Pressed'), style: 'cancel' },
- { text: 'YES', onPress: () => this.clickBack()},
- ]);
- return true;
- }
- getId() {
- AsyncStorage.getItem(GLOBAL.APPUSERID).then((value) => {
- this.funcGetUserInfo(value);
- });
- }
- funcGetUserInfo = async (getId) => {
- const resJson = await USER_INFO(getId);
- console.log(resJson)
- if (resJson.status == 200) {
- this.setState({
- tempWallet: resJson.data.walet,
- tempName: resJson.data.name
- })
- } else {
- }
- }
- handleConnectivityChange = (isConnected) => {
- if (isConnected) {
- this.setState({ isConnected: false });
- // this.handleGetProfile();
- } else {
- this.setState({ isConnected: true });
- }
- }
- clickBook() {
- this.props.navigation.navigate('CatalogEbook');
- }
- formatValue(value) {
- return Accounting.formatMoney(parseFloat(value), "Rp ", 0);
- }
- clickDialog(getTitle, getDescription) {
- Alert.alert(getTitle, getDescription)
- }
- render() {
- return (
- <View style={{ justifyContent: 'center', alignItems: 'center' }} onLayout={(event) => this._updateLayout(event)}>
- <ImageBackground source={require('../../Assets/image/icons/header.png')} style={{ width: width / 1, justifyContent: 'center', alignItems: 'center', height: height / 5, flexDirection: 'row' }}>
- {/* <TouchableOpacity style={{ marginLeft: width / 20 }}>
- <Icon name="bars" style={{ fontWeight: '900', fontSize: width / 20, color: 'white' }} />
- </TouchableOpacity> */}
- <View>
- <Text style={{ color: 'white', fontWeight: 'bold', fontSize: 25, marginLeft: width / 20 }}>Home</Text>
- </View>
- {/* <TouchableOpacity style={{ marginRight: width / 20 }}>
- <Text style={{ fontWeight: '900', fontSize: width / 25, color: 'white' }}>{this.formatValue(this.state.tempWallet)}</Text>
- </TouchableOpacity> */}
- </ImageBackground>
- {/* <Dialog
- onDismiss={() => {
- this.setState({ Dialog: false });
- }}
- onTouchOutside={() => {
- this.setState({ Dialog: false });
- }}
- visible={this.state.Dialog}
- dialogAnimation={new SlideAnimation({ slideFrom: 'bottom' })}>
- <DialogContent>
- <View style={{ width: width / 1, height: height / 1.25 }}>
- <Text>{this.state.DialogDeskripsi}</Text>
- </View>
- </DialogContent>
- </Dialog> */}
- <InternetOffline
- isConnected={this.state.isConnected}
- />
- {/* <View>
- <StatusBar backgroundColor='#678f75' barStyle='light-content' />
- </View> */}
- {/* <View style={{ height: 52, width: width / 1.1, backgroundColor: "#fcfcfa", justifyContent: 'center', paddingLeft: 30, position: 'absolute', top: width / 4, borderWidth: 0.5 }}>
- <TextInput placeholder='Telusuri E-book Anda ' placeholderTextColor='#0bbed6' />
- </View> */}
- <ScrollView style={{ marginTop: 5 }}
- showsVerticalScrollIndicator={false} bounces={false} bouncesZoom={false}
- >
- <View style={{ marginTop: width / 10, height: height / 3.8, width: width / 1 }}>
- <Slideshow
- dataSource={this.state.dataSource}
- position={this.state.position}
- onPositionChanged={position => this.setState({ position })}
- />
- </View>
- <View style={{
- marginTop: width / 10,
- backgroundColor: 'white',
- shadowColor: "#000",
- width: width / 1,
- height: height / 6,
- shadowOffset: {
- width: 0,
- height: 11,
- },
- shadowOpacity: 0.55,
- shadowRadius: 14.78,
- elevation: 22,
- justifyContent: 'center',
- marginRight: width / 20
- }}>
- <View style={{ flexDirection: 'row', justifyContent: 'space-around', alignItems: 'center' }}>
- <View style={{ justifyContent: 'center', alignItems: 'center', width: width / 4.5, height: height / 9, marginTop: 10 }}>
- <TouchableOpacity onPress={() => this.props.navigation.navigate('MyCharacter')} style={{ width: width / 4.5, height: height / 9, borderRadius: width / 25 }}>
- <Image source={require('../../Assets/image/icons/char.png')} style={{ width: width / 4.5, height: height / 9, borderRadius: width / 25 }} />
- </TouchableOpacity>
- <Text style={{ fontWeight: '800', marginTop: 2 }}>Character</Text>
- </View>
- <View style={{ justifyContent: 'center', alignItems: 'center', width: width / 4.5, height: height / 9, marginTop: 10 }}>
- <TouchableOpacity onPress={() => this.clickBook()} style={{ width: width / 4.5, height: height / 9, borderRadius: width / 25 }}>
- <Image source={require('../../Assets/image/icons/book.png')} style={{ width: width / 4.5, height: height / 9, borderRadius: width / 25 }} />
- </TouchableOpacity>
- <Text style={{ fontWeight: '800', marginTop: 2 }}>E Book</Text>
- </View>
- <View style={{ justifyContent: 'center', alignItems: 'center', width: width / 4.5, height: height / 9, marginTop: 10 }}>
- <TouchableOpacity onPress={() => this.props.navigation.navigate('CatalogXcull')} style={{ width: width / 4.5, height: height / 9, borderRadius: width / 25 }}>
- <Image source={require('../../Assets/image/icons/kuler.png')} style={{ width: width / 4.5, height: height / 9, borderRadius: width / 25 }} />
- </TouchableOpacity>
- <Text style={{ fontWeight: '800', marginTop: 2 }}>Xcull</Text>
- </View>
- </View>
- </View>
- <View style={{ marginTop: width / 20, width: width / 1 }}>
- <ImageBackground source={require('../../Assets/image/icons/bgP.png')} style={{ width: width / 1, height: height / 3, resizeMode: 'stretch' }}>
- <View>
- <View style={{ flexDirection: 'row', justifyContent: 'space-around', marginTop: width / 12 }}>
- <View style={{ justifyContent: 'center', alignItems: 'center', width: width / 5, height: height / 9.5 }}>
- <TouchableOpacity style={{ borderRadius: width / 25, width: width / 5, height: height / 9.5 }}>
- <Image source={require('../../Assets/image/icons/guru.png')} style={{ width: width / 5, height: height / 9.5, borderRadius: width / 25 }} />
- </TouchableOpacity>
- <Text style={{ fontWeight: '800', marginTop: 5 }}>E Student</Text>
- </View>
- <View style={{ justifyContent: 'center', alignItems: 'center', width: width / 4.5, height: height / 9.5 }}>
- <TouchableOpacity style={{ width: width / 5, height: height / 9.5, borderRadius: width / 25 }}>
- <Image source={require('../../Assets/image/icons/homework.png')} style={{ width: width / 5, height: height / 9.5, borderRadius: width / 25 }} />
- </TouchableOpacity>
- <Text style={{ fontWeight: '800', marginTop: 5 }}>Home Work</Text>
- </View>
- <View style={{ justifyContent: 'center', alignItems: 'center', width: width / 5, height: height / 9.5 }}>
- <TouchableOpacity style={{ width: width / 5, height: height / 9.5, borderRadius: width / 25 }}>
- <Image source={require('../../Assets/image/icons/eskul.png')} style={{ width: width / 5, height: height / 9.5, borderRadius: width / 25 }} />
- </TouchableOpacity>
- <Text style={{ fontWeight: '800', marginTop: 5 }}>E School</Text>
- </View>
- </View>
- <View style={{ flexDirection: 'row', justifyContent: 'space-around', marginTop: width / 15 }}>
- <View style={{ justifyContent: 'center', alignItems: 'center', width: width / 5, height: height / 9.5 }}>
- <TouchableOpacity style={{ width: width / 5, height: height / 9.5, borderRadius: width / 25 }}>
- <Image source={require('../../Assets/image/icons/schedul.png')} style={{ width: width / 5, height: height / 9.5, borderRadius: width / 25 }} />
- </TouchableOpacity>
- <Text style={{ fontWeight: '800', marginTop: 5 }}>Scheduler</Text>
- </View>
- <View style={{ justifyContent: 'center', alignItems: 'center', width: width / 5, height: height / 9.5 }}>
- <TouchableOpacity style={{ width: width / 5, height: height / 9.5, borderRadius: width / 25 }}>
- <Image source={require('../../Assets/image/icons/elearn.png')} style={{ width: width / 5, height: height / 9.5, borderRadius: width / 25 }} />
- </TouchableOpacity>
- <Text style={{ fontWeight: '800', marginTop: 5 }}>E Learning</Text>
- </View>
- <View style={{ justifyContent: 'center', alignItems: 'center', width: width / 5, height: height / 9.5 }}>
- <TouchableOpacity style={{ width: width / 5, height: height / 9.5, borderRadius: width / 25 }}>
- <Image source={require('../../Assets/image/icons/wallet.png')} style={{ width: width / 5, height: height / 9.5, borderRadius: width / 25 }} />
- </TouchableOpacity>
- <Text style={{ fontWeight: '800', marginTop: 5 }}>Wallet</Text>
- </View>
- </View>
- <View style={{ position: 'absolute', bottom: '80%', left: '2%' }}>
- <Image source={require('../../Assets/image/icons/comingsoon.png')} />
- </View>
- </View>
- </ImageBackground>
- </View>
- <View style={{
- height: height / 12, width: width / 1,
- marginTop: width / 20, backgroundColor: 'white',
- // shadowColor: "#000",
- // shadowOffset: {
- // width: 0,
- // height: 11,
- // },
- // shadowOpacity: 0.55,
- // shadowRadius: 14.78,
- // elevation: 22,
- borderTopLeftRadius: 20,
- borderBottomLeftRadius: 20,
- flexDirection: 'row',
- }}>
- <View style={{ width: width / 20, height: height / 12, backgroundColor: '#24a0ff', marginLeft: width / 15 }} />
- <View style={{ alignItems: 'center', justifyContent: 'center' }}>
- <Text style={{ fontWeight: '900', marginLeft: width / 20, fontSize: 20 }}>My Character Info</Text>
- </View>
- </View>
- <View style={{ marginTop: width / 20, width: width / 1 }}>
- <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
- <TouchableOpacity onPress={() => this.clickDialog('My Character', 'Pengembangan Karakter dan Softskill')} style={{
- width: width / 2.1, height: height / 10,
- backgroundColor: 'white',
- // shadowColor: "#000",
- // shadowOffset: {
- // width: 0,
- // height: 11,
- // },
- // shadowOpacity: 0.55,
- // shadowRadius: 14.78,
- // elevation: 22,
- borderTopRightRadius: 20,
- borderBottomRightRadius: 20,
- flexDirection: 'row',
- alignItems: 'center'
- }}>
- <Image source={require('../../Assets/image/icons/sayap.png')} style={{ height: height / 10 }} />
- <View style={{ width: width / 3, marginLeft: 5 }}>
- <Text style={{ fontWeight: '900' }}>My Character</Text>
- {/* <Text numberOfLines={3} style={{ fontSize: 10 }}>Pengembangan Karakter dan Softskill</Text> */}
- </View>
- </TouchableOpacity>
- <TouchableOpacity onPress={() => this.clickDialog('E-Student', 'Latar belakang yang meliputi bidang pendidikan')} style={{
- width: width / 2.1, height: height / 10,
- backgroundColor: 'white',
- // shadowColor: "#000",
- // shadowOffset: {
- // width: 0,
- // height: 11,
- // },
- // shadowOpacity: 0.55,
- // shadowRadius: 14.78,
- // elevation: 22,
- borderTopLeftRadius: 20,
- borderBottomLeftRadius: 20,
- flexDirection: 'row-reverse',
- alignItems: 'center'
- }}>
- <Image source={require('../../Assets/image/icons/guru.png')} style={{ height: height / 10 }} />
- <View style={{ width: width / 3, paddingLeft: 30 }}>
- <Text style={{ fontWeight: '900' }}>E Student</Text>
- {/* <Text numberOfLines={3} style={{ fontSize: 10 }}>Latar belakang yang meliputi bidang pendidikan</Text> */}
- </View>
- </TouchableOpacity>
- </View>
- <View style={{ flexDirection: 'row', justifyContent: 'space-between', marginTop: width / 20 }}>
- <TouchableOpacity onPress={() => this.clickDialog('Extrakulikuller', 'Pelatihan Ekstrakulikuler non Akademik melalui media audio visual')} style={{
- width: width / 2.1, height: height / 10,
- backgroundColor: 'white',
- // shadowColor: "#000",
- // shadowOffset: {
- // width: 0,
- // height: 11,
- // },
- // shadowOpacity: 0.55,
- // shadowRadius: 14.78,
- // elevation: 22,
- borderTopRightRadius: 20,
- borderBottomRightRadius: 20,
- flexDirection: 'row',
- alignItems: 'center'
- }}>
- <Image source={require('../../Assets/image/icons/kuler.png')} style={{ height: height / 10 }} />
- <View style={{ width: width / 3, marginLeft: 5 }}>
- <Text style={{ fontWeight: '900' }}>Xcull</Text>
- {/* <Text numberOfLines={3} style={{ fontSize: 10 }}>Pengembangan Karakter dan Softskill</Text> */}
- </View>
- </TouchableOpacity>
- <TouchableOpacity onPress={() => this.clickDialog('Home Work', 'Kegiatan penunjang dengan waktu yang flexible')} style={{
- width: width / 2.1, height: height / 10,
- backgroundColor: 'white',
- // shadowColor: "#000",
- // shadowOffset: {
- // width: 0,
- // height: 11,
- // },
- // shadowOpacity: 0.55,
- // shadowRadius: 14.78,
- // elevation: 22,
- borderTopLeftRadius: 20,
- borderBottomLeftRadius: 20,
- flexDirection: 'row-reverse',
- alignItems: 'center'
- }}>
- <Image source={require('../../Assets/image/icons/homework.png')} style={{ height: height / 10 }} />
- <View style={{ width: width / 3, paddingLeft: 30 }}>
- <Text style={{ fontWeight: '900' }}>Home Work</Text>
- {/* <Text numberOfLines={3} style={{ fontSize: 10 }}>Latar belakang yang meliputi bidang pendidikan</Text> */}
- </View>
- </TouchableOpacity>
- </View>
- <View style={{ flexDirection: 'row', justifyContent: 'space-between', marginTop: width / 20 }}>
- <TouchableOpacity onPress={() => this.clickDialog('E-School', 'Sistem integrasi Sekolah berbasis Teknologi Digital ')} style={{
- width: width / 2.1, height: height / 10,
- backgroundColor: 'white',
- // shadowColor: "#000",
- // shadowOffset: {
- // width: 0,
- // height: 11,
- // },
- // shadowOpacity: 0.55,
- // shadowRadius: 14.78,
- // elevation: 22,
- borderTopRightRadius: 20,
- borderBottomRightRadius: 20,
- flexDirection: 'row',
- alignItems: 'center'
- }}>
- <Image source={require('../../Assets/image/icons/eskul.png')} style={{ height: height / 10 }} />
- <View style={{ width: width / 3, marginLeft: 5 }}>
- <Text style={{ fontWeight: '900' }}>E School</Text>
- {/* <Text numberOfLines={3} style={{ fontSize: 10 }}>Pengembangan Karakter dan Softskill</Text> */}
- </View>
- </TouchableOpacity>
- <TouchableOpacity onPress={() => this.clickDialog('Wallet', 'Uang digital beserta opsi transaksinya')} style={{
- width: width / 2.1, height: height / 10,
- backgroundColor: 'white',
- // shadowColor: "#000",
- // shadowOffset: {
- // width: 0,
- // height: 11,
- // },
- // shadowOpacity: 0.55,
- // shadowRadius: 14.78,
- // elevation: 22,
- borderTopLeftRadius: 20,
- borderBottomLeftRadius: 20,
- flexDirection: 'row-reverse',
- alignItems: 'center'
- }}>
- <Image source={require('../../Assets/image/icons/wallet.png')} style={{ height: height / 10 }} />
- <View style={{ width: width / 3, paddingLeft: 30 }}>
- <Text style={{ fontWeight: '900' }}>Wallet</Text>
- {/* <Text numberOfLines={3} style={{ fontSize: 10 }}>Latar belakang yang meliputi bidang pendidikan</Text> */}
- </View>
- </TouchableOpacity>
- </View>
- <View style={{ flexDirection: 'row', justifyContent: 'space-between', marginTop: width / 20 }}>
- <TouchableOpacity onPress={() => this.clickDialog('Schedule', 'Jadwal target program pengembangan Karakter')} style={{
- width: width / 2.1, height: height / 10,
- backgroundColor: 'white',
- // shadowColor: "#000",
- // shadowOffset: {
- // width: 0,
- // height: 11,
- // },
- // shadowOpacity: 0.55,
- // shadowRadius: 14.78,
- // elevation: 22,
- borderTopRightRadius: 20,
- borderBottomRightRadius: 20,
- flexDirection: 'row',
- alignItems: 'center'
- }}>
- <Image source={require('../../Assets/image/icons/schedul.png')} style={{ height: height / 10 }} />
- <View style={{ width: width / 3, marginLeft: 5 }}>
- <Text style={{ fontWeight: '900' }}>Shedule</Text>
- {/* <Text numberOfLines={3} style={{ fontSize: 10 }}>Pengembangan Karakter dan Softskill</Text> */}
- </View>
- </TouchableOpacity>
- <TouchableOpacity onPress={() => this.clickDialog('E Learning', 'Pembelajaran melalui materi online berupa buku, audio, dan video')} style={{
- width: width / 2.1, height: height / 10,
- backgroundColor: 'white',
- // shadowColor: "#000",
- // shadowOffset: {
- // width: 0,
- // height: 11,
- // },
- // shadowOpacity: 0.55,
- // shadowRadius: 14.78,
- // elevation: 22,
- borderTopLeftRadius: 20,
- borderBottomLeftRadius: 20,
- flexDirection: 'row-reverse',
- alignItems: 'center'
- }}>
- <Image source={require('../../Assets/image/icons/elearn.png')} style={{ height: height / 10 }} />
- <View style={{ width: width / 3, paddingLeft: 30 }}>
- <Text style={{ fontWeight: '900' }}>E Learning</Text>
- {/* <Text numberOfLines={3} style={{ fontSize: 10 }}>Latar belakang yang meliputi bidang pendidikan</Text> */}
- </View>
- </TouchableOpacity>
- </View>
- </View>
- {/* <View style={{ marginTop: width / 20, marginLeft: width / 20 }}>
- <Text style={{ fontWeight: '900' }}>Terbaru Harga Mulai Rp. 5000</Text>
- <ScrollView horizontal={true} style={{ width: width / 1, height: height / 3, marginTop: width / 20 }} showsHorizontalScrollIndicator={false}>
- {
- this.state.dataBuku.map((item, index) => (
- <TouchableOpacity
- key={item.id}
- onPress={() => this.alertItemName(item)}
- >
- <Image source={item.image} style={{ height: 155, width: 100, marginLeft: 3 }} />
- <View style={{ marginTop: width / 25 }}>
- <Text style={{ fontSize: 10, color: 'black', fontWeight: 'bold', marginLeft: 5, width: width / 3 }} numberOfLines={3}>{item.judul}</Text>
- <Text style={{ fontSize: 10, color: 'black', marginLeft: 5 }}>{item.namapengarang}</Text>
- <Text style={{ fontSize: 10, color: 'black', fontWeight: 'bold', marginLeft: 5 }}>{item.harga}</Text>
- </View>
- </TouchableOpacity>
- ))
- }
- </ScrollView>
- </View> */}
- <View style={{ height: 100 }} />
- </ScrollView>
- </View>
- );
- }
- }
- // define your styles
- const styles = StyleSheet.create({
- container: {
- flex: 1,
- },
- activityIndicator: {
- justifyContent: 'center',
- alignItems: 'center',
- height: 900
- }
- });
- //make this component available to the app
- export default Home;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement