import React from 'react';
import { Platform, TouchableOpacity, View, Text } from 'react-native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createStackNavigator } from '@react-navigation/stack';
import { useNavigation } from '@react-navigation/native';
import Theme from '../../components/theme.style';
import Icon from '../../components/icons';
import DB from '../../components/storage/';
import Elements from '../../components/elements.js';
import HomeScreen from './home.js';
import PromosScreen from './promo/';
import IQAir from '../iqair';
import PayatpumpScreen from './../payatpump'; //disable temporarily
import StationsScreen from './station/';
import RewardsScreen from './rewards.js';
import { useDispatch, useSelector } from 'react-redux';
import { closeModal, openModal } from '../../redux/actions/AlertActions.js';
const Tab = createBottomTabNavigator();
const screenOptions = ({ route }) => ({
tabBarIcon: ({ focused, color, size }) => {
let iconName;
if (route.name === 'Home') {
iconName = focused ? 'activehome' : 'inactivehome';
return
} else if (route.name === 'Promos') {
iconName = focused ? 'activepromos' : 'inactivepromos';
return
} else if(route.name === 'Payatpump') {
iconName = focused ? 'activepayatpump' : 'activepayatpump';
return
} else if (route.name === 'Stations') {
iconName = focused ? 'activestation' : 'inactivestation';
return
} else if (route.name === 'Rewards') {
iconName = focused ? 'activerewards' : 'inactiverewards';
return
}
},
});
const PayatpumpTab = (navigation) => {
const app_theme = useSelector(state => state.appThemeReducer.theme);
const dispatch = useDispatch();
const noEmailContainer = () => {
const close = () => {
dispatch(closeModal());
}
const proceed = () => {
navigation.navigation.navigate('Payatpump');
dispatch(closeModal());
}
const update = () => {
dispatch(closeModal());
}
return (
No Email address is registered in your Account.
Update your Profile to receive an Email receipt.
Update Profile
Proceed without Updating
)
}
const onPress = async () => {
const isGuest = await DB.get("is_guest");
const user = await DB.profile();
if(isGuest) {
return dispatch(openModal({
open: true,
title: "Warning",
body: `You won't be able to access some\nof the pages unless you will enroll your\ncard or login.`,
yesText: "Okay",
yesButtonOnly: true,
theme: app_theme
}));
};
if(!user.data.email) {
return dispatch(openModal({
open: true,
children: noEmailContainer(),
theme: app_theme
}));
}
navigation.navigation.navigate('Payatpump');
}
return (
)
}
const payatpumpOption = (navigation) => {
return {
tabBarLabel: 'Pay at Pump',
tabBarButton: () => PayatpumpTab(navigation)
}
}
const tabBarOptions = {
activeTintColor: '#E74610',
inactiveTintColor: 'gray',
style: {
borderColor: 'transparent',
border: 0,
elevation: 0,
paddingTop: Platform.OS == 'ios' ? 5 : 5,
}
}
const Home = () => {
const navigation = useNavigation();
const Stack = createStackNavigator();
const navOptions = () => ({
headerShown: false
})
return (
)
}
export default function App(navigation) {
return (
{/* */}
);
}