Commit c4230eab authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

font

parent 68aaf8d1
import * as React from 'react';
import Auth from './view/Auth'; import Auth from './view/Auth';
import { NavigationContainer } from '@react-navigation/native'; import { NavigationContainer } from '@react-navigation/native';
import { persistStore, persistReducer } from 'redux-persist'; import { persistStore, persistReducer } from 'redux-persist';
...@@ -11,15 +11,18 @@ import * as Localization from 'expo-localization'; ...@@ -11,15 +11,18 @@ import * as Localization from 'expo-localization';
import i18n from 'i18n-js'; import i18n from 'i18n-js';
import en from './lib/en'; import en from './lib/en';
import id from './lib/id'; import id from './lib/id';
import React, {useState } from 'react';
import { Text, View } from 'react-native';
import { AppLoading } from 'expo';
import * as Font from 'expo-font';
export const lang = i18n.translations = { export const lang = i18n.translations = {
en:en, en:en,
id:id id:id
} }
export const set_lang = i18n.locale = Localization.locale; export const set_lang = i18n.locale = Localization.locale;
export const fallbacks = i18n.fallbacks = true; export const fallbacks = i18n.fallbacks = true;
const persistConfig = { const persistConfig = {
key: 'root', key: 'root',
...@@ -30,6 +33,8 @@ const persistReducers = persistReducer(persistConfig, rootReducer) ...@@ -30,6 +33,8 @@ const persistReducers = persistReducer(persistConfig, rootReducer)
const store = createStore(persistReducers); const store = createStore(persistReducers);
const persistor = persistStore(store) const persistor = persistStore(store)
i18n.locale = Localization.locale; i18n.locale = Localization.locale;
export default function App() { export default function App() {
return ( return (
<Provider store={store}> <Provider store={store}>
......
...@@ -1409,6 +1409,11 @@ ...@@ -1409,6 +1409,11 @@
"prop-types": "^15.6.1" "prop-types": "^15.6.1"
} }
}, },
"@use-expo/font": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@use-expo/font/-/font-2.0.0.tgz",
"integrity": "sha512-oOJ2uaRyZNQg7PnQviz7nBcdrRL38zxScab4ktgtI4asa6G0dHW9wg307uJJmn0sHS04Yqtw+m0EOjDcGw3iWg=="
},
"@valdio/react-native-scrollable-tabview": { "@valdio/react-native-scrollable-tabview": {
"version": "0.8.12", "version": "0.8.12",
"resolved": "https://registry.npmjs.org/@valdio/react-native-scrollable-tabview/-/react-native-scrollable-tabview-0.8.12.tgz", "resolved": "https://registry.npmjs.org/@valdio/react-native-scrollable-tabview/-/react-native-scrollable-tabview-0.8.12.tgz",
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
"@react-navigation/native": "^5.0.5", "@react-navigation/native": "^5.0.5",
"@react-navigation/stack": "^5.0.5", "@react-navigation/stack": "^5.0.5",
"@shankarmorwal/rn-viewpager": "^1.2.11", "@shankarmorwal/rn-viewpager": "^1.2.11",
"@use-expo/font": "^2.0.0",
"@valdio/react-native-scrollable-tabview": "^0.8.12", "@valdio/react-native-scrollable-tabview": "^0.8.12",
"accordion-collapse-react-native": "^0.2.8", "accordion-collapse-react-native": "^0.2.8",
"axios": "^0.19.2", "axios": "^0.19.2",
...@@ -75,5 +76,6 @@ ...@@ -75,5 +76,6 @@
"babel-preset-expo": "~8.0.0", "babel-preset-expo": "~8.0.0",
"@babel/core": "^7.0.0" "@babel/core": "^7.0.0"
}, },
"private": true "private": true
} }
...@@ -113,7 +113,7 @@ class Auth extends React.Component { ...@@ -113,7 +113,7 @@ class Auth extends React.Component {
this.props.session_id === '' ? ( this.props.session_id === '' ? (
<> <>
{/* <Stack.Screen name="Change language" component={ChangeLanguage} /> */} {/* <Stack.Screen name="Change language" component={ChangeLanguage} /> */}
<Stack.Screen name="Login" component={Login} /> <Stack.Screen name="Login" component={Login} options={{headerShown:false}} />
<Stack.Screen name="Home" component={Home} /> <Stack.Screen name="Home" component={Home} />
<Stack.Screen name="Profile" component={ProfilePage} /> <Stack.Screen name="Profile" component={ProfilePage} />
<Stack.Screen name="Change Profil" component={ChangeProfile} /> <Stack.Screen name="Change Profil" component={ChangeProfile} />
...@@ -136,7 +136,7 @@ class Auth extends React.Component { ...@@ -136,7 +136,7 @@ class Auth extends React.Component {
<Stack.Screen name="Card Activation" component={CardActivation} /> <Stack.Screen name="Card Activation" component={CardActivation} />
<Stack.Screen name="Renewal" component={Renewal} /> <Stack.Screen name="Renewal" component={Renewal} />
<Stack.Screen name="Account" component={Account} /> <Stack.Screen name="Account" component={Account} />
<Stack.Screen name="Login" component={Login} /> <Stack.Screen name="Login" component={Login} options={{headerShown:false}}/>
<Stack.Screen name="Transfer Balance" component={TransferBalance} /> <Stack.Screen name="Transfer Balance" component={TransferBalance} />
<Stack.Screen name="Register" component={Register} /> <Stack.Screen name="Register" component={Register} />
<Stack.Screen name="Email Confirmation" component={EmailConfirmation} /> <Stack.Screen name="Email Confirmation" component={EmailConfirmation} />
......
import * as React from 'react'; import * as React from 'react';
import { Button, View, Text, TextInput, StyleSheet, Alert, Platform } from 'react-native'; import { Button, View, Text, TextInput, StyleSheet, Alert, Platform, Image } from 'react-native';
import Axios from 'axios'; import Axios from 'axios';
import Constants from 'expo-constants'; import Constants from 'expo-constants';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import ActionType from '../redux/globalActionType'; import ActionType from '../redux/globalActionType';
import { BASE_URL_LOGIN } from '../model/Base_Model'; import { BASE_URL_LOGIN } from '../model/Base_Model';
import { TouchableOpacity } from 'react-native-gesture-handler';
import { Notifications } from 'expo'; import { Notifications } from 'expo';
import i18n from 'i18n-js';
import { StackActions } from '@react-navigation/native';
import Spinner from 'react-native-loading-spinner-overlay';
class Login extends React.Component { class Login extends React.Component {
constructor(props) { constructor(props) {
...@@ -29,7 +26,7 @@ class Login extends React.Component { ...@@ -29,7 +26,7 @@ class Login extends React.Component {
}) })
} }
componentDidMount(){ componentDidMount() {
// console.log(this.props.language) // console.log(this.props.language)
} }
...@@ -37,208 +34,195 @@ class Login extends React.Component { ...@@ -37,208 +34,195 @@ class Login extends React.Component {
if (/\s/.test(this.state.email)) { if (/\s/.test(this.state.email)) {
Alert.alert('Email tidak boleh mengandung spasi') Alert.alert('Email tidak boleh mengandung spasi')
} else { } else {
this.setState({ this.setState({
spinner: true, spinner: true,
}) })
try { try {
let device_id = Constants.deviceId let device_id = Constants.deviceId
let os_name = Constants.platform let os_name = Constants.platform
// let fb_token = await Notifications.getExpoPushTokenAsync(); // let fb_token = await Notifications.getExpoPushTokenAsync();
let os_version = Platform.Version let os_version = Platform.Version
if (this.props.device_id) { if (this.props.device_id) {
this.setState({ this.setState({
device_id: this.props.device_id, device_id: this.props.device_id,
os_name: os_name, os_name: os_name,
fb_token: fb_token, fb_token: fb_token,
os_version: os_version, os_version: os_version,
}) })
} else { } else {
let deviceInfoProps = { let deviceInfoProps = {
device_id: device_id, device_id: device_id,
os_name: os_name, os_name: os_name,
fb_token: fb_token, fb_token: fb_token,
os_version: os_version, os_version: os_version,
}
// console.log(deviceInfoProps);
this.props.setDeviceInfo(deviceInfoProps)
} }
// console.log(deviceInfoProps);
this.props.setDeviceInfo(deviceInfoProps)
}
} catch (error) { } catch (error) {
let device_id = Constants.deviceId
let os_name = Constants.platform
let fb_token = await Notifications.getExpoPushTokenAsync();
let os_version = Platform.Version
if (this.props.device_id) {
this.setState({
device_id: this.props.device_id,
os_name: os_name,
fb_token: fb_token,
os_version: os_version,
})
} else {
let deviceInfoProps = {
device_id: device_id,
os_name: os_name,
os_version: os_version,
fb_token: fb_token,
}
this.props.setDeviceInfo(deviceInfoProps)
}
let device_id = Constants.deviceId this.state.os_name = '';
let os_name = Constants.platform this.state.os_version = '';
let fb_token = await Notifications.getExpoPushTokenAsync(); this.state.fb_token = '';
let os_version = Platform.Version }
if (this.props.device_id) { if (this.props.app_version) {
this.setState({ this.setState({
device_id: this.props.device_id, app_version: this.props.app_version
os_name: os_name,
fb_token: fb_token,
os_version: os_version,
}) })
} else { } else {
let deviceInfoProps = { this.setState({
device_id: device_id, app_version: 'Unknown'
os_name: os_name, })
os_version: os_version,
fb_token: fb_token,
}
this.props.setDeviceInfo(deviceInfoProps)
} }
this.state.os_name = ''; //get request
this.state.os_version = ''; let params = {
this.state.fb_token = ''; "email": this.state.email,
} "password": this.state.password,
"fb_token": this.state.fb_token,
if (this.props.app_version) { "device_id": this.state.device_id,
this.setState({ "os_name": this.state.os_name,
app_version: this.props.app_version "os_version": this.state.os_version,
}) "app_version": this.state.app_version,
} else {
this.setState({
app_version: 'Unknown'
})
}
//get request
let params = {
"email": this.state.email,
"password": this.state.password,
"fb_token": this.state.fb_token,
"device_id": this.state.device_id,
"os_name": this.state.os_name,
"os_version": this.state.os_version,
"app_version": this.state.app_version,
}
// console.log(params)
Axios.post(BASE_URL_LOGIN, params).then(res => {
const navigation = this.props.navigation
let loginProps = {
email: this.state.email,
password: this.state.password,
session_id: res.data.session_id
} }
// console.log(params)
Axios.post(BASE_URL_LOGIN, params).then(res => {
let prosesProps = { const navigation = this.props.navigation
proses:'Register'
}
this.props.setProses(prosesProps);
this.props.setLoginInfo(loginProps);
this.setState({
spinner: false,
})
navigation.reset({
index: 0,
routes: [
{
name: 'Home',
params: { someParam: 'Param1' },
},
],
})
console.log("INI SESSION : " + this.props.session_id)
}).catch(error => {
let response = error.response.data;
if (response.code === "NEED_VERIFICATION") {
let loginProps = { let loginProps = {
email: this.state.email, email: this.state.email,
password: this.state.password, password: this.state.password,
session_id: res.data.session_id
} }
let emailConfirmProps = {
isEmailverif: true let prosesProps = {
} proses: 'Register'
let pageProps = {
pageEmailConfirmation:true
} }
this.props.setLoginInfo(loginProps) this.props.setProses(prosesProps);
this.props.setEmailConfirm(emailConfirmProps) this.props.setLoginInfo(loginProps);
this.props.setPage(pageProps)
this.setState({ this.setState({
spinner: false, spinner: false,
}) })
this.props.navigation.navigate('Email Confirmation')
} else { navigation.reset({
let response = error.response.data; index: 0,
Alert.alert(response.msg); routes: [
this.setState({ {
spinner: false, name: 'Home',
params: { someParam: 'Param1' },
},
],
}) })
}
}) console.log("INI SESSION : " + this.props.session_id)
}).catch(error => {
let response = error.response.data;
if (response.code === "NEED_VERIFICATION") {
let loginProps = {
email: this.state.email,
password: this.state.password,
}
let emailConfirmProps = {
isEmailverif: true
}
let pageProps = {
pageEmailConfirmation: true
}
this.props.setLoginInfo(loginProps)
this.props.setEmailConfirm(emailConfirmProps)
this.props.setPage(pageProps)
this.setState({
spinner: false,
})
this.props.navigation.navigate('Email Confirmation')
} else {
let response = error.response.data;
Alert.alert(response.msg);
this.setState({
spinner: false,
})
}
})
}
} }
}
render() { render() {
return ( return (
<View style={styles.container}> <View style={styles.container}>
<Spinner <View style={{ flex: 2 }}>
visible={this.state.spinner} <View style={{ flex: 1, flexDirection: 'row' }}>
textContent={'Loading...'} <View style={{ flex: 3 }}>
textStyle={styles.spinnerTextStyle} <Image
/> style={{ height: '100%', width: '100%' }}
<View style={styles.form}> source={require('../assets/images/daun.png')}
<View style={{ marginRight: 10, marginLeft: 10, }}> />
<Text style={{ top: 5 }}>Email</Text> </View>
<View style={{ flex: 6 }}>
<Image
style={{ height: 150, width: 150, alignSelf: 'center', top: '20%' }}
source={require('../assets/excelso.png')}
/>
</View>
</View> </View>
<View style={{ margin: 10 }}> </View>
<View style={{ flex: 1, marginRight: 20, marginLeft: 20 }}>
<View style={{ flex: 1, marginRight: 20, marginLeft: 20 }}>
<Text style={{color:'white',textAlign:'center'}}>Email</Text>
<TextInput <TextInput
style={{ height: 40, borderColor: 'gray', borderWidth: 1, padding: 5 }} style={{ height: 40, borderColor: 'gray', borderWidth: 1, padding: 5, borderRadius: 20 }}
onChangeText={(email) => this.setState({ email })} onChangeText={(email) => this.setState({ email })}
autoCapitalize="none" autoCapitalize="none"
value={this.state.email} value={this.state.email}
keyboardType='email-address' keyboardType='email-address'
/> />
</View> </View>
<View style={{ marginRight: 10, marginLeft: 10 }}> <View style={{ flex: 1, marginRight: 20, marginLeft: 20 }}>
<Text style={{ top: 5 }}>{i18n.t('password')}</Text> <Text style={{color:'white',textAlign:'center'}}>Password</Text>
</View>
<View style={{ margin: 10 }}>
<TextInput <TextInput
style={{ height: 40, borderColor: 'gray', borderWidth: 1, padding: 5 }} style={{ height: 40, borderColor: 'gray', borderWidth: 1, padding: 5, borderRadius: 20 }}
onChangeText={password => this.setState({ password })} onChangeText={password => this.setState({ password })}
value={this.state.password} value={this.state.password}
secureTextEntry={true} secureTextEntry={true}
/> />
</View> </View>
<View style={{ marginRight: 10, marginLeft: 10 }}>
<Button
title={i18n.t('login')}
onPress={() => this.handleLoggin()}
/>
</View>
</View>
<View style={styles.footer}>
<View style={styles.container_register}>
<View style={{ flex: 1 }}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('New Register')}>
<Text style={{ fontSize: 20 }}>{i18n.t('register')}</Text>
</TouchableOpacity>
</View>
<View style={{ flex: 1, }}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Reset Password')}>
<Text style={{ fontSize: 20, textAlign: 'right' }}>{i18n.t('forgotPassword')}</Text>
</TouchableOpacity>
</View>
</View>
</View> </View>
<View style={{ flex: 1, }}></View>
</View> </View>
) )
} }
...@@ -247,7 +231,7 @@ class Login extends React.Component { ...@@ -247,7 +231,7 @@ class Login extends React.Component {
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
flex: 1, flex: 1,
backgroundColor: 'white', backgroundColor: '#151515',
}, },
form: { form: {
...@@ -322,4 +306,62 @@ const mapStateToProps = (state) => { ...@@ -322,4 +306,62 @@ const mapStateToProps = (state) => {
} }
} }
export default connect(mapStateToProps, mapDispatchToProps)(Login); export default connect(mapStateToProps, mapDispatchToProps)(Login);
\ No newline at end of file
// <Spinner
// visible={this.state.spinner}
// textContent={'Loading...'}
// textStyle={styles.spinnerTextStyle}
// />
// <View style={styles.form}>
// <View style={{ marginRight: 10, marginLeft: 10, }}>
// <Text style={{ top: 5 }}>Email</Text>
// </View>
// <View style={{ margin: 10 }}>
// <TextInput
// style={{ height: 40, borderColor: 'gray', borderWidth: 1, padding: 5 }}
// onChangeText={(email) => this.setState({ email })}
// autoCapitalize="none"
// value={this.state.email}
// keyboardType='email-address'
// />
// </View>
// <View style={{ marginRight: 10, marginLeft: 10 }}>
// <Text style={{ top: 5 }}>{i18n.t('password')}</Text>
// </View>
// <View style={{ margin: 10 }}>
// <TextInput
// style={{ height: 40, borderColor: 'gray', borderWidth: 1, padding: 5 }}
// onChangeText={password => this.setState({ password })}
// value={this.state.password}
// secureTextEntry={true}
// />
// </View>
// <View style={{ marginRight: 10, marginLeft: 10 }}>
// <Button
// title={i18n.t('login')}
// onPress={() => this.handleLoggin()}
// />
// </View>
// </View>
// <View style={styles.footer}>
// <View style={styles.container_register}>
// <View style={{ flex: 1 }}>
// <TouchableOpacity onPress={() => this.props.navigation.navigate('New Register')}>
// <Text style={{ fontSize: 20 }}>{i18n.t('register')}</Text>
// </TouchableOpacity>
// </View>
// <View style={{ flex: 1, }}>
// <TouchableOpacity onPress={() => this.props.navigation.navigate('Reset Password')}>
// <Text style={{ fontSize: 20, textAlign: 'right' }}>{i18n.t('forgotPassword')}</Text>
// </TouchableOpacity>
// </View>
// </View>
// </View>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment