Commit 4fa9ef38 authored by Trisno's avatar Trisno

tambah function untuk open settings

parent 550c8306
......@@ -3095,6 +3095,11 @@
"expo-permissions": "*"
}
},
"expo-intent-launcher": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/expo-intent-launcher/-/expo-intent-launcher-8.0.0.tgz",
"integrity": "sha512-Rf+AprbFKJx4YH1+DooCGg92Y4jjlP3iMpW3rpinTD4N1TJzqkpsflMphARGsF/GKxcrhzvqX52D/JrmXrcjhA=="
},
"expo-keep-awake": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/expo-keep-awake/-/expo-keep-awake-8.0.0.tgz",
......
......@@ -83,7 +83,8 @@
"redux": "^4.0.5",
"redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0",
"sentry-expo": "^2.0.4"
"sentry-expo": "^2.0.4",
"expo-intent-launcher": "~8.0.0"
},
"devDependencies": {
"babel-preset-expo": "~8.0.0",
......
......@@ -6,7 +6,7 @@ import * as Location from 'expo-location';
import * as Permissions from 'expo-permissions';
import i18n from 'i18n-js';
import React from 'react';
import { ActivityIndicator, Alert, Image, ImageBackground, ScrollView, StatusBar, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import { ActivityIndicator, Alert, Image, ImageBackground, ScrollView, StatusBar, StyleSheet, Text, TouchableOpacity, View, Platform, Linking } from 'react-native';
import { Card } from 'react-native-shadow-cards';
import Toast from 'react-native-tiny-toast';
import NumberFormat from 'react-number-format';
......@@ -15,6 +15,7 @@ import requestParams from '../helper/requestParams';
import ActionType from '../redux/globalActionType';
import CustomIosStatusBar from './CustomIosStatusBar';
import Spinner from 'react-native-loading-spinner-overlay';
import * as IntentLauncher from 'expo-intent-launcher';
class Account extends React.Component {
......@@ -68,11 +69,31 @@ class Account extends React.Component {
}
openSetting = () => {
if (Platform.OS == 'ios') {
Linking.openURL('app-settings:')
}
else {
IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS);
}
}
_getPermissions = async () => {
try {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') {
Alert.alert(i18n.t('accessNotPermitted'))
Alert.alert(
i18n.t('titleAlertLocationNotPermitted'),
i18n.t('accessNotPermitted'),
[
{
text: i18n.t('selectOpenSetting'),
onPress: () => this.openSetting()
}
],
{ cancelable: false }
)
} else if (Platform.OS === 'android' && !Device.isDevice) {
Alert.alert(i18n.t('tryItRealDevice'))
......@@ -119,9 +140,9 @@ class Account extends React.Component {
}
handleClaimCredit() {
this.setState({spinner: true})
this.setState({old_balance_claimed: true}) /** set jadi true dulu buat hilangkan bagian claim credit */
this.setState({indicator: true}) /** atau sekalian dibuat loading aja bagian profilecardnya */
this.setState({ spinner: true })
this.setState({ old_balance_claimed: true }) /** set jadi true dulu buat hilangkan bagian claim credit */
this.setState({ indicator: true }) /** atau sekalian dibuat loading aja bagian profilecardnya */
let params = Object.assign(requestParams, {
session_id: this.props.session_id,
......@@ -129,7 +150,7 @@ class Account extends React.Component {
// console.log("start processing claim_old_balance")
Axios.post(this.props.BASE_URL + 'crm/v2/card/claim_old_balance', params).then(res => {
// console.log("success processing claim_old_balance")
this.setState({spinner: false})
this.setState({ spinner: false })
this._getProfile()
// Alert.alert(i18n.t('success'), i18n.t('alertclaimcredit'))
}).catch(error => {
......@@ -141,7 +162,7 @@ class Account extends React.Component {
response.msg,
[
{
text: 'OK', onPress: () => this.setState({spinner: false})
text: 'OK', onPress: () => this.setState({ spinner: false })
}
]
);
......@@ -398,7 +419,7 @@ class Account extends React.Component {
</View>
{/* <View style={styles.line2}></View> */}
<View style={{ flexDirection: 'row', flex: 1, display:'none' }}>
<View style={{ flexDirection: 'row', flex: 1, display: 'none' }}>
<View style={{ flex: 0.3, justifyContent: 'center' }}>
{/* <Text>{i18n.t('balance')}</Text> */}
<Text style={{ fontSize: 14, fontFamily: 'Gotham-Light' }}>{i18n.t('point')}</Text>
......@@ -443,13 +464,13 @@ class Account extends React.Component {
</TouchableOpacity>
{/* Member Card */}
<View style={{ marginVertical:30, marginHorizontal:20 }}>
<View style={{ marginVertical: 30, marginHorizontal: 20 }}>
<ImageBackground style={{ width: 350, height: 210 }}
resizeMode='stretch' source={this.state.img_card ? { uri: this.state.img_card } : null}>
<View style={{ justifyContent: 'center' }}>
<Text style={{
fontFamily: 'Gotham-Black', fontSize: 20, color: '#c9af6d',
top: 160, left:30
top: 160, left: 30
}}>
{this.state.card_number}
</Text>
......@@ -553,24 +574,24 @@ Account.navigationOptions = {
const styles = StyleSheet.create({
action_grid_container: {
flex:1, flexDirection: 'row', flexWrap: 'wrap',
flex: 1, flexDirection: 'row', flexWrap: 'wrap',
marginLeft: 10,
marginRight: 10
},
action_grid_col: {
flexBasis:'50%',
paddingLeft:10,
paddingRight:10,
flexBasis: '50%',
paddingLeft: 10,
paddingRight: 10,
marginBottom: 20
},
action_grid_col_full: {
flexBasis:'100%',
paddingLeft:10,
paddingRight:10,
flexBasis: '100%',
paddingLeft: 10,
paddingRight: 10,
marginBottom: 20
},
action_grid_card:{
action_grid_card: {
height: 120,
width: "100%",
backgroundColor: "#FCFCFC",
......@@ -580,11 +601,11 @@ const styles = StyleSheet.create({
justifyContent: 'flex-start',
padding: 15,
},
action_grid_icon:{
action_grid_icon: {
height: 50, width: 50,
justifyContent: 'center'
},
action_grid_text:{
action_grid_text: {
fontFamily: 'Gotham-Black', textAlign: 'center', top: 5, fontSize: 14, color: '#838383'
},
......
......@@ -5,12 +5,13 @@ import * as Location from 'expo-location';
import * as Permissions from 'expo-permissions';
import i18n from 'i18n-js';
import React from 'react';
import { ActivityIndicator, Alert, Platform, StyleSheet, Text, TextInput, View, KeyboardAvoidingView } from 'react-native';
import { ActivityIndicator, Alert, Platform, StyleSheet, Text, TextInput, View, KeyboardAvoidingView, Linking } from 'react-native';
import { ScrollView, TouchableOpacity } from 'react-native-gesture-handler';
import MapView, { PROVIDER_GOOGLE } from 'react-native-maps';
import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete';
import { connect } from 'react-redux';
import session from '../function/session';
import * as IntentLauncher from 'expo-intent-launcher';
class AddreesDetail extends React.Component {
......@@ -44,11 +45,31 @@ class AddreesDetail extends React.Component {
this._getPermissions();
}
openSetting = () => {
if (Platform.OS == 'ios') {
Linking.openURL('app-settings:')
}
else {
IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS);
}
}
//Permission (melakukan izin)
_getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') {
Alert.alert(i18n.t('accessNotPermitted'))
Alert.alert(
i18n.t('titleAlertLocationNotPermitted'),
i18n.t('accessNotPermitted'),
[
{
text: i18n.t('selectOpenSetting'),
onPress: () => this.openSetting()
}
],
{ cancelable: false }
)
} else if (Platform.OS === 'android' && !Device.isDevice) {
Alert.alert(i18n.t('tryItRealDevice'))
......@@ -311,7 +332,7 @@ class AddreesDetail extends React.Component {
}}
/>
</View>
<View style={{ flex: 1, margin: 5 , display:'none'}} >
<View style={{ flex: 1, margin: 5, display: 'none' }} >
<TouchableOpacity onPress={() => this._searchLocation()}>
<Ionicons name="ios-search" size={32} color="#ccb46c" />
</TouchableOpacity>
......
......@@ -5,12 +5,13 @@ import * as Location from 'expo-location';
import * as Permissions from 'expo-permissions';
import i18n from 'i18n-js';
import React from 'react';
import { ActivityIndicator, Alert, Platform, StyleSheet, Text, TextInput, View, KeyboardAvoidingView } from 'react-native';
import { ActivityIndicator, Alert, Platform, StyleSheet, Text, TextInput, View, KeyboardAvoidingView, Linking } from 'react-native';
import { ScrollView, TouchableOpacity } from 'react-native-gesture-handler';
import MapView, { PROVIDER_GOOGLE } from 'react-native-maps';
import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete';
import { connect } from 'react-redux';
import session from '../function/session';
import * as IntentLauncher from 'expo-intent-launcher';
class EditAddressDetail extends React.Component {
......@@ -44,11 +45,31 @@ class EditAddressDetail extends React.Component {
this._getPermissions();
}
openSetting = () => {
if (Platform.OS == 'ios') {
Linking.openURL('app-settings:')
}
else {
IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS);
}
}
//Permission (melakukan izin)
_getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') {
Alert.alert(i18n.t('accessNotPermitted'))
Alert.alert(
i18n.t('titleAlertLocationNotPermitted'),
i18n.t('accessNotPermitted'),
[
{
text: i18n.t('selectOpenSetting'),
onPress: () => this.openSetting()
}
],
{ cancelable: false }
)
} else if (Platform.OS === 'android' && !Device.isDevice) {
Alert.alert(i18n.t('tryItRealDevice'))
......@@ -79,7 +100,7 @@ class EditAddressDetail extends React.Component {
let postalCode = detail[0].postalCode
let latitude = parseFloat(this.props.route.params.lat);
let longitude = parseFloat(this.props.route.params.long);
this.setState({ latitude: latitude, longitude: longitude})
this.setState({ latitude: latitude, longitude: longitude })
if (street == null) {
let str_city = city.replace('null', '')
......@@ -151,8 +172,8 @@ class EditAddressDetail extends React.Component {
}
this.setState({
name:this.props.route.params.name,
description:this.props.route.params.address
name: this.props.route.params.name,
description: this.props.route.params.address
})
......@@ -322,7 +343,7 @@ class EditAddressDetail extends React.Component {
}}
/>
</View>
<View style={{ flex: 1, margin: 5 , display:'none'}} >
<View style={{ flex: 1, margin: 5, display: 'none' }} >
<TouchableOpacity onPress={() => this._searchLocation()}>
<Ionicons name="ios-search" size={32} color="#ccb46c" />
</TouchableOpacity>
......
......@@ -5,7 +5,7 @@ import * as Location from 'expo-location';
import * as Permissions from 'expo-permissions';
import i18n from 'i18n-js';
import * as React from 'react';
import { ActivityIndicator, Alert, Dimensions, Platform, ScrollView, StatusBar, StyleSheet, Text, TouchableOpacity, View, PermissionStatus } from 'react-native';
import { ActivityIndicator, Alert, Dimensions, Platform, ScrollView, StatusBar, StyleSheet, Text, TouchableOpacity, View, PermissionStatus, Linking } from 'react-native';
import { Badge } from 'react-native-elements';
import { SliderBox } from "react-native-image-slider-box";
import { Card } from 'react-native-shadow-cards';
......@@ -17,6 +17,7 @@ import requestParams from '../helper/requestParams';
import ActionType from '../redux/globalActionType';
import CustomIosStatusBar from './CustomIosStatusBar';
import Spinner from 'react-native-loading-spinner-overlay';
import * as IntentLauncher from 'expo-intent-launcher';
......@@ -127,6 +128,16 @@ class Home extends React.Component {
this._unsubscribe();
}
openSetting = () => {
if (Platform.OS == 'ios') {
Linking.openURL('app-settings:')
}
else {
IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS);
}
}
settings() {
//disini masukin open settings
this._getPermissions()
......@@ -142,7 +153,7 @@ class Home extends React.Component {
[
{
text: i18n.t('selectOpenSetting'),
onPress: () => this.settings()
onPress: () => this.openSetting()
}
],
{ cancelable: false }
......
import React from 'react';
import { View, Text, StyleSheet, ScrollView, Platform, TouchableOpacity, Image, FlatList, Button, StatusBar, ActivityIndicator, Alert, Modal } from 'react-native';
import { View, Text, StyleSheet, ScrollView, Platform, TouchableOpacity, Image, FlatList, Button, StatusBar, ActivityIndicator, Alert, Modal, Linking } from 'react-native';
import Axios from 'axios';
import Item from './Item';
import { connect } from 'react-redux';
......@@ -16,6 +16,7 @@ import Constants from 'expo-constants';
import requestParams from '../helper/requestParams';
import CustomIosStatusBar from './CustomIosStatusBar';
import Spinner from 'react-native-loading-spinner-overlay';
import * as IntentLauncher from 'expo-intent-launcher';
class MenuSelection extends React.Component {
constructor(props) {
......@@ -71,11 +72,31 @@ class MenuSelection extends React.Component {
this._unsubscribe();
}
openSetting = () => {
if (Platform.OS == 'ios') {
Linking.openURL('app-settings:')
}
else {
IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS);
}
}
_getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') {
Alert.alert(i18n.t('accessNotPermitted'))
Alert.alert(
i18n.t('titleAlertLocationNotPermitted'),
i18n.t('accessNotPermitted'),
[
{
text: i18n.t('selectOpenSetting'),
onPress: () => this.openSetting()
}
],
{ cancelable: false }
)
} else if (Platform.OS === 'android' && !Device.isDevice) {
Alert.alert(i18n.t('tryItRealDevice'))
......
......@@ -13,6 +13,7 @@ import RNPickerSelect from 'react-native-picker-select';
import { connect } from 'react-redux';
import requestParams from '../helper/requestParams';
import CustomIosStatusBar from './CustomIosStatusBar';
import * as IntentLauncher from 'expo-intent-launcher';
class Outlets extends React.Component {
......@@ -57,10 +58,30 @@ class Outlets extends React.Component {
// this._unsubscribe()
// }
openSetting = () => {
if (Platform.OS == 'ios') {
Linking.openURL('app-settings:')
}
else {
IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS);
}
}
_getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') {
Alert.alert(i18n.t('accessNotPermitted'))
Alert.alert(
i18n.t('titleAlertLocationNotPermitted'),
i18n.t('accessNotPermitted'),
[
{
text: i18n.t('selectOpenSetting'),
onPress: () => this.openSetting()
}
],
{ cancelable: false }
)
} else if (Platform.OS === 'android' && !Device.isDevice) {
Alert.alert(i18n.t('tryItRealDevice'))
......@@ -90,11 +111,11 @@ class Outlets extends React.Component {
this.setState({
spinner: true,
})
let params = Object.assign(requestParams,{
let params = Object.assign(requestParams, {
session_id: this.props.session_id,
})
Axios.post(this.props.BASE_URL+"crm/v2/outlet/get_list", params).then(res => {
Axios.post(this.props.BASE_URL + "crm/v2/outlet/get_list", params).then(res => {
let dataOutlets = res.data.outlets;
for (let i = 0; i < dataOutlets.length; i++) {
dataOutlets[i]['distance'] = this.distance(dataOutlets[i]['lat'], dataOutlets[i]['long']);
......@@ -145,7 +166,7 @@ class Outlets extends React.Component {
}
OrderedList() {
Axios.get(this.props.BASE_URL+'crm/v2/outlet/get_city_list').then(res => {
Axios.get(this.props.BASE_URL + 'crm/v2/outlet/get_city_list').then(res => {
let cities = res.data.city
let data_city = []
......@@ -267,7 +288,7 @@ class Outlets extends React.Component {
textContent={'Loading...'}
textStyle={styles.spinnerTextStyle}
/> */}
{Platform.OS === 'ios' && <CustomIosStatusBar color='#CFB368'/>}
{Platform.OS === 'ios' && <CustomIosStatusBar color='#CFB368' />}
<View style={{ flex: 1 }}>
<MapView style={{ flex: 1, marginRight: 10, marginLeft: 10 }}
region={{
......@@ -296,7 +317,7 @@ class Outlets extends React.Component {
<View style={{ flex: 1 }}></View>
<View style={{ flex: 1, justifyContent: 'center' }}>
<RNPickerSelect
placeholder={{ label: i18n.t('allcity')}}
placeholder={{ label: i18n.t('allcity') }}
onValueChange={(label) => this.filterData(label)}
items={this.state.data_outlet}
style={{ inputIOSContainer: { paddingVertical: 10, alignItems: 'center' } }}
......
......@@ -6,12 +6,13 @@ import * as Permissions from 'expo-permissions';
import i18n from 'i18n-js';
import _ from 'lodash';
import React from 'react';
import { ActivityIndicator, Alert, FlatList, StyleSheet, Text, TextInput, View } from 'react-native';
import { ActivityIndicator, Alert, FlatList, StyleSheet, Text, TextInput, View, Platform, Linking } from 'react-native';
import { CheckBox } from 'react-native-elements';
import { TouchableOpacity } from 'react-native-gesture-handler';
import { connect } from 'react-redux';
import ActionType from '../redux/globalActionType';
import MyStatusBar from './MyStatusBar';
import * as IntentLauncher from 'expo-intent-launcher';
class PickupName extends React.Component {
constructor(props) {
......@@ -91,10 +92,30 @@ class PickupName extends React.Component {
})
}
openSetting = () => {
if (Platform.OS == 'ios') {
Linking.openURL('app-settings:')
}
else {
IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS);
}
}
_getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') {
Alert.alert(i18n.t('accessNotPermitted'))
Alert.alert(
i18n.t('titleAlertLocationNotPermitted'),
i18n.t('accessNotPermitted'),
[
{
text: i18n.t('selectOpenSetting'),
onPress: () => this.openSetting()
}
],
{ cancelable: false }
)
} else if (Platform.OS === 'android' && !Device.isDevice) {
Alert.alert(i18n.t('tryItRealDevice'))
......
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