57 lines
2.2 KiB
JavaScript
57 lines
2.2 KiB
JavaScript
/*
|
|
Предрейсовые осмотры - мобильное приложение
|
|
Оболочка приложения (status bar, общая разметка)
|
|
*/
|
|
|
|
//---------------------
|
|
//Подключение библиотек
|
|
//---------------------
|
|
|
|
const React = require('react'); //React
|
|
const { StatusBar, Platform } = require('react-native'); //Базовые компоненты
|
|
const { useAppNavigationContext } = require('./AppNavigationProvider'); //Контекст навигации
|
|
const MainScreen = require('../../screens/MainScreen'); //Главный экран
|
|
const SettingsScreen = require('../../screens/SettingsScreen'); //Экран настроек
|
|
const AuthScreen = require('../../screens/AuthScreen'); //Экран авторизации
|
|
const AdaptiveView = require('../common/AdaptiveView'); //Адаптивный контейнер
|
|
const styles = require('../../styles/layout/AppShell.styles'); //Стили оболочки
|
|
|
|
//-----------
|
|
//Тело модуля
|
|
//-----------
|
|
|
|
//Оболочка приложения
|
|
function AppShell({ isDarkMode }) {
|
|
const { currentScreen, SCREENS } = useAppNavigationContext();
|
|
|
|
const renderScreen = React.useCallback(() => {
|
|
switch (currentScreen) {
|
|
case SCREENS.MAIN:
|
|
return <MainScreen />;
|
|
case SCREENS.SETTINGS:
|
|
return <SettingsScreen />;
|
|
case SCREENS.AUTH:
|
|
return <AuthScreen />;
|
|
default:
|
|
return <MainScreen />;
|
|
}
|
|
}, [currentScreen, SCREENS.MAIN, SCREENS.SETTINGS, SCREENS.AUTH]);
|
|
|
|
//Определяем цвет status bar в зависимости от темы
|
|
const statusBarStyle = isDarkMode ? 'light-content' : 'dark-content';
|
|
const statusBarBackground = isDarkMode ? '#0F172A' : '#F8FAFC';
|
|
|
|
return (
|
|
<>
|
|
<StatusBar barStyle={statusBarStyle} backgroundColor={statusBarBackground} translucent={Platform.OS === 'android'} />
|
|
<AdaptiveView style={styles.container}>{renderScreen()}</AdaptiveView>
|
|
</>
|
|
);
|
|
}
|
|
|
|
//----------------
|
|
//Интерфейс модуля
|
|
//----------------
|
|
|
|
module.exports = AppShell;
|