kia-ml
Version:
Kia
62 lines (56 loc) • 2.1 kB
JavaScript
import React, { useState } from 'react';
import { View, ActivityIndicator } from 'react-native';
import { observer } from 'mobx-react-lite';
import { useNavigation } from '@react-navigation/native';
import { BottomNav } from '../components/bottom-nav/bottom-nav';
import * as styles from "./base-screen.style";
import { KiaHeader } from '../components/kia-header/kia-header';
import { Toast } from '../components/toast/toast';
export const BaseScreen = observer(function BaseScreen(props) {
const navigation = useNavigation();
const goBack = () => navigation.goBack();
console.log("blocked bas");
console.log(props);
const [toastVisibility, toastToggle] = useState(false);
const [toastText, toastTextToggle] = useState("");
const [toastType, toastTypeToggle] = useState("info");
const showToast = (text, type) => {
if (!toastVisibility) {
if (!type) type = 'info';
toastTextToggle(text);
toastTypeToggle(type);
toastToggle(true);
setTimeout(hideToast, 3000);
}
};
const hideToast = () => {
toastToggle(false);
toastTextToggle("");
toastTypeToggle("info");
};
if (props.toastHandler) {
props.toastHandler(showToast);
}
return /*#__PURE__*/React.createElement(View, {
style: styles.baseView
}, /*#__PURE__*/React.createElement(View, {
style: styles.headerView
}, /*#__PURE__*/React.createElement(KiaHeader, {
title: props.title,
onBackPress: goBack
})), /*#__PURE__*/React.createElement(View, {
style: styles.childView
}, props.paginatedLoading === true && /*#__PURE__*/React.createElement(View, {
style: styles.loaderView
}, /*#__PURE__*/React.createElement(ActivityIndicator, null)), /*#__PURE__*/React.createElement(View, {
style: styles.section
}, props.children)), /*#__PURE__*/React.createElement(View, {
style: styles.footerView
}, /*#__PURE__*/React.createElement(BottomNav, {
active: props.active
})), toastVisibility && /*#__PURE__*/React.createElement(Toast, {
text: toastText,
type: toastType
}));
});
//# sourceMappingURL=base-screen.js.map