import React, { Component } from "react";
import {
Platform,
StyleSheet,
View,
TouchableOpacity,
SafeAreaView,
ScrollView,
Image,
Linking,
Alert,
Share
} from "react-native";
import Text from "react-native-text";
import { observable } from "mobx";
import Loader from '../../components/Public/loader'
import { observer, inject } from "mobx-react/native";
import { scale, verticalScale, moderateScale } from "react-native-size-matters";
import Size from "../../config/size";
import Icon from "react-native-vector-icons/dist/Ionicons";
import { width, height } from "../../config/screen";
import theme from "../../config/colors";
import { Fonts } from "../../config/fonts";
import DrawerNavigationHeader from "../../components/Public/drawerNavigationHeader";
import language from "../../config/language";
const size = new Size();
@inject(["menuStore"], ["userStore"])
@observer
export default class Settings extends Component {
@observable
items = [
{
icon: require("../../images/settingrefer.png"),
popup: true,
id: 0
},
{
icon: require("../../images/promo.png"),
screen:'myCoupons',
popup: true,
id: 1
},
{
icon: require("../../images/settingsetting.png"),
screen: "SettingInside",
popup: false,
id: 2
},
{
icon: require("../../images/settingt_c.png"),
popup: true,
id: 3
},
{
icon: require("../../images/settingprivacy.png"),
popup: true,
id: 4
},
{
icon: require("../../images/settingcontact.png"),
popup: true,
id: 5
}
];
constructor(props) {
super(props);
this.store = this.props.menuStore;
this.userStore = this.props.userStore;
}
static navigationOptions = {
drawerLabel: "Settings",
swipeEnabled: false,
tabBarLabel: language.en.setting
};
getTitle(id) {
switch (id) {
case 0:
return this.props.userStore.text.referYourFriends;
break;
case 1:
return this.props.userStore.text.myCoupons;
case 2:
return this.props.userStore.text.setting;
break;
case 3:
return this.props.userStore.text.termandconditions;
break;
case 4:
return this.props.userStore.text.privacy;
break;
case 5:
return this.props.userStore.text.contactUs;
break;
}
}
onPressAction(index) {
if (this.items[index].popup) {
switch (index) {
case 0:
this.referYourFriender();
break;
case 1:
this.store.userCoupon(this,this.userStore.userData.data.token,true)
break;
case 3:
Linking.openURL("https://www.hangryfood.co/terms-and-conditions");
break;
case 4:
Linking.openURL("https://www.hangryfood.co/privacy-statement");
break;
case 5:
Linking.openURL("mailto:support@hangryfood.co?subject=&body=");
break;
}
} else {
// console.log(this.items[index].screen);
this.props.navigation.navigate(this.items[index].screen);
}
}
logoutAlert() {
Alert.alert(
"Logout",
"Are you sure to Logout?",
[
{
text: "Cancel",
onPress: () => console.log("Cancel Pressed"),
style: "cancel"
},
{ text: "Sure", onPress: () => this.logoutAction() }
],
{ cancelable: false }
);
}
referYourFriender() {
//const link = Platform.OS === 'ios' ? 'itms://itunes.apple.com/us/app/apple-store/1439173696?mt=8' : '';
var sharemessage = ""
if (this.userStore.language == 'english'){
sharemessage = this.store.sharemessage[0].contentEn
}else{
sharemessage = this.store.sharemessage[0].content
}
const link = "http://onelink.to/mh4dh2"
Share.share({
message: sharemessage+link,
title: "Hangry no more"
});
}
logoutAction() {
this.userStore.logoutPost(this);
}
navigatieAction(page) {
this.props.navigation.navigate(page);
}
renderItems() {
return this.items.map((item, index, array) => {
if (item.id == 1 && !this.userStore.logined) {
return null;
} else {
return (
this.onPressAction(index)}
>
{this.getTitle(item.id)}
);
}
});
}
render() {
return (
{this.renderItems()}
follow us on
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: theme.mainColor
}
});